mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 18:39:45 +01:00
Turn unlock/unlocknotify into plain arrays
They're always fixed-size, so there's no need to them to be a dynamic vector. I changed their type to `bool` too because they don't need to be `int`s. Also, I replaced the hardcoded 25 constant with at least a name, in case people want to change it in the future.
This commit is contained in:
parent
c3e7ddca9c
commit
3f448ce439
2 changed files with 13 additions and 14 deletions
|
@ -229,8 +229,8 @@ void Game::init(void)
|
||||||
quick_currentarea = "Error! Error!";
|
quick_currentarea = "Error! Error!";
|
||||||
|
|
||||||
//Menu stuff initiliased here:
|
//Menu stuff initiliased here:
|
||||||
unlock.resize(25);
|
SDL_memset(unlock, false, sizeof(unlock));
|
||||||
unlocknotify.resize(25);
|
SDL_memset(unlocknotify, false, sizeof(unlock));
|
||||||
|
|
||||||
currentmenuoption = 0;
|
currentmenuoption = 0;
|
||||||
current_credits_list_index = 0;
|
current_credits_list_index = 0;
|
||||||
|
@ -4559,7 +4559,7 @@ void Game::deletestats()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 25; i++)
|
for (int i = 0; i < numunlock; i++)
|
||||||
{
|
{
|
||||||
unlock[i] = false;
|
unlock[i] = false;
|
||||||
unlocknotify[i] = false;
|
unlocknotify[i] = false;
|
||||||
|
@ -4631,10 +4631,9 @@ void Game::loadstats()
|
||||||
if(TextString.length())
|
if(TextString.length())
|
||||||
{
|
{
|
||||||
std::vector<std::string> values = split(TextString,',');
|
std::vector<std::string> values = split(TextString,',');
|
||||||
unlock.clear();
|
for(size_t i = 0; i < SDL_min(SDL_arraysize(unlock), values.size()); i++)
|
||||||
for(size_t i = 0; i < values.size(); i++)
|
|
||||||
{
|
{
|
||||||
unlock.push_back(atoi(values[i].c_str()));
|
unlock[i] = atoi(values[i].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4645,10 +4644,9 @@ void Game::loadstats()
|
||||||
if(TextString.length())
|
if(TextString.length())
|
||||||
{
|
{
|
||||||
std::vector<std::string> values = split(TextString,',');
|
std::vector<std::string> values = split(TextString,',');
|
||||||
unlocknotify.clear();
|
for(size_t i = 0; i < SDL_min(SDL_arraysize(unlocknotify), values.size()); i++)
|
||||||
for(size_t i = 0; i < values.size(); i++)
|
|
||||||
{
|
{
|
||||||
unlocknotify.push_back(atoi(values[i].c_str()));
|
unlocknotify[i] = atoi(values[i].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4967,7 +4965,7 @@ void Game::savestats()
|
||||||
root->LinkEndChild( dataNode );
|
root->LinkEndChild( dataNode );
|
||||||
|
|
||||||
std::string s_unlock;
|
std::string s_unlock;
|
||||||
for(size_t i = 0; i < unlock.size(); i++ )
|
for(size_t i = 0; i < SDL_arraysize(unlock); i++ )
|
||||||
{
|
{
|
||||||
s_unlock += help.String(unlock[i]) + ",";
|
s_unlock += help.String(unlock[i]) + ",";
|
||||||
}
|
}
|
||||||
|
@ -4976,7 +4974,7 @@ void Game::savestats()
|
||||||
dataNode->LinkEndChild( msg );
|
dataNode->LinkEndChild( msg );
|
||||||
|
|
||||||
std::string s_unlocknotify;
|
std::string s_unlocknotify;
|
||||||
for(size_t i = 0; i < unlocknotify.size(); i++ )
|
for(size_t i = 0; i < SDL_arraysize(unlocknotify); i++ )
|
||||||
{
|
{
|
||||||
s_unlocknotify += help.String(unlocknotify[i]) + ",";
|
s_unlocknotify += help.String(unlocknotify[i]) + ",";
|
||||||
}
|
}
|
||||||
|
@ -7761,7 +7759,7 @@ int Game::crewmates()
|
||||||
|
|
||||||
bool Game::anything_unlocked()
|
bool Game::anything_unlocked()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < unlock.size(); i++)
|
for (size_t i = 0; i < SDL_arraysize(unlock); i++)
|
||||||
{
|
{
|
||||||
if (unlock[i] &&
|
if (unlock[i] &&
|
||||||
(i == 8 // Secret Lab
|
(i == 8 // Secret Lab
|
||||||
|
|
|
@ -288,8 +288,9 @@ public:
|
||||||
|
|
||||||
std::vector<bool> quick_crewstats;
|
std::vector<bool> quick_crewstats;
|
||||||
|
|
||||||
std::vector<int> unlock;
|
static const int numunlock = 25;
|
||||||
std::vector<int> unlocknotify;
|
bool unlock[numunlock];
|
||||||
|
bool unlocknotify[numunlock];
|
||||||
bool anything_unlocked();
|
bool anything_unlocked();
|
||||||
int stat_trinkets;
|
int stat_trinkets;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
|
|
Loading…
Reference in a new issue