summaryrefslogtreecommitdiff
path: root/src/game-server
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-11 03:00:03 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-04-15 23:09:16 +0200
commitf529913ebe287cdd33be5ddafd4a8452f41e9383 (patch)
treec8836cc9d1da91999d659b092ed9c3630bb3c34a /src/game-server
parent89944ee6755a8d1cf1afb8e1e4808529bccf04c6 (diff)
downloadmanaserv-f529913ebe287cdd33be5ddafd4a8452f41e9383.tar.gz
manaserv-f529913ebe287cdd33be5ddafd4a8452f41e9383.tar.bz2
manaserv-f529913ebe287cdd33be5ddafd4a8452f41e9383.tar.xz
manaserv-f529913ebe287cdd33be5ddafd4a8452f41e9383.zip
Fixed crash on first map update
The crash happened when it was trying to move an NPC from its old zone to its new zone. The old zone was based on the old position, which was (0,0). That crashed since its zone didn't match its old position, but its new one. This fix makes sure to update the old position to be in sync with the zone, by resetting it after being inserted into the MapComposite. Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/game-server')
-rw-r--r--src/game-server/being.cpp12
-rw-r--r--src/game-server/being.h4
2 files changed, 16 insertions, 0 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index d27eb179..07a0a9fc 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -292,6 +292,9 @@ void Being::move()
|| !getModifiedAttribute(ATTR_MOVE_SPEED_RAW))
return;
+ // Remember the current position before moving. This is used by
+ // MapComposite::update() to determine whether a being has moved from one
+ // zone to another.
mOld = getPosition();
if (mMoveTime > WORLD_TICK_MS)
@@ -660,6 +663,15 @@ void Being::update()
died();
}
+void Being::inserted()
+{
+ Actor::inserted();
+
+ // Reset the old position, since after insertion it is important that it is
+ // in sync with the zone that we're currently present in.
+ mOld = getPosition();
+}
+
void Being::setTimerSoft(TimerID id, int value)
{
Timers::iterator i = mTimers.find(id);
diff --git a/src/game-server/being.h b/src/game-server/being.h
index 35457bcb..b210688a 100644
--- a/src/game-server/being.h
+++ b/src/game-server/being.h
@@ -286,6 +286,10 @@ class Being : public Actor
void setTarget(Being *target)
{ mTarget = target; }
+ /**
+ * Overridden in order to reset the old position upon insertion.
+ */
+ virtual void inserted();
protected:
static const int TICKS_PER_HP_REGENERATION = 100;