Quadtree add / remove bug fixes.
This commit is contained in:
parent
4ff02a82e5
commit
89f2e399a5
|
@ -103,7 +103,7 @@ void doEntities(void)
|
||||||
|
|
||||||
if (self->w == 0 || self->h == 0)
|
if (self->w == 0 || self->h == 0)
|
||||||
{
|
{
|
||||||
r = &self->sprite[self->facing]->frames[self->spriteFrame]->rect;
|
r = &self->sprite[0]->frames[0]->rect;
|
||||||
|
|
||||||
self->w = r->w;
|
self->w = r->w;
|
||||||
self->h = r->h;
|
self->h = r->h;
|
||||||
|
@ -250,6 +250,8 @@ void doEntities(void)
|
||||||
|
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
{
|
{
|
||||||
|
removeFromQuadtree(e, &world.quadtree);
|
||||||
|
|
||||||
if (e->dy > 0)
|
if (e->dy > 0)
|
||||||
{
|
{
|
||||||
pushEntity(e, e->riding->dx, 0);
|
pushEntity(e, e->riding->dx, 0);
|
||||||
|
@ -261,6 +263,8 @@ void doEntities(void)
|
||||||
|
|
||||||
e->y = e->riding->y - e->h;
|
e->y = e->riding->y - e->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addToQuadtree(e, &world.quadtree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -589,6 +593,8 @@ static void moveToOthers(float dx, float dy, PointF *position)
|
||||||
|
|
||||||
if (self->type == ET_BOB && e->type == ET_PUSHBLOCK && dx != 0)
|
if (self->type == ET_BOB && e->type == ET_PUSHBLOCK && dx != 0)
|
||||||
{
|
{
|
||||||
|
removeFromQuadtree(e, &world.quadtree);
|
||||||
|
|
||||||
if (!pushEntity(e, dx * 0.35, 0))
|
if (!pushEntity(e, dx * 0.35, 0))
|
||||||
{
|
{
|
||||||
position->x = e->x;
|
position->x = e->x;
|
||||||
|
@ -599,6 +605,8 @@ static void moveToOthers(float dx, float dy, PointF *position)
|
||||||
{
|
{
|
||||||
self->animate();
|
self->animate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addToQuadtree(e, &world.quadtree);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e->isSolid && self->type != ET_LIFT)
|
if (e->isSolid && self->type != ET_LIFT)
|
||||||
|
@ -668,8 +676,6 @@ static int pushEntity(Entity *e, float dx, float dy)
|
||||||
|
|
||||||
self = e;
|
self = e;
|
||||||
|
|
||||||
removeFromQuadtree(e, &world.quadtree);
|
|
||||||
|
|
||||||
if (dx != 0)
|
if (dx != 0)
|
||||||
{
|
{
|
||||||
position.x += dx;
|
position.x += dx;
|
||||||
|
@ -686,8 +692,6 @@ static int pushEntity(Entity *e, float dx, float dy)
|
||||||
e->y = position.y;
|
e->y = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
addToQuadtree(e, &world.quadtree);
|
|
||||||
|
|
||||||
self = oldSelf;
|
self = oldSelf;
|
||||||
|
|
||||||
return (e->x == expectedX && e->y == expectedY);
|
return (e->x == expectedX && e->y == expectedY);
|
||||||
|
@ -837,7 +841,7 @@ static void compareEnvironments(void)
|
||||||
switch (prevEnv)
|
switch (prevEnv)
|
||||||
{
|
{
|
||||||
case ENV_WATER:
|
case ENV_WATER:
|
||||||
playSound(SND_WATER_OUT, CH_EFFECTS);
|
playSound(SND_WATER_OUT, self->uniqueId % MAX_SND_CHANNELS);
|
||||||
if ((self->environment == ENV_AIR) && (self->dy < 0))
|
if ((self->environment == ENV_AIR) && (self->dy < 0))
|
||||||
{
|
{
|
||||||
self->dy = JUMP_POWER;
|
self->dy = JUMP_POWER;
|
||||||
|
@ -849,11 +853,11 @@ static void compareEnvironments(void)
|
||||||
self->dy = 0.25f;
|
self->dy = 0.25f;
|
||||||
if (self->environment == ENV_WATER)
|
if (self->environment == ENV_WATER)
|
||||||
{
|
{
|
||||||
playSound(SND_WATER_IN, CH_EFFECTS);
|
playSound(SND_WATER_IN, self->uniqueId % MAX_SND_CHANNELS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playSound(SND_SLIME, CH_EFFECTS);
|
playSound(SND_SLIME, self->uniqueId % MAX_SND_CHANNELS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -958,7 +962,7 @@ static void handleTeleport(void)
|
||||||
addTeleportStars(self);
|
addTeleportStars(self);
|
||||||
self->dx = self->dy = 0;
|
self->dx = self->dy = 0;
|
||||||
self->environment = ENV_AIR;
|
self->environment = ENV_AIR;
|
||||||
playSound(SND_TELEPORT, CH_EFFECTS);
|
playSound(SND_TELEPORT, self->uniqueId % MAX_SND_CHANNELS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue