Commit ec9b06cc authored by anotherguest's avatar anotherguest

Not all compilers allow pointer comparison with anything but the pointer type...

Not all compilers allow pointer comparison with anything but the pointer type or NULL! Just wondering when the Level* level should be < 0? I think != NULL is the correct statement.Please correct if not!
parent 1f982b3b
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "game.h" #include "game.h"
#include "gamemode.h" #include "gamemode.h"
#include "bonus/bonus.h" #include "bonus/bonus.h"
#include "io/controls.h" #include "io/controls.h"
#include "io/gfx/font.h" #include "io/gfx/font.h"
#include "io/gfx/video.h" #include "io/gfx/video.h"
...@@ -35,12 +35,12 @@ ...@@ -35,12 +35,12 @@
#include "player/player.h" #include "player/player.h"
#include "scene/scene.h" #include "scene/scene.h"
#include <string.h> #include <string.h>
Game::Game () { Game::Game () {
levelFile = NULL; levelFile = NULL;
bonusFile = NULL; bonusFile = NULL;
players = NULL; players = NULL;
...@@ -51,19 +51,19 @@ Game::Game () { ...@@ -51,19 +51,19 @@ Game::Game () {
Game::Game (char *firstLevel, int gameDifficulty) { Game::Game (char *firstLevel, int gameDifficulty) {
if (!strncmp(firstLevel, F_BONUSMAP, 8)) { if (!strncmp(firstLevel, F_BONUSMAP, 8)) {
levelFile = NULL; levelFile = NULL;
bonusFile = createString(firstLevel); bonusFile = createString(firstLevel);
} else { } else {
levelFile = createString(firstLevel); levelFile = createString(firstLevel);
bonusFile = NULL; bonusFile = NULL;
} }
difficulty = gameDifficulty; difficulty = gameDifficulty;
gameMode = NULL; gameMode = NULL;
...@@ -81,7 +81,7 @@ Game::Game (char *firstLevel, int gameDifficulty) { ...@@ -81,7 +81,7 @@ Game::Game (char *firstLevel, int gameDifficulty) {
Game::~Game () { Game::~Game () {
if (levelFile) delete[] levelFile; if (levelFile) delete[] levelFile;
if (bonusFile) delete[] levelFile; if (bonusFile) delete[] levelFile;
if (players) delete[] players; if (players) delete[] players;
localPlayer = NULL; localPlayer = NULL;
...@@ -103,20 +103,20 @@ int Game::setLevel (char *fileName) { ...@@ -103,20 +103,20 @@ int Game::setLevel (char *fileName) {
} }
int Game::setBonus (int ext) { int Game::setBonus (int ext) {
if (bonusFile) delete[] bonusFile; if (bonusFile) delete[] bonusFile;
if (level >= 0) bonusFile = createFileName(F_BONUSMAP, ext); if (level != NULL) bonusFile = createFileName(F_BONUSMAP, ext);
else bonusFile = NULL; else bonusFile = NULL;
return E_NONE; return E_NONE;
} }
int Game::play () { int Game::play () {
Bonus *bonus; Bonus *bonus;
Scene *scene; Scene *scene;
bool checkpoint; bool checkpoint;
...@@ -128,11 +128,11 @@ int Game::play () { ...@@ -128,11 +128,11 @@ int Game::play () {
while (true) { while (true) {
sendTime = checkTime = 0; sendTime = checkTime = 0;
level = NULL; level = NULL;
if (levelFile) { if (levelFile) {
// Load and play the level // Load and play the level
...@@ -147,107 +147,107 @@ int Game::play () { ...@@ -147,107 +147,107 @@ int Game::play () {
} }
levelRet = level->play(); levelRet = level->play();
if (levelRet < 0) { if (levelRet < 0) {
delete level; delete level;
return levelRet; return levelRet;
} else if (levelRet == E_NONE) { } else if (levelRet == E_NONE) {
delete level; delete level;
playMusic("menusng.psm"); playMusic("menusng.psm");
return E_NONE; return E_NONE;
} }
} else levelRet = WON; } else levelRet = WON;
if (bonusFile && (levelRet == WON)) { if (bonusFile && (levelRet == WON)) {
// Load and play the bonus level // Load and play the bonus level
try { try {
bonus = new Bonus(bonusFile, difficulty); bonus = new Bonus(bonusFile, difficulty);
} catch (int e) { } catch (int e) {
return e; return e;
} }
if (levelFile) { if (levelFile) {
delete[] bonusFile; delete[] bonusFile;
bonusFile = NULL; bonusFile = NULL;
} }
bonusRet = bonus->play(); bonusRet = bonus->play();
delete bonus; delete bonus;
if (bonusRet == E_QUIT) { if (bonusRet == E_QUIT) {
if (level) delete level; if (level) delete level;
return E_QUIT; return E_QUIT;
} else if (bonusRet == E_NONE) { } else if (bonusRet == E_NONE) {
if (level) delete level; if (level) delete level;
playMusic("menusng.psm"); playMusic("menusng.psm");
return E_NONE; return E_NONE;
} else if (bonusRet == WON) { } else if (bonusRet == WON) {
try { try {
scene = new Scene(F_BONUS_0SC); scene = new Scene(F_BONUS_0SC);
} catch (int e) { } catch (int e) {
scene = NULL; scene = NULL;
} }
if (scene) { if (scene) {
if (scene->play() == E_QUIT) { if (scene->play() == E_QUIT) {
delete scene; delete scene;
if (level) delete level; if (level) delete level;
return E_QUIT; return E_QUIT;
} }
delete scene; delete scene;
} }
// If part of a bonus-only game, go to next level // If part of a bonus-only game, go to next level
if (!level) setBonus((bonusFile[10] * 10) + bonusFile[11] - 527); if (!level) setBonus((bonusFile[10] * 10) + bonusFile[11] - 527);
} }
} }
if (!level) continue; if (!level) continue;
if (levelRet == WON) { if (levelRet == WON) {
// Won the level // Won the level
// If there is no next level, load and play the cutscene // If there is no next level, load and play the cutscene
if (!levelFile) { if (!levelFile) {
...@@ -255,19 +255,19 @@ int Game::play () { ...@@ -255,19 +255,19 @@ int Game::play () {
scene = level->createScene(); scene = level->createScene();
delete level; delete level;
if (scene) { if (scene) {
if (scene->play() == E_QUIT) { if (scene->play() == E_QUIT) {
delete scene; delete scene;
return E_QUIT; return E_QUIT;
} }
delete scene; delete scene;
} }
return E_NONE; return E_NONE;
...@@ -276,10 +276,10 @@ int Game::play () { ...@@ -276,10 +276,10 @@ int Game::play () {
// Do not use old level's checkpoint coordinates // Do not use old level's checkpoint coordinates
checkpoint = false; checkpoint = false;
} else { } else {
// Lost the level // Lost the level
if (!localPlayer->getLives()) return E_NONE; if (!localPlayer->getLives()) return E_NONE;
...@@ -287,9 +287,9 @@ int Game::play () { ...@@ -287,9 +287,9 @@ int Game::play () {
checkpoint = true; checkpoint = true;
} }
delete level; delete level;
} }
return E_NONE; return E_NONE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment