From da03d6fcdd76774fd97e94227f32b9574f52bc18 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 15 May 2009 12:09:45 +0200 Subject: Fixed a possible crash on logging in to the map server The Game instance was created too late, in some cases after messages were received by the BeingHandler. This caused crashes since the BeingHandler tried to use the BeingManager, which hadn't been created yet. (cherry picked from commit c7e57369f066ee9b7f9f62eacb19e2d10f8e13c5) --- src/main.cpp | 5 +++-- src/net/ea/maphandler.cpp | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 40b30899..07bcd3f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,6 +159,7 @@ extern Net::Connection *accountServerConnection; #endif Graphics *graphics; +Game *game = 0; unsigned char state; std::string errorMessage; @@ -910,7 +911,6 @@ int main(int argc, char *argv[]) // Needs to be created in main, as the updater uses it guiPalette = new Palette; - Game *game = NULL; Window *currentDialog = NULL; #ifdef TMWSERV_SUPPORT QuitDialog* quitDialog = NULL; @@ -1290,6 +1290,7 @@ int main(int argc, char *argv[]) game = new Game; game->logic(); delete game; + game = 0; state = STATE_EXIT; @@ -1467,9 +1468,9 @@ int main(int argc, char *argv[]) desktop = NULL; logger->log("State: GAME"); - game = new Game; game->logic(); delete game; + game = 0; state = STATE_EXIT; break; diff --git a/src/net/ea/maphandler.cpp b/src/net/ea/maphandler.cpp index 76b3c480..c7ff0ec7 100644 --- a/src/net/ea/maphandler.cpp +++ b/src/net/ea/maphandler.cpp @@ -27,6 +27,7 @@ #include "net/messagein.h" #include "net/messageout.h" +#include "game.h" #include "localplayer.h" #include "log.h" #include "main.h" @@ -37,6 +38,7 @@ #include "utils/stringutils.h" Net::MapHandler *mapHandler; +extern Game *game; namespace EAthena { @@ -65,6 +67,7 @@ void MapHandler::handleMessage(MessageIn &msg) logger->log("Protocol: Player start position: (%d, %d), Direction: %d", player_node->mX, player_node->mY, direction); state = STATE_GAME; + game = new Game; break; case SMSG_SERVER_PING: -- cgit v1.2.3-70-g09d2