Guard all cases obj.getplayer() is used unchecked

obj.getplayer() can return -1, which can cause out-of-bounds indexing of
obj.entities, which is really bad. This was by far the most changes, as
obj.getplayer() is the most used entity-getting function that returns
-1, as well as the most-used function whose sentinel value goes
unchecked.

To deal with the usage of obj.getplayer() in mapclass::warpto(), I just
added general bounds checks inside that function instead of changing all
the callers.
This commit is contained in:
Misa
2020-06-12 20:36:08 -07:00
committed by Ethan Lee
parent 08e47e839f
commit beab344267
7 changed files with 784 additions and 408 deletions

View File

@@ -1394,10 +1394,13 @@ void gamerender()
GhostInfo ghost;
ghost.rx = game.roomx-100;
ghost.ry = game.roomy-100;
ghost.x = obj.entities[i].xp;
ghost.y = obj.entities[i].yp;
ghost.col = obj.entities[i].colour;
ghost.frame = obj.entities[i].drawframe;
if (i > -1)
{
ghost.x = obj.entities[i].xp;
ghost.y = obj.entities[i].yp;
ghost.col = obj.entities[i].colour;
ghost.frame = obj.entities[i].drawframe;
}
ed.ghosts.push_back(ghost);
}
if (ed.ghosts.size() > 100)