diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index b5bf6340..1793ef54 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -5351,19 +5351,7 @@ void Game::loadquick() pText = ""; } - if (pKey == "worldmap") - { - std::string TextString = (pText); - if(TextString.length()>1) - { - std::vector values = split(TextString,','); - map.explored.clear(); - for(size_t i = 0; i < values.size(); i++) - { - map.explored.push_back(atoi(values[i].c_str())); - } - } - } + LOAD_ARRAY_RENAME(worldmap, map.explored) LOAD_ARRAY_RENAME(flags, obj.flags) @@ -5542,19 +5530,7 @@ void Game::customloadquick(std::string savfile) pText = ""; } - if (pKey == "worldmap") - { - std::string TextString = (pText); - if(TextString.length()>1) - { - std::vector values = split(TextString,','); - map.explored.clear(); - for(size_t i = 0; i < values.size(); i++) - { - map.explored.push_back(atoi(values[i].c_str())); - } - } - } + LOAD_ARRAY_RENAME(worldmap, map.explored) LOAD_ARRAY_RENAME(flags, obj.flags) @@ -5902,7 +5878,7 @@ void Game::savetele() //Flags, map and stats std::string mapExplored; - for(size_t i = 0; i < map.explored.size(); i++ ) + for(size_t i = 0; i < SDL_arraysize(map.explored); i++ ) { mapExplored += help.String(map.explored[i]) + ","; } @@ -6098,7 +6074,7 @@ void Game::savequick() //Flags, map and stats std::string mapExplored; - for(size_t i = 0; i < map.explored.size(); i++ ) + for(size_t i = 0; i < SDL_arraysize(map.explored); i++ ) { mapExplored += help.String(map.explored[i]) + ","; } @@ -6287,7 +6263,7 @@ void Game::customsavequick(std::string savfile) //Flags, map and stats std::string mapExplored; - for(size_t i = 0; i < map.explored.size(); i++ ) + for(size_t i = 0; i < SDL_arraysize(map.explored); i++ ) { mapExplored += help.String(map.explored[i]) + ","; } @@ -6508,19 +6484,7 @@ void Game::loadtele() pText = ""; } - if (pKey == "worldmap") - { - std::string TextString = (pText); - if(TextString.length()) - { - std::vector values = split(TextString,','); - map.explored.clear(); - for(size_t i = 0; i < values.size(); i++) - { - map.explored.push_back(atoi(values[i].c_str())); - } - } - } + LOAD_ARRAY_RENAME(worldmap, map.explored) LOAD_ARRAY_RENAME(flags, obj.flags) diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 7d6644e3..3950ed8a 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -64,9 +64,9 @@ mapclass::mapclass() //We create a blank map contents.resize(40 * 30); - roomdeaths.resize(20 * 20); - roomdeathsfinal.resize(20 * 20); - explored.resize(20 * 20); + SDL_memset(roomdeaths, 0, sizeof(roomdeaths)); + SDL_memset(roomdeathsfinal, 0, sizeof(roomdeathsfinal)); + resetmap(); tileset = 0; initmapdata(); @@ -133,8 +133,7 @@ void mapclass::settrinket(int x, int y) void mapclass::resetmap() { //clear the explored area of the map - explored.clear(); - explored.resize(20 * 20); + SDL_memset(explored, 0, sizeof(explored)); } void mapclass::resetnames() @@ -1167,7 +1166,7 @@ void mapclass::loadlevel(int rx, int ry) int t; if (!finalmode) { - explored[rx - 100 + ((ry - 100) * 20)] = 1; + explored[rx - 100 + ((ry - 100) * 20)] = true; if (rx == 109 && !custommode) { exploretower(); diff --git a/desktop_version/src/Map.h b/desktop_version/src/Map.h index 8d517801..26c9ac8d 100644 --- a/desktop_version/src/Map.h +++ b/desktop_version/src/Map.h @@ -79,11 +79,11 @@ public: void twoframedelayfix(); - std::vector roomdeaths; - std::vector roomdeathsfinal; + int roomdeaths[20 * 20]; + int roomdeathsfinal[20 * 20]; std::vector areamap; std::vector contents; - std::vector explored; + bool explored[20 * 20]; std::vector vmult; int background; diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index ddae3254..82522d6d 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1333,7 +1333,7 @@ void scriptclass::run() else if (words[0] == "ifexplored") { int room = ss_toi(words[1]) + (20 * ss_toi(words[2])); - if (room >= 0 && room < (int) map.explored.size() && map.explored[room] == 1) + if (INBOUNDS_ARR(room, map.explored) && map.explored[room] == 1) { load(words[3]); position--; @@ -1392,17 +1392,17 @@ void scriptclass::run() else if (words[0] == "hidecoordinates") { int room = ss_toi(words[1]) + (20 * ss_toi(words[2])); - if (room >= 0 && room < (int) map.explored.size()) + if (INBOUNDS_ARR(room, map.explored)) { - map.explored[room] = 0; + map.explored[room] = false; } } else if (words[0] == "showcoordinates") { int room = ss_toi(words[1]) + (20 * ss_toi(words[2])); - if (room >= 0 && room < (int) map.explored.size()) + if (INBOUNDS_ARR(room, map.explored)) { - map.explored[room] = 1; + map.explored[room] = true; } } else if (words[0] == "hideship") @@ -3686,12 +3686,9 @@ void scriptclass::hardreset() map.scrolldir = 0; map.customshowmm=true; - map.roomdeaths.clear(); - map.roomdeaths.resize(20 * 20); - map.roomdeathsfinal.clear(); - map.roomdeathsfinal.resize(20 * 20); - map.explored.clear(); - map.explored.resize(20 * 20); + SDL_memset(map.roomdeaths, 0, sizeof(map.roomdeaths)); + SDL_memset(map.roomdeathsfinal, 0, sizeof(map.roomdeathsfinal)); + map.resetmap(); //entityclass obj.nearelephant = false; obj.upsetmode = false;