Only NULL player during player select.

This commit is contained in:
Steve 2016-05-08 08:55:40 +01:00
parent 98f9663edb
commit a16dfeb997
10 changed files with 17 additions and 17 deletions

View File

@ -159,7 +159,7 @@ static void doFighterAI(void)
{ {
if (!lookForLeader()) if (!lookForLeader())
{ {
if (self->aiFlags & AIF_MOVES_TO_PLAYER && player != NULL) if (self->aiFlags & AIF_MOVES_TO_PLAYER && player->alive == ALIVE_ALIVE)
{ {
moveToPlayer(); moveToPlayer();
} }
@ -173,7 +173,7 @@ static void doFighterAI(void)
{ {
doWander(); doWander();
} }
else if (self->aiFlags & AIF_MOVES_TO_PLAYER && player != NULL) else if (self->aiFlags & AIF_MOVES_TO_PLAYER && player->alive == ALIVE_ALIVE)
{ {
moveToPlayer(); moveToPlayer();
} }
@ -864,7 +864,7 @@ static int lookForPlayer(void)
{ {
int range = (self->aiFlags & AIF_MOVES_TO_PLAYER) ? MAX_TARGET_RANGE : 2000; 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(); moveToPlayer();
return 1; return 1;

View File

@ -122,7 +122,7 @@ static void logic(void)
static void doBattle(void) static void doBattle(void)
{ {
if (player != NULL) if (player->alive == ALIVE_ALIVE)
{ {
ssx = player->dx; ssx = player->dx;
ssy = player->dy; ssy = player->dy;
@ -155,7 +155,7 @@ static void doBattle(void)
doPlayer(); doPlayer();
if (player != NULL) if (player->alive == ALIVE_ALIVE)
{ {
doSpawners(); doSpawners();
@ -196,7 +196,7 @@ static void doBattle(void)
static void draw(void) static void draw(void)
{ {
if (player != NULL) if (player->alive == ALIVE_ALIVE)
{ {
battle.camera.x = player->x - (SCREEN_WIDTH / 2); battle.camera.x = player->x - (SCREEN_WIDTH / 2);
battle.camera.y = player->y - (SCREEN_HEIGHT / 2); battle.camera.y = player->y - (SCREEN_HEIGHT / 2);
@ -223,7 +223,7 @@ static void draw(void)
drawHud(); drawHud();
if (player != NULL) if (player->alive == ALIVE_ALIVE)
{ {
drawMessageBox(); drawMessageBox();
} }

View File

@ -99,7 +99,7 @@ void doBullets(void)
huntTarget(b); huntTarget(b);
} }
if (b->target == player && player != NULL && player->health > 0) if (b->target == player && player->alive == ALIVE_ALIVE && player->health > 0)
{ {
incomingMissile = 1; incomingMissile = 1;
} }

View File

@ -178,8 +178,6 @@ void doEntities(void)
if (e == player) if (e == player)
{ {
player = NULL;
battle.playerSelect = battle.isEpic; battle.playerSelect = battle.isEpic;
} }
@ -464,7 +462,7 @@ static void drawTargetRects(Entity *e)
int size = MAX(e->w, e->h) + 16; 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.x = e->x - (size / 2) - battle.camera.x;
r.y = e->y - (size / 2) - battle.camera.y; r.y = e->y - (size / 2) - battle.camera.y;

View File

@ -284,7 +284,7 @@ void doFighter(void)
if (self->alive == ALIVE_DEAD) if (self->alive == ALIVE_DEAD)
{ {
if (player != NULL && self != player) if (player->alive == ALIVE_ALIVE && self != player)
{ {
if (self->side != SIDE_ALLIES) if (self->side != SIDE_ALLIES)
{ {

View File

@ -138,7 +138,7 @@ void addHudMessage(SDL_Color c, char *format, ...)
void drawHud(void) void drawHud(void)
{ {
if (player != NULL) if (player->alive == ALIVE_ALIVE)
{ {
drawHealthBars(); drawHealthBars();

View File

@ -124,7 +124,7 @@ static void lookForPlayer(void)
float dx, dy, norm; float dx, dy, norm;
int distance; int distance;
if (player != NULL) if (player->alive == ALIVE_ALIVE)
{ {
distance = getDistance(self->x, self->y, player->x, player->y); distance = getDistance(self->x, self->y, player->x, player->y);

View File

@ -93,7 +93,7 @@ void doPlayer(void)
battle.boostTimer = MIN(battle.boostTimer + 1, BOOST_RECHARGE_TIME); battle.boostTimer = MIN(battle.boostTimer + 1, BOOST_RECHARGE_TIME);
battle.ecmTimer = MIN(battle.ecmTimer + 1, ECM_RECHARGE_TIME); battle.ecmTimer = MIN(battle.ecmTimer + 1, ECM_RECHARGE_TIME);
if (player != NULL) if (player->alive == ALIVE_ALIVE)
{ {
self = player; self = player;
@ -416,6 +416,8 @@ void doPlayerSelect(void)
static void selectNewPlayer(int dir) static void selectNewPlayer(int dir)
{ {
player = NULL;
do do
{ {
selectedPlayerIndex += dir; selectedPlayerIndex += dir;

View File

@ -67,7 +67,7 @@ static void think(void)
{ {
self->aiActionTime = 0; 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; self->health = 0;

View File

@ -67,7 +67,7 @@ void playBattleSound(int id, int x, int y)
int channel; int channel;
float vol; float vol;
if (player != NULL) if (player->alive == ALIVE_ALIVE)
{ {
lastPlayerX = player->x; lastPlayerX = player->x;
lastPlayerY = player->y; lastPlayerY = player->y;