aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lab/engine.cpp38
-rw-r--r--engines/lab/lab.cpp2
-rw-r--r--engines/lab/lab.h4
-rw-r--r--engines/lab/labfun.h1
-rw-r--r--engines/lab/processroom.cpp9
-rw-r--r--engines/lab/resource.cpp16
-rw-r--r--engines/lab/resource.h2
-rw-r--r--engines/lab/special.cpp7
8 files changed, 40 insertions, 39 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 7b14afc0bf..051ccacd78 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -45,7 +45,6 @@ extern bool stopsound, DoNotDrawMessage;
/* Global parser data */
extern RoomData *_rooms;
-extern InventoryData *Inventory;
extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
bool ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
@@ -159,14 +158,14 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
}
if (_alternate) {
- if ((curInv <= NumInv) && _conditions->in(curInv) && Inventory[curInv].BInvName) {
+ if ((curInv <= NumInv) && _conditions->in(curInv) && _inventory[curInv].BInvName) {
if ((curInv == LAMPNUM) && _conditions->in(LAMPON)) /* LAB: Labyrinth specific */
drawStaticMessage(kTextLampOn);
- else if (Inventory[curInv].Many > 1) {
- Common::String roomMessage = Common::String(Inventory[curInv].name) + " (" + Common::String::format("%d", Inventory[curInv].Many) + ")";
+ else if (_inventory[curInv].Many > 1) {
+ Common::String roomMessage = Common::String(_inventory[curInv].name) + " (" + Common::String::format("%d", _inventory[curInv].Many) + ")";
drawMessage(roomMessage.c_str());
} else
- drawMessage(Inventory[curInv].name);
+ drawMessage(_inventory[curInv].name);
}
} else
drawDirection(closePtr);
@@ -390,7 +389,7 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
/******************************************************************************/
const char *LabEngine::getInvName(uint16 CurInv) {
if (MainDisplay)
- return Inventory[CurInv].BInvName;
+ return _inventory[CurInv].BInvName;
if ((CurInv == LAMPNUM) && _conditions->in(LAMPON))
return "P:Mines/120";
@@ -399,20 +398,20 @@ const char *LabEngine::getInvName(uint16 CurInv) {
return "P:Future/BeltGlow";
if (CurInv == WESTPAPERNUM) {
- g_lab->_curFileName = Inventory[CurInv].BInvName;
+ g_lab->_curFileName = _inventory[CurInv].BInvName;
g_lab->_anim->_noPalChange = true;
readPict(g_lab->_curFileName, false);
g_lab->_anim->_noPalChange = false;
doWestPaper();
} else if (CurInv == NOTESNUM) {
- g_lab->_curFileName = Inventory[CurInv].BInvName;
+ g_lab->_curFileName = _inventory[CurInv].BInvName;
g_lab->_anim->_noPalChange = true;
readPict(g_lab->_curFileName, false);
g_lab->_anim->_noPalChange = false;
doNotes();
}
- return Inventory[CurInv].BInvName;
+ return _inventory[CurInv].BInvName;
}
/******************************************************************************/
@@ -517,7 +516,7 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
(*CurInv)++;
while (*CurInv && (*CurInv <= NumInv)) {
- if (_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
+ if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
_nextFileName = getInvName(*CurInv);
break;
}
@@ -535,7 +534,7 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
*CurInv = 1;
while (*CurInv && (*CurInv <= NumInv)) {
- if (_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
+ if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
_nextFileName = getInvName(*CurInv);
break;
}
@@ -565,7 +564,8 @@ void LabEngine::mainGameLoop() {
Direction = NORTH;
_resource->readRoomData("LAB:Doors");
- _resource->readInventory("LAB:Inventor");
+ if (!(_inventory = _resource->readInventory("LAB:Inventor")))
+ return;
if (!(_conditions = new LargeSet(HighestCondition + 1, this)))
return;
@@ -698,16 +698,16 @@ void LabEngine::mainGameLoop() {
_rooms = nullptr;
}
- if (Inventory) {
+ if (_inventory) {
for (int i = 1; i <= NumInv; i++) {
- if (Inventory[i].name)
- free(Inventory[i].name);
+ if (_inventory[i].name)
+ free(_inventory[i].name);
- if (Inventory[i].BInvName)
- free(Inventory[i].BInvName);
+ if (_inventory[i].BInvName)
+ free(_inventory[i].BInvName);
}
- free(Inventory);
+ free(_inventory);
}
}
@@ -1041,7 +1041,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
}
if ((curInv <= NumInv) && _conditions->in(curInv) &&
- Inventory[curInv].BInvName)
+ _inventory[curInv].BInvName)
_nextFileName = getInvName(curInv);
screenUpdate();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 7bb05c8969..90c713135b 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -112,6 +112,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_longWinInFront = false;
_msgFont = 0;
+ _inventory = 0;
+
//const Common::FSNode gameDataDir(ConfMan.get("path"));
//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index f19a1bacff..d8b75cbc62 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -125,7 +125,6 @@ public:
const char *_newFileName; /* When ProcessRoom.c decides to change the filename
of the current picture. */
-
private:
int _lastWaitTOFTicks;
bool _lastMessageLong;
@@ -133,6 +132,7 @@ private:
TextFont *_msgFont;
bool _longWinInFront;
CloseDataPtr _cptr;
+ InventoryData *_inventory;
private:
bool createScreen(bool HiRes);
@@ -194,6 +194,8 @@ private:
void mayShowCrumbIndicatorOff();
const char *getInvName(uint16 curInv);
+ bool saveRestoreGame();
+
public:
void doActions(Action *aPtr, CloseDataPtr *lcptr);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index ad84402933..987864b097 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -193,7 +193,6 @@ void doJournal();
void doNotes();
void doWestPaper();
void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-bool saveRestoreGame();
/*--------------------------*/
/*----- From saveGame.c ----*/
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 2976c49ed6..954bf00f68 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -45,7 +45,6 @@ namespace Lab {
#define NOFILE "no file"
RoomData *_rooms;
-InventoryData *Inventory;
uint16 NumInv, ManyRooms, HighestCondition, Direction;
extern bool DoNotDrawMessage, noupdatediff, QuitLab, MusicOn;
@@ -434,16 +433,16 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
break;
case SUBINV:
- if (Inventory[aptr->Param1].Many)
- (Inventory[aptr->Param1].Many)--;
+ if (_inventory[aptr->Param1].Many)
+ (_inventory[aptr->Param1].Many)--;
- if (Inventory[aptr->Param1].Many == 0)
+ if (_inventory[aptr->Param1].Many == 0)
_conditions->exclElement(aptr->Param1);
break;
case ADDINV:
- (Inventory[aptr->Param1].Many) += aptr->Param2;
+ (_inventory[aptr->Param1].Many) += aptr->Param2;
_conditions->inclElement(aptr->Param1);
break;
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 415839d986..303bae85ab 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -36,7 +36,6 @@ namespace Lab {
static uint16 allocroom;
extern RoomData *_rooms;
-extern InventoryData *Inventory;
extern uint16 NumInv, ManyRooms, HighestCondition;
Resource::Resource(LabEngine *vm) : _vm(vm) {
@@ -127,22 +126,23 @@ bool Resource::readRoomData(const char *fileName) {
return true;
}
-bool Resource::readInventory(const char *fileName) {
+InventoryData *Resource::readInventory(const char *fileName) {
Common::File *dataFile;
if (!(dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'))))
- return false;
+ return nullptr;
NumInv = dataFile->readUint16LE();
- Inventory = (InventoryData *)malloc((NumInv + 1) * sizeof(InventoryData));
+ InventoryData *inventory = (InventoryData *)malloc((NumInv + 1) * sizeof(InventoryData));
for (uint16 i = 1; i <= NumInv; i++) {
- Inventory[i].Many = dataFile->readUint16LE();
- Inventory[i].name = readString(dataFile);
- Inventory[i].BInvName = readString(dataFile);
+ inventory[i].Many = dataFile->readUint16LE();
+ inventory[i].name = readString(dataFile);
+ inventory[i].BInvName = readString(dataFile);
}
delete dataFile;
- return true;
+
+ return inventory;
}
bool Resource::readViews(uint16 roomNum) {
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 35165693a0..2c7f9b75eb 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -100,7 +100,7 @@ public:
Common::File *openDataFile(const char * fileName, uint32 fileHeader = 0);
bool readRoomData(const char *fileName);
- bool readInventory(const char *fileName);
+ InventoryData *readInventory(const char *fileName);
bool readViews(uint16 roomNum);
TextFont *getFont(const char *fileName);
char *getText(const char *fileName);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index f8b0c2091e..9f36303a1d 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -83,7 +83,6 @@ uint16 CurTile[4][4] = {
extern uint16 *FadePalette;
extern BitMap *DispBitMap, *DrawBitMap;
-extern InventoryData *Inventory;
extern uint16 Direction;
#define COMBINATIONUNLOCKED 130
@@ -753,7 +752,7 @@ void LabEngine::doJournal() {
freeAllStolenMem();
}
-bool saveRestoreGame() {
+bool LabEngine::saveRestoreGame() {
bool isOK = false;
//g_lab->showMainMenu();
@@ -775,14 +774,14 @@ bool saveRestoreGame() {
desc = dialog->createDefaultSaveDescription(slot);
}
- isOK = saveGame(Direction, Inventory[QUARTERNUM].Many, slot, desc);
+ isOK = saveGame(Direction, _inventory[QUARTERNUM].Many, slot, desc);
}
} else {
// Restore
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
int slot = dialog->runModalWithCurrentTarget();
if (slot >= 0) {
- isOK = loadGame(&Direction, &(Inventory[QUARTERNUM].Many), slot);
+ isOK = loadGame(&Direction, &(_inventory[QUARTERNUM].Many), slot);
if (isOK)
g_lab->_music->resetMusic();
}