1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Fix memory leak from warping moving platforms

It turns out that when the game warps moving platforms, it won't remove
the block from the position before they warped. Eventually, these blocks
will pile up and will never be removed, causing a memory leak.
This commit is contained in:
Misa 2020-04-04 12:54:55 -07:00 committed by Ethan Lee
parent 79a54f23e6
commit 7f0db19abd

View file

@ -1045,10 +1045,12 @@ void gamelogic()
//ascii snakes //ascii snakes
if (obj.entities[i].xp <= -80) if (obj.entities[i].xp <= -80)
{ {
if (obj.entities[i].isplatform) obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
obj.entities[i].xp += 400; obj.entities[i].xp += 400;
} }
else if (obj.entities[i].xp > 320) else if (obj.entities[i].xp > 320)
{ {
if (obj.entities[i].isplatform) obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
obj.entities[i].xp -= 400; obj.entities[i].xp -= 400;
} }
} }
@ -1056,10 +1058,12 @@ void gamelogic()
{ {
if (obj.entities[i].xp <= -10) if (obj.entities[i].xp <= -10)
{ {
if (obj.entities[i].isplatform) obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
obj.entities[i].xp += 320; obj.entities[i].xp += 320;
} }
else if (obj.entities[i].xp > 310) else if (obj.entities[i].xp > 310)
{ {
if (obj.entities[i].isplatform) obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
obj.entities[i].xp -= 320; obj.entities[i].xp -= 320;
} }
} }
@ -1074,10 +1078,12 @@ void gamelogic()
if(obj.entities[i].type<50){ //Don't warp warp lines if(obj.entities[i].type<50){ //Don't warp warp lines
if (obj.entities[i].yp <= -12) if (obj.entities[i].yp <= -12)
{ {
if (obj.entities[i].isplatform) obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
obj.entities[i].yp += 232; obj.entities[i].yp += 232;
} }
else if (obj.entities[i].yp > 226) else if (obj.entities[i].yp > 226)
{ {
if (obj.entities[i].isplatform) obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
obj.entities[i].yp -= 232; obj.entities[i].yp -= 232;
} }
} }
@ -1094,10 +1100,12 @@ void gamelogic()
{ {
if (obj.entities[i].xp <= -30) if (obj.entities[i].xp <= -30)
{ {
if (obj.entities[i].isplatform) obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
obj.entities[i].xp += 350; obj.entities[i].xp += 350;
} }
else if (obj.entities[i].xp > 320) else if (obj.entities[i].xp > 320)
{ {
if (obj.entities[i].isplatform) obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
obj.entities[i].xp -= 350; obj.entities[i].xp -= 350;
} }
} }