diff options
author | Juan J. Martinez <jjm@usebox.net> | 2020-12-31 16:28:28 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2020-12-31 16:28:28 +0000 |
commit | b1161791479625b484c0f76934664d9050360ce1 (patch) | |
tree | 93b8f6d2fc9b4e49af35748d498c8b9c6ecef8b0 /game | |
parent | e0e9142dbf47115201f9d6579108ce40c255efb0 (diff) | |
download | ubox-msx-lib-b1161791479625b484c0f76934664d9050360ce1.tar.gz ubox-msx-lib-b1161791479625b484c0f76934664d9050360ce1.zip |
Fix: prevent crash with MAX_ENTITIES are used
The look would crash if all the entities are used, so we count how many
entities we process in the loop.
Diffstat (limited to 'game')
-rw-r--r-- | game/src/game.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/game/src/game.c b/game/src/game.c index bc52b2a..6a85ad2 100644 --- a/game/src/game.c +++ b/game/src/game.c @@ -370,6 +370,8 @@ void update_player() void run_game() { + uint8_t i; + // init some variables; look at game.h for description lives = MAX_LIVES; invuln = 0; @@ -421,7 +423,7 @@ void run_game() // - self is a pointer to THIS entity // - because we don't create/destroy entities dynamically // when we found one that is unused we are done - for (self = entities; self->type; self++) + for (i = 0, self = entities; i < MAX_ENTITIES && self->type; i++, self++) self->update(); // ensure we wait to our desired update rate |