mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Turn map.explored, map.roomdeaths(final) into plain arrays
They're always fixed-size anyways, there's no need for them to be vectors. Also used the new INBOUNDS_ARR() macro for the map.explored bounds checks in Script.cpp, and made map.explored a proper bool array instead of an int array.
This commit is contained in:
parent
118008d824
commit
cb3afa295a
4 changed files with 22 additions and 62 deletions
|
@ -5351,19 +5351,7 @@ void Game::loadquick()
|
|||
pText = "";
|
||||
}
|
||||
|
||||
if (pKey == "worldmap")
|
||||
{
|
||||
std::string TextString = (pText);
|
||||
if(TextString.length()>1)
|
||||
{
|
||||
std::vector<std::string> 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<std::string> 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<std::string> 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)
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -79,11 +79,11 @@ public:
|
|||
void twoframedelayfix();
|
||||
|
||||
|
||||
std::vector <int> roomdeaths;
|
||||
std::vector <int> roomdeathsfinal;
|
||||
int roomdeaths[20 * 20];
|
||||
int roomdeathsfinal[20 * 20];
|
||||
std::vector <int> areamap;
|
||||
std::vector <int> contents;
|
||||
std::vector <int> explored;
|
||||
bool explored[20 * 20];
|
||||
std::vector <int> vmult;
|
||||
|
||||
int background;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue