diff options
author | Strangerke | 2015-12-13 23:22:34 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:34:03 +0100 |
commit | a784e2bd5cb17e3abbc2bfd47e65b63ef13ec2fc (patch) | |
tree | 023b9526733bcf9f7e4807bbef2319cfd19e0d94 | |
parent | 974740d3076984535f941afb18e0adfa7132aab7 (diff) | |
download | scummvm-rg350-a784e2bd5cb17e3abbc2bfd47e65b63ef13ec2fc.tar.gz scummvm-rg350-a784e2bd5cb17e3abbc2bfd47e65b63ef13ec2fc.tar.bz2 scummvm-rg350-a784e2bd5cb17e3abbc2bfd47e65b63ef13ec2fc.zip |
LAB: Finally get rid of g_lab
-rw-r--r-- | engines/lab/detection.cpp | 7 | ||||
-rw-r--r-- | engines/lab/lab.cpp | 5 | ||||
-rw-r--r-- | engines/lab/lab.h | 17 | ||||
-rw-r--r-- | engines/lab/savegame.cpp | 66 | ||||
-rw-r--r-- | engines/lab/savegame.h | 53 |
5 files changed, 49 insertions, 99 deletions
diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp index afdf5a1625..ff8679c489 100644 --- a/engines/lab/detection.cpp +++ b/engines/lab/detection.cpp @@ -31,7 +31,6 @@ #include "engines/advancedDetector.h" #include "lab/lab.h" -#include "lab/savegame.h" static const PlainGameDescriptor lab_setting[] = { { "lab", "Labyrith of Time" }, @@ -184,9 +183,9 @@ SaveStateList LabMetaEngine::listSaves(const char *target) const { if (slotNum >= 0 && slotNum <= 999) { Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); if (in) { - if (Lab::readSaveGameHeader(in, header)) - saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription())); - delete in; + if (Lab::readSaveGameHeader(in, header)) + saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription())); + delete in; } } } diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp index 18b8b3d065..1decad0000 100644 --- a/engines/lab/lab.cpp +++ b/engines/lab/lab.cpp @@ -47,13 +47,8 @@ #include "lab/utils.h" namespace Lab { - -LabEngine *g_lab; - LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0), _rnd("lab") { - g_lab = this; - _lastWaitTOFTicks = 0; _isHiRes = false; diff --git a/engines/lab/lab.h b/engines/lab/lab.h index d968c18013..756f6e1a36 100644 --- a/engines/lab/lab.h +++ b/engines/lab/lab.h @@ -34,8 +34,9 @@ #include "common/system.h" #include "common/random.h" #include "common/rect.h" - +#include "common/savefile.h" #include "engines/engine.h" +#include "engines/savestate.h" #include "lab/image.h" @@ -64,6 +65,13 @@ class Resource; class TilePuzzle; class Utils; +struct SaveGameHeader { + byte _version; + SaveStateDescriptor _descr; + uint16 _roomNumber; + uint16 _direction; +}; + enum GameFeatures { GF_LOWRES = 1 << 0, GF_WINDOWS_TRIAL = 1 << 1 @@ -244,9 +252,14 @@ private: void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords); bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList); void turnPage(bool fromLeft); + +private: + bool saveGame(int slot, Common::String desc); + bool loadGame(int slot); + void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName); }; -extern LabEngine *g_lab; +bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header); } // End of namespace Lab diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp index 9ead742200..957bfdbf58 100644 --- a/engines/lab/savegame.cpp +++ b/engines/lab/savegame.cpp @@ -38,12 +38,10 @@ #include "engines/savestate.h" #include "lab/lab.h" - #include "lab/dispman.h" #include "lab/labsets.h" #include "lab/music.h" #include "lab/processroom.h" -#include "lab/savegame.h" #include "lab/tilepuzzle.h" namespace Lab { @@ -51,7 +49,7 @@ namespace Lab { #define SAVEGAME_ID MKTAG('L', 'O', 'T', 'S') #define SAVEGAME_VERSION 1 -void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) { +void LabEngine::writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) { out->writeUint32BE(SAVEGAME_ID); // Write version @@ -123,9 +121,9 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) { /** * Writes the game out to disk. */ -bool saveGame(int slot, Common::String desc) { +bool LabEngine::saveGame(int slot, Common::String desc) { uint16 i; - Common::String fileName = g_lab->generateSaveFileName(slot); + Common::String fileName = generateSaveFileName(slot); Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); Common::OutSaveFile *file = saveFileManager->openForSaving(fileName); @@ -134,27 +132,27 @@ bool saveGame(int slot, Common::String desc) { // Load scene pic CloseDataPtr closePtr = nullptr; - g_lab->_graphics->readPict(g_lab->getPictName(&closePtr), true); + _graphics->readPict(getPictName(&closePtr), true); writeSaveGameHeader(file, desc); - file->writeUint16LE(g_lab->_roomNum); - file->writeUint16LE(g_lab->getDirection()); - file->writeUint16LE(g_lab->getQuarters()); + file->writeUint16LE(_roomNum); + file->writeUint16LE(getDirection()); + file->writeUint16LE(getQuarters()); // Conditions - for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++) - file->writeUint16LE(g_lab->_conditions->_array[i]); + for (i = 0; i < _conditions->_lastElement / (8 * 2); i++) + file->writeUint16LE(_conditions->_array[i]); // Rooms found - for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++) - file->writeUint16LE(g_lab->_roomsFound->_array[i]); + for (i = 0; i < _roomsFound->_lastElement / (8 * 2); i++) + file->writeUint16LE(_roomsFound->_array[i]); - g_lab->_tilePuzzle->save(file); + _tilePuzzle->save(file); // Breadcrumbs - for (i = 0; i < sizeof(g_lab->_breadCrumbs); i++) { - file->writeUint16LE(g_lab->_breadCrumbs[i]._roomNum); - file->writeUint16LE(g_lab->_breadCrumbs[i]._direction); + for (i = 0; i < sizeof(_breadCrumbs); i++) { + file->writeUint16LE(_breadCrumbs[i]._roomNum); + file->writeUint16LE(_breadCrumbs[i]._direction); } file->flush(); @@ -167,9 +165,9 @@ bool saveGame(int slot, Common::String desc) { /** * Reads the game from disk. */ -bool loadGame(int slot) { +bool LabEngine::loadGame(int slot) { uint16 i; - Common::String fileName = g_lab->generateSaveFileName(slot); + Common::String fileName = generateSaveFileName(slot); Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); Common::InSaveFile *file = saveFileManager->openForLoading(fileName); @@ -178,33 +176,33 @@ bool loadGame(int slot) { SaveGameHeader header; readSaveGameHeader(file, header); - g_lab->_roomNum = file->readUint16LE(); - g_lab->setDirection(file->readUint16LE()); - g_lab->setQuarters(file->readUint16LE()); + _roomNum = file->readUint16LE(); + setDirection(file->readUint16LE()); + setQuarters(file->readUint16LE()); // Conditions - for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++) - g_lab->_conditions->_array[i] = file->readUint16LE(); + for (i = 0; i < _conditions->_lastElement / (8 * 2); i++) + _conditions->_array[i] = file->readUint16LE(); // Rooms found - for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++) - g_lab->_roomsFound->_array[i] = file->readUint16LE(); + for (i = 0; i < _roomsFound->_lastElement / (8 * 2); i++) + _roomsFound->_array[i] = file->readUint16LE(); - g_lab->_tilePuzzle->load(file); + _tilePuzzle->load(file); // Breadcrumbs for (i = 0; i < 128; i++) { - g_lab->_breadCrumbs[i]._roomNum = file->readUint16LE(); - g_lab->_breadCrumbs[i]._direction = file->readUint16LE(); + _breadCrumbs[i]._roomNum = file->readUint16LE(); + _breadCrumbs[i]._direction = file->readUint16LE(); } - g_lab->_droppingCrumbs = (g_lab->_breadCrumbs[0]._roomNum != 0); - g_lab->_followingCrumbs = false; + _droppingCrumbs = (_breadCrumbs[0]._roomNum != 0); + _followingCrumbs = false; for (i = 0; i < 128; i++) { - if (g_lab->_breadCrumbs[i]._roomNum == 0) + if (_breadCrumbs[i]._roomNum == 0) break; - g_lab->_numCrumbs = i; + _numCrumbs = i; } delete file; @@ -215,8 +213,6 @@ bool loadGame(int slot) { bool LabEngine::saveRestoreGame() { bool isOK = false; - //g_lab->showMainMenu(); - // The original had one screen for saving/loading. We have two. // Ask the user which screen to use. GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore")); diff --git a/engines/lab/savegame.h b/engines/lab/savegame.h deleted file mode 100644 index f4f08b6368..0000000000 --- a/engines/lab/savegame.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on Labyrinth of Time code with assistance of - * - * Copyright (c) 1993 Terra Nova Development - * Copyright (c) 2004 The Wyrmkeep Entertainment Co. - * - */ - -#ifndef LAB_SAVEGAME_H -#define LAB_SAVEGAME_H - -#include "common/savefile.h" - -namespace Lab { - -class LabEngine; - -struct SaveGameHeader { - byte _version; - SaveStateDescriptor _descr; - uint16 _roomNumber; - uint16 _direction; -}; - -bool saveGame(int slot, Common::String desc); -bool loadGame(int slot); -bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header); - -} // End of namespace Lab - -#endif // LAB_SAVEGAME_H |