1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-01 10:33:32 +02: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:
Misa 2020-07-02 16:45:22 -07:00 committed by Ethan Lee
parent c3e7ddca9c
commit 3f448ce439
2 changed files with 13 additions and 14 deletions

View File

@ -229,8 +229,8 @@ void Game::init(void)
quick_currentarea = "Error! Error!";
//Menu stuff initiliased here:
unlock.resize(25);
unlocknotify.resize(25);
SDL_memset(unlock, false, sizeof(unlock));
SDL_memset(unlocknotify, false, sizeof(unlock));
currentmenuoption = 0;
current_credits_list_index = 0;
@ -4559,7 +4559,7 @@ void Game::deletestats()
}
else
{
for (int i = 0; i < 25; i++)
for (int i = 0; i < numunlock; i++)
{
unlock[i] = false;
unlocknotify[i] = false;
@ -4631,10 +4631,9 @@ void Game::loadstats()
if(TextString.length())
{
std::vector<std::string> values = split(TextString,',');
unlock.clear();
for(size_t i = 0; i < values.size(); i++)
for(size_t i = 0; i < SDL_min(SDL_arraysize(unlock), 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())
{
std::vector<std::string> values = split(TextString,',');
unlocknotify.clear();
for(size_t i = 0; i < values.size(); i++)
for(size_t i = 0; i < SDL_min(SDL_arraysize(unlocknotify), 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 );
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]) + ",";
}
@ -4976,7 +4974,7 @@ void Game::savestats()
dataNode->LinkEndChild( msg );
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]) + ",";
}
@ -7761,7 +7759,7 @@ int Game::crewmates()
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] &&
(i == 8 // Secret Lab

View File

@ -288,8 +288,9 @@ public:
std::vector<bool> quick_crewstats;
std::vector<int> unlock;
std::vector<int> unlocknotify;
static const int numunlock = 25;
bool unlock[numunlock];
bool unlocknotify[numunlock];
bool anything_unlocked();
int stat_trinkets;
bool fullscreen;