summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-15 12:09:45 +0200
committerDennis Friis <peavey@inspircd.org>2009-05-17 04:32:24 +0200
commitc7e57369f066ee9b7f9f62eacb19e2d10f8e13c5 (patch)
tree56337ed5e26b4345367bc1a6d8e3a1873ed7f2f1 /src
parent98eadea1f98f76237701d2ac44868847a18d13c2 (diff)
downloadmana-c7e57369f066ee9b7f9f62eacb19e2d10f8e13c5.tar.gz
mana-c7e57369f066ee9b7f9f62eacb19e2d10f8e13c5.tar.bz2
mana-c7e57369f066ee9b7f9f62eacb19e2d10f8e13c5.tar.xz
mana-c7e57369f066ee9b7f9f62eacb19e2d10f8e13c5.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp5
-rw-r--r--src/net/ea/maphandler.cpp3
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: