aboutsummaryrefslogtreecommitdiff
path: root/engines/lab
diff options
context:
space:
mode:
authorFilippos Karapetis2015-12-23 01:32:12 +0200
committerWillem Jan Palenstijn2015-12-23 21:35:35 +0100
commitced5b677f63dcb53fc0606bf9578b1fff6981075 (patch)
tree953f3528751ca839ad5df81d31cd811e6d02046a /engines/lab
parentf59ccf534cc357d4cde1889fc9ff3ad852d73360 (diff)
downloadscummvm-rg350-ced5b677f63dcb53fc0606bf9578b1fff6981075.tar.gz
scummvm-rg350-ced5b677f63dcb53fc0606bf9578b1fff6981075.tar.bz2
scummvm-rg350-ced5b677f63dcb53fc0606bf9578b1fff6981075.zip
LAB: Add enums for action types, rule types ad rule actions
Diffstat (limited to 'engines/lab')
-rw-r--r--engines/lab/engine.cpp4
-rw-r--r--engines/lab/processroom.cpp80
-rw-r--r--engines/lab/processroom.h115
-rw-r--r--engines/lab/resource.cpp6
4 files changed, 104 insertions, 101 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 4a977d8a41..3350dd74a2 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1023,9 +1023,9 @@ void LabEngine::performAction(uint16 actionMode, Common::Point curPos, uint16 &c
_curFileName = _newFileName;
else if (takeItem(curPos, &_closeDataPtr))
drawStaticMessage(kTextTakeItem);
- else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_closeDataPtr))
+ else if (doActionRule(curPos, kRuleActionTakeDef, _roomNum, &_closeDataPtr))
_curFileName = _newFileName;
- else if (doActionRule(curPos, TAKE - 1, 0, &_closeDataPtr))
+ else if (doActionRule(curPos, kRuleActionTake, 0, &_closeDataPtr))
_curFileName = _newFileName;
else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
drawStaticMessage(kTextNothing);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 71f53e1020..2e37847346 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -238,53 +238,53 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
updateMusicAndEvents();
switch (actionList->_actionType) {
- case PLAYSOUND:
+ case kActionPlaySound:
_music->_loopSoundEffect = false;
_music->_waitTillFinished = true;
_music->readMusic(actionList->_messages[0], true);
_music->_waitTillFinished = false;
break;
- case PLAYSOUNDB:
+ case kActionPlaySoundNoWait:
_music->_loopSoundEffect = false;
_music->_waitTillFinished = false;
_music->readMusic(actionList->_messages[0], false);
break;
- case PLAYSOUNDCONT:
+ case kActionPlaySoundLooping:
_music->_loopSoundEffect = true;
_music->readMusic(actionList->_messages[0], _music->_waitTillFinished);
break;
- case SHOWDIFF:
+ case kActionShowDiff:
_graphics->readPict(actionList->_messages[0], true);
break;
- case SHOWDIFFCONT:
+ case kActionShowDiffLooping:
_graphics->readPict(actionList->_messages[0], false);
break;
- case LOADDIFF:
+ case kActionLoadDiff:
if (!actionList->_messages[0].empty())
// Puts a file into memory
_graphics->loadPict(actionList->_messages[0]);
break;
- case TRANSITION:
+ case kActionTransition:
_graphics->doTransition((TransitionType)actionList->_param1, closePtrList, actionList->_messages[0].c_str());
break;
- case NOUPDATE:
+ case kActionNoUpdate:
_noUpdateDiff = true;
_anim->_doBlack = false;
break;
- case FORCEUPDATE:
+ case kActionForceUpdate:
_curFileName = " ";
break;
- case SHOWCURPICT: {
+ case kActionShowCurPict: {
Common::String test = getPictName(closePtrList);
if (test != _curFileName) {
@@ -294,31 +294,31 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
}
break;
- case SETELEMENT:
+ case kActionSetElement:
_conditions->inclElement(actionList->_param1);
break;
- case UNSETELEMENT:
+ case kActionUnsetElement:
_conditions->exclElement(actionList->_param1);
break;
- case SHOWMESSAGE:
+ case kActionShowMessage:
if (_graphics->_longWinInFront)
_graphics->longDrawMessage(actionList->_messages[0]);
else
_graphics->drawMessage(actionList->_messages[0]);
break;
- case CSHOWMESSAGE:
+ case kActionCShowMessage:
if (!*closePtrList)
_graphics->drawMessage(actionList->_messages[0]);
break;
- case SHOWMESSAGES:
+ case kActionShowMessages:
_graphics->drawMessage(actionList->_messages[_utils->getRandom(actionList->_param1)]);
break;
- case SETPOSITION:
+ case kActionChangeRoom:
if (actionList->_param1 & 0x8000) {
// This is a Wyrmkeep Windows trial version, thus stop at this
// point, since we can't check for game payment status
@@ -335,7 +335,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
_anim->_doBlack = true;
break;
- case SETCLOSEUP: {
+ case kActionSetCloseup: {
Common::Point curPos = Common::Point(_utils->scaleX(actionList->_param1), _utils->scaleY(actionList->_param2));
CloseDataPtr tmpClosePtr = getObject(curPos, *closePtrList);
@@ -344,11 +344,11 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
}
break;
- case MAINVIEW:
+ case kActionMainView:
*closePtrList = nullptr;
break;
- case SUBINV:
+ case kActionSubInv:
if (_inventory[actionList->_param1]._quantity)
(_inventory[actionList->_param1]._quantity)--;
@@ -357,12 +357,12 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
break;
- case ADDINV:
+ case kActionAddInv:
(_inventory[actionList->_param1]._quantity) += actionList->_param2;
_conditions->inclElement(actionList->_param1);
break;
- case SHOWDIR:
+ case kActionShowDir:
// Originally, this set _doNotDrawMessage to false, so that the
// message would be shown by drawMessage(). However, _doNotDrawMEssage
// ended up hiding subsequent game messages, so this call is actually
@@ -370,7 +370,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
// side-effects.
break;
- case WAITSECS: {
+ case kActionWaitSecs: {
uint32 targetMillis = g_system->getMillis() + actionList->_param1 * 1000;
_graphics->screenUpdate();
@@ -382,29 +382,29 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
}
break;
- case STOPMUSIC:
+ case kActionStopMusic:
_music->setMusic(false);
break;
- case STARTMUSIC:
+ case kActionStartMusic:
_music->setMusic(true);
break;
- case CHANGEMUSIC:
+ case kActionChangeMusic:
_music->changeMusic(actionList->_messages[0]);
_music->setMusicReset(false);
break;
- case RESETMUSIC:
+ case kActionResetMusic:
_music->resetMusic();
_music->setMusicReset(true);
break;
- case FILLMUSIC:
+ case kActionFillMusic:
updateMusicAndEvents();
break;
- case WAITSOUND:
+ case kActionWaitSound:
while (_music->isSoundEffectActive()) {
updateMusicAndEvents();
_anim->diffNextFrame();
@@ -413,7 +413,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
break;
- case CLEARSOUND:
+ case kActionClearSound:
if (_music->_loopSoundEffect) {
_music->_loopSoundEffect = false;
_music->stopSoundEffect();
@@ -422,26 +422,26 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
break;
- case WINMUSIC:
+ case kActionWinMusic:
_music->freeMusic();
_music->initMusic("Music:WinGame");
break;
- case WINGAME:
+ case kActionWinGame:
_quitLab = true;
showLab2Teaser();
break;
- case LOSTGAME:
+ case kActionLostGame:
// This seems to be unused?
error("Unused opcode LOSTGAME has been called");
break;
- case RESETBUFFER:
+ case kActionResetBuffer:
_graphics->freePict();
break;
- case SPECIALCMD:
+ case kActionSpecialCmd:
if (actionList->_param1 == 0)
_anim->_doBlack = true;
else if (actionList->_param1 == 1)
@@ -505,7 +505,7 @@ bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closeP
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
- if ((rule->_ruleType == ACTION) &&
+ if ((rule->_ruleType == kRuleTypeAction) &&
((rule->_param1 == action) || ((rule->_param1 == 0) && allowDefaults))) {
if (((rule->_param2 == closePtr->_closeUpType) ||
((rule->_param2 == 0) && allowDefaults)) ||
@@ -553,7 +553,7 @@ bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr clos
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
- if ((rule->_ruleType == OPERATE) &&
+ if ((rule->_ruleType == kRuleTypeOperate) &&
((rule->_param1 == itemNum) || ((rule->_param1 == 0) && allowDefaults)) &&
((rule->_param2 == closePtr->_closeUpType) || ((rule->_param2 == 0) && allowDefaults))) {
if (checkConditions(rule->_condition)) {
@@ -599,7 +599,7 @@ bool LabEngine::doGoForward(CloseDataPtr *closePtrList) {
RuleList *rules = _rooms[_roomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
- if ((rule->_ruleType == GOFORWARD) && (rule->_param1 == (_direction + 1))) {
+ if ((rule->_ruleType == kRuleTypeGoForward) && (rule->_param1 == (_direction + 1))) {
if (checkConditions(rule->_condition)) {
doActions(rule->_actionList, closePtrList);
return true;
@@ -617,8 +617,8 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
RuleList *rules = _rooms[_roomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
- if ((rule->_ruleType == TURN) ||
- ((rule->_ruleType == TURNFROMTO) &&
+ if ((rule->_ruleType == kRuleTypeTurn) ||
+ ((rule->_ruleType == kRuleTypeTurnFromTo) &&
(rule->_param1 == from) && (rule->_param2 == to))) {
if (checkConditions(rule->_condition)) {
doActions(rule->_actionList, closePtrList);
@@ -633,7 +633,7 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
bool LabEngine::doMainView(CloseDataPtr *closePtrList) {
RuleList *rules = _rooms[_roomNum]._rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
- if (rule->_ruleType == GOMAINVIEW) {
+ if (rule->_ruleType == kRuleTypeGoMainView) {
if (checkConditions(rule->_condition)) {
doActions(rule->_actionList, closePtrList);
return true;
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index 60f696b7c2..9cdada2bfa 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -33,59 +33,63 @@
namespace Lab {
-//------------------------------- Action types ------------------------------
-#define PLAYSOUND 1
-#define PLAYSOUNDCONT 2
-#define SHOWDIFF 3
-#define SHOWDIFFCONT 4
-#define LOADDIFF 5
-#define LOADBM 6
-#define SHOWBM 7
-#define TRANSITION 8
-#define NOUPDATE 9
-#define FORCEUPDATE 10
-#define SHOWCURPICT 11
-#define SETELEMENT 12
-#define UNSETELEMENT 13
-#define SHOWMESSAGE 14
-#define SHOWMESSAGES 15
-#define SETPOSITION 16
-#define SETCLOSEUP 17
-#define MAINVIEW 18
-#define SUBINV 19
-#define ADDINV 20
-#define SHOWDIR 21
-#define WAITSECS 22
-#define STOPMUSIC 23
-#define STARTMUSIC 24
-#define CHANGEMUSIC 25
-#define RESETMUSIC 26
-#define FILLMUSIC 27
-#define WAITSOUND 28
-#define CLEARSOUND 29
-#define WINMUSIC 30
-#define WINGAME 31
-#define LOSTGAME 32
-#define RESETBUFFER 33
-#define SPECIALCMD 34
-#define CSHOWMESSAGE 35
-#define PLAYSOUNDB 36
-
-// Rule Types
-#define ACTION 1
-#define OPERATE 2
-#define GOFORWARD 3
-#define CONDITIONS 4
-#define TURN 5
-#define GOMAINVIEW 6
-#define TURNFROMTO 7
-
-//----------------------------- Rule Type Action ----------------------------
-#define TAKE 1
-#define MOVE 2
-#define OPENDOOR 3
-#define CLOSEDOOR 4
-#define TAKEDEF 5
+enum ActionType {
+ kActionPlaySound = 1,
+ kActionPlaySoundLooping = 2,
+ kActionShowDiff = 3,
+ kActionShowDiffLooping = 4,
+ kActionLoadDiff = 5,
+ kActionLoadBitmap = 6, // unused?
+ kActionShowBitmap = 7, // unused?
+ kActionTransition = 8,
+ kActionNoUpdate = 9,
+ kActionForceUpdate = 10,
+ kActionShowCurPict = 11,
+ kActionSetElement = 12,
+ kActionUnsetElement = 13,
+ kActionShowMessage = 14,
+ kActionShowMessages = 15,
+ kActionChangeRoom = 16,
+ kActionSetCloseup = 17,
+ kActionMainView = 18,
+ kActionSubInv = 19,
+ kActionAddInv = 20,
+ kActionShowDir = 21,
+ kActionWaitSecs = 22,
+ kActionStopMusic = 23,
+ kActionStartMusic = 24,
+ kActionChangeMusic = 25,
+ kActionResetMusic = 26,
+ kActionFillMusic = 27,
+ kActionWaitSound = 28,
+ kActionClearSound = 29,
+ kActionWinMusic = 30,
+ kActionWinGame = 31,
+ kActionLostGame = 32,
+ kActionResetBuffer = 33,
+ kActionSpecialCmd = 34,
+ kActionCShowMessage = 35,
+ kActionPlaySoundNoWait = 36
+};
+
+enum RuleType {
+ kRuleTypeNone = 0,
+ kRuleTypeAction = 1,
+ kRuleTypeOperate = 2,
+ kRuleTypeGoForward = 3,
+ kRuleTypeConditions = 4, // unused?
+ kRuleTypeTurn = 5,
+ kRuleTypeGoMainView = 6,
+ kRuleTypeTurnFromTo = 7
+};
+
+enum RuleAction {
+ kRuleActionTake = 0,
+ kRuleActionMove = 1, // unused?
+ kRuleActionOpenDoor = 2, // unused?
+ kRuleActionCloseDoor = 3, // unused?
+ kRuleActionTakeDef = 4
+};
#if defined(WIN32)
#pragma pack(push, 1)
@@ -109,7 +113,7 @@ struct ViewData {
};
struct Action {
- int16 _actionType;
+ ActionType _actionType;
int16 _param1;
int16 _param2;
int16 _param3;
@@ -118,12 +122,11 @@ struct Action {
};
struct Rule {
- int16 _ruleType;
+ RuleType _ruleType;
int16 _param1;
int16 _param2;
int16 *_condition;
Action *_actionList;
- Rule *_nextRule;
};
struct RoomData {
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 1063fd5f1b..6e2559d82d 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -265,7 +265,7 @@ RuleList *Resource::readRule(Common::File *file) {
if (c == 1) {
Rule rule;
- rule._ruleType = file->readSint16LE();
+ rule._ruleType = (RuleType)file->readSint16LE();
rule._param1 = file->readSint16LE();
rule._param2 = file->readSint16LE();
rule._condition = readConditions(file);
@@ -305,12 +305,12 @@ Action *Resource::readAction(Common::File *file) {
head = action;
if (prev)
prev->_nextAction = action;
- action->_actionType = file->readSint16LE();
+ action->_actionType = (ActionType)file->readSint16LE();
action->_param1 = file->readSint16LE();
action->_param2 = file->readSint16LE();
action->_param3 = file->readSint16LE();
- if (action->_actionType == SHOWMESSAGES) {
+ if (action->_actionType == kActionShowMessages) {
action->_messages = new Common::String[action->_param1];
for (int i = 0; i < action->_param1; i++)