From 73a301648c5a12004fe60c93f32c62c396097062 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 25 Apr 2013 17:12:04 +0200 Subject: 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. --- src/game-server/gamehandler.cpp | 5 ++--- 1 file 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()->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() - ->getDatabaseID(); - if (old_ch && oldId == id) + if (old_ch && id == old_ch->getComponent()->getDatabaseID()) { if (c->status != CLIENT_CONNECTED) { -- cgit