From ec72a5dd40e94840f13c9cd8a9a65043b3b29014 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 13 Nov 2015 22:08:59 +0000 Subject: [PATCH] Highlight all mission targets, not just the one the player is targetting. --- src/battle/entities.c | 37 +++++++++++++++++++++++++++++++++---- src/battle/entities.h | 1 + src/battle/hud.c | 30 ------------------------------ 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/battle/entities.c b/src/battle/entities.c index 514a700..439b873 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -22,8 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void drawEntity(Entity *e); static void doEntity(void); +static void drawEntity(Entity *e); static void activateEpicFighters(int n, int side); static void restrictToGrid(Entity *e); +static void drawTargetRects(Entity *e); static int drawComparator(const void *a, const void *b); Entity *spawnEntity(void) @@ -204,10 +206,8 @@ void drawEntities(void) candidates = getAllEntsWithin(battle.camera.x, battle.camera.y, SCREEN_WIDTH, SCREEN_HEIGHT, NULL); - for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i]) - { - - } + /* count number of candidates for use with qsort */ + for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i]) {} qsort(candidates, i, sizeof(Entity*), drawComparator); @@ -226,6 +226,8 @@ void drawEntities(void) break; } } + + drawTargetRects(e); } } @@ -234,6 +236,33 @@ static void drawEntity(Entity *e) blitRotated(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->angle); } +static void drawTargetRects(Entity *e) +{ + SDL_Rect r; + + if (e == player->target) + { + r.x = e->x - 32 - battle.camera.x; + r.y = e->y - 32 - battle.camera.y; + r.w = 64; + r.h = 64; + + SDL_SetRenderDrawColor(app.renderer, 255, 0, 0, 255); + SDL_RenderDrawRect(app.renderer, &r); + } + + if ((e == battle.missionTarget || e->flags & EF_MISSION_TARGET) && (e->flags & EF_NO_MT_BOX) == 0) + { + r.x = e->x - 28 - battle.camera.x; + r.y = e->y - 28 - battle.camera.y; + r.w = 56; + r.h = 56; + + SDL_SetRenderDrawColor(app.renderer, 0, 255, 0, 255); + SDL_RenderDrawRect(app.renderer, &r); + } +} + void activateEntities(char *name) { Entity *e; diff --git a/src/battle/entities.h b/src/battle/entities.h index 8431755..b07a4a4 100644 --- a/src/battle/entities.h +++ b/src/battle/entities.h @@ -30,6 +30,7 @@ extern void addToGrid(Entity *e); extern void removeFromGrid(Entity *e); extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore); +extern App app; extern Battle battle; extern Entity *self; extern Entity *player; diff --git a/src/battle/hud.c b/src/battle/hud.c index b06fc57..f5c253a 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -29,7 +29,6 @@ static void drawObjectives(void); static void drawDistancesInfo(void); static void drawHudMessages(void); static void drawPlayerSelect(void); -static void drawTargetsRects(void); static HudMessage hudMessageHead; static HudMessage *hudMessageTail; @@ -127,8 +126,6 @@ void drawHud(void) drawPlayerTargeter(); - drawTargetsRects(); - drawWeaponInfo(); drawNumFighters(); @@ -285,33 +282,6 @@ static void drawPlayerTargeter(void) } } -static void drawTargetsRects(void) -{ - SDL_Rect r; - - if (player->target) - { - r.x = player->target->x - 32 - battle.camera.x; - r.y = player->target->y - 32 - battle.camera.y; - r.w = 64; - r.h = 64; - - SDL_SetRenderDrawColor(app.renderer, 255, 64, 0, 255); - SDL_RenderDrawRect(app.renderer, &r); - } - - if (battle.missionTarget && (battle.missionTarget->flags & EF_NO_MT_BOX) == 0) - { - r.x = battle.missionTarget->x - 28 - battle.camera.x; - r.y = battle.missionTarget->y - 28 - battle.camera.y; - r.w = 56; - r.h = 56; - - SDL_SetRenderDrawColor(app.renderer, 64, 255, 0, 255); - SDL_RenderDrawRect(app.renderer, &r); - } -} - static void drawNumFighters(void) { /* Allies */