Turn ed.contents/vmult into arrays

They're always the same size, so there's no need for them to be vectors.

Also made the number of elements in ed.level/kludgewarpdir controllable
by maxwidth/maxheight.

I removed editorclass::saveconvertor() because I didn't want to convert
it to treat ed.contents like an array, because it's unused so I'd have
no way of testing it, plus it's also unused so it doesn't matter. Might
as well get rid of it.
This commit is contained in:
Misa
2020-07-03 02:54:31 -07:00
committed by Ethan Lee
parent 067fbc75f0
commit a80502bdc9
2 changed files with 10 additions and 74 deletions

View File

@@ -50,21 +50,12 @@ edlevelclass::edlevelclass()
editorclass::editorclass()
{
maxwidth=20;
maxheight=20;
//We create a blank map
for (int j = 0; j < 30 * maxwidth; j++)
{
for (int i = 0; i < 40 * maxheight; i++)
{
contents.push_back(0);
}
}
SDL_memset(contents, 0, sizeof(contents));
for (int i = 0; i < 30 * maxheight; i++)
for (size_t i = 0; i < SDL_arraysize(vmult); i++)
{
vmult.push_back(int(i * 40 * maxwidth));
vmult[i] = i * 40 * maxwidth;
}
reset();
@@ -1544,57 +1535,6 @@ void editorclass::findstartpoint()
}
}
void editorclass::saveconvertor()
{
//In the case of resizing breaking a level, this function can fix it
maxwidth=20;
maxheight=20;
int oldwidth=10, oldheight=10;
std::vector <int> tempcontents;
for (int j = 0; j < 30 * oldwidth; j++)
{
for (int i = 0; i < 40 * oldheight; i++)
{
tempcontents.push_back(contents[i+(j*40*oldwidth)]);
}
}
contents.clear();
for (int j = 0; j < 30 * maxheight; j++)
{
for (int i = 0; i < 40 * maxwidth; i++)
{
contents.push_back(0);
}
}
for (int j = 0; j < 30 * oldheight; j++)
{
for (int i = 0; i < 40 * oldwidth; i++)
{
contents[i+(j*40*oldwidth)]=tempcontents[i+(j*40*oldwidth)];
}
}
tempcontents.clear();
for (int i = 0; i < 30 * maxheight; i++)
{
vmult.push_back(int(i * 40 * maxwidth));
}
for (int j = 0; j < maxheight; j++)
{
for (int i = 0; i < maxwidth; i++)
{
level[i+(j*maxwidth)].tilecol=(i+j)%6;
}
}
contents.clear();
}
int editorclass::findtrinket(int t)
{
int ttrinket=0;
@@ -1884,11 +1824,7 @@ bool editorclass::load(std::string& _path)
if(TextString.length())
{
std::vector<std::string> values = split(TextString,',');
//contents.clear();
for(size_t i = 0; i < contents.size(); i++)
{
contents[i] =0;
}
SDL_memset(contents, 0, sizeof(contents));
int x =0;
int y =0;
for(size_t i = 0; i < values.size(); i++)