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 (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;

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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)
{

View File

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

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;