diff --git a/src/aliens.cpp b/src/aliens.cpp index 15d569f..588d5f4 100644 --- a/src/aliens.cpp +++ b/src/aliens.cpp @@ -224,7 +224,8 @@ bool addAlien() signed char randEnemy = alienArray[rand() % numberOfAliens]; - if ((currentGame.area != 10) && (currentGame.area != 15) && (currentGame.area != 24)) + if ((currentGame.area != 10) && (currentGame.area != 15) && + (currentGame.area != 24)) { if ((currentGame.system == 1) && (currentGame.area == MAX_MISSIONS - 1)) { @@ -1088,12 +1089,14 @@ void doAliens() limitCharAdd(&theEnemy->reload[0], -1, 0, 999); limitCharAdd(&theEnemy->reload[1], -1, 0, 999); - if ((!(theEnemy->flags & FL_DISABLED)) && (!(theEnemy->flags & FL_NOFIRE))) + if ((!(theEnemy->flags & FL_DISABLED)) && + (!(theEnemy->flags & FL_NOFIRE))) { if ((theEnemy->target->shield > 0)) canFire = traceTarget(theEnemy); - if (((theEnemy->thinktime % 2) == 0) && (theEnemy->flags & FL_FRIEND)) + if (((theEnemy->thinktime % 2) == 0) && + (theEnemy->flags & FL_FRIEND)) canFire = traceView(theEnemy); } else @@ -1103,13 +1106,18 @@ void doAliens() if ((canFire) && (dev.fireAliens)) { - if ((theEnemy->reload[0] == 0) && ((rand() % 1000 < theEnemy->chance[0]) || (theEnemy->flags & FL_CONTINUOUS_FIRE))) + if ((theEnemy->reload[0] == 0) && + ((rand() % 1000 < theEnemy->chance[0]) || + (theEnemy->flags & FL_CONTINUOUS_FIRE))) { fireBullet(theEnemy, 0); } - if ((theEnemy->reload[1] == 0) && ((rand() % 1000 < theEnemy->chance[1]) || (theEnemy->flags & FL_CONTINUOUS_FIRE))) + if ((theEnemy->reload[1] == 0) && + ((rand() % 1000 < theEnemy->chance[1]) || + (theEnemy->flags & FL_CONTINUOUS_FIRE))) { - if ((theEnemy->weaponType[1] != W_ENERGYRAY) && (theEnemy->weaponType[1] != W_LASER)) + if ((theEnemy->weaponType[1] != W_ENERGYRAY) && + (theEnemy->weaponType[1] != W_LASER)) { if (theEnemy->weaponType[1] == W_CHARGER) theEnemy->ammo[1] = 50 + rand() % 150; @@ -1119,7 +1127,8 @@ void doAliens() { theEnemy->flags += FL_FIRELASER; } - else if ((theEnemy->weaponType[1] == W_ENERGYRAY) && (theEnemy->ammo[0] == 250)) + else if ((theEnemy->weaponType[1] == W_ENERGYRAY) && + (theEnemy->ammo[0] == 250)) { theEnemy->flags += FL_FIRERAY; playSound(SFX_ENERGYRAY, theEnemy->x); @@ -1151,12 +1160,14 @@ void doAliens() if (theEnemy->flags & FL_DROPMINES) if ((rand() % 150) == 0) - addCollectable(theEnemy->x, theEnemy->y, P_MINE, 25, 600 + rand() % 2400); + addCollectable(theEnemy->x, theEnemy->y, P_MINE, 25, + 600 + rand() % 2400); // Kline drops mines a lot more often if ((theEnemy->flags & FL_DROPMINES) && (theEnemy == &enemy[WC_KLINE])) if ((rand() % 10) == 0) - addCollectable(theEnemy->x, theEnemy->y, P_MINE, 25, 600 + rand() % 2400); + addCollectable(theEnemy->x, theEnemy->y, P_MINE, 25, + 600 + rand() % 2400); // ------------------------------------------------------- @@ -1194,8 +1205,13 @@ void doAliens() if (theEnemy->shield < theEnemy->deathCounter) { theEnemy->active = false; - if ((theEnemy->classDef == CD_BOSS) || (theEnemy->owner == &enemy[WC_BOSS]) || (theEnemy->flags & FL_FRIEND) || (theEnemy->classDef == CD_ASTEROID) || (theEnemy->classDef == CD_KLINE)) - addDebris((int)theEnemy->x, (int)theEnemy->y, theEnemy->maxShield); + if ((theEnemy->classDef == CD_BOSS) || + (theEnemy->owner == &enemy[WC_BOSS]) || + (theEnemy->flags & FL_FRIEND) || + (theEnemy->classDef == CD_ASTEROID) || + (theEnemy->classDef == CD_KLINE)) + addDebris((int)theEnemy->x, (int)theEnemy->y, + theEnemy->maxShield); if (theEnemy->classDef == CD_ASTEROID) { @@ -1207,10 +1223,9 @@ void doAliens() } // Adjust the movement even whilst exploding - if ((dev.moveAliens) && (!(theEnemy->flags & FL_NOMOVE)) && (!(theEnemy->flags & FL_DISABLED))) - { + if ((dev.moveAliens) && (!(theEnemy->flags & FL_NOMOVE)) && + (!(theEnemy->flags & FL_DISABLED))) moveAndSeparate(theEnemy); - } if ((currentGame.area != 18) || (theEnemy->shield < 0)) theEnemy->x += engine.ssx + engine.smx; diff --git a/src/bullets.cpp b/src/bullets.cpp index 60380a9..bfb2dfd 100644 --- a/src/bullets.cpp +++ b/src/bullets.cpp @@ -215,9 +215,9 @@ void fireBullet(object *attacker, int weaponType) player.ammo[0]--; if (player.ammo[0] == 0) { - weapon[0].ammo[0] = currentGame.minPlasmaOutput; - weapon[0].damage = currentGame.minPlasmaDamage; - weapon[0].reload[0] = rate2reload[currentGame.minPlasmaRate]; + weapon[W_PLAYER_WEAPON].ammo[0] = currentGame.minPlasmaOutput; + weapon[W_PLAYER_WEAPON].damage = currentGame.minPlasmaDamage; + weapon[W_PLAYER_WEAPON].reload[0] = rate2reload[currentGame.minPlasmaRate]; } } } diff --git a/src/collectable.cpp b/src/collectable.cpp index 712ea07..38e7ca7 100644 --- a/src/collectable.cpp +++ b/src/collectable.cpp @@ -301,11 +301,11 @@ void doCollectables() case P_PLASMA_RATE: if (player.ammo[0] < 50) player.ammo[0] = 50; - if (weapon[0].reload[0] <= rate2reload[currentGame.maxPlasmaRate]) + if (weapon[W_PLAYER_WEAPON].reload[0] <= rate2reload[currentGame.maxPlasmaRate]) sprintf(temp, "Firing Rate already at Maximum"); else { - weapon[0].reload[0] -= 2; + weapon[W_PLAYER_WEAPON].reload[0] -= 2; sprintf(temp, "Firing rate increased"); } currentGame.powerups++; @@ -314,11 +314,11 @@ void doCollectables() case P_PLASMA_SHOT: if (player.ammo[0] < 50) player.ammo[0] = 50; - if (weapon[0].ammo[0] >= currentGame.maxPlasmaOutput) + if (weapon[W_PLAYER_WEAPON].ammo[0] >= currentGame.maxPlasmaOutput) sprintf(temp, "Plasma output already at Maximum"); else { - weapon[0].ammo[0]++; + weapon[W_PLAYER_WEAPON].ammo[0]++; sprintf(temp, "Plasma output increased"); } currentGame.powerups++; @@ -327,20 +327,20 @@ void doCollectables() case P_PLASMA_DAMAGE: if (player.ammo[0] < 50) player.ammo[0] = 50; - if (weapon[0].damage >= currentGame.maxPlasmaDamage) + if (weapon[W_PLAYER_WEAPON].damage >= currentGame.maxPlasmaDamage) sprintf(temp, "Plasma damage already at Maximum"); else { - weapon[0].damage++; + weapon[W_PLAYER_WEAPON].damage++; sprintf(temp, "Plasma damage increased"); } currentGame.powerups++; break; case P_SUPER: - weapon[0].ammo[0] = 5; - weapon[0].damage = 5; - weapon[0].reload[0] = rate2reload[5]; - weapon[0].flags |= WF_SPREAD; + weapon[W_PLAYER_WEAPON].ammo[0] = 5; + weapon[W_PLAYER_WEAPON].damage = 5; + weapon[W_PLAYER_WEAPON].reload[0] = rate2reload[5]; + weapon[W_PLAYER_WEAPON].flags |= WF_SPREAD; sprintf(temp, "Picked up a Super Charge!!"); @@ -404,9 +404,9 @@ void doCollectables() // stop people from exploiting a weapon check condition if (player.ammo[0] == 0) { - weapon[0].ammo[0] = currentGame.minPlasmaOutput; - weapon[0].damage = currentGame.minPlasmaDamage; - weapon[0].reload[0] = rate2reload[currentGame.minPlasmaRate]; + weapon[W_PLAYER_WEAPON].ammo[0] = currentGame.minPlasmaOutput; + weapon[W_PLAYER_WEAPON].damage = currentGame.minPlasmaDamage; + weapon[W_PLAYER_WEAPON].reload[0] = rate2reload[currentGame.minPlasmaRate]; } } diff --git a/src/explosions.cpp b/src/explosions.cpp index 9a795d0..8686816 100644 --- a/src/explosions.cpp +++ b/src/explosions.cpp @@ -109,7 +109,7 @@ void doExplosions() { prevExplosion->next = explosion->next; delete explosion; - explosion = prevExplosion; + explosion = prevExplosion; } } } diff --git a/src/init.cpp b/src/init.cpp index b63dfca..833f6a9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -159,7 +159,8 @@ void initSystem() #endif /* Initialize the SDL library */ - if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK) < 0) { + if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK) < 0) + { printf("Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } @@ -184,14 +185,16 @@ void initSystem() screen = SDL_CreateRGBSurface(0, screenWidth, screenHeight, 32, 0xff0000, 0xff00, 0xff, 0xff000000); - if (!screen) { + if (!screen) + { printf("Couldn't create %ix%ix32 surface: %s\n", screenWidth, screenHeight, SDL_GetError()); exit(1); } window = SDL_CreateWindow("Project: Starfighter", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen->w, screen->h, 0); - if (window == NULL) { + if (window == NULL) + { printf("Could not create window: %s\n", SDL_GetError()); exit(1); } @@ -201,7 +204,8 @@ void initSystem() renderer = SDL_CreateRenderer(window, -1, 0); - if (!renderer) { + if (!renderer) + { printf("Could not create renderer: %s\n", SDL_GetError()); exit(1); } @@ -210,7 +214,8 @@ void initSystem() texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen->w, screen->h); - if (!texture) { + if (!texture) + { printf("Couldn't create %ix%ix32 texture: %s\n", screen->w, screen->h, SDL_GetError()); exit(1); } @@ -228,8 +233,8 @@ void initSystem() SDL_ShowCursor(SDL_DISABLE); SDL_EventState(SDL_MOUSEMOTION, SDL_DISABLE); - SDL_JoystickEventState(SDL_ENABLE); - SDL_JoystickOpen(0); + SDL_JoystickEventState(SDL_ENABLE); + SDL_JoystickOpen(0); } /* diff --git a/src/intermission.cpp b/src/intermission.cpp index b347fe6..e7c1a63 100644 --- a/src/intermission.cpp +++ b/src/intermission.cpp @@ -481,10 +481,12 @@ int galaxyMap() // Remove the Supercharge, if it is there if (currentGame.difficulty > DIFFICULTY_EASY) { - weapon[0].reload[0] = max(weapon[0].reload[0], + weapon[W_PLAYER_WEAPON].reload[0] = max(weapon[W_PLAYER_WEAPON].reload[0], rate2reload[currentGame.maxPlasmaRate]); - weapon[0].ammo[0] = min(weapon[0].ammo[0], currentGame.maxPlasmaOutput); - weapon[0].damage = min(weapon[0].damage, currentGame.maxPlasmaDamage); + weapon[W_PLAYER_WEAPON].ammo[0] = min(weapon[W_PLAYER_WEAPON].ammo[0], + currentGame.maxPlasmaOutput); + weapon[W_PLAYER_WEAPON].damage = min(weapon[W_PLAYER_WEAPON].damage, + currentGame.maxPlasmaDamage); } clearScreen(black); diff --git a/src/loadSave.cpp b/src/loadSave.cpp index 89aba72..2818daa 100644 --- a/src/loadSave.cpp +++ b/src/loadSave.cpp @@ -101,7 +101,7 @@ bool loadGame(int slot) if (currentGame.saveFormat < 2) currentGame.difficulty = DIFFICULTY_NORMAL; - weapon[0] = currentGame.playerWeapon; + weapon[W_PLAYER_WEAPON] = currentGame.playerWeapon; player = currentGame.thePlayer; // Re-init all the planets in this system... @@ -128,7 +128,7 @@ void saveGame(int slot) fp = fopen(fileName, "wb"); currentGame.saveFormat = 2; - currentGame.playerWeapon = weapon[0]; + currentGame.playerWeapon = weapon[W_PLAYER_WEAPON]; currentGame.thePlayer = player; for (int i = 0 ; i < 10 ; i++) currentGame.missionCompleted[i] = systemPlanet[i].missionCompleted; diff --git a/src/misc.cpp b/src/misc.cpp index 7824775..a624162 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -331,7 +331,7 @@ void doInfo() for (int i = 1 ; i <= 5 ; i++) { - if (weapon[0].damage >= i) { + if (weapon[W_PLAYER_WEAPON].damage >= i) { if(i <= currentGame.maxPlasmaDamage || (SDL_GetTicks() % 1000 > (unsigned)i * 100)) { SDL_FillRect(screen, &bar, green); @@ -351,7 +351,7 @@ void doInfo() for (int i = 1 ; i <= 5 ; i++) { - if (weapon[0].ammo[0] >= i) { + if (weapon[W_PLAYER_WEAPON].ammo[0] >= i) { if(i <= currentGame.maxPlasmaOutput || (SDL_GetTicks() % 1000 > (unsigned)i * 100)) { SDL_FillRect(screen, &bar, yellow); @@ -371,7 +371,7 @@ void doInfo() for (int i = 1 ; i <= 5 ; i++) { - if (weapon[0].reload[0] <= rate2reload[i]) { + if (weapon[W_PLAYER_WEAPON].reload[0] <= rate2reload[i]) { if(i <= currentGame.maxPlasmaRate || (SDL_GetTicks() % 1000 > (unsigned)i * 100)) { SDL_FillRect(screen, &bar, blue); diff --git a/src/missions.cpp b/src/missions.cpp index c493174..c882e33 100644 --- a/src/missions.cpp +++ b/src/missions.cpp @@ -552,7 +552,7 @@ bool allMissionsCompleted() setInfoLine("*** Interception Destroyed ***", FONT_GREEN); currentMission.completed1[i] = OB_COMPLETED; - // do some area specific things + // do some area specific things if ((currentGame.area == 5) || (currentGame.area == 10) || (currentGame.area == 18) || (currentGame.area == 24)) { if (currentMission.remainingObjectives2 == 0) diff --git a/src/player.cpp b/src/player.cpp index 53180ab..4de3fc1 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -42,12 +42,12 @@ void initPlayer() player.weaponType[0] = W_PLAYER_WEAPON; - if(weapon[0].ammo[0] < currentGame.minPlasmaOutput) - weapon[0].ammo[0] = currentGame.minPlasmaOutput; - if(weapon[0].damage < currentGame.minPlasmaDamage) - weapon[0].damage = currentGame.minPlasmaDamage; - if(weapon[0].reload[0] > rate2reload[currentGame.minPlasmaRate]) - weapon[0].reload[0] = rate2reload[currentGame.minPlasmaRate]; + if(weapon[W_PLAYER_WEAPON].ammo[0] < currentGame.minPlasmaOutput) + weapon[W_PLAYER_WEAPON].ammo[0] = currentGame.minPlasmaOutput; + if(weapon[W_PLAYER_WEAPON].damage < currentGame.minPlasmaDamage) + weapon[W_PLAYER_WEAPON].damage = currentGame.minPlasmaDamage; + if(weapon[W_PLAYER_WEAPON].reload[0] > rate2reload[currentGame.minPlasmaRate]) + weapon[W_PLAYER_WEAPON].reload[0] = rate2reload[currentGame.minPlasmaRate]; player.hit = 0; @@ -130,11 +130,12 @@ void doPlayer() if ((engine.keyState[KEY_SWITCH])) { - if(weapon[0].ammo[0] >= 3 && weapon[0].ammo[0] <= currentGame.maxPlasmaOutput) + if ((weapon[W_PLAYER_WEAPON].ammo[0] >= 3) && + (weapon[W_PLAYER_WEAPON].ammo[0] <= currentGame.maxPlasmaOutput)) { - weapon[0].flags ^= WF_SPREAD; + weapon[W_PLAYER_WEAPON].flags ^= WF_SPREAD; - if(weapon[0].flags & WF_SPREAD) + if (weapon[W_PLAYER_WEAPON].flags & WF_SPREAD) { setInfoLine("Weapon set to Spread", FONT_WHITE); }