Fix indexing out-of-bounds via an entity's drawframe

I tracked down all the functions that took in an entity's drawframe and
made sure that no matter what value an entity's drawframe was, the game
would never segfault.
This commit is contained in:
Misa
2020-06-13 18:35:12 -07:00
committed by Ethan Lee
parent 6900553f57
commit 5195299e65
3 changed files with 44 additions and 5 deletions

View File

@@ -2816,7 +2816,8 @@ void editorrender()
SDL_FillRect(graphics.ghostbuffer, NULL, SDL_MapRGBA(graphics.ghostbuffer->format, 0, 0, 0, 0));
for (int i = 0; i < (int)ed.ghosts.size(); i++) {
if (i <= ed.currentghosts) { // We don't want all of them to show up at once :)
if (ed.ghosts[i].rx != ed.levx || ed.ghosts[i].ry != ed.levy)
if (ed.ghosts[i].rx != ed.levx || ed.ghosts[i].ry != ed.levy
|| !INBOUNDS(ed.ghosts[i].frame, graphics.sprites))
continue;
point tpoint;
tpoint.x = ed.ghosts[i].x;