diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-04-12 14:46:06 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-04-12 15:15:37 -0600 |
commit | 612c842f32fec68ece4244ac672a1b889cf2eb18 (patch) | |
tree | 8682f225a4681e281505bd0f4c501be701228a9e /src/game.cpp | |
parent | f30f3e6a51fc20bded8a3a04cd3a0f328a064469 (diff) | |
download | mana-612c842f32fec68ece4244ac672a1b889cf2eb18.tar.gz mana-612c842f32fec68ece4244ac672a1b889cf2eb18.tar.bz2 mana-612c842f32fec68ece4244ac672a1b889cf2eb18.tar.xz mana-612c842f32fec68ece4244ac672a1b889cf2eb18.zip |
Add support for map-server switching under eAthena
Also do some cleanup that's been needed for a while.
Reviewed-by: Bertram
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/game.cpp b/src/game.cpp index e0aa7313..88c74de6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -92,8 +92,6 @@ #include <sstream> #include <string> -std::string map_path; - Joystick *joystick = NULL; OkDialog *weightNotice = NULL; @@ -232,12 +230,7 @@ Game::Game(): initEngines(); - // This part is eAthena specific - // For Manaserv, the map is obtained - // with the GPMSG_PLAYER_MAP_CHANGE flag. - map_path = map_path.substr(0, map_path.rfind(".")); - if (!map_path.empty()) - changeMap(map_path); + Net::getGameHandler()->inGame(); // Initialize beings beingManager->setPlayer(player_node); @@ -269,7 +262,8 @@ Game::~Game() destroyGuiWindows(); del_0(beingManager) - del_0(player_node) + if (Client::getState() != STATE_CHANGE_MAP) + del_0(player_node) del_0(floorItemManager) del_0(channelManager) del_0(commandHandler) @@ -277,7 +271,6 @@ Game::~Game() del_0(particleEngine) del_0(viewport) del_0(mCurrentMap) - map_path = ""; mInstance = 0; } @@ -349,6 +342,9 @@ void Game::logic() // Handle network stuff if (!Net::getGameHandler()->isConnected()) { + if (Client::getState() == STATE_CHANGE_MAP) + return; // Not a problem here + if (Client::getState() != STATE_ERROR) { errorMessage = _("The connection to the server was lost."); @@ -930,20 +926,19 @@ void Game::changeMap(const std::string &mapPath) mMapName = mapPath; - // Store full map path in global var - map_path = "maps/" + mapPath + ".tmx"; + std::string fullMap = "maps/" + mapPath + ".tmx"; ResourceManager *resman = ResourceManager::getInstance(); - if (!resman->exists(map_path)) - map_path += ".gz"; + if (!resman->exists(fullMap)) + fullMap += ".gz"; // Attempt to load the new map - Map *newMap = MapReader::readMap(map_path); + Map *newMap = MapReader::readMap(fullMap); if (!newMap) { - logger->log("Error while loading %s", map_path.c_str()); + logger->log("Error while loading %s", fullMap.c_str()); new OkDialog(_("Could Not Load Map"), - strprintf(_("Error while loading %s"), map_path.c_str())); + strprintf(_("Error while loading %s"), fullMap.c_str())); } // Notify the minimap and beingManager about the map change |