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

@@ -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;