mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09: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 = "";
|
pText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pKey == "worldmap")
|
LOAD_ARRAY_RENAME(worldmap, map.explored)
|
||||||
{
|
|
||||||
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(flags, obj.flags)
|
LOAD_ARRAY_RENAME(flags, obj.flags)
|
||||||
|
|
||||||
|
@ -5542,19 +5530,7 @@ void Game::customloadquick(std::string savfile)
|
||||||
pText = "";
|
pText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pKey == "worldmap")
|
LOAD_ARRAY_RENAME(worldmap, map.explored)
|
||||||
{
|
|
||||||
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(flags, obj.flags)
|
LOAD_ARRAY_RENAME(flags, obj.flags)
|
||||||
|
|
||||||
|
@ -5902,7 +5878,7 @@ void Game::savetele()
|
||||||
//Flags, map and stats
|
//Flags, map and stats
|
||||||
|
|
||||||
std::string mapExplored;
|
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]) + ",";
|
mapExplored += help.String(map.explored[i]) + ",";
|
||||||
}
|
}
|
||||||
|
@ -6098,7 +6074,7 @@ void Game::savequick()
|
||||||
//Flags, map and stats
|
//Flags, map and stats
|
||||||
|
|
||||||
std::string mapExplored;
|
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]) + ",";
|
mapExplored += help.String(map.explored[i]) + ",";
|
||||||
}
|
}
|
||||||
|
@ -6287,7 +6263,7 @@ void Game::customsavequick(std::string savfile)
|
||||||
//Flags, map and stats
|
//Flags, map and stats
|
||||||
|
|
||||||
std::string mapExplored;
|
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]) + ",";
|
mapExplored += help.String(map.explored[i]) + ",";
|
||||||
}
|
}
|
||||||
|
@ -6508,19 +6484,7 @@ void Game::loadtele()
|
||||||
pText = "";
|
pText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pKey == "worldmap")
|
LOAD_ARRAY_RENAME(worldmap, map.explored)
|
||||||
{
|
|
||||||
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(flags, obj.flags)
|
LOAD_ARRAY_RENAME(flags, obj.flags)
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,9 @@ mapclass::mapclass()
|
||||||
//We create a blank map
|
//We create a blank map
|
||||||
contents.resize(40 * 30);
|
contents.resize(40 * 30);
|
||||||
|
|
||||||
roomdeaths.resize(20 * 20);
|
SDL_memset(roomdeaths, 0, sizeof(roomdeaths));
|
||||||
roomdeathsfinal.resize(20 * 20);
|
SDL_memset(roomdeathsfinal, 0, sizeof(roomdeathsfinal));
|
||||||
explored.resize(20 * 20);
|
resetmap();
|
||||||
|
|
||||||
tileset = 0;
|
tileset = 0;
|
||||||
initmapdata();
|
initmapdata();
|
||||||
|
@ -133,8 +133,7 @@ void mapclass::settrinket(int x, int y)
|
||||||
void mapclass::resetmap()
|
void mapclass::resetmap()
|
||||||
{
|
{
|
||||||
//clear the explored area of the map
|
//clear the explored area of the map
|
||||||
explored.clear();
|
SDL_memset(explored, 0, sizeof(explored));
|
||||||
explored.resize(20 * 20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapclass::resetnames()
|
void mapclass::resetnames()
|
||||||
|
@ -1167,7 +1166,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
int t;
|
int t;
|
||||||
if (!finalmode)
|
if (!finalmode)
|
||||||
{
|
{
|
||||||
explored[rx - 100 + ((ry - 100) * 20)] = 1;
|
explored[rx - 100 + ((ry - 100) * 20)] = true;
|
||||||
if (rx == 109 && !custommode)
|
if (rx == 109 && !custommode)
|
||||||
{
|
{
|
||||||
exploretower();
|
exploretower();
|
||||||
|
|
|
@ -79,11 +79,11 @@ public:
|
||||||
void twoframedelayfix();
|
void twoframedelayfix();
|
||||||
|
|
||||||
|
|
||||||
std::vector <int> roomdeaths;
|
int roomdeaths[20 * 20];
|
||||||
std::vector <int> roomdeathsfinal;
|
int roomdeathsfinal[20 * 20];
|
||||||
std::vector <int> areamap;
|
std::vector <int> areamap;
|
||||||
std::vector <int> contents;
|
std::vector <int> contents;
|
||||||
std::vector <int> explored;
|
bool explored[20 * 20];
|
||||||
std::vector <int> vmult;
|
std::vector <int> vmult;
|
||||||
|
|
||||||
int background;
|
int background;
|
||||||
|
|
|
@ -1333,7 +1333,7 @@ void scriptclass::run()
|
||||||
else if (words[0] == "ifexplored")
|
else if (words[0] == "ifexplored")
|
||||||
{
|
{
|
||||||
int room = ss_toi(words[1]) + (20 * ss_toi(words[2]));
|
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]);
|
load(words[3]);
|
||||||
position--;
|
position--;
|
||||||
|
@ -1392,17 +1392,17 @@ void scriptclass::run()
|
||||||
else if (words[0] == "hidecoordinates")
|
else if (words[0] == "hidecoordinates")
|
||||||
{
|
{
|
||||||
int room = ss_toi(words[1]) + (20 * ss_toi(words[2]));
|
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")
|
else if (words[0] == "showcoordinates")
|
||||||
{
|
{
|
||||||
int room = ss_toi(words[1]) + (20 * ss_toi(words[2]));
|
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")
|
else if (words[0] == "hideship")
|
||||||
|
@ -3686,12 +3686,9 @@ void scriptclass::hardreset()
|
||||||
map.scrolldir = 0;
|
map.scrolldir = 0;
|
||||||
map.customshowmm=true;
|
map.customshowmm=true;
|
||||||
|
|
||||||
map.roomdeaths.clear();
|
SDL_memset(map.roomdeaths, 0, sizeof(map.roomdeaths));
|
||||||
map.roomdeaths.resize(20 * 20);
|
SDL_memset(map.roomdeathsfinal, 0, sizeof(map.roomdeathsfinal));
|
||||||
map.roomdeathsfinal.clear();
|
map.resetmap();
|
||||||
map.roomdeathsfinal.resize(20 * 20);
|
|
||||||
map.explored.clear();
|
|
||||||
map.explored.resize(20 * 20);
|
|
||||||
//entityclass
|
//entityclass
|
||||||
obj.nearelephant = false;
|
obj.nearelephant = false;
|
||||||
obj.upsetmode = false;
|
obj.upsetmode = false;
|
||||||
|
|
Loading…
Reference in a new issue