summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-11-01 21:33:51 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-11-01 22:21:00 +0100
commit63ff01f1d53f2c362beb60fdba664efe19593131 (patch)
tree8ae409671e587fdb0263e8814ff8a614bec06884 /src
parent6129e5bf1fe0128eb7742a7270e1264b65798bbb (diff)
downloadmanaserv-63ff01f1d53f2c362beb60fdba664efe19593131.tar.gz
manaserv-63ff01f1d53f2c362beb60fdba664efe19593131.tar.bz2
manaserv-63ff01f1d53f2c362beb60fdba664efe19593131.tar.xz
manaserv-63ff01f1d53f2c362beb60fdba664efe19593131.zip
Prevented a crash in the monster loading code.
The server was trying to insert attributes value not in monster scope. The monster code is to be rewritten anyway. Resolves: Mana-Mantis #212.
Diffstat (limited to 'src')
-rw-r--r--src/game-server/monster.cpp6
-rw-r--r--src/game-server/monster.hpp7
2 files changed, 12 insertions, 1 deletions
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index 2412c849..4df000ed 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -96,7 +96,11 @@ Monster::Monster(MonsterClass *specy):
it2 != it2_end;
++it2)
{
- double attr = specy->getAttribute(it2->first);
+ double attr = 0.0f;
+
+ if (specy->hasAttribute(it2->first))
+ attr = specy->getAttribute(it2->first);
+
setAttribute(it2->first,
mutation ?
attr * (100 + (rand()%(mutation << 1)) - mutation) / 100.0 :
diff --git a/src/game-server/monster.hpp b/src/game-server/monster.hpp
index 0d5d9688..b25e9c17 100644
--- a/src/game-server/monster.hpp
+++ b/src/game-server/monster.hpp
@@ -107,6 +107,13 @@ class MonsterClass
double getAttribute(int attribute) const
{ return mAttributes.at(attribute); }
+ /**
+ * Returns whether the monster has got the attribute.
+ */
+ bool hasAttribute(int attribute) const
+ { return (mAttributes.find(attribute) != mAttributes.end()); }
+
+
/** Sets collision circle radius. */
void setSize(int size) { mSize = size; }