summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-04-25 17:12:04 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-04-25 17:12:19 +0200
commit73a301648c5a12004fe60c93f32c62c396097062 (patch)
treec114b7798e08b67bec83dc30e0982b1288592219
parent2ce00c5f8ffb341ee65395d9700ca304851097b9 (diff)
downloadmanaserv-73a301648c5a12004fe60c93f32c62c396097062.tar.gz
manaserv-73a301648c5a12004fe60c93f32c62c396097062.tar.xz
manaserv-73a301648c5a12004fe60c93f32c62c396097062.zip
Fixed crash when checking whether a character is already online
Not every connected game client has a character in the world. The code was checking this, but since commit aa04597c5f8bb806996 the pointer was being used before being checked.
-rw-r--r--src/game-server/gamehandler.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 9566316..fa579c3 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -347,14 +347,13 @@ void GameHandler::addPendingCharacter(const std::string &token, Entity *ch)
again, yet the game server has not yet detected the lost connection. */
int id = ch->getComponent<CharacterComponent>()->getDatabaseID();
+
for (NetComputers::const_iterator i = clients.begin(),
i_end = clients.end(); i != i_end; ++i)
{
GameClient *c = static_cast< GameClient * >(*i);
Entity *old_ch = c->character;
- const int oldId = old_ch->getComponent<CharacterComponent>()
- ->getDatabaseID();
- if (old_ch && oldId == id)
+ if (old_ch && id == old_ch->getComponent<CharacterComponent>()->getDatabaseID())
{
if (c->status != CLIENT_CONNECTED)
{