Turn signed chars into bools where appropriate.

This commit is contained in:
Guus Sliepen 2011-08-26 16:14:58 +02:00
parent c710b8df7c
commit 277d34dabd
16 changed files with 101 additions and 105 deletions

View File

@ -27,7 +27,7 @@ int main(int argc, char *argv[])
{
defineGlobals(); // Must do this first!
signed char cheatAttempt = 0;
bool cheatAttempt = false;
if (argc > 1)
{
@ -54,11 +54,11 @@ int main(int argc, char *argv[])
{printf("Enemy firing disabled\n"); dev.fireAliens = 0;}
#endif
if (strcmp(argv[i], "-cheat") == 0)
cheatAttempt = 1;
cheatAttempt = true;
if (strcmp(argv[i], "-noaudio") == 0)
{printf("No Audio\n"); engine.useAudio = 0;}
{printf("No Audio\n"); engine.useAudio = false;}
if (strcmp(argv[i], "-mono") == 0)
{printf("Mono sound output\n"); engine.useAudio = 1;}
{printf("Mono sound output\n"); engine.useAudio = true;}
}
atexit(cleanUp);

View File

@ -76,7 +76,7 @@ void addDrone(object *host)
return;
enemy[index] = defEnemy[CD_DRONE];
enemy[index].active = 1;
enemy[index].active = true;
enemy[index].face = rand() % 2;
enemy[index].owner = &enemy[index]; // Most enemies will own themselves
enemy[index].target = &enemy[index];
@ -101,7 +101,7 @@ void addSmallAsteroid(object *host)
addBullet(&weapon[W_ROCKETS], host, 0, 0);
for (int i = 10 ; i < 20 ; i++)
if (enemy[i].active == 0)
if (!enemy[i].active)
index = i;
if (index == -1)
@ -128,7 +128,7 @@ void addSmallAsteroid(object *host)
enemy[index].x = host->x;
enemy[index].y = host->y;
enemy[index].active = 1;
enemy[index].active = true;
}
signed char addAlien()
@ -239,7 +239,7 @@ signed char addAlien()
delete[] alienArray;
enemy[index] = defEnemy[randEnemy];
enemy[index].active = 1;
enemy[index].active = true;
enemy[index].face = rand() % 2;
enemy[index].owner = &enemy[index]; // Most enemies will own themselves
enemy[index].target = &enemy[index];
@ -255,7 +255,7 @@ signed char addAlien()
{
if (placeAlien(&enemy[index]))
break;
enemy[index].active = 0;
enemy[index].active = false;
return 0;
}
@ -314,7 +314,7 @@ void getPreDefinedAliens()
enemy[index].owner = &enemy[index];
enemy[index].target = &enemy[index];
enemy[index].face = rand() % 2;
enemy[index].active = 1;
enemy[index].active = true;
/*
we make 1000 attempts to place this enemy since it is required. If after 1000 attempts
@ -346,7 +346,7 @@ void getPreDefinedAliens()
if (enemy[index].classDef == CD_CLOAKFIGHTER)
{
enemy[index].active = 0;
enemy[index].active = false;
enemy[index].maxShield = enemy[index].shield = 400;
enemy[index].flags -= FL_RUNSAWAY;
enemy[index].speed = 3;
@ -354,12 +354,12 @@ void getPreDefinedAliens()
if ((enemy[index].classDef == CD_MOBILE_RAY) && (index >= 11))
{
enemy[index].active = 0;
enemy[index].active = false;
}
if (enemy[index].classDef == CD_FIREFLY)
{
enemy[index].active = 0;
enemy[index].active = false;
}
if (enemy[index].classDef == CD_BARRIER)
@ -469,7 +469,7 @@ void addFriendly(int type)
enemy[type].owner = &enemy[type];
enemy[type].target = &enemy[type];
enemy[type].active = 1;
enemy[type].active = true;
if (rand() % 2 == 0)
enemy[type].x = Math::rrand(400, 550);
@ -507,7 +507,7 @@ void initAliens()
{
for (int i = 0 ; i < MAX_ALIENS ; i++)
{
enemy[i].active = 0;
enemy[i].active = false;
enemy[i].shield = -1;
enemy[i].flags = 0;
}
@ -521,7 +521,7 @@ void initAliens()
currentGame.hasWingMate1 = 1;
if (currentGame.area == 11)
enemy[WC_KLINE].active = 0;
enemy[WC_KLINE].active = false;
for (int i = 0 ; i < engine.maxAliens ; i++)
addAlien();
@ -546,8 +546,8 @@ void initAliens()
case 18:
case 24:
case 26:
enemy[FR_PHOEBE].active = 0;
enemy[FR_URSULA].active = 0;
enemy[FR_PHOEBE].active = false;
enemy[FR_URSULA].active = false;
break;
}
@ -566,7 +566,7 @@ void initAliens()
enemy[WC_KLINE].owner = &enemy[WC_KLINE];
enemy[WC_KLINE].target = &player;
enemy[WC_KLINE].shield = 100;
enemy[WC_KLINE].active = 1;
enemy[WC_KLINE].active = true;
enemy[WC_KLINE].x = player.x + 1000;
enemy[WC_KLINE].y = player.y;
setTarget(WC_KLINE);
@ -580,7 +580,7 @@ void initAliens()
enemy[10].owner = &enemy[10];
enemy[10].target = &enemy[10];
enemy[10].shield = 1000;
enemy[10].active = 1;
enemy[10].active = true;
enemy[10].x = player.x - 1000;
enemy[10].y = player.y;
setTarget(10);
@ -1056,7 +1056,7 @@ void doAliens()
{
theEnemy->flags -= FL_LEAVESECTOR;
theEnemy->flags += FL_ESCAPED;
theEnemy->active = 0;
theEnemy->active = false;
if (theEnemy->classDef == CD_CLOAKFIGHTER)
{
@ -1201,7 +1201,7 @@ void doAliens()
}
if ((currentGame.area == 24) && (theEnemy->x < -300))
theEnemy->active = 0;
theEnemy->active = false;
}
else
{
@ -1213,7 +1213,7 @@ void doAliens()
}
if (theEnemy->shield < theEnemy->deathCounter)
{
theEnemy->active = 0;
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);

View File

@ -32,7 +32,7 @@ void addBullet(object *theWeapon, object *attacker, int y, int dy)
currentGame.shots++;
bullet->next = NULL;
bullet->active = 1;
bullet->active = true;
bullet->x = attacker->x - ((attacker->image[0]->w / 2) * attacker->face);
bullet->y = attacker->y + y;
bullet->flags = theWeapon->flags;
@ -517,7 +517,7 @@ void doBullets()
{
bullet = bullet->next;
if (bullet->active == 1)
if (bullet->active)
{
if (bullet->flags & WF_HOMING)
{
@ -602,7 +602,7 @@ void doBullets()
if (okayToHit)
{
if ((bullet->active == 1) && (Collision::collision(bullet, theEnemy)))
if ((bullet->active) && (Collision::collision(bullet, theEnemy)))
{
if (bullet->owner == &player)
{
@ -654,14 +654,14 @@ void doBullets()
if (bullet->id != WT_CHARGER)
{
bullet->active = 0;
bullet->active = false;
bullet->shield = 0;
}
else if (bullet->id == WT_CHARGER)
{
bullet->shield -= theEnemy->shield;
if (bullet->shield < 0)
bullet->active = 0;
bullet->active = false;
}
playSound(SFX_HIT);
@ -695,7 +695,7 @@ void 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->active == 1) && (player.shield > 0) && (Collision::collision(bullet, &player)) && (bullet->owner != &player))
if ((bullet->active) && (player.shield > 0) && (Collision::collision(bullet, &player)) && (bullet->owner != &player))
{
if ((!engine.cheatShield) || (engine.missionCompleteTimer != 0))
{
@ -716,14 +716,14 @@ void doBullets()
if (bullet->id != WT_CHARGER)
{
bullet->active = 0;
bullet->active = false;
bullet->shield = 0;
}
else if (bullet->id == WT_CHARGER)
{
bullet->shield -= theEnemy->shield;
if (bullet->shield < 0)
bullet->active = 0;
bullet->active = false;
}
playSound(SFX_HIT);
@ -745,12 +745,12 @@ void doBullets()
{
if (Collision::collision(bullet, theCargo))
{
bullet->active = 0;
bullet->active = false;
addExplosion(bullet->x, bullet->y, E_SMALL_EXPLOSION);
playSound(SFX_HIT);
if (theCargo->collectType != P_PHOEBE)
{
theCargo->active = 0;
theCargo->active = false;
playSound(SFX_EXPLOSION);
for (int i = 0 ; i < 10 ; i++)
addExplosion(theCargo->x + Math::rrand(-15, 15), theCargo->y + Math::rrand(-15, 15), E_BIG_EXPLOSION);
@ -778,10 +778,10 @@ void doBullets()
if (checkPlayerShockDamage(bullet->x, bullet->y))
setInfoLine("Warning: Missile Shockwave Damage!!", FONT_RED);
}
bullet->active = 0;
bullet->active = false;
}
if (bullet->active == 1)
if (bullet->active)
{
prevBullet = bullet;
engine.bulletTail = bullet;

View File

@ -24,7 +24,7 @@ void initCargo()
{
for (int i = 0 ; i < MAX_CARGO ; i++)
{
cargo[i].active = 0;
cargo[i].active = false;
cargo[i].owner = NULL;
}
}
@ -36,7 +36,7 @@ int getCargo()
{
for (int i = 0 ; i < MAX_CARGO ; i++)
{
if (cargo[i].active == 0)
if (!cargo[i].active)
return i;
}
@ -50,7 +50,7 @@ object *addCargo(object *owner, int cargoType)
if (index == -1)
return NULL;
cargo[index].active = 1;
cargo[index].active = false;
cargo[index].owner = owner;
cargo[index].x = owner->x;
cargo[index].y = owner->y;
@ -72,13 +72,13 @@ void becomeCollectable(int i)
}
else
{
enemy[FR_PHOEBE].active = 1;
enemy[FR_PHOEBE].active = true;
enemy[FR_PHOEBE].x = cargo[i].x;
enemy[FR_PHOEBE].y = cargo[i].y;
setRadioMessage(FACE_PHOEBE, "Thanks!! Watch out, WEAPCO! Phoebe's loose and she's ANGRY!!!", 1);
}
cargo[i].active = 0;
cargo[i].active = false;
}
void doCargo()

View File

@ -89,7 +89,7 @@ void addCollectable(float x, float y, int type, int value, int life)
collectables *collectable = new collectables;
collectable->next = NULL;
collectable->active = 1;
collectable->active = true;
collectable->x = x;
collectable->y = y;
@ -187,17 +187,17 @@ void checkMineBulletCollisions(object *bullet)
{
if (Collision::collision(collectable, bullet))
{
collectable->active = 0;
collectable->active = false;
if (bullet->id != WT_CHARGER)
{
bullet->active = 0;
bullet->active = false;
}
else
{
bullet->shield--;
if (bullet->shield < 0)
bullet->active = 0;
bullet->active = false;
}
if (bullet->owner == &player)
@ -208,7 +208,7 @@ void checkMineBulletCollisions(object *bullet)
}
}
if (collectable->active == 1)
if (collectable->active)
{
prevCollectable = collectable;
engine.collectableTail = collectable;
@ -240,7 +240,7 @@ void doCollectables()
{
collectable = collectable->next;
if (collectable->active == 1)
if (collectable->active)
{
if ((collectable->x + collectable->image->w > 0) && (collectable->x < 800) && (collectable->y + collectable->image->h > 0) && (collectable->y < 600))
graphics.blit(collectable->image, (int)collectable->x, (int)collectable->y);
@ -386,7 +386,7 @@ void doCollectables()
updateMissionRequirements(M_COLLECT, collectable->type, collectable->value);
collectable->active = 0;
collectable->active = false;
if (collectable->type != P_MINE)
{
setInfoLine(temp, FONT_WHITE);
@ -407,12 +407,12 @@ void doCollectables()
if (collectable->life < 1)
{
collectable->active = 0;
collectable->active = false;
if ((collectable->type == P_CARGO) || (collectable->type == P_ESCAPEPOD) || (collectable->type == P_SLAVES))
updateMissionRequirements(M_PROTECT_PICKUP, collectable->type, 1);
}
if (collectable->active == 1)
if (collectable->active)
{
prevCollectable = collectable;
engine.collectableTail = collectable;

View File

@ -31,7 +31,7 @@ signed char checkPauseRequest()
if (engine.keyState[SDLK_ESCAPE])
{
engine.paused = 0;
engine.paused = false;
engine.done = 1;
player.shield = 0;
return 1;
@ -39,7 +39,7 @@ signed char checkPauseRequest()
if (engine.keyState[SDLK_p])
{
engine.paused = 0;
engine.paused = false;
engine.keyState[SDLK_p] = 0;
}
@ -49,10 +49,10 @@ signed char checkPauseRequest()
void compareLastKeyInputs()
{
if (strstr(lastKeyEvents, "humansdoitbetter") != NULL)
{engine.cheat = 1; memset(lastKeyEvents, ' ', 25);}
{engine.cheat = true; memset(lastKeyEvents, ' ', 25);}
if (strstr(lastKeyEvents, "credits") != NULL)
{engine.cheatCredits = 1; memset(lastKeyEvents, ' ', 25);}
{engine.cheatCredits = true; memset(lastKeyEvents, ' ', 25);}
}
void addKeyEvent(const char *keyName)

View File

@ -31,7 +31,7 @@ void addExplosion(float x, float y, int type)
object *explosion = new object;
explosion->next = NULL;
explosion->active = 1;
explosion->active = true;
explosion->x = x;
explosion->y = y;
explosion->thinktime = 28;
@ -74,7 +74,7 @@ void doExplosions()
{
explosion = explosion->next;
if (explosion->active == 1)
if (explosion->active)
{
explosion->x += engine.ssx;
explosion->y += engine.ssy;
@ -88,7 +88,7 @@ void doExplosions()
if(explosion->thinktime < 1)
{
explosion->active = 0;
explosion->active = false;
}
else
{
@ -98,7 +98,7 @@ void doExplosions()
}
}
if (explosion->active == 1)
if (explosion->active)
{
prevExplosion = explosion;
engine.explosionTail = explosion;

View File

@ -29,8 +29,8 @@ void newGame()
if (!engine.useAudio)
{
currentGame.useSound = 0;
currentGame.useMusic = 0;
currentGame.useSound = false;
currentGame.useMusic = false;
}
currentGame.autoSaveSlot = -1;

View File

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void defineGlobals()
{
engine.musicVolume = 100;
engine.useAudio = 2;
engine.useAudio = true;
engine.maxAliens = 9;
@ -58,16 +58,16 @@ void defineGlobals()
engine.counter = 0;
engine.seconds = 0;
engine.minutes = 0;
engine.paused = 0;
engine.paused = false;
engine.gameSection = SECTION_TITLE;
engine.targetArrow = -1;
engine.targetArrowTimer = 0;
engine.cheat = 0;
engine.cheatShield = 0;
engine.cheatAmmo = 0;
engine.cheatCash = 0;
engine.cheat = false;
engine.cheatShield = false;
engine.cheatAmmo = false;
engine.cheatCash = false;
// All Development Stuff...
dev.moveAliens = 1;

View File

@ -159,10 +159,6 @@ void initSystem()
exit(1);
}
currentGame.useSound = 1;
currentGame.useMusic = 1;
currentGame.fullScreen = 0;
char filename[PATH_MAX];
int fullScreen = 0, useSound = 1, useMusic = 1;
@ -199,7 +195,7 @@ void initSystem()
{
printf("Warning: Couldn't set 22050 Hz 16-bit audio - Reason: %s\n", Mix_GetError());
printf("Sound and Music will be disabled\n");
engine.useAudio = 0;
engine.useAudio = false;
}
}

View File

@ -396,15 +396,15 @@ void showOptions(SDL_Surface *optionsSurface)
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]))
{
if (Collision::collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 172, 45, 22))
currentGame.useSound = 1;
currentGame.useSound = true;
if (Collision::collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 478, 172, 45, 22))
currentGame.useSound = 0;
currentGame.useSound = false;
if (Collision::collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 222, 45, 22))
{
currentGame.useMusic = 1;
currentGame.useMusic = true;
if (engine.useAudio)
{
if (Mix_PausedMusic() == 1)
@ -416,7 +416,7 @@ void showOptions(SDL_Surface *optionsSurface)
if (Collision::collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 478, 222, 45, 22))
{
currentGame.useMusic = 0;
currentGame.useMusic = false;
if (engine.useAudio)
Mix_PauseMusic();
}
@ -432,7 +432,7 @@ void showOptions(SDL_Surface *optionsSurface)
graphics.drawBackground();
flushBuffer();
#endif
currentGame.fullScreen = 1;
currentGame.fullScreen = true;
}
}
@ -447,7 +447,7 @@ void showOptions(SDL_Surface *optionsSurface)
graphics.drawBackground();
flushBuffer();
#endif
currentGame.fullScreen = 0;
currentGame.fullScreen = false;
}
}

View File

@ -497,7 +497,7 @@ char revealHiddenObjectives()
{
killAllAliens();
syncScriptEvents();
enemy[WC_KLINE].active = 1;
enemy[WC_KLINE].active = true;
enemy[WC_KLINE].x = player.x + 1000;
enemy[WC_KLINE].y = player.y;
enemy[WC_KLINE].flags += FL_IMMORTAL + FL_NOFIRE;

View File

@ -25,7 +25,7 @@ Initialises the player for a new game.
*/
void initPlayer()
{
player.active = 1;
player.active = true;
player.x = 200;
player.y = 200;
player.speed = 2;
@ -234,7 +234,7 @@ void doPlayer()
if (engine.keyState[SDLK_p])
{
engine.paused = 1;
engine.paused = true;
engine.keyState[SDLK_p] = 0;
}
@ -286,7 +286,7 @@ void doPlayer()
}
else
{
player.active = 0;
player.active = false;
player.shield--;
if (player.shield == -1)
{
@ -374,7 +374,7 @@ void getPlayerInput()
engine.keyState[engine.event.key.keysym.sym] = 1;
if (engine.gameSection != SECTION_GAME)
engine.paused = 0;
engine.paused = false;
break;

View File

@ -111,7 +111,7 @@ void checkScriptEvents()
}
else
{
enemy[gameEvent[i].entity].active = 1;
enemy[gameEvent[i].entity].active = true;
enemy[gameEvent[i].entity].x = Math::rrand((int)player.x + 400, (int)player.x + 800);
enemy[gameEvent[i].entity].y = Math::rrand((int)player.y - 400, (int)player.y + 800);
}
@ -175,7 +175,7 @@ void setScene(int scene)
enemy[index].x = x;
enemy[index].y = y;
enemy[index].dx = speed;
enemy[index].active = 1;
enemy[index].active = true;
}
}
@ -215,7 +215,7 @@ void doCutscene(int scene)
{
enemy[i] = defEnemy[0];
enemy[i].face = 0;
enemy[i].active = 0;
enemy[i].active = false;
}
for (int i = 0 ; i < 10 ; i++)

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct object {
signed char active;
bool active;
signed char classDef; // Used by aliens to determine what they are
signed char AIType; // Type of articifial intelligence
@ -98,7 +98,7 @@ struct Star {
struct collectables {
signed char active;
bool active;
float x, y, dx, dy;
SDL_Surface *image;
signed char type; // What kind of collectable is it?
@ -130,9 +130,9 @@ struct Game {
unsigned char musicVolume;
unsigned char sfxVolume;
signed char fullScreen;
signed char useMusic;
signed char useSound;
bool fullScreen;
bool useMusic;
bool useSound;
signed char autoSaveSlot;
unsigned int cash;
@ -261,22 +261,22 @@ struct globalEngineVariables {
signed char allAliensDead;
int addAliens;
signed char paused;
bool paused;
signed char gameSection;
signed char useAudio;
bool useAudio;
// This really only applies to Linux users.
char userHomeDirectory[1024];
char keyState[350];
signed char cheat; // overall cheat
signed char cheatShield;
signed char cheatCash;
signed char cheatAmmo;
signed char cheatTime;
signed char cheatCredits;
bool cheat; // overall cheat
bool cheatShield;
bool cheatCash;
bool cheatAmmo;
bool cheatTime;
bool cheatCredits;
};
struct event {

View File

@ -346,7 +346,7 @@ int doTitle()
if (engine.cheatCredits)
{
doCredits();
engine.cheatCredits = 0;
engine.cheatCredits = false;
}
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE]))
@ -389,10 +389,10 @@ int doTitle()
case 2:
if ((selectedOption == 1) && (engine.useAudio))
currentGame.useSound = 1 - currentGame.useSound;
currentGame.useSound = !currentGame.useSound;
else if ((selectedOption == 2) && (engine.useAudio))
{
currentGame.useMusic = 1 - currentGame.useMusic;
currentGame.useMusic = !currentGame.useMusic;
if (currentGame.useMusic)
{
@ -408,7 +408,7 @@ int doTitle()
}
else if (selectedOption == 3)
{
currentGame.fullScreen = 1 - currentGame.fullScreen;
currentGame.fullScreen = !currentGame.fullScreen;
#if LINUX
SDL_WM_ToggleFullScreen(graphics.screen);
#else
@ -430,13 +430,13 @@ int doTitle()
case 3:
if (selectedOption == 1)
engine.cheatShield = 1 - engine.cheatShield;
engine.cheatShield = !engine.cheatShield;
else if (selectedOption == 2)
engine.cheatAmmo = 1 - engine.cheatAmmo;
engine.cheatAmmo = !engine.cheatAmmo;
else if (selectedOption == 3)
engine.cheatCash = 1 - engine.cheatCash;
engine.cheatCash = !engine.cheatCash;
else if (selectedOption == 4)
engine.cheatTime = 1 - engine.cheatTime;
engine.cheatTime = !engine.cheatTime;
else if (selectedOption == listLength)
{menuType = 0; selectedOption = 1;}
createCheatMenu();