From 262eefec6e2d92ebdaf163ec59a603d4b98c5b82 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 26 Apr 2016 10:52:47 +0100 Subject: [PATCH] Don't make fighters appear onscreen when being spawned during epic battles. --- src/battle/entities.c | 11 +++++++++++ src/battle/entities.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/battle/entities.c b/src/battle/entities.c index 3be8eff..01dff42 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -569,6 +569,17 @@ static void activateEpicFighters(int side) if (!e->active && e->type == ET_FIGHTER && !(e->flags & EF_NO_EPIC) && ((side == SIDE_ALLIES && e->side == SIDE_ALLIES) || (side != SIDE_ALLIES && e->side != SIDE_ALLIES))) { e->active = 1; + + /* don't spring into existence in front of the player */ + if (isOnBattleScreen(e->x, e->y, e->w, e->h)) + { + e->x = player->x; + e->y = player->y; + + e->x += (rand() % 2) ? -SCREEN_WIDTH : SCREEN_WIDTH; + e->y += (rand() % 2) ? -SCREEN_HEIGHT : SCREEN_HEIGHT; + } + return; } } diff --git a/src/battle/entities.h b/src/battle/entities.h index 67f801a..a9b99ac 100644 --- a/src/battle/entities.h +++ b/src/battle/entities.h @@ -35,6 +35,7 @@ extern void removeFromQuadtree(Entity *e, Quadtree *root); extern void addToQuadtree(Entity *e, Quadtree *root); extern void updateCapitalShipComponentProperties(Entity *parent, long flags); extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore); +extern int isOnBattleScreen(int x, int y, int w, int h); extern App app; extern Battle battle;