diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2013-04-25 17:12:04 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2013-04-25 17:12:19 +0200 |
commit | 73a301648c5a12004fe60c93f32c62c396097062 (patch) | |
tree | c114b7798e08b67bec83dc30e0982b1288592219 /src | |
parent | 2ce00c5f8ffb341ee65395d9700ca304851097b9 (diff) | |
download | manaserv-73a301648c5a12004fe60c93f32c62c396097062.tar.gz manaserv-73a301648c5a12004fe60c93f32c62c396097062.tar.bz2 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.
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/gamehandler.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp index 95663168..fa579c30 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) { |