diff --git a/src/battle/ai.c b/src/battle/ai.c index 54f223a..3f88d1a 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -159,7 +159,7 @@ static void doFighterAI(void) { if (!lookForLeader()) { - if (self->aiFlags & AIF_MOVES_TO_PLAYER && player != NULL) + if (self->aiFlags & AIF_MOVES_TO_PLAYER && player->alive == ALIVE_ALIVE) { moveToPlayer(); } @@ -173,7 +173,7 @@ static void doFighterAI(void) { doWander(); } - else if (self->aiFlags & AIF_MOVES_TO_PLAYER && player != NULL) + else if (self->aiFlags & AIF_MOVES_TO_PLAYER && player->alive == ALIVE_ALIVE) { moveToPlayer(); } @@ -864,7 +864,7 @@ static int lookForPlayer(void) { int range = (self->aiFlags & AIF_MOVES_TO_PLAYER) ? MAX_TARGET_RANGE : 2000; - if (player != NULL && getDistance(self->x, self->y, player->x, player->y) < range) + if (player->alive == ALIVE_ALIVE && getDistance(self->x, self->y, player->x, player->y) < range) { moveToPlayer(); return 1; diff --git a/src/battle/battle.c b/src/battle/battle.c index 7ac2db4..e8b2ae2 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -122,7 +122,7 @@ static void logic(void) static void doBattle(void) { - if (player != NULL) + if (player->alive == ALIVE_ALIVE) { ssx = player->dx; ssy = player->dy; @@ -155,7 +155,7 @@ static void doBattle(void) doPlayer(); - if (player != NULL) + if (player->alive == ALIVE_ALIVE) { doSpawners(); @@ -196,7 +196,7 @@ static void doBattle(void) static void draw(void) { - if (player != NULL) + if (player->alive == ALIVE_ALIVE) { battle.camera.x = player->x - (SCREEN_WIDTH / 2); battle.camera.y = player->y - (SCREEN_HEIGHT / 2); @@ -223,7 +223,7 @@ static void draw(void) drawHud(); - if (player != NULL) + if (player->alive == ALIVE_ALIVE) { drawMessageBox(); } diff --git a/src/battle/bullets.c b/src/battle/bullets.c index d09dbdd..0e0684c 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -99,7 +99,7 @@ void doBullets(void) huntTarget(b); } - if (b->target == player && player != NULL && player->health > 0) + if (b->target == player && player->alive == ALIVE_ALIVE && player->health > 0) { incomingMissile = 1; } diff --git a/src/battle/entities.c b/src/battle/entities.c index fa03038..358c9f2 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -178,8 +178,6 @@ void doEntities(void) if (e == player) { - player = NULL; - battle.playerSelect = battle.isEpic; } @@ -464,7 +462,7 @@ static void drawTargetRects(Entity *e) int size = MAX(e->w, e->h) + 16; - if (player != NULL && e == player->target) + if (player->alive == ALIVE_ALIVE && e == player->target) { r.x = e->x - (size / 2) - battle.camera.x; r.y = e->y - (size / 2) - battle.camera.y; diff --git a/src/battle/fighters.c b/src/battle/fighters.c index 54e4b17..d6c102c 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -284,7 +284,7 @@ void doFighter(void) if (self->alive == ALIVE_DEAD) { - if (player != NULL && self != player) + if (player->alive == ALIVE_ALIVE && self != player) { if (self->side != SIDE_ALLIES) { diff --git a/src/battle/hud.c b/src/battle/hud.c index 773d0e4..9ec3a06 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -138,7 +138,7 @@ void addHudMessage(SDL_Color c, char *format, ...) void drawHud(void) { - if (player != NULL) + if (player->alive == ALIVE_ALIVE) { drawHealthBars(); diff --git a/src/battle/mine.c b/src/battle/mine.c index b53e7ad..151c6f1 100644 --- a/src/battle/mine.c +++ b/src/battle/mine.c @@ -124,7 +124,7 @@ static void lookForPlayer(void) float dx, dy, norm; int distance; - if (player != NULL) + if (player->alive == ALIVE_ALIVE) { distance = getDistance(self->x, self->y, player->x, player->y); diff --git a/src/battle/player.c b/src/battle/player.c index 457b4ea..bd2a0b4 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -93,7 +93,7 @@ void doPlayer(void) battle.boostTimer = MIN(battle.boostTimer + 1, BOOST_RECHARGE_TIME); battle.ecmTimer = MIN(battle.ecmTimer + 1, ECM_RECHARGE_TIME); - if (player != NULL) + if (player->alive == ALIVE_ALIVE) { self = player; @@ -416,6 +416,8 @@ void doPlayerSelect(void) static void selectNewPlayer(int dir) { + player = NULL; + do { selectedPlayerIndex += dir; diff --git a/src/battle/waypoints.c b/src/battle/waypoints.c index dfd8e14..939aeab 100644 --- a/src/battle/waypoints.c +++ b/src/battle/waypoints.c @@ -67,7 +67,7 @@ static void think(void) { self->aiActionTime = 0; - if (self->health && player != NULL && getDistance(player->x, player->y, self->x, self->y) <= 128 && isCurrentObjective() && teamMatesClose()) + if (self->health && player->alive == ALIVE_ALIVE && getDistance(player->x, player->y, self->x, self->y) <= 128 && isCurrentObjective() && teamMatesClose()) { self->health = 0; diff --git a/src/system/sound.c b/src/system/sound.c index 429f628..13e0cfd 100644 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -67,7 +67,7 @@ void playBattleSound(int id, int x, int y) int channel; float vol; - if (player != NULL) + if (player->alive == ALIVE_ALIVE) { lastPlayerX = player->x; lastPlayerY = player->y;