From d5b86aa54dfa4ddf5b5f2361918c719ba8d0dd18 Mon Sep 17 00:00:00 2001 From: Lloyd Bryant Date: Sun, 17 Aug 2008 06:28:13 +0000 Subject: Fixed crash resulting from having a player targeted when hitting a warp point --- src/net/beinghandler.cpp | 5 ++--- src/net/playerhandler.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/net') diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index affdcd56..5b2ac5f4 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -201,10 +201,9 @@ void BeingHandler::handleMessage(MessageIn *msg) if (!dstBeing) break; - if (dstBeing == player_node->getTarget()) - { + // If this is player's current target, clear it. + if (player_node->getTarget() == dstBeing) player_node->stopAttack(); - } if (msg->readInt8() == 1) { diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp index 7f9e455a..e871b670 100644 --- a/src/net/playerhandler.cpp +++ b/src/net/playerhandler.cpp @@ -129,6 +129,12 @@ void PlayerHandler::handleMessage(MessageIn *msg) logger->log("Warping to %s (%d, %d)", mapPath.c_str(), x, y); + /* + * We must clear the local player's target *before* the call + * to changeMap, as it deletes all beings. + */ + player_node->stopAttack(); + // Switch the actual map, deleting the previous one engine->changeMap(mapPath); @@ -138,7 +144,6 @@ void PlayerHandler::handleMessage(MessageIn *msg) float scrollOffsetY = (y - player_node->mY) * 32; player_node->setAction(Being::STAND); - player_node->stopAttack(); player_node->mFrame = 0; player_node->mX = x; player_node->mY = y; -- cgit v1.2.3-70-g09d2