From 486c57304076b7352a588dff08c2b976a76e1608 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Wed, 14 Sep 2005 00:41:04 +0000 Subject: Converted map_path from char array to std::string. --- ChangeLog | 5 +++++ src/game.cpp | 16 +++++----------- src/game.h | 4 ++-- src/gui/char_select.cpp | 7 ++++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 123c62d0..8e7f6752 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-09-14 Björn Steinbrink + + * src/game.cpp, src/game.h, src/gui/char_select.cpp: Converted + map_path from char array to std::string. + 2005-09-13 Eugenio Favalli * The Mana World.dev: Updated to last changes. diff --git a/src/game.cpp b/src/game.cpp index ba860822..b3801bfd 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -71,7 +71,7 @@ extern Graphics *graphics; -char map_path[480]; +std::string map_path; std::string tradePartnerName; bool refresh_beings = false; @@ -272,12 +272,7 @@ void destroyGuiWindows() void do_init() { - std::string path(map_path); - std::string pathDir = path.substr(0, path.rfind(".")); - - // Try .tmx.gz map file - pathDir.insert(pathDir.size(), ".tmx.gz"); - Map *tiledMap = MapReader::readMap(pathDir); + Map *tiledMap = MapReader::readMap(map_path); if (!tiledMap) { @@ -1431,14 +1426,13 @@ void do_parse() case SMSG_PLAYER_WARP: { // Set new map path - strcpy(map_path, - std::string("maps/" + msg.readString(16)).c_str()); - strcpy(strrchr(map_path, '.') + 1, "tmx.gz"); + map_path = "maps/" + msg.readString(16); + map_path= map_path.substr(0, map_path.rfind(".")) + ".tmx.gz"; int x = msg.readShort(); int y = msg.readShort(); - logger->log("Warping to %s (%d, %d)", map_path, x, y); + logger->log("Warping to %s (%d, %d)", map_path.c_str(), x, y); Map *oldMap = tiledMap; tiledMap = MapReader::readMap(map_path); diff --git a/src/game.h b/src/game.h index d819a245..c76e787e 100644 --- a/src/game.h +++ b/src/game.h @@ -24,7 +24,7 @@ #ifndef _TMW_GAME_ #define _TMW_GAME_ -#include +#include #define SPEECH_TIME 80 #define SPEECH_MAX_TIME 100 @@ -32,7 +32,7 @@ #define LOCK 254 #define IDLE 255 -extern char map_path[480]; +extern std::string map_path; extern std::string tradePartnerName; extern int fps, frame, current_npc; extern volatile int tick_time; diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 071708b8..862e659d 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -24,6 +24,7 @@ #include "char_select.h" #include +#include #include #include @@ -230,14 +231,14 @@ void CharSelectDialog::serverCharSelect() if (msg.getId() == 0x0071) { char_ID = msg.readLong(); - std::string mapPath = "maps/" + msg.readString(16); - strcpy(map_path, mapPath.c_str()); + map_path = "maps/" + msg.readString(16); + map_path= map_path.substr(0, map_path.rfind(".")) + ".tmx.gz"; map_address = msg.readLong(); map_port = msg.readShort(); player_info = char_info[0]; state = GAME; - logger->log("CharSelect: Map: %s", map_path); + logger->log("CharSelect: Map: %s", map_path.c_str()); logger->log("CharSelect: Server: %s:%d", iptostring(map_address), map_port); close_session(); -- cgit v1.2.3-70-g09d2