summaryrefslogtreecommitdiffstats
path: root/src/game-server/state.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-01-10 01:43:59 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-01-10 20:42:24 +0100
commit8172b66469a257b61769e0ce69baa1a0f75eb785 (patch)
treee19beffb3d3b92703d347f7fd70137a0a2b44e2f /src/game-server/state.cpp
parentd4ee26fb6b05c07c84f61799bcb2cba81873b873 (diff)
downloadmanaserv-8172b66469a257b61769e0ce69baa1a0f75eb785.tar.gz
manaserv-8172b66469a257b61769e0ce69baa1a0f75eb785.tar.xz
manaserv-8172b66469a257b61769e0ce69baa1a0f75eb785.zip
Made the game server execute the chr_respawn_accept script even
in case of disconnection. I made the Character::disconnected() function handle that case, permitting also to centralize GameState::remove() calls there. I also made the GameState::enqueueWarp() function test whether the Character pointer is about to be deleted, so that the warp can be handled directly to avoid a crash. Last but not least, I also made the Character::update() function not update the Character specials and hp to avoid discrepancies seen in the client. Resolves: Mana-Mantis #309. Reviewed-by: Ablu.
Diffstat (limited to 'src/game-server/state.cpp')
-rw-r--r--src/game-server/state.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index 6713007..1d72e20 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -720,6 +720,11 @@ void GameState::warp(Character *ptr, MapComposite *map, int x, int y)
a disconnection. */
accountHandler->sendCharacterData(ptr);
+ // If the player has just left, The character pointer is also about
+ // to be deleted. So we don't have to do anything else.
+ if (!ptr->isConnected())
+ return;
+
if (map->isActive())
{
if (!insert(ptr))
@@ -766,6 +771,14 @@ void GameState::enqueueRemove(Actor *ptr)
void GameState::enqueueWarp(Character *ptr, MapComposite *m, int x, int y)
{
+ // When the player has just disconnected, better not wait for the pointer
+ // to become invalid.
+ if (!ptr->isConnected())
+ {
+ warp(ptr, m, x, y);
+ return;
+ }
+
DelayedEvent e = { EVENT_WARP, x, y, m };
enqueueEvent(ptr, e);
}