aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2015-11-30 00:34:43 +0100
committerWillem Jan Palenstijn2015-12-23 21:33:44 +0100
commit771e558d905ee467280482d62697dc66d969ed2b (patch)
treee9eeada2ac2552d74c7213b00ef45270721b0a6e /engines
parent0c84355f4ae5651e7667b9aa0d2d3c6c28f21496 (diff)
downloadscummvm-rg350-771e558d905ee467280482d62697dc66d969ed2b.tar.gz
scummvm-rg350-771e558d905ee467280482d62697dc66d969ed2b.tar.bz2
scummvm-rg350-771e558d905ee467280482d62697dc66d969ed2b.zip
LAB: Move the global variable g_resource to the main engine class
Diffstat (limited to 'engines')
-rw-r--r--engines/lab/engine.cpp10
-rw-r--r--engines/lab/graphics.cpp4
-rw-r--r--engines/lab/intro.cpp2
-rw-r--r--engines/lab/lab.cpp9
-rw-r--r--engines/lab/lab.h3
-rw-r--r--engines/lab/labfun.h8
-rw-r--r--engines/lab/labsets.cpp5
-rw-r--r--engines/lab/map.cpp22
-rw-r--r--engines/lab/processroom.cpp14
-rw-r--r--engines/lab/resource.cpp4
-rw-r--r--engines/lab/resource.h5
-rw-r--r--engines/lab/special.cpp12
12 files changed, 56 insertions, 42 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index e246d6d9be..d7561d1e8f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -650,13 +650,13 @@ void LabEngine::mainGameLoop() {
RoomNum = 1;
Direction = NORTH;
- g_resource->readRoomData("LAB:Doors");
- g_resource->readInventory("LAB:Inventor");
+ _resource->readRoomData("LAB:Doors");
+ _resource->readInventory("LAB:Inventor");
- if (!(_conditions = new LargeSet(HighestCondition + 1)))
+ if (!(_conditions = new LargeSet(HighestCondition + 1, this)))
return;
- if (!(_roomsFound = new LargeSet(ManyRooms + 1)))
+ if (!(_roomsFound = new LargeSet(ManyRooms + 1, this)))
return;
_conditions->readInitialConditions("LAB:Conditio");
@@ -1328,7 +1328,7 @@ void LabEngine::go() {
if (!dointro)
g_music->initMusic();
- MsgFont = g_resource->getFont("P:AvanteG.12");
+ MsgFont = _resource->getFont("P:AvanteG.12");
_event->mouseHide();
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 218f3c66d4..80d78edfbe 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -93,7 +93,7 @@ bool readPict(const char *filename, bool PlayOnce) {
/* Reads in a music file. Ignores any graphics. */
/*****************************************************************************/
bool readMusic(const char *filename, bool waitTillFinished) {
- Common::File *file = g_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
+ Common::File *file = g_lab->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
g_music->updateMusic();
if (!g_music->_doNotFilestopSoundEffect)
g_music->stopSoundEffect();
@@ -360,7 +360,7 @@ int32 LabEngine::longDrawMessage(const char *str) {
}
void LabEngine::drawStaticMessage(byte index) {
- drawMessage(g_resource->getStaticText((StaticText)index).c_str());
+ drawMessage(_resource->getStaticText((StaticText)index).c_str());
}
/******************************************************************************/
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 269922bbb3..7cbe48c044 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -347,7 +347,7 @@ void Intro::introSequence() {
blackAllScreen();
g_music->updateMusic();
- _msgfont = g_resource->getFont("P:Map.fon");
+ _msgfont = g_lab->_resource->getFont("P:Map.fon");
nopalchange = true;
nReadPict("Intro.1", true);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index b2e779f07e..3792f2b0d3 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -73,6 +73,10 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_nextKeyOut = 0;
_isHiRes = false;
+
+ _event = nullptr;
+ _resource = nullptr;
+
//const Common::FSNode gameDataDir(ConfMan.get("path"));
//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
@@ -83,6 +87,9 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
LabEngine::~LabEngine() {
// Remove all of our debug levels here
DebugMan.clearAllDebugChannels();
+
+ delete _event;
+ delete _resource;
}
Common::Error LabEngine::run() {
@@ -92,9 +99,9 @@ Common::Error LabEngine::run() {
initGraphics(640, 480, true);
_event = new EventManager(this);
+ _resource = new Resource(this);
g_music = new Music();
- g_resource = new Resource();
if (getPlatform() == Common::kPlatformWindows) {
// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 8ead009fd7..7e7f645167 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -38,6 +38,7 @@
#include "lab/labfun.h"
#include "lab/interface.h"
#include "lab/mouse.h"
+#include "lab/resource.h"
struct ADGameDescription;
@@ -99,6 +100,8 @@ private:
public:
EventManager *_event;
+ Resource *_resource;
+
byte *_currentDsplayBuffer;
Common::Point _mousePos;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index f602d6007a..dd4796a2d0 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -47,6 +47,8 @@
namespace Lab {
+class LabEngine;
+
/* Direction defines */
#define NORTH 0
#define SOUTH 1
@@ -209,12 +211,16 @@ extern Music *g_music;
class LargeSet {
public:
- LargeSet(uint16 last);
+ LargeSet(uint16 last, LabEngine *vm);
~LargeSet();
bool in(uint16 element);
void inclElement(uint16 element);
void exclElement(uint16 element);
bool readInitialConditions(const char *fileName);
+
+private:
+ LabEngine *_vm;
+
public:
uint16 _lastElement;
uint16 *_array;
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 4dcc0c8ebc..edd764668b 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -28,13 +28,14 @@
*
*/
+#include "lab/lab.h"
#include "lab/stddefines.h"
#include "lab/labfun.h"
#include "lab/resource.h"
namespace Lab {
-LargeSet::LargeSet(uint16 last) {
+ LargeSet::LargeSet(uint16 last, LabEngine *vm) : _vm(vm) {
last = (((last + 15) >> 4) << 4);
_array = (uint16 *)calloc(last >> 3, 2);
@@ -60,7 +61,7 @@ void LargeSet::exclElement(uint16 element) {
bool LargeSet::readInitialConditions(const char *fileName) {
Common::File *file;
- if (file = g_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0'))) {
+ if (file = _vm->_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0'))) {
uint16 conditions = file->readUint16LE();
for (int i = 0; i < conditions; i++) {
inclElement(file->readUint16LE());
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index e4b8b3258a..e4a6f04c74 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -196,7 +196,7 @@ static bool loadMapData() {
BigMsgFont = &bmf;
- if (!(BigMsgFont = g_resource->getFont("P:Map.fon")))
+ if (!(BigMsgFont = g_lab->_resource->getFont("P:Map.fon")))
BigMsgFont = MsgFont;
resetBuffer(); /* Make images load into start of buffer */
@@ -249,7 +249,7 @@ static bool loadMapData() {
counter++;
}
- Common::File *mapFile = g_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
+ Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
if (!mapFile)
error("Corrupt map file");
g_music->updateMusic();
@@ -611,31 +611,31 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
if (onFloor(HEDGEMAZEFLOOR))
drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
} else if (Floor == SURMAZEFLOOR) {
- sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str();
+ sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
}
switch (Floor) {
case LOWERFLOOR:
- sptr = (char *)g_resource->getStaticText(kTextLowerFloor).c_str();
+ sptr = (char *)_resource->getStaticText(kTextLowerFloor).c_str();
break;
case MIDDLEFLOOR:
- sptr = (char *)g_resource->getStaticText(kTextMiddleFloor).c_str();
+ sptr = (char *)_resource->getStaticText(kTextMiddleFloor).c_str();
break;
case UPPERFLOOR:
- sptr = (char *)g_resource->getStaticText(kTextUpperFloor).c_str();
+ sptr = (char *)_resource->getStaticText(kTextUpperFloor).c_str();
break;
case MEDMAZEFLOOR:
- sptr = (char *)g_resource->getStaticText(kTextMedMazeFloor).c_str();
+ sptr = (char *)_resource->getStaticText(kTextMedMazeFloor).c_str();
break;
case HEDGEMAZEFLOOR:
- sptr = (char *)g_resource->getStaticText(kTextHedgeMazeFloor).c_str();
+ sptr = (char *)_resource->getStaticText(kTextHedgeMazeFloor).c_str();
break;
case SURMAZEFLOOR:
- sptr = (char *)g_resource->getStaticText(kTextSurMazeFloor).c_str();
+ sptr = (char *)_resource->getStaticText(kTextSurMazeFloor).c_str();
break;
case CARNIVAL:
- sptr = (char *)g_resource->getStaticText(kTextCarnivalFloor).c_str();
+ sptr = (char *)_resource->getStaticText(kTextCarnivalFloor).c_str();
break;
default:
sptr = NULL;
@@ -795,7 +795,7 @@ void LabEngine::processMap(uint16 CurRoom) {
if (OldMsg != CurMsg) {
if (_rooms[CurMsg]._roomMsg == nullptr)
- g_resource->readViews(CurMsg);
+ _resource->readViews(CurMsg);
if ((sptr = _rooms[CurMsg]._roomMsg)) {
_event->mouseHide();
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 1932d486d4..ef1a8011e1 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -96,7 +96,7 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
ViewData *view = NULL;
if (!_rooms[roomNum]._roomMsg)
- g_resource->readViews(roomNum);
+ g_lab->_resource->readViews(roomNum);
if (direction == NORTH)
view = _rooms[roomNum]._northView;
@@ -202,13 +202,13 @@ void LabEngine::drawDirection(CloseDataPtr LCPtr) {
}
if (Direction == NORTH)
- message += g_resource->getStaticText(kTextFacingNorth);
+ message += _resource->getStaticText(kTextFacingNorth);
else if (Direction == EAST)
- message += g_resource->getStaticText(kTextFacingEast);
+ message += _resource->getStaticText(kTextFacingEast);
else if (Direction == SOUTH)
- message += g_resource->getStaticText(kTextFacingSouth);
+ message += _resource->getStaticText(kTextFacingSouth);
else if (Direction == WEST)
- message += g_resource->getStaticText(kTextFacingWest);
+ message += _resource->getStaticText(kTextFacingWest);
drawMessage(message.c_str());
}
@@ -614,7 +614,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
RuleList *rules = _rooms[RoomNum]._rules;
if ((rules == NULL) && (roomNum == 0)) {
- g_resource->readViews(roomNum);
+ g_lab->_resource->readViews(roomNum);
rules = _rooms[roomNum]._rules;
}
@@ -671,7 +671,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
RuleList *rules = _rooms[roomNum]._rules;
if ((rules == NULL) && (roomNum == 0)) {
- g_resource->readViews(roomNum);
+ g_lab->_resource->readViews(roomNum);
rules = _rooms[roomNum]._rules;
}
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 2f11515db2..5e6fe290df 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -39,9 +39,7 @@ extern RoomData *_rooms;
extern InventoryData *Inventory;
extern uint16 NumInv, ManyRooms, HighestCondition;
-Resource *g_resource;
-
-Resource::Resource() {
+Resource::Resource(LabEngine *vm) : _vm(vm) {
readStaticText();
}
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index d41859e9f5..841aa09564 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -95,7 +95,7 @@ enum StaticText {
class Resource {
public:
- Resource();
+ Resource(LabEngine *vm);
~Resource() {}
Common::File *openDataFile(const char * fileName, uint32 fileHeader);
@@ -106,6 +106,7 @@ public:
Common::String getStaticText(byte index) const { return _staticText[index]; }
private:
+ LabEngine *_vm;
char *readString(Common::File *file);
int16 *readConditions(Common::File *file);
RuleList *readRule(Common::File *file);
@@ -117,8 +118,6 @@ private:
Common::String _staticText[48];
};
-extern Resource *g_resource;
-
} // End of namespace Lab
#endif /* LAB_RESOURCE_H */
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 96f7bfd1ac..eaa9ef2755 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -461,7 +461,7 @@ void doNotes() {
/* Load in the data */
BigMsgFont = &bmfont;
- if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) {
+ if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) {
BigMsgFont = NULL;
return;
}
@@ -487,7 +487,7 @@ void doWestPaper() {
BigMsgFont = &bmfont;
- if (!(BigMsgFont = g_resource->getFont("P:News22.fon"))) {
+ if (!(BigMsgFont = g_lab->_resource->getFont("P:News22.fon"))) {
BigMsgFont = NULL;
return;
}
@@ -499,7 +499,7 @@ void doWestPaper() {
BigMsgFont = &bmfont;
- if (!(BigMsgFont = g_resource->getFont("P:News32.fon"))) {
+ if (!(BigMsgFont = g_lab->_resource->getFont("P:News32.fon"))) {
BigMsgFont = NULL;
return;
}
@@ -518,7 +518,7 @@ void doWestPaper() {
BigMsgFont = &bmfont;
- if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) {
+ if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) {
BigMsgFont = NULL;
return;
}
@@ -548,7 +548,7 @@ static bool loadJournalData() {
BigMsgFont = &bmfont;
- if (!(BigMsgFont = g_resource->getFont("P:Journal.fon"))) {
+ if (!(BigMsgFont = g_lab->_resource->getFont("P:Journal.fon"))) {
BigMsgFont = NULL;
return false;
}
@@ -1047,7 +1047,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
BigMsgFont = &bmfont;
- if (!(BigMsgFont = g_resource->getFont("P:Map.fon"))) {
+ if (!(BigMsgFont = _resource->getFont("P:Map.fon"))) {
freeAllStolenMem();
BigMsgFont = NULL;
return;