summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/action.cpp10
-rw-r--r--src/resources/action.h18
-rw-r--r--src/resources/ambientoverlay.cpp9
-rw-r--r--src/resources/ambientoverlay.h12
-rw-r--r--src/resources/animation.cpp19
-rw-r--r--src/resources/animation.h30
-rw-r--r--src/resources/colordb.cpp122
-rw-r--r--src/resources/colordb.h52
-rw-r--r--src/resources/dye.cpp9
-rw-r--r--src/resources/dye.h17
-rw-r--r--src/resources/emotedb.cpp140
-rw-r--r--src/resources/emotedb.h60
-rw-r--r--src/resources/image.cpp54
-rw-r--r--src/resources/image.h49
-rw-r--r--src/resources/imageloader.cpp13
-rw-r--r--src/resources/imageloader.h12
-rw-r--r--src/resources/imageset.cpp14
-rw-r--r--src/resources/imageset.h13
-rw-r--r--src/resources/imagewriter.cpp14
-rw-r--r--src/resources/imagewriter.h12
-rw-r--r--src/resources/itemdb.cpp45
-rw-r--r--src/resources/itemdb.h16
-rw-r--r--src/resources/iteminfo.cpp43
-rw-r--r--src/resources/iteminfo.h32
-rw-r--r--src/resources/mapreader.cpp155
-rw-r--r--src/resources/mapreader.h16
-rw-r--r--src/resources/monsterdb.cpp33
-rw-r--r--src/resources/monsterdb.h20
-rw-r--r--src/resources/monsterinfo.cpp27
-rw-r--r--src/resources/monsterinfo.h55
-rw-r--r--src/resources/music.cpp14
-rw-r--r--src/resources/music.h23
-rw-r--r--src/resources/npcdb.cpp22
-rw-r--r--src/resources/npcdb.h20
-rw-r--r--src/resources/resource.cpp15
-rw-r--r--src/resources/resource.h21
-rw-r--r--src/resources/resourcemanager.cpp31
-rw-r--r--src/resources/resourcemanager.h18
-rw-r--r--src/resources/soundeffect.cpp11
-rw-r--r--src/resources/soundeffect.h22
-rw-r--r--src/resources/spritedef.cpp21
-rw-r--r--src/resources/spritedef.h31
42 files changed, 898 insertions, 472 deletions
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index bbea45c9..e2cb11f2 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -1,31 +1,29 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "action.h"
-
#include "animation.h"
#include "../utils/dtor.h"
-
Action::Action()
{
}
diff --git a/src/resources/action.h b/src/resources/action.h
index 09eb066e..649d3828 100644
--- a/src/resources/action.h
+++ b/src/resources/action.h
@@ -1,26 +1,26 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_ACTION_H
-#define _TMW_ACTION_H
+#ifndef ACTION_H
+#define ACTION_H
#include <map>
@@ -44,11 +44,9 @@ class Action
*/
~Action();
- void
- setAnimation(int direction, Animation *animation);
+ void setAnimation(int direction, Animation *animation);
- Animation*
- getAnimation(int direction) const;
+ Animation* getAnimation(int direction) const;
protected:
typedef std::map<int, Animation*> Animations;
diff --git a/src/resources/ambientoverlay.cpp b/src/resources/ambientoverlay.cpp
index 9eee57f0..32ed47d1 100644
--- a/src/resources/ambientoverlay.cpp
+++ b/src/resources/ambientoverlay.cpp
@@ -1,26 +1,25 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ambientoverlay.h"
-
#include "image.h"
#include "../graphics.h"
diff --git a/src/resources/ambientoverlay.h b/src/resources/ambientoverlay.h
index 56c70066..65f9891d 100644
--- a/src/resources/ambientoverlay.h
+++ b/src/resources/ambientoverlay.h
@@ -1,26 +1,26 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_RESOURCES_AMBIENTOVERLAY_H_
-#define _TMW_RESOURCES_AMBIENTOVERLAY_H_
+#ifndef RESOURCES_AMBIENTOVERLAY_H
+#define RESOURCES_AMBIENTOVERLAY_H
class Graphics;
class Image;
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp
index d2794e61..54c319de 100644
--- a/src/resources/animation.cpp
+++ b/src/resources/animation.cpp
@@ -1,28 +1,26 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "animation.h"
-#include <algorithm>
-
#include "../utils/dtor.h"
Animation::Animation():
@@ -30,22 +28,19 @@ Animation::Animation():
{
}
-void
-Animation::addFrame(Image *image, unsigned int delay, int offsetX, int offsetY)
+void Animation::addFrame(Image *image, unsigned int delay, int offsetX, int offsetY)
{
Frame frame = { image, delay, offsetX, offsetY };
mFrames.push_back(frame);
mDuration += delay;
}
-void
-Animation::addTerminator()
+void Animation::addTerminator()
{
addFrame(NULL, 0, 0, 0);
}
-bool
-Animation::isTerminator(const Frame &candidate)
+bool Animation::isTerminator(const Frame &candidate)
{
return (candidate.image == NULL);
}
diff --git a/src/resources/animation.h b/src/resources/animation.h
index 8dfe8614..0c461ebe 100644
--- a/src/resources/animation.h
+++ b/src/resources/animation.h
@@ -1,26 +1,26 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_ANIMATION_H
-#define _TMW_ANIMATION_H
+#ifndef ANIMATION_H
+#define ANIMATION_H
#include <vector>
@@ -54,39 +54,33 @@ class Animation
/**
* Appends a new animation at the end of the sequence.
*/
- void
- addFrame(Image *image, unsigned int delay, int offsetX, int offsetY);
+ void addFrame(Image *image, unsigned int delay, int offsetX, int offsetY);
/**
* Appends an animation terminator that states that the animation
* should not loop.
*/
- void
- addTerminator();
+ void addTerminator();
/**
* Returns the frame at the specified index.
*/
- Frame*
- getFrame(int index) { return &(mFrames[index]); }
+ Frame* getFrame(int index) { return &(mFrames[index]); }
/**
* Returns the length of this animation in frames.
*/
- unsigned int
- getLength() const { return mFrames.size(); }
+ unsigned int getLength() const { return mFrames.size(); }
/**
* Returns the duration of this animation.
*/
- int
- getDuration() const { return mDuration; }
+ int getDuration() const { return mDuration; }
/**
* Determines whether the given animation frame is a terminator.
*/
- static bool
- isTerminator(const Frame &phase);
+ static bool isTerminator(const Frame &phase);
protected:
std::vector<Frame> mFrames;
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
new file mode 100644
index 00000000..3a8754ea
--- /dev/null
+++ b/src/resources/colordb.cpp
@@ -0,0 +1,122 @@
+/*
+ * Color database
+ * Copyright (C) 2008 Aethyra Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <libxml/tree.h>
+
+#include "colordb.h"
+
+#include "../log.h"
+
+#include "../utils/xml.h"
+
+#define HAIR_COLOR_FILE "colors.xml"
+#define TMW_COLOR_FILE "hair.xml"
+
+namespace
+{
+ ColorDB::Colors mColors;
+ bool mLoaded = false;
+ std::string mFail = "#ffffff";
+}
+
+void ColorDB::load()
+{
+ if (mLoaded)
+ {
+ return;
+ }
+
+ XML::Document *doc = new XML::Document(HAIR_COLOR_FILE);
+ xmlNodePtr root = doc->rootNode();
+ bool TMWHair = false;
+
+ if (!root || !xmlStrEqual(root->name, BAD_CAST "colors"))
+ {
+ logger->log("Trying TMW's color file, %s.", TMW_COLOR_FILE);
+
+ TMWHair = true;
+
+ delete doc;
+
+ doc = new XML::Document(TMW_COLOR_FILE);
+ root = doc->rootNode();
+ if (!root || !xmlStrEqual(root->name, BAD_CAST "colors"))
+ {
+ logger->log("ColorDB: Failed");
+ mColors[0] = mFail;
+ mLoaded = true;
+
+ delete doc;
+
+ return;
+ }
+ }
+ for_each_xml_child_node(node, root)
+ {
+ if (xmlStrEqual(node->name, BAD_CAST "color"))
+ {
+ int id = XML::getProperty(node, "id", 0);
+
+ if (mColors.find(id) != mColors.end())
+ {
+ logger->log("ColorDB: Redefinition of dye ID %d", id);
+ }
+
+ TMWHair ? mColors[id] = XML::getProperty(node, "value", "#FFFFFF") :
+ mColors[id] = XML::getProperty(node, "dye", "#FFFFFF");
+ }
+ }
+
+ delete doc;
+
+ mLoaded = true;
+}
+
+void ColorDB::unload()
+{
+ logger->log("Unloading color database...");
+
+ mColors.clear();
+ mLoaded = false;
+}
+
+std::string& ColorDB::get(int id)
+{
+ if (!mLoaded)
+ load();
+
+ ColorIterator i = mColors.find(id);
+
+ if (i == mColors.end())
+ {
+ logger->log("ColorDB: Error, unknown dye ID# %d", id);
+ return mFail;
+ }
+ else
+ {
+ return i->second;
+ }
+}
+
+int ColorDB::size()
+{
+ return mColors.size();
+}
diff --git a/src/resources/colordb.h b/src/resources/colordb.h
new file mode 100644
index 00000000..c581f653
--- /dev/null
+++ b/src/resources/colordb.h
@@ -0,0 +1,52 @@
+/*
+ * Color database
+ * Copyright (C) 2008 Aethyra Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef COLOR_MANAGER_H
+#define COLOR_MANAGER_H
+
+#include <map>
+#include <string>
+
+/**
+ * The class that holds the color information.
+ */
+namespace ColorDB
+{
+ /**
+ * Loads the color data from <code>colors.xml</code>.
+ */
+ void load();
+
+ /**
+ * Clear the color data
+ */
+ void unload();
+
+ std::string& get(int id);
+
+ int size();
+
+ // Color DB
+ typedef std::map<int, std::string> Colors;
+ typedef Colors::iterator ColorIterator;
+}
+
+#endif
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index d180d725..22bd2411 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -1,25 +1,24 @@
/*
* The Mana World
- * Copyright 2007 The Mana World Development Team
+ * Copyright (C) 2007 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
#include <sstream>
#include "dye.h"
diff --git a/src/resources/dye.h b/src/resources/dye.h
index f0bd7aab..3cef334a 100644
--- a/src/resources/dye.h
+++ b/src/resources/dye.h
@@ -1,27 +1,28 @@
/*
* The Mana World
- * Copyright 2007 The Mana World Development Team
+ * Copyright (C) 2007 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_DYE_H
-#define _TMW_DYE_H
+#ifndef DYE_H
+#define DYE_H
+#include <string>
#include <vector>
/**
@@ -36,7 +37,7 @@ class Palette
* The string is either a file name or a sequence of hexadecimal RGB
* values separated by ',' and starting with '#'.
*/
- Palette(const std::string &);
+ Palette(const std::string &pallete);
/**
* Gets a pixel color depending on its intensity.
@@ -63,7 +64,7 @@ class Dye
* The parts of string are separated by semi-colons. Each part starts
* by an uppercase letter, followed by a colon and then a palette name.
*/
- Dye(const std::string &);
+ Dye(const std::string &dye);
/**
* Destroys the associated palettes.
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
new file mode 100644
index 00000000..5e9a146c
--- /dev/null
+++ b/src/resources/emotedb.cpp
@@ -0,0 +1,140 @@
+/*
+ * Emote database
+ * Copyright (C) 2009 Aethyra Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "emotedb.h"
+
+#include "../log.h"
+
+#include "../utils/xml.h"
+
+namespace
+{
+ EmoteInfos mEmoteInfos;
+ EmoteInfo mUnknown;
+ bool mLoaded = false;
+ int mLastEmote = 0;
+}
+
+void EmoteDB::load()
+{
+ if (mLoaded)
+ return;
+
+ mLastEmote = 0;
+
+ EmoteSprite *unknownSprite = new EmoteSprite;
+ unknownSprite->sprite = "error.xml";
+ unknownSprite->name = "unknown";
+ unknownSprite->variant = 0;
+ mUnknown.sprites.push_back(unknownSprite);
+
+ logger->log("Initializing emote database...");
+
+ XML::Document doc("emotes.xml");
+ xmlNodePtr rootNode = doc.rootNode();
+
+ if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "emotes"))
+ {
+ logger->log("Emote Database: Error while loading emotes.xml!");
+ return;
+ }
+
+ //iterate <emote>s
+ for_each_xml_child_node(emoteNode, rootNode)
+ {
+ if (!xmlStrEqual(emoteNode->name, BAD_CAST "emote"))
+ continue;
+
+ int id = XML::getProperty(emoteNode, "id", -1);
+ if (id == -1)
+ {
+ logger->log("Emote Database: Emote with missing ID in emotes.xml!");
+ continue;
+ }
+
+ EmoteInfo *currentInfo = new EmoteInfo;
+
+ for_each_xml_child_node(spriteNode, emoteNode)
+ {
+ if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
+ {
+ EmoteSprite *currentSprite = new EmoteSprite;
+ currentSprite->sprite = (const char*) spriteNode->xmlChildrenNode->content;
+ currentSprite->variant = XML::getProperty(spriteNode, "variant", 0);
+ currentInfo->sprites.push_back(currentSprite);
+ }
+ else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx"))
+ {
+ std::string particlefx = (const char*) spriteNode->xmlChildrenNode->content;
+ currentInfo->particles.push_back(particlefx);
+ }
+ }
+ mEmoteInfos[id] = currentInfo;
+ if (id > mLastEmote) mLastEmote = id;
+ }
+
+ mLoaded = true;
+}
+
+void EmoteDB::unload()
+{
+ for ( EmoteInfosIterator i = mEmoteInfos.begin();
+ i != mEmoteInfos.end();
+ i++)
+ {
+ while (!i->second->sprites.empty())
+ {
+ delete i->second->sprites.front();
+ i->second->sprites.pop_front();
+ }
+ delete i->second;
+ }
+
+ mEmoteInfos.clear();
+
+ while (!mUnknown.sprites.empty())
+ {
+ delete mUnknown.sprites.front();
+ mUnknown.sprites.pop_front();
+ }
+
+ mLoaded = false;
+}
+
+const EmoteInfo& EmoteDB::get(int id)
+{
+ EmoteInfosIterator i = mEmoteInfos.find(id);
+
+ if (i == mEmoteInfos.end())
+ {
+ logger->log("EmoteDB: Warning, unknown emote ID %d requested", id);
+ return mUnknown;
+ }
+ else
+ {
+ return *(i->second);
+ }
+}
+
+const int& EmoteDB::getLast()
+{
+ return mLastEmote;
+}
diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h
new file mode 100644
index 00000000..ad21722a
--- /dev/null
+++ b/src/resources/emotedb.h
@@ -0,0 +1,60 @@
+/*
+ * Emote database
+ * Copyright (C) 2009 Aethyra Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef EMOTE_DB_H
+#define EMOTE_DB_H
+
+#include <list>
+#include <map>
+#include <string>
+
+struct EmoteSprite
+{
+ std::string sprite;
+ std::string name;
+ int variant;
+};
+
+struct EmoteInfo
+{
+ std::list<EmoteSprite*> sprites;
+ std::list<std::string> particles;
+};
+
+typedef std::map<int, EmoteInfo*> EmoteInfos;
+
+/**
+ * Emote information database.
+ */
+namespace EmoteDB
+{
+ void load();
+
+ void unload();
+
+ const EmoteInfo& get(int id);
+
+ const int& getLast();
+
+ typedef EmoteInfos::iterator EmoteInfosIterator;
+}
+
+#endif
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 77d77f96..7a7e6ac8 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -1,29 +1,28 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <SDL_image.h>
-#include "image.h"
-
#include "dye.h"
+#include "image.h"
#include "../log.h"
@@ -168,7 +167,8 @@ Image *Image::load(SDL_Surface *tmpImage)
tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);
- if (!tmpImage) {
+ if (!tmpImage)
+ {
logger->log("Error, image convert failed: out of memory");
return NULL;
}
@@ -179,9 +179,8 @@ Image *Image::load(SDL_Surface *tmpImage)
glGenTextures(1, &texture);
glBindTexture(mTextureType, texture);
- if (SDL_MUSTLOCK(tmpImage)) {
+ if (SDL_MUSTLOCK(tmpImage))
SDL_LockSurface(tmpImage);
- }
glTexImage2D(
mTextureType, 0, 4,
@@ -256,14 +255,13 @@ Image *Image::load(SDL_Surface *tmpImage)
SDL_Surface *image;
// Convert the surface to the current display format
- if (hasAlpha) {
+ if (hasAlpha)
image = SDL_DisplayFormatAlpha(tmpImage);
- }
- else {
+ else
image = SDL_DisplayFormat(tmpImage);
- }
- if (!image) {
+ if (!image)
+ {
logger->log("Error: Image convert failed.");
return NULL;
}
@@ -275,14 +273,16 @@ void Image::unload()
{
mLoaded = false;
- if (mImage) {
+ if (mImage)
+ {
// Free the image surface.
SDL_FreeSurface(mImage);
mImage = NULL;
}
#ifdef USE_OPENGL
- if (mGLImage) {
+ if (mGLImage)
+ {
glDeleteTextures(1, &mGLImage);
mGLImage = 0;
}
@@ -293,10 +293,9 @@ Image *Image::getSubImage(int x, int y, int width, int height)
{
// Create a new clipped sub-image
#ifdef USE_OPENGL
- if (mUseOpenGL) {
+ if (mUseOpenGL)
return new SubImage(this, mGLImage, x, y, width, height,
mTexWidth, mTexHeight);
- }
#endif
return new SubImage(this, mImage, x, y, width, height);
@@ -304,13 +303,13 @@ Image *Image::getSubImage(int x, int y, int width, int height)
void Image::setAlpha(float a)
{
- if (mAlpha == a) {
+ if (mAlpha == a)
return;
- }
mAlpha = a;
- if (mImage) {
+ if (mImage)
+ {
// Set the alpha value this image is drawn at
SDL_SetAlpha(mImage, SDL_SRCALPHA, (int) (255 * mAlpha));
}
@@ -322,14 +321,12 @@ float Image::getAlpha()
}
#ifdef USE_OPENGL
-void
-Image::setLoadAsOpenGL(bool useOpenGL)
+void Image::setLoadAsOpenGL(bool useOpenGL)
{
Image::mUseOpenGL = useOpenGL;
}
-int
-Image::powerOfTwo(int input)
+int Image::powerOfTwo(int input)
{
int value;
if (mTextureType == GL_TEXTURE_2D)
@@ -354,7 +351,8 @@ Image::powerOfTwo(int input)
SubImage::SubImage(Image *parent, SDL_Surface *image,
int x, int y, int width, int height):
- Image(image), mParent(parent)
+ Image(image),
+ mParent(parent)
{
mParent->incRef();
@@ -369,7 +367,8 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
SubImage::SubImage(Image *parent, GLuint image,
int x, int y, int width, int height,
int texWidth, int texHeight):
- Image(image, width, height, texWidth, texHeight), mParent(parent)
+ Image(image, width, height, texWidth, texHeight),
+ mParent(parent)
{
mParent->incRef();
@@ -395,3 +394,4 @@ Image *SubImage::getSubImage(int x, int y, int w, int h)
{
return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
}
+
diff --git a/src/resources/image.h b/src/resources/image.h
index 3677696f..3160add8 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -1,30 +1,31 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_IMAGE_H
-#define _TMW_IMAGE_H
+#ifndef IMAGE_H
+#define IMAGE_H
+
+#include <SDL.h>
#include "../main.h"
-#include <SDL.h>
#ifdef USE_OPENGL
/* The definition of OpenGL extensions by SDL is giving problems with recent
@@ -54,8 +55,7 @@ class Image : public Resource
/**
* Destructor.
*/
- virtual
- ~Image();
+ virtual ~Image();
/**
* Loads an image from a buffer in memory.
@@ -78,7 +78,8 @@ class Image : public Resource
* @return <code>NULL</code> if an error occurred, a valid pointer
* otherwise.
*/
- static Resource *load(void *buffer, unsigned bufferSize, Dye const &dye);
+ static Resource *load(void *buffer, unsigned bufferSize,
+ Dye const &dye);
/**
* Loads an image from an SDL surface.
@@ -88,21 +89,19 @@ class Image : public Resource
/**
* Frees the resources created by SDL.
*/
- virtual void
- unload();
+ virtual void unload();
/**
* Returns the width of the image.
*/
- virtual int
- getWidth() const { return mBounds.w; }
-
+ virtual int getWidth() const
+ { return mBounds.w; }
/**
* Returns the height of the image.
*/
- virtual int
- getHeight() const { return mBounds.h; }
+ virtual int getHeight() const
+ { return mBounds.h; }
/**
* Creates a new image with the desired clipping rectangle.
@@ -110,20 +109,17 @@ class Image : public Resource
* @return <code>NULL</code> if creation failed and a valid
* object otherwise.
*/
- virtual Image*
- getSubImage(int x, int y, int width, int height);
+ virtual Image *getSubImage(int x, int y, int width, int height);
/**
* Sets the alpha value of this image.
*/
- void
- setAlpha(float alpha);
+ virtual void setAlpha(float alpha);
/**
* Returns the alpha value of this image.
*/
- float
- getAlpha();
+ float getAlpha();
#ifdef USE_OPENGL
/**
@@ -133,7 +129,6 @@ class Image : public Resource
static void setLoadAsOpenGL(bool useOpenGL);
#endif
-
protected:
/**
* Constructor.
@@ -145,8 +140,7 @@ class Image : public Resource
/**
* Returns the first power of two equal or bigger than the input.
*/
- static int
- powerOfTwo(int input);
+ static int powerOfTwo(int input);
#endif
Image(SDL_Surface *image);
@@ -192,8 +186,7 @@ class SubImage : public Image
* @return <code>NULL</code> if creation failed and a valid
* image otherwise.
*/
- Image*
- getSubImage(int x, int y, int width, int height);
+ Image *getSubImage(int x, int y, int width, int height);
private:
Image *mParent;
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
index 835ba100..40d62797 100644
--- a/src/resources/imageloader.cpp
+++ b/src/resources/imageloader.cpp
@@ -1,32 +1,31 @@
/*
* The Mana World
- * Copyright 2007 The Mana World Development Team
+ * Copyright (C) 2007 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <cassert>
-#include <string>
+
#include <guichan/color.hpp>
#include <guichan/sdl/sdlpixel.hpp>
-#include "imageloader.h"
-
#include "image.h"
+#include "imageloader.h"
#include "resourcemanager.h"
ProxyImage::ProxyImage(SDL_Surface *s):
diff --git a/src/resources/imageloader.h b/src/resources/imageloader.h
index 821a0254..1d6c9ae4 100644
--- a/src/resources/imageloader.h
+++ b/src/resources/imageloader.h
@@ -1,26 +1,26 @@
/*
* The Mana World
- * Copyright 2007 The Mana World Development Team
+ * Copyright (C) 2007 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_IMAGELOADER_H
-#define _TMW_IMAGELOADER_H
+#ifndef IMAGELOADER_H
+#define IMAGELOADER_H
#include <string>
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index 1c0f9373..92bb3242 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -1,30 +1,29 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "image.h"
#include "imageset.h"
#include "../log.h"
-#include "image.h"
-
#include "../utils/dtor.h"
ImageSet::ImageSet(Image *img, int width, int height)
@@ -45,8 +44,7 @@ ImageSet::~ImageSet()
delete_all(mImages);
}
-Image*
-ImageSet::get(size_type i) const
+Image* ImageSet::get(size_type i) const
{
if (i >= mImages.size())
{
diff --git a/src/resources/imageset.h b/src/resources/imageset.h
index 58b7a8ea..f59c76bb 100644
--- a/src/resources/imageset.h
+++ b/src/resources/imageset.h
@@ -1,26 +1,26 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_IMAGESET_H
-#define _TMW_IMAGESET_H
+#ifndef IMAGESET_H
+#define IMAGESET_H
#include <vector>
@@ -28,7 +28,6 @@
class Image;
-
/**
* Stores a set of subimages originating from a single image.
*/
diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp
index d6d8a6c2..c350ac07 100644
--- a/src/resources/imagewriter.cpp
+++ b/src/resources/imagewriter.cpp
@@ -1,29 +1,29 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "imagewriter.h"
-
#include <png.h>
-#include <string>
#include <SDL.h>
+#include <string>
+
+#include "imagewriter.h"
#include "../log.h"
diff --git a/src/resources/imagewriter.h b/src/resources/imagewriter.h
index 632e2ae4..039d3afb 100644
--- a/src/resources/imagewriter.h
+++ b/src/resources/imagewriter.h
@@ -1,31 +1,29 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <iosfwd>
-
struct SDL_Surface;
class ImageWriter
{
public:
static bool writePNG(SDL_Surface *surface,
- const std::string &filename);
+ const std::string &filename);
};
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 5dfcfb87..7304f8a7 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -1,30 +1,29 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <cassert>
+
#include <libxml/tree.h>
#include "itemdb.h"
-
-#include "iteminfo.h"
#include "resourcemanager.h"
#include "../log.h"
@@ -32,6 +31,7 @@
#include "../utils/dtor.h"
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
+#include "../utils/stringutils.h"
#include "../utils/xml.h"
namespace
@@ -95,13 +95,13 @@ void ItemDB::load()
logger->log("Initializing item database...");
- mUnknown = new ItemInfo();
- mUnknown->setName("Unknown item");
+ mUnknown = new ItemInfo;
+ mUnknown->setName(_("Unknown item"));
mUnknown->setImageName("");
mUnknown->setSprite("error.xml", GENDER_MALE);
mUnknown->setSprite("error.xml", GENDER_FEMALE);
- XML::Document doc("items.xml");
+ XML::Document doc(_("items.xml"));
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "items"))
@@ -126,27 +126,37 @@ void ItemDB::load()
logger->log("ItemDB: Redefinition of item ID %d", id);
}
- int type = itemTypeFromString(XML::getProperty(node, "type", ""));
+ std::string typeStr = XML::getProperty(node, "type", "other");
int weight = XML::getProperty(node, "weight", 0);
int view = XML::getProperty(node, "view", 0);
std::string name = XML::getProperty(node, "name", "");
std::string image = XML::getProperty(node, "image", "");
std::string description = XML::getProperty(node, "description", "");
+#ifdef TMWSERV_SUPPORT
int weaponType = weaponTypeFromString(XML::getProperty(node, "weapon-type", ""));
+#else
+ int weaponType = XML::getProperty(node, "weapon_type", 0);
+#endif
int attackRange = XML::getProperty(node, "attack-range", 0);
ItemInfo *itemInfo = new ItemInfo;
itemInfo->setId(id);
itemInfo->setImageName(image);
- itemInfo->setName(name.empty() ? "Unnamed" : name);
+ itemInfo->setName(name.empty() ? _("Unnamed") : name);
itemInfo->setDescription(description);
+#ifdef TMWSERV_SUPPORT
+ int type = itemTypeFromString(typeStr);
itemInfo->setType(type);
+#else
+ itemInfo->setType(typeStr);
+#endif
itemInfo->setView(view);
itemInfo->setWeight(weight);
itemInfo->setWeaponType(weaponType);
itemInfo->setAttackRange(attackRange);
+#ifdef TMWSERV_SUPPORT
std::string effect;
for (int i = 0; i < int(sizeof(fields) / sizeof(fields[0])); ++i)
{
@@ -155,6 +165,9 @@ void ItemDB::load()
if (!effect.empty()) effect += " / ";
effect += strprintf(gettext(fields[i][1]), value);
}
+#else
+ std::string effect = XML::getProperty(node, "effect", "");
+#endif
itemInfo->setEffect(effect);
@@ -176,7 +189,10 @@ void ItemDB::load()
NamedItemInfoIterator itr = mNamedItemInfos.find(name);
if (itr == mNamedItemInfos.end())
{
- mNamedItemInfos[name] = itemInfo;
+ std::string temp = name;
+ toLower(trim(temp));
+
+ mNamedItemInfos[temp] = itemInfo;
}
else
{
@@ -191,7 +207,7 @@ void ItemDB::load()
CHECK_PARAM(name, "");
CHECK_PARAM(image, "");
CHECK_PARAM(description, "");
- CHECK_PARAM(effect, "");
+ // CHECK_PARAM(effect, "");
// CHECK_PARAM(type, 0);
// CHECK_PARAM(weight, 0);
// CHECK_PARAM(slot, 0);
@@ -216,7 +232,7 @@ void ItemDB::unload()
const ItemInfo& ItemDB::get(int id)
{
- assert(mLoaded && id);
+ assert(mLoaded);
ItemInfoIterator i = mItemInfos.find(id);
@@ -257,7 +273,6 @@ void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node)
{
itemInfo->setSprite(filename, GENDER_MALE);
}
-
if (gender == "female" || gender == "unisex")
{
itemInfo->setSprite(filename, GENDER_FEMALE);
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index 1d814f34..68f3b039 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -1,30 +1,32 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_ITEM_MANAGER_H
-#define _TMW_ITEM_MANAGER_H
+#ifndef ITEM_MANAGER_H
+#define ITEM_MANAGER_H
+
+#include <map>
#include "iteminfo.h"
-#include <map>
+class ItemInfo;
/**
* Item information database.
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index cc7a6afc..f7118755 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -1,30 +1,28 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "iteminfo.h"
-
#include "itemdb.h"
+#include "iteminfo.h"
-const std::string&
-ItemInfo::getSprite(Gender gender) const
+const std::string& ItemInfo::getSprite(Gender gender) const
{
if (mView)
{
@@ -43,8 +41,10 @@ ItemInfo::getSprite(Gender gender) const
void ItemInfo::setWeaponType(int type)
{
+ // See server item.hpp file for type values.
switch (type)
{
+#ifdef TMWSERV_SUPPORT
case WPNTYPE_NONE:
mAttackType = ACTION_DEFAULT;
break;
@@ -63,18 +63,35 @@ void ItemInfo::setWeaponType(int type)
break;
default:
mAttackType = ACTION_ATTACK;
+#else
+ case 0: // none
+ mAttackType = ACTION_DEFAULT;
+ break;
+ case 1: // knife
+ case 2: // sword
+ mAttackType = ACTION_ATTACK_STAB;
+ break;
+ case 8: // projectile
+ mAttackType = ACTION_ATTACK_THROW;
+ break;
+ case 10: // bow
+ mAttackType = ACTION_ATTACK_BOW;
+ break;
+ case 11: // sickle
+ mAttackType = ACTION_ATTACK_SWING;
+ break;
+ default:
+ mAttackType = ACTION_ATTACK;
+#endif
}
}
-void
-ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename)
+void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename)
{
mSounds[event].push_back("sfx/" + filename);
}
-
-const std::string&
-ItemInfo::getSound(EquipmentSoundEvent event) const
+const std::string& ItemInfo::getSound(EquipmentSoundEvent event) const
{
static const std::string empty;
std::map< EquipmentSoundEvent, std::vector<std::string> >::const_iterator i;
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 1c1d8467..10749c9e 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -1,26 +1,26 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_ITEMINFO_H_
-#define _TMW_ITEMINFO_H_
+#ifndef ITEMINFO_H
+#define ITEMINFO_H
#include <map>
#include <string>
@@ -28,7 +28,7 @@
#include "spritedef.h"
-#include "../player.h"
+#include "../being.h"
enum EquipmentSoundEvent
{
@@ -115,7 +115,11 @@ class ItemInfo
* Constructor.
*/
ItemInfo():
+#ifdef TMWSERV_SUPPORT
mType(ITEM_UNUSABLE),
+#else
+ mType(""),
+#endif
mWeight(0),
mView(0),
mAttackType(ACTION_DEFAULT)
@@ -149,14 +153,20 @@ class ItemInfo
void setEffect(const std::string &effect)
{ mEffect = effect; }
- const std::string&
- getEffect() const { return mEffect; }
+ const std::string& getEffect() const { return mEffect; }
+#ifdef TMWSERV_SUPPORT
void setType(short type)
{ mType = type; }
short getType() const
{ return mType; }
+#else
+ void setType(const std::string& type)
+ { mType = type; }
+
+ const std::string& getType() const { return mType; }
+#endif
void setWeight(short weight)
{ mWeight = weight; }
@@ -192,7 +202,11 @@ class ItemInfo
std::string mName;
std::string mDescription; /**< Short description. */
std::string mEffect; /**< Description of effects. */
+#ifdef TMWSERV_SUPPORT
char mType; /**< Item type. */
+#else
+ std::string mType; /**< Item type. */
+#endif
short mWeight; /**< Weight in grams. */
int mView; /**< Item ID of how this item looks. */
int mId; /**< Item ID */
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index b812b2ce..c4cb7447 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -1,39 +1,39 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "mapreader.h"
-
#include <cassert>
#include <iostream>
#include <zlib.h>
-#include "resourcemanager.h"
+#include "animation.h"
#include "image.h"
+#include "mapreader.h"
+#include "resourcemanager.h"
#include "../log.h"
#include "../map.h"
#include "../tileset.h"
#include "../utils/base64.h"
-#include "../utils/tostring.h"
+#include "../utils/stringutils.h"
#include "../utils/xml.h"
const unsigned int DEFAULT_TILE_WIDTH = 32;
@@ -205,14 +205,11 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
// Take the filename off the path
const std::string pathDir = path.substr(0, path.rfind("/") + 1);
- //xmlChar *prop = xmlGetProp(node, BAD_CAST "version");
- //xmlFree(prop);
-
const int w = XML::getProperty(node, "width", 0);
const int h = XML::getProperty(node, "height", 0);
- const int tw = XML::getProperty(node, "tilewidth", DEFAULT_TILE_WIDTH);
- const int th = XML::getProperty(node, "tileheight", DEFAULT_TILE_HEIGHT);
- Map *map = new Map(w, h, tw, th);
+ const int tilew = XML::getProperty(node, "tilewidth", DEFAULT_TILE_WIDTH);
+ const int tileh = XML::getProperty(node, "tileheight", DEFAULT_TILE_HEIGHT);
+ Map *map = new Map(w, h, tilew, tileh);
for_each_xml_child_node(childNode, node)
{
@@ -233,6 +230,12 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
}
else if (xmlStrEqual(childNode->name, BAD_CAST "objectgroup"))
{
+ // The object group offset is applied to each object individually
+ const int tileOffsetX = XML::getProperty(childNode, "x", 0);
+ const int tileOffsetY = XML::getProperty(childNode, "y", 0);
+ const int offsetX = tileOffsetX * tilew;
+ const int offsetY = tileOffsetY * tileh;
+
for_each_xml_child_node(objectNode, childNode)
{
if (xmlStrEqual(objectNode->name, BAD_CAST "object"))
@@ -253,7 +256,8 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
const int objY = XML::getProperty(objectNode, "y", 0);
logger->log("- Loading object name: %s type: %s at %d:%d",
- objName.c_str(), objType.c_str(), objX, objY);
+ objName.c_str(), objType.c_str(),
+ objX, objY);
if (objType == "PARTICLE_EFFECT")
{
@@ -262,7 +266,9 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
continue;
}
- map->addParticleEffect(objName, objX, objY);
+ map->addParticleEffect(objName,
+ objX + offsetX,
+ objY + offsetY);
}
else
{
@@ -297,7 +303,8 @@ void MapReader::readProperties(xmlNodePtr node, Properties *props)
static void setTile(Map *map, MapLayer *layer, int x, int y, int gid)
{
const Tileset * const set = map->getTilesetWithGid(gid);
- if (layer) {
+ if (layer)
+ {
// Set regular tile on a layer
Image * const img = set ? set->get(gid - set->getFirstGid()) : 0;
layer->setTile(x, y, img);
@@ -313,12 +320,12 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
// Layers are not necessarily the same size as the map
const int w = XML::getProperty(node, "width", map->getWidth());
const int h = XML::getProperty(node, "height", map->getHeight());
- const int offsetX = XML::getProperty(node, "xoffset", 0);
- const int offsetY = XML::getProperty(node, "yoffset", 0);
+ const int offsetX = XML::getProperty(node, "x", 0);
+ const int offsetY = XML::getProperty(node, "y", 0);
const std::string name = XML::getProperty(node, "name", "");
- const bool isFringeLayer = (name == "Fringe");
- const bool isCollisionLayer = (name == "Collision");
+ const bool isFringeLayer = (name.substr(0,6) == "Fringe");
+ const bool isCollisionLayer = (name.substr(0,9) == "Collision");
MapLayer *layer = 0;
@@ -361,7 +368,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
while (*charStart) {
if (*charStart != ' ' && *charStart != '\t' &&
- *charStart != '\n')
+ *charStart != '\n')
{
*charIndex = *charStart;
charIndex++;
@@ -401,6 +408,12 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
setTile(map, layer, x, y, gid);
+ TileAnimation* ani = map->getAnimationForGid(gid);
+ if (ani)
+ {
+ ani->addAffectedTile(layer, x + y * w);
+ }
+
x++;
if (x == w) {
x = 0; y++;
@@ -446,46 +459,96 @@ Tileset *MapReader::readTileset(xmlNodePtr node,
const std::string &path,
Map *map)
{
+ int firstGid = XML::getProperty(node, "firstgid", 0);
+ XML::Document* doc = NULL;
+ Tileset *set = NULL;
+
if (xmlHasProp(node, BAD_CAST "source"))
{
- logger->log("Warning: External tilesets not supported yet.");
- return NULL;
+ std::string filename = XML::getProperty(node, "source", "");
+ while (filename.substr(0, 3) == "../")
+ filename.erase(0, 3); // Remove "../"
+ doc = new XML::Document(filename);
+ node = doc->rootNode();
+ firstGid += XML::getProperty(node, "firstgid", 0);
}
- const int firstGid = XML::getProperty(node, "firstgid", 0);
const int tw = XML::getProperty(node, "tilewidth", map->getTileWidth());
const int th = XML::getProperty(node, "tileheight", map->getTileHeight());
for_each_xml_child_node(childNode, node)
{
- if (!xmlStrEqual(childNode->name, BAD_CAST "image"))
- continue;
+ if (xmlStrEqual(childNode->name, BAD_CAST "image"))
+ {
+ const std::string source = XML::getProperty(childNode, "source", "");
- const std::string source = XML::getProperty(childNode, "source", "");
+ if (!source.empty())
+ {
+ std::string sourceStr = source;
+ sourceStr.erase(0, 3); // Remove "../"
+
+ ResourceManager *resman = ResourceManager::getInstance();
+ Image* tilebmp = resman->getImage(sourceStr);
- if (!source.empty())
+ if (tilebmp)
+ {
+ set = new Tileset(tilebmp, tw, th, firstGid);
+ tilebmp->decRef();
+ }
+ else {
+ logger->log("Warning: Failed to load tileset (%s)",
+ source.c_str());
+ }
+ }
+ }
+ else if (xmlStrEqual(childNode->name, BAD_CAST "tile"))
{
- std::string sourceStr = source;
- sourceStr.erase(0, 3); // Remove "../"
+ for_each_xml_child_node(tileNode, childNode)
+ {
+ if (!xmlStrEqual(tileNode->name, BAD_CAST "properties")) continue;
- ResourceManager *resman = ResourceManager::getInstance();
- Image* tilebmp = resman->getImage(sourceStr);
+ int tileGID = firstGid + XML::getProperty(childNode, "id", 0);
- if (tilebmp)
- {
- Tileset *set = new Tileset(tilebmp, tw, th, firstGid);
- tilebmp->decRef();
- return set;
- }
- else {
- logger->log("Warning: Failed to load tileset (%s)",
- source.c_str());
+ // read tile properties to a map for simpler handling
+ std::map<std::string, int> tileProperties;
+ for_each_xml_child_node(propertyNode, tileNode)
+ {
+ if (!xmlStrEqual(propertyNode->name, BAD_CAST "property")) continue;
+ std::string name = XML::getProperty(propertyNode, "name", "");
+ int value = XML::getProperty(propertyNode, "value", 0);
+ tileProperties[name] = value;
+ logger->log("Tile Prop of %d \"%s\" = \"%d\"", tileGID, name.c_str(), value);
+ }
+
+ // create animation
+ if (!set) continue;
+
+ Animation *ani = new Animation;
+ for (int i = 0; ;i++)
+ {
+ std::map<std::string, int>::iterator iFrame, iDelay;
+ iFrame = tileProperties.find("animation-frame" + toString(i));
+ iDelay = tileProperties.find("animation-delay" + toString(i));
+ if (iFrame != tileProperties.end() && iDelay != tileProperties.end())
+ {
+ ani->addFrame(set->get(iFrame->second), iDelay->second, 0, 0);
+ } else {
+ break;
+ }
+ }
+
+ if (ani->getLength() > 0)
+ {
+ map->addAnimation(tileGID, new TileAnimation(ani));
+ logger->log("Animation length: %d", ani->getLength());
+ } else {
+ delete ani;
+ }
}
}
-
- // Only one image element expected
- break;
}
- return NULL;
+ delete doc;
+
+ return set;
}
diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h
index 04e83b99..0ed553c3 100644
--- a/src/resources/mapreader.h
+++ b/src/resources/mapreader.h
@@ -1,33 +1,31 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_MAPREADER_H_
-#define _TMW_MAPREADER_H_
-
-#include <iosfwd>
+#ifndef MAPREADER_H
+#define MAPREADER_H
#include <libxml/tree.h>
-class Properties;
class Map;
+class Properties;
class Tileset;
/**
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index ed4acd38..cee9eea5 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -1,32 +1,31 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "monsterdb.h"
-
-#include "resourcemanager.h"
-#include "spritedef.h"
+#include "monsterinfo.h"
#include "../log.h"
#include "../utils/dtor.h"
+#include "../utils/gettext.h"
#include "../utils/xml.h"
namespace
@@ -36,18 +35,17 @@ namespace
bool mLoaded = false;
}
-void
-MonsterDB::load()
+void MonsterDB::load()
{
if (mLoaded)
return;
mUnknown.addSprite("error.xml");
- mUnknown.setName("unnamed");
+ mUnknown.setName(_("unnamed"));
logger->log("Initializing monster database...");
- XML::Document doc("monsters.xml");
+ XML::Document doc(_("monsters.xml"));
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "monsters"))
@@ -59,11 +57,13 @@ MonsterDB::load()
for_each_xml_child_node(monsterNode, rootNode)
{
if (!xmlStrEqual(monsterNode->name, BAD_CAST "monster"))
+ {
continue;
+ }
- MonsterInfo *currentInfo = new MonsterInfo();
+ MonsterInfo *currentInfo = new MonsterInfo;
- currentInfo->setName(XML::getProperty(monsterNode, "name", "unnamed"));
+ currentInfo->setName(XML::getProperty(monsterNode, "name", _("unnamed")));
std::string targetCursor;
targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium");
@@ -81,8 +81,8 @@ MonsterDB::load()
}
else
{
- logger->log("MonsterDB: Unknown target cursor type \"%s\" for %s "
- "- using medium sized one",
+ logger->log("MonsterDB: Unknown target cursor type \"%s\" for %s -"
+ "using medium sized one",
targetCursor.c_str(), currentInfo->getName().c_str());
currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
}
@@ -92,7 +92,8 @@ MonsterDB::load()
{
if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
{
- currentInfo->addSprite((const char*) spriteNode->xmlChildrenNode->content);
+ currentInfo->addSprite(
+ (const char*) spriteNode->xmlChildrenNode->content);
}
else if (xmlStrEqual(spriteNode->name, BAD_CAST "sound"))
{
diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h
index f1d69e72..0a218661 100644
--- a/src/resources/monsterdb.h
+++ b/src/resources/monsterdb.h
@@ -1,41 +1,39 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_MONSTER_DB_H
-#define _TMW_MONSTER_DB_H
+#ifndef MONSTER_DB_H
+#define MONSTER_DB_H
#include <map>
-#include "monsterinfo.h"
+class MonsterInfo;
/**
* Monster information database.
*/
namespace MonsterDB
{
- void
- load();
+ void load();
- void
- unload();
+ void unload();
const MonsterInfo& get(int id);
diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp
index 1e982213..2fc16bef 100644
--- a/src/resources/monsterinfo.cpp
+++ b/src/resources/monsterinfo.cpp
@@ -1,21 +1,21 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -34,8 +34,7 @@ MonsterInfo::~MonsterInfo()
mSounds.clear();
}
-void
-MonsterInfo::addSound(MonsterSoundEvent event, const std::string &filename)
+void MonsterInfo::addSound(MonsterSoundEvent event, const std::string &filename)
{
if (mSounds.find(event) == mSounds.end())
{
@@ -45,8 +44,7 @@ MonsterInfo::addSound(MonsterSoundEvent event, const std::string &filename)
mSounds[event]->push_back("sfx/" + filename);
}
-const std::string &
-MonsterInfo::getSound(MonsterSoundEvent event) const
+const std::string &MonsterInfo::getSound(MonsterSoundEvent event) const
{
static std::string empty("");
std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i =
@@ -55,8 +53,7 @@ MonsterInfo::getSound(MonsterSoundEvent event) const
i->second->at(rand() % i->second->size());
}
-const std::string &
-MonsterInfo::getAttackParticleEffect(int attackType) const
+const std::string &MonsterInfo::getAttackParticleEffect(int attackType) const
{
static std::string empty("");
std::map<int, MonsterAttack*>::const_iterator i =
@@ -64,18 +61,16 @@ MonsterInfo::getAttackParticleEffect(int attackType) const
return (i == mMonsterAttacks.end()) ? empty : (*i).second->particleEffect;
}
-SpriteAction
-MonsterInfo::getAttackAction(int attackType) const
+SpriteAction MonsterInfo::getAttackAction(int attackType) const
{
std::map<int, MonsterAttack*>::const_iterator i =
mMonsterAttacks.find(attackType);
return (i == mMonsterAttacks.end()) ? ACTION_ATTACK : (*i).second->action;
}
-void
-MonsterInfo::addMonsterAttack(int id,
- const std::string &particleEffect,
- SpriteAction action)
+void MonsterInfo::addMonsterAttack(int id,
+ const std::string &particleEffect,
+ SpriteAction action)
{
MonsterAttack *a = new MonsterAttack;
a->particleEffect = particleEffect;
diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h
index 88f6fb2b..02574147 100644
--- a/src/resources/monsterinfo.h
+++ b/src/resources/monsterinfo.h
@@ -1,35 +1,34 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_MONSTERINFO_H_
-#define _TMW_MONSTERINFO_H_
+#ifndef MONSTERINFO_H
+#define MONSTERINFO_H
+#include <list>
#include <map>
#include <string>
#include <vector>
-#include <list>
#include "../being.h"
-
enum MonsterSoundEvent
{
MONSTER_EVENT_HIT,
@@ -63,47 +62,39 @@ class MonsterInfo
*/
~MonsterInfo();
- void
- setName(const std::string &name) { mName = name; }
+ void setName(const std::string &name) { mName = name; }
- void
- addSprite(const std::string &filename)
+ void addSprite(const std::string &filename)
{ mSprites.push_back(filename); }
- void
- setTargetCursorSize(Being::TargetCursorSize targetCursorSize)
+ void setTargetCursorSize(Being::TargetCursorSize targetCursorSize)
{ mTargetCursorSize = targetCursorSize; }
- void
- addSound(MonsterSoundEvent event, const std::string &filename);
+ void addSound(MonsterSoundEvent event, const std::string &filename);
- void
- addParticleEffect(const std::string &filename);
+ void addParticleEffect(const std::string &filename);
- const std::string&
- getName() const { return mName; }
+ const std::string& getName() const
+ { return mName; }
- const std::list<std::string>&
- getSprites() const { return mSprites; }
+ const std::list<std::string>& getSprites() const
+ { return mSprites; }
- Being::TargetCursorSize
- getTargetCursorSize() const { return mTargetCursorSize; }
+ Being::TargetCursorSize getTargetCursorSize() const
+ { return mTargetCursorSize; }
- const std::string&
- getSound(MonsterSoundEvent event) const;
+ const std::string &getSound(MonsterSoundEvent event) const;
void addMonsterAttack(int id,
const std::string &particleEffect,
SpriteAction action);
- const std::string&
- getAttackParticleEffect(int attackType) const;
+ const std::string &getAttackParticleEffect(int attackType) const;
- SpriteAction
- getAttackAction(int attackType) const;
+ SpriteAction getAttackAction(int attackType) const;
- const std::list<std::string>&
- getParticleEffects() const { return mParticleEffects; }
+ const std::list<std::string>& getParticleEffects() const
+ { return mParticleEffects; }
private:
std::string mName;
diff --git a/src/resources/music.cpp b/src/resources/music.cpp
index 2386aa43..ed78a541 100644
--- a/src/resources/music.cpp
+++ b/src/resources/music.cpp
@@ -1,21 +1,21 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -55,8 +55,7 @@ Resource *Music::load(void *buffer, unsigned bufferSize)
}
}
-bool
-Music::play(int loops)
+bool Music::play(int loops)
{
/*
* Warning: loops should be always set to -1 (infinite) with current
@@ -71,8 +70,7 @@ Music::play(int loops)
return mChannel != -1;
}
-void
-Music::stop()
+void Music::stop()
{
/*
* Warning: very dungerous trick, it could try to stop channels occupied
diff --git a/src/resources/music.h b/src/resources/music.h
index d50150b8..34907cf1 100644
--- a/src/resources/music.h
+++ b/src/resources/music.h
@@ -1,29 +1,32 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_MUSIC_H
-#define _TMW_MUSIC_H
+#ifndef MUSIC_H
+#define MUSIC_H
+#ifdef __APPLE__
+#include <SDL_mixer/SDL_mixer.h>
+#else
#include <SDL_mixer.h>
-
+#endif
#include "resource.h"
/**
@@ -56,14 +59,12 @@ class Music : public Resource
* @return <code>true</code> if the playback started properly
* <code>false</code> otherwise.
*/
- virtual bool
- play(int loops);
+ virtual bool play(int loops);
/**
* Stops the music.
*/
- virtual void
- stop();
+ virtual void stop();
protected:
/**
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index 2f8d78d4..ee65136a 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -1,31 +1,29 @@
/*
* The Mana World
- * Copyright 2008 The Mana World Development Team
+ * Copyright (C) 2008 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "npcdb.h"
-#include "resourcemanager.h"
-
#include "../log.h"
-#include "../utils/dtor.h"
+#include "../utils/gettext.h"
#include "../utils/xml.h"
namespace
@@ -52,10 +50,10 @@ void NPCDB::load()
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "npcs"))
{
- logger->error("NPC Database: Error while loading items.xml!");
+ logger->error(_("NPC Database: Error while loading npcs.xml!"));
}
- //iterate <monster>s
+ //iterate <npc>s
for_each_xml_child_node(npcNode, rootNode)
{
if (!xmlStrEqual(npcNode->name, BAD_CAST "npc"))
@@ -91,8 +89,7 @@ void NPCDB::load()
mLoaded = true;
}
-void
-NPCDB::unload()
+void NPCDB::unload()
{
for ( NPCInfosIterator i = mNPCInfos.begin();
i != mNPCInfos.end();
@@ -117,8 +114,7 @@ NPCDB::unload()
mLoaded = false;
}
-const NPCInfo&
-NPCDB::get(int id)
+const NPCInfo& NPCDB::get(int id)
{
NPCInfosIterator i = mNPCInfos.find(id);
diff --git a/src/resources/npcdb.h b/src/resources/npcdb.h
index 00b4f99b..af6764bf 100644
--- a/src/resources/npcdb.h
+++ b/src/resources/npcdb.h
@@ -1,29 +1,29 @@
/*
* The Mana World
- * Copyright 2008 The Mana World Development Team
+ * Copyright (C) 2008 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_NPC_DB_H
-#define _TMW_NPC_DB_H
+#ifndef NPC_DB_H
+#define NPC_DB_H
-#include <map>
#include <list>
+#include <map>
#include <string>
struct NPCsprite
@@ -45,11 +45,9 @@ typedef std::map<int, NPCInfo*> NPCInfos;
*/
namespace NPCDB
{
- void
- load();
+ void load();
- void
- unload();
+ void unload();
const NPCInfo& get(int id);
diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp
index 449caf55..d1c3ada4 100644
--- a/src/resources/resource.cpp
+++ b/src/resources/resource.cpp
@@ -1,42 +1,39 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <cassert>
#include "resource.h"
-
#include "resourcemanager.h"
Resource::~Resource()
{
}
-void
-Resource::incRef()
+void Resource::incRef()
{
mRefCount++;
}
-void
-Resource::decRef()
+void Resource::decRef()
{
// Reference may not already have reached zero
assert(mRefCount != 0);
diff --git a/src/resources/resource.h b/src/resources/resource.h
index e85e3147..7c5f989e 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -1,26 +1,26 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_RESOURCE_H
-#define _TMW_RESOURCE_H
+#ifndef RESOURCE_H
+#define RESOURCE_H
#include <ctime>
#include <string>
@@ -41,8 +41,7 @@ class Resource
/**
* Increments the internal reference count.
*/
- void
- incRef();
+ void incRef();
/**
* Decrements the reference count and deletes the object
@@ -51,8 +50,7 @@ class Resource
* @return <code>true</code> if the object was deleted
* <code>false</code> otherwise.
*/
- void
- decRef();
+ void decRef();
/**
* Return the path identifying this resource.
@@ -64,8 +62,7 @@ class Resource
/**
* Destructor.
*/
- virtual
- ~Resource();
+ virtual ~Resource();
private:
std::string mIdPath; /**< Path identifying this resource. */
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 3d42d92e..50eda0ce 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -1,43 +1,41 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <cassert>
-#include <sstream>
-#include <sys/time.h>
-
#include <physfs.h>
#include <SDL_image.h>
+#include <sstream>
-#include "resourcemanager.h"
+#include <sys/time.h>
#include "dye.h"
#include "image.h"
+#include "imageset.h"
#include "music.h"
+#include "resourcemanager.h"
#include "soundeffect.h"
-#include "imageset.h"
#include "spritedef.h"
#include "../log.h"
-
ResourceManager *ResourceManager::instance = NULL;
ResourceManager::ResourceManager()
@@ -155,13 +153,13 @@ bool ResourceManager::addToSearchPath(const std::string &path, bool append)
}
void ResourceManager::searchAndAddArchives(const std::string &path,
- const std::string &ext,
- bool append)
+ const std::string &ext,
+ bool append)
{
const char *dirSep = PHYSFS_getDirSeparator();
char **list = PHYSFS_enumerateFiles(path.c_str());
- for (char **i = list; *i != NULL; i++)
+ for (char **i = list; *i; i++)
{
size_t len = strlen(*i);
@@ -209,7 +207,7 @@ std::string ResourceManager::getPath(const std::string &file)
else
{
// if not found in search path return the default path
- path = std::string(TMW_DATADIR) + std::string("data") + "/" + file;
+ path = std::string(PKG_DATADIR) + std::string("data") + "/" + file;
}
return path;
@@ -381,7 +379,7 @@ ResourceManager *ResourceManager::getInstance()
{
// Create a new instance if necessary.
if (!instance)
- instance = new ResourceManager();
+ instance = new ResourceManager;
return instance;
}
@@ -420,8 +418,7 @@ void *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
return buffer;
}
-std::vector<std::string>
-ResourceManager::loadTextFile(const std::string &fileName)
+std::vector<std::string> ResourceManager::loadTextFile(const std::string &fileName)
{
int contentsLength;
char *fileContents = (char*)loadFile(fileName, contentsLength);
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index e70dfb9d..c3c68d88 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -1,37 +1,37 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_RESOURCE_MANAGER_H
-#define _TMW_RESOURCE_MANAGER_H
+#ifndef RESOURCE_MANAGER_H
+#define RESOURCE_MANAGER_H
#include <ctime>
#include <map>
#include <string>
#include <vector>
-class Resource;
class Image;
+class ImageSet;
class Music;
+class Resource;
class SoundEffect;
-class ImageSet;
class SpriteDef;
struct SDL_Surface;
@@ -100,7 +100,7 @@ class ResourceManager
/**
* Returns the real path to a file. Note that this method will always
* return a path, it does not check whether the file exists.
- *
+ *
* @param file The file to get the real path to.
* @return The real path.
*/
diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp
index e21fd2b0..3a285730 100644
--- a/src/resources/soundeffect.cpp
+++ b/src/resources/soundeffect.cpp
@@ -1,21 +1,21 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -47,8 +47,7 @@ Resource *SoundEffect::load(void *buffer, unsigned bufferSize)
}
}
-bool
-SoundEffect::play(int loops, int volume)
+bool SoundEffect::play(int loops, int volume)
{
Mix_VolumeChunk(mChunk, volume);
diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h
index c3ff6668..fc2d4a69 100644
--- a/src/resources/soundeffect.h
+++ b/src/resources/soundeffect.h
@@ -1,28 +1,32 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_SOUND_EFFECT_H
-#define _TMW_SOUND_EFFECT_H
+#ifndef SOUND_EFFECT_H
+#define SOUND_EFFECT_H
+#ifdef __APPLE__
+#include <SDL_mixer/SDL_mixer.h>
+#else
#include <SDL_mixer.h>
+#endif
#include "resource.h"
@@ -35,8 +39,7 @@ class SoundEffect : public Resource
/**
* Destructor.
*/
- virtual
- ~SoundEffect();
+ virtual ~SoundEffect();
/**
* Loads a sample from a buffer in memory.
@@ -58,8 +61,7 @@ class SoundEffect : public Resource
* @return <code>true</code> if the playback started properly
* <code>false</code> otherwise.
*/
- virtual bool
- play(int loops, int volume);
+ virtual bool play(int loops, int volume);
protected:
/**
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index f5b763ea..390bd3d0 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -1,34 +1,33 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <set>
-#include "spritedef.h"
-
#include "action.h"
#include "animation.h"
#include "dye.h"
#include "image.h"
#include "imageset.h"
#include "resourcemanager.h"
+#include "spritedef.h"
#include "../log.h"
#include "../utils/xml.h"
@@ -167,7 +166,7 @@ void SpriteDef::loadAction(xmlNodePtr node, int variant_offset)
actionName.c_str(), getIdPath().c_str());
return;
}
- Action *action = new Action();
+ Action *action = new Action;
mActions[actionType] = action;
// When first action set it as default direction
@@ -201,7 +200,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode,
return;
}
- Animation *animation = new Animation();
+ Animation *animation = new Animation;
action->setAnimation(directionType, animation);
// Get animation frames
@@ -322,7 +321,7 @@ SpriteDef::~SpriteDef()
SpriteAction SpriteDef::makeSpriteAction(const std::string &action)
{
- if (action == "" || action == "default") {
+ if (action.empty() || action == "default") {
return ACTION_DEFAULT;
}
if (action == "stand") {
@@ -349,6 +348,7 @@ SpriteAction SpriteDef::makeSpriteAction(const std::string &action)
else if (action == "attack_throw") {
return ACTION_ATTACK_THROW;
}
+#ifdef TMWSERV_SUPPORT
else if (action == "special0") {
return ACTION_SPECIAL_0;
}
@@ -379,6 +379,7 @@ SpriteAction SpriteDef::makeSpriteAction(const std::string &action)
else if (action == "special9") {
return ACTION_SPECIAL_9;
}
+#endif
else if (action == "cast_magic") {
return ACTION_CAST_MAGIC;
}
@@ -404,7 +405,7 @@ SpriteAction SpriteDef::makeSpriteAction(const std::string &action)
SpriteDirection SpriteDef::makeSpriteDirection(const std::string& direction)
{
- if (direction == "" || direction == "default") {
+ if (direction.empty() || direction == "default") {
return DIRECTION_DEFAULT;
}
else if (direction == "up") {
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 0c3e443b..c3db8d64 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -1,34 +1,34 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_SPRITEDEF_H
-#define _TMW_SPRITEDEF_H
+#ifndef SPRITEDEF_H
+#define SPRITEDEF_H
#include <map>
#include <string>
-#include "resource.h"
-
#include <libxml/tree.h>
+#include "resource.h"
+
class Action;
class ImageSet;
@@ -43,6 +43,7 @@ enum SpriteAction
ACTION_ATTACK_STAB,
ACTION_ATTACK_BOW,
ACTION_ATTACK_THROW,
+#ifdef TMWSERV_SUPPORT
ACTION_SPECIAL_0,
ACTION_SPECIAL_1,
ACTION_SPECIAL_2,
@@ -53,6 +54,7 @@ enum SpriteAction
ACTION_SPECIAL_7,
ACTION_SPECIAL_8,
ACTION_SPECIAL_9,
+#endif
ACTION_CAST_MAGIC,
ACTION_USE_ITEM,
ACTION_SIT,
@@ -93,6 +95,12 @@ class SpriteDef : public Resource
*/
static SpriteAction makeSpriteAction(const std::string &action);
+ /**
+ * Converts a string into a SpriteDirection enum.
+ */
+ static SpriteDirection
+ makeSpriteDirection(const std::string &direction);
+
private:
/**
* Constructor.
@@ -143,13 +151,6 @@ class SpriteDef : public Resource
*/
void substituteAction(SpriteAction complete, SpriteAction with);
- /**
- * Converts a string into a SpriteDirection enum.
- */
- static SpriteDirection
- makeSpriteDirection(const std::string &direction);
-
-
typedef std::map<std::string, ImageSet*> ImageSets;
typedef ImageSets::iterator ImageSetIterator;