Reformatted conditionals with trailing || and &&

This commit is contained in:
Layla Marchant 2020-11-22 23:03:38 -05:00
parent 123087e60e
commit 1a3e801271
No known key found for this signature in database
GPG Key ID: 52FB5C20A8336782
10 changed files with 120 additions and 117 deletions

View File

@ -114,8 +114,8 @@ int main(int argc, char **argv)
cheatCount = 2;
if ((strcmp(argv[i], "it") == 0) && (cheatCount == 2))
cheatCount = 3;
if (((strcmp(argv[i], "better") == 0) && (cheatCount == 3)) ||
(strcmp(argv[i], "humansdoitbetter") == 0))
if (((strcmp(argv[i], "better") == 0) && (cheatCount == 3))
|| (strcmp(argv[i], "humansdoitbetter") == 0))
{
printf("Humans do it better! Cheats enabled.\n");
engine.cheat = 1;

View File

@ -1144,8 +1144,8 @@ void aliens_init()
aliens[ALIEN_BOSS_PART2].dx = -20;
aliens[ALIEN_BOSS_PART2].dy = 37;
}
else if ((game.area == MISN_ELAMALE) ||
(game.area == MISN_FELLON))
else if ((game.area == MISN_ELAMALE)
|| (game.area == MISN_FELLON))
{
aliens[ALIEN_BOSS].target = &player;
aliens[ALIEN_BOSS].x = -screen->w / 2;
@ -1194,8 +1194,8 @@ int alien_add()
{
int index = alien_getFreeIndex();
if ((index == -1) || (game.area == MISN_JUPITER) ||
(game.area == MISN_VENUS))
if ((index == -1) || (game.area == MISN_JUPITER)
|| (game.area == MISN_VENUS))
return 0;
int *alienArray;
@ -1674,9 +1674,9 @@ void alien_setKlineAI(Object *alien)
case 1:
case 2:
// Kline only attacks when he is ready!
if ((!(alien->flags & FL_NOFIRE)) &&
((game.area == MISN_ELAMALE) ||
game.difficulty != DIFFICULTY_ORIGINAL))
if ((!(alien->flags & FL_NOFIRE))
&& ((game.area == MISN_ELAMALE)
|| game.difficulty != DIFFICULTY_ORIGINAL))
alien->flags |= FL_DROPMINES;
break;
case 3:
@ -1743,8 +1743,8 @@ void alien_searchForTarget(Object *alien)
if (targetEnemy->classDef == CD_BOSS)
return;
if ((targetEnemy->flags & FL_DISABLED) ||
(targetEnemy->flags & FL_NOFIRE))
if ((targetEnemy->flags & FL_DISABLED)
|| (targetEnemy->flags & FL_NOFIRE))
badTarget = 1;
}
}
@ -1815,8 +1815,8 @@ int alien_checkTarget(Object *alien)
return 1;
// Not at the correct vertical height
if ((alien->y < alien->target->y - 15) ||
(alien->y > alien->target->y + alien->target->image[0]->h + 15))
if ((alien->y < alien->target->y - 15)
|| (alien->y > alien->target->y + alien->target->image[0]->h + 15))
return 0;
return 1;

View File

@ -45,8 +45,8 @@ void collectable_add(float x, float y, int type, int value, int life)
&& (weapons[W_PLAYER_WEAPON].damage <= game.minPlasmaDamage))
|| (player.ammo[0] >= game.maxPlasmaAmmo));
shield_useless = ((game.difficulty == DIFFICULTY_NIGHTMARE) ||
(player.shield >= player.maxShield));
shield_useless = ((game.difficulty == DIFFICULTY_NIGHTMARE)
|| (player.shield >= player.maxShield));
rockets_useless = ((player.weaponType[1] == W_CHARGER)
|| (player.weaponType[1] == W_LASER)
@ -187,8 +187,8 @@ void collectable_add(float x, float y, int type, int value, int life)
// Shield bonus is useless if you can't heal; give cash instead.
if ((type == P_SHIELD) && (game.difficulty != DIFFICULTY_ORIGINAL))
{
if ((game.difficulty == DIFFICULTY_NIGHTMARE) ||
(player.shield >= player.maxShield))
if ((game.difficulty == DIFFICULTY_NIGHTMARE)
|| (player.shield >= player.maxShield))
{
type = P_CASH;
}
@ -338,24 +338,27 @@ int collectable_numGood()
while (col != NULL)
{
if ((col->type != P_MINE) && (col->type != P_ORE) &&
((col->type != P_SHIELD) || (player.shield < player.maxShield)) &&
((col->type != P_ROCKET) || (player.ammo[1] < game.maxRocketAmmo)) &&
((col->type != P_PLASMA_AMMO) || (player.ammo[0] < game.maxPlasmaAmmo)) &&
((col->type != P_PLASMA_SHOT) ||
(player.ammo[0] < game.maxPlasmaAmmo) ||
(weapons[W_PLAYER_WEAPON].ammo[0] < game.maxPlasmaOutput)) &&
((col->type != P_PLASMA_DAMAGE) ||
(player.ammo[0] < game.maxPlasmaAmmo) ||
(weapons[W_PLAYER_WEAPON].damage < game.maxPlasmaDamage)) &&
((col->type != P_PLASMA_RATE) ||
(player.ammo[0] < game.maxPlasmaAmmo) ||
(weapons[W_PLAYER_WEAPON].reload[0] > rate2reload[game.maxPlasmaRate])) &&
((col->type != P_SUPER) ||
(player.ammo[0] < game.maxPlasmaAmmo) ||
(weapons[W_PLAYER_WEAPON].ammo[0] < game.maxPlasmaOutput) ||
(weapons[W_PLAYER_WEAPON].damage < game.maxPlasmaDamage) ||
(weapons[W_PLAYER_WEAPON].reload[0] > rate2reload[game.maxPlasmaRate])))
if ((col->type != P_MINE) && (col->type != P_ORE)
&& ((col->type != P_SHIELD)
|| (player.shield < player.maxShield))
&& ((col->type != P_ROCKET)
|| (player.ammo[1] < game.maxRocketAmmo))
&& ((col->type != P_PLASMA_AMMO)
|| (player.ammo[0] < game.maxPlasmaAmmo))
&& ((col->type != P_PLASMA_SHOT)
|| (player.ammo[0] < game.maxPlasmaAmmo)
|| (weapons[W_PLAYER_WEAPON].ammo[0] < game.maxPlasmaOutput))
&& ((col->type != P_PLASMA_DAMAGE)
|| (player.ammo[0] < game.maxPlasmaAmmo)
|| (weapons[W_PLAYER_WEAPON].damage < game.maxPlasmaDamage))
&& ((col->type != P_PLASMA_RATE)
|| (player.ammo[0] < game.maxPlasmaAmmo)
|| (weapons[W_PLAYER_WEAPON].reload[0] > rate2reload[game.maxPlasmaRate]))
&& ((col->type != P_SUPER)
|| (player.ammo[0] < game.maxPlasmaAmmo)
|| (weapons[W_PLAYER_WEAPON].ammo[0] < game.maxPlasmaOutput)
|| (weapons[W_PLAYER_WEAPON].damage < game.maxPlasmaDamage)
|| (weapons[W_PLAYER_WEAPON].reload[0] > rate2reload[game.maxPlasmaRate])))
{
n++;
}

View File

@ -567,9 +567,9 @@ static void game_doCollectables()
if (collectable->life < 1)
{
collectable->active = 0;
if ((collectable->type == P_CARGO) ||
(collectable->type == P_ESCAPEPOD) ||
(collectable->type == P_SLAVES))
if ((collectable->type == P_CARGO)
|| (collectable->type == P_ESCAPEPOD)
|| (collectable->type == P_SLAVES))
mission_updateRequirements(M_PROTECT_PICKUP, collectable->type, 1);
}
@ -708,8 +708,8 @@ static void game_doBullets()
okayToHit = 1;
if ((bullet->flags & WF_WEAPCO) && (aliens[i].flags & FL_FRIEND))
okayToHit = 1;
if ((bullet->id == WT_ROCKET) || (bullet->id == WT_LASER) ||
(bullet->id == WT_CHARGER))
if ((bullet->id == WT_ROCKET) || (bullet->id == WT_LASER)
|| (bullet->id == WT_CHARGER))
okayToHit = 1;
if (bullet->owner == aliens[i].owner)
@ -815,8 +815,8 @@ static void game_doBullets()
}
// Check for bullets hitting player
if ((bullet->flags & WF_WEAPCO) || (bullet->id == WT_ROCKET) ||
(bullet->id == WT_LASER) || (bullet->id == WT_CHARGER))
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))
@ -1101,9 +1101,9 @@ static void game_doAliens()
if (aliens[i].x > aliens[i].target->x) aliens[i].face = 1;
}
if ((game.area == MISN_ELLESH) &&
((aliens[i].classDef == CD_BOSS) ||
(game.difficulty != DIFFICULTY_ORIGINAL)))
if ((game.area == MISN_ELLESH)
&& ((aliens[i].classDef == CD_BOSS)
|| (game.difficulty != DIFFICULTY_ORIGINAL)))
aliens[i].face = 0;
if ((aliens[i].flags & FL_DEPLOYDRONES) && ((rand() % 300) == 0))
@ -1194,8 +1194,8 @@ 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)))
((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))
@ -1387,8 +1387,8 @@ static void game_doPlayer()
if (player.weaponType[1] == W_CHARGER)
{
if (engine.keyState[KEY_ALTFIRE] &&
((game.difficulty == DIFFICULTY_ORIGINAL) ||
!(engine.keyState[KEY_FIRE])))
((game.difficulty == DIFFICULTY_ORIGINAL)
|| !(engine.keyState[KEY_FIRE])))
{
if (!player_chargerFired)
{
@ -1486,8 +1486,8 @@ static void game_doPlayer()
engine.keyState[KEY_PAUSE] = 0;
}
if ((game.area == MISN_ELLESH) ||
(game.area == MISN_MARS))
if ((game.area == MISN_ELLESH)
|| (game.area == MISN_MARS))
{
player.face = 0;
xmoved = 1;
@ -1658,8 +1658,8 @@ static void game_doPlayer()
LIMIT(engine.ssy, -CAMERA_MAX_SPEED, CAMERA_MAX_SPEED);
// Specific for the mission were you have to chase the Executive Transport
if (((game.area == MISN_ELLESH) && (player.shield > 0)) ||
(game.area == MISN_MARS))
if (((game.area == MISN_ELLESH) && (player.shield > 0))
|| (game.area == MISN_MARS))
{
engine.ssx = -6;
engine.ssy = 0;
@ -2473,9 +2473,9 @@ int game_mainLoop()
if (game.hasWingMate2)
alien_addFriendly(ALIEN_URSULA);
if ((game.area == MISN_URUSOR) ||
(game.area == MISN_POSWIC) ||
(game.area == MISN_EARTH))
if ((game.area == MISN_URUSOR)
|| (game.area == MISN_POSWIC)
|| (game.area == MISN_EARTH))
alien_addFriendly(ALIEN_SID);
// Disable Wingmates for certain missions
@ -2651,14 +2651,14 @@ int game_mainLoop()
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)))
((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))
{
@ -2683,8 +2683,8 @@ int game_mainLoop()
aliens[ALIEN_URSULA].face = 0;
}
if ((game.area == MISN_URUSOR) ||
(game.area == MISN_POSWIC))
if ((game.area == MISN_URUSOR)
|| (game.area == MISN_POSWIC))
{
aliens[ALIEN_SID].x = player.x - 100;
aliens[ALIEN_SID].y = player.y;

View File

@ -754,8 +754,8 @@ static void intermission_showStatus(SDL_Surface *infoSurface)
for (int i = TS_STATUS_HEADER + 1 ; i < TS_STATUS_FOOTER ; i++)
{
y += 20;
if ((i == TS_CHRIS_HEADER) || (i == TS_PHOEBE_HEADER) ||
(i == TS_URSULA_HEADER))
if ((i == TS_CHRIS_HEADER) || (i == TS_PHOEBE_HEADER)
|| (i == TS_URSULA_HEADER))
y += 25;
gfx_textSprites[i].y = y;
@ -1743,9 +1743,9 @@ int intermission()
screen_blit(gfx_sprites[SP_OPTIONS], x + 6 * w / 7, y);
screen_blit(gfx_sprites[SP_EXIT], x + w, y);
if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x, y, 32, 32) &&
((game.stationedPlanet != game.destinationPlanet) ||
(!intermission_planets[game.stationedPlanet].missionCompleted)))
if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x, y, 32, 32)
&& ((game.stationedPlanet != game.destinationPlanet)
|| (!intermission_planets[game.stationedPlanet].missionCompleted)))
{
if (game.stationedPlanet == game.destinationPlanet)
screen_blitText(TS_INFO_START_MISSION, -1, screen->h - 25);

View File

@ -814,9 +814,9 @@ void mission_updateRequirements(int type, int id, int value)
{
if ((mission.completed1[i] == OB_INCOMPLETE) || (mission.completed1[i] == OB_CONDITION))
{
if ((mission.primaryType[i] == type) &&
((mission.target1[i] == id) ||
(mission.target1[i] == CD_ANY)))
if ((mission.primaryType[i] == type)
&& ((mission.target1[i] == id)
|| (mission.target1[i] == CD_ANY)))
{
matched = 1;
mission.targetValue1[i] -= value;
@ -833,9 +833,9 @@ void mission_updateRequirements(int type, int id, int value)
{
if ((mission.completed2[i] == OB_INCOMPLETE) || (mission.completed2[i] == OB_CONDITION))
{
if ((mission.secondaryType[i] == type) &&
((mission.target2[i] == id) ||
(mission.target2[i] == CD_ANY)))
if ((mission.secondaryType[i] == type)
&& ((mission.target2[i] == id)
|| (mission.target2[i] == CD_ANY)))
{
mission.targetValue2[i] -= value;
mission_evaluate(type, id, &mission.completed2[i], &mission.targetValue2[i], FONT_YELLOW);
@ -983,10 +983,10 @@ int mission_checkCompleted()
mission.completed1[i] = OB_COMPLETED;
// do some area specific things
if ((game.area == MISN_MOEBO) ||
(game.area == MISN_DORIM) ||
(game.area == MISN_ELLESH) ||
(game.area == MISN_MARS))
if ((game.area == MISN_MOEBO)
|| (game.area == MISN_DORIM)
|| (game.area == MISN_ELLESH)
|| (game.area == MISN_MARS))
{
if (mission.remainingObjectives2 == 0)
{
@ -1222,17 +1222,17 @@ void mission_showStartScreen()
break;
}
if ((game.area == MISN_URUSOR) ||
(game.area == MISN_POSWIC) ||
(game.area == MISN_EARTH))
if ((game.area == MISN_URUSOR)
|| (game.area == MISN_POSWIC)
|| (game.area == MISN_EARTH))
screen_renderUnicode(_("Sid Wilson will join you on this mission"), screen->w / 2 - BRIEFING_WIDTH / 2 + 20, screen->h / 2 + 175, FONT_WHITE);
renderer_update();
game_delayFrame();
player_getInput();
if ((engine.keyState[KEY_FIRE]) || (engine.keyState[KEY_ALTFIRE]) ||
(engine.keyState[KEY_ESCAPE]))
if ((engine.keyState[KEY_FIRE]) || (engine.keyState[KEY_ALTFIRE])
|| (engine.keyState[KEY_ESCAPE]))
break;
}

View File

@ -100,13 +100,13 @@ void player_damage(int amount, int delay)
player_resetDamageDelay = 0;
if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0) &&
((!player.hit) ||
(game.difficulty == DIFFICULTY_ORIGINAL) ||
((player.shield != engine.lowShield) &&
(player.shield != 1))))
((!player.hit)
|| (game.difficulty == DIFFICULTY_ORIGINAL)
|| ((player.shield != engine.lowShield)
&& (player.shield != 1))))
{
if ((game.difficulty == DIFFICULTY_ORIGINAL) ||
(player_damageDelay >= delay))
if ((game.difficulty == DIFFICULTY_ORIGINAL)
|| (player_damageDelay >= delay))
{
player.shield -= amount;

View File

@ -160,42 +160,42 @@ int save_load(int slot)
{
case 4:
case 5:
if ((fscanf(fp, "%d%*c", &game.difficulty) < 1) ||
(fscanf(fp, "%d %d %d %d %d %d %d %d%*c",
if ((fscanf(fp, "%d%*c", &game.difficulty) < 1)
|| (fscanf(fp, "%d %d %d %d %d %d %d %d%*c",
&game.minPlasmaRateLimit, &game.minPlasmaDamageLimit,
&game.minPlasmaOutputLimit, &game.maxPlasmaRateLimit,
&game.maxPlasmaDamageLimit, &game.maxPlasmaOutputLimit,
&game.maxPlasmaAmmoLimit, &game.maxRocketAmmoLimit) < 8) ||
(fscanf(fp, "%d %d %d%*c%*[^\n]%*c", &game.system, &game.area,
&game.stationedPlanet) < 3) ||
(fscanf(fp, "%d %d%*c", &game.hasWingMate1, &game.hasWingMate2) < 2) ||
(fscanf(fp, "%d %d %d %d%*c", &player.maxShield,
&player.ammo[0], &player.ammo[1], &player.weaponType[1]) < 4) ||
(fscanf(fp, "%d %d %d%*c",
&game.maxPlasmaAmmoLimit, &game.maxRocketAmmoLimit) < 8)
|| (fscanf(fp, "%d %d %d%*c%*[^\n]%*c", &game.system, &game.area,
&game.stationedPlanet) < 3)
|| (fscanf(fp, "%d %d%*c", &game.hasWingMate1, &game.hasWingMate2) < 2)
|| (fscanf(fp, "%d %d %d %d%*c", &player.maxShield,
&player.ammo[0], &player.ammo[1], &player.weaponType[1]) < 4)
|| (fscanf(fp, "%d %d %d%*c",
&weapons[W_PLAYER_WEAPON].ammo[0],
&weapons[W_PLAYER_WEAPON].damage,
&weapons[W_PLAYER_WEAPON].reload[0]) < 3) ||
(fscanf(fp, "%d %d %d %d %d %d %d %d%*c",
&weapons[W_PLAYER_WEAPON].reload[0]) < 3)
|| (fscanf(fp, "%d %d %d %d %d %d %d %d%*c",
&game.minPlasmaRate, &game.minPlasmaDamage,
&game.minPlasmaOutput, &game.maxPlasmaRate,
&game.maxPlasmaDamage, &game.maxPlasmaOutput,
&game.maxPlasmaAmmo, &game.maxRocketAmmo) < 8) ||
(fscanf(fp, "%d %d %d %d %d %d %d %d %d %d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d%*c",
&game.maxPlasmaAmmo, &game.maxRocketAmmo) < 8)
|| (fscanf(fp, "%d %d %d %d %d %d %d %d %d %d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d%*c",
&game.missionCompleted[0], &game.missionCompleted[1],
&game.missionCompleted[2], &game.missionCompleted[3],
&game.missionCompleted[4], &game.missionCompleted[5],
&game.missionCompleted[6], &game.missionCompleted[7],
&game.missionCompleted[8], &game.missionCompleted[9]) < 10) ||
(fscanf(fp, "%d%*c", &game.experimentalShield) < 1) ||
(fscanf(fp, "%d %d%*c", &game.cash, &game.cashEarned) < 2) ||
(fscanf(fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d%*c",
&game.missionCompleted[8], &game.missionCompleted[9]) < 10)
|| (fscanf(fp, "%d%*c", &game.experimentalShield) < 1)
|| (fscanf(fp, "%d %d%*c", &game.cash, &game.cashEarned) < 2)
|| (fscanf(fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d%*c",
&game.shots, &game.hits, &game.accuracy, &game.totalKills,
&game.wingMate1Kills, &game.wingMate2Kills,
&game.wingMate1Ejects, &game.wingMate2Ejects,
&game.totalOtherKills, &game.shieldPickups,
&game.rocketPickups, &game.cellPickups, &game.powerups,
&game.minesKilled, &game.slavesRescued) < 15) ||
(fscanf(fp, "%lu%*c", &timeTaken) < 1))
&game.minesKilled, &game.slavesRescued) < 15)
|| (fscanf(fp, "%lu%*c", &timeTaken) < 1))
{
printf("Warning: Save data is not correctly formatted. Some data may be lost.\n");
}

View File

@ -645,8 +645,8 @@ static void buy(int i)
break;
case SHOP_ROCKET_AMMO:
if ((player.weaponType[1] == W_CHARGER) ||
(player.weaponType[1] == W_LASER))
if ((player.weaponType[1] == W_CHARGER)
|| (player.weaponType[1] == W_LASER))
{
shopSelectedItem = SHOP_ERROR_IS_NOT_ROCKETS;
return;
@ -723,8 +723,8 @@ static void buy(int i)
break;
case SHOP_ROCKET_MAX_AMMO:
if ((player.weaponType[1] == W_CHARGER) ||
(player.weaponType[1] == W_LASER))
if ((player.weaponType[1] == W_CHARGER)
|| (player.weaponType[1] == W_LASER))
{
shopSelectedItem = SHOP_ERROR_IS_NOT_ROCKETS;
return;

View File

@ -695,8 +695,8 @@ void title_showCredits()
screen_unBuffer();
player_getInput();
if (engine.keyState[KEY_ESCAPE] || engine.keyState[KEY_FIRE] ||
engine.keyState[KEY_ALTFIRE])
if (engine.keyState[KEY_ESCAPE] || engine.keyState[KEY_FIRE]
|| engine.keyState[KEY_ALTFIRE])
break;
float speed = 0.5;