1
0
Fork 0
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:
Marvin Scholz 2020-01-12 12:28:34 +01:00 committed by Ethan Lee
parent 882da7de28
commit 64fd50be6f
3 changed files with 22 additions and 59 deletions

View file

@ -73,28 +73,13 @@ void entityclass::init()
customcrewmoods[i]=1;
}
for (int i = 0; i < 100; i++)
{
int t =0;
flags.push_back(t);
}
flags.resize(100);
blocks.resize(500);
entities.resize(200);
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;
}

View file

@ -207,18 +207,14 @@ Game::Game(void):
}
customcol=0;
for (int i = 0; i < 6; i++)
{
bool cstats;
cstats = false;
crewstats.push_back(cstats);
tele_crewstats.push_back(false);
quick_crewstats.push_back(false);
besttimes.push_back( -1);
besttrinkets.push_back( -1);
bestlives.push_back( -1);
bestrank.push_back( -1);
}
crewstats.resize(6);
tele_crewstats.resize(6);
quick_crewstats.resize(6);
besttimes.resize(6, -1);
besttrinkets.resize(6, -1);
bestlives.resize(6, -1);
bestrank.resize(6, -1);
crewstats[0] = true;
lastsaved = 0;
@ -230,23 +226,10 @@ Game::Game(void):
quick_currentarea = "Error! Error!";
//Menu stuff initiliased here:
for (int mi = 0; mi < 25; mi++)
{
menuoptions.push_back(std::string());
menuoptionsactive.push_back(bool());
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;
}
menuoptions.resize(25);
menuoptionsactive.resize(25);
unlock.resize(25);
unlocknotify.resize(25);
nummenuoptions = 0;
currentmenuoption = 0;

View file

@ -11,15 +11,10 @@ scriptclass::scriptclass()
//Start SDL
//Init
for (int init = 0; init < 500; init++)
{
commands.push_back(std::string());
}
for (int init = 0; init < 40; init++)
{
words.push_back(std::string());
txt.push_back(std::string());
}
commands.resize(500);
words.resize(40);
txt.resize(40);
position = 0;
scriptlength = 0;
scriptdelay = 0;