diff options
author | Marisa-Chan | 2013-11-25 13:30:29 +0000 |
---|---|---|
committer | Marisa-Chan | 2013-11-25 13:30:29 +0000 |
commit | 1dbb6e807a3b70fc1cdcf7ff1a4949fc69913a05 (patch) | |
tree | 48e9a2cce02829a260a59bc8a605e23b8086879d /engines | |
parent | 4cb006f2602199a3f201f918392f3e66a385df0e (diff) | |
download | scummvm-rg350-1dbb6e807a3b70fc1cdcf7ff1a4949fc69913a05.tar.gz scummvm-rg350-1dbb6e807a3b70fc1cdcf7ff1a4949fc69913a05.tar.bz2 scummvm-rg350-1dbb6e807a3b70fc1cdcf7ff1a4949fc69913a05.zip |
ZVISION: Refactor parsing actions, it must handle presence/miss of slot key in same actions.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/actions.cpp | 148 | ||||
-rw-r--r-- | engines/zvision/actions.h | 55 | ||||
-rw-r--r-- | engines/zvision/scr_file_handling.cpp | 209 |
3 files changed, 228 insertions, 184 deletions
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 2fbec2945a..9670016d74 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -44,9 +44,9 @@ namespace ZVision { // ActionAdd ////////////////////////////////////////////////////////////////////////////// -ActionAdd::ActionAdd(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u,%d)", &_key, &_value); +ActionAdd::ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%u,%d", &_key, &_value); } bool ActionAdd::execute() { @@ -59,11 +59,11 @@ bool ActionAdd::execute() { // ActionAssign ////////////////////////////////////////////////////////////////////////////// -ActionAssign::ActionAssign(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionAssign::ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char buf[64]; memset(buf, 0, 64); - sscanf(line.c_str(), "%*[^(](%u, %s)", &_key, buf); + sscanf(line.c_str(), "%u, %s", &_key, buf); _value = new ValueSlot(_engine->getScriptManager(), buf); } @@ -82,9 +82,9 @@ bool ActionAssign::execute() { // ActionAttenuate ////////////////////////////////////////////////////////////////////////////// -ActionAttenuate::ActionAttenuate(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u, %d)", &_key, &_attenuation); +ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%u, %d", &_key, &_attenuation); } bool ActionAttenuate::execute() { @@ -97,9 +97,9 @@ bool ActionAttenuate::execute() { // ActionChangeLocation ////////////////////////////////////////////////////////////////////////////// -ActionChangeLocation::ActionChangeLocation(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%c, %c, %c%c, %u)", &_world, &_room, &_node, &_view, &_offset); +ActionChangeLocation::ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%c, %c, %c%c, %u", &_world, &_room, &_node, &_view, &_offset); } bool ActionChangeLocation::execute() { @@ -114,10 +114,10 @@ bool ActionChangeLocation::execute() { // ActionCrossfade ////////////////////////////////////////////////////////////////////////////// -ActionCrossfade::ActionCrossfade(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { sscanf(line.c_str(), - "%*[^(](%u %u %u %u %u %u %u)", + "%u %u %u %u %u %u %u", &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis); } @@ -131,9 +131,9 @@ bool ActionCrossfade::execute() { // ActionDisableControl ////////////////////////////////////////////////////////////////////////////// -ActionDisableControl::ActionDisableControl(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u)", &_key); +ActionDisableControl::ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%u", &_key); } bool ActionDisableControl::execute() { @@ -146,9 +146,9 @@ bool ActionDisableControl::execute() { // ActionEnableControl ////////////////////////////////////////////////////////////////////////////// -ActionEnableControl::ActionEnableControl(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u)", &_key); +ActionEnableControl::ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%u", &_key); } bool ActionEnableControl::execute() { @@ -160,10 +160,10 @@ bool ActionEnableControl::execute() { // ActionInventory ////////////////////////////////////////////////////////////////////////////// -ActionInventory::ActionInventory(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char buf[25]; - sscanf(line.c_str(), "%*[^(](%25s %d)", buf, &_key); + sscanf(line.c_str(), "%25s %d", buf, &_key); if (strcmp(buf, "add") == 0) { _type = 0; @@ -210,12 +210,12 @@ bool ActionInventory::execute() { // ActionKill ////////////////////////////////////////////////////////////////////////////// -ActionKill::ActionKill(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { _key = 0; _type = 0; char keytype[25]; - sscanf(line.c_str(), "%*[^(](%25s)", keytype); + sscanf(line.c_str(), "%25s", keytype); if (keytype[0] == '"') { if (!scumm_stricmp(keytype, "\"ANIM\"")) _type = SideFX::SIDEFX_ANIM; @@ -250,8 +250,8 @@ bool ActionKill::execute() { // ActionMusic ////////////////////////////////////////////////////////////////////////////// -ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool global) : - ResultAction(engine), +ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global) : + ResultAction(engine, slotkey), _volume(255), _universe(global) { uint type; @@ -259,7 +259,7 @@ ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool globa uint loop; uint volume = 255; - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u %25s %u %u)", &_key, &type, fileNameBuffer, &loop, &volume); + sscanf(line.c_str(), "%u %25s %u %u", &type, fileNameBuffer, &loop, &volume); // type 4 are midi sound effect files if (type == 4) { @@ -282,11 +282,11 @@ ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool globa ActionMusic::~ActionMusic() { if (!_universe) - _engine->getScriptManager()->killSideFx(_key); + _engine->getScriptManager()->killSideFx(_slotkey); } bool ActionMusic::execute() { - if (_engine->getScriptManager()->getSideFX(_key)) + if (_engine->getScriptManager()->getSideFX(_slotkey)) return true; Common::File *file = new Common::File(); if (!file->exists(_fileName) && _fileName.size() >= 12) { @@ -307,7 +307,7 @@ bool ActionMusic::execute() { } } if (file->exists(_fileName)) - _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _key, _fileName, _loop, _volume)); + _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume)); delete file; return true; @@ -318,12 +318,12 @@ bool ActionMusic::execute() { // ActionPreloadAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; // The two %*u are always 0 and dont seem to have a use - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %d %d)", &_key, fileName, &_mask, &_framerate); + sscanf(line.c_str(), "%25s %*u %*u %d %d", fileName, &_mask, &_framerate); if (_mask > 0) { byte r, g, b; @@ -335,14 +335,14 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::St } ActionPreloadAnimation::~ActionPreloadAnimation() { - _engine->getScriptManager()->deleteSideFx(_key); + _engine->getScriptManager()->deleteSideFx(_slotkey); } bool ActionPreloadAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key); + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey); if (!nod) { - nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate, false); + nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate, false); _engine->getScriptManager()->addSideFX(nod); } else nod->stop(); @@ -354,14 +354,14 @@ bool ActionPreloadAnimation::execute() { // ActionPlayAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; // The two %*u are always 0 and dont seem to have a use sscanf(line.c_str(), - "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %d %*u %*u %d %d)", - &_key, fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); + "%25s %u %u %u %u %u %u %d %*u %*u %d %d", + fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); if (_mask > 0) { byte r, g, b; @@ -373,20 +373,20 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String & } ActionPlayAnimation::~ActionPlayAnimation() { - _engine->getScriptManager()->deleteSideFx(_key); + _engine->getScriptManager()->deleteSideFx(_slotkey); } bool ActionPlayAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key); + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey); if (!nod) { - nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate); + nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate); _engine->getScriptManager()->addSideFX(nod); } else nod->stop(); if (nod) - nod->addPlayNode(_key, _x, _y, _x2, _y2, _start, _end, _loopCount); + nod->addPlayNode(_slotkey, _x, _y, _x2, _y2, _start, _end, _loopCount); return true; } @@ -396,18 +396,18 @@ bool ActionPlayAnimation::execute() { // ActionPlayPreloadAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { sscanf(line.c_str(), - "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)", - &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount); + "%u %u %u %u %u %u %u %u", + &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount); } bool ActionPlayPreloadAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_animationKey); + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_controlKey); if (nod) - nod->addPlayNode(_controlKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount); + nod->addPlayNode(_slotkey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount); return true; } @@ -428,11 +428,11 @@ bool ActionQuit::execute() { // ActionRandom ////////////////////////////////////////////////////////////////////////////// -ActionRandom::ActionRandom(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char max_buf[64]; memset(max_buf, 0, 64); - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, max_buf); + sscanf(line.c_str(), "%s", max_buf); _max = new ValueSlot(_engine->getScriptManager(), max_buf); } @@ -443,7 +443,7 @@ ActionRandom::~ActionRandom() { bool ActionRandom::execute() { uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue()); - _engine->getScriptManager()->setStateValue(_key, randNumber); + _engine->getScriptManager()->setStateValue(_slotkey, randNumber); return true; } @@ -452,12 +452,12 @@ bool ActionRandom::execute() { // ActionSetPartialScreen ////////////////////////////////////////////////////////////////////////////// -ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; int color; - sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %d)", &_x, &_y, fileName, &color); + sscanf(line.c_str(), "%u %u %25s %*u %d", &_x, &_y, fileName, &color); _fileName = Common::String(fileName); @@ -489,10 +489,10 @@ bool ActionSetPartialScreen::execute() { // ActionSetScreen ////////////////////////////////////////////////////////////////////////////// -ActionSetScreen::ActionSetScreen(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionSetScreen::ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; - sscanf(line.c_str(), "%*[^(](%25[^)])", fileName); + sscanf(line.c_str(), "%25s", fileName); _fileName = Common::String(fileName); } @@ -507,10 +507,10 @@ bool ActionSetScreen::execute() { // ActionStop ////////////////////////////////////////////////////////////////////////////// -ActionStop::ActionStop(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionStop::ActionStop(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { _key = 0; - sscanf(line.c_str(), "%*[^(](%u)", &_key); + sscanf(line.c_str(), "%u", &_key); } bool ActionStop::execute() { @@ -523,12 +523,12 @@ bool ActionStop::execute() { // ActionStreamVideo ////////////////////////////////////////////////////////////////////////////// -ActionStreamVideo::ActionStreamVideo(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; uint skipline; //skipline - render video with skip every second line, not skippable. - sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline); + sscanf(line.c_str(), "%25s %u %u %u %u %u %u", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline); _fileName = Common::String(fileName); _skippable = true; @@ -554,22 +554,22 @@ bool ActionStreamVideo::execute() { // ActionTimer ////////////////////////////////////////////////////////////////////////////// -ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char time_buf[64]; memset(time_buf, 0, 64); - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, time_buf); + sscanf(line.c_str(), "%s", time_buf); _time = new ValueSlot(_engine->getScriptManager(), time_buf); } ActionTimer::~ActionTimer() { if (_time) delete _time; - _engine->getScriptManager()->killSideFx(_key); + _engine->getScriptManager()->killSideFx(_slotkey); } bool ActionTimer::execute() { - _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _key, _time->getValue())); + _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotkey, _time->getValue())); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index d9871328cb..aadb97fc9b 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -40,7 +40,7 @@ class ValueSlot; */ class ResultAction { public: - ResultAction(ZVision *engine) : _engine(engine) {} + ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotkey(slotkey) {} virtual ~ResultAction() {} /** * This is called by the script system whenever a Puzzle's criteria are found to be true. @@ -53,6 +53,7 @@ public: virtual bool execute() = 0; protected: ZVision *_engine; + int32 _slotkey; }; @@ -89,7 +90,7 @@ protected: class ActionAdd : public ResultAction { public: - ActionAdd(ZVision *engine, const Common::String &line); + ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -99,7 +100,7 @@ private: class ActionAssign : public ResultAction { public: - ActionAssign(ZVision *engine, const Common::String &line); + ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionAssign(); bool execute(); @@ -110,7 +111,7 @@ private: class ActionAttenuate : public ResultAction { public: - ActionAttenuate(ZVision *engine, const Common::String &line); + ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -120,7 +121,7 @@ private: class ActionChangeLocation : public ResultAction { public: - ActionChangeLocation(ZVision *engine, const Common::String &line); + ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -133,7 +134,7 @@ private: class ActionCrossfade : public ResultAction { public: - ActionCrossfade(ZVision *engine, const Common::String &line); + ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -148,7 +149,7 @@ private: class ActionDebug : public ResultAction { public: - ActionDebug(ZVision *engine, const Common::String &line); + ActionDebug(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -156,7 +157,7 @@ private: class ActionDelayRender : public ResultAction { public: - ActionDelayRender(ZVision *engine, const Common::String &line); + ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -166,7 +167,7 @@ private: class ActionDisableControl : public ResultAction { public: - ActionDisableControl(ZVision *engine, const Common::String &line); + ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -175,7 +176,7 @@ private: class ActionDisableVenus : public ResultAction { public: - ActionDisableVenus(ZVision *engine, const Common::String &line); + ActionDisableVenus(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -183,7 +184,7 @@ private: class ActionDisplayMessage : public ResultAction { public: - ActionDisplayMessage(ZVision *engine, const Common::String &line); + ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -197,7 +198,7 @@ public: class ActionDistort : public ResultAction { public: - ActionDistort(ZVision *engine, const Common::String &line); + ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -205,7 +206,7 @@ private: class ActionEnableControl : public ResultAction { public: - ActionEnableControl(ZVision *engine, const Common::String &line); + ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -214,7 +215,7 @@ private: class ActionInventory : public ResultAction { public: - ActionInventory(ZVision *engine, const Common::String &line); + ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: uint8 _type; @@ -223,7 +224,7 @@ private: class ActionKill : public ResultAction { public: - ActionKill(ZVision *engine, const Common::String &line); + ActionKill(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -233,7 +234,7 @@ private: class ActionMusic : public ResultAction { public: - ActionMusic(ZVision *engine, const Common::String &line, bool global); + ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global); ~ActionMusic(); bool execute(); @@ -248,7 +249,7 @@ private: class ActionPlayAnimation : public ResultAction { public: - ActionPlayAnimation(ZVision *engine, const Common::String &line); + ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionPlayAnimation(); bool execute(); @@ -268,7 +269,7 @@ private: class ActionPlayPreloadAnimation : public ResultAction { public: - ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line); + ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -285,7 +286,7 @@ private: class ActionPreloadAnimation : public ResultAction { public: - ActionPreloadAnimation(ZVision *engine, const Common::String &line); + ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionPreloadAnimation(); bool execute(); @@ -298,20 +299,20 @@ private: class ActionQuit : public ResultAction { public: - ActionQuit(ZVision *engine) : ResultAction(engine) {} + ActionQuit(ZVision *engine, int32 slotkey) : ResultAction(engine, slotkey) {} bool execute(); }; // TODO: See if this exists in ZGI. It doesn't in ZNem class ActionUnloadAnimation : public ResultAction { public: - ActionUnloadAnimation(ZVision *engine, const Common::String &line); + ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); }; class ActionRandom : public ResultAction { public: - ActionRandom(ZVision *engine, const Common::String &line); + ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionRandom(); bool execute(); @@ -322,7 +323,7 @@ private: class ActionSetPartialScreen : public ResultAction { public: - ActionSetPartialScreen(ZVision *engine, const Common::String &line); + ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -334,7 +335,7 @@ private: class ActionSetScreen : public ResultAction { public: - ActionSetScreen(ZVision *engine, const Common::String &line); + ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -343,7 +344,7 @@ private: class ActionStop : public ResultAction { public: - ActionStop(ZVision *engine, const Common::String &line); + ActionStop(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -352,7 +353,7 @@ private: class ActionStreamVideo : public ResultAction { public: - ActionStreamVideo(ZVision *engine, const Common::String &line); + ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -371,7 +372,7 @@ private: class ActionTimer : public ResultAction { public: - ActionTimer(ZVision *engine, const Common::String &line); + ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionTimer(); bool execute(); private: diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 769c94921b..0149347c4e 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -161,89 +161,132 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis continue; } - // Parse for the action type - if (line.matchString("*:add*", true)) { - actionList.push_back(new ActionAdd(_engine, line)); - } else if (line.matchString("*:animplay*", true)) { - actionList.push_back(new ActionPlayAnimation(_engine, line)); - } else if (line.matchString("*:animpreload*", true)) { - actionList.push_back(new ActionPreloadAnimation(_engine, line)); - } else if (line.matchString("*:animunload*", true)) { - //actionList.push_back(new ActionUnloadAnimation(_engine, line)); - } else if (line.matchString("*:attenuate*", true)) { - // TODO: Implement ActionAttenuate - } else if (line.matchString("*:assign*", true)) { - actionList.push_back(new ActionAssign(_engine, line)); - } else if (line.matchString("*:change_location*", true)) { - actionList.push_back(new ActionChangeLocation(_engine, line)); - } else if (line.matchString("*:crossfade*", true)) { - // TODO: Implement ActionCrossfade - } else if (line.matchString("*:debug*", true)) { - // TODO: Implement ActionDebug - } else if (line.matchString("*:delay_render*", true)) { - // TODO: Implement ActionDelayRender - } else if (line.matchString("*:disable_control*", true)) { - actionList.push_back(new ActionDisableControl(_engine, line)); - } else if (line.matchString("*:disable_venus*", true)) { - // TODO: Implement ActionDisableVenus - } else if (line.matchString("*:display_message*", true)) { - // TODO: Implement ActionDisplayMessage - } else if (line.matchString("*:dissolve*", true)) { - // TODO: Implement ActionDissolve - } else if (line.matchString("*:distort*", true)) { - // TODO: Implement ActionDistort - } else if (line.matchString("*:enable_control*", true)) { - actionList.push_back(new ActionEnableControl(_engine, line)); - } else if (line.matchString("*:flush_mouse_events*", true)) { - // TODO: Implement ActionFlushMouseEvents - } else if (line.matchString("*:inventory*", true)) { - actionList.push_back(new ActionInventory(_engine, line)); - } else if (line.matchString("*:kill*", true)) { - actionList.push_back(new ActionKill(_engine, line)); - } else if (line.matchString("*:menu_bar_enable*", true)) { - // TODO: Implement ActionMenuBarEnable - } else if (line.matchString("*:music*", true)) { - actionList.push_back(new ActionMusic(_engine, line, false)); - } else if (line.matchString("*:pan_track*", true)) { - // TODO: Implement ActionPanTrack - } else if (line.matchString("*:playpreload*", true)) { - actionList.push_back(new ActionPlayPreloadAnimation(_engine, line)); - } else if (line.matchString("*:preferences*", true)) { - // TODO: Implement ActionPreferences - } else if (line.matchString("*:quit*", true)) { - actionList.push_back(new ActionQuit(_engine)); - } else if (line.matchString("*:random*", true)) { - actionList.push_back(new ActionRandom(_engine, line)); - } else if (line.matchString("*:region*", true)) { - // TODO: Implement ActionRegion - } else if (line.matchString("*:restore_game*", true)) { - // TODO: Implement ActionRestoreGame - } else if (line.matchString("*:rotate_to*", true)) { - // TODO: Implement ActionRotateTo - } else if (line.matchString("*:save_game*", true)) { - // TODO: Implement ActionSaveGame - } else if (line.matchString("*:set_partial_screen*", true)) { - actionList.push_back(new ActionSetPartialScreen(_engine, line)); - } else if (line.matchString("*:set_screen*", true)) { - actionList.push_back(new ActionSetScreen(_engine, line)); - } else if (line.matchString("*:set_venus*", true)) { - // TODO: Implement ActionSetVenus - } else if (line.matchString("*:stop*", true)) { - actionList.push_back(new ActionStop(_engine, line)); - } else if (line.matchString("*:streamvideo*", true)) { - actionList.push_back(new ActionStreamVideo(_engine, line)); - } else if (line.matchString("*:syncsound*", true)) { - // TODO: Implement ActionSyncSound - } else if (line.matchString("*:timer*", true)) { - actionList.push_back(new ActionTimer(_engine, line)); - } else if (line.matchString("*:ttytext*", true)) { - // TODO: Implement ActionTTYText - } else if (line.matchString("*:universe_music*", true)) { - actionList.push_back(new ActionMusic(_engine, line, true)); - } else if (line.matchString("*:copy_file*", true)) { - // Not used. Purposely left empty - } else { - warning("Unhandled result action type: %s", line.c_str()); + const char *chrs = line.c_str(); + uint pos; + for (pos = 0; pos < line.size(); pos++) + if (chrs[pos] == ':') + break; + + if (pos < line.size()) { + + uint startpos = pos + 1; + + for (pos = startpos; pos < line.size(); pos++) + if (chrs[pos] == ':' || chrs[pos] == '(') + break; + + if (pos < line.size()) { + int32 slot = 11; + Common::String args = ""; + Common::String act(chrs + startpos, chrs + pos); + + startpos = pos + 1; + + if (chrs[pos] == ':') { + for (pos = startpos; pos < line.size(); pos++) + if (chrs[pos] == '(') + break; + Common::String s_slot(chrs + startpos, chrs + pos); + slot = atoi(s_slot.c_str()); + + startpos = pos + 1; + } + + if (pos < line.size()) { + for (pos = startpos; pos < line.size(); pos++) + if (chrs[pos] == ')') + break; + + args = Common::String(chrs + startpos, chrs + pos); + } + + + + // Parse for the action type + if (act.matchString("add", true)) { + actionList.push_back(new ActionAdd(_engine, slot, args)); + } else if (act.matchString("animplay", true)) { + actionList.push_back(new ActionPlayAnimation(_engine, slot, args)); + } else if (act.matchString("animpreload", true)) { + actionList.push_back(new ActionPreloadAnimation(_engine, slot, args)); + } else if (act.matchString("animunload", true)) { + //actionList.push_back(new ActionUnloadAnimation(_engine, slot, args)); + } else if (act.matchString("attenuate", true)) { + // TODO: Implement ActionAttenuate + } else if (act.matchString("assign", true)) { + actionList.push_back(new ActionAssign(_engine, slot, args)); + } else if (act.matchString("change_location", true)) { + actionList.push_back(new ActionChangeLocation(_engine, slot, args)); + } else if (act.matchString("crossfade", true)) { + // TODO: Implement ActionCrossfade + } else if (act.matchString("debug", true)) { + // TODO: Implement ActionDebug + } else if (act.matchString("delay_render", true)) { + // TODO: Implement ActionDelayRender + } else if (act.matchString("disable_control", true)) { + actionList.push_back(new ActionDisableControl(_engine, slot, args)); + } else if (act.matchString("disable_venus", true)) { + // TODO: Implement ActionDisableVenus + } else if (act.matchString("display_message", true)) { + // TODO: Implement ActionDisplayMessage + } else if (act.matchString("dissolve", true)) { + // TODO: Implement ActionDissolve + } else if (act.matchString("distort", true)) { + // TODO: Implement ActionDistort + } else if (act.matchString("enable_control", true)) { + actionList.push_back(new ActionEnableControl(_engine, slot, args)); + } else if (act.matchString("flush_mouse_events", true)) { + // TODO: Implement ActionFlushMouseEvents + } else if (act.matchString("inventory", true)) { + actionList.push_back(new ActionInventory(_engine, slot, args)); + } else if (act.matchString("kill", true)) { + actionList.push_back(new ActionKill(_engine, slot, args)); + } else if (act.matchString("menu_bar_enable", true)) { + // TODO: Implement ActionMenuBarEnable + } else if (act.matchString("music", true)) { + actionList.push_back(new ActionMusic(_engine, slot, args, false)); + } else if (act.matchString("pan_track", true)) { + // TODO: Implement ActionPanTrack + } else if (act.matchString("playpreload", true)) { + actionList.push_back(new ActionPlayPreloadAnimation(_engine, slot, args)); + } else if (act.matchString("preferences", true)) { + // TODO: Implement ActionPreferences + } else if (act.matchString("quit", true)) { + actionList.push_back(new ActionQuit(_engine, slot)); + } else if (act.matchString("random", true)) { + actionList.push_back(new ActionRandom(_engine, slot, args)); + } else if (act.matchString("region", true)) { + // TODO: Implement ActionRegion + } else if (act.matchString("restore_game", true)) { + // TODO: Implement ActionRestoreGame + } else if (act.matchString("rotate_to", true)) { + // TODO: Implement ActionRotateTo + } else if (act.matchString("save_game", true)) { + // TODO: Implement ActionSaveGame + } else if (act.matchString("set_partial_screen", true)) { + actionList.push_back(new ActionSetPartialScreen(_engine, slot, args)); + } else if (act.matchString("set_screen", true)) { + actionList.push_back(new ActionSetScreen(_engine, slot, args)); + } else if (act.matchString("set_venus", true)) { + // TODO: Implement ActionSetVenus + } else if (act.matchString("stop", true)) { + actionList.push_back(new ActionStop(_engine, slot, args)); + } else if (act.matchString("streamvideo", true)) { + actionList.push_back(new ActionStreamVideo(_engine, slot, args)); + } else if (act.matchString("syncsound", true)) { + // TODO: Implement ActionSyncSound + } else if (act.matchString("timer", true)) { + actionList.push_back(new ActionTimer(_engine, slot, args)); + } else if (act.matchString("ttytext", true)) { + // TODO: Implement ActionTTYText + } else if (act.matchString("universe_music", true)) { + actionList.push_back(new ActionMusic(_engine, slot, args, true)); + } else if (act.matchString("copy_file", true)) { + // Not used. Purposely left empty + } else { + warning("Unhandled result action type: %s", line.c_str()); + } + } } line = stream.readLine(); |