LAB: Move _rooms to LabEngine, some renaming

This commit is contained in:
Strangerke 2015-12-06 21:39:41 +01:00 committed by Willem Jan Palenstijn
parent b3269dc80d
commit 803dbcee90
9 changed files with 108 additions and 117 deletions

View file

@ -41,9 +41,7 @@
namespace Lab { namespace Lab {
/* Global parser data */ /* Global parser data */
extern RoomData *_rooms; bool ispal = false;
bool ispal = false, MainDisplay = true;
/* LAB: Labyrinth specific code for the special puzzles */ /* LAB: Labyrinth specific code for the special puzzles */
#define SPECIALLOCK 100 #define SPECIALLOCK 100
@ -226,31 +224,31 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
/******************************************************************************/ /******************************************************************************/
/* Gets the current inventory name. */ /* Gets the current inventory name. */
/******************************************************************************/ /******************************************************************************/
const char *LabEngine::getInvName(uint16 CurInv) { const char *LabEngine::getInvName(uint16 curInv) {
if (MainDisplay) if (_mainDisplay)
return _inventory[CurInv].BInvName; return _inventory[curInv].BInvName;
if ((CurInv == LAMPNUM) && _conditions->in(LAMPON)) if ((curInv == LAMPNUM) && _conditions->in(LAMPON))
return "P:Mines/120"; return "P:Mines/120";
if ((CurInv == BELTNUM) && _conditions->in(BELTGLOW)) if ((curInv == BELTNUM) && _conditions->in(BELTGLOW))
return "P:Future/BeltGlow"; return "P:Future/BeltGlow";
if (CurInv == WESTPAPERNUM) { if (curInv == WESTPAPERNUM) {
_curFileName = _inventory[CurInv].BInvName; _curFileName = _inventory[curInv].BInvName;
_anim->_noPalChange = true; _anim->_noPalChange = true;
_graphics->readPict(_curFileName, false); _graphics->readPict(_curFileName, false);
_anim->_noPalChange = false; _anim->_noPalChange = false;
doWestPaper(); doWestPaper();
} else if (CurInv == NOTESNUM) { } else if (curInv == NOTESNUM) {
_curFileName = _inventory[CurInv].BInvName; _curFileName = _inventory[curInv].BInvName;
_anim->_noPalChange = true; _anim->_noPalChange = true;
_graphics->readPict(_curFileName, false); _graphics->readPict(_curFileName, false);
_anim->_noPalChange = false; _anim->_noPalChange = false;
doNotes(); doNotes();
} }
return _inventory[CurInv].BInvName; return _inventory[curInv].BInvName;
} }
/******************************************************************************/ /******************************************************************************/
@ -274,7 +272,7 @@ void LabEngine::interfaceOn() {
} }
if (_graphics->_longWinInFront) if (_graphics->_longWinInFront)
_event->attachGadgetList(NULL); _event->attachGadgetList(nullptr);
else if (_alternate) else if (_alternate)
_event->attachGadgetList(_invGadgetList); _event->attachGadgetList(_invGadgetList);
else else
@ -284,8 +282,8 @@ void LabEngine::interfaceOn() {
/******************************************************************************/ /******************************************************************************/
/* If the user hits the "Use" gadget; things that can get used on themselves. */ /* If the user hits the "Use" gadget; things that can get used on themselves. */
/******************************************************************************/ /******************************************************************************/
bool LabEngine::doUse(uint16 CurInv) { bool LabEngine::doUse(uint16 curInv) {
if (CurInv == MAPNUM) { /* LAB: Labyrinth specific */ if (curInv == MAPNUM) { /* LAB: Labyrinth specific */
drawStaticMessage(kTextUseMap); drawStaticMessage(kTextUseMap);
interfaceOff(); interfaceOff();
_anim->stopDiff(); _anim->stopDiff();
@ -295,7 +293,7 @@ bool LabEngine::doUse(uint16 CurInv) {
_graphics->setPalette(initcolors, 8); _graphics->setPalette(initcolors, 8);
_graphics->drawMessage(NULL); _graphics->drawMessage(NULL);
_graphics->drawPanel(); _graphics->drawPanel();
} else if (CurInv == JOURNALNUM) { /* LAB: Labyrinth specific */ } else if (curInv == JOURNALNUM) { /* LAB: Labyrinth specific */
drawStaticMessage(kTextUseJournal); drawStaticMessage(kTextUseJournal);
interfaceOff(); interfaceOff();
_anim->stopDiff(); _anim->stopDiff();
@ -304,7 +302,7 @@ bool LabEngine::doUse(uint16 CurInv) {
doJournal(); doJournal();
_graphics->drawPanel(); _graphics->drawPanel();
_graphics->drawMessage(NULL); _graphics->drawMessage(NULL);
} else if (CurInv == LAMPNUM) { /* LAB: Labyrinth specific */ } else if (curInv == LAMPNUM) { /* LAB: Labyrinth specific */
interfaceOff(); interfaceOff();
if (_conditions->in(LAMPON)) { if (_conditions->in(LAMPON)) {
@ -321,20 +319,20 @@ bool LabEngine::doUse(uint16 CurInv) {
_anim->_waitForEffect = false; _anim->_waitForEffect = false;
_anim->_doBlack = false; _anim->_doBlack = false;
_nextFileName = getInvName(CurInv); _nextFileName = getInvName(curInv);
} else if (CurInv == BELTNUM) { /* LAB: Labyrinth specific */ } else if (curInv == BELTNUM) { /* LAB: Labyrinth specific */
if (!_conditions->in(BELTGLOW)) if (!_conditions->in(BELTGLOW))
_conditions->inclElement(BELTGLOW); _conditions->inclElement(BELTGLOW);
_anim->_doBlack = false; _anim->_doBlack = false;
_nextFileName = getInvName(CurInv); _nextFileName = getInvName(curInv);
} else if (CurInv == WHISKEYNUM) { /* LAB: Labyrinth specific */ } else if (curInv == WHISKEYNUM) { /* LAB: Labyrinth specific */
_conditions->inclElement(USEDHELMET); _conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUseWhiskey); drawStaticMessage(kTextUseWhiskey);
} else if (CurInv == PITHHELMETNUM) { /* LAB: Labyrinth specific */ } else if (curInv == PITHHELMETNUM) { /* LAB: Labyrinth specific */
_conditions->inclElement(USEDHELMET); _conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUsePith); drawStaticMessage(kTextUsePith);
} else if (CurInv == HELMETNUM) { /* LAB: Labyrinth specific */ } else if (curInv == HELMETNUM) { /* LAB: Labyrinth specific */
_conditions->inclElement(USEDHELMET); _conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUseHelmet); drawStaticMessage(kTextUseHelmet);
} else } else
@ -346,47 +344,46 @@ bool LabEngine::doUse(uint16 CurInv) {
/******************************************************************************/ /******************************************************************************/
/* Decrements the current inventory number. */ /* Decrements the current inventory number. */
/******************************************************************************/ /******************************************************************************/
void LabEngine::decIncInv(uint16 *CurInv, bool dec) { void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
interfaceOff(); interfaceOff();
if (dec) if (decreaseFl)
(*CurInv)--; (*curInv)--;
else else
(*CurInv)++; (*curInv)++;
while (*CurInv && (*CurInv <= _numInv)) { while (*curInv && (*curInv <= _numInv)) {
if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) { if (_conditions->in(*curInv) && _inventory[*curInv].BInvName) {
_nextFileName = getInvName(*CurInv); _nextFileName = getInvName(*curInv);
break; break;
} }
if (dec) if (decreaseFl)
(*CurInv)--; (*curInv)--;
else else
(*CurInv)++; (*curInv)++;
} }
if ((*CurInv == 0) || (*CurInv > _numInv)) { if ((*curInv == 0) || (*curInv > _numInv)) {
if (dec) if (decreaseFl)
*CurInv = _numInv; *curInv = _numInv;
else else
*CurInv = 1; *curInv = 1;
while (*CurInv && (*CurInv <= _numInv)) { while (*curInv && (*curInv <= _numInv)) {
if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) { if (_conditions->in(*curInv) && _inventory[*curInv].BInvName) {
_nextFileName = getInvName(*CurInv); _nextFileName = getInvName(*curInv);
break; break;
} }
if (dec) if (decreaseFl)
(*CurInv)--; (*curInv)--;
else else
(*CurInv)++; (*curInv)++;
} }
} }
} }
/******************************************************************************/ /******************************************************************************/
/* The main game loop */ /* The main game loop */
/******************************************************************************/ /******************************************************************************/
@ -394,7 +391,8 @@ void LabEngine::mainGameLoop() {
uint16 actionMode = 4; uint16 actionMode = 4;
uint16 curInv = MAPNUM; uint16 curInv = MAPNUM;
bool forceDraw = false, GotMessage = true; bool forceDraw = false;
bool gotMessage = true;
_graphics->setPalette(initcolors, 8); _graphics->setPalette(initcolors, 8);
@ -424,7 +422,7 @@ void LabEngine::mainGameLoop() {
while (1) { while (1) {
_event->processInput(true); _event->processInput(true);
if (GotMessage) { if (gotMessage) {
if (_quitLab || g_engine->shouldQuit()) { if (_quitLab || g_engine->shouldQuit()) {
_anim->stopDiff(); _anim->stopDiff();
break; break;
@ -441,7 +439,7 @@ void LabEngine::mainGameLoop() {
} }
/* Sets the current picture properly on the screen */ /* Sets the current picture properly on the screen */
if (MainDisplay) if (_mainDisplay)
_nextFileName = getPictName(&_cptr); _nextFileName = getPictName(&_cptr);
if (_noUpdateDiff) { if (_noUpdateDiff) {
@ -456,11 +454,11 @@ void LabEngine::mainGameLoop() {
_curFileName = _nextFileName; _curFileName = _nextFileName;
if (_cptr) { if (_cptr) {
if ((_cptr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */ if ((_cptr->CloseUpType == SPECIALLOCK) && _mainDisplay) /* LAB: Labyrinth specific code */
showCombination(_curFileName); showCombination(_curFileName);
else if (((_cptr->CloseUpType == SPECIALBRICK) || else if (((_cptr->CloseUpType == SPECIALBRICK) ||
(_cptr->CloseUpType == SPECIALBRICKNOMOUSE)) && (_cptr->CloseUpType == SPECIALBRICKNOMOUSE)) &&
MainDisplay) /* LAB: Labyrinth specific code */ _mainDisplay) /* LAB: Labyrinth specific code */
showTile(_curFileName, (bool)(_cptr->CloseUpType == SPECIALBRICKNOMOUSE)); showTile(_curFileName, (bool)(_cptr->CloseUpType == SPECIALBRICKNOMOUSE));
else else
_graphics->readPict(_curFileName, false); _graphics->readPict(_curFileName, false);
@ -489,7 +487,7 @@ void LabEngine::mainGameLoop() {
IntuiMessage *curMsg = getMsg(); IntuiMessage *curMsg = getMsg();
if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */ if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
GotMessage = false; gotMessage = false;
_music->checkRoomMusic(); _music->checkRoomMusic();
_music->updateMusic(); _music->updateMusic();
_anim->diffNextFrame(); _anim->diffNextFrame();
@ -506,7 +504,7 @@ void LabEngine::mainGameLoop() {
else if (result == VKEY_RTARROW) else if (result == VKEY_RTARROW)
code = 8; code = 8;
GotMessage = true; gotMessage = true;
mayShowCrumbIndicator(); mayShowCrumbIndicator();
_graphics->screenUpdate(); _graphics->screenUpdate();
if (!from_crumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode)) if (!from_crumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
@ -517,7 +515,7 @@ void LabEngine::mainGameLoop() {
mayShowCrumbIndicator(); mayShowCrumbIndicator();
_graphics->screenUpdate(); _graphics->screenUpdate();
} else { } else {
GotMessage = true; gotMessage = true;
Common::Point curPos; Common::Point curPos;
curPos.x = curMsg->mouseX; curPos.x = curMsg->mouseX;
@ -591,7 +589,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_anim->_doBlack = true; _anim->_doBlack = true;
_graphics->_doNotDrawMessage = false; _graphics->_doNotDrawMessage = false;
MainDisplay = true; _mainDisplay = true;
interfaceOn(); /* Sets the correct gadget list */ interfaceOn(); /* Sets the correct gadget list */
_graphics->drawPanel(); _graphics->drawPanel();
drawRoomMessage(curInv, _cptr); drawRoomMessage(curInv, _cptr);
@ -680,7 +678,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_graphics->_doNotDrawMessage = false; _graphics->_doNotDrawMessage = false;
interfaceOn(); /* Sets the correct gadget list */ interfaceOn(); /* Sets the correct gadget list */
MainDisplay = false; _mainDisplay = false;
if (lastInv && _conditions->in(lastInv)) { if (lastInv && _conditions->in(lastInv)) {
curInv = lastInv; curInv = lastInv;
@ -809,7 +807,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_anim->_doBlack = true; _anim->_doBlack = true;
_graphics->_doNotDrawMessage = false; _graphics->_doNotDrawMessage = false;
MainDisplay = true; _mainDisplay = true;
interfaceOn(); /* Sets the correct gadget list */ interfaceOn(); /* Sets the correct gadget list */
_graphics->drawPanel(); _graphics->drawPanel();
drawRoomMessage(curInv, _cptr); drawRoomMessage(curInv, _cptr);
@ -827,7 +825,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
doit = !saveRestoreGame(); doit = !saveRestoreGame();
_cptr = NULL; _cptr = NULL;
MainDisplay = true; _mainDisplay = true;
curInv = MAPNUM; curInv = MAPNUM;
lastInv = MAPNUM; lastInv = MAPNUM;
@ -851,12 +849,12 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
perFlipGadget(oldActionMode); perFlipGadget(oldActionMode);
drawStaticMessage(kTextUseOnWhat); drawStaticMessage(kTextUseOnWhat);
MainDisplay = true; _mainDisplay = true;
_graphics->screenUpdate(); _graphics->screenUpdate();
} }
} else if (gadgetId == 2) { } else if (gadgetId == 2) {
MainDisplay = !MainDisplay; _mainDisplay = !_mainDisplay;
if ((curInv == 0) || (curInv > _numInv)) { if ((curInv == 0) || (curInv > _numInv)) {
curInv = 1; curInv = 1;
@ -904,7 +902,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_anim->_doBlack = true; _anim->_doBlack = true;
_graphics->_doNotDrawMessage = false; _graphics->_doNotDrawMessage = false;
MainDisplay = true; _mainDisplay = true;
interfaceOn(); /* Sets the correct gadget list */ interfaceOn(); /* Sets the correct gadget list */
_graphics->drawPanel(); _graphics->drawPanel();
drawRoomMessage(curInv, _cptr); 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(); interfaceOff();
MainDisplay = true; _mainDisplay = true;
doit = false; doit = false;
if (_cptr) { if (_cptr) {
if ((_cptr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */ if ((_cptr->CloseUpType == SPECIALLOCK) && _mainDisplay) /* LAB: Labyrinth specific code */
mouseCombination(curPos); mouseCombination(curPos);
else if ((_cptr->CloseUpType == SPECIALBRICK) && MainDisplay) else if ((_cptr->CloseUpType == SPECIALBRICK) && _mainDisplay)
mouseTile(curPos); mouseTile(curPos);
else else
doit = true; doit = true;
@ -1022,7 +1020,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_alternate = !_alternate; _alternate = !_alternate;
_anim->_doBlack = true; _anim->_doBlack = true;
_graphics->_doNotDrawMessage = false; _graphics->_doNotDrawMessage = false;
MainDisplay = true; _mainDisplay = true;
interfaceOn(); /* Sets the correct gadget list */ interfaceOn(); /* Sets the correct gadget list */
if (_alternate) { if (_alternate) {
@ -1163,7 +1161,7 @@ void LabEngine::mayShowCrumbIndicator() {
if (getPlatform() != Common::kPlatformWindows) if (getPlatform() != Common::kPlatformWindows)
return; return;
if (_droppingCrumbs && MainDisplay) { if (_droppingCrumbs && _mainDisplay) {
_event->mouseHide(); _event->mouseHide();
dropCrumbsImage.drawMaskImage(612, 4); dropCrumbsImage.drawMaskImage(612, 4);
_event->mouseShow(); _event->mouseShow();
@ -1177,7 +1175,7 @@ void LabEngine::mayShowCrumbIndicatorOff() {
if (getPlatform() != Common::kPlatformWindows) if (getPlatform() != Common::kPlatformWindows)
return; return;
if (MainDisplay) { if (_mainDisplay) {
_event->mouseHide(); _event->mouseHide();
dropCrumbsOffImage.drawMaskImage(612, 4); dropCrumbsOffImage.drawMaskImage(612, 4);
_event->mouseShow(); _event->mouseShow();

View file

@ -72,11 +72,12 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_isCrumbWaiting = false; _isCrumbWaiting = false;
_noUpdateDiff = false; _noUpdateDiff = false;
_quitLab = false; _quitLab = false;
_mainDisplay = true;
_numInv = 0; _numInv = 0;
_manyRooms = 0; _manyRooms = 0;
_direction = 0; _direction = 0;
_highestCondition = 0; _highestCondition = 0;
_crumbSecs = 0; _crumbSecs = 0;
_crumbMicros = 0; _crumbMicros = 0;
@ -85,6 +86,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_music = nullptr; _music = nullptr;
_anim = nullptr; _anim = nullptr;
_graphics = nullptr; _graphics = nullptr;
_rooms = nullptr;
_lastTooLong = false; _lastTooLong = false;
_interfaceOff = false; _interfaceOff = false;
@ -129,6 +131,7 @@ LabEngine::~LabEngine() {
delete _music; delete _music;
delete _anim; delete _anim;
delete _graphics; delete _graphics;
free(_rooms);
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
delete _tiles[i]; delete _tiles[i];

View file

@ -90,7 +90,7 @@ private:
bool _interfaceOff; bool _interfaceOff;
bool _noUpdateDiff; bool _noUpdateDiff;
bool _quitLab; bool _quitLab;
bool _mainDisplay;
// timing.cpp // timing.cpp
void microDelay(uint32 secs, uint32 micros); void microDelay(uint32 secs, uint32 micros);
@ -100,6 +100,7 @@ public:
Music *_music; Music *_music;
Anim *_anim; Anim *_anim;
DisplayMan *_graphics; DisplayMan *_graphics;
RoomData *_rooms;
int _roomNum; int _roomNum;
CrumbData _breadCrumbs[MAX_CRUMBS]; CrumbData _breadCrumbs[MAX_CRUMBS];

View file

@ -45,8 +45,6 @@ namespace Lab {
/*------------------------------ The Map stuff ------------------------------*/ /*------------------------------ The Map stuff ------------------------------*/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
extern RoomData *_rooms;
static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
*HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth, *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,
*MapEast, *MapSouth, *MapWest, *XMark; *MapEast, *MapSouth, *MapWest, *XMark;

View file

@ -146,13 +146,13 @@ void Music::fillbuffer(byte *musicBuffer) {
/*****************************************************************************/ /*****************************************************************************/
/* Starts up the music initially. */ /* Starts up the music initially. */
/*****************************************************************************/ /*****************************************************************************/
void Music::startMusic(bool startatbegin) { void Music::startMusic(bool restartFl) {
if (!_musicOn) if (!_musicOn)
return; return;
stopSoundEffect(); stopSoundEffect();
if (startatbegin) { if (restartFl) {
_file->seek(0); _file->seek(0);
_leftinfile = _file->size(); _leftinfile = _file->size();
} }

View file

@ -79,7 +79,7 @@ public:
private: private:
LabEngine *_vm; LabEngine *_vm;
void fillbuffer(byte *musicBuffer); void fillbuffer(byte *musicBuffer);
void startMusic(bool startatbegin); void startMusic(bool restartFl);
Common::File *_file; Common::File *_file;
Common::File *_tFile; Common::File *_tFile;

View file

@ -103,8 +103,7 @@ namespace Lab {
typedef struct closeData { typedef struct closeData {
uint16 x1, y1, x2, y2; uint16 x1, y1, x2, y2;
int16 CloseUpType; /* if > 0, an object. If < 0, int16 CloseUpType; /* if > 0, an object. If < 0, an item */
an item */
uint16 depth; /* Level of the closeup. */ uint16 depth; /* Level of the closeup. */
char *GraphicName, *Message; char *GraphicName, *Message;
closeData *NextCloseUp, *SubCloseUps; closeData *NextCloseUp, *SubCloseUps;
@ -121,14 +120,12 @@ struct ViewData {
struct Action { struct Action {
int16 ActionType, Param1, Param2, Param3; int16 ActionType, Param1, Param2, Param3;
byte *Data; /* Message, or a pointer to array byte *Data; /* Message, or a pointer to array of messages. */
of messages. */
Action *NextAction; Action *NextAction;
}; };
struct Rule { struct Rule {
int16 RuleType, Param1, Param2, *Condition; int16 RuleType, Param1, Param2, *Condition;
Action *ActionList; Action *ActionList;
Rule *NextRule; Rule *NextRule;
}; };
@ -150,8 +147,6 @@ struct InventoryData {
char *name, *BInvName; char *name, *BInvName;
}; };
/* Map Flags */ /* Map Flags */
/* Where the doors are; in a corridor, assumed to be left doors */ /* Where the doors are; in a corridor, assumed to be left doors */

View file

@ -44,8 +44,6 @@ namespace Lab {
#define NOFILE "no file" #define NOFILE "no file"
RoomData *_rooms;
/*****************************************************************************/ /*****************************************************************************/
/* Generates a random number. */ /* Generates a random number. */
/*****************************************************************************/ /*****************************************************************************/
@ -81,10 +79,10 @@ static bool checkConditions(int16 *condition) {
/* Gets the current ViewDataPointer. */ /* Gets the current ViewDataPointer. */
/*****************************************************************************/ /*****************************************************************************/
ViewData *getViewData(uint16 roomNum, uint16 direction) { ViewData *getViewData(uint16 roomNum, uint16 direction) {
if (!_rooms[roomNum]._roomMsg) if (!g_lab->_rooms[roomNum]._roomMsg)
g_lab->_resource->readViews(roomNum); g_lab->_resource->readViews(roomNum);
ViewData *view = _rooms[roomNum]._view[direction]; ViewData *view = g_lab->_rooms[roomNum]._view[direction];
do { do {
if (checkConditions(view->Condition)) if (checkConditions(view->Condition))
@ -195,13 +193,13 @@ bool processArrow(uint16 *direction, uint16 arrow) {
uint16 room = 1; uint16 room = 1;
if (*direction == NORTH) if (*direction == NORTH)
room = _rooms[g_lab->_roomNum]._northDoor; room = g_lab->_rooms[g_lab->_roomNum]._northDoor;
else if (*direction == SOUTH) else if (*direction == SOUTH)
room = _rooms[g_lab->_roomNum]._southDoor; room = g_lab->_rooms[g_lab->_roomNum]._southDoor;
else if (*direction == EAST) else if (*direction == EAST)
room = _rooms[g_lab->_roomNum]._eastDoor; room = g_lab->_rooms[g_lab->_roomNum]._eastDoor;
else if (*direction == WEST) else if (*direction == WEST)
room = _rooms[g_lab->_roomNum]._westDoor; room = g_lab->_rooms[g_lab->_roomNum]._westDoor;
if (room == 0) if (room == 0)
return false; return false;
@ -574,11 +572,11 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
action++; action++;
if (lcptr) { if (lcptr) {
RuleList *rules = _rooms[g_lab->_roomNum]._rules; RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
if ((rules == NULL) && (roomNum == 0)) { if ((rules == NULL) && (roomNum == 0)) {
g_lab->_resource->readViews(roomNum); 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) { 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) { static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
if (lcptr) if (lcptr)
if (lcptr->CloseUpType > 0) { if (lcptr->CloseUpType > 0) {
RuleList *rules = _rooms[roomNum]._rules; RuleList *rules = g_lab->_rooms[roomNum]._rules;
if ((rules == NULL) && (roomNum == 0)) { if ((rules == NULL) && (roomNum == 0)) {
g_lab->_resource->readViews(roomNum); 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) { 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. */ /* Goes thru the rules if the user tries to go forward. */
/*****************************************************************************/ /*****************************************************************************/
bool doGoForward(CloseDataPtr *lcptr) { 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) { for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (g_lab->_direction + 1))) { if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (g_lab->_direction + 1))) {
@ -710,7 +708,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
from++; from++;
to++; 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) { for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == TURN) || 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 */ /* Goes thru the rules if the user tries to go to the main view */
/*****************************************************************************/ /*****************************************************************************/
bool doMainView(CloseDataPtr *lcptr) { 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) { for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if ((*rule)->RuleType == GOMAINVIEW) { if ((*rule)->RuleType == GOMAINVIEW) {
if (checkConditions((*rule)->Condition)) { if (checkConditions((*rule)->Condition)) {

View file

@ -34,8 +34,6 @@
namespace Lab { namespace Lab {
extern RoomData *_rooms;
Resource::Resource(LabEngine *vm) : _vm(vm) { Resource::Resource(LabEngine *vm) : _vm(vm) {
readStaticText(); readStaticText();
} }
@ -93,22 +91,22 @@ bool Resource::readRoomData(const char *fileName) {
_vm->_manyRooms = dataFile->readUint16LE(); _vm->_manyRooms = dataFile->readUint16LE();
_vm->_highestCondition = dataFile->readUint16LE(); _vm->_highestCondition = dataFile->readUint16LE();
_rooms = (RoomData *)malloc((_vm->_manyRooms + 1) * sizeof(RoomData)); _vm->_rooms = (RoomData *)malloc((_vm->_manyRooms + 1) * sizeof(RoomData));
memset(_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData)); memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
for (uint16 i = 1; i <= _vm->_manyRooms; i++) { for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
_rooms[i]._northDoor = dataFile->readUint16LE(); _vm->_rooms[i]._northDoor = dataFile->readUint16LE();
_rooms[i]._southDoor = dataFile->readUint16LE(); _vm->_rooms[i]._southDoor = dataFile->readUint16LE();
_rooms[i]._eastDoor = dataFile->readUint16LE(); _vm->_rooms[i]._eastDoor = dataFile->readUint16LE();
_rooms[i]._westDoor = dataFile->readUint16LE(); _vm->_rooms[i]._westDoor = dataFile->readUint16LE();
_rooms[i]._wipeType = dataFile->readByte(); _vm->_rooms[i]._wipeType = dataFile->readByte();
_rooms[i]._view[NORTH] = nullptr; _vm->_rooms[i]._view[NORTH] = nullptr;
_rooms[i]._view[SOUTH] = nullptr; _vm->_rooms[i]._view[SOUTH] = nullptr;
_rooms[i]._view[EAST] = nullptr; _vm->_rooms[i]._view[EAST] = nullptr;
_rooms[i]._view[WEST] = nullptr; _vm->_rooms[i]._view[WEST] = nullptr;
_rooms[i]._rules = nullptr; _vm->_rooms[i]._rules = nullptr;
_rooms[i]._roomMsg = nullptr; _vm->_rooms[i]._roomMsg = nullptr;
} }
delete dataFile; delete dataFile;
@ -136,12 +134,12 @@ bool Resource::readViews(uint16 roomNum) {
Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum); Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
Common::File *dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4')); Common::File *dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4'));
_rooms[roomNum]._roomMsg = readString(dataFile); _vm->_rooms[roomNum]._roomMsg = readString(dataFile);
_rooms[roomNum]._view[NORTH] = readView(dataFile); _vm->_rooms[roomNum]._view[NORTH] = readView(dataFile);
_rooms[roomNum]._view[SOUTH] = readView(dataFile); _vm->_rooms[roomNum]._view[SOUTH] = readView(dataFile);
_rooms[roomNum]._view[EAST] = readView(dataFile); _vm->_rooms[roomNum]._view[EAST] = readView(dataFile);
_rooms[roomNum]._view[WEST] = readView(dataFile); _vm->_rooms[roomNum]._view[WEST] = readView(dataFile);
_rooms[roomNum]._rules = readRule(dataFile); _vm->_rooms[roomNum]._rules = readRule(dataFile);
_vm->_music->updateMusic(); _vm->_music->updateMusic();