aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2015-12-06 21:39:41 +0100
committerWillem Jan Palenstijn2015-12-23 21:33:52 +0100
commit803dbcee90bad321532dea54219697aaec34608a (patch)
tree58e9bc170566e54916d33239143cda6253722862 /engines
parentb3269dc80d2a2e1dca9ac24854578befe5004f4f (diff)
downloadscummvm-rg350-803dbcee90bad321532dea54219697aaec34608a.tar.gz
scummvm-rg350-803dbcee90bad321532dea54219697aaec34608a.tar.bz2
scummvm-rg350-803dbcee90bad321532dea54219697aaec34608a.zip
LAB: Move _rooms to LabEngine, some renaming
Diffstat (limited to 'engines')
-rw-r--r--engines/lab/engine.cpp132
-rw-r--r--engines/lab/lab.cpp5
-rw-r--r--engines/lab/lab.h3
-rw-r--r--engines/lab/map.cpp2
-rw-r--r--engines/lab/music.cpp4
-rw-r--r--engines/lab/music.h2
-rw-r--r--engines/lab/parsetypes.h9
-rw-r--r--engines/lab/processroom.cpp28
-rw-r--r--engines/lab/resource.cpp42
9 files changed, 109 insertions, 118 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index e371858e9a..f3d13610e3 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -41,9 +41,7 @@
namespace Lab {
/* Global parser data */
-extern RoomData *_rooms;
-
-bool ispal = false, MainDisplay = true;
+bool ispal = false;
/* LAB: Labyrinth specific code for the special puzzles */
#define SPECIALLOCK 100
@@ -226,31 +224,31 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
/******************************************************************************/
/* Gets the current inventory name. */
/******************************************************************************/
-const char *LabEngine::getInvName(uint16 CurInv) {
- if (MainDisplay)
- return _inventory[CurInv].BInvName;
+const char *LabEngine::getInvName(uint16 curInv) {
+ if (_mainDisplay)
+ return _inventory[curInv].BInvName;
- if ((CurInv == LAMPNUM) && _conditions->in(LAMPON))
+ if ((curInv == LAMPNUM) && _conditions->in(LAMPON))
return "P:Mines/120";
- if ((CurInv == BELTNUM) && _conditions->in(BELTGLOW))
+ if ((curInv == BELTNUM) && _conditions->in(BELTGLOW))
return "P:Future/BeltGlow";
- if (CurInv == WESTPAPERNUM) {
- _curFileName = _inventory[CurInv].BInvName;
+ if (curInv == WESTPAPERNUM) {
+ _curFileName = _inventory[curInv].BInvName;
_anim->_noPalChange = true;
_graphics->readPict(_curFileName, false);
_anim->_noPalChange = false;
doWestPaper();
- } else if (CurInv == NOTESNUM) {
- _curFileName = _inventory[CurInv].BInvName;
+ } else if (curInv == NOTESNUM) {
+ _curFileName = _inventory[curInv].BInvName;
_anim->_noPalChange = true;
_graphics->readPict(_curFileName, false);
_anim->_noPalChange = false;
doNotes();
}
- return _inventory[CurInv].BInvName;
+ return _inventory[curInv].BInvName;
}
/******************************************************************************/
@@ -274,7 +272,7 @@ void LabEngine::interfaceOn() {
}
if (_graphics->_longWinInFront)
- _event->attachGadgetList(NULL);
+ _event->attachGadgetList(nullptr);
else if (_alternate)
_event->attachGadgetList(_invGadgetList);
else
@@ -284,8 +282,8 @@ void LabEngine::interfaceOn() {
/******************************************************************************/
/* If the user hits the "Use" gadget; things that can get used on themselves. */
/******************************************************************************/
-bool LabEngine::doUse(uint16 CurInv) {
- if (CurInv == MAPNUM) { /* LAB: Labyrinth specific */
+bool LabEngine::doUse(uint16 curInv) {
+ if (curInv == MAPNUM) { /* LAB: Labyrinth specific */
drawStaticMessage(kTextUseMap);
interfaceOff();
_anim->stopDiff();
@@ -295,7 +293,7 @@ bool LabEngine::doUse(uint16 CurInv) {
_graphics->setPalette(initcolors, 8);
_graphics->drawMessage(NULL);
_graphics->drawPanel();
- } else if (CurInv == JOURNALNUM) { /* LAB: Labyrinth specific */
+ } else if (curInv == JOURNALNUM) { /* LAB: Labyrinth specific */
drawStaticMessage(kTextUseJournal);
interfaceOff();
_anim->stopDiff();
@@ -304,7 +302,7 @@ bool LabEngine::doUse(uint16 CurInv) {
doJournal();
_graphics->drawPanel();
_graphics->drawMessage(NULL);
- } else if (CurInv == LAMPNUM) { /* LAB: Labyrinth specific */
+ } else if (curInv == LAMPNUM) { /* LAB: Labyrinth specific */
interfaceOff();
if (_conditions->in(LAMPON)) {
@@ -321,20 +319,20 @@ bool LabEngine::doUse(uint16 CurInv) {
_anim->_waitForEffect = false;
_anim->_doBlack = false;
- _nextFileName = getInvName(CurInv);
- } else if (CurInv == BELTNUM) { /* LAB: Labyrinth specific */
+ _nextFileName = getInvName(curInv);
+ } else if (curInv == BELTNUM) { /* LAB: Labyrinth specific */
if (!_conditions->in(BELTGLOW))
_conditions->inclElement(BELTGLOW);
_anim->_doBlack = false;
- _nextFileName = getInvName(CurInv);
- } else if (CurInv == WHISKEYNUM) { /* LAB: Labyrinth specific */
+ _nextFileName = getInvName(curInv);
+ } else if (curInv == WHISKEYNUM) { /* LAB: Labyrinth specific */
_conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUseWhiskey);
- } else if (CurInv == PITHHELMETNUM) { /* LAB: Labyrinth specific */
+ } else if (curInv == PITHHELMETNUM) { /* LAB: Labyrinth specific */
_conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUsePith);
- } else if (CurInv == HELMETNUM) { /* LAB: Labyrinth specific */
+ } else if (curInv == HELMETNUM) { /* LAB: Labyrinth specific */
_conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUseHelmet);
} else
@@ -346,47 +344,46 @@ bool LabEngine::doUse(uint16 CurInv) {
/******************************************************************************/
/* Decrements the current inventory number. */
/******************************************************************************/
-void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
+void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
interfaceOff();
- if (dec)
- (*CurInv)--;
+ if (decreaseFl)
+ (*curInv)--;
else
- (*CurInv)++;
+ (*curInv)++;
- while (*CurInv && (*CurInv <= _numInv)) {
- if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
- _nextFileName = getInvName(*CurInv);
+ while (*curInv && (*curInv <= _numInv)) {
+ if (_conditions->in(*curInv) && _inventory[*curInv].BInvName) {
+ _nextFileName = getInvName(*curInv);
break;
}
- if (dec)
- (*CurInv)--;
+ if (decreaseFl)
+ (*curInv)--;
else
- (*CurInv)++;
+ (*curInv)++;
}
- if ((*CurInv == 0) || (*CurInv > _numInv)) {
- if (dec)
- *CurInv = _numInv;
+ if ((*curInv == 0) || (*curInv > _numInv)) {
+ if (decreaseFl)
+ *curInv = _numInv;
else
- *CurInv = 1;
+ *curInv = 1;
- while (*CurInv && (*CurInv <= _numInv)) {
- if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
- _nextFileName = getInvName(*CurInv);
+ while (*curInv && (*curInv <= _numInv)) {
+ if (_conditions->in(*curInv) && _inventory[*curInv].BInvName) {
+ _nextFileName = getInvName(*curInv);
break;
}
- if (dec)
- (*CurInv)--;
+ if (decreaseFl)
+ (*curInv)--;
else
- (*CurInv)++;
+ (*curInv)++;
}
}
}
-
/******************************************************************************/
/* The main game loop */
/******************************************************************************/
@@ -394,7 +391,8 @@ void LabEngine::mainGameLoop() {
uint16 actionMode = 4;
uint16 curInv = MAPNUM;
- bool forceDraw = false, GotMessage = true;
+ bool forceDraw = false;
+ bool gotMessage = true;
_graphics->setPalette(initcolors, 8);
@@ -424,7 +422,7 @@ void LabEngine::mainGameLoop() {
while (1) {
_event->processInput(true);
- if (GotMessage) {
+ if (gotMessage) {
if (_quitLab || g_engine->shouldQuit()) {
_anim->stopDiff();
break;
@@ -441,7 +439,7 @@ void LabEngine::mainGameLoop() {
}
/* Sets the current picture properly on the screen */
- if (MainDisplay)
+ if (_mainDisplay)
_nextFileName = getPictName(&_cptr);
if (_noUpdateDiff) {
@@ -456,11 +454,11 @@ void LabEngine::mainGameLoop() {
_curFileName = _nextFileName;
if (_cptr) {
- if ((_cptr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */
+ if ((_cptr->CloseUpType == SPECIALLOCK) && _mainDisplay) /* LAB: Labyrinth specific code */
showCombination(_curFileName);
else if (((_cptr->CloseUpType == SPECIALBRICK) ||
(_cptr->CloseUpType == SPECIALBRICKNOMOUSE)) &&
- MainDisplay) /* LAB: Labyrinth specific code */
+ _mainDisplay) /* LAB: Labyrinth specific code */
showTile(_curFileName, (bool)(_cptr->CloseUpType == SPECIALBRICKNOMOUSE));
else
_graphics->readPict(_curFileName, false);
@@ -489,7 +487,7 @@ void LabEngine::mainGameLoop() {
IntuiMessage *curMsg = getMsg();
if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
- GotMessage = false;
+ gotMessage = false;
_music->checkRoomMusic();
_music->updateMusic();
_anim->diffNextFrame();
@@ -506,7 +504,7 @@ void LabEngine::mainGameLoop() {
else if (result == VKEY_RTARROW)
code = 8;
- GotMessage = true;
+ gotMessage = true;
mayShowCrumbIndicator();
_graphics->screenUpdate();
if (!from_crumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
@@ -517,7 +515,7 @@ void LabEngine::mainGameLoop() {
mayShowCrumbIndicator();
_graphics->screenUpdate();
} else {
- GotMessage = true;
+ gotMessage = true;
Common::Point curPos;
curPos.x = curMsg->mouseX;
@@ -591,7 +589,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_anim->_doBlack = true;
_graphics->_doNotDrawMessage = false;
- MainDisplay = true;
+ _mainDisplay = true;
interfaceOn(); /* Sets the correct gadget list */
_graphics->drawPanel();
drawRoomMessage(curInv, _cptr);
@@ -680,7 +678,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_graphics->_doNotDrawMessage = false;
interfaceOn(); /* Sets the correct gadget list */
- MainDisplay = false;
+ _mainDisplay = false;
if (lastInv && _conditions->in(lastInv)) {
curInv = lastInv;
@@ -809,7 +807,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_anim->_doBlack = true;
_graphics->_doNotDrawMessage = false;
- MainDisplay = true;
+ _mainDisplay = true;
interfaceOn(); /* Sets the correct gadget list */
_graphics->drawPanel();
drawRoomMessage(curInv, _cptr);
@@ -827,7 +825,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
doit = !saveRestoreGame();
_cptr = NULL;
- MainDisplay = true;
+ _mainDisplay = true;
curInv = MAPNUM;
lastInv = MAPNUM;
@@ -851,12 +849,12 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
perFlipGadget(oldActionMode);
drawStaticMessage(kTextUseOnWhat);
- MainDisplay = true;
+ _mainDisplay = true;
_graphics->screenUpdate();
}
} else if (gadgetId == 2) {
- MainDisplay = !MainDisplay;
+ _mainDisplay = !_mainDisplay;
if ((curInv == 0) || (curInv > _numInv)) {
curInv = 1;
@@ -904,7 +902,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_anim->_doBlack = true;
_graphics->_doNotDrawMessage = false;
- MainDisplay = true;
+ _mainDisplay = true;
interfaceOn(); /* Sets the correct gadget list */
_graphics->drawPanel();
drawRoomMessage(curInv, _cptr);
@@ -919,16 +917,16 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
}
}
}
- } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && MainDisplay) {
+ } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && _mainDisplay) {
interfaceOff();
- MainDisplay = true;
+ _mainDisplay = true;
doit = false;
if (_cptr) {
- if ((_cptr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */
+ if ((_cptr->CloseUpType == SPECIALLOCK) && _mainDisplay) /* LAB: Labyrinth specific code */
mouseCombination(curPos);
- else if ((_cptr->CloseUpType == SPECIALBRICK) && MainDisplay)
+ else if ((_cptr->CloseUpType == SPECIALBRICK) && _mainDisplay)
mouseTile(curPos);
else
doit = true;
@@ -1022,7 +1020,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_alternate = !_alternate;
_anim->_doBlack = true;
_graphics->_doNotDrawMessage = false;
- MainDisplay = true;
+ _mainDisplay = true;
interfaceOn(); /* Sets the correct gadget list */
if (_alternate) {
@@ -1163,7 +1161,7 @@ void LabEngine::mayShowCrumbIndicator() {
if (getPlatform() != Common::kPlatformWindows)
return;
- if (_droppingCrumbs && MainDisplay) {
+ if (_droppingCrumbs && _mainDisplay) {
_event->mouseHide();
dropCrumbsImage.drawMaskImage(612, 4);
_event->mouseShow();
@@ -1177,7 +1175,7 @@ void LabEngine::mayShowCrumbIndicatorOff() {
if (getPlatform() != Common::kPlatformWindows)
return;
- if (MainDisplay) {
+ if (_mainDisplay) {
_event->mouseHide();
dropCrumbsOffImage.drawMaskImage(612, 4);
_event->mouseShow();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 5f2a4d5f10..83f09cdf87 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -72,11 +72,12 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_isCrumbWaiting = false;
_noUpdateDiff = false;
_quitLab = false;
+ _mainDisplay = true;
+
_numInv = 0;
_manyRooms = 0;
_direction = 0;
_highestCondition = 0;
-
_crumbSecs = 0;
_crumbMicros = 0;
@@ -85,6 +86,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_music = nullptr;
_anim = nullptr;
_graphics = nullptr;
+ _rooms = nullptr;
_lastTooLong = false;
_interfaceOff = false;
@@ -129,6 +131,7 @@ LabEngine::~LabEngine() {
delete _music;
delete _anim;
delete _graphics;
+ free(_rooms);
for (int i = 0; i < 16; i++)
delete _tiles[i];
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 384b5599ed..27bae37d0d 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -90,7 +90,7 @@ private:
bool _interfaceOff;
bool _noUpdateDiff;
bool _quitLab;
-
+ bool _mainDisplay;
// timing.cpp
void microDelay(uint32 secs, uint32 micros);
@@ -100,6 +100,7 @@ public:
Music *_music;
Anim *_anim;
DisplayMan *_graphics;
+ RoomData *_rooms;
int _roomNum;
CrumbData _breadCrumbs[MAX_CRUMBS];
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 218aae4213..40e8eb9d49 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -45,8 +45,6 @@ namespace Lab {
/*------------------------------ The Map stuff ------------------------------*/
/*---------------------------------------------------------------------------*/
-extern RoomData *_rooms;
-
static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
*HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,
*MapEast, *MapSouth, *MapWest, *XMark;
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 66db0d8493..ddc6cbdaa6 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -146,13 +146,13 @@ void Music::fillbuffer(byte *musicBuffer) {
/*****************************************************************************/
/* Starts up the music initially. */
/*****************************************************************************/
-void Music::startMusic(bool startatbegin) {
+void Music::startMusic(bool restartFl) {
if (!_musicOn)
return;
stopSoundEffect();
- if (startatbegin) {
+ if (restartFl) {
_file->seek(0);
_leftinfile = _file->size();
}
diff --git a/engines/lab/music.h b/engines/lab/music.h
index d292e9ed9c..7905da74a5 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -79,7 +79,7 @@ public:
private:
LabEngine *_vm;
void fillbuffer(byte *musicBuffer);
- void startMusic(bool startatbegin);
+ void startMusic(bool restartFl);
Common::File *_file;
Common::File *_tFile;
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 6be1ba2482..9bfc2b094d 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -103,8 +103,7 @@ namespace Lab {
typedef struct closeData {
uint16 x1, y1, x2, y2;
- int16 CloseUpType; /* if > 0, an object. If < 0,
- an item */
+ int16 CloseUpType; /* if > 0, an object. If < 0, an item */
uint16 depth; /* Level of the closeup. */
char *GraphicName, *Message;
closeData *NextCloseUp, *SubCloseUps;
@@ -121,14 +120,12 @@ struct ViewData {
struct Action {
int16 ActionType, Param1, Param2, Param3;
- byte *Data; /* Message, or a pointer to array
- of messages. */
+ byte *Data; /* Message, or a pointer to array of messages. */
Action *NextAction;
};
struct Rule {
int16 RuleType, Param1, Param2, *Condition;
-
Action *ActionList;
Rule *NextRule;
};
@@ -150,8 +147,6 @@ struct InventoryData {
char *name, *BInvName;
};
-
-
/* Map Flags */
/* Where the doors are; in a corridor, assumed to be left doors */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 932649cb7e..f254d4b753 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -44,8 +44,6 @@ namespace Lab {
#define NOFILE "no file"
-RoomData *_rooms;
-
/*****************************************************************************/
/* Generates a random number. */
/*****************************************************************************/
@@ -81,10 +79,10 @@ static bool checkConditions(int16 *condition) {
/* Gets the current ViewDataPointer. */
/*****************************************************************************/
ViewData *getViewData(uint16 roomNum, uint16 direction) {
- if (!_rooms[roomNum]._roomMsg)
+ if (!g_lab->_rooms[roomNum]._roomMsg)
g_lab->_resource->readViews(roomNum);
- ViewData *view = _rooms[roomNum]._view[direction];
+ ViewData *view = g_lab->_rooms[roomNum]._view[direction];
do {
if (checkConditions(view->Condition))
@@ -195,13 +193,13 @@ bool processArrow(uint16 *direction, uint16 arrow) {
uint16 room = 1;
if (*direction == NORTH)
- room = _rooms[g_lab->_roomNum]._northDoor;
+ room = g_lab->_rooms[g_lab->_roomNum]._northDoor;
else if (*direction == SOUTH)
- room = _rooms[g_lab->_roomNum]._southDoor;
+ room = g_lab->_rooms[g_lab->_roomNum]._southDoor;
else if (*direction == EAST)
- room = _rooms[g_lab->_roomNum]._eastDoor;
+ room = g_lab->_rooms[g_lab->_roomNum]._eastDoor;
else if (*direction == WEST)
- room = _rooms[g_lab->_roomNum]._westDoor;
+ room = g_lab->_rooms[g_lab->_roomNum]._westDoor;
if (room == 0)
return false;
@@ -574,11 +572,11 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
action++;
if (lcptr) {
- RuleList *rules = _rooms[g_lab->_roomNum]._rules;
+ RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
if ((rules == NULL) && (roomNum == 0)) {
g_lab->_resource->readViews(roomNum);
- rules = _rooms[roomNum]._rules;
+ rules = g_lab->_rooms[roomNum]._rules;
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -629,11 +627,11 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
if (lcptr)
if (lcptr->CloseUpType > 0) {
- RuleList *rules = _rooms[roomNum]._rules;
+ RuleList *rules = g_lab->_rooms[roomNum]._rules;
if ((rules == NULL) && (roomNum == 0)) {
g_lab->_resource->readViews(roomNum);
- rules = _rooms[roomNum]._rules;
+ rules = g_lab->_rooms[roomNum]._rules;
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -689,7 +687,7 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
/* Goes thru the rules if the user tries to go forward. */
/*****************************************************************************/
bool doGoForward(CloseDataPtr *lcptr) {
- RuleList *rules = _rooms[g_lab->_roomNum]._rules;
+ RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (g_lab->_direction + 1))) {
@@ -710,7 +708,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
from++;
to++;
- RuleList *rules = _rooms[g_lab->_roomNum]._rules;
+ RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == TURN) ||
@@ -730,7 +728,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
/* Goes thru the rules if the user tries to go to the main view */
/*****************************************************************************/
bool doMainView(CloseDataPtr *lcptr) {
- RuleList *rules = _rooms[g_lab->_roomNum]._rules;
+ RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if ((*rule)->RuleType == GOMAINVIEW) {
if (checkConditions((*rule)->Condition)) {
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 654ce97b24..f8a70cc7c2 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -34,8 +34,6 @@
namespace Lab {
-extern RoomData *_rooms;
-
Resource::Resource(LabEngine *vm) : _vm(vm) {
readStaticText();
}
@@ -93,22 +91,22 @@ bool Resource::readRoomData(const char *fileName) {
_vm->_manyRooms = dataFile->readUint16LE();
_vm->_highestCondition = dataFile->readUint16LE();
- _rooms = (RoomData *)malloc((_vm->_manyRooms + 1) * sizeof(RoomData));
- memset(_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
+ _vm->_rooms = (RoomData *)malloc((_vm->_manyRooms + 1) * sizeof(RoomData));
+ memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
- _rooms[i]._northDoor = dataFile->readUint16LE();
- _rooms[i]._southDoor = dataFile->readUint16LE();
- _rooms[i]._eastDoor = dataFile->readUint16LE();
- _rooms[i]._westDoor = dataFile->readUint16LE();
- _rooms[i]._wipeType = dataFile->readByte();
-
- _rooms[i]._view[NORTH] = nullptr;
- _rooms[i]._view[SOUTH] = nullptr;
- _rooms[i]._view[EAST] = nullptr;
- _rooms[i]._view[WEST] = nullptr;
- _rooms[i]._rules = nullptr;
- _rooms[i]._roomMsg = nullptr;
+ _vm->_rooms[i]._northDoor = dataFile->readUint16LE();
+ _vm->_rooms[i]._southDoor = dataFile->readUint16LE();
+ _vm->_rooms[i]._eastDoor = dataFile->readUint16LE();
+ _vm->_rooms[i]._westDoor = dataFile->readUint16LE();
+ _vm->_rooms[i]._wipeType = dataFile->readByte();
+
+ _vm->_rooms[i]._view[NORTH] = nullptr;
+ _vm->_rooms[i]._view[SOUTH] = nullptr;
+ _vm->_rooms[i]._view[EAST] = nullptr;
+ _vm->_rooms[i]._view[WEST] = nullptr;
+ _vm->_rooms[i]._rules = nullptr;
+ _vm->_rooms[i]._roomMsg = nullptr;
}
delete dataFile;
@@ -136,12 +134,12 @@ bool Resource::readViews(uint16 roomNum) {
Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
Common::File *dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4'));
- _rooms[roomNum]._roomMsg = readString(dataFile);
- _rooms[roomNum]._view[NORTH] = readView(dataFile);
- _rooms[roomNum]._view[SOUTH] = readView(dataFile);
- _rooms[roomNum]._view[EAST] = readView(dataFile);
- _rooms[roomNum]._view[WEST] = readView(dataFile);
- _rooms[roomNum]._rules = readRule(dataFile);
+ _vm->_rooms[roomNum]._roomMsg = readString(dataFile);
+ _vm->_rooms[roomNum]._view[NORTH] = readView(dataFile);
+ _vm->_rooms[roomNum]._view[SOUTH] = readView(dataFile);
+ _vm->_rooms[roomNum]._view[EAST] = readView(dataFile);
+ _vm->_rooms[roomNum]._view[WEST] = readView(dataFile);
+ _vm->_rooms[roomNum]._rules = readRule(dataFile);
_vm->_music->updateMusic();