mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +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:
@@ -2077,8 +2077,11 @@ void mapclass::loadlevel(int rx, int ry)
|
||||
//A slight varation - she's upside down
|
||||
obj.createentity(249, 62, 18, 16, 0, 18);
|
||||
int j = obj.getcrewman(5);
|
||||
obj.entities[j].rule = 7;
|
||||
obj.entities[j].tile +=6;
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].rule = 7;
|
||||
obj.entities[j].tile +=6;
|
||||
}
|
||||
//What script do we use?
|
||||
obj.createblock(5, 249-32, 0, 32+32+32, 240, 5);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user