From 554c3678df737e72cb9d29ee7695c667b8aa5732 Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 9 Apr 2016 13:22:20 +0100 Subject: [PATCH] Made COMPONENTS more generic, not just for capital ships. --- src/battle/capitalShips.c | 14 +++++++------- src/battle/entities.c | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/battle/capitalShips.c b/src/battle/capitalShips.c index da1555f..b4a55c0 100644 --- a/src/battle/capitalShips.c +++ b/src/battle/capitalShips.c @@ -280,7 +280,7 @@ static void engineDie(void) for (e = battle.entityHead.next ; e != NULL ; e = e->next) { - if (e != self && e->owner == self->owner && e->type == ET_CAPITAL_SHIP_ENGINE) + if (e != self && e->owner == self->owner && e->type == ET_COMPONENT_ENGINE) { return; } @@ -430,7 +430,7 @@ static void loadComponents(Entity *parent, cJSON *components) e->active = 1; - e->type = ET_CAPITAL_SHIP_COMPONENT; + e->type = ET_COMPONENT; e->health = e->maxHealth = cJSON_GetObjectItem(component, "health")->valueint; e->offsetX = cJSON_GetObjectItem(component, "x")->valueint; e->offsetY = cJSON_GetObjectItem(component, "y")->valueint; @@ -481,7 +481,7 @@ static void loadGuns(Entity *parent, cJSON *guns) e->active = 1; - e->type = ET_CAPITAL_SHIP_GUN; + e->type = ET_COMPONENT_GUN; e->health = e->maxHealth = cJSON_GetObjectItem(gun, "health")->valueint; e->reloadTime = cJSON_GetObjectItem(gun, "reloadTime")->valueint; e->offsetX = cJSON_GetObjectItem(gun, "x")->valueint; @@ -532,7 +532,7 @@ static void loadEngines(Entity *parent, cJSON *engines) e->active = 1; - e->type = ET_CAPITAL_SHIP_ENGINE; + e->type = ET_COMPONENT_ENGINE; e->health = e->maxHealth = cJSON_GetObjectItem(engine, "health")->valueint; e->offsetX = cJSON_GetObjectItem(engine, "x")->valueint; e->offsetY = cJSON_GetObjectItem(engine, "y")->valueint; @@ -567,15 +567,15 @@ void updateCapitalShipComponentProperties(Entity *parent, long flags) { switch (e->type) { - case ET_CAPITAL_SHIP_ENGINE: + case ET_COMPONENT_ENGINE: sprintf(e->name, _("%s (Engine)"), parent->name); break; - case ET_CAPITAL_SHIP_COMPONENT: + case ET_COMPONENT: sprintf(e->name, _("%s (Component)"), parent->name); break; - case ET_CAPITAL_SHIP_GUN: + case ET_COMPONENT_GUN: sprintf(e->name, _("%s (Gun)"), parent->name); break; } diff --git a/src/battle/entities.c b/src/battle/entities.c index 850d8ba..61a8ce4 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -29,7 +29,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); +static int isComponent(Entity *e); static void resizeDrawList(void); static Entity deadHead; @@ -175,7 +175,7 @@ void doEntities(void) e->x += e->dx; e->y += e->dy; - if (!isCapitalShipComponent(e)) + if (!isComponent(e)) { addToQuadtree(e, &battle.quadtree); } @@ -367,7 +367,7 @@ static void alignComponents(void) for (e = battle.entityHead.next ; e != NULL ; e = e->next) { - if (isCapitalShipComponent(e)) + if (isComponent(e)) { s = sin(TO_RAIDANS(e->owner->angle)); c = cos(TO_RAIDANS(e->owner->angle)); @@ -391,9 +391,9 @@ static void alignComponents(void) } } -static int isCapitalShipComponent(Entity *e) +static int isComponent(Entity *e) { - return (e->type == ET_CAPITAL_SHIP_COMPONENT || e->type == ET_CAPITAL_SHIP_GUN || e->type == ET_CAPITAL_SHIP_ENGINE); + return (e->type == ET_COMPONENT || e->type == ET_COMPONENT_GUN || e->type == ET_COMPONENT_ENGINE); } void drawEntities(void)