Prevent updating an entity if updateentities() removed it

Otherwise, this would result in the game updating an entity twice, which
isn't good. This is most noticeable in the Gravitron, where many
Gravitron squares are created and destroyed at a time, and it's
especially noticeable during the part near the end of the Gravitron
where the pattern is two Gravitron squares, one at the top and bottom,
and then two Gravitron squares in the middle afterwards. The timing is
just right such that the top one of the two middle ones would be
misaligned with the bottom one of the two when a Gravitron square gets
outside the screen.

To do this, I changed entityclass::updateentities() into a bool, and
made every single caller check its return value. I only needed to do
this for the ones preceding updateentitylogic() and
entitymapcollision(), but I wanted to play it safe and be defensive, so
I did it for the disappearing platform kludge, as well as the
updateentities() within the updateentities() function.
This commit is contained in:
Misa
2020-05-05 13:49:12 -07:00
committed by Ethan Lee
parent 3c80d136e4
commit ce1e212317
3 changed files with 91 additions and 25 deletions

View File

@@ -76,7 +76,7 @@ public:
void createentity(float xp, float yp, int t, float vx = 0, float vy = 0,
int p1 = 0, int p2 = 0, int p3 = 320, int p4 = 240 );
void updateentities(int i);
bool updateentities(int i);
void animateentities(int i);