mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 02:19:45 +01:00
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:
parent
067fbc75f0
commit
a80502bdc9
2 changed files with 10 additions and 74 deletions
|
@ -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++)
|
||||
|
|
|
@ -128,7 +128,6 @@ class editorclass{
|
|||
void getDirectoryData();
|
||||
bool getLevelMetaData(std::string& filename, LevelMetaData& _data );
|
||||
|
||||
void saveconvertor();
|
||||
void reset();
|
||||
void getlin(const enum textmode mode, const std::string& prompt, std::string* ptr);
|
||||
const int* loadlevel(int rxi, int ryi);
|
||||
|
@ -189,12 +188,14 @@ class editorclass{
|
|||
int getwarpbackground(int rx, int ry);
|
||||
|
||||
std::vector<std::string> getLevelDirFileNames( );
|
||||
std::vector <int> contents;
|
||||
std::vector <int> vmult;
|
||||
static const int maxwidth = 20, maxheight = 20; //Special; the physical max the engine allows
|
||||
static const int numrooms = maxwidth * maxheight;
|
||||
int contents[40 * 30 * numrooms];
|
||||
int vmult[30 * maxheight];
|
||||
int numtrinkets();
|
||||
int numcrewmates();
|
||||
edlevelclass level[400]; //Maxwidth*maxheight
|
||||
int kludgewarpdir[400]; //Also maxwidth*maxheight
|
||||
edlevelclass level[numrooms]; //Maxwidth*maxheight
|
||||
int kludgewarpdir[numrooms]; //Also maxwidth*maxheight
|
||||
|
||||
int notedelay;
|
||||
int oldnotedelay;
|
||||
|
@ -236,7 +237,6 @@ class editorclass{
|
|||
|
||||
int levmusic;
|
||||
int mapwidth, mapheight; //Actual width and height of stage
|
||||
int maxwidth, maxheight; //Special; the physical max the engine allows
|
||||
|
||||
int version;
|
||||
|
||||
|
|
Loading…
Reference in a new issue