mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Simplify std::vector initializations
Resizing the vector does the same thing that the loops did, it changes the size for the vector and initializes it with default-constructed elements (or 0 or its equivalent for POD types). Where a specific value is needed, it is set with the second parameter of resize().
This commit is contained in:
parent
882da7de28
commit
64fd50be6f
3 changed files with 22 additions and 59 deletions
|
@ -73,28 +73,13 @@ void entityclass::init()
|
||||||
customcrewmoods[i]=1;
|
customcrewmoods[i]=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++)
|
flags.resize(100);
|
||||||
{
|
blocks.resize(500);
|
||||||
int t =0;
|
entities.resize(200);
|
||||||
flags.push_back(t);
|
linecrosskludge.resize(100);
|
||||||
}
|
collect.resize(100);
|
||||||
|
customcollect.resize(100);
|
||||||
|
|
||||||
for (int i = 0; i < 500; i++)
|
|
||||||
{
|
|
||||||
blocks.push_back(blockclass());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int z = 0; z < 200; z++)
|
|
||||||
{
|
|
||||||
entities.push_back(entclass());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++)
|
|
||||||
{
|
|
||||||
linecrosskludge.push_back(entclass());
|
|
||||||
collect.push_back(0);
|
|
||||||
customcollect.push_back(0);
|
|
||||||
}
|
|
||||||
nlinecrosskludge = 0;
|
nlinecrosskludge = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,18 +207,14 @@ Game::Game(void):
|
||||||
}
|
}
|
||||||
customcol=0;
|
customcol=0;
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
crewstats.resize(6);
|
||||||
{
|
tele_crewstats.resize(6);
|
||||||
bool cstats;
|
quick_crewstats.resize(6);
|
||||||
cstats = false;
|
besttimes.resize(6, -1);
|
||||||
crewstats.push_back(cstats);
|
besttrinkets.resize(6, -1);
|
||||||
tele_crewstats.push_back(false);
|
bestlives.resize(6, -1);
|
||||||
quick_crewstats.push_back(false);
|
bestrank.resize(6, -1);
|
||||||
besttimes.push_back( -1);
|
|
||||||
besttrinkets.push_back( -1);
|
|
||||||
bestlives.push_back( -1);
|
|
||||||
bestrank.push_back( -1);
|
|
||||||
}
|
|
||||||
crewstats[0] = true;
|
crewstats[0] = true;
|
||||||
lastsaved = 0;
|
lastsaved = 0;
|
||||||
|
|
||||||
|
@ -230,23 +226,10 @@ Game::Game(void):
|
||||||
quick_currentarea = "Error! Error!";
|
quick_currentarea = "Error! Error!";
|
||||||
|
|
||||||
//Menu stuff initiliased here:
|
//Menu stuff initiliased here:
|
||||||
for (int mi = 0; mi < 25; mi++)
|
menuoptions.resize(25);
|
||||||
{
|
menuoptionsactive.resize(25);
|
||||||
menuoptions.push_back(std::string());
|
unlock.resize(25);
|
||||||
menuoptionsactive.push_back(bool());
|
unlocknotify.resize(25);
|
||||||
|
|
||||||
bool nb1, nb2;
|
|
||||||
nb1 = false;
|
|
||||||
nb2 = false;
|
|
||||||
unlock.push_back(nb1);
|
|
||||||
unlocknotify.push_back(nb2);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int ui = 0; ui < 25; ui++)
|
|
||||||
{
|
|
||||||
unlock[ui] = false;
|
|
||||||
unlocknotify[ui] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
nummenuoptions = 0;
|
nummenuoptions = 0;
|
||||||
currentmenuoption = 0;
|
currentmenuoption = 0;
|
||||||
|
|
|
@ -11,15 +11,10 @@ scriptclass::scriptclass()
|
||||||
//Start SDL
|
//Start SDL
|
||||||
|
|
||||||
//Init
|
//Init
|
||||||
for (int init = 0; init < 500; init++)
|
commands.resize(500);
|
||||||
{
|
words.resize(40);
|
||||||
commands.push_back(std::string());
|
txt.resize(40);
|
||||||
}
|
|
||||||
for (int init = 0; init < 40; init++)
|
|
||||||
{
|
|
||||||
words.push_back(std::string());
|
|
||||||
txt.push_back(std::string());
|
|
||||||
}
|
|
||||||
position = 0;
|
position = 0;
|
||||||
scriptlength = 0;
|
scriptlength = 0;
|
||||||
scriptdelay = 0;
|
scriptdelay = 0;
|
||||||
|
|
Loading…
Reference in a new issue