diff --git a/src/alien.c b/src/alien.c index 0f0bdda..5862653 100644 --- a/src/alien.c +++ b/src/alien.c @@ -1110,8 +1110,8 @@ void aliens_init() barrierSpeed++; } - if ((game.area == MISN_POSWIC) && - (aliens[i].classDef == CD_BOSS)) + if ((game.area == MISN_POSWIC) + && (aliens[i].classDef == CD_BOSS)) { aliens[i].flags |= FL_IMMORTAL; } @@ -1663,8 +1663,8 @@ void alien_setKlineAI(Object *alien) switch(RANDRANGE(0, 9)) { case 0: - if ((alien->weaponType[0] != W_DIRSHOCKMISSILE) && - (alien->weaponType[1] != W_MICRO_HOMING_MISSILES)) + if ((alien->weaponType[0] != W_DIRSHOCKMISSILE) + && (alien->weaponType[1] != W_MICRO_HOMING_MISSILES)) alien->flags |= FL_CONTINUOUS_FIRE; alien->dx = ((alien->x - alien->target->x) / ((300 / alien->speed) + RANDRANGE(0, 100))); @@ -1726,8 +1726,8 @@ void alien_searchForTarget(Object *alien) } else { - if ((targetEnemy->classDef != CD_CARGOSHIP) && - (targetEnemy->classDef != CD_BOSS)) + if ((targetEnemy->classDef != CD_CARGOSHIP) + && (targetEnemy->classDef != CD_BOSS)) { badTarget = 1; } @@ -1830,11 +1830,11 @@ int alien_enemiesInFront(Object *alien) { for (int i = 0 ; i < ALIEN_MAX ; i++) { - if ((alien != &aliens[i]) && (aliens[i].flags & FL_WEAPCO) && - (aliens[i].shield > 0)) + if ((alien != &aliens[i]) && (aliens[i].flags & FL_WEAPCO) + && (aliens[i].shield > 0)) { - if ((alien->y > aliens[i].y - 15) && - (alien->y < aliens[i].y + aliens[i].image[0]->h + 15)) + if ((alien->y > aliens[i].y - 15) + && (alien->y < aliens[i].y + aliens[i].image[0]->h + 15)) { if ((alien->face == 1) && (aliens[i].x < alien->x)) return 1; @@ -1886,14 +1886,18 @@ void alien_move(Object *alien) { for (int i = 0 ; i < ALIEN_MAX ; i++) { - if ((aliens[i].owner != alien) && (aliens[i].active) && - (aliens[i].shield > 0) && (!(aliens[i].flags & FL_LEAVESECTOR)) && - (alien->classDef != CD_BARRIER) && - ship_collision(alien, &aliens[i])) + if ((aliens[i].owner != alien) && (aliens[i].active) + && (aliens[i].shield > 0) + && (!(aliens[i].flags & FL_LEAVESECTOR)) + && (alien->classDef != CD_BARRIER) + && ship_collision(alien, &aliens[i])) { - if ((game.difficulty == DIFFICULTY_ORIGINAL) && (alien->classDef != CD_DRONE) && - (alien->classDef != CD_ASTEROID) && (alien->classDef != CD_ASTEROID2) && - (alien->owner == alien) && (game.area != MISN_ELLESH)) + if ((game.difficulty == DIFFICULTY_ORIGINAL) + && (alien->classDef != CD_DRONE) + && (alien->classDef != CD_ASTEROID) + && (alien->classDef != CD_ASTEROID2) + && (alien->owner == alien) + && (game.area != MISN_ELLESH)) { collided = 1; } @@ -1978,8 +1982,8 @@ void alien_destroy(Object *alien, Object *attacker) audio_playSound(SFX_EXPLOSION, alien->x, alien->y); // Chain reaction damage if needed (Classic Difficulty version) - if ((game.difficulty == DIFFICULTY_ORIGINAL) && - (alien->owner != alien) && (alien->flags & FL_DAMAGEOWNER)) + if ((game.difficulty == DIFFICULTY_ORIGINAL) + && (alien->owner != alien) && (alien->flags & FL_DAMAGEOWNER)) { alien_hurt(alien->owner, attacker, alien->maxShield, 0); } @@ -2015,8 +2019,8 @@ void alien_destroy(Object *alien, Object *attacker) } } - if (CHANCE(1 / 16.) && (alien->flags & FL_WEAPCO) && - (!(alien->flags & FL_NOBANTER))) + if (CHANCE(1 / 16.) && (alien->flags & FL_WEAPCO) + && (!(alien->flags & FL_NOBANTER))) { radio_getRandomMessage(msg, _( /// Chris brag messages @@ -2048,8 +2052,8 @@ void alien_destroy(Object *alien, Object *attacker) else if (attacker->classDef == CD_PHOEBE) { game.wingMate1Kills++; - if (CHANCE(1 / 8.) && (alien-> flags & FL_WEAPCO) && - (!(alien->flags & FL_NOBANTER))) + if (CHANCE(1 / 8.) && (alien-> flags & FL_WEAPCO) + && (!(alien->flags & FL_NOBANTER))) { radio_getRandomMessage(msg, _( /// Phoebe brag messages @@ -2077,8 +2081,8 @@ void alien_destroy(Object *alien, Object *attacker) else if (attacker->classDef == CD_URSULA) { game.wingMate2Kills++; - if (CHANCE(1 / 8.) && (alien-> flags & FL_WEAPCO) && - (!(alien->flags & FL_NOBANTER))) + if (CHANCE(1 / 8.) && (alien-> flags & FL_WEAPCO) + && (!(alien->flags & FL_NOBANTER))) { radio_getRandomMessage(msg, _( /// Ursula brag messages diff --git a/src/audio.c b/src/audio.c index 909bdfe..cfac50e 100644 --- a/src/audio.c +++ b/src/audio.c @@ -109,8 +109,8 @@ void audio_playSound(int sid, float x, float y) } else { - if (Mix_Playing(channel) && (volume <= MIX_MAX_VOLUME / 4) && - (channelVolume[channel] >= MIX_MAX_VOLUME * 3 / 4)) + if (Mix_Playing(channel) && (volume <= MIX_MAX_VOLUME / 4) + && (channelVolume[channel] >= MIX_MAX_VOLUME * 3 / 4)) return; else channelVolume[channel] = volume; diff --git a/src/event.c b/src/event.c index 4ca87ea..8f40109 100644 --- a/src/event.c +++ b/src/event.c @@ -48,8 +48,8 @@ void events_init() switch (game.area) { case MISN_INTERCEPTION: - if ((aliens[ALIEN_KLINE].classDef == CD_KLINE) && - (aliens[ALIEN_KLINE].active)) + if ((aliens[ALIEN_KLINE].classDef == CD_KLINE) + && (aliens[ALIEN_KLINE].active)) { events[0].time = 2; events[0].face = FS_KLINE; diff --git a/src/game.c b/src/game.c index 34f392c..6a6fe81 100644 --- a/src/game.c +++ b/src/game.c @@ -294,10 +294,10 @@ static void game_doCollectables() if (collectable->active) { - if ((collectable->x + collectable->image->w > 0) && - (collectable->x < screen->w) && - (collectable->y + collectable->image->h > 0) && - (collectable->y < screen->h)) + if ((collectable->x + collectable->image->w > 0) + && (collectable->x < screen->w) + && (collectable->y + collectable->image->h > 0) + && (collectable->y < screen->h)) screen_blit(collectable->image, (int)collectable->x, (int)collectable->y); collectable->x += engine.ssx + engine.smx; @@ -580,9 +580,9 @@ static void game_doCollectables() } else { - if ((collectable->type == P_MINE) && (collectable->x >= 0) && - (collectable->x <= screen->w) && (collectable->y >= 0) && - (collectable->y <= screen->h)) + if ((collectable->type == P_MINE) && (collectable->x >= 0) + && (collectable->x <= screen->w) && (collectable->y >= 0) + && (collectable->y <= screen->h)) collectable_explode(collectable); prevCollectable->next = collectable->next; free(collectable); @@ -818,8 +818,9 @@ static void game_doBullets() if ((bullet->flags & WF_WEAPCO) || (bullet->id == WT_ROCKET) || (bullet->id == WT_LASER) || (bullet->id == WT_CHARGER)) { - if (bullet->active && (player.shield > 0) && - (bullet->owner != &player) && bullet_collision(bullet, &player)) + if (bullet->active && (player.shield > 0) + && (bullet->owner != &player) + && bullet_collision(bullet, &player)) { old_shield = player.shield; @@ -1024,14 +1025,16 @@ static void game_doAliens() if (aliens[i].face == 0) aliens[i].x = aliens[i].owner->x - aliens[i].dx; else - aliens[i].x = aliens[i].owner->x + aliens[i].owner->image[0]->w + aliens[i].dx - aliens[i].image[0]->w; + aliens[i].x = (aliens[i].owner->x + aliens[i].dx + + aliens[i].owner->image[0]->w + - aliens[i].image[0]->w); aliens[i].y = (aliens[i].owner->y + aliens[i].dy); if (aliens[i].owner->shield < 1) { - if ((aliens[i].classDef != CD_URANUSBOSSWING1) && - (aliens[i].classDef != CD_URANUSBOSSWING2)) + if ((aliens[i].classDef != CD_URANUSBOSSWING1) + && (aliens[i].classDef != CD_URANUSBOSSWING2)) { aliens[i].shield = 0; } @@ -1052,8 +1055,8 @@ static void game_doAliens() aliens[i].target = &aliens[i]; // Specific to Sid to stop him pissing about(!) - if ((aliens[i].classDef == CD_SID) && - (aliens[i].target->flags & FL_DISABLED)) + if ((aliens[i].classDef == CD_SID) + && (aliens[i].target->flags & FL_DISABLED)) aliens[i].target = &aliens[i]; if (aliens[i].target == &aliens[i]) @@ -1072,9 +1075,9 @@ static void game_doAliens() } } - if ((!(aliens[i].flags & FL_DISABLED)) && - (aliens[i].thinktime == 0) && (aliens[i].target != &aliens[i]) && - (aliens[i].owner == &aliens[i])) + if ((!(aliens[i].flags & FL_DISABLED)) + && (aliens[i].thinktime == 0) && (aliens[i].target != &aliens[i]) + && (aliens[i].owner == &aliens[i])) { if (aliens[i].classDef == CD_KLINE) alien_setKlineAI(&aliens[i]); @@ -1163,9 +1166,9 @@ static void game_doAliens() aliens[i].dy = 20 + (cosf(barrierLoop + aliens[i].speed) * 40); } - if ((aliens[i].classDef == CD_MOBILESHIELD) && - (aliens[ALIEN_BOSS].active) && - (aliens[ALIEN_BOSS].shield > 0)) + if ((aliens[i].classDef == CD_MOBILESHIELD) + && (aliens[ALIEN_BOSS].active) + && (aliens[ALIEN_BOSS].shield > 0)) { LIMIT_ADD(aliens[ALIEN_BOSS].shield, 1, 0, aliens[ALIEN_BOSS].maxShield); @@ -1174,14 +1177,14 @@ static void game_doAliens() LIMIT_ADD(aliens[i].reload[0], -1, 0, 999); LIMIT_ADD(aliens[i].reload[1], -1, 0, 999); - if ((!(aliens[i].flags & FL_DISABLED)) && - (!(aliens[i].flags & FL_NOFIRE))) + if ((!(aliens[i].flags & FL_DISABLED)) + && (!(aliens[i].flags & FL_NOFIRE))) { if ((aliens[i].target->shield > 0)) canFire = alien_checkTarget(&aliens[i]); - if (((aliens[i].thinktime % 2) == 0) && - (aliens[i].flags & FL_FRIEND)) + if (((aliens[i].thinktime % 2) == 0) + && (aliens[i].flags & FL_FRIEND)) canFire = alien_enemiesInFront(&aliens[i]); } else @@ -1193,12 +1196,12 @@ static void game_doAliens() { for (int j = 0 ; j < 2 ; j++) { - if ((aliens[i].reload[j] == 0) && - ((rand() % 1000 < aliens[i].chance[j]) - || (aliens[i].flags & FL_CONTINUOUS_FIRE))) + if ((aliens[i].reload[j] == 0) + && ((rand() % 1000 < aliens[i].chance[j]) + || (aliens[i].flags & FL_CONTINUOUS_FIRE))) { - if ((aliens[i].weaponType[j] != W_ENERGYRAY) && - (aliens[i].weaponType[j] != W_LASER)) + if ((aliens[i].weaponType[j] != W_ENERGYRAY) + && (aliens[i].weaponType[j] != W_LASER)) { if (aliens[i].weaponType[j] == W_CHARGER) aliens[i].ammo[j] = 50 + rand() % 150; @@ -1211,8 +1214,8 @@ static void game_doAliens() // Note: ammo[0] is required whether the ray is primary // or secondary because futher below, ammo[0] increases on // any alien that isn't currently firing a ray. - else if ((aliens[i].weaponType[j] == W_ENERGYRAY) && - (aliens[i].ammo[0] >= RAY_INTERVAL)) + else if ((aliens[i].weaponType[j] == W_ENERGYRAY) + && (aliens[i].ammo[0] >= RAY_INTERVAL)) { aliens[i].flags += FL_FIRERAY; audio_playSound(SFX_ENERGYRAY, aliens[i].x, aliens[i].y); @@ -1259,16 +1262,17 @@ static void game_doAliens() LIMIT_ADD(aliens[i].hit, -1, 0, 100); - if ((aliens[i].x + aliens[i].image[0]->w > 0) && - (aliens[i].x < screen->w) && - (aliens[i].y + aliens[i].image[0]->h > 0) && - (aliens[i].y < screen->h)) + if ((aliens[i].x + aliens[i].image[0]->w > 0) + && (aliens[i].x < screen->w) + && (aliens[i].y + aliens[i].image[0]->h > 0) + && (aliens[i].y < screen->h)) { - if ((!(aliens[i].flags & FL_DISABLED)) && - (aliens[i].classDef != CD_ASTEROID) && - (aliens[i].classDef != CD_ASTEROID2)) + if ((!(aliens[i].flags & FL_DISABLED)) + && (aliens[i].classDef != CD_ASTEROID) + && (aliens[i].classDef != CD_ASTEROID2)) explosion_addEngine(&aliens[i]); - if ((!(aliens[i].flags & FL_ISCLOAKED)) || (aliens[i].hit > 0)) + if ((!(aliens[i].flags & FL_ISCLOAKED)) + || (aliens[i].hit > 0)) screen_blit(gfx_shipSprites[shapeToUse], (int)aliens[i].x, (int)aliens[i].y); if (aliens[i].flags & FL_DISABLED) @@ -1320,8 +1324,8 @@ static void game_doAliens() } // Adjust the movement even whilst exploding - if ((!(aliens[i].flags & FL_NOMOVE)) && - (!(aliens[i].flags & FL_DISABLED))) + if ((!(aliens[i].flags & FL_NOMOVE)) + && (!(aliens[i].flags & FL_DISABLED))) alien_move(&aliens[i]); if ((game.area != MISN_ELLESH) || (aliens[i].shield < 0)) @@ -1360,8 +1364,9 @@ static void game_doPlayer() if ((engine.keyState[KEY_ALTFIRE]) && (player.weaponType[1] != W_NONE)) { - if ((player.weaponType[1] != W_CHARGER) && - (player.weaponType[1] != W_LASER) && (player.ammo[1] > 0)) + if ((player.weaponType[1] != W_CHARGER) + && (player.weaponType[1] != W_LASER) + && (player.ammo[1] > 0)) { ship_fireBullet(&player, 1); } @@ -1386,9 +1391,9 @@ static void game_doPlayer() if (player.weaponType[1] == W_CHARGER) { - if (engine.keyState[KEY_ALTFIRE] && - ((game.difficulty == DIFFICULTY_ORIGINAL) - || !(engine.keyState[KEY_FIRE]))) + if (engine.keyState[KEY_ALTFIRE] + && ((game.difficulty == DIFFICULTY_ORIGINAL) + || !(engine.keyState[KEY_FIRE]))) { if (!player_chargerFired) { @@ -1424,8 +1429,8 @@ static void game_doPlayer() if ((engine.keyState[KEY_SWITCH])) { - if ((weapons[W_PLAYER_WEAPON].ammo[0] >= 3) && - (weapons[W_PLAYER_WEAPON].ammo[0] <= game.maxPlasmaOutput)) + if ((weapons[W_PLAYER_WEAPON].ammo[0] >= 3) + && (weapons[W_PLAYER_WEAPON].ammo[0] <= game.maxPlasmaOutput)) { weapons[W_PLAYER_WEAPON].flags ^= WF_SPREAD; @@ -1470,9 +1475,9 @@ static void game_doPlayer() if (engine.keyState[KEY_ESCAPE]) { - if ((engine.done == ENGINE_RUNNING) && - (engine.gameSection == SECTION_GAME) && - (mission.remainingObjectives1 == 0)) + if ((engine.done == ENGINE_RUNNING) + && (engine.gameSection == SECTION_GAME) + && (mission.remainingObjectives1 == 0)) { audio_playSound(SFX_FLY, screen->w / 2, screen->h / 2); engine.done = ENGINE_SYSEXIT; @@ -1575,8 +1580,8 @@ static void game_doPlayer() LIMIT_ADD(player.hit, -1, 0, 100); screen_blit(gfx_shipSprites[shapeToUse], (int)player.x, (int)player.y); - if ((player.maxShield > 1) && (player.shield <= engine.lowShield) && - CHANCE(1. / 10)) + if ((player.maxShield > 1) && (player.shield <= engine.lowShield) + && CHANCE(1. / 10)) explosion_add(player.x + RANDRANGE(-10, 10), player.y + RANDRANGE(-10, 20), SP_SMOKE); } @@ -1816,41 +1821,41 @@ static void game_doArrow(int i) if (aliens[i].x + aliens[i].image[0]->w < 0) { if (aliens[i].y + aliens[i].image[0]->h < 0) - arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) && - (aliens[i].flags & FL_FRIEND)) ? - SP_ARROW_FRIEND_NORTHWEST : SP_ARROW_NORTHWEST); + arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) + && (aliens[i].flags & FL_FRIEND)) ? + SP_ARROW_FRIEND_NORTHWEST : SP_ARROW_NORTHWEST); else if (aliens[i].y > screen->h) - arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) && - (aliens[i].flags & FL_FRIEND)) ? - SP_ARROW_FRIEND_SOUTHWEST : SP_ARROW_SOUTHWEST); + arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) + && (aliens[i].flags & FL_FRIEND)) ? + SP_ARROW_FRIEND_SOUTHWEST : SP_ARROW_SOUTHWEST); else - arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) && - (aliens[i].flags & FL_FRIEND)) ? - SP_ARROW_FRIEND_WEST : SP_ARROW_WEST); + arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) + && (aliens[i].flags & FL_FRIEND)) ? + SP_ARROW_FRIEND_WEST : SP_ARROW_WEST); } else if (aliens[i].x > screen->w) { if (aliens[i].y + aliens[i].image[0]->h < 0) - arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) && - (aliens[i].flags & FL_FRIEND)) ? - SP_ARROW_FRIEND_NORTHEAST : SP_ARROW_NORTHEAST); + arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) + && (aliens[i].flags & FL_FRIEND)) ? + SP_ARROW_FRIEND_NORTHEAST : SP_ARROW_NORTHEAST); else if (aliens[i].y > screen->h) - arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) && - (aliens[i].flags & FL_FRIEND)) ? - SP_ARROW_FRIEND_SOUTHEAST : SP_ARROW_SOUTHEAST); + arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) + && (aliens[i].flags & FL_FRIEND)) ? + SP_ARROW_FRIEND_SOUTHEAST : SP_ARROW_SOUTHEAST); else - arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) && - (aliens[i].flags & FL_FRIEND)) ? - SP_ARROW_FRIEND_EAST : SP_ARROW_EAST); + arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) + && (aliens[i].flags & FL_FRIEND)) ? + SP_ARROW_FRIEND_EAST : SP_ARROW_EAST); } else if (aliens[i].y + aliens[i].image[0]->h < 0) - arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) && - (aliens[i].flags & FL_FRIEND)) ? - SP_ARROW_FRIEND_NORTH : SP_ARROW_NORTH); + arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) + && (aliens[i].flags & FL_FRIEND)) ? + SP_ARROW_FRIEND_NORTH : SP_ARROW_NORTH); else if (aliens[i].y > screen->h) - arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) && - (aliens[i].flags & FL_FRIEND)) ? - SP_ARROW_FRIEND_SOUTH : SP_ARROW_SOUTH); + arrow = (((game.difficulty != DIFFICULTY_ORIGINAL) + && (aliens[i].flags & FL_FRIEND)) ? + SP_ARROW_FRIEND_SOUTH : SP_ARROW_SOUTH); if (arrow != -1) { @@ -2038,8 +2043,8 @@ static void game_doHud() events_check(); } - if ((engine.timeMission) && (player.shield > 0) && - ((!engine.cheatTime) || (game.area == MISN_MARS))) + if ((engine.timeMission) && (player.shield > 0) + && ((!engine.cheatTime) || (game.area == MISN_MARS))) { if (SDL_GetTicks() >= engine.counter) { @@ -2113,8 +2118,8 @@ static void game_doHud() // Do the target's remaining shield (if required) if (game.area != MISN_DORIM) { - if ((engine.targetIndex > -1) && (aliens[engine.targetIndex].shield > 0) && - (engine.targetIndex > engine.maxAliens)) + if ((engine.targetIndex > -1) && (aliens[engine.targetIndex].shield > 0) + && (engine.targetIndex > engine.maxAliens)) { if (game.difficulty == DIFFICULTY_ORIGINAL) { @@ -2604,8 +2609,8 @@ int game_mainLoop() for (int i = 0 ; i < 3 ; i++) { - if ((mission.primaryType[i] == M_DESTROY_TARGET_TYPE) && - (mission.target1[i] == CD_ANY)) + if ((mission.primaryType[i] == M_DESTROY_TARGET_TYPE) + && (mission.target1[i] == CD_ANY)) allowableAliens = mission.targetValue1[i]; if (mission.primaryType[i] == M_DESTROY_ALL_TARGETS) @@ -2650,33 +2655,33 @@ int game_mainLoop() engine.gameSection = SECTION_INTERMISSION; if (player.shield > 0) { - if ((SDL_GetTicks() >= engine.missionCompleteTimer) && - ((game.difficulty == DIFFICULTY_ORIGINAL) - || (game.difficulty == DIFFICULTY_NIGHTMARE) - || (game.area == MISN_INTERCEPTION) - || (game.area == MISN_ELLESH) - || (game.area == MISN_MARS) - || (mission_checkFailed()) - || (collectable_numGood() <= 0) - || (engine.done == ENGINE_SYSEXIT))) + if ((SDL_GetTicks() >= engine.missionCompleteTimer) + && ((game.difficulty == DIFFICULTY_ORIGINAL) + || (game.difficulty == DIFFICULTY_NIGHTMARE) + || (game.area == MISN_INTERCEPTION) + || (game.area == MISN_ELLESH) + || (game.area == MISN_MARS) + || (mission_checkFailed()) + || (collectable_numGood() <= 0) + || (engine.done == ENGINE_SYSEXIT))) { if ((!mission_checkFailed()) && (game.area != MISN_VENUS)) { player_leaveSector(); - if ((engine.done == ENGINE_SYSEXIT) && - (game.area != MISN_DORIM) && - (game.area != MISN_SIVEDI)) + if ((engine.done == ENGINE_SYSEXIT) + && (game.area != MISN_DORIM) + && (game.area != MISN_SIVEDI)) { - if ((aliens[ALIEN_PHOEBE].shield > 0) && - (game.area != MISN_EARTH)) + if ((aliens[ALIEN_PHOEBE].shield > 0) + && (game.area != MISN_EARTH)) { aliens[ALIEN_PHOEBE].x = player.x - 40; aliens[ALIEN_PHOEBE].y = player.y - 35; aliens[ALIEN_PHOEBE].face = 0; } - if ((aliens[ALIEN_URSULA].shield > 0) && - (game.area != MISN_EARTH)) + if ((aliens[ALIEN_URSULA].shield > 0) + && (game.area != MISN_EARTH)) { aliens[ALIEN_URSULA].x = player.x - 40; aliens[ALIEN_URSULA].y = player.y + 45; @@ -2692,8 +2697,8 @@ int game_mainLoop() } } } - else if ((game.area == MISN_VENUS) && - (engine.musicVolume > 0)) + else if ((game.area == MISN_VENUS) + && (engine.musicVolume > 0)) { engine.keyState[KEY_UP] = 0; engine.keyState[KEY_DOWN] = 0; @@ -2806,8 +2811,8 @@ int game_mainLoop() engine.missionCompleteTimer = SDL_GetTicks() + 7000; // specific to Boss 1 - if ((game.area == MISN_MOEBO) && - (aliens[ALIEN_BOSS].flags & FL_ESCAPED)) + if ((game.area == MISN_MOEBO) + && (aliens[ALIEN_BOSS].flags & FL_ESCAPED)) { audio_playSound(SFX_DEATH, aliens[ALIEN_BOSS].x, aliens[ALIEN_BOSS].y); screen_clear(white); diff --git a/src/gfx.c b/src/gfx.c index 0c48503..f348f01 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -646,9 +646,11 @@ void gfx_createTextObject(int index, const char *inString, int x, int y, int fon gfx_textSprites[index].life = 0; /* Shortcut: if we already rendered the same string in the same color, don't render it again. */ - if (gfx_textSprites[index].text && gfx_textSprites[index].image && - gfx_textSprites[index].fontColor == fontColor && - !strcmp(gfx_textSprites[index].text, inString)) + // TODO: Double-check this, I think it's trying to test if gfx_textSprites[index].image is NULL. + // Also, check what `text` will be when "empty". + if (gfx_textSprites[index].text && gfx_textSprites[index].image + && (gfx_textSprites[index].fontColor == fontColor) + && (strcmp(gfx_textSprites[index].text, inString) == 0)) { gfx_textSprites[index].x = x; gfx_textSprites[index].y = y; diff --git a/src/intermission.c b/src/intermission.c index 47e120b..55bf38a 100644 --- a/src/intermission.c +++ b/src/intermission.c @@ -693,10 +693,10 @@ static int intermission_showSystem(float pos, int selectable) r.y -= (intermission_planets[planet].image->h / 2); screen_blit(intermission_planets[planet].image, r.x, r.y); - if (selectable && - game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, - r.x, r.y, intermission_planets[planet].image->w, - intermission_planets[planet].image->h)) + if (selectable + && game_collision(engine.cursor_x + 13, engine.cursor_y + 13, + 6, 6, r.x, r.y, intermission_planets[planet].image->w, + intermission_planets[planet].image->h)) { if (!printedName) { @@ -1729,8 +1729,8 @@ int intermission() x = screen->w / 16; y = screen->h - 80; w = screen->w - 2 * x - 32; - if ((game.stationedPlanet == game.destinationPlanet) && - (!intermission_planets[game.stationedPlanet].missionCompleted)) + if ((game.stationedPlanet == game.destinationPlanet) + && (!intermission_planets[game.stationedPlanet].missionCompleted)) screen_blit(gfx_sprites[SP_START_MISSION], x, y); else if (game.stationedPlanet != game.destinationPlanet) screen_blit(gfx_sprites[SP_GOTO], x, y); diff --git a/src/mission.c b/src/mission.c index 68d85ad..7195be9 100644 --- a/src/mission.c +++ b/src/mission.c @@ -565,8 +565,8 @@ static void mission_killAllEnemies() { for (int i = 0 ; i < ALIEN_MAX ; i++) { - if ((aliens[i].flags & FL_WEAPCO) && (aliens[i].active) && - (aliens[i].shield > 0)) + if ((aliens[i].flags & FL_WEAPCO) && (aliens[i].active) + && (aliens[i].shield > 0)) aliens[i].shield = 0; } } @@ -596,13 +596,13 @@ void mission_checkTimer() } // specific to Spirit Boss - if ((game.area == MISN_MOEBO) && - (mission.completed1[0] < OB_INCOMPLETE)) + if ((game.area == MISN_MOEBO) + && (mission.completed1[0] < OB_INCOMPLETE)) engine.timeMission = 1; // specific to the Asteroid belt - if ((game.area == MISN_MARS) && - (mission.completed1[0] < OB_INCOMPLETE)) + if ((game.area == MISN_MARS) + && (mission.completed1[0] < OB_INCOMPLETE)) { mission.completed1[0] = OB_COMPLETED; mission_killAllEnemies(); @@ -616,8 +616,8 @@ static void mission_evaluate(int type, int id, int *completed, int *targetValue, char message[STRMAX_SHORT]; char fmt[STRMAX_SHORT]; - if ((*targetValue <= 0) && (type != M_PROTECT_TARGET) && - (type != M_PROTECT_PICKUP)) + if ((*targetValue <= 0) && (type != M_PROTECT_TARGET) + && (type != M_PROTECT_PICKUP)) { *completed = OB_JUST_COMPLETED; mission_checkTimer(); @@ -937,7 +937,9 @@ int mission_checkCompleted() { if (mission.completed1[i] == OB_INCOMPLETE) { - if ((mission.primaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (mission.remainingObjectives1 + mission.remainingObjectives2 == 1)) + if ((mission.primaryType[i] == M_DESTROY_ALL_TARGETS) + && (engine.allAliensDead) + && (mission.remainingObjectives1 + mission.remainingObjectives2 == 1)) { mission.completed1[i] = OB_JUST_COMPLETED; mission_checkTimer(); @@ -949,7 +951,9 @@ int mission_checkCompleted() { if (mission.completed2[i] == OB_INCOMPLETE) { - if ((mission.secondaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (mission.remainingObjectives1 + mission.remainingObjectives2 == 1)) + if ((mission.secondaryType[i] == M_DESTROY_ALL_TARGETS) + && (engine.allAliensDead) + && (mission.remainingObjectives1 + mission.remainingObjectives2 == 1)) { mission.completed2[i] = OB_JUST_COMPLETED; mission_checkTimer(); @@ -1017,8 +1021,8 @@ int mission_checkCompleted() mission.completed2[i] = OB_COMPLETED; // do some area specific things - if ((game.area == MISN_DORIM) && - (mission.remainingObjectives1 == 0)) + if ((game.area == MISN_DORIM) + && (mission.remainingObjectives1 == 0)) { mission_killAllEnemies(); engine.addAliens = -1; diff --git a/src/player.c b/src/player.c index bcbf8f8..e2e5c04 100644 --- a/src/player.c +++ b/src/player.c @@ -99,8 +99,8 @@ void player_damage(int amount, int delay) player_resetDamageDelay = 0; - if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0) && - ((!player.hit) + if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0) + && ((!player.hit) || (game.difficulty == DIFFICULTY_ORIGINAL) || ((player.shield != engine.lowShield) && (player.shield != 1)))) @@ -115,8 +115,8 @@ void player_damage(int amount, int delay) audio_playSound(SFX_HIT, player.x, player.y); // Damage tiers (not in Classic mode) - if ((oldshield > engine.lowShield) && - (player.shield <= engine.lowShield)) + if ((oldshield > engine.lowShield) + && (player.shield <= engine.lowShield)) { info_setLine("!!! WARNING: SHIELD LOW !!!", FONT_RED); if (game.difficulty != DIFFICULTY_ORIGINAL) @@ -460,8 +460,8 @@ void player_getInput() screen_addBuffer(0, 0, screen->w, screen->h); } - if (engine.autoPause && - (engine.event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)) + if (engine.autoPause + && (engine.event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)) engine.paused = 1; break; } diff --git a/src/ship.c b/src/ship.c index f5c0226..b4cd157 100644 --- a/src/ship.c +++ b/src/ship.c @@ -68,8 +68,8 @@ void ship_fireBullet(Object *ship, int weaponIndex) return; // Remove some ammo from the player - if ((ship == &player) && (player.weaponType[weaponIndex] != W_LASER) && - (player.ammo[weaponIndex] > 0) && (!engine.cheatAmmo)) + if ((ship == &player) && (player.weaponType[weaponIndex] != W_LASER) + && (player.ammo[weaponIndex] > 0) && (!engine.cheatAmmo)) player.ammo[weaponIndex]--; switch(theWeapon->id) @@ -130,8 +130,8 @@ void ship_fireBullet(Object *ship, int weaponIndex) // Reset the weapon reload time. Double it if it is not friendly or // a boss or Kline ship->reload[weaponIndex] = theWeapon->reload[0]; - if ((ship->flags & FL_WEAPCO) && (ship != &aliens[ALIEN_BOSS]) && - (ship != &aliens[ALIEN_KLINE]) && (theWeapon->id != W_LASER)) + if ((ship->flags & FL_WEAPCO) && (ship != &aliens[ALIEN_BOSS]) + && (ship != &aliens[ALIEN_KLINE]) && (theWeapon->id != W_LASER)) ship->reload[weaponIndex] *= 2; if ((ship == &player) && (weaponIndex == 0)) @@ -173,8 +173,9 @@ void ship_fireRay(Object *ship) if (player.shield > 0) { if (game_collision(player.x, player.y, player.image[0]->w, - player.image[0]->h, ray.x, ray.y, ray.w, ray.h) && - (!engine.cheatShield) && (engine.missionCompleteTimer == 0)) + player.image[0]->h, ray.x, ray.y, ray.w, ray.h) + && (!engine.cheatShield) + && (engine.missionCompleteTimer == 0)) { player_damage(1, RAY_DAMAGE_DELAY); explosion_add(player.x, player.y, SP_SMALL_EXPLOSION); @@ -187,8 +188,8 @@ void ship_fireRay(Object *ship) if (aliens[i].flags & FL_IMMORTAL) continue; - if ((aliens[i].shield > 0) && (ship != &aliens[i]) && - (ship->classDef != aliens[i].classDef)) + if ((aliens[i].shield > 0) && (ship != &aliens[i]) + && (ship->classDef != aliens[i].classDef)) { if (game_collision(aliens[i].x, aliens[i].y, aliens[i].image[0]->w, aliens[i].image[0]->h, ray.x, ray.y, ray.w, ray.h)) diff --git a/src/shop.c b/src/shop.c index 619e4a2..927e957 100644 --- a/src/shop.c +++ b/src/shop.c @@ -97,8 +97,9 @@ static void drawSecondaryWeaponSurface() } gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]); - if ((player.weaponType[1] != W_LASER) && - (player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_NONE)) + if ((player.weaponType[1] != W_LASER) + && (player.weaponType[1] != W_CHARGER) + && (player.weaponType[1] != W_NONE)) { /// Retain "%d" as-is. It is replaced with the rocket capacity of the Firefly. snprintf(description, STRMAX_SHORT, _("Capacity : %d"), game.maxRocketAmmo); @@ -656,20 +657,20 @@ static void buy(int i) shopSelectedItem = SHOP_ERROR_AMMO_LIMIT; return; } - if ((player.weaponType[1] == W_HOMING_MISSILE) && - (player.ammo[1] >= MAX_HOMING)) + if ((player.weaponType[1] == W_HOMING_MISSILE) + && (player.ammo[1] >= MAX_HOMING)) { shopSelectedItem = SHOP_ERROR_WEAPON_CAPACITY; return; } - if ((player.weaponType[1] == W_DOUBLE_HOMING_MISSILES) && - (player.ammo[1] >= MAX_DOUBLE_HOMING)) + if ((player.weaponType[1] == W_DOUBLE_HOMING_MISSILES) + && (player.ammo[1] >= MAX_DOUBLE_HOMING)) { shopSelectedItem = SHOP_ERROR_WEAPON_CAPACITY; return; } - if ((player.weaponType[1] == W_MICRO_HOMING_MISSILES) && - (player.ammo[1] >= MAX_MICRO_HOMING)) + if ((player.weaponType[1] == W_MICRO_HOMING_MISSILES) + && (player.ammo[1] >= MAX_MICRO_HOMING)) { shopSelectedItem = SHOP_ERROR_WEAPON_CAPACITY; return; @@ -729,20 +730,20 @@ static void buy(int i) shopSelectedItem = SHOP_ERROR_IS_NOT_ROCKETS; return; } - if ((player.weaponType[1] == W_HOMING_MISSILE) && - (game.maxRocketAmmo >= MAX_HOMING)) + if ((player.weaponType[1] == W_HOMING_MISSILE) + && (game.maxRocketAmmo >= MAX_HOMING)) { shopSelectedItem = SHOP_ERROR_WEAPON_CAPACITY; return; } - if ((player.weaponType[1] == W_DOUBLE_HOMING_MISSILES) && - (game.maxRocketAmmo >= MAX_DOUBLE_HOMING)) + if ((player.weaponType[1] == W_DOUBLE_HOMING_MISSILES) + && (game.maxRocketAmmo >= MAX_DOUBLE_HOMING)) { shopSelectedItem = SHOP_ERROR_WEAPON_CAPACITY; return; } - if ((player.weaponType[1] == W_MICRO_HOMING_MISSILES) && - (game.maxRocketAmmo >= MAX_MICRO_HOMING)) + if ((player.weaponType[1] == W_MICRO_HOMING_MISSILES) + && (game.maxRocketAmmo >= MAX_MICRO_HOMING)) { shopSelectedItem = SHOP_ERROR_WEAPON_CAPACITY; return;