diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-13 21:09:12 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-13 21:09:12 +0000 |
commit | 68f069fea3182c6d5720df03f1d63de38f14c31d (patch) | |
tree | 129b4705b644cf1144b3bff3c18fca9e1b83a3b8 /src | |
parent | d3e938c478570be44c497607262fe8ca7145b171 (diff) | |
download | mana-68f069fea3182c6d5720df03f1d63de38f14c31d.tar.gz mana-68f069fea3182c6d5720df03f1d63de38f14c31d.tar.bz2 mana-68f069fea3182c6d5720df03f1d63de38f14c31d.tar.xz mana-68f069fea3182c6d5720df03f1d63de38f14c31d.zip |
Fixed svn properties.
Diffstat (limited to 'src')
-rw-r--r-- | src/channel.cpp | 120 | ||||
-rw-r--r-- | src/channel.h | 82 | ||||
-rw-r--r-- | src/channelmanager.cpp | 172 | ||||
-rw-r--r-- | src/channelmanager.h | 88 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/serverdialog.h | 2 | ||||
-rw-r--r-- | src/particleemitter.cpp | 654 | ||||
-rw-r--r-- | src/particleemitter.h | 240 | ||||
-rw-r--r-- | src/resources/equipmentdb.cpp | 312 | ||||
-rw-r--r-- | src/resources/equipmentinfo.h | 104 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 298 | ||||
-rw-r--r-- | src/resources/itemdb.h | 106 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 350 | ||||
-rw-r--r-- | src/resources/monsterinfo.cpp | 140 | ||||
-rw-r--r-- | src/resources/monsterinfo.h | 2 | ||||
-rw-r--r-- | src/resources/openglsdlimageloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/openglsdlimageloader.h | 2 | ||||
-rw-r--r-- | src/utils/fastsqrt.h | 48 | ||||
-rw-r--r-- | src/utils/minmax.h | 94 |
19 files changed, 1409 insertions, 1409 deletions
diff --git a/src/channel.cpp b/src/channel.cpp index ae79d7a7..170dbf5e 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -1,60 +1,60 @@ -/*
- * The Mana World
- * Copyright 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#include "channel.h"
-
-Channel::Channel(short id) :
-mID(id)
-{
-
-}
-
-std::string Channel::getName() const
-{
- return mName;
-}
-
-void Channel::setName(const std::string &channelName)
-{
- mName = channelName;
-}
-
-const short Channel::getId() const
-{
- return mID;
-}
-
-const int Channel::getUserListSize() const
-{
- return userList.size();
-}
-
-std::string Channel::getUser(unsigned int id) const
-{
- if(id <= userList.size())
- {
- return userList[id];
- }
- return "";
-}
+/* + * The Mana World + * Copyright 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + + +#include "channel.h" + +Channel::Channel(short id) : +mID(id) +{ + +} + +std::string Channel::getName() const +{ + return mName; +} + +void Channel::setName(const std::string &channelName) +{ + mName = channelName; +} + +const short Channel::getId() const +{ + return mID; +} + +const int Channel::getUserListSize() const +{ + return userList.size(); +} + +std::string Channel::getUser(unsigned int id) const +{ + if(id <= userList.size()) + { + return userList[id]; + } + return ""; +} diff --git a/src/channel.h b/src/channel.h index 2845eb39..0a62e073 100644 --- a/src/channel.h +++ b/src/channel.h @@ -1,41 +1,41 @@ -/*
- * The Mana World
- * Copyright 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include <string>
-#include <vector>
-
-class Channel
-{
- public:
- Channel(short id);
- std::string getName() const;
- void setName(const std::string &channelName);
- const short getId() const;
- const int getUserListSize() const;
- std::string getUser(unsigned int i) const;
- private:
- typedef std::vector<std::string> Users;
- std::string mName;
- short mID;
- Users userList;
-};
+/* + * The Mana World + * Copyright 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include <string> +#include <vector> + +class Channel +{ + public: + Channel(short id); + std::string getName() const; + void setName(const std::string &channelName); + const short getId() const; + const int getUserListSize() const; + std::string getUser(unsigned int i) const; + private: + typedef std::vector<std::string> Users; + std::string mName; + short mID; + Users userList; +}; diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp index 352b3ab5..07dc2bbf 100644 --- a/src/channelmanager.cpp +++ b/src/channelmanager.cpp @@ -1,86 +1,86 @@ -/*
- * The Mana World
- * Copyright 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include <list>
-
-#include "channelmanager.h"
-#include "channel.h"
-
-#include "utils/dtor.h"
-
-ChannelManager::ChannelManager()
-{
-
-}
-
-ChannelManager::~ChannelManager()
-{
- for_each(mChannels.begin(), mChannels.end(), make_dtor(mChannels));
- mChannels.clear();
-}
-
-Channel* ChannelManager::findById(int id)
-{
- Channel* channel;
- for(std::list<Channel*>::iterator itr = mChannels.begin();
- itr != mChannels.end();
- itr++)
- {
- channel = (*itr);
- if(channel->getId() == id)
- {
- return channel;
- }
- }
- return NULL;
-}
-
-Channel* ChannelManager::findByName(std::string name)
-{
- Channel* channel;
- if(name != "")
- {
- for(std::list<Channel*>::iterator itr = mChannels.begin();
- itr != mChannels.end();
- itr++)
- {
- channel = (*itr);
- if(channel->getName() == name)
- {
- return channel;
- }
- }
- }
- return NULL;
-}
-
-void ChannelManager::addChannel(Channel *channel)
-{
- mChannels.push_back(channel);
-}
-
-void ChannelManager::removeChannel(Channel *channel)
-{
- mChannels.remove(channel);
- delete channel;
-}
+/* + * The Mana World + * Copyright 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include <list> + +#include "channelmanager.h" +#include "channel.h" + +#include "utils/dtor.h" + +ChannelManager::ChannelManager() +{ + +} + +ChannelManager::~ChannelManager() +{ + for_each(mChannels.begin(), mChannels.end(), make_dtor(mChannels)); + mChannels.clear(); +} + +Channel* ChannelManager::findById(int id) +{ + Channel* channel; + for(std::list<Channel*>::iterator itr = mChannels.begin(); + itr != mChannels.end(); + itr++) + { + channel = (*itr); + if(channel->getId() == id) + { + return channel; + } + } + return NULL; +} + +Channel* ChannelManager::findByName(std::string name) +{ + Channel* channel; + if(name != "") + { + for(std::list<Channel*>::iterator itr = mChannels.begin(); + itr != mChannels.end(); + itr++) + { + channel = (*itr); + if(channel->getName() == name) + { + return channel; + } + } + } + return NULL; +} + +void ChannelManager::addChannel(Channel *channel) +{ + mChannels.push_back(channel); +} + +void ChannelManager::removeChannel(Channel *channel) +{ + mChannels.remove(channel); + delete channel; +} diff --git a/src/channelmanager.h b/src/channelmanager.h index 75c86a93..3ad8f0b8 100644 --- a/src/channelmanager.h +++ b/src/channelmanager.h @@ -1,44 +1,44 @@ -/*
- * The Mana World
- * Copyright 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#ifndef _TMW_CHANNELMANAGER_H
-#define _TMW_CHANNELMANAGER_H
-
-class Channel;
-
-class ChannelManager
-{
-public:
- ChannelManager();
- ~ChannelManager();
- Channel* findById(int id);
- Channel* findByName(std::string name);
- void addChannel(Channel *channel);
- void removeChannel(Channel *channel);
-private:
- std::list<Channel*> mChannels;
-};
-
-extern ChannelManager *channelManager;
-
-#endif
+/* + * The Mana World + * Copyright 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef _TMW_CHANNELMANAGER_H +#define _TMW_CHANNELMANAGER_H + +class Channel; + +class ChannelManager +{ +public: + ChannelManager(); + ~ChannelManager(); + Channel* findById(int id); + Channel* findByName(std::string name); + void addChannel(Channel *channel); + void removeChannel(Channel *channel); +private: + std::list<Channel*> mChannels; +}; + +extern ChannelManager *channelManager; + +#endif diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 2eada7ad..292e8fca 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -18,7 +18,7 @@ * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: login.cpp 2550 2006-08-20 00:56:23Z b_lindeijer $ + * $Id$ */ #include "serverdialog.h" diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index 2bb0609f..ae81cb2d 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -18,7 +18,7 @@ * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: login.h 2486 2006-07-30 14:33:28Z b_lindeijer $ + * $Id$ */ #ifndef _TMW_SERVERDIALOG_H diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index 5b5e86b9..60a98cc5 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -1,327 +1,327 @@ -/*
- * The Mana World
- * Copyright 2006 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include "particleemitter.h"
-
-#include "animationparticle.h"
-#include "imageparticle.h"
-#include "log.h"
-#include "particle.h"
-
-#include "resources/animation.h"
-#include "resources/image.h"
-#include "resources/resourcemanager.h"
-#include "resources/imageset.h"
-
-#include <cmath>
-
-#define SIN45 0.707106781f
-#define DEG_RAD_FACTOR 0.017453293f
-
-ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map):
- mParticleImage(0)
-{
- mMap = map;
- mParticleTarget = target;
-
- //initializing default values
- mParticlePosX.set(0.0f);
- mParticlePosY.set(0.0f);
- mParticlePosZ.set(0.0f);
- mParticleAngleHorizontal.set(0.0f);
- mParticleAngleVertical.set(0.0f);
- mParticlePower.set(0.0f);
- mParticleGravity.set(0.0f);
- mParticleRandomnes.set(0);
- mParticleBounce.set(0.0f);
- mParticleAcceleration.set(0.0f);
- mParticleDieDistance.set(-1.0f);
- mParticleMomentum.set(1.0f);
- mParticleLifetime.set(-1);
- mParticleFadeOut.set(0);
- mParticleFadeIn.set(0);
- mOutput.set(1);
-
- for_each_xml_child_node(propertyNode, emitterNode)
- {
- if (xmlStrEqual(propertyNode->name, BAD_CAST "property"))
- {
- std::string name = XML::getProperty(propertyNode, "name", "");
-
- if (name == "position-x")
- {
- mParticlePosX = readMinMax(propertyNode, 0.0f);
- }
- else if (name == "position-y")
- {
-
- mParticlePosY = readMinMax(propertyNode, 0.0f);
- mParticlePosY.minVal *= SIN45;
- mParticlePosY.maxVal *= SIN45;
- }
- else if (name == "position-z")
- {
- mParticlePosZ = readMinMax(propertyNode, 0.0f);
- mParticlePosZ.minVal *= SIN45;
- mParticlePosZ.maxVal *= SIN45;
- }
- else if (name == "image")
- {
- std::string image = XML::getProperty(propertyNode, "value", "");
- // Don't leak when multiple images are defined
- if (image != "" && !mParticleImage)
- {
- ResourceManager *resman = ResourceManager::getInstance();
- mParticleImage = resman->getImage(image);
- }
- }
- else if (name == "horizontal-angle")
- {
- mParticleAngleHorizontal = readMinMax(propertyNode, 0.0f);
- mParticleAngleHorizontal.minVal *= DEG_RAD_FACTOR;
- mParticleAngleHorizontal.maxVal *= DEG_RAD_FACTOR;
- }
- else if (name == "vertical-angle")
- {
- mParticleAngleVertical = readMinMax(propertyNode, 0.0f);
- mParticleAngleVertical.minVal *= DEG_RAD_FACTOR;
- mParticleAngleVertical.maxVal *= DEG_RAD_FACTOR;
- }
- else if (name == "power")
- {
- mParticlePower = readMinMax(propertyNode, 0.0f);
- }
- else if (name == "gravity")
- {
- mParticleGravity = readMinMax(propertyNode, 0.0f);
- }
- else if (name == "randomnes")
- {
- mParticleRandomnes = readMinMax(propertyNode, 0);
- }
- else if (name == "bounce")
- {
- mParticleBounce = readMinMax(propertyNode, 0.0f);
- }
- else if (name == "lifetime")
- {
- mParticleLifetime = readMinMax(propertyNode, 0);
- mParticleLifetime.minVal += 1;
- }
- else if (name == "output")
- {
- mOutput = readMinMax(propertyNode, 0);
- mOutput.maxVal +=1;
- }
- else if (name == "acceleration")
- {
- mParticleAcceleration = readMinMax(propertyNode, 0.0f);
- }
- else if (name == "die-distance")
- {
- mParticleDieDistance = readMinMax(propertyNode, 0.0f);
- }
- else if (name == "momentum")
- {
- mParticleMomentum = readMinMax(propertyNode, 1.0f);
- }
- else if (name == "fade-out")
- {
- mParticleFadeOut = readMinMax(propertyNode, 0);
- }
- else if (name == "fade-in")
- {
- mParticleFadeIn = readMinMax(propertyNode, 0);
- }
- else
- {
- logger->log("Particle Engine: Warning, unknown emitter property \"%s\"",
- name.c_str()
- );
- }
- }
- else if (xmlStrEqual(propertyNode->name, BAD_CAST "emitter"))
- {
- ParticleEmitter newEmitter(propertyNode, mParticleTarget, map);
- mParticleChildEmitters.push_back(newEmitter);
- }
- else if (xmlStrEqual(propertyNode->name, BAD_CAST "animation"))
- {
- ImageSet *imageset = ResourceManager::getInstance()->getImageSet(
- XML::getProperty(propertyNode, "imageset", ""),
- XML::getProperty(propertyNode, "width", 0),
- XML::getProperty(propertyNode, "height", 0)
- );
-
- // Get animation frames
- for_each_xml_child_node(frameNode, propertyNode)
- {
- int delay = XML::getProperty(frameNode, "delay", 0);
- int offsetX = XML::getProperty(frameNode, "offsetX", 0);
- int offsetY = XML::getProperty(frameNode, "offsetY", 0);
- offsetY -= imageset->getHeight() - 32;
- offsetX -= imageset->getWidth() / 2 - 16;
-
- if (xmlStrEqual(frameNode->name, BAD_CAST "frame"))
- {
- int index = XML::getProperty(frameNode, "index", -1);
-
- if (index < 0)
- {
- logger->log("No valid value for 'index'");
- continue;
- }
-
- Image *img = imageset->get(index);
-
- if (!img)
- {
- logger->log("No image at index " + (index));
- continue;
- }
-
- mParticleAnimation.addFrame(img, delay, offsetX, offsetY);
- }
- else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence"))
- {
- int start = XML::getProperty(frameNode, "start", -1);
- int end = XML::getProperty(frameNode, "end", -1);
-
- if (start < 0 || end < 0)
- {
- logger->log("No valid value for 'start' or 'end'");
- continue;
- }
-
- while (end >= start)
- {
- Image *img = imageset->get(start);
-
- if (!img)
- {
- logger->log("No image at index " +
- (start));
- continue;
- }
-
- mParticleAnimation.addFrame(img, delay, offsetX, offsetY);
- start++;
- }
- }
- else if (xmlStrEqual(frameNode->name, BAD_CAST "end"))
- {
- mParticleAnimation.addTerminator();
- }
- } // for frameNode
- }
- }
-}
-
-
-ParticleEmitter::~ParticleEmitter()
-{
-}
-
-
-template <typename T> MinMax<T>
-ParticleEmitter::readMinMax(xmlNodePtr propertyNode, T def)
-{
- MinMax<T> retval;
-
- def = (T)XML::getFloatProperty(propertyNode, "value", (double)def);
- retval.set ( (T)XML::getFloatProperty(propertyNode, "min", (double)def),
- (T)XML::getFloatProperty(propertyNode, "max", (double)def)
- );
-
- return retval;
-}
-
-
-std::list<Particle *>
-ParticleEmitter::createParticles()
-{
- std::list<Particle *> newParticles;
-
- for (int i = mOutput.value(); i > 0; i--)
- {
- // Limit maximum particles
- if (Particle::particleCount > Particle::maxCount) break;
-
- Particle *newParticle;
- if (mParticleImage)
- {
- newParticle = new ImageParticle(mMap, mParticleImage);
- }
- else if (mParticleAnimation.getLength() > 0)
- {
- Animation *newAnimation = new Animation(mParticleAnimation);
- newParticle = new AnimationParticle(mMap, newAnimation);
- }
- else
- {
- newParticle = new Particle(mMap);
- }
-
-
- newParticle->setPosition(
- mParticlePosX.value(),
- mParticlePosY.value(),
- mParticlePosZ.value()
- );
-
- float angleH = mParticleAngleHorizontal.value();
- float angleV = mParticleAngleVertical.value();
- float power = mParticlePower.value();
- newParticle->setVector(
- cos(angleH) * cos(angleV) * power,
- sin(angleH) * cos(angleV) * power,
- sin(angleV) * power
- );
-
- newParticle->setRandomnes(mParticleRandomnes.value());
- newParticle->setGravity(mParticleGravity.value());
- newParticle->setBounce(mParticleBounce.value());
-
- newParticle->setDestination(mParticleTarget,
- mParticleAcceleration.value(),
- mParticleMomentum.value()
- );
- newParticle->setDieDistance(mParticleDieDistance.value());
-
- newParticle->setLifetime(mParticleLifetime.value());
- newParticle->setFadeOut(mParticleFadeOut.value());
- newParticle->setFadeIn(mParticleFadeIn.value());
-
- for ( std::list<ParticleEmitter>::iterator i = mParticleChildEmitters.begin();
- i != mParticleChildEmitters.end();
- i++
- )
- {
- newParticle->addEmitter(new ParticleEmitter(*i));
- }
-
- newParticles.push_back(newParticle);
- }
-
- return newParticles;
-}
+/* + * The Mana World + * Copyright 2006 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "particleemitter.h" + +#include "animationparticle.h" +#include "imageparticle.h" +#include "log.h" +#include "particle.h" + +#include "resources/animation.h" +#include "resources/image.h" +#include "resources/resourcemanager.h" +#include "resources/imageset.h" + +#include <cmath> + +#define SIN45 0.707106781f +#define DEG_RAD_FACTOR 0.017453293f + +ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map): + mParticleImage(0) +{ + mMap = map; + mParticleTarget = target; + + //initializing default values + mParticlePosX.set(0.0f); + mParticlePosY.set(0.0f); + mParticlePosZ.set(0.0f); + mParticleAngleHorizontal.set(0.0f); + mParticleAngleVertical.set(0.0f); + mParticlePower.set(0.0f); + mParticleGravity.set(0.0f); + mParticleRandomnes.set(0); + mParticleBounce.set(0.0f); + mParticleAcceleration.set(0.0f); + mParticleDieDistance.set(-1.0f); + mParticleMomentum.set(1.0f); + mParticleLifetime.set(-1); + mParticleFadeOut.set(0); + mParticleFadeIn.set(0); + mOutput.set(1); + + for_each_xml_child_node(propertyNode, emitterNode) + { + if (xmlStrEqual(propertyNode->name, BAD_CAST "property")) + { + std::string name = XML::getProperty(propertyNode, "name", ""); + + if (name == "position-x") + { + mParticlePosX = readMinMax(propertyNode, 0.0f); + } + else if (name == "position-y") + { + + mParticlePosY = readMinMax(propertyNode, 0.0f); + mParticlePosY.minVal *= SIN45; + mParticlePosY.maxVal *= SIN45; + } + else if (name == "position-z") + { + mParticlePosZ = readMinMax(propertyNode, 0.0f); + mParticlePosZ.minVal *= SIN45; + mParticlePosZ.maxVal *= SIN45; + } + else if (name == "image") + { + std::string image = XML::getProperty(propertyNode, "value", ""); + // Don't leak when multiple images are defined + if (image != "" && !mParticleImage) + { + ResourceManager *resman = ResourceManager::getInstance(); + mParticleImage = resman->getImage(image); + } + } + else if (name == "horizontal-angle") + { + mParticleAngleHorizontal = readMinMax(propertyNode, 0.0f); + mParticleAngleHorizontal.minVal *= DEG_RAD_FACTOR; + mParticleAngleHorizontal.maxVal *= DEG_RAD_FACTOR; + } + else if (name == "vertical-angle") + { + mParticleAngleVertical = readMinMax(propertyNode, 0.0f); + mParticleAngleVertical.minVal *= DEG_RAD_FACTOR; + mParticleAngleVertical.maxVal *= DEG_RAD_FACTOR; + } + else if (name == "power") + { + mParticlePower = readMinMax(propertyNode, 0.0f); + } + else if (name == "gravity") + { + mParticleGravity = readMinMax(propertyNode, 0.0f); + } + else if (name == "randomnes") + { + mParticleRandomnes = readMinMax(propertyNode, 0); + } + else if (name == "bounce") + { + mParticleBounce = readMinMax(propertyNode, 0.0f); + } + else if (name == "lifetime") + { + mParticleLifetime = readMinMax(propertyNode, 0); + mParticleLifetime.minVal += 1; + } + else if (name == "output") + { + mOutput = readMinMax(propertyNode, 0); + mOutput.maxVal +=1; + } + else if (name == "acceleration") + { + mParticleAcceleration = readMinMax(propertyNode, 0.0f); + } + else if (name == "die-distance") + { + mParticleDieDistance = readMinMax(propertyNode, 0.0f); + } + else if (name == "momentum") + { + mParticleMomentum = readMinMax(propertyNode, 1.0f); + } + else if (name == "fade-out") + { + mParticleFadeOut = readMinMax(propertyNode, 0); + } + else if (name == "fade-in") + { + mParticleFadeIn = readMinMax(propertyNode, 0); + } + else + { + logger->log("Particle Engine: Warning, unknown emitter property \"%s\"", + name.c_str() + ); + } + } + else if (xmlStrEqual(propertyNode->name, BAD_CAST "emitter")) + { + ParticleEmitter newEmitter(propertyNode, mParticleTarget, map); + mParticleChildEmitters.push_back(newEmitter); + } + else if (xmlStrEqual(propertyNode->name, BAD_CAST "animation")) + { + ImageSet *imageset = ResourceManager::getInstance()->getImageSet( + XML::getProperty(propertyNode, "imageset", ""), + XML::getProperty(propertyNode, "width", 0), + XML::getProperty(propertyNode, "height", 0) + ); + + // Get animation frames + for_each_xml_child_node(frameNode, propertyNode) + { + int delay = XML::getProperty(frameNode, "delay", 0); + int offsetX = XML::getProperty(frameNode, "offsetX", 0); + int offsetY = XML::getProperty(frameNode, "offsetY", 0); + offsetY -= imageset->getHeight() - 32; + offsetX -= imageset->getWidth() / 2 - 16; + + if (xmlStrEqual(frameNode->name, BAD_CAST "frame")) + { + int index = XML::getProperty(frameNode, "index", -1); + + if (index < 0) + { + logger->log("No valid value for 'index'"); + continue; + } + + Image *img = imageset->get(index); + + if (!img) + { + logger->log("No image at index " + (index)); + continue; + } + + mParticleAnimation.addFrame(img, delay, offsetX, offsetY); + } + else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence")) + { + int start = XML::getProperty(frameNode, "start", -1); + int end = XML::getProperty(frameNode, "end", -1); + + if (start < 0 || end < 0) + { + logger->log("No valid value for 'start' or 'end'"); + continue; + } + + while (end >= start) + { + Image *img = imageset->get(start); + + if (!img) + { + logger->log("No image at index " + + (start)); + continue; + } + + mParticleAnimation.addFrame(img, delay, offsetX, offsetY); + start++; + } + } + else if (xmlStrEqual(frameNode->name, BAD_CAST "end")) + { + mParticleAnimation.addTerminator(); + } + } // for frameNode + } + } +} + + +ParticleEmitter::~ParticleEmitter() +{ +} + + +template <typename T> MinMax<T> +ParticleEmitter::readMinMax(xmlNodePtr propertyNode, T def) +{ + MinMax<T> retval; + + def = (T)XML::getFloatProperty(propertyNode, "value", (double)def); + retval.set ( (T)XML::getFloatProperty(propertyNode, "min", (double)def), + (T)XML::getFloatProperty(propertyNode, "max", (double)def) + ); + + return retval; +} + + +std::list<Particle *> +ParticleEmitter::createParticles() +{ + std::list<Particle *> newParticles; + + for (int i = mOutput.value(); i > 0; i--) + { + // Limit maximum particles + if (Particle::particleCount > Particle::maxCount) break; + + Particle *newParticle; + if (mParticleImage) + { + newParticle = new ImageParticle(mMap, mParticleImage); + } + else if (mParticleAnimation.getLength() > 0) + { + Animation *newAnimation = new Animation(mParticleAnimation); + newParticle = new AnimationParticle(mMap, newAnimation); + } + else + { + newParticle = new Particle(mMap); + } + + + newParticle->setPosition( + mParticlePosX.value(), + mParticlePosY.value(), + mParticlePosZ.value() + ); + + float angleH = mParticleAngleHorizontal.value(); + float angleV = mParticleAngleVertical.value(); + float power = mParticlePower.value(); + newParticle->setVector( + cos(angleH) * cos(angleV) * power, + sin(angleH) * cos(angleV) * power, + sin(angleV) * power + ); + + newParticle->setRandomnes(mParticleRandomnes.value()); + newParticle->setGravity(mParticleGravity.value()); + newParticle->setBounce(mParticleBounce.value()); + + newParticle->setDestination(mParticleTarget, + mParticleAcceleration.value(), + mParticleMomentum.value() + ); + newParticle->setDieDistance(mParticleDieDistance.value()); + + newParticle->setLifetime(mParticleLifetime.value()); + newParticle->setFadeOut(mParticleFadeOut.value()); + newParticle->setFadeIn(mParticleFadeIn.value()); + + for ( std::list<ParticleEmitter>::iterator i = mParticleChildEmitters.begin(); + i != mParticleChildEmitters.end(); + i++ + ) + { + newParticle->addEmitter(new ParticleEmitter(*i)); + } + + newParticles.push_back(newParticle); + } + + return newParticles; +} diff --git a/src/particleemitter.h b/src/particleemitter.h index ca6d8622..37d067a6 100644 --- a/src/particleemitter.h +++ b/src/particleemitter.h @@ -1,120 +1,120 @@ -/*
- * The Mana World
- * Copyright 2006 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#ifndef _PARTICLEEMITTER_H
-#define _PARTICLEEMITTER_H
-
-#include <list>
-
-#include "utils/xml.h"
-#include "utils/minmax.h"
-
-#include "resources/animation.h"
-
-class Image;
-class Map;
-class Particle;
-
-/**
- * Every Particle can have one or more particle emitters that create new
- * particles when they are updated
- */
-class ParticleEmitter
-{
- public:
- /**
- * Constructor.
- */
- ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map);
-
- /**
- * Destructor.
- */
- ~ParticleEmitter();
-
- /**
- * Spawns new particles
- * @return: a list of created particles
- */
- std::list<Particle *> createParticles();
-
- /**
- * Sets the target of the particles that are created
- */
- void
- setTarget(Particle *target)
- { mParticleTarget = target; };
-
- private:
- template <typename T> MinMax<T> readMinMax(xmlNodePtr propertyNode, T def);
-
- /**
- * initial position of particles:
- */
- MinMax<float> mParticlePosX, mParticlePosY, mParticlePosZ;
-
- /**
- * initial vector of particles:
- */
- MinMax<float> mParticleAngleHorizontal, mParticleAngleVertical;
-
- /**
- * Initial velocity of particles
- */
- MinMax<float> mParticlePower;
-
- /*
- * Vector changing of particles:
- */
- MinMax<float> mParticleGravity;
- MinMax<int> mParticleRandomnes;
- MinMax<float> mParticleBounce;
-
- /*
- * Properties of targeting particles:
- */
- Particle *mParticleTarget;
- MinMax<float> mParticleAcceleration;
- MinMax<float> mParticleDieDistance;
- MinMax<float> mParticleMomentum;
-
- /*
- * Behavior over time of the particles:
- */
- MinMax<int> mParticleLifetime;
- MinMax<int> mParticleFadeOut;
- MinMax<int> mParticleFadeIn;
-
- Map *mMap; /**< Map the particles are spawned on */
-
- MinMax<int> mOutput; /**< Number of particles spawned per update */
-
- Image *mParticleImage; /**< Particle image, if used */
-
- /** Filename of particle animation file */
- Animation mParticleAnimation;
-
- /** List of emitters the spawned particles are equipped with */
- std::list<ParticleEmitter> mParticleChildEmitters;
-};
-#endif
+/* + * The Mana World + * Copyright 2006 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef _PARTICLEEMITTER_H +#define _PARTICLEEMITTER_H + +#include <list> + +#include "utils/xml.h" +#include "utils/minmax.h" + +#include "resources/animation.h" + +class Image; +class Map; +class Particle; + +/** + * Every Particle can have one or more particle emitters that create new + * particles when they are updated + */ +class ParticleEmitter +{ + public: + /** + * Constructor. + */ + ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map); + + /** + * Destructor. + */ + ~ParticleEmitter(); + + /** + * Spawns new particles + * @return: a list of created particles + */ + std::list<Particle *> createParticles(); + + /** + * Sets the target of the particles that are created + */ + void + setTarget(Particle *target) + { mParticleTarget = target; }; + + private: + template <typename T> MinMax<T> readMinMax(xmlNodePtr propertyNode, T def); + + /** + * initial position of particles: + */ + MinMax<float> mParticlePosX, mParticlePosY, mParticlePosZ; + + /** + * initial vector of particles: + */ + MinMax<float> mParticleAngleHorizontal, mParticleAngleVertical; + + /** + * Initial velocity of particles + */ + MinMax<float> mParticlePower; + + /* + * Vector changing of particles: + */ + MinMax<float> mParticleGravity; + MinMax<int> mParticleRandomnes; + MinMax<float> mParticleBounce; + + /* + * Properties of targeting particles: + */ + Particle *mParticleTarget; + MinMax<float> mParticleAcceleration; + MinMax<float> mParticleDieDistance; + MinMax<float> mParticleMomentum; + + /* + * Behavior over time of the particles: + */ + MinMax<int> mParticleLifetime; + MinMax<int> mParticleFadeOut; + MinMax<int> mParticleFadeIn; + + Map *mMap; /**< Map the particles are spawned on */ + + MinMax<int> mOutput; /**< Number of particles spawned per update */ + + Image *mParticleImage; /**< Particle image, if used */ + + /** Filename of particle animation file */ + Animation mParticleAnimation; + + /** List of emitters the spawned particles are equipped with */ + std::list<ParticleEmitter> mParticleChildEmitters; +}; +#endif diff --git a/src/resources/equipmentdb.cpp b/src/resources/equipmentdb.cpp index 64982ce3..38ac6415 100644 --- a/src/resources/equipmentdb.cpp +++ b/src/resources/equipmentdb.cpp @@ -1,156 +1,156 @@ -/*
- * The Mana World
- * Copyright 2006 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include "equipmentdb.h"
-
-#include "resourcemanager.h"
-
-#include "../log.h"
-
-#include "../utils/dtor.h"
-#include "../utils/xml.h"
-
-namespace
-{
- EquipmentDB::EquipmentInfos mEquipmentInfos;
- EquipmentInfo mUnknown;
- bool mLoaded = false;
-}
-
-void
-EquipmentDB::load()
-{
- if (mLoaded)
- return;
-
- logger->log("Initializing equipment database...");
- mUnknown.setSprite("error.xml", 0);
- mUnknown.setSprite("error.xml", 1);
-
- ResourceManager *resman = ResourceManager::getInstance();
- int size;
- char *data = (char*)resman->loadFile("equipment.xml", size);
-
- if (!data)
- {
- logger->error("Equipment Database: Could not find equipment.xml!");
- }
-
- xmlDocPtr doc = xmlParseMemory(data, size);
- free(data);
-
- if (!doc)
- {
- logger->error("Equipment Database: Error while parsing equipment database (equipment.xml)!");
- }
-
- xmlNodePtr rootNode = xmlDocGetRootElement(doc);
- if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "equipments"))
- {
- logger->error("Equipment Database: equipment.xml is not a valid database file!");
- }
-
- //iterate <equipment>s
- for_each_xml_child_node(equipmentNode, rootNode)
- {
- if (!xmlStrEqual(equipmentNode->name, BAD_CAST "equipment"))
- {
- continue;
- }
-
- EquipmentInfo *currentInfo = new EquipmentInfo();
-
- currentInfo->setSlot (XML::getProperty(equipmentNode, "slot", 0));
-
- //iterate <sprite>s
- for_each_xml_child_node(spriteNode, equipmentNode)
- {
- if (!xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
- {
- continue;
- }
-
- std::string gender = XML::getProperty(spriteNode, "gender", "unisex");
- std::string filename = (const char*) spriteNode->xmlChildrenNode->content;
-
- if (gender == "male" || gender == "unisex")
- {
- currentInfo->setSprite(filename, 0);
- }
-
- if (gender == "female" || gender == "unisex")
- {
- currentInfo->setSprite(filename, 1);
- }
- }
-
- setEquipment( XML::getProperty(equipmentNode, "id", 0),
- currentInfo);
- }
-
- mLoaded = true;
-}
-
-void
-EquipmentDB::unload()
-{
- // kill EquipmentInfos
- for_each ( mEquipmentInfos.begin(), mEquipmentInfos.end(),
- make_dtor(mEquipmentInfos));
- mEquipmentInfos.clear();
-
- mLoaded = false;
-}
-
-EquipmentInfo*
-EquipmentDB::get(int id)
-{
- if (!mLoaded) {
- logger->error("Error: Equipment database used before initialization!");
- }
-
- EquipmentInfoIterator i = mEquipmentInfos.find(id);
-
- if (i == mEquipmentInfos.end() )
- {
- logger->log("EquipmentDB: Error, unknown equipment ID# %d", id);
- return &mUnknown;
- }
- else
- {
- return i->second;
- }
-}
-
-void
-EquipmentDB::setEquipment(int id, EquipmentInfo* equipmentInfo)
-{
- if (mEquipmentInfos.find(id) != mEquipmentInfos.end()) {
- logger->log("Warning: Equipment Piece with ID %d defined multiple times",
- id);
- delete equipmentInfo;
- }
- else {
- mEquipmentInfos[id] = equipmentInfo;
- };
-}
+/* + * The Mana World + * Copyright 2006 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "equipmentdb.h" + +#include "resourcemanager.h" + +#include "../log.h" + +#include "../utils/dtor.h" +#include "../utils/xml.h" + +namespace +{ + EquipmentDB::EquipmentInfos mEquipmentInfos; + EquipmentInfo mUnknown; + bool mLoaded = false; +} + +void +EquipmentDB::load() +{ + if (mLoaded) + return; + + logger->log("Initializing equipment database..."); + mUnknown.setSprite("error.xml", 0); + mUnknown.setSprite("error.xml", 1); + + ResourceManager *resman = ResourceManager::getInstance(); + int size; + char *data = (char*)resman->loadFile("equipment.xml", size); + + if (!data) + { + logger->error("Equipment Database: Could not find equipment.xml!"); + } + + xmlDocPtr doc = xmlParseMemory(data, size); + free(data); + + if (!doc) + { + logger->error("Equipment Database: Error while parsing equipment database (equipment.xml)!"); + } + + xmlNodePtr rootNode = xmlDocGetRootElement(doc); + if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "equipments")) + { + logger->error("Equipment Database: equipment.xml is not a valid database file!"); + } + + //iterate <equipment>s + for_each_xml_child_node(equipmentNode, rootNode) + { + if (!xmlStrEqual(equipmentNode->name, BAD_CAST "equipment")) + { + continue; + } + + EquipmentInfo *currentInfo = new EquipmentInfo(); + + currentInfo->setSlot (XML::getProperty(equipmentNode, "slot", 0)); + + //iterate <sprite>s + for_each_xml_child_node(spriteNode, equipmentNode) + { + if (!xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) + { + continue; + } + + std::string gender = XML::getProperty(spriteNode, "gender", "unisex"); + std::string filename = (const char*) spriteNode->xmlChildrenNode->content; + + if (gender == "male" || gender == "unisex") + { + currentInfo->setSprite(filename, 0); + } + + if (gender == "female" || gender == "unisex") + { + currentInfo->setSprite(filename, 1); + } + } + + setEquipment( XML::getProperty(equipmentNode, "id", 0), + currentInfo); + } + + mLoaded = true; +} + +void +EquipmentDB::unload() +{ + // kill EquipmentInfos + for_each ( mEquipmentInfos.begin(), mEquipmentInfos.end(), + make_dtor(mEquipmentInfos)); + mEquipmentInfos.clear(); + + mLoaded = false; +} + +EquipmentInfo* +EquipmentDB::get(int id) +{ + if (!mLoaded) { + logger->error("Error: Equipment database used before initialization!"); + } + + EquipmentInfoIterator i = mEquipmentInfos.find(id); + + if (i == mEquipmentInfos.end() ) + { + logger->log("EquipmentDB: Error, unknown equipment ID# %d", id); + return &mUnknown; + } + else + { + return i->second; + } +} + +void +EquipmentDB::setEquipment(int id, EquipmentInfo* equipmentInfo) +{ + if (mEquipmentInfos.find(id) != mEquipmentInfos.end()) { + logger->log("Warning: Equipment Piece with ID %d defined multiple times", + id); + delete equipmentInfo; + } + else { + mEquipmentInfos[id] = equipmentInfo; + }; +} diff --git a/src/resources/equipmentinfo.h b/src/resources/equipmentinfo.h index 93a1cb42..75ed1b8a 100644 --- a/src/resources/equipmentinfo.h +++ b/src/resources/equipmentinfo.h @@ -1,52 +1,52 @@ -/*
- * The Mana World
- * Copyright 2006 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id:
- */
-
-#ifndef _TMW_EQUIPMENTINFO_H_
-#define _TMW_EQUIPMENTINFO_H_
-
-#include <string>
-#include <map>
-
-class EquipmentInfo
-{
- public:
- EquipmentInfo():
- mSlot (0)
- {
- };
-
- void
- setSlot (int slot) { mSlot = slot; };
-
- const std::string&
- getSprite(int gender) {return animationFiles[gender]; };
-
- void
- setSprite(std::string animationFile, int gender) {animationFiles[gender] = animationFile; };
-
- private:
- int mSlot; //not used at the moment but maybe useful on our own server
- std::map<int, std::string> animationFiles;
-};
-
-#endif
+/* + * The Mana World + * Copyright 2006 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id: + */ + +#ifndef _TMW_EQUIPMENTINFO_H_ +#define _TMW_EQUIPMENTINFO_H_ + +#include <string> +#include <map> + +class EquipmentInfo +{ + public: + EquipmentInfo(): + mSlot (0) + { + }; + + void + setSlot (int slot) { mSlot = slot; }; + + const std::string& + getSprite(int gender) {return animationFiles[gender]; }; + + void + setSprite(std::string animationFile, int gender) {animationFiles[gender] = animationFile; }; + + private: + int mSlot; //not used at the moment but maybe useful on our own server + std::map<int, std::string> animationFiles; +}; + +#endif diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 70ead6ab..7b16339c 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -1,149 +1,149 @@ -/*
- * The Mana World
- * Copyright 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id:
- */
-
-#include "itemdb.h"
-
-#include <libxml/tree.h>
-
-#include "iteminfo.h"
-#include "resourcemanager.h"
-
-#include "../log.h"
-
-#include "../utils/dtor.h"
-#include "../utils/xml.h"
-
-namespace
-{
- ItemDB::ItemInfos mItemInfos;
- ItemInfo mUnknown;
- bool mLoaded = false;
-}
-
-
-void ItemDB::load()
-{
- if (mLoaded)
- return;
-
- logger->log("Initializing item database...");
- mUnknown.setName("Unknown item");
-
- ResourceManager *resman = ResourceManager::getInstance();
- int size;
- char *data = (char*)resman->loadFile("items.xml", size);
-
- if (!data) {
- logger->error("ItemDB: Could not find items.xml!");
- }
-
- xmlDocPtr doc = xmlParseMemory(data, size);
- free(data);
-
- if (!doc)
- {
- logger->error("ItemDB: Error while parsing item database (items.xml)!");
- }
-
- xmlNodePtr rootNode = xmlDocGetRootElement(doc);
- if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "items"))
- {
- logger->error("ItemDB: items.xml is not a valid database file!");
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (!xmlStrEqual(node->name, BAD_CAST "item")) {
- continue;
- }
-
- int id = XML::getProperty(node, "id", 0);
- int art = XML::getProperty(node, "art", 0);
- int type = XML::getProperty(node, "type", 0);
- int weight = XML::getProperty(node, "weight", 0);
- int slot = XML::getProperty(node, "slot", 0);
-
- std::string name = XML::getProperty(node, "name", "");
- std::string image = XML::getProperty(node, "image", "");
- std::string description = XML::getProperty(node, "description", "");
- std::string effect = XML::getProperty(node, "effect", "");
-
- if (id && name != "")
- {
- ItemInfo *itemInfo = new ItemInfo();
- itemInfo->setImage(image);
- itemInfo->setArt(art);
- itemInfo->setName(name);
- itemInfo->setDescription(description);
- itemInfo->setEffect(effect);
- itemInfo->setType(type);
- itemInfo->setWeight(weight);
- itemInfo->setSlot(slot);
- mItemInfos[id] = itemInfo;
- }
-
- if (id == 0)
- {
- logger->log("ItemDB: An item has no ID in items.xml!");
- }
-
-#define CHECK_PARAM(param, error_value) \
- if (param == error_value) \
- logger->log("ItemDB: Missing" #param " parameter for item %i! %s", \
- id, name.c_str())
-
- CHECK_PARAM(name, "");
- CHECK_PARAM(image, "");
- // CHECK_PARAM(art, 0);
- // CHECK_PARAM(description, "");
- // CHECK_PARAM(effect, "");
- // CHECK_PARAM(type, 0);
- CHECK_PARAM(weight, 0);
- // CHECK_PARAM(slot, 0);
-
-#undef CHECK_PARAM
- }
-
- xmlFreeDoc(doc);
-
- mLoaded = true;
-}
-
-void ItemDB::unload()
-{
- for (ItemInfoIterator i = mItemInfos.begin(); i != mItemInfos.end(); i++)
- {
- delete i->second;
- }
- mItemInfos.clear();
-
- mLoaded = false;
-}
-
-const ItemInfo&
-ItemDB::get(int id)
-{
- ItemInfoIterator i = mItemInfos.find(id);
-
- return (i != mItemInfos.end()) ? *(i->second) : mUnknown;
-}
+/* + * The Mana World + * Copyright 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id: + */ + +#include "itemdb.h" + +#include <libxml/tree.h> + +#include "iteminfo.h" +#include "resourcemanager.h" + +#include "../log.h" + +#include "../utils/dtor.h" +#include "../utils/xml.h" + +namespace +{ + ItemDB::ItemInfos mItemInfos; + ItemInfo mUnknown; + bool mLoaded = false; +} + + +void ItemDB::load() +{ + if (mLoaded) + return; + + logger->log("Initializing item database..."); + mUnknown.setName("Unknown item"); + + ResourceManager *resman = ResourceManager::getInstance(); + int size; + char *data = (char*)resman->loadFile("items.xml", size); + + if (!data) { + logger->error("ItemDB: Could not find items.xml!"); + } + + xmlDocPtr doc = xmlParseMemory(data, size); + free(data); + + if (!doc) + { + logger->error("ItemDB: Error while parsing item database (items.xml)!"); + } + + xmlNodePtr rootNode = xmlDocGetRootElement(doc); + if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "items")) + { + logger->error("ItemDB: items.xml is not a valid database file!"); + } + + for_each_xml_child_node(node, rootNode) + { + if (!xmlStrEqual(node->name, BAD_CAST "item")) { + continue; + } + + int id = XML::getProperty(node, "id", 0); + int art = XML::getProperty(node, "art", 0); + int type = XML::getProperty(node, "type", 0); + int weight = XML::getProperty(node, "weight", 0); + int slot = XML::getProperty(node, "slot", 0); + + std::string name = XML::getProperty(node, "name", ""); + std::string image = XML::getProperty(node, "image", ""); + std::string description = XML::getProperty(node, "description", ""); + std::string effect = XML::getProperty(node, "effect", ""); + + if (id && name != "") + { + ItemInfo *itemInfo = new ItemInfo(); + itemInfo->setImage(image); + itemInfo->setArt(art); + itemInfo->setName(name); + itemInfo->setDescription(description); + itemInfo->setEffect(effect); + itemInfo->setType(type); + itemInfo->setWeight(weight); + itemInfo->setSlot(slot); + mItemInfos[id] = itemInfo; + } + + if (id == 0) + { + logger->log("ItemDB: An item has no ID in items.xml!"); + } + +#define CHECK_PARAM(param, error_value) \ + if (param == error_value) \ + logger->log("ItemDB: Missing" #param " parameter for item %i! %s", \ + id, name.c_str()) + + CHECK_PARAM(name, ""); + CHECK_PARAM(image, ""); + // CHECK_PARAM(art, 0); + // CHECK_PARAM(description, ""); + // CHECK_PARAM(effect, ""); + // CHECK_PARAM(type, 0); + CHECK_PARAM(weight, 0); + // CHECK_PARAM(slot, 0); + +#undef CHECK_PARAM + } + + xmlFreeDoc(doc); + + mLoaded = true; +} + +void ItemDB::unload() +{ + for (ItemInfoIterator i = mItemInfos.begin(); i != mItemInfos.end(); i++) + { + delete i->second; + } + mItemInfos.clear(); + + mLoaded = false; +} + +const ItemInfo& +ItemDB::get(int id) +{ + ItemInfoIterator i = mItemInfos.find(id); + + return (i != mItemInfos.end()) ? *(i->second) : mUnknown; +} diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 6ead5b22..df7e7be9 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -1,53 +1,53 @@ -/*
- * The Mana World
- * Copyright 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id: itemdb.h 2650 2006-09-03 15:00:47Z b_lindeijer $
- */
-
-#ifndef _TMW_ITEM_MANAGER_H
-#define _TMW_ITEM_MANAGER_H
-
-#include "iteminfo.h"
-
-#include <map>
-
-/**
- * Item information database.
- */
-namespace ItemDB
-{
- /**
- * Loads the item data from <code>items.xml</code>.
- */
- void load();
-
- /**
- * Frees item data.
- */
- void unload();
-
- const ItemInfo& get(int id);
-
- // Items database
- typedef std::map<int, ItemInfo*> ItemInfos;
- typedef ItemInfos::iterator ItemInfoIterator;
-}
-
-#endif
+/* + * The Mana World + * Copyright 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef _TMW_ITEM_MANAGER_H +#define _TMW_ITEM_MANAGER_H + +#include "iteminfo.h" + +#include <map> + +/** + * Item information database. + */ +namespace ItemDB +{ + /** + * Loads the item data from <code>items.xml</code>. + */ + void load(); + + /** + * Frees item data. + */ + void unload(); + + const ItemInfo& get(int id); + + // Items database + typedef std::map<int, ItemInfo*> ItemInfos; + typedef ItemInfos::iterator ItemInfoIterator; +} + +#endif diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 89afc549..339ed6ba 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -1,175 +1,175 @@ -/*
- * The Mana World
- * Copyright 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include "monsterdb.h"
-
-#include "resourcemanager.h"
-
-#include "../log.h"
-
-#include "../utils/dtor.h"
-#include "../utils/xml.h"
-
-namespace
-{
- MonsterDB::MonsterInfos mMonsterInfos;
- MonsterInfo mUnknown;
- bool mLoaded = false;
-}
-
-void
-MonsterDB::load()
-{
- if (mLoaded)
- return;
-
- mUnknown.setSprite("error.xml");
- mUnknown.setName("unnamed");
-
- logger->log("Initializing monster database...");
-
- ResourceManager *resman = ResourceManager::getInstance();
- int size;
- char *data = (char*)resman->loadFile("monsters.xml", size);
-
- if (!data)
- {
- logger->error("Monster Database: Could not find monsters.xml!");
- }
-
- xmlDocPtr doc = xmlParseMemory(data, size);
- free(data);
-
- if (!doc)
- {
- logger->error("Monster Database: Error while parsing monster database (monsters.xml)!");
- }
-
- xmlNodePtr rootNode = xmlDocGetRootElement(doc);
- if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "monsters"))
- {
- logger->error("Monster Database: monster.xml is not a valid database file!");
- }
-
- //iterate <monster>s
- for_each_xml_child_node(monsterNode, rootNode)
- {
- if (!xmlStrEqual(monsterNode->name, BAD_CAST "monster"))
- {
- continue;
- }
-
- MonsterInfo *currentInfo = new MonsterInfo();
-
- currentInfo->setName (XML::getProperty(monsterNode, "name", "unnamed"));
-
- std::string targetCursor;
- targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium");
- if (targetCursor == "small")
- {
- currentInfo->setTargetCursorSize(Being::TC_SMALL);
- }
- else if (targetCursor == "medium")
- {
- currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
- }
- else if (targetCursor == "large")
- {
- currentInfo->setTargetCursorSize(Being::TC_LARGE);
- }
- else
- {
- 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);
- }
-
- //iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, monsterNode)
- {
- if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
- {
- currentInfo->setSprite((const char*) spriteNode->xmlChildrenNode->content);
- }
-
- if (xmlStrEqual(spriteNode->name, BAD_CAST "sound"))
- {
- std::string event = XML::getProperty(spriteNode, "event", "");
- const char *filename;
- filename = (const char*) spriteNode->xmlChildrenNode->content;
-
- if (event == "hit")
- {
- currentInfo->addSound(EVENT_HIT, filename);
- }
- else if (event == "miss")
- {
- currentInfo->addSound(EVENT_MISS, filename);
- }
- else if (event == "hurt")
- {
- currentInfo->addSound(EVENT_HURT, filename);
- }
- else if (event == "die")
- {
- currentInfo->addSound(EVENT_DIE, filename);
- }
- else
- {
- logger->log("MonsterDB: Warning, sound effect %s for unknown event %s of monster %s",
- filename, event.c_str(), currentInfo->getName().c_str());
- }
- }
- }
- mMonsterInfos[XML::getProperty(monsterNode, "id", 0)] = currentInfo;
- }
-
- mLoaded = true;
-}
-
-void
-MonsterDB::unload()
-{
- for_each ( mMonsterInfos.begin(), mMonsterInfos.end(),
- make_dtor(mMonsterInfos));
- mMonsterInfos.clear();
-
- mLoaded = false;
-}
-
-
-const MonsterInfo&
-MonsterDB::get (int id)
-{
- MonsterInfoIterator i = mMonsterInfos.find(id);
-
- if (i == mMonsterInfos.end())
- {
- logger->log("MonsterDB: Warning, unknown monster ID %d requested", id);
- return mUnknown;
- }
- else
- {
- return *(i->second);
- }
-}
+/* + * The Mana World + * Copyright 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "monsterdb.h" + +#include "resourcemanager.h" + +#include "../log.h" + +#include "../utils/dtor.h" +#include "../utils/xml.h" + +namespace +{ + MonsterDB::MonsterInfos mMonsterInfos; + MonsterInfo mUnknown; + bool mLoaded = false; +} + +void +MonsterDB::load() +{ + if (mLoaded) + return; + + mUnknown.setSprite("error.xml"); + mUnknown.setName("unnamed"); + + logger->log("Initializing monster database..."); + + ResourceManager *resman = ResourceManager::getInstance(); + int size; + char *data = (char*)resman->loadFile("monsters.xml", size); + + if (!data) + { + logger->error("Monster Database: Could not find monsters.xml!"); + } + + xmlDocPtr doc = xmlParseMemory(data, size); + free(data); + + if (!doc) + { + logger->error("Monster Database: Error while parsing monster database (monsters.xml)!"); + } + + xmlNodePtr rootNode = xmlDocGetRootElement(doc); + if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "monsters")) + { + logger->error("Monster Database: monster.xml is not a valid database file!"); + } + + //iterate <monster>s + for_each_xml_child_node(monsterNode, rootNode) + { + if (!xmlStrEqual(monsterNode->name, BAD_CAST "monster")) + { + continue; + } + + MonsterInfo *currentInfo = new MonsterInfo(); + + currentInfo->setName (XML::getProperty(monsterNode, "name", "unnamed")); + + std::string targetCursor; + targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium"); + if (targetCursor == "small") + { + currentInfo->setTargetCursorSize(Being::TC_SMALL); + } + else if (targetCursor == "medium") + { + currentInfo->setTargetCursorSize(Being::TC_MEDIUM); + } + else if (targetCursor == "large") + { + currentInfo->setTargetCursorSize(Being::TC_LARGE); + } + else + { + 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); + } + + //iterate <sprite>s and <sound>s + for_each_xml_child_node(spriteNode, monsterNode) + { + if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) + { + currentInfo->setSprite((const char*) spriteNode->xmlChildrenNode->content); + } + + if (xmlStrEqual(spriteNode->name, BAD_CAST "sound")) + { + std::string event = XML::getProperty(spriteNode, "event", ""); + const char *filename; + filename = (const char*) spriteNode->xmlChildrenNode->content; + + if (event == "hit") + { + currentInfo->addSound(EVENT_HIT, filename); + } + else if (event == "miss") + { + currentInfo->addSound(EVENT_MISS, filename); + } + else if (event == "hurt") + { + currentInfo->addSound(EVENT_HURT, filename); + } + else if (event == "die") + { + currentInfo->addSound(EVENT_DIE, filename); + } + else + { + logger->log("MonsterDB: Warning, sound effect %s for unknown event %s of monster %s", + filename, event.c_str(), currentInfo->getName().c_str()); + } + } + } + mMonsterInfos[XML::getProperty(monsterNode, "id", 0)] = currentInfo; + } + + mLoaded = true; +} + +void +MonsterDB::unload() +{ + for_each ( mMonsterInfos.begin(), mMonsterInfos.end(), + make_dtor(mMonsterInfos)); + mMonsterInfos.clear(); + + mLoaded = false; +} + + +const MonsterInfo& +MonsterDB::get (int id) +{ + MonsterInfoIterator i = mMonsterInfos.find(id); + + if (i == mMonsterInfos.end()) + { + logger->log("MonsterDB: Warning, unknown monster ID %d requested", id); + return mUnknown; + } + else + { + return *(i->second); + } +} diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp index 43aac32a..2a59419e 100644 --- a/src/resources/monsterinfo.cpp +++ b/src/resources/monsterinfo.cpp @@ -1,70 +1,70 @@ -/*
- * The Mana World
- * Copyright 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id: monsterinfo.cpp 2650 2006-09-03 15:00:47Z b_lindeijer $
- */
-
-#include "monsterinfo.h"
-
-#include "../utils/dtor.h"
-
-MonsterInfo::MonsterInfo():
- mSprite("error.xml")
-{
-
-}
-
-MonsterInfo::~MonsterInfo()
-{
- //kill vectors in mSoundEffects
- for_each ( mSounds.begin(), mSounds.end(),
- make_dtor(mSounds));
- mSounds.clear();
-}
-
-
-void
-MonsterInfo::addSound (SoundEvent event, std::string filename)
-{
- if (mSounds.find(event) == mSounds.end())
- {
- mSounds[event] = new std::vector<std::string>;
- }
-
- mSounds[event]->push_back("sfx/" + filename);
-}
-
-
-std::string
-MonsterInfo::getSound (SoundEvent event) const
-{
- std::map<SoundEvent, std::vector<std::string>* >::const_iterator i;
-
- i = mSounds.find(event);
-
- if (i == mSounds.end())
- {
- return "";
- }
- else
- {
- return i->second->at(rand()%i->second->size());
- }
-}
+/* + * The Mana World + * Copyright 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "monsterinfo.h" + +#include "../utils/dtor.h" + +MonsterInfo::MonsterInfo(): + mSprite("error.xml") +{ + +} + +MonsterInfo::~MonsterInfo() +{ + //kill vectors in mSoundEffects + for_each ( mSounds.begin(), mSounds.end(), + make_dtor(mSounds)); + mSounds.clear(); +} + + +void +MonsterInfo::addSound (SoundEvent event, std::string filename) +{ + if (mSounds.find(event) == mSounds.end()) + { + mSounds[event] = new std::vector<std::string>; + } + + mSounds[event]->push_back("sfx/" + filename); +} + + +std::string +MonsterInfo::getSound (SoundEvent event) const +{ + std::map<SoundEvent, std::vector<std::string>* >::const_iterator i; + + i = mSounds.find(event); + + if (i == mSounds.end()) + { + return ""; + } + else + { + return i->second->at(rand()%i->second->size()); + } +} diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index d2a0a2c8..aa7db9f0 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -18,7 +18,7 @@ * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: monsterinfo.h 2650 2006-09-03 15:00:47Z b_lindeijer $ + * $Id$ */ #ifndef _TMW_MONSTERINFO_H_ diff --git a/src/resources/openglsdlimageloader.cpp b/src/resources/openglsdlimageloader.cpp index 68de1e19..9b6645bd 100644 --- a/src/resources/openglsdlimageloader.cpp +++ b/src/resources/openglsdlimageloader.cpp @@ -18,7 +18,7 @@ * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: sdlimageloader.cpp 2121 2006-01-31 02:55:26Z der_doener $ + * $Id$ */ #include "openglsdlimageloader.h" diff --git a/src/resources/openglsdlimageloader.h b/src/resources/openglsdlimageloader.h index b79dde15..d776dafe 100644 --- a/src/resources/openglsdlimageloader.h +++ b/src/resources/openglsdlimageloader.h @@ -18,7 +18,7 @@ * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: sdlimageloader.h 1724 2005-09-12 22:15:35Z der_doener $ + * $Id$ */ #ifndef _TMW_OPENGLSDLIMAGELOADER_H diff --git a/src/utils/fastsqrt.h b/src/utils/fastsqrt.h index 8da1d354..78768149 100644 --- a/src/utils/fastsqrt.h +++ b/src/utils/fastsqrt.h @@ -1,24 +1,24 @@ -/* A very fast function to calculate the approximate inverse square root of a
- * floating point value and a helper function that uses it for getting the
- * normal squareroot. For an explanation of the inverse squareroot function
- * read:
- * http://www.math.purdue.edu/~clomont/Math/Papers/2003/InvSqrt.pdf
- *
- * Unfortunately the original creator of this function seems to be unknown.
- */
-
-float fastInvSqrt(float x)
-{
- union { int i; float x; } tmp;
- float xhalf = 0.5f * x;
- tmp.x = x;
- tmp.i = 0x5f375a86 - (tmp.i >> 1);
- x = tmp.x;
- x = x * (1.5f - xhalf * x * x);
- return x;
-}
-
-float fastSqrt(float x)
-{
- return 1.0f / fastInvSqrt(x);
-}
+/* A very fast function to calculate the approximate inverse square root of a + * floating point value and a helper function that uses it for getting the + * normal squareroot. For an explanation of the inverse squareroot function + * read: + * http://www.math.purdue.edu/~clomont/Math/Papers/2003/InvSqrt.pdf + * + * Unfortunately the original creator of this function seems to be unknown. + */ + +float fastInvSqrt(float x) +{ + union { int i; float x; } tmp; + float xhalf = 0.5f * x; + tmp.x = x; + tmp.i = 0x5f375a86 - (tmp.i >> 1); + x = tmp.x; + x = x * (1.5f - xhalf * x * x); + return x; +} + +float fastSqrt(float x) +{ + return 1.0f / fastInvSqrt(x); +} diff --git a/src/utils/minmax.h b/src/utils/minmax.h index 1add2b7e..27eb2565 100644 --- a/src/utils/minmax.h +++ b/src/utils/minmax.h @@ -1,47 +1,47 @@ -/*
- * The Mana World
- * Copyright 2006 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
- * 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,
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-/**
- * Returns a random numeric value that is larger than or equal min and smaller
- * than max
- */
-
-template <typename T> struct MinMax
-{
- void set(T min, T max)
- {
- minVal=min; maxVal=max;
- }
-
- void set(T val)
- {
- set(val, val);
- }
-
- T value()
- {
- return (T)(minVal + (maxVal - minVal) * (rand() / ((double) RAND_MAX + 1)));
- }
-
- T minVal;
- T maxVal;
-};
+/* + * The Mana World + * Copyright 2006 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 + * 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, + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/** + * Returns a random numeric value that is larger than or equal min and smaller + * than max + */ + +template <typename T> struct MinMax +{ + void set(T min, T max) + { + minVal=min; maxVal=max; + } + + void set(T val) + { + set(val, val); + } + + T value() + { + return (T)(minVal + (maxVal - minVal) * (rand() / ((double) RAND_MAX + 1))); + } + + T minVal; + T maxVal; +}; |