1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-10 13:09:43 +01:00

Remove unnecessary middleman ed.swapmap

When the game loads a room in a custom level, previously it would load
the tilemap of that room into ed.swapmap, and then mapclass::loadlevel()
would manually go through each element in ed.swapmap to set each tile in
`contents`. Why do that, when you can just return the vector from
editorclass::loadlevel() and set it directly? ed.swapmap is really
unnecessary.
This commit is contained in:
Misa 2020-05-21 19:23:21 -07:00 committed by Ethan Lee
parent 6913abb171
commit 4301a70f2d
3 changed files with 8 additions and 19 deletions

View file

@ -1568,18 +1568,12 @@ void mapclass::loadlevel(int rx, int ry)
roomname=ed.level[curlevel].roomname;
}
extrarow = 1;
ed.loadlevel(rx, ry);
contents = ed.loadlevel(rx, ry);
roomtexton = false;
roomtext.clear();
for (int edj = 0; edj < 30; edj++){
for(int edi = 0; edi < 40; edi++){
contents[edi + vmult[edj]] = ed.swapmap[edi + vmult[edj]];
}
}
//Entities have to be created HERE, akwardly
int tempcheckpoints=0;
int tempscriptbox=0;

View file

@ -52,14 +52,6 @@ editorclass::editorclass()
}
}
for (int j = 0; j < 30; j++)
{
for (int i = 0; i < 40; i++)
{
swapmap.push_back(0);
}
}
for (int i = 0; i < 30 * maxheight; i++)
{
vmult.push_back(int(i * 40 * maxwidth));
@ -532,7 +524,7 @@ void editorclass::insertline(int t)
sb.insert(sb.begin() + t, "");
}
void editorclass::loadlevel( int rxi, int ryi )
std::vector<int> editorclass::loadlevel( int rxi, int ryi )
{
//Set up our buffer array to be picked up by mapclass
rxi -= 100;
@ -542,13 +534,17 @@ void editorclass::loadlevel( int rxi, int ryi )
if(rxi>=mapwidth)rxi-=mapwidth;
if(ryi>=mapheight)ryi-=mapheight;
std::vector<int> result;
for (int j = 0; j < 30; j++)
{
for (int i = 0; i < 40; i++)
{
swapmap[i+(j*40)]=contents[i+(rxi*40)+vmult[j+(ryi*30)]];
result.push_back(contents[i+(rxi*40)+vmult[j+(ryi*30)]]);
}
}
return result;
}
int editorclass::getlevelcol(int t)

View file

@ -95,7 +95,7 @@ class editorclass{
void saveconvertor();
void reset();
void loadlevel(int rxi, int ryi);
std::vector<int> loadlevel(int rxi, int ryi);
void placetile(int x, int y, int t);
@ -147,7 +147,6 @@ class editorclass{
int getwarpbackground(int rx, int ry);
std::vector<std::string> getLevelDirFileNames( );
std::vector <int> swapmap;
std::vector <int> contents;
std::vector <int> vmult;
int numtrinkets();