LAB: Finally get rid of g_lab
This commit is contained in:
parent
974740d307
commit
a784e2bd5c
5 changed files with 49 additions and 99 deletions
|
@ -31,7 +31,6 @@
|
||||||
#include "engines/advancedDetector.h"
|
#include "engines/advancedDetector.h"
|
||||||
|
|
||||||
#include "lab/lab.h"
|
#include "lab/lab.h"
|
||||||
#include "lab/savegame.h"
|
|
||||||
|
|
||||||
static const PlainGameDescriptor lab_setting[] = {
|
static const PlainGameDescriptor lab_setting[] = {
|
||||||
{ "lab", "Labyrith of Time" },
|
{ "lab", "Labyrith of Time" },
|
||||||
|
|
|
@ -47,13 +47,8 @@
|
||||||
#include "lab/utils.h"
|
#include "lab/utils.h"
|
||||||
|
|
||||||
namespace Lab {
|
namespace Lab {
|
||||||
|
|
||||||
LabEngine *g_lab;
|
|
||||||
|
|
||||||
LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
|
LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
|
||||||
: Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0), _rnd("lab") {
|
: Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0), _rnd("lab") {
|
||||||
g_lab = this;
|
|
||||||
|
|
||||||
_lastWaitTOFTicks = 0;
|
_lastWaitTOFTicks = 0;
|
||||||
|
|
||||||
_isHiRes = false;
|
_isHiRes = false;
|
||||||
|
|
|
@ -34,8 +34,9 @@
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/random.h"
|
#include "common/random.h"
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
|
#include "common/savefile.h"
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
|
#include "engines/savestate.h"
|
||||||
|
|
||||||
#include "lab/image.h"
|
#include "lab/image.h"
|
||||||
|
|
||||||
|
@ -64,6 +65,13 @@ class Resource;
|
||||||
class TilePuzzle;
|
class TilePuzzle;
|
||||||
class Utils;
|
class Utils;
|
||||||
|
|
||||||
|
struct SaveGameHeader {
|
||||||
|
byte _version;
|
||||||
|
SaveStateDescriptor _descr;
|
||||||
|
uint16 _roomNumber;
|
||||||
|
uint16 _direction;
|
||||||
|
};
|
||||||
|
|
||||||
enum GameFeatures {
|
enum GameFeatures {
|
||||||
GF_LOWRES = 1 << 0,
|
GF_LOWRES = 1 << 0,
|
||||||
GF_WINDOWS_TRIAL = 1 << 1
|
GF_WINDOWS_TRIAL = 1 << 1
|
||||||
|
@ -244,9 +252,14 @@ private:
|
||||||
void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
|
void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
|
||||||
bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
|
bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
|
||||||
void turnPage(bool fromLeft);
|
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
|
} // End of namespace Lab
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,10 @@
|
||||||
#include "engines/savestate.h"
|
#include "engines/savestate.h"
|
||||||
|
|
||||||
#include "lab/lab.h"
|
#include "lab/lab.h"
|
||||||
|
|
||||||
#include "lab/dispman.h"
|
#include "lab/dispman.h"
|
||||||
#include "lab/labsets.h"
|
#include "lab/labsets.h"
|
||||||
#include "lab/music.h"
|
#include "lab/music.h"
|
||||||
#include "lab/processroom.h"
|
#include "lab/processroom.h"
|
||||||
#include "lab/savegame.h"
|
|
||||||
#include "lab/tilepuzzle.h"
|
#include "lab/tilepuzzle.h"
|
||||||
|
|
||||||
namespace Lab {
|
namespace Lab {
|
||||||
|
@ -51,7 +49,7 @@ namespace Lab {
|
||||||
#define SAVEGAME_ID MKTAG('L', 'O', 'T', 'S')
|
#define SAVEGAME_ID MKTAG('L', 'O', 'T', 'S')
|
||||||
#define SAVEGAME_VERSION 1
|
#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);
|
out->writeUint32BE(SAVEGAME_ID);
|
||||||
|
|
||||||
// Write version
|
// Write version
|
||||||
|
@ -123,9 +121,9 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
|
||||||
/**
|
/**
|
||||||
* Writes the game out to disk.
|
* Writes the game out to disk.
|
||||||
*/
|
*/
|
||||||
bool saveGame(int slot, Common::String desc) {
|
bool LabEngine::saveGame(int slot, Common::String desc) {
|
||||||
uint16 i;
|
uint16 i;
|
||||||
Common::String fileName = g_lab->generateSaveFileName(slot);
|
Common::String fileName = generateSaveFileName(slot);
|
||||||
Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
|
Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
|
||||||
Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);
|
Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);
|
||||||
|
|
||||||
|
@ -134,27 +132,27 @@ bool saveGame(int slot, Common::String desc) {
|
||||||
|
|
||||||
// Load scene pic
|
// Load scene pic
|
||||||
CloseDataPtr closePtr = nullptr;
|
CloseDataPtr closePtr = nullptr;
|
||||||
g_lab->_graphics->readPict(g_lab->getPictName(&closePtr), true);
|
_graphics->readPict(getPictName(&closePtr), true);
|
||||||
|
|
||||||
writeSaveGameHeader(file, desc);
|
writeSaveGameHeader(file, desc);
|
||||||
file->writeUint16LE(g_lab->_roomNum);
|
file->writeUint16LE(_roomNum);
|
||||||
file->writeUint16LE(g_lab->getDirection());
|
file->writeUint16LE(getDirection());
|
||||||
file->writeUint16LE(g_lab->getQuarters());
|
file->writeUint16LE(getQuarters());
|
||||||
|
|
||||||
// Conditions
|
// Conditions
|
||||||
for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++)
|
for (i = 0; i < _conditions->_lastElement / (8 * 2); i++)
|
||||||
file->writeUint16LE(g_lab->_conditions->_array[i]);
|
file->writeUint16LE(_conditions->_array[i]);
|
||||||
|
|
||||||
// Rooms found
|
// Rooms found
|
||||||
for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++)
|
for (i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
|
||||||
file->writeUint16LE(g_lab->_roomsFound->_array[i]);
|
file->writeUint16LE(_roomsFound->_array[i]);
|
||||||
|
|
||||||
g_lab->_tilePuzzle->save(file);
|
_tilePuzzle->save(file);
|
||||||
|
|
||||||
// Breadcrumbs
|
// Breadcrumbs
|
||||||
for (i = 0; i < sizeof(g_lab->_breadCrumbs); i++) {
|
for (i = 0; i < sizeof(_breadCrumbs); i++) {
|
||||||
file->writeUint16LE(g_lab->_breadCrumbs[i]._roomNum);
|
file->writeUint16LE(_breadCrumbs[i]._roomNum);
|
||||||
file->writeUint16LE(g_lab->_breadCrumbs[i]._direction);
|
file->writeUint16LE(_breadCrumbs[i]._direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
file->flush();
|
file->flush();
|
||||||
|
@ -167,9 +165,9 @@ bool saveGame(int slot, Common::String desc) {
|
||||||
/**
|
/**
|
||||||
* Reads the game from disk.
|
* Reads the game from disk.
|
||||||
*/
|
*/
|
||||||
bool loadGame(int slot) {
|
bool LabEngine::loadGame(int slot) {
|
||||||
uint16 i;
|
uint16 i;
|
||||||
Common::String fileName = g_lab->generateSaveFileName(slot);
|
Common::String fileName = generateSaveFileName(slot);
|
||||||
Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
|
Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
|
||||||
Common::InSaveFile *file = saveFileManager->openForLoading(fileName);
|
Common::InSaveFile *file = saveFileManager->openForLoading(fileName);
|
||||||
|
|
||||||
|
@ -178,33 +176,33 @@ bool loadGame(int slot) {
|
||||||
|
|
||||||
SaveGameHeader header;
|
SaveGameHeader header;
|
||||||
readSaveGameHeader(file, header);
|
readSaveGameHeader(file, header);
|
||||||
g_lab->_roomNum = file->readUint16LE();
|
_roomNum = file->readUint16LE();
|
||||||
g_lab->setDirection(file->readUint16LE());
|
setDirection(file->readUint16LE());
|
||||||
g_lab->setQuarters(file->readUint16LE());
|
setQuarters(file->readUint16LE());
|
||||||
|
|
||||||
// Conditions
|
// Conditions
|
||||||
for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++)
|
for (i = 0; i < _conditions->_lastElement / (8 * 2); i++)
|
||||||
g_lab->_conditions->_array[i] = file->readUint16LE();
|
_conditions->_array[i] = file->readUint16LE();
|
||||||
|
|
||||||
// Rooms found
|
// Rooms found
|
||||||
for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++)
|
for (i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
|
||||||
g_lab->_roomsFound->_array[i] = file->readUint16LE();
|
_roomsFound->_array[i] = file->readUint16LE();
|
||||||
|
|
||||||
g_lab->_tilePuzzle->load(file);
|
_tilePuzzle->load(file);
|
||||||
|
|
||||||
// Breadcrumbs
|
// Breadcrumbs
|
||||||
for (i = 0; i < 128; i++) {
|
for (i = 0; i < 128; i++) {
|
||||||
g_lab->_breadCrumbs[i]._roomNum = file->readUint16LE();
|
_breadCrumbs[i]._roomNum = file->readUint16LE();
|
||||||
g_lab->_breadCrumbs[i]._direction = file->readUint16LE();
|
_breadCrumbs[i]._direction = file->readUint16LE();
|
||||||
}
|
}
|
||||||
|
|
||||||
g_lab->_droppingCrumbs = (g_lab->_breadCrumbs[0]._roomNum != 0);
|
_droppingCrumbs = (_breadCrumbs[0]._roomNum != 0);
|
||||||
g_lab->_followingCrumbs = false;
|
_followingCrumbs = false;
|
||||||
|
|
||||||
for (i = 0; i < 128; i++) {
|
for (i = 0; i < 128; i++) {
|
||||||
if (g_lab->_breadCrumbs[i]._roomNum == 0)
|
if (_breadCrumbs[i]._roomNum == 0)
|
||||||
break;
|
break;
|
||||||
g_lab->_numCrumbs = i;
|
_numCrumbs = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete file;
|
delete file;
|
||||||
|
@ -215,8 +213,6 @@ bool loadGame(int slot) {
|
||||||
bool LabEngine::saveRestoreGame() {
|
bool LabEngine::saveRestoreGame() {
|
||||||
bool isOK = false;
|
bool isOK = false;
|
||||||
|
|
||||||
//g_lab->showMainMenu();
|
|
||||||
|
|
||||||
// The original had one screen for saving/loading. We have two.
|
// The original had one screen for saving/loading. We have two.
|
||||||
// Ask the user which screen to use.
|
// Ask the user which screen to use.
|
||||||
GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));
|
GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));
|
||||||
|
|
|
@ -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
|
|
Loading…
Add table
Add a link
Reference in a new issue