summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-21 00:03:11 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-21 00:03:11 +0000
commitf741c14337dd0850a7201f5aa2185e40a625353a (patch)
treedd1dd0cf95b6117e4a8aea96317f6301eaa078ed
parentf7214b33bf5cbb85df57e8d0035af7a25826e985 (diff)
downloadmana-client-f741c14337dd0850a7201f5aa2185e40a625353a.tar.gz
mana-client-f741c14337dd0850a7201f5aa2185e40a625353a.tar.bz2
mana-client-f741c14337dd0850a7201f5aa2185e40a625353a.tar.xz
mana-client-f741c14337dd0850a7201f5aa2185e40a625353a.zip
Updates to change log, file lists, lots of doxygen comments and small changes.
-rw-r--r--ChangeLog8
-rw-r--r--file.list1
-rw-r--r--src/Makefile.am2
-rw-r--r--src/configuration.h2
-rw-r--r--src/gui/itemcontainer.h2
-rw-r--r--src/gui/newskill.cpp30
-rw-r--r--src/gui/newskill.h2
-rw-r--r--src/gui/window.cpp14
-rw-r--r--src/gui/window.h3
-rw-r--r--src/net/network.cpp2
-rw-r--r--src/resources/image.h15
-rw-r--r--src/resources/mapreader.cpp95
-rw-r--r--src/resources/mapreader.h12
-rw-r--r--src/resources/resourcemanager.h3
-rw-r--r--src/sound.cpp87
-rw-r--r--src/sound.h98
-rw-r--r--tmw.ini2
17 files changed, 215 insertions, 163 deletions
diff --git a/ChangeLog b/ChangeLog
index 9abbc502..715e16fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,14 @@
0.0.10
- Added using and dropping of items
- Added experimental support for OpenGL rendering
+- Added support for new map format in client
+- Added ability to load resources from zip files
+- Added start of a minimap
+- Added new GUI skin, wallpaper and mouse cursor
+- Reintroduced cancel button for npc choice dialog after Mra fixed it for us
- Fixed crash in fullscreen with hardware acceleration enabled (win32)
-- Reimplemented A* pathfinding, hopefully stable now
+- Reimplemented A* pathfinding, more flexible and stable now
+- Removed background music that wasn't ours
0.0.9 (30 Jan 2005)
- Replaced Allegro library with SDL, SDL_image and SDL_mixer
diff --git a/file.list b/file.list
index 7f95e206..6e0006e6 100644
--- a/file.list
+++ b/file.list
@@ -16,6 +16,7 @@ MODULES = src/sound.cpp \
src/gui/listbox.cpp \
src/gui/login.cpp \
src/gui/minimap.cpp \
+ src/gui/newskill.cpp \
src/gui/npc.cpp \
src/gui/npc_text.cpp \
src/gui/ok_dialog.cpp \
diff --git a/src/Makefile.am b/src/Makefile.am
index 696cc366..188df313 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,6 +33,8 @@ tmw_SOURCES = graphic/graphic.cpp \
gui/login.h \
gui/minimap.cpp \
gui/minimap.h \
+ gui/newskill.cpp \
+ gui/newskill.h \
gui/npc.cpp \
gui/npc.h \
gui/npc_text.cpp \
diff --git a/src/configuration.h b/src/configuration.h
index 28383765..03950230 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -75,7 +75,7 @@ class Configuration {
* \param key Option identifier.
* \param deflt Default option if not there or error.
*/
- float getValue(std::string key, float delflt);
+ float getValue(std::string key, float deflt);
private:
/**
* Returns wether they given key exists.
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 5f7b6cbe..dc88655a 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -55,8 +55,6 @@ class ItemContainer : public gcn::Widget
public:
/**
* Constructor. Initializes the graphic.
- *
- * @param path The file containing item images.
*/
ItemContainer();
diff --git a/src/gui/newskill.cpp b/src/gui/newskill.cpp
index 341fe046..c3c16f2b 100644
--- a/src/gui/newskill.cpp
+++ b/src/gui/newskill.cpp
@@ -20,7 +20,7 @@
*
* $Id$
*/
-
+
/* This file implements the new skill dialog for use under the latest
* version of the skill system as of 2005/02/20
*/
@@ -45,41 +45,41 @@ char *skill_name[] = {
"", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", ""
};
-
+
NewSkillDialog::NewSkillDialog():
Window("Skills")
{
// the window
setSize(400, 300);
-
+
// the skill labels
skillLabel = new gcn::Label[N_SKILL];
- for(int a=0;a<N_SKILL;a++) {
+ for (int a = 0; a < N_SKILL; a++) {
skillLabel[a].setCaption(skill_name[a]);
skillLabel[a].setDimension(gcn::Rectangle(8, 190, 200, 16));
}
-
+
// the close button
closeButton = new Button("Close");
closeButton->setEventId("close");
closeButton->setPosition(160, 210);
add(closeButton);
-
+
// setting up the container
skillList = new gcn::Container();
- skillList->setDimension(gcn::Rectangle(0,0,230,600));
- for(int b=0;b<N_SKILL;b++) {
- skillList->add(&skillLabel[b],20,20*b);
+ skillList->setDimension(gcn::Rectangle(0, 0, 230, 600));
+ for (int b = 0; b < N_SKILL; b++) {
+ skillList->add(&skillLabel[b], 20, 20 * b);
}
// the scroll area (content = container)
- skillScrollArea = new gcn::ScrollArea();
- skillScrollArea->setDimension(gcn::Rectangle(5, 5, 229, 300));
+ skillScrollArea = new ScrollArea();
+ skillScrollArea->setDimension(gcn::Rectangle(5, 5, 229, 290));
skillScrollArea->setContent(skillList);
add(skillScrollArea);
-
-
+
+
closeButton->addActionListener(this);
@@ -89,7 +89,7 @@ NewSkillDialog::NewSkillDialog():
NewSkillDialog::~NewSkillDialog()
{
delete skillScrollArea;
- delete skillLabel;
+ delete[] skillLabel;
delete closeButton;
}
@@ -99,4 +99,4 @@ void NewSkillDialog::action(const std::string& eventId)
{
setVisible(false);
}
-} \ No newline at end of file
+}
diff --git a/src/gui/newskill.h b/src/gui/newskill.h
index 203a686e..a3cf6c04 100644
--- a/src/gui/newskill.h
+++ b/src/gui/newskill.h
@@ -60,4 +60,4 @@ class NewSkillDialog : public Window, public gcn::ActionListener
void action(const std::string&);
};
-#endif _TMW_NSKILL_H \ No newline at end of file
+#endif
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 399cb73f..77cdec03 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -56,12 +56,12 @@ Window::Window(const std::string& text, bool modal, Window *parent):
dRightBorder = dBorders->getSubImage(7, 4, 4, 10);
dLowerBorder = dBorders->getSubImage(4, 15, 3, 4);
- dBackground->setAlpha(0.7f);
- dBorders->setAlpha(0.7f);
- dUpperBorder->setAlpha(0.7f);
- dLeftBorder->setAlpha(0.7f);
- dRightBorder->setAlpha(0.7f);
- dLowerBorder->setAlpha(0.7f);
+ dBackground->setAlpha(0.8f);
+ dBorders->setAlpha(0.8f);
+ dUpperBorder->setAlpha(0.8f);
+ dLeftBorder->setAlpha(0.8f);
+ dRightBorder->setAlpha(0.8f);
+ dLowerBorder->setAlpha(0.8f);
// Register mouse listener
addMouseListener(this);
@@ -190,7 +190,7 @@ void Window::add(gcn::Widget *w)
chrome->add(w);
}
-void Window::add(Widget *w, int x, int y)
+void Window::add(gcn::Widget *w, int x, int y)
{
chrome->add(w, x, y);
}
diff --git a/src/gui/window.h b/src/gui/window.h
index 25403851..c78de2f4 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -67,6 +67,9 @@ class Window : public gcn::Container, public gcn::MouseListener
*
* @param text The initial window title, "Window" by default.
* @param modal Block input to other windows.
+ * @param parent The parent window. This is the window standing above
+ * this one in the window hiearchy. When reordering,
+ * a window will never go below its parent window.
*/
Window(const std::string& text = "Window", bool modal = false,
Window *parent = NULL);
diff --git a/src/net/network.cpp b/src/net/network.cpp
index 2e563fb7..8ad0fd85 100644
--- a/src/net/network.cpp
+++ b/src/net/network.cpp
@@ -180,4 +180,4 @@ void flush()
#endif
} else RFIFOSET(ret); // Set size of available data to read
}
-} \ No newline at end of file
+}
diff --git a/src/resources/image.h b/src/resources/image.h
index ed1e0905..9102f62c 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -64,7 +64,12 @@ class Image : public Resource
/**
* Loads an image.
+ *
* @param filePath The path to the image file to load.
+ * @param flags These flags allow controlling the way the image is
+ * loaded. Currently only IMG_ALPHA is supported, which
+ * causes alpha layer to be preserved.
+ *
* @return <code>NULL</code> if the an error occurred, a
* valid pointer otherwise.
*/
@@ -72,10 +77,12 @@ class Image : public Resource
/**
* Loads an image from a buffer in memory.
- * @param buffer The memory buffer containing the image
- * data.
- * @return <code>NULL</code> if the an error occurred, a
- * valid pointer otherwise.
+ *
+ * @param buffer The memory buffer containing the image data.
+ * @param bufferSize The size of the memory buffer in bytes.
+ *
+ * @return <code>NULL</code> if the an error occurred, a valid pointer
+ * otherwise.
*/
static Image *load(const char* buffer, unsigned int bufferSize);
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 32b71d9c..b28515c1 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -31,6 +31,13 @@
#define DEFAULT_TILE_WIDTH 32
#define DEFAULT_TILE_HEIGHT 32
+// MSVC libxml2 at the moment doesn't work right when using MinGW, missing this
+// function at link time.
+#ifdef WIN32
+#undef xmlFree
+#define xmlFree(x) ;
+#endif
+
std::vector<Tileset*> MapReader::tilesets;
Tileset::Tileset(Image *img, int w, int h, int firstGid):
@@ -100,9 +107,7 @@ Map* MapReader::readMap(xmlNodePtr node, const std::string &path)
std::string pathDir = path.substr(0, path.rfind("/") + 1);
prop = xmlGetProp(node, BAD_CAST "version");
-#ifndef WIN32
xmlFree(prop);
-#endif
int w = getProperty(node, "width", 0);
int h = getProperty(node, "height", 0);
@@ -144,41 +149,49 @@ void MapReader::readLayer(xmlNodePtr node, Map *map, int layer)
// origin.
while (node != NULL)
{
- if (xmlStrEqual(node->name, BAD_CAST "tile") && y < h)
+ if (xmlStrEqual(node->name, BAD_CAST "data"))
{
- int gid = getProperty(node, "gid", -1);
- Image *img = NULL;
+ xmlChar *encoding = xmlGetProp(node, BAD_CAST "encoding");
+ xmlChar *compression = xmlGetProp(node, BAD_CAST "compression");
- if (gid > -1) {
- std::vector<Tileset*>::iterator i;
- Tileset *set = NULL;
+ if (encoding && xmlStrEqual(encoding, BAD_CAST "base64"))
+ {
+ xmlFree(encoding);
- // Find the tileset with the highest firstGid below/eq to gid
- for (i = tilesets.begin(); i != tilesets.end(); ++i) {
- if ((*i)->getFirstGid() <= gid) {
- set = (*i);
- }
+ if (compression) {
+ log("Warning: no layer compression supported!");
+ xmlFree(compression);
+ return;
}
- if (set && (gid - set->getFirstGid()) <
- (int)set->spriteset.size())
+ // Read base64 encoded map file
+
+ }
+ else {
+ // Read plain XML map file
+ xmlNodePtr n2 = node->xmlChildrenNode;
+
+ while (n2 != NULL)
{
- img = set->spriteset[gid - set->getFirstGid()];
+ if (xmlStrEqual(n2->name, BAD_CAST "tile") && y < h)
+ {
+ int gid = getProperty(n2, "gid", -1);
+ if (layer == 0) map->setWalk(x, y, true);
+ map->setTile(x, y, layer, getTileWithGid(gid));
+
+ x++;
+ if (x == w) {x = 0; y++;}
+ }
+
+ n2 = n2->next;
}
}
- if (layer == 0) map->setWalk(x, y, true);
- map->setTile(x, y, layer, img);
-
- x++;
- if (x == w) {x = 0; y++;}
- }
-
- if (xmlStrEqual(node->name, BAD_CAST "data")) {
- node = node->xmlChildrenNode;
- } else {
- node = node->next;
+ // There can be only one data element
+ break;
}
+
+ node = node->next;
}
}
@@ -211,9 +224,7 @@ Tileset* MapReader::readTileset(
if (tilebmp)
{
Tileset *set = new Tileset(tilebmp, tw, th, firstGid);
-#ifndef WIN32
xmlFree(source);
-#endif
return set;
}
else {
@@ -235,12 +246,34 @@ int MapReader::getProperty(xmlNodePtr node, const char* name, int def)
xmlChar *prop = xmlGetProp(node, BAD_CAST name);
if (prop) {
int val = atoi((char*)prop);
-#ifndef WIN32
xmlFree(prop);
-#endif
return val;
}
else {
return def;
}
}
+
+Image *MapReader::getTileWithGid(int gid)
+{
+ std::vector<Tileset*>::iterator i;
+ Tileset *set = NULL;
+
+ // Find the tileset with the highest firstGid below/eq to gid
+ for (i = tilesets.begin(); i != tilesets.end(); ++i)
+ {
+ if ((*i)->getFirstGid() <= gid) {
+ set = (*i);
+ }
+ else {
+ break;
+ }
+ }
+
+ if (set && (gid - set->getFirstGid()) < (int)set->spriteset.size())
+ {
+ return set->spriteset[gid - set->getFirstGid()];
+ }
+
+ return NULL;
+}
diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h
index b2a076ec..69c531de 100644
--- a/src/resources/mapreader.h
+++ b/src/resources/mapreader.h
@@ -68,21 +68,27 @@ class MapReader
private:
/**
- * Helper function that handles reading a map layer.
+ * Reads a map layer.
*/
static void readLayer(xmlNodePtr node, Map *map, int layer);
/**
- * Helper function that handles reading a tile set.
+ * Reads a tile set.
*/
static Tileset *readTileset(xmlNodePtr node, const std::string &path,
Map *map);
/**
- * Helper function to get an integer property.
+ * Gets an integer property from an xmlNodePtr.
*/
static int getProperty(xmlNodePtr node, const char* name, int def);
+ /**
+ * Converts a global tile id to the Image* pointing to the associated
+ * tile image.
+ */
+ static Image *getTileWithGid(int gid);
+
static std::vector<Tileset*> tilesets;
};
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index c3ed8904..961c000a 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -74,8 +74,9 @@ class ResourceManager
* converted into the appropriate path for the current operating system
* and the resource is loaded.
*
- * @param type The type of resource to load.
+ * @param type The type of resource to load.
* @param idPath The resource identifier path.
+ * @param flags Flags to control the loading of certain resources.
* @return A valid resource or <code>NULL</code> if the resource could
* not be loaded.
*/
diff --git a/src/sound.cpp b/src/sound.cpp
index b64af13f..2556aaa7 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -22,25 +22,12 @@
*/
#include "sound.h"
+#include "log.h"
#ifdef __DEBUG
#include <iostream>
#endif
-/**
- \brief install the sound engine
- \param voices overall reserved voices
- \param mod_voices voices dedicated for mod-playback
-
- NOTE:
- overall voices must not be less or equal to the
- specified amount of mod_voices!
- if mod-voices is too low some mods will not sound
- correctly since a couple of tracks are not going
- to be played along w/ the others. so missing ins-
- truments can be a result.
- 32/20 sounds realistic here.
-*/
void Sound::init(int voices, int mod_voices)
{
if (isOk == 0) {
@@ -49,7 +36,7 @@ void Sound::init(int voices, int mod_voices)
bgm = NULL;
int audio_rate = 44100;
- Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */
+ Uint16 audio_format = AUDIO_S16; // 16-bit stereo
int audio_channels = 2;
int audio_buffers = 4096;
@@ -67,19 +54,9 @@ void Sound::init(int voices, int mod_voices)
items = -1;
isOk = 0;
-#ifdef __DEBUG
- std::cout << "Sound::Init() Initializing Sound\n";
-#endif
+ log("Sound::Init() Initializing Sound");
}
-/**
- \brief set the volume value-range: 0-128
- \param music volume value
-
- NOTE:
- all values may only be between 0-128 where 0 means
- muted.
-*/
void Sound::setVolume(int music)
{
if (isOk == -1)
@@ -91,10 +68,6 @@ void Sound::setVolume(int music)
}
}
-/**
- \brief adjusts current volume
- \param amusic volume difference
-*/
void Sound::adjustVolume(int amusic)
{
if (isOk == -1)
@@ -106,11 +79,6 @@ void Sound::adjustVolume(int amusic)
}
}
-/**
- \brief start BGM
- \param in full path to file
- \param loop how many times should the midi be looped? (-1 = infinite)
-*/
void Sound::startBgm(char * in, int loop)
{
if (isOk == -1)
@@ -127,16 +95,6 @@ void Sound::startBgm(char * in, int loop)
#endif
}
-/**
- \brief stop all currently running BGM tracks
-
- NOTE:
- you need to stop all playback when you want to
- switch from mod to midi. playing a new track is
- usually simple as calling StartMIDI() or StartMOD() again.
- passing NULL to the playing functions only means to make
- playback stop.
-*/
void Sound::stopBgm()
{
if (isOk == -1) {
@@ -154,19 +112,6 @@ void Sound::stopBgm()
}
}
-/**
- \brief preloads a sound-item into buffer
- \param fpath full path to file
- \param type type of item (SOUND_MOD, SOUND_MID, SOUND_SFX)
-
- NOTE:
- please make sure that the object is not loaded more
- than once since the function will not run any checks
- on its own!
-
- the return value should be kept as a reference to the
- object loaded. if not it is practicaly lost.
-*/
SOUND_SID Sound::loadItem(char *fpath)
{
#ifdef __DEBUG
@@ -184,11 +129,6 @@ SOUND_SID Sound::loadItem(char *fpath)
return 0;
}
-/**
- \brief plays an item in soundpool
- \param id id returned to the item in the soundpool
- \param volume volume the sound should be played with (possible range: 0-128)
-*/
void Sound::startItem(SOUND_SID id, int volume)
{
if (soundpool[id]) {
@@ -200,9 +140,6 @@ void Sound::startItem(SOUND_SID id, int volume)
}
}
-/**
- \brief wipe all items off the cache
-*/
void Sound::clearCache()
{
for(SOUND_SID i = 0; i == items; i++) {
@@ -216,30 +153,14 @@ void Sound::clearCache()
#endif
}
-/**
- \brief deinstall all sound functionality
-
- NOTE:
- normally you won't need to call this since this is
- done by SDL when shutting itself down. but if
- you find a reason to delete the sound-engine from
- memory (e.g. garbage-collection) feel free to use
- it. :-P
-*/
void Sound::close(void)
{
isOk = -1;
clearCache();
Mix_CloseAudio();
-#ifdef __DEBUG
- std::cout << "Sound::close() shutting down Sound\n";
-#endif
+ log("Sound::close() shutting down Sound");
}
-/**
- \brief checks if value equals min-/maximum volume and returns
- true if that's the case.
-*/
bool Sound::isMaxVol(int vol)
{
if (vol > 0 && vol < 128) return false;
diff --git a/src/sound.h b/src/sound.h
index c7ca055b..465defa5 100644
--- a/src/sound.h
+++ b/src/sound.h
@@ -32,32 +32,102 @@
typedef short SOUND_SID;
-/**
- * Sound engine
+/** Sound engine
*
* \ingroup CORE
*/
class Sound {
public:
- void init(int, int);
- void close();
+ /**
+ * \brief Install the sound engine
+ *
+ * \param voices Overall reserved voices
+ * \param mod_voices Voices dedicated for mod-playback
+ *
+ * Overall voices must not be less or equal to the specified amount of
+ * mod_voices! if mod-voices is too low some mods will not sound
+ * correctly since a couple of tracks are not going to be played along
+ * w/ the others. so missing ins- truments can be a result. 32/20
+ * sounds realistic here.
+ */
+ void init(int, int);
- void startBgm(char*, int);
- void stopBgm();
+ /**
+ * \brief Deinstall all sound functionality
+ *
+ * Normally you won't need to call this since this is done by SDL when
+ * shutting itself down. but if you find a reason to delete the
+ * sound-engine from memory (e.g. garbage-collection) feel free to use
+ * it. :-P
+ */
+ void close();
+
+ /**
+ * \brief Start background music
+ *
+ * \param in Full path to file
+ * \param loop The number of times the song is played (-1 = infinite)
+ */
+ void startBgm(char*, int);
+
+ /**
+ * \brief Stop all currently running background music tracks
+ *
+ * You need to stop all playback when you want to switch from mod to
+ * midi. playing a new track is usually simple as calling StartMIDI()
+ * or StartMOD() again. passing NULL to the playing functions only
+ * means to make playback stop.
+ */
+ void stopBgm();
- void setVolume(int);
- void adjustVolume(int);
+ /**
+ * \brief Set the volume value-range: 0-128
+ *
+ * \param music Volume value
+ *
+ * All values may only be between 0-128 where 0 means muted.
+ */
+ void setVolume(int);
+
+ /**
+ * \brief Adjusts current volume
+ * \param amusic Volume difference
+ */
+ void adjustVolume(int);
+ /**
+ * \brief Preloads a sound-item into buffer
+ *
+ * \param fpath Full path to file
+ *
+ * Please make sure that the object is not loaded more than once since
+ * the function will not run any checks on its own!
+ *
+ * The return value should be kept as a reference to the object loaded.
+ * if not it is practicaly lost.
+ */
SOUND_SID loadItem(char *);
- void startItem(SOUND_SID, int);
+
+ /**
+ * \brief Plays an item in soundpool
+ *
+ * \param id Id returned to the item in the soundpool
+ * \param volume Volume the sound should be played with (possible
+ * range: 0-128)
+ */
+ void startItem(SOUND_SID, int);
- void clearCache();
+ /**
+ * \brief Wipe all items off the cache
+ */
+ void clearCache();
- Sound() {isOk=-1;}
+ Sound() { isOk = -1; }
/** if allegro is shut down or object is deleted any BGM is
stopped and SFX run out */
- ~Sound() {stopBgm(); close();};
+ ~Sound() { stopBgm(); close(); }
+
private:
/** initial value is -1 which means error or noninitialzed.
you can only play sounds and bgm if this is 0.
@@ -73,6 +143,10 @@ class Sound {
std::map<int, Mix_Chunk*> soundpool;
SOUND_SID items;
+ /**
+ * \brief checks if value equals min-/maximum volume and returns
+ * <code>true</code> if that's the case.
+ */
bool isMaxVol(int);
};
diff --git a/tmw.ini b/tmw.ini
index 1af8115a..c991eccc 100644
--- a/tmw.ini
+++ b/tmw.ini
@@ -8,5 +8,5 @@ sound=0
stretch=0
system=
url=http://localhost/
-username=Kyokai
+username=
version=0.200000