mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03:00
Bounds check all entity getters that can return 0
The entity getters I'm referring to are entityclass::getscm(), entityclass::getlineat(), entityclass::getcrewman(), and entityclass::getcustomcrewman(). Even though the player should always exist, and the player should always be indice 0, I wouldn't want to make that assumption. I've been wrong before. Also, these functions returning 0 lull you into a false sense of security. If you assume that commands using these functions are fine, you'll forget about the fact that `i` in those commands could be potentially anything, given an invalid argument. In fact, it's possible to index createactivityzone(), flipgravity(), and customposition() out-of-bounds by setting `i` to anything! Well, WAS possible. I fixed it so now they can't. Furthermore, in the game.scmmoveme block in gamelogic(), obj.getplayer() wasn't even checked, even though it's been checked in all other places. I only caught it just now because I wanted to bounds-check all usages of obj.getscm(), too, and that game.scmmove block also used obj.getscm() without bounds-checking it as well.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "Game.h"
|
||||
#include "Entity.h"
|
||||
#include "MakeAndPlay.h"
|
||||
#include "UtilityClass.h"
|
||||
|
||||
const short* otherlevelclass::loadlevel(int rx, int ry)
|
||||
{
|
||||
@@ -8892,8 +8893,12 @@ const short* otherlevelclass::loadlevel(int rx, int ry)
|
||||
|
||||
//violet
|
||||
obj.createentity(83, 126, 18, 20, 0, 18);
|
||||
obj.entities[obj.getcrewman(1)].rule = 7;
|
||||
obj.entities[obj.getcrewman(1)].tile +=6;
|
||||
int crewman = obj.getcrewman(1);
|
||||
if (INBOUNDS_VEC(crewman, obj.entities))
|
||||
{
|
||||
obj.entities[crewman].rule = 7;
|
||||
obj.entities[crewman].tile +=6;
|
||||
}
|
||||
obj.createblock(5, 83 - 32, 0, 32 + 32 + 32, 240, 1);
|
||||
}
|
||||
result = contents;
|
||||
|
||||
Reference in New Issue
Block a user