Don't add capital ship components to quadtree until they've been positioned.
This commit is contained in:
parent
721ca3e110
commit
497977c665
|
@ -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,8 +163,11 @@ void doEntities(void)
|
|||
e->x += e->dx;
|
||||
e->y += e->dy;
|
||||
|
||||
if (!isCapitalShipComponent(e))
|
||||
{
|
||||
addToQuadtree(e, &battle.quadtree);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e == battle.entityTail)
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue