diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/game-server/player.cpp | 11 | ||||
-rw-r--r-- | src/game-server/state.cpp | 15 |
3 files changed, 15 insertions, 17 deletions
@@ -1,4 +1,4 @@ -2006-01-05 Bjørn Lindeijer <bjorn@lindeijer.nl> +2007-01-05 Bjørn Lindeijer <bjorn@lindeijer.nl> * AUTHORS: Updated to include all current authors. * src/account-server/main-account.cpp, @@ -10,7 +10,9 @@ 2007-01-05 Guillaume Melquiond <guillaume.melquiond@gmail.com> - * src/game-server/player.cpp: Delayed update of persistent position. + * src/game-server/player.cpp, src/game-server/state.cpp: Delayed update + of persistent position and put it into state handling, so that the + update happens before map change. * src/game-server/item.hpp: Added an amount property to items lying on the ground. * src/game-server/testing.cpp: Added a piece of equipment. diff --git a/src/game-server/player.cpp b/src/game-server/player.cpp index 8d5cbae..2160cbb 100644 --- a/src/game-server/player.cpp +++ b/src/game-server/player.cpp @@ -38,17 +38,6 @@ void Player::update() setStat(STAT_ACCURACY, 50 + getRawStat(STAT_DEXTERITY)); setStat(STAT_SPEED, getRawStat(STAT_DEXTERITY)); - // Update persistent data. - int mapId = getMapId(); - if (getMap() != mapId) - { - /* Only update on map change. This is on purpose. It prevents players - from respawning/reconnecting at the location they died. They will - reappear where they entered the map. */ - setMap(mapId); - setPos(getPosition()); - } - // attacking if (mIsAttacking) { diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp index 62e867a..58949ce 100644 --- a/src/game-server/state.cpp +++ b/src/game-server/state.cpp @@ -286,18 +286,25 @@ void State::update() case EVENT_WARP: { remove(o); - o->setMapId(e.map); Point pos = { e.x, e.y }; + o->setMapId(e.map); o->setPosition(pos); + + assert(o->getType() == OBJECT_PLAYER); + Player *p = static_cast< Player * >(o); + /* Force update of persistent data on map change, so that + players can respawn at the start of the map after a death or + a disconnection. */ + p->setMap(e.map); + p->setPos(pos); + accountHandler->sendPlayerData(p); + if (mapManager->isActive(e.map)) { insert(o); } else { - assert(o->getType() == OBJECT_PLAYER); - Player *p = static_cast< Player * >(o); - accountHandler->sendPlayerData(p); MessageOut msg(GAMSG_REDIRECT); msg.writeLong(p->getDatabaseID()); accountHandler->send(msg); |