mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Fix undefined behavior when removing activity zones
It turns out the game engaged in pseudo-UB when removing activity zones, which got turned into actual UB due to the previous commit. There were three places where this could happen: - Pressing ENTER on an activity zone in normal gameplay - Pressing ENTER on an activity zone in in-editor playtesting (because the code is duped here) - Pressing ESC and quitting to menu while standing inside an activity zone In all cases, game.activeactivity would still be pointing to a non-existent activity zone. This activity zone in the previous system would simply be a block with a false 'active', and in the system where C++ vectors are used properly, would index past the blocks array. In fact, it is a bug that when you press ENTER on an activity zone, the activity zone prompt suddenly turns to black, then immediately disappears. It was pointing to a block that had its clear() method called, which is why it was all black, and it was an inactive block! This commit makes it so pressing ENTER on an activity zone smoothly fades out the activity zone prompt instead of being sudden black.
This commit is contained in:
parent
f10ac88c1a
commit
2a80c80f6c
1 changed files with 3 additions and 0 deletions
|
@ -1717,6 +1717,7 @@ void gameinput()
|
||||||
{
|
{
|
||||||
script.load(obj.blocks[game.activeactivity].script);
|
script.load(obj.blocks[game.activeactivity].script);
|
||||||
obj.removeblock(game.activeactivity);
|
obj.removeblock(game.activeactivity);
|
||||||
|
game.activeactivity = -1;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
game.gamestate = EDITORMODE;
|
game.gamestate = EDITORMODE;
|
||||||
|
@ -1823,6 +1824,7 @@ void gameinput()
|
||||||
{
|
{
|
||||||
script.load(obj.blocks[game.activeactivity].script);
|
script.load(obj.blocks[game.activeactivity].script);
|
||||||
obj.removeblock(game.activeactivity);
|
obj.removeblock(game.activeactivity);
|
||||||
|
game.activeactivity = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (game.swnmode == 1 && game.swngame == 1)
|
else if (game.swnmode == 1 && game.swngame == 1)
|
||||||
|
@ -2058,6 +2060,7 @@ void mapinput()
|
||||||
FillRect(graphics.menubuffer, 0x000000);
|
FillRect(graphics.menubuffer, 0x000000);
|
||||||
graphics.resumegamemode = true;
|
graphics.resumegamemode = true;
|
||||||
obj.removeallblocks();
|
obj.removeallblocks();
|
||||||
|
game.activeactivity = -1;
|
||||||
game.menukludge = false;
|
game.menukludge = false;
|
||||||
if (game.menupage >= 20)
|
if (game.menupage >= 20)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue