1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 06:28:30 +02:00

Use memset to give 20 trinkets and explore all rooms

SDL_memset() conveys intent better and is snappier than using a
for-loop. Also, using SDL_memset() to explore all rooms is more
future-proof, in case the size of map.explored were to change in the
future, and it's more conducive to optimization.

However, the `i` variable has to be explicitly set because it was
previously used here, but it's much better that it's explicitly set here
rather than being subtlely hidden in the inner for-loop initialization.
This commit is contained in:
Misa 2021-06-11 22:28:34 -07:00
parent 96660cd235
commit d404986e6f

View File

@ -2840,14 +2840,9 @@ void scriptclass::startgamemode( int t )
game.jumpheld = true;
//Secret lab, so reveal the map, give them all 20 trinkets
for (int j = 0; j < 20; j++)
{
obj.collect[j] = true;
for (i = 0; i < 20; i++)
{
map.setexplored(i, j, true);
}
}
SDL_memset(obj.collect, true, sizeof(obj.collect[0]) * 20);
SDL_memset(map.explored, true, sizeof(map.explored));
i = 400; /* previously a nested for-loop set this */
game.insecretlab = true;
map.showteleporters = true;