Don't add capital ship components to quadtree until they've been positioned.

This commit is contained in:
Steve 2016-03-06 17:13:57 +00:00
parent 721ca3e110
commit 497977c665
1 changed files with 13 additions and 2 deletions

View File

@ -35,6 +35,7 @@ static void restrictToBattleArea(Entity *e);
static void drawTargetRects(Entity *e);
static int drawComparator(const void *a, const void *b);
static void notifyNewArrivals(void);
static int isCapitalShipComponent(Entity *e);
void initEntities(void)
{
@ -162,7 +163,10 @@ void doEntities(void)
e->x += e->dx;
e->y += e->dy;
addToQuadtree(e, &battle.quadtree);
if (!isCapitalShipComponent(e))
{
addToQuadtree(e, &battle.quadtree);
}
}
else
{
@ -321,7 +325,7 @@ static void alignComponents(void)
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{
if (e->type == ET_CAPITAL_SHIP_COMPONENT || e->type == ET_CAPITAL_SHIP_GUN || e->type == ET_CAPITAL_SHIP_ENGINE)
if (isCapitalShipComponent(e))
{
s = sin(TO_RAIDANS(e->owner->angle));
c = cos(TO_RAIDANS(e->owner->angle));
@ -339,10 +343,17 @@ static void alignComponents(void)
{
e->angle = e->owner->angle;
}
addToQuadtree(e, &battle.quadtree);
}
}
}
static int isCapitalShipComponent(Entity *e)
{
return (e->type == ET_CAPITAL_SHIP_COMPONENT || e->type == ET_CAPITAL_SHIP_GUN || e->type == ET_CAPITAL_SHIP_ENGINE);
}
void drawEntities(void)
{
Entity *e, **candidates;