LAB: Move RoomNum to main engine class

This commit is contained in:
Strangerke 2015-11-30 01:42:12 +01:00 committed by Willem Jan Palenstijn
parent d0c6c73036
commit 6cee2eb2be
10 changed files with 69 additions and 69 deletions

View file

@ -53,7 +53,7 @@ extern bool DoBlack, waitForEffect, stopsound, DoNotDrawMessage, nopalchange;
extern RoomData *_rooms;
extern InventoryData *Inventory;
extern uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
CloseDataPtr CPtr;
CrumbData BreadCrumbs[MAX_CRUMBS];
@ -528,7 +528,7 @@ bool LabEngine::doUse(uint16 CurInv) {
stopDiff();
CurFileName = " ";
CPtr = NULL;
doMap(RoomNum);
doMap(_roomNum);
VGASetPal(initcolors, 8);
drawMessage(NULL);
drawPanel();
@ -647,7 +647,7 @@ void LabEngine::mainGameLoop() {
VGASetPal(initcolors, 8);
CPtr = NULL;
RoomNum = 1;
_roomNum = 1;
Direction = NORTH;
_resource->readRoomData("LAB:Doors");
@ -693,7 +693,7 @@ void LabEngine::mainGameLoop() {
Test = getPictName(&CPtr);
if (noupdatediff) {
_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
ForceDraw = (strcmp(Test, CurFileName) != 0) || ForceDraw;
noupdatediff = false;
@ -702,7 +702,7 @@ void LabEngine::mainGameLoop() {
else if (strcmp(Test, CurFileName) != 0) {
interfaceOff();
_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
CurFileName = Test;
if (CPtr) {
@ -965,18 +965,18 @@ from_crumbs:
mayShowCrumbIndicator();
WSDL_UpdateScreen();
} else if (GadID == 7) {
OldRoomNum = RoomNum;
OldRoomNum = _roomNum;
if (doGoForward(&CPtr)) {
if (OldRoomNum == RoomNum)
if (OldRoomNum == _roomNum)
DoBlack = true;
} else {
DoBlack = true;
processArrow(&Direction, GadID - 6);
if (OldRoomNum != RoomNum) {
if (OldRoomNum != _roomNum) {
drawStaticMessage(kTextGoForward);
_roomsFound->inclElement(RoomNum); /* Potentially entered a new room */
_roomsFound->inclElement(_roomNum); /* Potentially entered a new room */
CurFileName = " ";
ForceDraw = true;
} else {
@ -991,15 +991,15 @@ from_crumbs:
FollowingCrumbs = false;
}
} else {
if (RoomNum == OldRoomNum) { // didn't get there?
if (_roomNum == OldRoomNum) { // didn't get there?
FollowingCrumbs = false;
}
}
} else if (DroppingCrumbs && OldRoomNum != RoomNum) {
} else if (DroppingCrumbs && OldRoomNum != _roomNum) {
// If in surreal maze, turn off DroppingCrumbs.
// Note: These numbers were generated by parsing the
// "Maps" file, which is why they are hard-coded. Bleh!
if (RoomNum >= 245 && RoomNum <= 280) {
if (_roomNum >= 245 && _roomNum <= 280) {
FollowingCrumbs = false;
DroppingCrumbs = false;
NumCrumbs = 0;
@ -1007,7 +1007,7 @@ from_crumbs:
} else {
bool intersect = false;
for (int idx = 0; idx < NumCrumbs; idx++) {
if (BreadCrumbs[idx].RoomNum == RoomNum) {
if (BreadCrumbs[idx].RoomNum == _roomNum) {
NumCrumbs = idx + 1;
BreadCrumbs[NumCrumbs].RoomNum = 0;
intersect = true;
@ -1020,7 +1020,7 @@ from_crumbs:
memcpy(&BreadCrumbs[0], &BreadCrumbs[1], NumCrumbs * sizeof BreadCrumbs[0]);
}
BreadCrumbs[NumCrumbs].RoomNum = RoomNum;
BreadCrumbs[NumCrumbs].RoomNum = _roomNum;
BreadCrumbs[NumCrumbs++].Direction = Direction;
}
}
@ -1175,11 +1175,11 @@ from_crumbs:
eatMessages();
if (ActionMode == 0) { /* Take something. */
if (doActionRule(Common::Point(curPos.x, curPos.y), ActionMode, RoomNum, &CPtr))
if (doActionRule(Common::Point(curPos.x, curPos.y), ActionMode, _roomNum, &CPtr))
CurFileName = NewFileName;
else if (takeItem(curPos.x, curPos.y, &CPtr))
drawStaticMessage(kTextTakeItem);
else if (doActionRule(curPos, TAKEDEF - 1, RoomNum, &CPtr))
else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &CPtr))
CurFileName = NewFileName;
else if (doActionRule(curPos, TAKE - 1, 0, &CPtr))
CurFileName = NewFileName;
@ -1188,7 +1188,7 @@ from_crumbs:
} else if ((ActionMode == 1) /* Manipulate an object */ ||
(ActionMode == 2) /* Open up a "door" */ ||
(ActionMode == 3)) { /* Close a "door" */
if (doActionRule(curPos, ActionMode, RoomNum, &CPtr))
if (doActionRule(curPos, ActionMode, _roomNum, &CPtr))
CurFileName = NewFileName;
else if (!doActionRule(curPos, ActionMode, 0, &CPtr)) {
if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
@ -1224,7 +1224,7 @@ from_crumbs:
mayShowCrumbIndicator();
WSDL_UpdateScreen();
} else if (Class == DELTAMOVE) {
VPtr = getViewData(RoomNum, Direction);
VPtr = getViewData(_roomNum, Direction);
OldCPtr = VPtr->closeUps;
if (HCPtr == NULL) {
@ -1400,7 +1400,7 @@ int followCrumbs() {
BreadCrumbs[NumCrumbs--].RoomNum = 0;
// Is the current crumb this room? If not, logic error.
if (RoomNum != BreadCrumbs[NumCrumbs].RoomNum) {
if (g_lab->_roomNum != BreadCrumbs[NumCrumbs].RoomNum) {
NumCrumbs = 0;
BreadCrumbs[0].RoomNum = 0;
DroppingCrumbs = false;

View file

@ -73,11 +73,13 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_nextKeyOut = 0;
_isHiRes = false;
_roomNum = -1;
_event = nullptr;
_resource = nullptr;
_music = nullptr;
//const Common::FSNode gameDataDir(ConfMan.get("path"));
//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");

View file

@ -103,6 +103,7 @@ public:
Resource *_resource;
Music *_music;
int _roomNum;
byte *_currentDsplayBuffer;
Common::Point _mousePos;

View file

@ -256,8 +256,8 @@ bool saveRestoreGame();
/*----- From saveGame.c ----*/
/*--------------------------*/
bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Common::String desc);
bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot);
bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc);
bool loadGame(uint16 *Direction, uint16 *Quarters, int slot);
bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
/*--------------------------*/

View file

@ -43,8 +43,6 @@ namespace Lab {
#define CLOWNROOM 123
#define DIMROOM 80
extern uint16 RoomNum; // TODO: Move into a class
Music::Music(LabEngine *vm) : _vm(vm) {
_file = 0;
_tFile = 0;
@ -70,9 +68,9 @@ Music::Music(LabEngine *vm) : _vm(vm) {
/* it from the Audio device. */
/*****************************************************************************/
void Music::updateMusic() {
g_lab->WSDL_ProcessInput(0);
_vm->WSDL_ProcessInput(0);
g_lab->_event->updateMouse();
_vm->_event->updateMouse();
if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
// NOTE: We need to use malloc(), cause this will be freed with free()
@ -89,7 +87,7 @@ void Music::updateMusic() {
}
byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
if (g_lab->getPlatform() == Common::kPlatformWindows)
if (_vm->getPlatform() == Common::kPlatformWindows)
soundFlags |= Audio::FLAG_16BITS;
else
soundFlags |= Audio::FLAG_UNSIGNED;
@ -97,7 +95,7 @@ void Music::updateMusic() {
_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
if (startMusic)
g_lab->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
_vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
}
}
@ -113,7 +111,7 @@ void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
SampleSpeed = 4000;
byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
if (g_lab->getPlatform() == Common::kPlatformWindows)
if (_vm->getPlatform() == Common::kPlatformWindows)
soundFlags |= Audio::FLAG_16BITS;
else
soundFlags |= Audio::FLAG_UNSIGNED;
@ -121,16 +119,16 @@ void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
uint loops = (_loopSoundEffect) ? 0 : 1;
Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
}
void Music::stopSoundEffect() {
if (isSoundEffectActive())
g_lab->_mixer->stopHandle(_sfxHandle);
_vm->_mixer->stopHandle(_sfxHandle);
}
bool Music::isSoundEffectActive() const {
return g_lab->_mixer->isSoundHandleActive(_sfxHandle);
return _vm->_mixer->isSoundHandleActive(_sfxHandle);
}
void Music::fillbuffer(byte *musicBuffer) {
@ -196,10 +194,10 @@ bool Music::initMusic() {
void Music::freeMusic() {
_musicOn = false;
g_lab->_mixer->stopHandle(_musicHandle);
_vm->_mixer->stopHandle(_musicHandle);
_queuingAudioStream = NULL;
g_lab->_mixer->stopHandle(_sfxHandle);
_vm->_mixer->stopHandle(_sfxHandle);
delete _file;
_file = NULL;
@ -214,7 +212,7 @@ void Music::pauseBackMusic() {
_musicOn = false;
stopSoundEffect();
g_lab->_mixer->pauseHandle(_musicHandle, true);
_vm->_mixer->pauseHandle(_musicHandle, true);
_musicPaused = true;
}
@ -228,7 +226,7 @@ void Music::resumeBackMusic() {
stopSoundEffect();
_musicOn = true;
g_lab->_mixer->pauseHandle(_musicHandle, false);
_vm->_mixer->pauseHandle(_musicHandle, false);
updateMusic();
_musicPaused = false;
@ -255,17 +253,17 @@ void Music::setMusic(bool on) {
/* Checks the music that should be playing in a particular room. */
/******************************************************************************/
void Music::checkRoomMusic() {
if ((_lastMusicRoom == RoomNum) || !_musicOn)
if ((_lastMusicRoom == _vm->_roomNum) || !_musicOn)
return;
if (RoomNum == CLOWNROOM)
if (_vm->_roomNum == CLOWNROOM)
changeMusic("Music:Laugh");
else if (RoomNum == DIMROOM)
else if (_vm->_roomNum == DIMROOM)
changeMusic("Music:Rm81");
else if (_doReset)
resetMusic();
_lastMusicRoom = RoomNum;
_lastMusicRoom = _vm->_roomNum;
}
/*****************************************************************************/

View file

@ -49,7 +49,6 @@ static TextFont bmf;
extern uint16 Direction;
extern CloseDataPtr CPtr;
extern uint16 RoomNum;
/*****************************************************************************/
/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */

View file

@ -47,7 +47,7 @@ namespace Lab {
RoomData *_rooms;
InventoryData *Inventory;
uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
uint16 NumInv, ManyRooms, HighestCondition, Direction;
const char *NewFileName;
extern bool DoNotDrawMessage, IsBM, noupdatediff, QuitLab, MusicOn, DoBlack, LongWinInFront;
@ -124,7 +124,7 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr LCPtr) {
ViewData *VPtr;
if (LCPtr == NULL) {
VPtr = getViewData(RoomNum, Direction);
VPtr = getViewData(g_lab->_roomNum, Direction);
LCPtr = VPtr->closeUps;
}
@ -173,7 +173,7 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
/* Returns the current picture name. */
/*****************************************************************************/
char *getPictName(CloseDataPtr *LCPtr) {
ViewData *ViewPtr = getViewData(RoomNum, Direction);
ViewData *ViewPtr = getViewData(g_lab->_roomNum, Direction);
if (*LCPtr != NULL) {
*LCPtr = findCPtrMatch(*LCPtr, ViewPtr->closeUps);
@ -196,8 +196,8 @@ void LabEngine::drawDirection(CloseDataPtr LCPtr) {
Common::String message;
if (_rooms[RoomNum]._roomMsg) {
message += _rooms[RoomNum]._roomMsg;
if (_rooms[_roomNum]._roomMsg) {
message += _rooms[_roomNum]._roomMsg;
message += ", ";
}
@ -221,18 +221,18 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
if (Arrow == 1) { /* Forward */
if (*direction == NORTH)
room = _rooms[RoomNum]._northDoor;
room = _rooms[g_lab->_roomNum]._northDoor;
else if (*direction == SOUTH)
room = _rooms[RoomNum]._southDoor;
room = _rooms[g_lab->_roomNum]._southDoor;
else if (*direction == EAST)
room = _rooms[RoomNum]._eastDoor;
room = _rooms[g_lab->_roomNum]._eastDoor;
else if (*direction == WEST)
room = _rooms[RoomNum]._westDoor;
room = _rooms[g_lab->_roomNum]._westDoor;
if (room == 0)
return false;
else
RoomNum = room;
g_lab->_roomNum = room;
} else if (Arrow == 0) { /* Left */
if (*direction == NORTH)
*direction = WEST;
@ -265,7 +265,7 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
uint16 x1, y1, x2, y2;
if (*cptr == NULL) {
VPtr = getViewData(RoomNum, Direction);
VPtr = getViewData(g_lab->_roomNum, Direction);
LCPtr = VPtr->closeUps;
} else
LCPtr = (*cptr)->SubCloseUps;
@ -300,7 +300,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
CloseDataPtr LCPtr;
if (*cptr == NULL) {
VPtr = getViewData(RoomNum, Direction);
VPtr = getViewData(g_lab->_roomNum, Direction);
LCPtr = VPtr->closeUps;
} else if ((*cptr)->CloseUpType < 0) {
g_lab->_conditions->inclElement(abs((*cptr)->CloseUpType));
@ -443,7 +443,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
continue;
}
RoomNum = APtr->Param1;
g_lab->_roomNum = APtr->Param1;
Direction = APtr->Param2 - 1;
*LCPtr = NULL;
DoBlack = true;
@ -611,7 +611,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
action++;
if (LCPtr) {
RuleList *rules = _rooms[RoomNum]._rules;
RuleList *rules = _rooms[g_lab->_roomNum]._rules;
if ((rules == NULL) && (roomNum == 0)) {
g_lab->_resource->readViews(roomNum);
@ -700,13 +700,13 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
TLCPtr = getObject(x, y, *LCPtr);
if (doOperateRuleSub(ItemNum, RoomNum, TLCPtr, LCPtr, false))
if (doOperateRuleSub(ItemNum, g_lab->_roomNum, TLCPtr, LCPtr, false))
return true;
else if (doOperateRuleSub(ItemNum, RoomNum, *LCPtr, LCPtr, false))
else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *LCPtr, LCPtr, false))
return true;
else if (doOperateRuleSub(ItemNum, RoomNum, TLCPtr, LCPtr, true))
else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, TLCPtr, LCPtr, true))
return true;
else if (doOperateRuleSub(ItemNum, RoomNum, *LCPtr, LCPtr, true))
else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *LCPtr, LCPtr, true))
return true;
else {
NewFileName = CurFileName;
@ -728,7 +728,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[RoomNum]._rules;
RuleList *rules = _rooms[g_lab->_roomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
@ -749,7 +749,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
from++;
to++;
RuleList *rules = _rooms[RoomNum]._rules;
RuleList *rules = _rooms[g_lab->_roomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == TURN) ||
@ -769,7 +769,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[RoomNum]._rules;
RuleList *rules = _rooms[g_lab->_roomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if ((*rule)->RuleType == GOMAINVIEW) {
if (checkConditions((*rule)->Condition)) {

View file

@ -132,7 +132,7 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
/*****************************************************************************/
/* Writes the game out to disk. */
/*****************************************************************************/
bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Common::String desc) {
bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc) {
uint16 i, j;
Common::String fileName = g_lab->generateSaveFileName(slot);
Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
@ -146,7 +146,7 @@ bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Commo
readPict(getPictName(&CPtr), true);
writeSaveGameHeader(file, desc);
file->writeUint16LE(RoomNum);
file->writeUint16LE(g_lab->_roomNum);
file->writeUint16LE(Direction);
file->writeUint16LE(Quarters);
@ -185,7 +185,7 @@ bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Commo
/*****************************************************************************/
/* Reads the game from disk. */
/*****************************************************************************/
bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot) {
bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
uint16 i, j;
Common::String fileName = g_lab->generateSaveFileName(slot);
Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
@ -196,7 +196,7 @@ bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot) {
SaveGameHeader header;
readSaveGameHeader(file, header);
*RoomNum = file->readUint16LE();
g_lab->_roomNum = file->readUint16LE();
*Direction = file->readUint16LE();
*Quarters = file->readUint16LE();

View file

@ -90,7 +90,7 @@ extern BitMap *DispBitMap, *DrawBitMap;
extern char diffcmap[3 * 256];
extern CloseDataPtr CPtr;
extern InventoryData *Inventory;
extern uint16 RoomNum, Direction;
extern uint16 Direction;
#define COMBINATIONUNLOCKED 130
#define BRICKOPEN 115
@ -828,14 +828,14 @@ bool saveRestoreGame() {
desc = dialog->createDefaultSaveDescription(slot);
}
isOK = saveGame(RoomNum, 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(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot);
isOK = loadGame(&Direction, &(Inventory[QUARTERNUM].Many), slot);
if (isOK)
g_lab->_music->resetMusic();
}

View file

@ -73,7 +73,7 @@ uint16 textHeight(struct TextFont *tf) {
/*****************************************************************************/
/* Draws the text to the screen. */
/*****************************************************************************/
void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata;
uint32 RealOffset, SegmentOffset;
int32 templeft, LeftInSegment;