AGI: Remove _game.state, not needed anymore

This commit is contained in:
Martin Kiewitz 2016-02-03 03:07:50 +01:00
parent 34117170f2
commit cc55cb13d3
4 changed files with 22 additions and 40 deletions

View File

@ -207,6 +207,9 @@ void AgiEngine::agiUnloadResources() {
int AgiEngine::agiDeinit() {
int ec;
if (!_loader)
return errOK;
_words->clearEgoWords(); // remove all words from memory
agiUnloadResources(); // unload resources in memory
_loader->unloadResource(RESOURCETYPE_LOGIC, 0);
@ -332,7 +335,6 @@ const byte *AgiBase::getFontData() {
}
AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) {
// Setup mixer
syncSoundSettings();
@ -365,8 +367,6 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
_game.gfxMode = true;
_game.state = STATE_INIT;
_keyQueueStart = 0;
_keyQueueEnd = 0;
@ -391,14 +391,17 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
memset(_keyQueue, 0, sizeof(_keyQueue));
_text = NULL;
_sprites = NULL;
_picture = NULL;
_loader = NULL;
_console = NULL;
_menu = NULL;
_gfx = NULL;
_systemUI = NULL;
_console = nullptr;
_font = nullptr;
_gfx = nullptr;
_sound = nullptr;
_picture = nullptr;
_sprites = nullptr;
_text = nullptr;
_loader = nullptr;
_menu = nullptr;
_systemUI = nullptr;
_inventory = nullptr;
_egoHoldKey = false;
}
@ -467,7 +470,6 @@ void AgiEngine::initialize() {
debugC(2, kDebugLevelMain, "Detect game");
if (agiDetectGame() == errOK) {
_game.state = STATE_LOADED;
debugC(2, kDebugLevelMain, "game loaded");
} else {
warning("Could not open AGI game");
@ -504,19 +506,14 @@ void AgiEngine::adjustPosToGameScreen(int16 &x, int16 &y) {
}
AgiEngine::~AgiEngine() {
// If the engine hasn't been initialized yet via
// AgiEngine::initialize(), don't attempt to free any resources, as
// they haven't been allocated. Fixes bug #1742432 - AGI: Engine
// crashes if no game is detected
if (_game.state == STATE_INIT) {
return;
}
agiDeinit();
delete _loader;
_gfx->deinitVideo();
if (_gfx) {
_gfx->deinitVideo();
}
delete _inventory;
delete _systemUI;
delete _menu;
delete _text;
delete _sprites;
delete _picture;
@ -540,12 +537,6 @@ Common::Error AgiEngine::go() {
}
inGameTimerReset();
if (_game.state < STATE_LOADED) {
do {
processAGIEvents();
} while (_game.state < STATE_RUNNING);
}
runGame();
return Common::kNoError;

View File

@ -394,12 +394,6 @@ enum CycleInnerLoopType {
CYCLE_INNERLOOP_HAVEKEY = 7
};
enum State {
STATE_INIT = 0x00,
STATE_LOADED = 0x01,
STATE_RUNNING = 0x02
};
typedef Common::Array<int16> SavedGameSlotIdArray;
/**
@ -410,8 +404,6 @@ typedef Common::Array<int16> SavedGameSlotIdArray;
struct AgiGame {
AgiEngine *_vm;
State state; /**< state of the interpreter */
// TODO: Check whether adjMouseX and adjMouseY must be saved and loaded when using savegames.
// If they must be then loading and saving is partially broken at the moment.
int adjMouseX; /**< last given adj.ego.move.to.x.y-command's 1st parameter */
@ -734,6 +726,8 @@ public:
void adjustPosToGameScreen(int16 &x, int16 &y);
private:
bool initialized;
int _keyQueue[KEY_QUEUE_SIZE];
int _keyQueueStart;
int _keyQueueEnd;

View File

@ -440,9 +440,7 @@ int AgiEngine::runGame() {
setVar(VM_VAR_MAX_INPUT_CHARACTERS, 38);
_text->promptDisable();
_game.state = STATE_RUNNING;
ec = playGame();
_game.state = STATE_LOADED;
agiDeinit();
} while (_restartGame);

View File

@ -110,8 +110,7 @@ int AgiEngine::saveGame(const Common::String &fileName, const Common::String &de
out->writeUint32BE(playTime);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing play time (%d)", playTime);
out->writeByte(_game.state);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game state (%d)", _game.state);
out->writeByte(2); // was _game.state, 2 = STATE_RUNNING
strcpy(gameIDstring, _game.id);
out->write(gameIDstring, 8);
@ -387,7 +386,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
}
}
_game.state = (State)in->readByte();
in->readByte(); // was _game.state, not needed anymore
in->read(loadId, 8);
if (strcmp(loadId, _game.id) != 0 && checkId) {