diff options
author | whiterandrek | 2018-05-22 08:03:37 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2018-06-28 23:51:32 +0200 |
commit | 82974a9ce37aba6240f7c3543947631170f012c2 (patch) | |
tree | 6aeed5f5edfb1c758b2c18b8ac224bde40eaff8c /engines/pink/objects | |
parent | 931d6adbcbbe063857814dc76886e9a967b2a4f3 (diff) | |
download | scummvm-rg350-82974a9ce37aba6240f7c3543947631170f012c2.tar.gz scummvm-rg350-82974a9ce37aba6240f7c3543947631170f012c2.tar.bz2 scummvm-rg350-82974a9ce37aba6240f7c3543947631170f012c2.zip |
PINK: fix indentation
Diffstat (limited to 'engines/pink/objects')
69 files changed, 2055 insertions, 2055 deletions
diff --git a/engines/pink/objects/actions/action.cpp b/engines/pink/objects/actions/action.cpp index c6398833ae..934d6fc5be 100644 --- a/engines/pink/objects/actions/action.cpp +++ b/engines/pink/objects/actions/action.cpp @@ -27,8 +27,8 @@ namespace Pink { void Action::deserialize(Archive &archive) { - NamedObject::deserialize(archive); - _actor = static_cast<Actor*>(archive.readObject()); + NamedObject::deserialize(archive); + _actor = static_cast<Actor*>(archive.readObject()); } } // End of namespace Pink diff --git a/engines/pink/objects/actions/action.h b/engines/pink/objects/actions/action.h index 0d57fbb129..241aee821f 100644 --- a/engines/pink/objects/actions/action.h +++ b/engines/pink/objects/actions/action.h @@ -32,21 +32,21 @@ class Director; class Action : public NamedObject { public: - virtual void deserialize(Archive &archive); - virtual void start(bool unk) {}; - virtual void end() {}; - virtual void update() {}; - virtual void toConsole() {}; + virtual void deserialize(Archive &archive); + virtual void start(bool unk) {}; + virtual void end() {}; + virtual void update() {}; + virtual void toConsole() {}; - virtual bool initPalette(Director *director) { return 0;} + virtual bool initPalette(Director *director) { return 0;} - Actor *getActor() { return _actor;} + Actor *getActor() { return _actor;} - virtual void pause() {}; - virtual void unpause() {}; + virtual void pause() {}; + virtual void unpause() {}; protected: - Actor *_actor; + Actor *_actor; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_cel.cpp b/engines/pink/objects/actions/action_cel.cpp index 352c635d68..f38c127782 100644 --- a/engines/pink/objects/actions/action_cel.cpp +++ b/engines/pink/objects/actions/action_cel.cpp @@ -32,64 +32,64 @@ namespace Pink { ActionCEL::ActionCEL() - : _decoder(nullptr) { + : _decoder(nullptr) { } void ActionCEL::deserialize(Archive &archive) { - Action::deserialize(archive); - _fileName = archive.readString(); - _z = archive.readDWORD(); + Action::deserialize(archive); + _fileName = archive.readString(); + _z = archive.readDWORD(); } void ActionCEL::start(bool unk) { - if (!_decoder) - _decoder = _actor->getPage()->loadCel(_fileName); - _actor->getPage()->getGame()->getDirector()->addSprite(this); + if (!_decoder) + _decoder = _actor->getPage()->loadCel(_fileName); + _actor->getPage()->getGame()->getDirector()->addSprite(this); - this->onStart(); + this->onStart(); } void ActionCEL::end() { - _actor->getPage()->getGame()->getDirector()->removeSprite(this); - delete _decoder; - _decoder = nullptr; + _actor->getPage()->getGame()->getDirector()->removeSprite(this); + delete _decoder; + _decoder = nullptr; } uint32 ActionCEL::getZ() { - return _z; + return _z; } CelDecoder *ActionCEL::getDecoder() { - return _decoder; + return _decoder; } bool ActionCEL::initPalette(Director *director) { - _decoder = _actor->getPage()->loadCel(_fileName); - _decoder->decodeNextFrame(); - _decoder->rewind(); - director->setPallette(_decoder->getPalette()); + _decoder = _actor->getPage()->loadCel(_fileName); + _decoder->decodeNextFrame(); + _decoder->rewind(); + director->setPallette(_decoder->getPalette()); - return 1; + return 1; } void ActionCEL::update() { - if (_decoder->endOfVideo()){ - _decoder->stop(); - _actor->endAction(); - } + if (_decoder->endOfVideo()){ + _decoder->stop(); + _actor->endAction(); + } } ActionCEL::~ActionCEL() { - end(); + end(); } void ActionCEL::pause() { - _decoder->pauseVideo(1); + _decoder->pauseVideo(1); } void ActionCEL::unpause() { - _decoder->pauseVideo(0); + _decoder->pauseVideo(0); } } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_cel.h b/engines/pink/objects/actions/action_cel.h index 937c23bc08..765fe8dd61 100644 --- a/engines/pink/objects/actions/action_cel.h +++ b/engines/pink/objects/actions/action_cel.h @@ -31,28 +31,28 @@ class CelDecoder; class ActionCEL : public Action { public: - ~ActionCEL() override; + ~ActionCEL() override; - ActionCEL(); - virtual void deserialize(Archive &archive); - virtual void start(bool unk); - virtual void end(); - virtual void update(); + ActionCEL(); + virtual void deserialize(Archive &archive); + virtual void start(bool unk); + virtual void end(); + virtual void update(); - uint32 getZ(); - CelDecoder *getDecoder(); + uint32 getZ(); + CelDecoder *getDecoder(); - virtual bool initPalette(Director *director); + virtual bool initPalette(Director *director); - void pause() override; + void pause() override; - void unpause() override; + void unpause() override; protected: - virtual void onStart() {} ; - CelDecoder *_decoder; - Common::String _fileName; - uint32 _z; + virtual void onStart() {} ; + CelDecoder *_decoder; + Common::String _fileName; + uint32 _z; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_hide.cpp b/engines/pink/objects/actions/action_hide.cpp index a8a9a3a0b7..1732d2d967 100644 --- a/engines/pink/objects/actions/action_hide.cpp +++ b/engines/pink/objects/actions/action_hide.cpp @@ -27,20 +27,20 @@ namespace Pink { void Pink::ActionHide::deserialize(Archive &archive) { - Action::deserialize(archive); + Action::deserialize(archive); } void ActionHide::start(bool unk_startNow) { - debug("Actor %s has now ActionHide %s", _actor->getName().c_str(), _name.c_str()); - _actor->endAction(); + debug("Actor %s has now ActionHide %s", _actor->getName().c_str(), _name.c_str()); + _actor->endAction(); } void ActionHide::end() { - debug("ActionHide %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); + debug("ActionHide %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); } void ActionHide::toConsole() { - debug("\tActionHide: _name = %s", _name.c_str()); + debug("\tActionHide: _name = %s", _name.c_str()); } ActionHide::~ActionHide() {} diff --git a/engines/pink/objects/actions/action_hide.h b/engines/pink/objects/actions/action_hide.h index a7c23a4b15..eb2b8da519 100644 --- a/engines/pink/objects/actions/action_hide.h +++ b/engines/pink/objects/actions/action_hide.h @@ -29,13 +29,13 @@ namespace Pink { class ActionHide : public Action { public: - ~ActionHide() override; + ~ActionHide() override; - virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); - virtual void start(bool unk); - virtual void end(); + virtual void start(bool unk); + virtual void end(); }; } //End of namespace Pink diff --git a/engines/pink/objects/actions/action_loop.cpp b/engines/pink/objects/actions/action_loop.cpp index 77a17630e2..f32a3a4035 100644 --- a/engines/pink/objects/actions/action_loop.cpp +++ b/engines/pink/objects/actions/action_loop.cpp @@ -28,42 +28,42 @@ namespace Pink { void ActionLoop::deserialize(Archive &archive) { - ActionPlay::deserialize(archive); - uint16 style; - _intro = archive.readDWORD(); - style = archive.readWORD(); - switch (style) { - case kPingPong: - _style = kPingPong; - break; - case kRandom: - _style = kRandom; - break; - default: - _style = kForward; - break; - } + ActionPlay::deserialize(archive); + uint16 style; + _intro = archive.readDWORD(); + style = archive.readWORD(); + switch (style) { + case kPingPong: + _style = kPingPong; + break; + case kRandom: + _style = kRandom; + break; + default: + _style = kForward; + break; + } } void ActionLoop::toConsole() { - debug("\tActionLoop: _name = %s, _fileName = %s, z = %u, _startFrame = %u," - " _endFrame = %d, _intro = %u, _style = %u", - _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _intro, _style); + debug("\tActionLoop: _name = %s, _fileName = %s, z = %u, _startFrame = %u," + " _endFrame = %d, _intro = %u, _style = %u", + _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _intro, _style); } void ActionLoop::update() { - // for now it supports only forward loop animation - if (_style == kForward) { - if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame){ - //debug("ACTION LOOP : NEXT ITERATION"); - _decoder->rewind(); - } - } + // for now it supports only forward loop animation + if (_style == kForward) { + if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame){ + //debug("ACTION LOOP : NEXT ITERATION"); + _decoder->rewind(); + } + } } void ActionLoop::onStart() { - ActionPlay::onStart(); - _actor->endAction(); + ActionPlay::onStart(); + _actor->endAction(); } } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_loop.h b/engines/pink/objects/actions/action_loop.h index 12c9e2dd88..0b8132aa5c 100644 --- a/engines/pink/objects/actions/action_loop.h +++ b/engines/pink/objects/actions/action_loop.h @@ -29,19 +29,19 @@ namespace Pink { class ActionLoop : public ActionPlay { public: - virtual void deserialize(Archive &archive); - virtual void toConsole(); - virtual void update(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); + virtual void update(); protected: - virtual void onStart(); + virtual void onStart(); - enum Style { - kPingPong = 2, - kRandom = 3, - kForward = 4 - }; - uint _intro; - Style _style; + enum Style { + kPingPong = 2, + kRandom = 3, + kForward = 4 + }; + uint _intro; + Style _style; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_play.cpp b/engines/pink/objects/actions/action_play.cpp index 6ab21db32e..6ae56df349 100644 --- a/engines/pink/objects/actions/action_play.cpp +++ b/engines/pink/objects/actions/action_play.cpp @@ -30,34 +30,34 @@ namespace Pink { void ActionPlay::deserialize(Archive &archive) { - ActionStill::deserialize(archive); - _stopFrame = archive.readDWORD(); + ActionStill::deserialize(archive); + _stopFrame = archive.readDWORD(); } void ActionPlay::toConsole() { - debug("\tActionPlay: _name = %s, _fileName = %s, z = %u, _startFrame = %u," - " _endFrame = %d", _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame); + debug("\tActionPlay: _name = %s, _fileName = %s, z = %u, _startFrame = %u," + " _endFrame = %d", _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame); } void ActionPlay::end() { - ActionCEL::end(); - debug("ActionPlay %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); + ActionCEL::end(); + debug("ActionPlay %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); } void ActionPlay::onStart() { - debug("Actor %s has now ActionPlay %s", _actor->getName().c_str(), _name.c_str()); - _decoder->start(); - for (uint i = 0; i < _startFrame; ++i) { - _decoder->skipFrame(); - } - _decoder->decodeNextFrame(); + debug("Actor %s has now ActionPlay %s", _actor->getName().c_str(), _name.c_str()); + _decoder->start(); + for (uint i = 0; i < _startFrame; ++i) { + _decoder->skipFrame(); + } + _decoder->decodeNextFrame(); } void ActionPlay::update() { - if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame){ - _decoder->stop(); - _actor->endAction(); - } + if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame){ + _decoder->stop(); + _actor->endAction(); + } } } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_play.h b/engines/pink/objects/actions/action_play.h index 319d05921c..6553bb1776 100644 --- a/engines/pink/objects/actions/action_play.h +++ b/engines/pink/objects/actions/action_play.h @@ -29,17 +29,17 @@ namespace Pink { class ActionPlay : public ActionStill { public: - virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); - virtual void end(); + virtual void end(); - void update() override; + void update() override; protected: - virtual void onStart(); + virtual void onStart(); - int32 _stopFrame; + int32 _stopFrame; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_play_with_sfx.cpp b/engines/pink/objects/actions/action_play_with_sfx.cpp index e6f557051f..9cb850384e 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.cpp +++ b/engines/pink/objects/actions/action_play_with_sfx.cpp @@ -29,90 +29,90 @@ namespace Pink { void ActionPlayWithSfx::deserialize(Pink::Archive &archive) { - ActionPlay::deserialize(archive); - _isLoop = archive.readDWORD(); - _sfxArray.deserialize(archive); + ActionPlay::deserialize(archive); + _isLoop = archive.readDWORD(); + _sfxArray.deserialize(archive); } void ActionPlayWithSfx::toConsole() { - debug("\tActionPlayWithSfx: _name = %s, _fileName = %s, z = %u, _startFrame = %u," - " _endFrame = %d, _isLoop = %u", _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _isLoop); - for (uint i = 0; i < _sfxArray.size(); ++i) { - _sfxArray[i]->toConsole(); - } + debug("\tActionPlayWithSfx: _name = %s, _fileName = %s, z = %u, _startFrame = %u," + " _endFrame = %d, _isLoop = %u", _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _isLoop); + for (uint i = 0; i < _sfxArray.size(); ++i) { + _sfxArray[i]->toConsole(); + } } void ActionPlayWithSfx::update() { - if ((_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame) && _isLoop) { - _decoder->rewind(); - } else if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame) { - _decoder->stop(); - _actor->endAction(); - } - - updateSound(); + if ((_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame) && _isLoop) { + _decoder->rewind(); + } else if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame) { + _decoder->stop(); + _actor->endAction(); + } + + updateSound(); } void ActionPlayWithSfx::onStart() { - ActionPlay::onStart(); - if (_isLoop) { - _actor->endAction(); - } - updateSound(); + ActionPlay::onStart(); + if (_isLoop) { + _actor->endAction(); + } + updateSound(); } void ActionPlayWithSfx::updateSound() { - if (!_actor->isPlaying() && !_isLoop) - return; - - for (uint i = 0; i < _sfxArray.size(); ++i) { - if (_sfxArray[i]->getFrame() == _decoder->getCurFrame()) { - _sfxArray[i]->play(_actor->getPage()); - } - } + if (!_actor->isPlaying() && !_isLoop) + return; + + for (uint i = 0; i < _sfxArray.size(); ++i) { + if (_sfxArray[i]->getFrame() == _decoder->getCurFrame()) { + _sfxArray[i]->play(_actor->getPage()); + } + } } ActionPlayWithSfx::~ActionPlayWithSfx() { - ActionPlay::end(); - for (uint i = 0; i < _sfxArray.size(); ++i) { - delete _sfxArray[i]; - } + ActionPlay::end(); + for (uint i = 0; i < _sfxArray.size(); ++i) { + delete _sfxArray[i]; + } } void ActionSfx::deserialize(Pink::Archive &archive) { - _frame = archive.readDWORD(); + _frame = archive.readDWORD(); _volume = archive.readDWORD(); - _sfxName = archive.readString(); - archive.readObject(); // pointer of ActionPlayWithSfx + _sfxName = archive.readString(); + archive.readObject(); // pointer of ActionPlayWithSfx } void ActionSfx::toConsole() { - debug("\t\tActionSfx: _sfx = %s, _volume = %u, _frame = %u", _sfxName.c_str(), _volume, _frame); + debug("\t\tActionSfx: _sfx = %s, _volume = %u, _frame = %u", _sfxName.c_str(), _volume, _frame); } void ActionSfx::play(GamePage *page) { - if (!_sound) - _sound = page->loadSound(_sfxName); + if (!_sound) + _sound = page->loadSound(_sfxName); - if (!_sound->isPlaying()) - _sound->play(Audio::Mixer::SoundType::kSFXSoundType, _volume, 0); + if (!_sound->isPlaying()) + _sound->play(Audio::Mixer::SoundType::kSFXSoundType, _volume, 0); } ActionSfx::~ActionSfx() { - end(); + end(); } uint32 ActionSfx::getFrame() { - return _frame; + return _frame; } ActionSfx::ActionSfx() - : _sound(nullptr) + : _sound(nullptr) {} void ActionSfx::end() { - delete _sound; - _sound = nullptr; + delete _sound; + _sound = nullptr; } } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_play_with_sfx.h b/engines/pink/objects/actions/action_play_with_sfx.h index 865f3685cc..89b2ec61ab 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.h +++ b/engines/pink/objects/actions/action_play_with_sfx.h @@ -31,18 +31,18 @@ class ActionSfx; class ActionPlayWithSfx : public ActionPlay { public: - virtual ~ActionPlayWithSfx(); - virtual void deserialize(Archive &archive); - virtual void toConsole(); - virtual void update(); + virtual ~ActionPlayWithSfx(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); + virtual void update(); protected: - virtual void onStart(); + virtual void onStart(); private: - void updateSound(); - uint32 _isLoop; - Array<ActionSfx*> _sfxArray; + void updateSound(); + uint32 _isLoop; + Array<ActionSfx*> _sfxArray; }; class Sound; @@ -50,20 +50,20 @@ class GamePage; class ActionSfx : public Object { public: - ActionSfx(); - virtual ~ActionSfx(); - virtual void deserialize(Archive &archive); - virtual void toConsole(); + ActionSfx(); + virtual ~ActionSfx(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); - void play(GamePage *page); - uint32 getFrame(); - void end(); + void play(GamePage *page); + uint32 getFrame(); + void end(); private: - Sound *_sound; - Common::String _sfxName; - uint32 _volume; - uint32 _frame; + Sound *_sound; + Common::String _sfxName; + uint32 _volume; + uint32 _frame; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp index 45d74be23a..e94251d9c0 100644 --- a/engines/pink/objects/actions/action_sound.cpp +++ b/engines/pink/objects/actions/action_sound.cpp @@ -32,68 +32,68 @@ namespace Pink { ActionSound::ActionSound() - : _sound(nullptr) + : _sound(nullptr) {} ActionSound::~ActionSound(){ - end(); + end(); } void ActionSound::deserialize(Archive &archive) { - Action::deserialize(archive); - _fileName = archive.readString(); - _volume = archive.readDWORD(); - _isLoop = (bool) archive.readDWORD(); - _isBackground = (bool) archive.readDWORD(); + Action::deserialize(archive); + _fileName = archive.readString(); + _volume = archive.readDWORD(); + _isLoop = (bool) archive.readDWORD(); + _isBackground = (bool) archive.readDWORD(); } void ActionSound::toConsole() { - debug("\tActionSound: _name = %s, _fileName = %s, _volume = %u, _isLoop = %u," - " _isBackground = %u", _name.c_str(), _fileName.c_str(), _volume, _isLoop, _isBackground); + debug("\tActionSound: _name = %s, _fileName = %s, _volume = %u, _isLoop = %u," + " _isBackground = %u", _name.c_str(), _fileName.c_str(), _volume, _isLoop, _isBackground); } void ActionSound::start(bool unk) { - assert(!_sound); - _sound = _actor->getPage()->loadSound(_fileName); + assert(!_sound); + _sound = _actor->getPage()->loadSound(_fileName); - Audio::Mixer::SoundType soundType = _isBackground ? Audio::Mixer::SoundType::kMusicSoundType - : Audio::Mixer::SoundType::kSpeechSoundType; + Audio::Mixer::SoundType soundType = _isBackground ? Audio::Mixer::SoundType::kMusicSoundType + : Audio::Mixer::SoundType::kSpeechSoundType; - Director *director = _actor->getPage()->getGame()->getDirector(); - director->addSound(this); + Director *director = _actor->getPage()->getGame()->getDirector(); + director->addSound(this); - _sound->play(soundType, _volume, _isLoop); - if (_isLoop) - _actor->endAction(); + _sound->play(soundType, _volume, _isLoop); + if (_isLoop) + _actor->endAction(); - debug("Actor %s has now ActionSound %s", _actor->getName().c_str(), _name.c_str()); + debug("Actor %s has now ActionSound %s", _actor->getName().c_str(), _name.c_str()); } void ActionSound::end() { - if (_sound) { - debug("ActionSound %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); + if (_sound) { + debug("ActionSound %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); - Director *director = _actor->getPage()->getGame()->getDirector(); - director->removeSound(this); + Director *director = _actor->getPage()->getGame()->getDirector(); + director->removeSound(this); - delete _sound; - _sound = nullptr; - } + delete _sound; + _sound = nullptr; + } } void ActionSound::update() { - if (!_sound->isPlaying()) - _actor->endAction(); + if (!_sound->isPlaying()) + _actor->endAction(); } void ActionSound::pause() { - if (_sound) - _sound->pause(); + if (_sound) + _sound->pause(); } void ActionSound::unpause() { - if (_sound) - _sound->resume(); + if (_sound) + _sound->resume(); } } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_sound.h b/engines/pink/objects/actions/action_sound.h index 0fb39bbf66..6e18f97c67 100644 --- a/engines/pink/objects/actions/action_sound.h +++ b/engines/pink/objects/actions/action_sound.h @@ -31,26 +31,26 @@ class Sound; class ActionSound : public Action { public: - ActionSound(); - ~ActionSound(); + ActionSound(); + ~ActionSound(); - virtual void deserialize(Archive &archive); + virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void toConsole(); - virtual void start(bool unk_startNow); - virtual void end(); - virtual void update(); + virtual void start(bool unk_startNow); + virtual void end(); + virtual void update(); - void pause() override; - void unpause() override; + void pause() override; + void unpause() override; private: - Sound *_sound; - Common::String _fileName; - uint32 _volume; - bool _isLoop; - bool _isBackground; + Sound *_sound; + Common::String _fileName; + uint32 _volume; + bool _isLoop; + bool _isBackground; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_still.cpp b/engines/pink/objects/actions/action_still.cpp index c72e6347b4..ebdde4ed09 100644 --- a/engines/pink/objects/actions/action_still.cpp +++ b/engines/pink/objects/actions/action_still.cpp @@ -30,28 +30,28 @@ namespace Pink { void ActionStill::deserialize(Archive &archive) { - ActionCEL::deserialize(archive); - _startFrame = archive.readDWORD(); + ActionCEL::deserialize(archive); + _startFrame = archive.readDWORD(); } void ActionStill::toConsole() { - debug("\tActionStill: _name = %s, _fileName = %s, _z =%u _startFrame = %u", - _name.c_str(), _fileName.c_str(), _z, _startFrame); + debug("\tActionStill: _name = %s, _fileName = %s, _z =%u _startFrame = %u", + _name.c_str(), _fileName.c_str(), _z, _startFrame); } void ActionStill::end() { - ActionCEL::end(); - debug("ActionStill %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); + ActionCEL::end(); + debug("ActionStill %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); } void ActionStill::onStart() { - debug("Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str()); - for (uint i = 0; i < _startFrame; ++i) { - _decoder->skipFrame(); - } - _decoder->decodeNextFrame(); - _decoder->stop(); - _actor->endAction(); + debug("Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str()); + for (uint i = 0; i < _startFrame; ++i) { + _decoder->skipFrame(); + } + _decoder->decodeNextFrame(); + _decoder->stop(); + _actor->endAction(); } } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_still.h b/engines/pink/objects/actions/action_still.h index cef3967e33..a62b201ce8 100644 --- a/engines/pink/objects/actions/action_still.h +++ b/engines/pink/objects/actions/action_still.h @@ -29,15 +29,15 @@ namespace Pink { class ActionStill : public ActionCEL { public: - virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); - virtual void end(); + virtual void end(); protected: - virtual void onStart(); + virtual void onStart(); - uint32 _startFrame; + uint32 _startFrame; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_talk.cpp b/engines/pink/objects/actions/action_talk.cpp index fad3f19ff9..1f55de1f42 100644 --- a/engines/pink/objects/actions/action_talk.cpp +++ b/engines/pink/objects/actions/action_talk.cpp @@ -30,46 +30,46 @@ namespace Pink { void ActionTalk::deserialize(Archive &archive) { - ActionLoop::deserialize(archive); - _vox = archive.readString(); + ActionLoop::deserialize(archive); + _vox = archive.readString(); } void ActionTalk::toConsole() { - debug("\tActionTalk: _name = %s, _fileName = %s, z = %u, _startFrame = %u," - " _endFrame = %d, _intro = %u, _style = %u, _vox = %s", - _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _intro, _style, _vox.c_str()); + debug("\tActionTalk: _name = %s, _fileName = %s, z = %u, _startFrame = %u," + " _endFrame = %d, _intro = %u, _style = %u, _vox = %s", + _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _intro, _style, _vox.c_str()); } void ActionTalk::onStart() { - ActionPlay::onStart(); - _sound = _actor->getPage()->loadSound(_vox); - _sound->play(Audio::Mixer::SoundType::kSpeechSoundType, 100, 0); + ActionPlay::onStart(); + _sound = _actor->getPage()->loadSound(_vox); + _sound->play(Audio::Mixer::SoundType::kSpeechSoundType, 100, 0); } void ActionTalk::update() { - ActionLoop::update(); - if (!_sound->isPlaying()) { - _decoder->stop(); - _actor->endAction(); - } + ActionLoop::update(); + if (!_sound->isPlaying()) { + _decoder->stop(); + _actor->endAction(); + } } void ActionTalk::end() { - ActionPlay::end(); - delete _sound; - _sound = nullptr; + ActionPlay::end(); + delete _sound; + _sound = nullptr; } void ActionTalk::pause() { - ActionCEL::pause(); - if (_sound) - _sound->pause(); + ActionCEL::pause(); + if (_sound) + _sound->pause(); } void ActionTalk::unpause() { - ActionCEL::unpause(); - if (_sound) - _sound->resume(); + ActionCEL::unpause(); + if (_sound) + _sound->resume(); } } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_talk.h b/engines/pink/objects/actions/action_talk.h index 77e8d9099d..61ef1a452f 100644 --- a/engines/pink/objects/actions/action_talk.h +++ b/engines/pink/objects/actions/action_talk.h @@ -31,21 +31,21 @@ class Sound; class ActionTalk : public ActionLoop { public: - virtual void deserialize(Archive &archive); - virtual void toConsole(); - virtual void update(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); + virtual void update(); - virtual void end(); + virtual void end(); - void pause() override; - void unpause() override; + void pause() override; + void unpause() override; protected: - virtual void onStart(); + virtual void onStart(); private: - Sound *_sound; - Common::String _vox; + Sound *_sound; + Common::String _vox; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_text.cpp b/engines/pink/objects/actions/action_text.cpp index 12e2809d21..3e05346b88 100644 --- a/engines/pink/objects/actions/action_text.cpp +++ b/engines/pink/objects/actions/action_text.cpp @@ -28,19 +28,19 @@ namespace Pink { void ActionText::deserialize(Archive &archive) { - for (int i = 0; i < 4 ; ++i) { - _bounds[i] = archive.readDWORD(); - } - _centered = archive.readDWORD(); - _scrollBar = archive.readDWORD(); - _textColor = archive.readDWORD(); - _backgroundColor = archive.readDWORD(); + for (int i = 0; i < 4 ; ++i) { + _bounds[i] = archive.readDWORD(); + } + _centered = archive.readDWORD(); + _scrollBar = archive.readDWORD(); + _textColor = archive.readDWORD(); + _backgroundColor = archive.readDWORD(); } void ActionText::toConsole() { - debug("\tActionText: _name = %s, _text = %s, " - "_bound0 = %u, _bound1 = %u, _bound2 = %u, _bound3 = %u _centered = %u, _scrollBar = %u, _textColor = %u _backgroundColor = %u", - _name.c_str(), _text.c_str(), _bounds[0], _bounds[1], _bounds[2], _bounds[3], _centered, _scrollBar, _textColor, _backgroundColor); + debug("\tActionText: _name = %s, _text = %s, " + "_bound0 = %u, _bound1 = %u, _bound2 = %u, _bound3 = %u _centered = %u, _scrollBar = %u, _textColor = %u _backgroundColor = %u", + _name.c_str(), _text.c_str(), _bounds[0], _bounds[1], _bounds[2], _bounds[3], _centered, _scrollBar, _textColor, _backgroundColor); } } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_text.h b/engines/pink/objects/actions/action_text.h index 22159490ce..c881610fad 100644 --- a/engines/pink/objects/actions/action_text.h +++ b/engines/pink/objects/actions/action_text.h @@ -29,17 +29,17 @@ namespace Pink { class ActionText : public Action { public: - void deserialize(Archive &archive) override; + void deserialize(Archive &archive) override; - void toConsole() override; + void toConsole() override; private: - Common::String _text; - uint32 _bounds[4]; - uint32 _centered; - uint32 _scrollBar; - uint32 _textColor; - uint32 _backgroundColor; + Common::String _text; + uint32 _bounds[4]; + uint32 _centered; + uint32 _scrollBar; + uint32 _textColor; + uint32 _backgroundColor; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/walk_action.cpp b/engines/pink/objects/actions/walk_action.cpp index d05e94eadb..e4e35184ca 100644 --- a/engines/pink/objects/actions/walk_action.cpp +++ b/engines/pink/objects/actions/walk_action.cpp @@ -27,18 +27,18 @@ namespace Pink { void WalkAction::deserialize(Archive &archive) { - ActionCEL::deserialize(archive); - uint32 calcFramePositions = archive.readDWORD(); - _toCalcFramePositions = calcFramePositions; + ActionCEL::deserialize(archive); + uint32 calcFramePositions = archive.readDWORD(); + _toCalcFramePositions = calcFramePositions; } void WalkAction::toConsole() { - debug("\tWalkAction: _name = %s, _fileName = %s, _calcFramePositions = %u", - _name.c_str(), _fileName.c_str(), _toCalcFramePositions); + debug("\tWalkAction: _name = %s, _fileName = %s, _calcFramePositions = %u", + _name.c_str(), _fileName.c_str(), _toCalcFramePositions); } void WalkAction::onStart() { - _decoder->start(); + _decoder->start(); } } // End of namespace Pink diff --git a/engines/pink/objects/actions/walk_action.h b/engines/pink/objects/actions/walk_action.h index 21926ab9c1..d53c8c2bdc 100644 --- a/engines/pink/objects/actions/walk_action.h +++ b/engines/pink/objects/actions/walk_action.h @@ -29,15 +29,15 @@ namespace Pink { class WalkAction : public ActionCEL { public: - virtual void deserialize(Archive &archive); + virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void toConsole(); protected: - void onStart() override; + void onStart() override; private: - bool _toCalcFramePositions; + bool _toCalcFramePositions; }; } // End of namespace Pink diff --git a/engines/pink/objects/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp index 4853f8d2ff..e6545f3a1f 100644 --- a/engines/pink/objects/actors/actor.cpp +++ b/engines/pink/objects/actors/actor.cpp @@ -30,20 +30,20 @@ namespace Pink { void Actor::deserialize(Archive &archive) { - NamedObject::deserialize(archive); - _page = static_cast<GamePage*>(archive.readObject()); - _actions.deserialize(archive); + NamedObject::deserialize(archive); + _page = static_cast<GamePage*>(archive.readObject()); + _actions.deserialize(archive); } void Actor::toConsole() { - debug("Actor: _name = %s", _name.c_str()); - for (uint i = 0; i < _actions.size(); ++i) { - _actions[i]->toConsole(); - } + debug("Actor: _name = %s", _name.c_str()); + for (uint i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } } Sequencer *Actor::getSequencer() const { - return _page->getSequencer(); + return _page->getSequencer(); } Action *Actor::findAction(const Common::String &name) { @@ -56,112 +56,112 @@ Action *Actor::findAction(const Common::String &name) { } GamePage *Actor::getPage() const { - return _page; + return _page; } void Actor::init(bool unk) { - if (!_action) { - _action = findAction(kIdleAction); - } + if (!_action) { + _action = findAction(kIdleAction); + } - if (!_action) { - _isActionEnded = 1; - } - else { - _isActionEnded = 0; - _action->start(unk); - } + if (!_action) { + _isActionEnded = 1; + } + else { + _isActionEnded = 0; + _action->start(unk); + } } void Actor::hide() { - setAction(kHideAction); + setAction(kHideAction); } void Actor::endAction() { - _isActionEnded = 1; + _isActionEnded = 1; } void Actor::setAction(const Common::String &name) { - Action *newAction = findAction(name); - setAction(newAction); + Action *newAction = findAction(name); + setAction(newAction); } void Actor::setAction(Action *newAction) { - if (_action) { - _isActionEnded = 1; - _action->end(); - } - _action = newAction; - if (newAction) { - _isActionEnded = 0; - _action->start(0); - } + if (_action) { + _isActionEnded = 1; + _action->end(); + } + _action = newAction; + if (newAction) { + _isActionEnded = 0; + _action->start(0); + } } void Actor::setAction(Action *newAction, bool unk) { - if (unk) { - assert(0); // want to see this - _isActionEnded = 1; - _action = newAction; - } - else { + if (unk) { + assert(0); // want to see this + _isActionEnded = 1; + _action = newAction; + } + else { setAction(newAction); } } Action *Actor::getAction() const { - return _action; + return _action; } bool Actor::isPlaying() { - return !_isActionEnded; + return !_isActionEnded; } bool Actor::initPallete(Director *director) { - for (uint i = 0; i < _actions.size(); ++i) { - if (_actions[i]->initPalette(director)) - return true; - } - return false; + for (uint i = 0; i < _actions.size(); ++i) { + if (_actions[i]->initPalette(director)) + return true; + } + return false; } void Actor::onMouseOver(Common::Point point, CursorMgr *mgr) { - mgr->setCursor(kDefaultCursor, point, Common::String()); + mgr->setCursor(kDefaultCursor, point, Common::String()); } Actor::~Actor() { - for (uint i = 0; i < _actions.size(); ++i) { - delete _actions[i]; - } + for (uint i = 0; i < _actions.size(); ++i) { + delete _actions[i]; + } } void Actor::loadState(Archive &archive) { - Common::String actionName; - actionName = archive.readString(); - _action = findAction(actionName); + Common::String actionName; + actionName = archive.readString(); + _action = findAction(actionName); } void Actor::saveState(Archive &archive) { - Common::String actionName; + Common::String actionName; - if (_action) - actionName = _action->getName(); + if (_action) + actionName = _action->getName(); - archive.writeString(actionName); + archive.writeString(actionName); } void Actor::pause() { - if (_action) - _action->pause(); + if (_action) + _action->pause(); } void Actor::unpause() { - if (_action) - _action->unpause(); + if (_action) + _action->unpause(); } void Actor::onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) { - cursorMgr->setCursor(kHoldingItemCursor, point, itemName); + cursorMgr->setCursor(kHoldingItemCursor, point, itemName); } } // End of namespace Pink diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h index b7650a20d0..cfbc358d70 100644 --- a/engines/pink/objects/actors/actor.h +++ b/engines/pink/objects/actors/actor.h @@ -39,49 +39,49 @@ class InventoryMgr; class Actor : public NamedObject { public: - Actor() - : _page(nullptr), _action(nullptr), - _isActionEnded(1) - {}; - ~Actor(); - virtual void deserialize(Archive &archive); + Actor() + : _page(nullptr), _action(nullptr), + _isActionEnded(1) + {}; + ~Actor(); + virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void toConsole(); - Sequencer *getSequencer() const; - GamePage *getPage() const; - Action *getAction() const; + Sequencer *getSequencer() const; + GamePage *getPage() const; + Action *getAction() const; - bool isPlaying(); - virtual void init(bool unk); - void hide(); - void endAction(); + bool isPlaying(); + virtual void init(bool unk); + void hide(); + void endAction(); - Action *findAction(const Common::String &name); - void setAction(const Common::String &name); - void setAction(Action *newAction); - void setAction(Action *newAction, bool unk); + Action *findAction(const Common::String &name); + void setAction(const Common::String &name); + void setAction(Action *newAction); + void setAction(Action *newAction, bool unk); - void loadState(Archive &archive); - void saveState(Archive &archive); + void loadState(Archive &archive); + void saveState(Archive &archive); - bool initPallete(Director *director); + bool initPallete(Director *director); - virtual void update() {}; + virtual void update() {}; - virtual void onMouseOver(Common::Point point, CursorMgr *mgr); - virtual void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr); + virtual void onMouseOver(Common::Point point, CursorMgr *mgr); + virtual void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr); - virtual bool isClickable() { return 0;} + virtual bool isClickable() { return 0;} - virtual void pause(); - virtual void unpause(); + virtual void pause(); + virtual void unpause(); protected: - GamePage *_page; - Action *_action; - Array<Action*> _actions; - bool _isActionEnded; + GamePage *_page; + Action *_action; + Array<Action*> _actions; + bool _isActionEnded; }; } // End of namespace Pink diff --git a/engines/pink/objects/actors/audio_info_pda_button.h b/engines/pink/objects/actors/audio_info_pda_button.h index 63badfd64f..05c8408fe5 100644 --- a/engines/pink/objects/actors/audio_info_pda_button.h +++ b/engines/pink/objects/actors/audio_info_pda_button.h @@ -34,20 +34,20 @@ namespace Pink { class AudioInfoPDAButton : public Actor { public: - void toConsole() { - debug("CursorActor: _name = %s", _name.c_str()); - for (uint i = 0; i < _actions.size(); ++i) { - _actions[i]->toConsole(); - } - } - - void onMouseOver(Common::Point point, CursorMgr *mgr) override { - mgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); - } - - void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) override { - onMouseOver(point, cursorMgr); - } + void toConsole() { + debug("CursorActor: _name = %s", _name.c_str()); + for (uint i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } + } + + void onMouseOver(Common::Point point, CursorMgr *mgr) override { + mgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); + } + + void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) override { + onMouseOver(point, cursorMgr); + } }; } // End of namespace Pink diff --git a/engines/pink/objects/actors/cursor_actor.h b/engines/pink/objects/actors/cursor_actor.h index 7c83a6b289..897728c30c 100644 --- a/engines/pink/objects/actors/cursor_actor.h +++ b/engines/pink/objects/actors/cursor_actor.h @@ -33,12 +33,12 @@ namespace Pink { //same as actor class CursorActor : public Actor { public: - void toConsole() { - debug("CursorActor: _name = %s", _name.c_str()); - for (uint i = 0; i < _actions.size(); ++i) { - _actions[i]->toConsole(); - } - } + void toConsole() { + debug("CursorActor: _name = %s", _name.c_str()); + for (uint i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } + } }; } // End of namespace Pink diff --git a/engines/pink/objects/actors/inventory_actor.h b/engines/pink/objects/actors/inventory_actor.h index 61ebbc4c09..4e6edef5a1 100644 --- a/engines/pink/objects/actors/inventory_actor.h +++ b/engines/pink/objects/actors/inventory_actor.h @@ -32,14 +32,14 @@ namespace Pink { class InventoryActor : public Actor { public: - void toConsole() { - debug("CursorActor: _name = %s", _name.c_str()); - for (uint i = 0; i < _actions.size(); ++i) { - _actions[i]->toConsole(); - } - } - - void pause() {} + void toConsole() { + debug("CursorActor: _name = %s", _name.c_str()); + for (uint i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } + } + + void pause() {} }; } // End of namespace Pink diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp index 05d9a763f4..f414cd6e30 100644 --- a/engines/pink/objects/actors/lead_actor.cpp +++ b/engines/pink/objects/actors/lead_actor.cpp @@ -34,382 +34,382 @@ namespace Pink { void LeadActor::deserialize(Archive &archive) { - _state = kReady; - Actor::deserialize(archive); - _cursorMgr = static_cast<CursorMgr*>(archive.readObject()); - _walkMgr = static_cast<WalkMgr*>(archive.readObject()); - _sequencer = static_cast<Sequencer*>(archive.readObject()); + _state = kReady; + Actor::deserialize(archive); + _cursorMgr = static_cast<CursorMgr*>(archive.readObject()); + _walkMgr = static_cast<WalkMgr*>(archive.readObject()); + _sequencer = static_cast<Sequencer*>(archive.readObject()); } void LeadActor::setNextExecutors(Common::String &nextModule, Common::String &nextPage) { - if (_state == kReady || _state == kMoving || _state == kInDialog1 || _state == kInventory || _state == kPDA) { - _state = kPlayingVideo; - _page->getGame()->setNextExecutors(nextModule, nextPage); - } + if (_state == kReady || _state == kMoving || _state == kInDialog1 || _state == kInventory || _state == kPDA) { + _state = kPlayingVideo; + _page->getGame()->setNextExecutors(nextModule, nextPage); + } } void LeadActor::init(bool unk) { - if (_state == kUnk_Loading){ - _state = kReady; - } - _page->getModule()->getInventoryMgr()->setLeadActor(this); - _page->getGame()->setLeadActor(this); - Actor::init(unk); + if (_state == kUnk_Loading){ + _state = kReady; + } + _page->getModule()->getInventoryMgr()->setLeadActor(this); + _page->getGame()->setLeadActor(this); + Actor::init(unk); } void LeadActor::toConsole() { - debug("LeadActor: _name = %s", _name.c_str()); - for (uint i = 0; i < _actions.size(); ++i) { - _actions[i]->toConsole(); - } + debug("LeadActor: _name = %s", _name.c_str()); + for (uint i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } } LeadActor::State LeadActor::getState() const { - return _state; + return _state; } void LeadActor::update() { - switch (_state) { - case kReady: - _sequencer->update(); - _cursorMgr->update(); - break; - case kMoving: - _walkMgr->update(); - _cursorMgr->update(); - break; - case kInDialog1: - case kInDialog2: - _sequencer->update(); - if (!_sequencer->_context){ - _state = _nextState; - _nextState = kUnk_Loading; - } - break; - - case kInventory: - getPage()->getModule()->getInventoryMgr()->update(); - break; - case kPDA: - break; - - case kPlayingVideo: - _sequencer->update(); - if (!_sequencer->_context){ - _state = kUnk_Loading; - _page->getGame()->changeScene(_page); - } - break; - case kUnk_Loading: - break; - } + switch (_state) { + case kReady: + _sequencer->update(); + _cursorMgr->update(); + break; + case kMoving: + _walkMgr->update(); + _cursorMgr->update(); + break; + case kInDialog1: + case kInDialog2: + _sequencer->update(); + if (!_sequencer->_context){ + _state = _nextState; + _nextState = kUnk_Loading; + } + break; + + case kInventory: + getPage()->getModule()->getInventoryMgr()->update(); + break; + case kPDA: + break; + + case kPlayingVideo: + _sequencer->update(); + if (!_sequencer->_context){ + _state = kUnk_Loading; + _page->getGame()->changeScene(_page); + } + break; + case kUnk_Loading: + break; + } } void LeadActor::onKeyboardButtonClick(Common::KeyCode code) { - switch(_state) { - case kMoving: - switch (code){ - case Common::KEYCODE_ESCAPE: - // set unk variables - // Fall Through intended - case Common::KEYCODE_SPACE: - //skip walking animation - default: - break; - } - break; - case kInDialog1: - case kInDialog2: - case kPlayingVideo: - switch (code) { - case Common::KEYCODE_SPACE: - case Common::KEYCODE_RIGHT: - _sequencer->skipSubSequence(); - break; - case Common::KEYCODE_ESCAPE: - _sequencer->skipToLastSubSequence(); - break; - case Common::KEYCODE_LEFT: - _sequencer->restartSequence(); - break; - default: - break; - } - break; - default: - break; - } + switch(_state) { + case kMoving: + switch (code){ + case Common::KEYCODE_ESCAPE: + // set unk variables + // Fall Through intended + case Common::KEYCODE_SPACE: + //skip walking animation + default: + break; + } + break; + case kInDialog1: + case kInDialog2: + case kPlayingVideo: + switch (code) { + case Common::KEYCODE_SPACE: + case Common::KEYCODE_RIGHT: + _sequencer->skipSubSequence(); + break; + case Common::KEYCODE_ESCAPE: + _sequencer->skipToLastSubSequence(); + break; + case Common::KEYCODE_LEFT: + _sequencer->restartSequence(); + break; + default: + break; + } + break; + default: + break; + } } void LeadActor::start(bool isHandler) { - if (isHandler && _state != kPlayingVideo){ - _state = kInDialog1; - _nextState = kReady; - } - forceUpdateCursor(); + if (isHandler && _state != kPlayingVideo){ + _state = kInDialog1; + _nextState = kReady; + } + forceUpdateCursor(); } void LeadActor::onMouseMove(Common::Point point) { - if (_state != kPDA) - updateCursor(point); - else error("pda is not supported"); + if (_state != kPDA) + updateCursor(point); + else error("pda is not supported"); } void LeadActor::updateCursor(Common::Point point) { - switch (_state) { - case kReady: - case kMoving: { - Director *director = _page->getGame()->getDirector(); - Actor *actor = director->getActorByPoint(point); - InventoryItem *item = _page->getModule()->getInventoryMgr()->getCurrentItem(); - if (_isHaveItem) { - if (actor) { - actor->onHover(point, item->getName(), _cursorMgr); - } - else _cursorMgr->setCursor(kHoldingItemCursor, point, item->getName()); - } - else if (actor) - actor->onMouseOver(point, _cursorMgr); - else _cursorMgr->setCursor(kDefaultCursor, point, Common::String()); - break; - } - case kInDialog1: - case kInDialog2: - case kPlayingVideo: - _cursorMgr->setCursor(kNotClickableCursor, point, Common::String()); - break; - case kPDA: - case kInventory: - _cursorMgr->setCursor(kDefaultCursor, point, Common::String()); - break; - default: - break; - } + switch (_state) { + case kReady: + case kMoving: { + Director *director = _page->getGame()->getDirector(); + Actor *actor = director->getActorByPoint(point); + InventoryItem *item = _page->getModule()->getInventoryMgr()->getCurrentItem(); + if (_isHaveItem) { + if (actor) { + actor->onHover(point, item->getName(), _cursorMgr); + } + else _cursorMgr->setCursor(kHoldingItemCursor, point, item->getName()); + } + else if (actor) + actor->onMouseOver(point, _cursorMgr); + else _cursorMgr->setCursor(kDefaultCursor, point, Common::String()); + break; + } + case kInDialog1: + case kInDialog2: + case kPlayingVideo: + _cursorMgr->setCursor(kNotClickableCursor, point, Common::String()); + break; + case kPDA: + case kInventory: + _cursorMgr->setCursor(kDefaultCursor, point, Common::String()); + break; + default: + break; + } } void LeadActor::onLeftButtonClick(Common::Point point) { - InventoryMgr *invMgr = _page->getModule()->getInventoryMgr(); - - switch (_state) { - case kReady: - case kMoving: { - Actor *actor = _page->getGame()->getDirector()->getActorByPoint(point); - - if (this == actor) { - onClick(); - return; - } - - _recipient = dynamic_cast<SupportingActor*>(actor); - if (actor->isClickable() && isInteractingWith(_recipient)) { - WalkLocation *location = getWalkDestination(); - if (location) { - _state = kMoving; - _nextState = kInDialog1; - _walkMgr->start(location); - } - else if (_state == kReady){ - if (_isHaveItem) - sendUseClickMessage(_recipient); - else sendLeftClickMessage(_recipient); - } - } - - break; - } - case kPDA: - - break; - case kInventory: - invMgr->onClick(point); - break; - default: - break; - } + InventoryMgr *invMgr = _page->getModule()->getInventoryMgr(); + + switch (_state) { + case kReady: + case kMoving: { + Actor *actor = _page->getGame()->getDirector()->getActorByPoint(point); + + if (this == actor) { + onClick(); + return; + } + + _recipient = dynamic_cast<SupportingActor*>(actor); + if (actor->isClickable() && isInteractingWith(_recipient)) { + WalkLocation *location = getWalkDestination(); + if (location) { + _state = kMoving; + _nextState = kInDialog1; + _walkMgr->start(location); + } + else if (_state == kReady){ + if (_isHaveItem) + sendUseClickMessage(_recipient); + else sendLeftClickMessage(_recipient); + } + } + + break; + } + case kPDA: + + break; + case kInventory: + invMgr->onClick(point); + break; + default: + break; + } } void LeadActor::onMouseOver(Common::Point point, CursorMgr *mgr) { - if (_page->getModule()->getInventoryMgr()->isPinkOwnsAnyItems()) - _cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); - else Actor::onMouseOver(point, mgr); + if (_page->getModule()->getInventoryMgr()->isPinkOwnsAnyItems()) + _cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); + else Actor::onMouseOver(point, mgr); } void LeadActor::onWalkEnd() { - State oldNextState = _nextState; - _state = kReady; - _nextState = kUnk_Loading; - if (_recipient && oldNextState == kInDialog1){ - if (_isHaveItem) - sendUseClickMessage(_recipient); - else sendLeftClickMessage(_recipient); - } + State oldNextState = _nextState; + _state = kReady; + _nextState = kUnk_Loading; + if (_recipient && oldNextState == kInDialog1){ + if (_isHaveItem) + sendUseClickMessage(_recipient); + else sendLeftClickMessage(_recipient); + } } bool LeadActor::sendUseClickMessage(SupportingActor *actor) { - InventoryMgr *mgr = _page->getModule()->getInventoryMgr(); - _nextState = _state != kPlayingVideo ? kReady : kPlayingVideo; - _state = kInDialog1; - InventoryItem *item = mgr->getCurrentItem(); - actor->onUseClickMessage(mgr->getCurrentItem(), mgr); - if (item->getCurrentOwner() != this->_name) - _isHaveItem = false; - return true; + InventoryMgr *mgr = _page->getModule()->getInventoryMgr(); + _nextState = _state != kPlayingVideo ? kReady : kPlayingVideo; + _state = kInDialog1; + InventoryItem *item = mgr->getCurrentItem(); + actor->onUseClickMessage(mgr->getCurrentItem(), mgr); + if (item->getCurrentOwner() != this->_name) + _isHaveItem = false; + return true; } bool LeadActor::sendLeftClickMessage(SupportingActor *actor) { - _nextState = _state != kPlayingVideo ? kReady : kPlayingVideo; - _state = kInDialog1; - return actor->onLeftClickMessage(); + _nextState = _state != kPlayingVideo ? kReady : kPlayingVideo; + _state = kInDialog1; + return actor->onLeftClickMessage(); } void LeadActor::onClick() { - if (_isHaveItem) { - _isHaveItem = false; - _nextState = (_state != kMoving) ? - kUnk_Loading : kReady; - } - else { - if (_state == kMoving) { - _recipient = nullptr; - _nextState = kReady; - } - if (_page->getModule()->getInventoryMgr()->start(1)){ - _stateCopy = _state; - _state = kInventory; - _page->pause(); - } - } + if (_isHaveItem) { + _isHaveItem = false; + _nextState = (_state != kMoving) ? + kUnk_Loading : kReady; + } + else { + if (_state == kMoving) { + _recipient = nullptr; + _nextState = kReady; + } + if (_page->getModule()->getInventoryMgr()->start(1)){ + _stateCopy = _state; + _state = kInventory; + _page->pause(); + } + } } LeadActor::LeadActor() - : _state(kReady), _nextState(kReady), - _isHaveItem(false), _recipient(nullptr), - _cursorMgr(nullptr), _walkMgr(nullptr), - _sequencer(nullptr) + : _state(kReady), _nextState(kReady), + _isHaveItem(false), _recipient(nullptr), + _cursorMgr(nullptr), _walkMgr(nullptr), + _sequencer(nullptr) {} void LeadActor::onInventoryClosed(bool isItemClicked) { - _isHaveItem = isItemClicked; - _state = _stateCopy; - _stateCopy = kUnk_Loading; - _page->unpause(); - forceUpdateCursor(); + _isHaveItem = isItemClicked; + _state = _stateCopy; + _stateCopy = kUnk_Loading; + _page->unpause(); + forceUpdateCursor(); } void LeadActor::forceUpdateCursor() { - Common::Point point = _page->getGame()->getEventManager()->getMousePos(); - updateCursor(point); + Common::Point point = _page->getGame()->getEventManager()->getMousePos(); + updateCursor(point); } WalkLocation *LeadActor::getWalkDestination() { - return _walkMgr->findLocation(_recipient->getLocation()); + return _walkMgr->findLocation(_recipient->getLocation()); } bool LeadActor::isInteractingWith(SupportingActor *actor) { - if (!_isHaveItem) - return actor->isLeftClickHandlers(); + if (!_isHaveItem) + return actor->isLeftClickHandlers(); - return actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem()); + return actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem()); } void ParlSqPink::toConsole() { - debug("ParlSqPink: _name = %s", _name.c_str()); - for (uint i = 0; i < _actions.size(); ++i) { - _actions[i]->toConsole(); - } + debug("ParlSqPink: _name = %s", _name.c_str()); + for (uint i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } } WalkLocation *ParlSqPink::getWalkDestination() { - if (_recipient->getName() == kBoy && - _page->checkValueOfVariable(kBoyBlocked, kUndefined)) - { - return _walkMgr->findLocation(kSirBaldley); - } - return LeadActor::getWalkDestination(); + if (_recipient->getName() == kBoy && + _page->checkValueOfVariable(kBoyBlocked, kUndefined)) + { + return _walkMgr->findLocation(kSirBaldley); + } + return LeadActor::getWalkDestination(); } PubPink::PubPink() : - LeadActor(), _round(0) + LeadActor(), _round(0) {} void PubPink::toConsole() { - debug("PubPink: _name = %s", _name.c_str()); - for (uint i = 0; i < _actions.size(); ++i) { - _actions[i]->toConsole(); - } + debug("PubPink: _name = %s", _name.c_str()); + for (uint i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } } bool PubPink::playingMiniGame() { - return !(_page->checkValueOfVariable(kFoodPuzzle, "TRUE") || - _page->checkValueOfVariable(kFoodPuzzle, kUndefined)); + return !(_page->checkValueOfVariable(kFoodPuzzle, "TRUE") || + _page->checkValueOfVariable(kFoodPuzzle, kUndefined)); } void PubPink::onClick() { - if (!playingMiniGame()) - LeadActor::onClick(); + if (!playingMiniGame()) + LeadActor::onClick(); } void PubPink::updateCursor(Common::Point point) { - if (playingMiniGame()) { - SupportingActor *actor = dynamic_cast<SupportingActor*>(_page->getGame()->getDirector()->getActorByPoint(point)); - if (_state == kReady && - actor && - actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem())) - { - _cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); - } - else _cursorMgr->setCursor(kDefaultCursor, point, Common::String()); - } - else LeadActor::updateCursor(point); + if (playingMiniGame()) { + SupportingActor *actor = dynamic_cast<SupportingActor*>(_page->getGame()->getDirector()->getActorByPoint(point)); + if (_state == kReady && + actor && + actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem())) + { + _cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); + } + else _cursorMgr->setCursor(kDefaultCursor, point, Common::String()); + } + else LeadActor::updateCursor(point); } WalkLocation *PubPink::getWalkDestination() { - if (playingMiniGame()) - return nullptr; + if (playingMiniGame()) + return nullptr; - if (_recipient->getName() == kJackson && - !_page->checkValueOfVariable(kDrunkLocation, kBolted)) - { - return _walkMgr->findLocation(_page->findActor(kDrunk)->getName()); - } + if (_recipient->getName() == kJackson && + !_page->checkValueOfVariable(kDrunkLocation, kBolted)) + { + return _walkMgr->findLocation(_page->findActor(kDrunk)->getName()); + } - return LeadActor::getWalkDestination(); + return LeadActor::getWalkDestination(); } bool PubPink::sendUseClickMessage(SupportingActor *actor) { if (!LeadActor::sendUseClickMessage(actor) && - playingMiniGame()) { - _nextState = _state; - _state = kInDialog1; - - const char *roundName; - switch (_round++ % 3) { - case 0: - roundName = kFirstRound; - break; - case 1: - roundName = kSecondRound; - break; - case 2: - roundName = kThirdRound; - break; - default: - roundName = nullptr; - assert(0); - break; - } - _sequencer->authorSequence(_sequencer->findSequence(roundName), 0); + playingMiniGame()) { + _nextState = _state; + _state = kInDialog1; + + const char *roundName; + switch (_round++ % 3) { + case 0: + roundName = kFirstRound; + break; + case 1: + roundName = kSecondRound; + break; + case 2: + roundName = kThirdRound; + break; + default: + roundName = nullptr; + assert(0); + break; + } + _sequencer->authorSequence(_sequencer->findSequence(roundName), 0); } if (playingMiniGame()) - _isHaveItem = true; + _isHaveItem = true; return true; } void PubPink::onVariableSet() { - if (playingMiniGame()) - _isHaveItem = true; + if (playingMiniGame()) + _isHaveItem = true; } } // End of namespace Pink diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h index b6f91acabf..7dff2e86df 100644 --- a/engines/pink/objects/actors/lead_actor.h +++ b/engines/pink/objects/actors/lead_actor.h @@ -40,89 +40,89 @@ class InventoryItem; class LeadActor : public Actor { public: - LeadActor(); - enum State { - kReady = 0, - kMoving = 1, - kInDialog1 = 2, //??? - kInventory = 3, - kPDA = 4, - kInDialog2 = 5,//??? - kPlayingVideo = 6, // ??? - kUnk_Loading = 7// ???? - }; + LeadActor(); + enum State { + kReady = 0, + kMoving = 1, + kInDialog1 = 2, //??? + kInventory = 3, + kPDA = 4, + kInDialog2 = 5,//??? + kPlayingVideo = 6, // ??? + kUnk_Loading = 7// ???? + }; - virtual void deserialize(Archive &archive); + virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void toConsole(); - void setNextExecutors (Common::String &nextModule, Common::String &nextPage); - virtual void init(bool unk); + void setNextExecutors (Common::String &nextModule, Common::String &nextPage); + virtual void init(bool unk); - State getState() const; + State getState() const; - void start(bool isHandler); - void update(); + void start(bool isHandler); + void update(); - void onKeyboardButtonClick(Common::KeyCode code); - void onLeftButtonClick(Common::Point point); - void onMouseMove(Common::Point point); - void onWalkEnd(); - virtual void onClick(); - void onInventoryClosed(bool isItemClicked); - virtual void onVariableSet() {}; + void onKeyboardButtonClick(Common::KeyCode code); + void onLeftButtonClick(Common::Point point); + void onMouseMove(Common::Point point); + void onWalkEnd(); + virtual void onClick(); + void onInventoryClosed(bool isItemClicked); + virtual void onVariableSet() {}; - virtual void onMouseOver(Common::Point point, CursorMgr *mgr); + virtual void onMouseOver(Common::Point point, CursorMgr *mgr); - bool isInteractingWith(SupportingActor *actor); + bool isInteractingWith(SupportingActor *actor); protected: - virtual void updateCursor(Common::Point point); - void forceUpdateCursor(); + virtual void updateCursor(Common::Point point); + void forceUpdateCursor(); - virtual bool sendUseClickMessage(SupportingActor *actor); - bool sendLeftClickMessage(SupportingActor *actor); + virtual bool sendUseClickMessage(SupportingActor *actor); + bool sendLeftClickMessage(SupportingActor *actor); - virtual WalkLocation *getWalkDestination(); + virtual WalkLocation *getWalkDestination(); - State _state; - State _nextState; - State _stateCopy; + State _state; + State _nextState; + State _stateCopy; - bool _isHaveItem; + bool _isHaveItem; - SupportingActor *_recipient; + SupportingActor *_recipient; - CursorMgr *_cursorMgr; - WalkMgr *_walkMgr; - Sequencer *_sequencer; + CursorMgr *_cursorMgr; + WalkMgr *_walkMgr; + Sequencer *_sequencer; }; class ParlSqPink : public LeadActor { public: - virtual WalkLocation *getWalkDestination(); - void toConsole(); + virtual WalkLocation *getWalkDestination(); + void toConsole(); }; class PubPink : public LeadActor { public: - PubPink(); + PubPink(); - void toConsole(); + void toConsole(); - virtual void onClick(); - virtual void onVariableSet(); + virtual void onClick(); + virtual void onVariableSet(); private: - int _round; + int _round; - virtual bool sendUseClickMessage(SupportingActor *actor); - virtual void updateCursor(Common::Point point); - virtual WalkLocation *getWalkDestination(); + virtual bool sendUseClickMessage(SupportingActor *actor); + virtual void updateCursor(Common::Point point); + virtual WalkLocation *getWalkDestination(); - bool playingMiniGame(); + bool playingMiniGame(); }; diff --git a/engines/pink/objects/actors/pda_button_actor.cpp b/engines/pink/objects/actors/pda_button_actor.cpp index 1057a060e4..65e3f7ba21 100644 --- a/engines/pink/objects/actors/pda_button_actor.cpp +++ b/engines/pink/objects/actors/pda_button_actor.cpp @@ -25,18 +25,18 @@ namespace Pink { void PDAButtonActor::deserialize(Archive &archive) { - Actor::deserialize(archive); - _hideOnStop = (bool) archive.readDWORD(); - _opaque = (bool) archive.readDWORD(); + Actor::deserialize(archive); + _hideOnStop = (bool) archive.readDWORD(); + _opaque = (bool) archive.readDWORD(); - int comm = archive.readDWORD(); - assert(comm <= 4); - _command = (Command) comm; + int comm = archive.readDWORD(); + assert(comm <= 4); + _command = (Command) comm; } void PDAButtonActor::toConsole() { - debug("PDAButtonActor: _name = %s, _x = %u _y = %u _hideOnStop = %u, _opaque = %u, _command = %u", - _name.c_str(), _x, _y, _hideOnStop, _opaque, (int) _command); + debug("PDAButtonActor: _name = %s, _x = %u _y = %u _hideOnStop = %u, _opaque = %u, _command = %u", + _name.c_str(), _x, _y, _hideOnStop, _opaque, (int) _command); } } // End of namespace Pink diff --git a/engines/pink/objects/actors/pda_button_actor.h b/engines/pink/objects/actors/pda_button_actor.h index c3cd845886..5e7d53b4b4 100644 --- a/engines/pink/objects/actors/pda_button_actor.h +++ b/engines/pink/objects/actors/pda_button_actor.h @@ -29,19 +29,19 @@ namespace Pink { class PDAButtonActor : public Actor { public: - enum Command {Null = 0, GoToPage = 1, Close = 2, Unk = 4}; + enum Command {Null = 0, GoToPage = 1, Close = 2, Unk = 4}; - void deserialize(Archive &archive) override; - void toConsole() override; + void deserialize(Archive &archive) override; + void toConsole() override; private: - int _x; - int _y; + int _x; + int _y; - bool _hideOnStop; - bool _opaque; + bool _hideOnStop; + bool _opaque; - Command _command; + Command _command; }; } // End of namespace Pink diff --git a/engines/pink/objects/actors/supporting_actor.cpp b/engines/pink/objects/actors/supporting_actor.cpp index 9c06dee3fc..3ba10366ed 100644 --- a/engines/pink/objects/actors/supporting_actor.cpp +++ b/engines/pink/objects/actors/supporting_actor.cpp @@ -30,64 +30,64 @@ namespace Pink { void SupportingActor::deserialize(Archive &archive) { - Actor::deserialize(archive); - _location = archive.readString(); - _pdaLink = archive.readString(); - _cursor = archive.readString(); - _handlerMgr.deserialize(archive); + Actor::deserialize(archive); + _location = archive.readString(); + _pdaLink = archive.readString(); + _cursor = archive.readString(); + _handlerMgr.deserialize(archive); } void SupportingActor::toConsole() { - debug("SupportingActor: _name = %s, _location=%s, _pdaLink=%s, _cursor=%s", - _name.c_str(), _location.c_str(), _pdaLink.c_str(), _cursor.c_str()); - for (uint i = 0; i < _actions.size(); ++i) { - _actions[i]->toConsole(); - } - _handlerMgr.toConsole(); + debug("SupportingActor: _name = %s, _location=%s, _pdaLink=%s, _cursor=%s", + _name.c_str(), _location.c_str(), _pdaLink.c_str(), _cursor.c_str()); + for (uint i = 0; i < _actions.size(); ++i) { + _actions[i]->toConsole(); + } + _handlerMgr.toConsole(); } void SupportingActor::onMouseOver(Common::Point point, CursorMgr *mgr) { - if (isLeftClickHandlers()){ - if (!_cursor.empty()){ - mgr->setCursor(_cursor, point); - } - else mgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); - } - else Actor::onMouseOver(point, mgr); + if (isLeftClickHandlers()){ + if (!_cursor.empty()){ + mgr->setCursor(_cursor, point); + } + else mgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); + } + else Actor::onMouseOver(point, mgr); } bool SupportingActor::isLeftClickHandlers() { - return _handlerMgr.isLeftClickHandler(this); + return _handlerMgr.isLeftClickHandler(this); } bool SupportingActor::isUseClickHandlers(InventoryItem *item) { - return _handlerMgr.isUseClickHandler(this, item->getName()); + return _handlerMgr.isUseClickHandler(this, item->getName()); } void SupportingActor::onTimerMessage() { - _handlerMgr.onTimerMessage(this); + _handlerMgr.onTimerMessage(this); } bool SupportingActor::onLeftClickMessage() { - return _handlerMgr.onLeftClickMessage(this); + return _handlerMgr.onLeftClickMessage(this); } bool SupportingActor::onUseClickMessage(InventoryItem *item, InventoryMgr *mgr) { - return _handlerMgr.onUseClickMessage(this, item, mgr); + return _handlerMgr.onUseClickMessage(this, item, mgr); } const Common::String &SupportingActor::getLocation() const { - return _location; + return _location; } SupportingActor::~SupportingActor() {} void SupportingActor::onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) { - Common::String item = itemName; - if (_handlerMgr.isUseClickHandler(this, itemName)) { - item += kClickable; - } - Actor::onHover(point, item, cursorMgr); + Common::String item = itemName; + if (_handlerMgr.isUseClickHandler(this, itemName)) { + item += kClickable; + } + Actor::onHover(point, item, cursorMgr); } } // End of namespace Pink diff --git a/engines/pink/objects/actors/supporting_actor.h b/engines/pink/objects/actors/supporting_actor.h index eecee3a642..d47959dfa9 100644 --- a/engines/pink/objects/actors/supporting_actor.h +++ b/engines/pink/objects/actors/supporting_actor.h @@ -33,30 +33,30 @@ class InventoryMgr; class SupportingActor : public Actor { public: - virtual ~SupportingActor(); - virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual ~SupportingActor(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); - virtual void onMouseOver(Common::Point point, CursorMgr *mgr); + virtual void onMouseOver(Common::Point point, CursorMgr *mgr); - virtual bool isClickable() { return 1; } - bool isLeftClickHandlers(); - bool isUseClickHandlers(InventoryItem *item); + virtual bool isClickable() { return 1; } + bool isLeftClickHandlers(); + bool isUseClickHandlers(InventoryItem *item); - void onTimerMessage(); - bool onLeftClickMessage(); - bool onUseClickMessage(InventoryItem *item, InventoryMgr *mgr); + void onTimerMessage(); + bool onLeftClickMessage(); + bool onUseClickMessage(InventoryItem *item, InventoryMgr *mgr); - virtual void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr); + virtual void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr); - const Common::String &getLocation() const; + const Common::String &getLocation() const; private: - HandlerMgr _handlerMgr; - Common::String _location; - Common::String _pdaLink; - Common::String _cursor; + HandlerMgr _handlerMgr; + Common::String _location; + Common::String _pdaLink; + Common::String _cursor; }; } // End of namespace Pink diff --git a/engines/pink/objects/condition.cpp b/engines/pink/objects/condition.cpp index 4e0b3760b8..abb955028b 100644 --- a/engines/pink/objects/condition.cpp +++ b/engines/pink/objects/condition.cpp @@ -29,71 +29,71 @@ namespace Pink { void Pink::ConditionVariable::deserialize(Archive &archive) { - _name = archive.readString(); - _value = archive.readString(); + _name = archive.readString(); + _value = archive.readString(); } bool Pink::ConditionGameVariable::evaluate(Actor *actor) { - return actor->getPage()->getModule()->getGame()->checkValueOfVariable(_name, _value); + return actor->getPage()->getModule()->getGame()->checkValueOfVariable(_name, _value); } void ConditionGameVariable::toConsole() { - debug("\t\tConditionGameVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); + debug("\t\tConditionGameVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } bool Pink::ConditionModuleVariable::evaluate(Actor *actor) { - return actor->getPage()->getModule()->checkValueOfVariable(_name, _value); + return actor->getPage()->getModule()->checkValueOfVariable(_name, _value); } void ConditionModuleVariable::toConsole() { - debug("\t\tConditionModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); + debug("\t\tConditionModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } bool Pink::ConditionNotModuleVariable::evaluate(Actor *actor) { - return !ConditionModuleVariable::evaluate(actor); + return !ConditionModuleVariable::evaluate(actor); } void ConditionNotModuleVariable::toConsole() { - debug("\t\tConditionNotModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); + debug("\t\tConditionNotModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } bool ConditionPageVariable::evaluate(Actor *actor) { - return actor->getPage()->checkValueOfVariable(_name, _value); + return actor->getPage()->checkValueOfVariable(_name, _value); } void ConditionPageVariable::toConsole() { - debug("\t\tConditionPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); + debug("\t\tConditionPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } bool ConditionNotPageVariable::evaluate(Actor *actor) { - return !ConditionPageVariable::evaluate(actor); + return !ConditionPageVariable::evaluate(actor); } void ConditionNotPageVariable::toConsole() { - debug("\t\tConditionNotPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); + debug("\t\tConditionNotPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } void ConditionInventoryItemOwner::deserialize(Archive &archive) { - _item = archive.readString(); - _owner = archive.readString(); + _item = archive.readString(); + _owner = archive.readString(); } bool ConditionInventoryItemOwner::evaluate(Actor *actor) { - InventoryMgr *mgr = actor->getPage()->getModule()->getInventoryMgr(); - InventoryItem *item = mgr->findInventoryItem(_item); - return item->getCurrentOwner() == _owner; + InventoryMgr *mgr = actor->getPage()->getModule()->getInventoryMgr(); + InventoryItem *item = mgr->findInventoryItem(_item); + return item->getCurrentOwner() == _owner; } void ConditionInventoryItemOwner::toConsole() { - debug("\t\tConditionInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); + debug("\t\tConditionInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); } bool ConditionNotInventoryItemOwner::evaluate(Actor *actor) { - return !ConditionInventoryItemOwner::evaluate(actor); + return !ConditionInventoryItemOwner::evaluate(actor); } void ConditionNotInventoryItemOwner::toConsole() { - debug("\t\tConditionNotInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); + debug("\t\tConditionNotInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); } } // End of namespace Pink diff --git a/engines/pink/objects/condition.h b/engines/pink/objects/condition.h index 505ed2d58d..ff5a6fb793 100644 --- a/engines/pink/objects/condition.h +++ b/engines/pink/objects/condition.h @@ -31,73 +31,73 @@ class Actor; class Condition : public Object { public: - virtual void deserialize(Archive &archive) = 0; - virtual bool evaluate(Actor *actor) = 0; + virtual void deserialize(Archive &archive) = 0; + virtual bool evaluate(Actor *actor) = 0; }; class ConditionVariable : public Condition { public: - virtual void deserialize(Archive &archive); - virtual bool evaluate(Actor *actor) = 0; + virtual void deserialize(Archive &archive); + virtual bool evaluate(Actor *actor) = 0; protected: - Common::String _name; - Common::String _value; + Common::String _name; + Common::String _value; }; class ConditionGameVariable : public ConditionVariable { public: - virtual void toConsole(); - virtual bool evaluate(Actor *actor); + virtual void toConsole(); + virtual bool evaluate(Actor *actor); }; /* * It is not used in games and has evaluate method with infinity recursion class ConditionNotGameVariable : public ConditionGameVariable { - virtual bool evaluate(LeadActor *leadActor); + virtual bool evaluate(LeadActor *leadActor); }; */ class ConditionModuleVariable : public ConditionVariable { public: - virtual void toConsole(); - virtual bool evaluate(Actor *actor); + virtual void toConsole(); + virtual bool evaluate(Actor *actor); }; class ConditionNotModuleVariable : public ConditionModuleVariable { public: - virtual void toConsole(); - virtual bool evaluate(Actor *actor); + virtual void toConsole(); + virtual bool evaluate(Actor *actor); }; class ConditionPageVariable : public ConditionVariable { public: - virtual void toConsole(); - virtual bool evaluate(Actor *actor); + virtual void toConsole(); + virtual bool evaluate(Actor *actor); }; class ConditionNotPageVariable : public ConditionPageVariable { public: - virtual void toConsole(); - virtual bool evaluate(Actor *actor); + virtual void toConsole(); + virtual bool evaluate(Actor *actor); }; class ConditionInventoryItemOwner : public Condition { public: - virtual void toConsole(); - virtual void deserialize(Archive &archive); - virtual bool evaluate(Actor *actor); + virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual bool evaluate(Actor *actor); protected: - Common::String _item; - Common::String _owner; + Common::String _item; + Common::String _owner; }; class ConditionNotInventoryItemOwner : public ConditionInventoryItemOwner { public: - virtual void toConsole(); - virtual bool evaluate(Actor *actor); + virtual void toConsole(); + virtual bool evaluate(Actor *actor); }; } // End of namespace Pink diff --git a/engines/pink/objects/handlers/handler.cpp b/engines/pink/objects/handlers/handler.cpp index 8833153e0c..2f73553f2a 100644 --- a/engines/pink/objects/handlers/handler.cpp +++ b/engines/pink/objects/handlers/handler.cpp @@ -34,123 +34,123 @@ namespace Pink { void Handler::deserialize(Archive &archive) { _conditions.deserialize(archive); - _sideEffects.deserialize(archive); + _sideEffects.deserialize(archive); } bool Handler::isSuitable(Actor *actor) { - for (uint i = 0; i < _conditions.size(); ++i) { - if (!_conditions[i]->evaluate(actor)){ - return false; - } - } - return true; + for (uint i = 0; i < _conditions.size(); ++i) { + if (!_conditions[i]->evaluate(actor)){ + return false; + } + } + return true; } void Handler::executeSideEffects(Actor *actor) { - for (uint i = 0; i < _sideEffects.size(); ++i) { - _sideEffects[i]->execute(actor); - } + for (uint i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->execute(actor); + } } void Handler::handle(Actor *actor) { - executeSideEffects(actor); + executeSideEffects(actor); } Handler::~Handler() { - for (uint i = 0; i < _sideEffects.size(); ++i) { - delete _sideEffects[i]; - } - for (uint i = 0; i < _conditions.size(); ++i) { - delete _conditions[i]; - } + for (uint i = 0; i < _sideEffects.size(); ++i) { + delete _sideEffects[i]; + } + for (uint i = 0; i < _conditions.size(); ++i) { + delete _conditions[i]; + } } void HandlerSequences::deserialize(Archive &archive) { - Handler::deserialize(archive); - _sequences.deserialize(archive); + Handler::deserialize(archive); + _sequences.deserialize(archive); } void HandlerSequences::handle(Actor *actor) { - Handler::handle(actor); - Sequencer *sequencer = actor->getSequencer(); + Handler::handle(actor); + Sequencer *sequencer = actor->getSequencer(); - assert(!_sequences.empty()); + assert(!_sequences.empty()); - Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd(); - uint index = rnd.getRandomNumber(_sequences.size() - 1); + Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd(); + uint index = rnd.getRandomNumber(_sequences.size() - 1); - Sequence *sequence = sequencer->findSequence(_sequences[index]); + Sequence *sequence = sequencer->findSequence(_sequences[index]); - assert(sequence); - sequencer->authorSequence(sequence, 0); + assert(sequence); + sequencer->authorSequence(sequence, 0); - execute(sequence); + execute(sequence); } void HandlerStartPage::execute(Sequence *sequence) { - sequence->_unk = 1; + sequence->_unk = 1; } void HandlerStartPage::toConsole() { - debug("HandlerStartPage:"); - - debug("\tSideEffects:"); - for (uint i = 0; i < _sideEffects.size(); ++i) { - _sideEffects[i]->toConsole(); - } - - debug("\tConditions:"); - for (uint i = 0; i < _conditions.size(); ++i) { - _conditions[i]->toConsole(); - } - - debug("\tSequences:"); - for (uint i = 0; i < _sequences.size(); ++i) { - debug("\t\t%s", _sequences[i].c_str()); - } + debug("HandlerStartPage:"); + + debug("\tSideEffects:"); + for (uint i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (uint i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + + debug("\tSequences:"); + for (uint i = 0; i < _sequences.size(); ++i) { + debug("\t\t%s", _sequences[i].c_str()); + } } void HandlerLeftClick::toConsole() { - debug("HandlerLeftClick:"); - - debug("\tSideEffects:"); - for (uint i = 0; i < _sideEffects.size(); ++i) { - _sideEffects[i]->toConsole(); - } - - debug("\tConditions:"); - for (uint i = 0; i < _conditions.size(); ++i) { - _conditions[i]->toConsole(); - } - - debug("\tSequences:"); - for (uint i = 0; i < _sequences.size(); ++i) { - debug("\t\t%s", _sequences[i].c_str()); - } + debug("HandlerLeftClick:"); + + debug("\tSideEffects:"); + for (uint i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (uint i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + + debug("\tSequences:"); + for (uint i = 0; i < _sequences.size(); ++i) { + debug("\t\t%s", _sequences[i].c_str()); + } } void HandlerUseClick::deserialize(Archive &archive) { - HandlerSequences::deserialize(archive); - _inventoryItem = archive.readString(); - _recepient = archive.readString(); + HandlerSequences::deserialize(archive); + _inventoryItem = archive.readString(); + _recepient = archive.readString(); } void HandlerUseClick::toConsole() { - debug("HandlerUseClick: _inventoryItem=%s, _recepient=%s", _inventoryItem.c_str(), _recepient.c_str()); - debug("\tSideEffects:"); - for (uint i = 0; i < _sideEffects.size(); ++i) { - _sideEffects[i]->toConsole(); - } - - debug("\tConditions:"); - for (uint i = 0; i < _conditions.size(); ++i) { - _conditions[i]->toConsole(); - } - - debug("\tSequences:"); - for (uint i = 0; i < _sequences.size(); ++i) { - debug("\t\t%s", _sequences[i].c_str()); - } + debug("HandlerUseClick: _inventoryItem=%s, _recepient=%s", _inventoryItem.c_str(), _recepient.c_str()); + debug("\tSideEffects:"); + for (uint i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (uint i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + + debug("\tSequences:"); + for (uint i = 0; i < _sequences.size(); ++i) { + debug("\t\t%s", _sequences[i].c_str()); + } } } // End of namespace Pink diff --git a/engines/pink/objects/handlers/handler.h b/engines/pink/objects/handlers/handler.h index 9d0d29833e..98d26620b5 100644 --- a/engines/pink/objects/handlers/handler.h +++ b/engines/pink/objects/handlers/handler.h @@ -36,60 +36,60 @@ class Actor; class Handler : public Object { public: - ~Handler(); - virtual void deserialize(Archive &archive); - virtual void handle(Actor *actor); - bool isSuitable(Actor *actor); + ~Handler(); + virtual void deserialize(Archive &archive); + virtual void handle(Actor *actor); + bool isSuitable(Actor *actor); protected: - void executeSideEffects(Actor *actor); + void executeSideEffects(Actor *actor); - Array<Condition*> _conditions; - Array<SideEffect*> _sideEffects; + Array<Condition*> _conditions; + Array<SideEffect*> _sideEffects; }; class Sequence; class HandlerSequences : public Handler { public: - virtual void deserialize(Archive &archive); - virtual void handle(Actor *actor); + virtual void deserialize(Archive &archive); + virtual void handle(Actor *actor); protected: - virtual void execute(Sequence *sequence) = 0; + virtual void execute(Sequence *sequence) = 0; - StringArray _sequences; + StringArray _sequences; }; class HandlerStartPage : public HandlerSequences { public: - virtual void toConsole(); + virtual void toConsole(); private: - virtual void execute(Sequence *sequence); + virtual void execute(Sequence *sequence); }; class HandlerLeftClick : public HandlerSequences { public: - virtual void toConsole(); + virtual void toConsole(); private: - virtual void execute(Sequence *sequence) {} + virtual void execute(Sequence *sequence) {} }; class HandlerUseClick : public HandlerSequences { public: - virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); - const Common::String &getInventoryItem() const { return _inventoryItem; } - const Common::String &getRecepient() const { return _recepient; } + const Common::String &getInventoryItem() const { return _inventoryItem; } + const Common::String &getRecepient() const { return _recepient; } private: - virtual void execute(Sequence *sequence) {}; + virtual void execute(Sequence *sequence) {}; - Common::String _inventoryItem; - Common::String _recepient; + Common::String _inventoryItem; + Common::String _recepient; }; } // End of namespace Pink diff --git a/engines/pink/objects/handlers/handler_mgr.cpp b/engines/pink/objects/handlers/handler_mgr.cpp index 695030f5d2..cf5b6ca004 100644 --- a/engines/pink/objects/handlers/handler_mgr.cpp +++ b/engines/pink/objects/handlers/handler_mgr.cpp @@ -28,107 +28,107 @@ namespace Pink { void HandlerMgr::deserialize(Archive &archive) { - _leftClickHandlers.deserialize(archive); - _useClickHandlers.deserialize(archive); - _timerHandlers.deserialize(archive); + _leftClickHandlers.deserialize(archive); + _useClickHandlers.deserialize(archive); + _timerHandlers.deserialize(archive); } void HandlerMgr::toConsole() { - debug("HandlerMgr:"); - for (uint i = 0; i < _leftClickHandlers.size(); ++i) { - _leftClickHandlers[i]->toConsole(); - } - for (uint i = 0; i < _useClickHandlers.size(); ++i) { - _useClickHandlers[i]->toConsole(); - } - for (uint i = 0; i < _timerHandlers.size(); ++i) { - _timerHandlers[i]->toConsole(); - } + debug("HandlerMgr:"); + for (uint i = 0; i < _leftClickHandlers.size(); ++i) { + _leftClickHandlers[i]->toConsole(); + } + for (uint i = 0; i < _useClickHandlers.size(); ++i) { + _useClickHandlers[i]->toConsole(); + } + for (uint i = 0; i < _timerHandlers.size(); ++i) { + _timerHandlers[i]->toConsole(); + } } bool HandlerMgr::isLeftClickHandler(Actor *actor) { - for (uint i = 0; i < _leftClickHandlers.size(); ++i) { - if (_leftClickHandlers[i]->isSuitable(actor)) - return true; - } + for (uint i = 0; i < _leftClickHandlers.size(); ++i) { + if (_leftClickHandlers[i]->isSuitable(actor)) + return true; + } - return false; + return false; } bool HandlerMgr::isUseClickHandler(Actor *actor, const Common::String &itemName){ - for (uint i = 0; i < _useClickHandlers.size(); ++i) { - if (itemName == _useClickHandlers[i]->getInventoryItem() && - _useClickHandlers[i]->isSuitable(actor)) - return true; - } + for (uint i = 0; i < _useClickHandlers.size(); ++i) { + if (itemName == _useClickHandlers[i]->getInventoryItem() && + _useClickHandlers[i]->isSuitable(actor)) + return true; + } - return false; + return false; } void HandlerMgr::onTimerMessage(Actor *actor) { - Handler *handler = findSuitableHandlerTimer(actor); - if (handler) - handler->handle(actor); + Handler *handler = findSuitableHandlerTimer(actor); + if (handler) + handler->handle(actor); } bool HandlerMgr::onLeftClickMessage(Actor *actor) { - Handler *handler = findSuitableHandlerLeftClick(actor); - if (handler) { - handler->handle(actor); - return true; - } - return false; + Handler *handler = findSuitableHandlerLeftClick(actor); + if (handler) { + handler->handle(actor); + return true; + } + return false; } bool HandlerMgr::onUseClickMessage(Actor *actor, InventoryItem *item, InventoryMgr *mgr) { - HandlerUseClick *handler = findSuitableHandlerUseClick(actor, item); - if (handler) { - if (!handler->getRecepient().empty()) - mgr->setItemOwner(handler->getRecepient(), item); - handler->handle(actor); - return true; - } - return false; + HandlerUseClick *handler = findSuitableHandlerUseClick(actor, item); + if (handler) { + if (!handler->getRecepient().empty()) + mgr->setItemOwner(handler->getRecepient(), item); + handler->handle(actor); + return true; + } + return false; } Handler *HandlerMgr::findSuitableHandlerTimer(Actor *actor) { - for (uint i = 0; i < _timerHandlers.size(); ++i) { - if (_timerHandlers[i]->isSuitable(actor)) - return _timerHandlers[i]; - } + for (uint i = 0; i < _timerHandlers.size(); ++i) { + if (_timerHandlers[i]->isSuitable(actor)) + return _timerHandlers[i]; + } - return nullptr; + return nullptr; } HandlerLeftClick *HandlerMgr::findSuitableHandlerLeftClick(Actor *actor) { - for (uint i = 0; i < _leftClickHandlers.size(); ++i) { - if (_leftClickHandlers[i]->isSuitable(actor)) - return _leftClickHandlers[i]; - } + for (uint i = 0; i < _leftClickHandlers.size(); ++i) { + if (_leftClickHandlers[i]->isSuitable(actor)) + return _leftClickHandlers[i]; + } - return nullptr; + return nullptr; } HandlerUseClick *HandlerMgr::findSuitableHandlerUseClick(Actor *actor, InventoryItem *item) { - for (uint i = 0; i < _useClickHandlers.size(); ++i) { - if (item->getName() == _useClickHandlers[i]->getInventoryItem() && _useClickHandlers[i]->isSuitable(actor)) - return _useClickHandlers[i]; - } + for (uint i = 0; i < _useClickHandlers.size(); ++i) { + if (item->getName() == _useClickHandlers[i]->getInventoryItem() && _useClickHandlers[i]->isSuitable(actor)) + return _useClickHandlers[i]; + } - return nullptr; + return nullptr; } HandlerMgr::~HandlerMgr() { - for (uint i = 0; i < _leftClickHandlers.size(); ++i) { - delete _leftClickHandlers[i]; - } - for (uint j = 0; j < _useClickHandlers.size(); ++j) { - delete _useClickHandlers[j]; - } - for (uint k = 0; k < _timerHandlers.size(); ++k) { - delete _timerHandlers[k]; - } + for (uint i = 0; i < _leftClickHandlers.size(); ++i) { + delete _leftClickHandlers[i]; + } + for (uint j = 0; j < _useClickHandlers.size(); ++j) { + delete _useClickHandlers[j]; + } + for (uint k = 0; k < _timerHandlers.size(); ++k) { + delete _timerHandlers[k]; + } } } // End of namespace Pink diff --git a/engines/pink/objects/handlers/handler_mgr.h b/engines/pink/objects/handlers/handler_mgr.h index 36e2b05513..dabb329d27 100644 --- a/engines/pink/objects/handlers/handler_mgr.h +++ b/engines/pink/objects/handlers/handler_mgr.h @@ -39,26 +39,26 @@ class Actor; class HandlerMgr : public Object { public: - virtual ~HandlerMgr(); - virtual void deserialize(Archive &archive); + virtual ~HandlerMgr(); + virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void toConsole(); - bool isLeftClickHandler(Actor *actor); - bool isUseClickHandler(Actor *actor, const Common::String &itemName); + bool isLeftClickHandler(Actor *actor); + bool isUseClickHandler(Actor *actor, const Common::String &itemName); - void onTimerMessage(Actor *actor); - bool onLeftClickMessage(Actor *actor); - bool onUseClickMessage(Actor *actor, InventoryItem *item, InventoryMgr *mgr); + void onTimerMessage(Actor *actor); + bool onLeftClickMessage(Actor *actor); + bool onUseClickMessage(Actor *actor, InventoryItem *item, InventoryMgr *mgr); private: - Handler *findSuitableHandlerTimer(Actor *actor); - HandlerLeftClick *findSuitableHandlerLeftClick(Actor *actor); - HandlerUseClick *findSuitableHandlerUseClick(Actor *actor, InventoryItem *item); + Handler *findSuitableHandlerTimer(Actor *actor); + HandlerLeftClick *findSuitableHandlerLeftClick(Actor *actor); + HandlerUseClick *findSuitableHandlerUseClick(Actor *actor, InventoryItem *item); - Array<HandlerLeftClick*> _leftClickHandlers; - Array<HandlerUseClick*> _useClickHandlers; - Array<Handler*> _timerHandlers; + Array<HandlerLeftClick*> _leftClickHandlers; + Array<HandlerUseClick*> _useClickHandlers; + Array<Handler*> _timerHandlers; }; } diff --git a/engines/pink/objects/handlers/handler_timer.cpp b/engines/pink/objects/handlers/handler_timer.cpp index d9f75f67b9..e27d4bb207 100644 --- a/engines/pink/objects/handlers/handler_timer.cpp +++ b/engines/pink/objects/handlers/handler_timer.cpp @@ -36,76 +36,76 @@ namespace Pink { void HandlerTimerActions::deserialize(Archive &archive) { - Handler::deserialize(archive); - _actions.deserialize(archive); + Handler::deserialize(archive); + _actions.deserialize(archive); } void HandlerTimerActions::toConsole() { - debug("HandlerTimerActions:"); - - debug("\tSideEffects:"); - for (uint i = 0; i < _sideEffects.size(); ++i) { - _sideEffects[i]->toConsole(); - } - - debug("\tConditions:"); - for (uint i = 0; i < _conditions.size(); ++i) { - _conditions[i]->toConsole(); - } - - debug("\tActions:"); - for (uint i = 0; i < _actions.size(); ++i) { - debug("\t\t%s", _actions[i].c_str()); - } + debug("HandlerTimerActions:"); + + debug("\tSideEffects:"); + for (uint i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (uint i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + + debug("\tActions:"); + for (uint i = 0; i < _actions.size(); ++i) { + debug("\t\t%s", _actions[i].c_str()); + } } void HandlerTimerActions::handle(Actor *actor) { - Handler::handle(actor); - if (!actor->isPlaying() && !_actions.empty()) { - Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd(); - uint index = rnd.getRandomNumber(_actions.size() - 1); - Action *action = actor->findAction(_actions[index]); - assert(action); - actor->setAction(action, 0); - } + Handler::handle(actor); + if (!actor->isPlaying() && !_actions.empty()) { + Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd(); + uint index = rnd.getRandomNumber(_actions.size() - 1); + Action *action = actor->findAction(_actions[index]); + assert(action); + actor->setAction(action, 0); + } } void HandlerTimerSequences::execute(Sequence *sequence) { - error("HandlerTimerSequences function is not implemented"); + error("HandlerTimerSequences function is not implemented"); } void HandlerTimerSequences::toConsole() { - debug("HandlerTimerSequences:"); - - debug("\tSideEffects:"); - for (uint i = 0; i < _sideEffects.size(); ++i) { - _sideEffects[i]->toConsole(); - } - - debug("\tConditions:"); - for (uint i = 0; i < _conditions.size(); ++i) { - _conditions[i]->toConsole(); - } - - debug("\tSequences:"); - for (uint i = 0; i < _sequences.size(); ++i) { - debug("\t\t%s", _sequences[i].c_str()); - } + debug("HandlerTimerSequences:"); + + debug("\tSideEffects:"); + for (uint i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (uint i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + + debug("\tSequences:"); + for (uint i = 0; i < _sequences.size(); ++i) { + debug("\t\t%s", _sequences[i].c_str()); + } } void HandlerTimerSequences::handle(Actor *actor) { - Handler::handle(actor); - Sequencer *sequencer = actor->getSequencer(); + Handler::handle(actor); + Sequencer *sequencer = actor->getSequencer(); - assert(!_sequences.empty()); + assert(!_sequences.empty()); - Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd(); - uint index = rnd.getRandomNumber(_sequences.size() - 1); + Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd(); + uint index = rnd.getRandomNumber(_sequences.size() - 1); - Sequence *sequence = sequencer->findSequence(_sequences[index]); + Sequence *sequence = sequencer->findSequence(_sequences[index]); - assert(sequence); + assert(sequence); } } // End of namespace Pink diff --git a/engines/pink/objects/handlers/handler_timer.h b/engines/pink/objects/handlers/handler_timer.h index cbe6824d2a..b420272c2a 100644 --- a/engines/pink/objects/handlers/handler_timer.h +++ b/engines/pink/objects/handlers/handler_timer.h @@ -39,23 +39,23 @@ class HandlerTimer : public Handler { //in Peril this is HandlerTimer class HandlerTimerActions : public Handler { public: - virtual void toConsole(); - virtual void deserialize(Archive &archive); - virtual void handle(Actor *actor); + virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual void handle(Actor *actor); private: - StringArray _actions; + StringArray _actions; }; //appear in HokusPokus class HandlerTimerSequences : public HandlerSequences { //originally it was inherited from HandlerTimer public: - virtual void toConsole(); + virtual void toConsole(); - virtual void handle(Actor *actor); + virtual void handle(Actor *actor); protected: - virtual void execute(Sequence *sequence); + virtual void execute(Sequence *sequence); }; } // End of namespace Pink diff --git a/engines/pink/objects/inventory.cpp b/engines/pink/objects/inventory.cpp index a7a483f24d..c2ad3bb0a7 100644 --- a/engines/pink/objects/inventory.cpp +++ b/engines/pink/objects/inventory.cpp @@ -33,32 +33,32 @@ namespace Pink { InventoryMgr::InventoryMgr() - : _lead(nullptr), _item(nullptr), _isClickedOnItem(false) + : _lead(nullptr), _item(nullptr), _isClickedOnItem(false) { } void Pink::InventoryItem::deserialize(Archive &archive) { - NamedObject::deserialize(archive); - _initialOwner = archive.readString(); - _currentOwner = _initialOwner; + NamedObject::deserialize(archive); + _initialOwner = archive.readString(); + _currentOwner = _initialOwner; } Common::String &InventoryItem::getCurrentOwner() { - return _currentOwner; + return _currentOwner; } void InventoryItem::toConsole() { - debug("\tInventoryItem: _initialOwner=%s _currentOwner=%s", _initialOwner.c_str(), _currentOwner.c_str()); + debug("\tInventoryItem: _initialOwner=%s _currentOwner=%s", _initialOwner.c_str(), _currentOwner.c_str()); } InventoryMgr::~InventoryMgr() { - for (uint i = 0; i < _items.size(); ++i) { - delete _items[i]; - } + for (uint i = 0; i < _items.size(); ++i) { + delete _items[i]; + } } void InventoryMgr::deserialize(Archive &archive) { - _items.deserialize(archive); + _items.deserialize(archive); } InventoryItem *InventoryMgr::findInventoryItem(const Common::String &name) { @@ -71,133 +71,133 @@ InventoryItem *InventoryMgr::findInventoryItem(const Common::String &name) { } void InventoryMgr::setLeadActor(LeadActor *lead) { - _lead = lead; + _lead = lead; } void InventoryMgr::toConsole() { - debug("InventoryMgr:"); - for (uint i = 0; i < _items.size(); ++i) { - _items[i]->toConsole(); - } + debug("InventoryMgr:"); + for (uint i = 0; i < _items.size(); ++i) { + _items[i]->toConsole(); + } } bool InventoryMgr::isPinkOwnsAnyItems() { - if (_item) - return true; + if (_item) + return true; - for (uint i = 0; i < _items.size(); ++i) { - if (_items[i]->getCurrentOwner() == _lead->getName()){ - _item = _items[i]; - return true; - } - } + for (uint i = 0; i < _items.size(); ++i) { + if (_items[i]->getCurrentOwner() == _lead->getName()){ + _item = _items[i]; + return true; + } + } - return false; + return false; } void InventoryMgr::setItemOwner(const Common::String &owner, InventoryItem *item) { - if (owner == item->getCurrentOwner()) - return; + if (owner == item->getCurrentOwner()) + return; - if (item == _item && _lead->getName() != owner) - _item = nullptr; + if (item == _item && _lead->getName() != owner) + _item = nullptr; - item->_currentOwner = owner; + item->_currentOwner = owner; - if (_lead->getName() == owner) - _item = item; + if (_lead->getName() == owner) + _item = item; } bool InventoryMgr::start(bool playOpening) { - if (!_item) { - _item = findInventoryItem(_lead->getName()); - if (!_item) - return false; - } + if (!_item) { + _item = findInventoryItem(_lead->getName()); + if (!_item) + return false; + } - _window = _lead->getPage()->findActor(kInventoryWindowActor); - _itemActor = _lead->getPage()->findActor(kInventoryItemActor); - _rightArrow = _lead->getPage()->findActor(kInventoryRightArrowActor); - _leftArrow = _lead->getPage()->findActor(kInventoryLeftArrowActor); + _window = _lead->getPage()->findActor(kInventoryWindowActor); + _itemActor = _lead->getPage()->findActor(kInventoryItemActor); + _rightArrow = _lead->getPage()->findActor(kInventoryRightArrowActor); + _leftArrow = _lead->getPage()->findActor(kInventoryLeftArrowActor); - if (playOpening){ - _window->setAction(kOpenAction); - _state = kOpening; - } + if (playOpening){ + _window->setAction(kOpenAction); + _state = kOpening; + } - return true; + return true; } void InventoryMgr::update() { - if (_state == kOpening && !_window->isPlaying()){ - _state = kReady; - _itemActor->setAction(_item->getName()); - _window->setAction(kShowAction); - _leftArrow->setAction(kShowAction); - _rightArrow->setAction(kShowAction); - } - else if (_state == kClosing && !_window->isPlaying()){ - _window->setAction(kIdleAction); + if (_state == kOpening && !_window->isPlaying()){ + _state = kReady; + _itemActor->setAction(_item->getName()); + _window->setAction(kShowAction); + _leftArrow->setAction(kShowAction); + _rightArrow->setAction(kShowAction); + } + else if (_state == kClosing && !_window->isPlaying()){ + _window->setAction(kIdleAction); - _lead->onInventoryClosed(_isClickedOnItem); + _lead->onInventoryClosed(_isClickedOnItem); - _state = kIdle; + _state = kIdle; - _window = nullptr; - _itemActor = nullptr; - _isClickedOnItem = false; - } + _window = nullptr; + _itemActor = nullptr; + _isClickedOnItem = false; + } } void InventoryMgr::onClick(Common::Point point) { - if (_state != kReady) - return; - - Actor *actor = _lead->getPage()->getGame()->getDirector()->getActorByPoint(point); - if (actor == _itemActor || actor == _window) { - _isClickedOnItem = true; - close(); - } - else if (actor == _leftArrow) { - showNextItem(kLeft); - } - else if (actor == _rightArrow) { - showNextItem(kRight); - } - else close(); + if (_state != kReady) + return; + + Actor *actor = _lead->getPage()->getGame()->getDirector()->getActorByPoint(point); + if (actor == _itemActor || actor == _window) { + _isClickedOnItem = true; + close(); + } + else if (actor == _leftArrow) { + showNextItem(kLeft); + } + else if (actor == _rightArrow) { + showNextItem(kRight); + } + else close(); } void InventoryMgr::close() { - _state = kClosing; + _state = kClosing; - _window->setAction(kCloseAction); - _itemActor->setAction(kIdleAction); - _leftArrow->setAction(kIdleAction); - _rightArrow->setAction(kIdleAction); + _window->setAction(kCloseAction); + _itemActor->setAction(kIdleAction); + _leftArrow->setAction(kIdleAction); + _rightArrow->setAction(kIdleAction); } void InventoryMgr::showNextItem(bool direction) { - int index = 0; - for (uint i = 0; i < _items.size(); ++i) { - if (_item == _items[i]) { - index = i + _items.size(); - break; - } - } + int index = 0; + for (uint i = 0; i < _items.size(); ++i) { + if (_item == _items[i]) { + index = i + _items.size(); + break; + } + } - uint i = 0; - do { - index = (direction == kLeft) ? --index : ++index; - } while(_items[index % _items.size()]->getCurrentOwner() != _item->getCurrentOwner() && ++i < _items.size()); + uint i = 0; + do { + index = (direction == kLeft) ? --index : ++index; + } while(_items[index % _items.size()]->getCurrentOwner() != _item->getCurrentOwner() && ++i < _items.size()); - if (i != _items.size()) { - _item = _items[index % _items.size()]; - _itemActor->setAction(_item->getName()); - } + if (i != _items.size()) { + _item = _items[index % _items.size()]; + _itemActor->setAction(_item->getName()); + } } InventoryItem *InventoryMgr::getCurrentItem() { - return _item; + return _item; } } // End of namespace Pink diff --git a/engines/pink/objects/inventory.h b/engines/pink/objects/inventory.h index b8de36b8b4..02bf9d6182 100644 --- a/engines/pink/objects/inventory.h +++ b/engines/pink/objects/inventory.h @@ -31,16 +31,16 @@ namespace Pink { class InventoryItem : public NamedObject { public: - virtual void deserialize(Archive &archive); + virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void toConsole(); - Common::String &getCurrentOwner(); + Common::String &getCurrentOwner(); - friend class InventoryMgr; + friend class InventoryMgr; private: - Common::String _initialOwner; - Common::String _currentOwner; + Common::String _initialOwner; + Common::String _currentOwner; }; class LeadActor; @@ -48,51 +48,51 @@ class Actor; class InventoryMgr : public Object { public: - InventoryMgr(); - virtual ~InventoryMgr(); - virtual void deserialize(Archive &archive); - virtual void toConsole(); + InventoryMgr(); + virtual ~InventoryMgr(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); - void update(); - void onClick(Common::Point point); + void update(); + void onClick(Common::Point point); - bool start(bool playOpening); + bool start(bool playOpening); - void setLeadActor(LeadActor *lead); - InventoryItem* findInventoryItem(const Common::String &name); + void setLeadActor(LeadActor *lead); + InventoryItem* findInventoryItem(const Common::String &name); - bool isPinkOwnsAnyItems(); - void setItemOwner(const Common::String &owner, InventoryItem *item); + bool isPinkOwnsAnyItems(); + void setItemOwner(const Common::String &owner, InventoryItem *item); - InventoryItem *getCurrentItem(); + InventoryItem *getCurrentItem(); private: - void close(); - enum Direction { - kLeft = 0, - kRight = 1, - }; - void showNextItem(bool direction); + void close(); + enum Direction { + kLeft = 0, + kRight = 1, + }; + void showNextItem(bool direction); - LeadActor *_lead; - Actor *_window; - Actor *_itemActor; - Actor *_rightArrow; - Actor *_leftArrow; + LeadActor *_lead; + Actor *_window; + Actor *_itemActor; + Actor *_rightArrow; + Actor *_leftArrow; - InventoryItem *_item; - Array<InventoryItem*> _items; + InventoryItem *_item; + Array<InventoryItem*> _items; - enum State { - kIdle = 0, - kOpening = 1, - kReady = 2, - kClosing = 3, - } _state; - bool _isClickedOnItem; + enum State { + kIdle = 0, + kOpening = 1, + kReady = 2, + kClosing = 3, + } _state; + bool _isClickedOnItem; }; } // End of namespace Pink diff --git a/engines/pink/objects/module.cpp b/engines/pink/objects/module.cpp index 019f71ba30..5a7dd6bbc9 100644 --- a/engines/pink/objects/module.cpp +++ b/engines/pink/objects/module.cpp @@ -27,52 +27,52 @@ namespace Pink { ModuleProxy::ModuleProxy(const Common::String &name) - : NamedObject(name) + : NamedObject(name) {} ModuleProxy::ModuleProxy() {} Module::Module(PinkEngine *game, const Common::String &name) - : NamedObject(name), _game(game), _page(nullptr) + : NamedObject(name), _game(game), _page(nullptr) {} Module::~Module() { - for (uint i = 0; i < _pages.size(); ++i) { - delete _pages[i]; - } + for (uint i = 0; i < _pages.size(); ++i) { + delete _pages[i]; + } } void Module::load(Archive &archive){ - archive.mapObject(this); - NamedObject::deserialize(archive); + archive.mapObject(this); + NamedObject::deserialize(archive); - archive.readString(); // skip directory + archive.readString(); // skip directory - _invMgr.deserialize(archive); - _pages.deserialize(archive); + _invMgr.deserialize(archive); + _pages.deserialize(archive); } void Module::init(bool isLoadingSave, const Common::String &pageName) { - // 0 0 - new game - // 0 1 - module changed - // 1 0 - from save - if (!pageName.empty()) - _page = findPage(pageName); - else if (!_page) - _page = _pages[0]; - - _page->init(isLoadingSave); + // 0 0 - new game + // 0 1 - module changed + // 1 0 - from save + if (!pageName.empty()) + _page = findPage(pageName); + else if (!_page) + _page = _pages[0]; + + _page->init(isLoadingSave); } void Module::changePage(const Common::String &pageName) { - GamePage *page = nullptr; - page = findPage(pageName); - assert(_page != page); + GamePage *page = nullptr; + page = findPage(pageName); + assert(_page != page); - _page->unload(); + _page->unload(); - _page = page; - _page->init(kLoadingNewGame); + _page = page; + _page->init(kLoadingNewGame); } GamePage *Module::findPage(const Common::String &pageName) const { @@ -84,21 +84,21 @@ GamePage *Module::findPage(const Common::String &pageName) const { } PinkEngine *Module::getGame() const { - return _game; + return _game; } bool Module::checkValueOfVariable(Common::String &variable, Common::String &value) { - if (!_variables.contains(variable)) - return value == kUndefined; - return _variables[variable] == value; + if (!_variables.contains(variable)) + return value == kUndefined; + return _variables[variable] == value; } void Module::setVariable(Common::String &variable, Common::String &value) { - _variables[variable] = value; + _variables[variable] = value; } InventoryMgr *Module::getInventoryMgr() { - return &_invMgr; + return &_invMgr; } } // End of namespace Pink diff --git a/engines/pink/objects/module.h b/engines/pink/objects/module.h index 622381d8a3..5c253ebcbe 100644 --- a/engines/pink/objects/module.h +++ b/engines/pink/objects/module.h @@ -34,8 +34,8 @@ namespace Pink { class ModuleProxy : public NamedObject { public: - ModuleProxy(); - ModuleProxy(const Common::String &name); + ModuleProxy(); + ModuleProxy(const Common::String &name); }; class PinkEngine; @@ -43,31 +43,31 @@ class GamePage; class Module : public NamedObject { public: - Module(PinkEngine *game, const Common::String &name); - ~Module(); + Module(PinkEngine *game, const Common::String &name); + ~Module(); - void load(Archive &archive); - void init(bool isLoadingSave, const Common::String &pageName); - void changePage(const Common::String &pageName); + void load(Archive &archive); + void init(bool isLoadingSave, const Common::String &pageName); + void changePage(const Common::String &pageName); - void OnLeftButtonDown(); - void OnMouseMove(); - void OnKeyboardButtonClick(); + void OnLeftButtonDown(); + void OnMouseMove(); + void OnKeyboardButtonClick(); - PinkEngine *getGame() const; - InventoryMgr *getInventoryMgr(); + PinkEngine *getGame() const; + InventoryMgr *getInventoryMgr(); - bool checkValueOfVariable(Common::String &variable, Common::String &value); - void setVariable(Common::String &variable, Common::String &value); + bool checkValueOfVariable(Common::String &variable, Common::String &value); + void setVariable(Common::String &variable, Common::String &value); private: - GamePage *findPage(const Common::String &pageName) const; + GamePage *findPage(const Common::String &pageName) const; - PinkEngine *_game; - GamePage *_page; - Array<GamePage*> _pages; - InventoryMgr _invMgr; - Common::StringMap _variables; + PinkEngine *_game; + GamePage *_page; + Array<GamePage*> _pages; + InventoryMgr _invMgr; + Common::StringMap _variables; }; diff --git a/engines/pink/objects/object.cpp b/engines/pink/objects/object.cpp index 6e5005372e..4d9041f891 100644 --- a/engines/pink/objects/object.cpp +++ b/engines/pink/objects/object.cpp @@ -27,15 +27,15 @@ namespace Pink { Pink::NamedObject::NamedObject(const Common::String &name) - : _name(name) + : _name(name) {} void Pink::NamedObject::deserialize(Archive &archive) { - _name = archive.readString(); + _name = archive.readString(); } const Common::String &Pink::NamedObject::getName() const { - return _name; + return _name; } void NamedObject::store(Archive &archive) { diff --git a/engines/pink/objects/object.h b/engines/pink/objects/object.h index 88ce35b3b7..62ca9f758a 100644 --- a/engines/pink/objects/object.h +++ b/engines/pink/objects/object.h @@ -31,26 +31,26 @@ class Archive; class Object { public: - virtual ~Object() {}; - virtual void load(Archive &){}; - virtual void store(Archive &){}; - virtual void deserialize(Archive &){}; - virtual void init() {} - virtual void toConsole() {}; + virtual ~Object() {}; + virtual void load(Archive &){}; + virtual void store(Archive &){}; + virtual void deserialize(Archive &){}; + virtual void init() {} + virtual void toConsole() {}; }; class NamedObject : public Object { public: - NamedObject(){}; - NamedObject(const Common::String &name); + NamedObject(){}; + NamedObject(const Common::String &name); - void deserialize(Archive &archive); - void store(Archive &archive); + void deserialize(Archive &archive); + void store(Archive &archive); - const Common::String &getName() const; + const Common::String &getName() const; protected: - Common::String _name; + Common::String _name; }; } // End of namespace Pink diff --git a/engines/pink/objects/pages/game_page.cpp b/engines/pink/objects/pages/game_page.cpp index 952ea42b1f..83df359b80 100644 --- a/engines/pink/objects/pages/game_page.cpp +++ b/engines/pink/objects/pages/game_page.cpp @@ -31,128 +31,128 @@ namespace Pink { GamePage::GamePage() - : _cursorMgr(nullptr), _walkMgr(nullptr), _sequencer(nullptr), - _isLoaded(false), _memFile(nullptr) + : _cursorMgr(nullptr), _walkMgr(nullptr), _sequencer(nullptr), + _isLoaded(false), _memFile(nullptr) {} GamePage::~GamePage() { - clear(); + clear(); } void GamePage::toConsole() { - Page::toConsole(); - _walkMgr->toConsole(); - _sequencer->toConsole(); - for (uint i = 0; i < _handlers.size(); ++i) { - _handlers[i]->toConsole(); - } + Page::toConsole(); + _walkMgr->toConsole(); + _sequencer->toConsole(); + for (uint i = 0; i < _handlers.size(); ++i) { + _handlers[i]->toConsole(); + } } void GamePage::deserialize(Archive &archive) { - Page::deserialize(archive); - _module = static_cast<Module*>(archive.readObject()); - assert(dynamic_cast<Module*>(_module) != 0); + Page::deserialize(archive); + _module = static_cast<Module*>(archive.readObject()); + assert(dynamic_cast<Module*>(_module) != 0); } void GamePage::load(Archive &archive) { - archive.mapObject(_cursorMgr); - archive.mapObject(_walkMgr); - archive.mapObject(_sequencer); + archive.mapObject(_cursorMgr); + archive.mapObject(_walkMgr); + archive.mapObject(_sequencer); - Page::load(archive); + Page::load(archive); - _leadActor = static_cast<LeadActor*>(archive.readObject()); + _leadActor = static_cast<LeadActor*>(archive.readObject()); - _walkMgr->deserialize(archive); - _sequencer->deserialize(archive); - _handlers.deserialize(archive); + _walkMgr->deserialize(archive); + _sequencer->deserialize(archive); + _handlers.deserialize(archive); } void GamePage::init(bool isLoadingSave) { - if (!_isLoaded) - loadManagers(); + if (!_isLoaded) + loadManagers(); - toConsole(); + toConsole(); - for (uint j = 0; j < _actors.size(); ++j) { - if (_actors[j]->initPallete(_module->getGame()->getDirector())) - break; - } + for (uint j = 0; j < _actors.size(); ++j) { + if (_actors[j]->initPallete(_module->getGame()->getDirector())) + break; + } - LeadActor::State state = _leadActor->getState(); - bool startNow = !(state == LeadActor::kInventory || state == LeadActor::kPDA); + LeadActor::State state = _leadActor->getState(); + bool startNow = !(state == LeadActor::kInventory || state == LeadActor::kPDA); - for (uint i = 0; i < _actors.size(); ++i) { - _actors[i]->init(startNow); - } + for (uint i = 0; i < _actors.size(); ++i) { + _actors[i]->init(startNow); + } - bool isHandler = false; - if (!isLoadingSave) { - isHandler = initHandler(); - } + bool isHandler = false; + if (!isLoadingSave) { + isHandler = initHandler(); + } - _leadActor->start(isHandler); + _leadActor->start(isHandler); } bool GamePage::initHandler() { - for (uint i = 0; i < _handlers.size(); ++i) { - if (_handlers[i]->isSuitable(_leadActor)){ - _handlers[i]->handle(_leadActor); - return true; - } - } - return false; + for (uint i = 0; i < _handlers.size(); ++i) { + if (_handlers[i]->isSuitable(_leadActor)){ + _handlers[i]->handle(_leadActor); + return true; + } + } + return false; } void GamePage::loadManagers() { - _isLoaded = true; + _isLoaded = true; - _cursorMgr = new CursorMgr(_module->getGame(), this); - _walkMgr = new WalkMgr; - _sequencer = new Sequencer(this); + _cursorMgr = new CursorMgr(_module->getGame(), this); + _walkMgr = new WalkMgr; + _sequencer = new Sequencer(this); - _resMgr.init(_module->getGame(), this); + _resMgr.init(_module->getGame(), this); - if (_memFile != nullptr) { - loadState(); + if (_memFile != nullptr) { + loadState(); - delete _memFile; - _memFile = nullptr; - } + delete _memFile; + _memFile = nullptr; + } } PinkEngine *GamePage::getGame() { - return _resMgr.getGame(); + return _resMgr.getGame(); } Sequencer *GamePage::getSequencer() { - return _sequencer; + return _sequencer; } Module *GamePage::getModule() const { - return _module; + return _module; } bool GamePage::checkValueOfVariable(const Common::String &variable, const Common::String &value) { - if (!_variables.contains(variable)) - return value == kUndefined; - return _variables[variable] == value; + if (!_variables.contains(variable)) + return value == kUndefined; + return _variables[variable] == value; } void GamePage::setVariable(Common::String &variable, Common::String &value) { - _variables[variable] = value; - _leadActor->onVariableSet(); + _variables[variable] = value; + _leadActor->onVariableSet(); } WalkMgr *GamePage::getWalkMgr() { - return _walkMgr; + return _walkMgr; } void GamePage::loadState() { - Archive archive(static_cast<Common::SeekableReadStream*>(_memFile)); - //_variables.clear(1); - Common::StringMap mapTest; // HACK. Without it isn't working - //archive >> _variables; + Archive archive(static_cast<Common::SeekableReadStream*>(_memFile)); + //_variables.clear(1); + Common::StringMap mapTest; // HACK. Without it isn't working + //archive >> _variables; uint size = archive.readCount(); for (uint i = 0; i < size; ++i) { @@ -161,56 +161,56 @@ void GamePage::loadState() { mapTest.setVal(key, val); } - _variables = mapTest; + _variables = mapTest; - uint16 actorCount = archive.readWORD(); + uint16 actorCount = archive.readWORD(); - Common::String actorName; - for (int i = 0; i < actorCount; ++i) { - actorName = archive.readString(); - findActor(actorName)->loadState(archive); - } + Common::String actorName; + for (int i = 0; i < actorCount; ++i) { + actorName = archive.readString(); + findActor(actorName)->loadState(archive); + } } void GamePage::saveState() { - _memFile = new Common::MemoryReadWriteStream(DisposeAfterUse::YES); - Archive archive(static_cast<Common::WriteStream*>(_memFile)); + _memFile = new Common::MemoryReadWriteStream(DisposeAfterUse::YES); + Archive archive(static_cast<Common::WriteStream*>(_memFile)); - for (Common::StringMap::const_iterator it = _variables.begin(); it != _variables.end(); ++it) { - archive.writeString(it->_key); - archive.writeString(it->_value); - } + for (Common::StringMap::const_iterator it = _variables.begin(); it != _variables.end(); ++it) { + archive.writeString(it->_key); + archive.writeString(it->_value); + } - archive.writeWORD(_actors.size()); - for (uint i = 0; i < _actors.size(); ++i) { - archive.writeString(_actors[i]->getName()); - _actors[i]->saveState(archive); - } + archive.writeWORD(_actors.size()); + for (uint i = 0; i < _actors.size(); ++i) { + archive.writeString(_actors[i]->getName()); + _actors[i]->saveState(archive); + } } void GamePage::unload() { - _leadActor->setAction(_leadActor->findAction(kIdleAction)); + _leadActor->setAction(_leadActor->findAction(kIdleAction)); - saveState(); - clear(); + saveState(); + clear(); - _isLoaded = false; + _isLoaded = false; } void GamePage::clear() { - Page::clear(); - //_variables.clear(1); + Page::clear(); + //_variables.clear(1); - for (uint i = 0; i < _handlers.size(); ++i) { - delete _handlers[i]; - } + for (uint i = 0; i < _handlers.size(); ++i) { + delete _handlers[i]; + } - _handlers.clear(); + _handlers.clear(); - delete _cursorMgr; _cursorMgr = nullptr; - delete _sequencer; _sequencer = nullptr; - delete _walkMgr; _walkMgr = nullptr; + delete _cursorMgr; _cursorMgr = nullptr; + delete _sequencer; _sequencer = nullptr; + delete _walkMgr; _walkMgr = nullptr; } } // End of namespace Pink diff --git a/engines/pink/objects/pages/game_page.h b/engines/pink/objects/pages/game_page.h index 5aad7ac66f..1bae58d768 100644 --- a/engines/pink/objects/pages/game_page.h +++ b/engines/pink/objects/pages/game_page.h @@ -36,39 +36,39 @@ class HandlerStartPage; class GamePage : public Page { public: - GamePage(); - ~GamePage(); - virtual void toConsole(); - virtual void deserialize(Archive &archive); + GamePage(); + ~GamePage(); + virtual void toConsole(); + virtual void deserialize(Archive &archive); - virtual void load(Archive &archive); - void unload(); - void loadManagers(); - void init(bool isLoadingSave); + virtual void load(Archive &archive); + void unload(); + void loadManagers(); + void init(bool isLoadingSave); - PinkEngine *getGame(); - Sequencer *getSequencer(); - WalkMgr *getWalkMgr(); - Module *getModule() const; + PinkEngine *getGame(); + Sequencer *getSequencer(); + WalkMgr *getWalkMgr(); + Module *getModule() const; - bool checkValueOfVariable(const Common::String &variable, const Common::String &value); - void setVariable(Common::String &variable, Common::String &value); + bool checkValueOfVariable(const Common::String &variable, const Common::String &value); + void setVariable(Common::String &variable, Common::String &value); - virtual void clear(); + virtual void clear(); private: - bool initHandler(); - void loadState(); - void saveState(); + bool initHandler(); + void loadState(); + void saveState(); - bool _isLoaded; - Common::MemoryReadWriteStream *_memFile; - Module *_module; - CursorMgr *_cursorMgr; - WalkMgr *_walkMgr; - Sequencer *_sequencer; - Array<HandlerStartPage*> _handlers; - Common::StringMap _variables; + bool _isLoaded; + Common::MemoryReadWriteStream *_memFile; + Module *_module; + CursorMgr *_cursorMgr; + WalkMgr *_walkMgr; + Sequencer *_sequencer; + Array<HandlerStartPage*> _handlers; + Common::StringMap _variables; }; } diff --git a/engines/pink/objects/pages/page.cpp b/engines/pink/objects/pages/page.cpp index 4b2f5f1d49..1465e17b39 100644 --- a/engines/pink/objects/pages/page.cpp +++ b/engines/pink/objects/pages/page.cpp @@ -27,14 +27,14 @@ namespace Pink { Page::~Page() { - clear(); + clear(); } void Page::load(Archive &archive) { - archive.mapObject(this); - NamedObject::deserialize(archive); - archive.readString(); //skip directory - _actors.deserialize(archive); + archive.mapObject(this); + NamedObject::deserialize(archive); + archive.readString(); //skip directory + _actors.deserialize(archive); } Actor *Page::findActor(const Common::String &name) { @@ -47,52 +47,52 @@ Actor *Page::findActor(const Common::String &name) { } Sound *Page::loadSound(Common::String &fileName) { - return _resMgr.loadSound(fileName); + return _resMgr.loadSound(fileName); } CelDecoder *Page::loadCel(Common::String &fileName) { - return _resMgr.loadCEL(fileName); + return _resMgr.loadCEL(fileName); } void Page::toConsole() { - for (uint i = 0; i < _actors.size(); ++i) { - _actors[i]->toConsole(); - } + for (uint i = 0; i < _actors.size(); ++i) { + _actors[i]->toConsole(); + } } void Page::init() { - LeadActor::State state = _leadActor->getState(); - bool unk = (state == LeadActor::kInventory || state == LeadActor::kPDA); + LeadActor::State state = _leadActor->getState(); + bool unk = (state == LeadActor::kInventory || state == LeadActor::kPDA); - for (uint i = 0; i < _actors.size(); ++i) { - _actors[i]->init(unk); - } + for (uint i = 0; i < _actors.size(); ++i) { + _actors[i]->init(unk); + } } LeadActor *Page::getLeadActor() { - return _leadActor; + return _leadActor; } void Page::clear() { - for (uint i = 0; i < _actors.size(); ++i) { - delete _actors[i]; - } - _actors.clear(); - _resMgr.clear(); + for (uint i = 0; i < _actors.size(); ++i) { + delete _actors[i]; + } + _actors.clear(); + _resMgr.clear(); } void Page::pause() { - for (uint i = 0; i < _actors.size(); ++i) { - _actors[i]->pause(); - } + for (uint i = 0; i < _actors.size(); ++i) { + _actors[i]->pause(); + } } void Page::unpause() { - for (uint i = 0; i < _actors.size(); ++i) { - _actors[i]->unpause(); - } + for (uint i = 0; i < _actors.size(); ++i) { + _actors[i]->unpause(); + } } } // End of namespace Pink diff --git a/engines/pink/objects/pages/page.h b/engines/pink/objects/pages/page.h index 1d96a93b5a..3b5708f530 100644 --- a/engines/pink/objects/pages/page.h +++ b/engines/pink/objects/pages/page.h @@ -34,26 +34,26 @@ class LeadActor; class Page : public NamedObject { public: - ~Page(); - virtual void toConsole(); + ~Page(); + virtual void toConsole(); - void load(Archive &archive); - Actor *findActor(const Common::String &name); - LeadActor *getLeadActor(); + void load(Archive &archive); + Actor *findActor(const Common::String &name); + LeadActor *getLeadActor(); - Sound *loadSound(Common::String &fileName); - CelDecoder *loadCel(Common::String &fileName); + Sound *loadSound(Common::String &fileName); + CelDecoder *loadCel(Common::String &fileName); - virtual void clear(); - void pause(); - void unpause(); + virtual void clear(); + void pause(); + void unpause(); protected: - void init(); + void init(); - Array<Actor*> _actors; - ResourceMgr _resMgr; - LeadActor *_leadActor; + Array<Actor*> _actors; + ResourceMgr _resMgr; + LeadActor *_leadActor; }; } // End of namespace Pink diff --git a/engines/pink/objects/sequences/seq_timer.cpp b/engines/pink/objects/sequences/seq_timer.cpp index 974056a956..9f8ee31a4c 100644 --- a/engines/pink/objects/sequences/seq_timer.cpp +++ b/engines/pink/objects/sequences/seq_timer.cpp @@ -32,30 +32,30 @@ namespace Pink { SeqTimer::SeqTimer() - : _updatesToMessage(0) {} + : _updatesToMessage(0) {} void SeqTimer::deserialize(Archive &archive) { - _actor = archive.readString(); - _period = archive.readDWORD(); - _range = archive.readDWORD(); - _sequencer = static_cast<Sequencer*>(archive.readObject()); + _actor = archive.readString(); + _period = archive.readDWORD(); + _range = archive.readDWORD(); + _sequencer = static_cast<Sequencer*>(archive.readObject()); } void SeqTimer::toConsole() { - debug("\tSeqTimer: _actor=%s _period=%u _range=%u", _actor.c_str(), _period, _range); + debug("\tSeqTimer: _actor=%s _period=%u _range=%u", _actor.c_str(), _period, _range); } void SeqTimer::update() { - Common::RandomSource &rnd =_sequencer->_page->getGame()->getRnd(); - if (_updatesToMessage--) - return; + Common::RandomSource &rnd =_sequencer->_page->getGame()->getRnd(); + if (_updatesToMessage--) + return; _updatesToMessage = _range ? _period + rnd.getRandomNumber(_range) : _period; SupportingActor *actor = static_cast<SupportingActor*>(_sequencer->_page->findActor(_actor)); - if (actor && !_sequencer->findSequenceActorState(actor->getName())){ - actor->onTimerMessage(); - } + if (actor && !_sequencer->findSequenceActorState(actor->getName())){ + actor->onTimerMessage(); + } } } // End of namespace Pink diff --git a/engines/pink/objects/sequences/seq_timer.h b/engines/pink/objects/sequences/seq_timer.h index bfd6295ce0..9af706f6c8 100644 --- a/engines/pink/objects/sequences/seq_timer.h +++ b/engines/pink/objects/sequences/seq_timer.h @@ -31,17 +31,17 @@ class Sequencer; class SeqTimer : public Object { public: - SeqTimer(); - virtual void deserialize(Archive &archive); - virtual void toConsole(); - virtual void update(); + SeqTimer(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); + virtual void update(); private: - Common::String _actor; - Sequencer *_sequencer; - int _period; - int _range; - int _updatesToMessage; + Common::String _actor; + Sequencer *_sequencer; + int _period; + int _range; + int _updatesToMessage; }; } // End of namespace Pink diff --git a/engines/pink/objects/sequences/sequence.cpp b/engines/pink/objects/sequences/sequence.cpp index 1e08bb5c02..5eeae68657 100644 --- a/engines/pink/objects/sequences/sequence.cpp +++ b/engines/pink/objects/sequences/sequence.cpp @@ -34,158 +34,158 @@ namespace Pink { Sequence::Sequence() - : _unk(0), _context(nullptr), - _sequencer(nullptr) {} + : _unk(0), _context(nullptr), + _sequencer(nullptr) {} Sequence::~Sequence() { - for (uint i = 0; i < _items.size(); ++i) { - delete _items[i]; - } + for (uint i = 0; i < _items.size(); ++i) { + delete _items[i]; + } } void Sequence::deserialize(Archive &archive) { - NamedObject::deserialize(archive); - _sequencer = static_cast<Sequencer*>(archive.readObject()); - _items.deserialize(archive); + NamedObject::deserialize(archive); + _sequencer = static_cast<Sequencer*>(archive.readObject()); + _items.deserialize(archive); } void Sequence::toConsole() { - debug("\t\tSequence %s", _name.c_str()); - debug("\t\t\tItems:"); - for (uint i = 0; i < _items.size(); ++i) { - _items[i]->toConsole(); - } + debug("\t\tSequence %s", _name.c_str()); + debug("\t\t\tItems:"); + for (uint i = 0; i < _items.size(); ++i) { + _items[i]->toConsole(); + } } Common::Array<SequenceItem*> &Sequence::getItems() { - return _items; + return _items; } void Sequence::setContext(SequenceContext *context) { - _context = context; + _context = context; } void Sequence::init(int unk) { - assert(_items.size()); - assert(dynamic_cast<SequenceItemLeader*>(_items[0])); // first item must always be a leader - start(unk); + assert(_items.size()); + assert(dynamic_cast<SequenceItemLeader*>(_items[0])); // first item must always be a leader + start(unk); } void Sequence::start(int unk) { - if (_context->_nextItemIndex >= _items.size() || !_items[_context->_nextItemIndex]->execute(_context->_index, this, unk)){ - debug("Sequence %s ended", _name.c_str()); - end(); - return; - } + if (_context->_nextItemIndex >= _items.size() || !_items[_context->_nextItemIndex]->execute(_context->_index, this, unk)){ + debug("Sequence %s ended", _name.c_str()); + end(); + return; + } - uint i; - for (i = _context->_nextItemIndex + 1; i <_items.size(); ++i){ - if (_items[i]->isLeader()) - break; - _items[i]->execute(_context->_index, this, unk); - } - _context->_nextItemIndex = i; + uint i; + for (i = _context->_nextItemIndex + 1; i <_items.size(); ++i){ + if (_items[i]->isLeader()) + break; + _items[i]->execute(_context->_index, this, unk); + } + _context->_nextItemIndex = i; - Common::Array<SequenceActorState> &states = _context->_states; - for (uint j = 0; j < states.size(); ++j) { - states[j].check(_context->_index, this, unk); - } - _context->_index++; + Common::Array<SequenceActorState> &states = _context->_states; + for (uint j = 0; j < states.size(); ++j) { + states[j].check(_context->_index, this, unk); + } + _context->_index++; } void Sequence::update() { - if (!_context->_actor->isPlaying()){ - debug("Sequence step ended"); - start(0); - } + if (!_context->_actor->isPlaying()){ + debug("Sequence step ended"); + start(0); + } } void Sequence::end() { - _context->_actor = 0; - _unk = 1; - _sequencer->removeContext(_context); + _context->_actor = 0; + _unk = 1; + _sequencer->removeContext(_context); } void Sequence::restart() { - _context->setNextItemIndex(0); - _context->clearActionsFromActorStates(); - start(0); + _context->setNextItemIndex(0); + _context->clearActionsFromActorStates(); + start(0); } void Sequence::skipToLastSubSequence() { - if (_unk && _context->getNextItemIndex() < _items.size()){ - int i = _items.size() - 1; - while(i >= 0 && !_items[--i]->isLeader()); - assert(i >= 0); - _context->setNextItemIndex(i); - _context->clearActionsFromActorStates(); - skipItemsTo(i); - start(0); - } + if (_unk && _context->getNextItemIndex() < _items.size()){ + int i = _items.size() - 1; + while(i >= 0 && !_items[--i]->isLeader()); + assert(i >= 0); + _context->setNextItemIndex(i); + _context->clearActionsFromActorStates(); + skipItemsTo(i); + start(0); + } } void Sequence::skipItemsTo(int index) { - for(int i = 0; i < index; ++i){ - _items[i]->skip(this); - } + for(int i = 0; i < index; ++i){ + _items[i]->skip(this); + } } void Sequence::skipSubSequence() { - if (_context->getNextItemIndex() < _context->getSequence()->getItems().size()) - _context->getSequence()->start(0); + if (_context->getNextItemIndex() < _context->getSequence()->getItems().size()) + _context->getSequence()->start(0); } void SequenceAudio::deserialize(Archive &archive) { - Sequence::deserialize(archive); - _soundName = archive.readString(); + Sequence::deserialize(archive); + _soundName = archive.readString(); } void SequenceAudio::toConsole() { - debug("\t\tSequenceAudio %s : _sound = %s", _name.c_str(), _soundName.c_str()); - debug("\t\t\tItems:"); - for (uint i = 0; i < _items.size(); ++i) { - _items[i]->toConsole(); - } + debug("\t\tSequenceAudio %s : _sound = %s", _name.c_str(), _soundName.c_str()); + debug("\t\t\tItems:"); + for (uint i = 0; i < _items.size(); ++i) { + _items[i]->toConsole(); + } } void SequenceAudio::start(int unk) { - Sequence::start(unk); - uint index = _context->getNextItemIndex(); - if (index < _items.size()) { - SequenceItemLeaderAudio* leaderAudio = (SequenceItemLeaderAudio*) _items[index]; - _sample = leaderAudio->getSample(); - } + Sequence::start(unk); + uint index = _context->getNextItemIndex(); + if (index < _items.size()) { + SequenceItemLeaderAudio* leaderAudio = (SequenceItemLeaderAudio*) _items[index]; + _sample = leaderAudio->getSample(); + } } void SequenceAudio::end() { - delete _sound; - _sound = nullptr; - Sequence::end(); + delete _sound; + _sound = nullptr; + Sequence::end(); } void SequenceAudio::update() { - if (!_sound->isPlaying()) - end(); - else if (_sample <= _sound->getCurrentSample()){ - start(0); - } + if (!_sound->isPlaying()) + end(); + else if (_sample <= _sound->getCurrentSample()){ + start(0); + } } void SequenceAudio::init(int unk) { - _sample = 0; - _sound = _sequencer->_page->loadSound(_soundName); - _sound->play(Audio::Mixer::SoundType::kMusicSoundType, 100, 0); - Sequence::init(unk); + _sample = 0; + _sound = _sequencer->_page->loadSound(_soundName); + _sound->play(Audio::Mixer::SoundType::kMusicSoundType, 100, 0); + Sequence::init(unk); } void SequenceAudio::restart() { - _sound->play(Audio::Mixer::SoundType::kMusicSoundType, 100, 0); - Sequence::restart(); + _sound->play(Audio::Mixer::SoundType::kMusicSoundType, 100, 0); + Sequence::restart(); } void SequenceAudio::skipToLastSubSequence() { - end(); + end(); } } // End of namespace Pink diff --git a/engines/pink/objects/sequences/sequence.h b/engines/pink/objects/sequences/sequence.h index e40b0160e2..f4c6c5a1b3 100644 --- a/engines/pink/objects/sequences/sequence.h +++ b/engines/pink/objects/sequences/sequence.h @@ -33,54 +33,54 @@ class SequenceContext; class Sequence : public NamedObject { public: - Sequence(); - virtual ~Sequence(); - virtual void deserialize(Archive &archive); + Sequence(); + virtual ~Sequence(); + virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void toConsole(); - Common::Array<SequenceItem*> &getItems(); + Common::Array<SequenceItem*> &getItems(); - void setContext(SequenceContext *context); - virtual void init(int unk); - virtual void start(int unk); - virtual void end(); + void setContext(SequenceContext *context); + virtual void init(int unk); + virtual void start(int unk); + virtual void end(); - virtual void update(); - virtual void restart(); - virtual void skipSubSequence(); - virtual void skipToLastSubSequence(); - void skipItemsTo(int index); + virtual void update(); + virtual void restart(); + virtual void skipSubSequence(); + virtual void skipToLastSubSequence(); + void skipItemsTo(int index); public: - SequenceContext *_context; - Sequencer *_sequencer; - Array<SequenceItem*> _items; - int _unk; + SequenceContext *_context; + Sequencer *_sequencer; + Array<SequenceItem*> _items; + int _unk; }; class Sound; class SequenceAudio : public Sequence { public: - virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); - virtual void init(int unk); - virtual void start(int unk); - virtual void end(); + virtual void init(int unk); + virtual void start(int unk); + virtual void end(); - virtual void update(); - virtual void restart(); + virtual void update(); + virtual void restart(); - virtual void skipSubSequence() {}; - virtual void skipToLastSubSequence(); + virtual void skipSubSequence() {}; + virtual void skipToLastSubSequence(); private: - Common::String _soundName; - Sound *_sound; - uint _sample; + Common::String _soundName; + Sound *_sound; + uint _sample; }; } // End of namespace Pink diff --git a/engines/pink/objects/sequences/sequence_context.cpp b/engines/pink/objects/sequences/sequence_context.cpp index 8ce85b7273..48cbfedfc5 100644 --- a/engines/pink/objects/sequences/sequence_context.cpp +++ b/engines/pink/objects/sequences/sequence_context.cpp @@ -32,62 +32,62 @@ namespace Pink { SequenceActorState::SequenceActorState(const Common::String &name) - :_actorName(name), _index(0) + :_actorName(name), _index(0) {} const Common::String &SequenceActorState::getActor() const { - return _actorName; + return _actorName; } void SequenceActorState::check(int index, Sequence *sequence, bool unk) { - Actor *actor = sequence->_sequencer->_page->findActor(_actorName); - debug("%s %s", _actorName.c_str(), _actionName.c_str()); - if (_index != index && !_actionName.empty()){ - Action *action = actor->findAction(_actionName); - if (actor->getAction() != action) - actor->setAction(action, unk); - } + Actor *actor = sequence->_sequencer->_page->findActor(_actorName); + debug("%s %s", _actorName.c_str(), _actionName.c_str()); + if (_index != index && !_actionName.empty()){ + Action *action = actor->findAction(_actionName); + if (actor->getAction() != action) + actor->setAction(action, unk); + } } SequenceContext::SequenceContext(Sequence *sequence, Sequencer *sequencer) - : _sequence(sequence), _sequencer(sequencer), - _nextItemIndex(0), _index(1), _actor(nullptr) + : _sequence(sequence), _sequencer(sequencer), + _nextItemIndex(0), _index(1), _actor(nullptr) { - sequence->setContext(this); - Common::Array<SequenceItem*> &items = sequence->getItems(); - debug("SequenceContext for %s", _sequence->getName().c_str()); + sequence->setContext(this); + Common::Array<SequenceItem*> &items = sequence->getItems(); + debug("SequenceContext for %s", _sequence->getName().c_str()); - for (uint i = 0; i < items.size(); ++i) { - bool found = 0; - for (uint j = 0; j < _states.size(); ++j) { - if (items[i]->getActor() == _states[j].getActor()){ - found = 1; - break; - } - } - if (!found) { - debug(items[i]->getActor().c_str()); - _states.push_back({items[i]->getActor()}); - } - } + for (uint i = 0; i < items.size(); ++i) { + bool found = 0; + for (uint j = 0; j < _states.size(); ++j) { + if (items[i]->getActor() == _states[j].getActor()){ + found = 1; + break; + } + } + if (!found) { + debug(items[i]->getActor().c_str()); + _states.push_back({items[i]->getActor()}); + } + } } uint SequenceContext::getNextItemIndex() const { - return _nextItemIndex; + return _nextItemIndex; } Sequence *SequenceContext::getSequence() const { - return _sequence; + return _sequence; } void SequenceContext::clearActionsFromActorStates() { - for (uint i = 0; i < _states.size(); ++i) { - _states[i]._actionName.clear(); - } + for (uint i = 0; i < _states.size(); ++i) { + _states[i]._actionName.clear(); + } } void SequenceContext::setNextItemIndex(int index) { - _nextItemIndex = index; + _nextItemIndex = index; } } // End of namespace Pink diff --git a/engines/pink/objects/sequences/sequence_context.h b/engines/pink/objects/sequences/sequence_context.h index 334553cf57..e7acf093ea 100644 --- a/engines/pink/objects/sequences/sequence_context.h +++ b/engines/pink/objects/sequences/sequence_context.h @@ -32,37 +32,37 @@ class Sequencer; class SequenceActorState { public: - SequenceActorState(const Common::String &name); + SequenceActorState(const Common::String &name); - const Common::String &getActor() const; - void check(int index, Sequence *sequence, bool unk); + const Common::String &getActor() const; + void check(int index, Sequence *sequence, bool unk); public: - Common::String _actorName; - Common::String _actionName; - int _index; + Common::String _actorName; + Common::String _actionName; + int _index; }; class Actor; class SequenceContext { public: - SequenceContext(Sequence *sequence, Sequencer* sequencer); + SequenceContext(Sequence *sequence, Sequencer* sequencer); - uint getNextItemIndex() const; - Sequence *getSequence() const; + uint getNextItemIndex() const; + Sequence *getSequence() const; - void setNextItemIndex(int index); + void setNextItemIndex(int index); - void clearActionsFromActorStates(); + void clearActionsFromActorStates(); public: - Sequence *_sequence; - Sequencer *_sequencer; - uint _nextItemIndex; - Actor *_actor; - Common::Array<SequenceActorState> _states; - int _index; + Sequence *_sequence; + Sequencer *_sequencer; + uint _nextItemIndex; + Actor *_actor; + Common::Array<SequenceActorState> _states; + int _index; }; } diff --git a/engines/pink/objects/sequences/sequence_item.cpp b/engines/pink/objects/sequences/sequence_item.cpp index a530390f97..7cc3f1b153 100644 --- a/engines/pink/objects/sequences/sequence_item.cpp +++ b/engines/pink/objects/sequences/sequence_item.cpp @@ -34,77 +34,77 @@ namespace Pink { void SequenceItem::deserialize(Archive &archive) { - _actor = archive.readString(); - _action = archive.readString(); + _actor = archive.readString(); + _action = archive.readString(); } void SequenceItem::toConsole() { - debug("\t\t\t\tSequenceItem: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); + debug("\t\t\t\tSequenceItem: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); } const Common::String &SequenceItem::getActor() const { - return _actor; + return _actor; } const Common::String &SequenceItem::getAction() const { - return _action; + return _action; } bool SequenceItem::execute(int index, Sequence *sequence, bool unk2) { - Actor *actor; - Action *action; - if (!(actor = sequence->_sequencer->_page->findActor(_actor)) || - !(action = actor->findAction(_action))) { - return false; - } + Actor *actor; + Action *action; + if (!(actor = sequence->_sequencer->_page->findActor(_actor)) || + !(action = actor->findAction(_action))) { + return false; + } - actor->setAction(action, unk2); + actor->setAction(action, unk2); - SequenceActorState *state = sequence->_sequencer->findSequenceActorState(_actor); - state->_index = index; - sequence->_context->_actor = isLeader() ? actor : sequence->_context->_actor; + SequenceActorState *state = sequence->_sequencer->findSequenceActorState(_actor); + state->_index = index; + sequence->_context->_actor = isLeader() ? actor : sequence->_context->_actor; - return true; + return true; } bool SequenceItem::isLeader() { - return false; + return false; } bool SequenceItemLeader::isLeader() { - return true; + return true; } void SequenceItemLeader::toConsole() { - debug("\t\t\t\tSequenceItemLeader: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); + debug("\t\t\t\tSequenceItemLeader: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); } void SequenceItemLeaderAudio::deserialize(Archive &archive) { - SequenceItem::deserialize(archive); - _sample = archive.readDWORD(); + SequenceItem::deserialize(archive); + _sample = archive.readDWORD(); } void SequenceItemLeaderAudio::toConsole() { - debug("\t\t\t\tSequenceItemLeaderAudio: _actor=%s, _action=%s _sample=%d", _actor.c_str(), _action.c_str(), _sample); + debug("\t\t\t\tSequenceItemLeaderAudio: _actor=%s, _action=%s _sample=%d", _actor.c_str(), _action.c_str(), _sample); } uint32 SequenceItemLeaderAudio::getSample() { - return _sample; + return _sample; } bool SequenceItemDefaultAction::execute(int index, Sequence *sequence, bool unk2) { - SequenceActorState *state = sequence->_sequencer->findSequenceActorState(_actor); - state->_actionName = _action; - return true; + SequenceActorState *state = sequence->_sequencer->findSequenceActorState(_actor); + state->_actionName = _action; + return true; } void SequenceItemDefaultAction::toConsole() { - debug("\t\t\t\tSequenceItemDefaultAction: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); + debug("\t\t\t\tSequenceItemDefaultAction: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); } void SequenceItemDefaultAction::skip(Sequence *sequence) { - execute(0, sequence, 1); + execute(0, sequence, 1); } } // End of namespace Pink diff --git a/engines/pink/objects/sequences/sequence_item.h b/engines/pink/objects/sequences/sequence_item.h index dd026a87d9..df22f86fe5 100644 --- a/engines/pink/objects/sequences/sequence_item.h +++ b/engines/pink/objects/sequences/sequence_item.h @@ -31,53 +31,53 @@ class Sequence; class SequenceItem : public Object { public: - virtual void deserialize(Archive &archive); + virtual void deserialize(Archive &archive); - virtual void toConsole(); + virtual void toConsole(); - const Common::String &getActor() const; - const Common::String &getAction() const; + const Common::String &getActor() const; + const Common::String &getAction() const; - virtual bool execute(int index, Sequence *sequence, bool unk2); - virtual bool isLeader(); - virtual void skip(Sequence *sequence) {}; + virtual bool execute(int index, Sequence *sequence, bool unk2); + virtual bool isLeader(); + virtual void skip(Sequence *sequence) {}; protected: - Common::String _actor; - Common::String _action; + Common::String _actor; + Common::String _action; }; class SequenceItemLeader : public SequenceItem { public: - virtual void toConsole(); - virtual bool isLeader(); + virtual void toConsole(); + virtual bool isLeader(); }; class SequenceItemLeaderAudio : public SequenceItemLeader { public: - virtual void deserialize(Archive &archive); - virtual void toConsole(); - uint32 getSample(); + virtual void deserialize(Archive &archive); + virtual void toConsole(); + uint32 getSample(); private: - uint32 _sample; + uint32 _sample; }; class SequenceItemDefaultAction : public SequenceItem { public: - virtual bool execute(int index, Sequence *sequence, bool unk2); - virtual void skip(Sequence *sequence); + virtual bool execute(int index, Sequence *sequence, bool unk2); + virtual void skip(Sequence *sequence); - virtual void toConsole(); + virtual void toConsole(); }; /* not used in games but is implemented in engine class SequenceItemSideEffects : public SequenceItemDefaultAction { public: - virtual void deserialize(Archive &archive); - virtual bool execute(int unk, Sequence *sequence, bool unk2); + virtual void deserialize(Archive &archive); + virtual bool execute(int unk, Sequence *sequence, bool unk2); private - Common::Array<SideEffect*> _sideEffects + Common::Array<SideEffect*> _sideEffects }; */ diff --git a/engines/pink/objects/sequences/sequencer.cpp b/engines/pink/objects/sequences/sequencer.cpp index 5644aa8f25..430c8c2da0 100644 --- a/engines/pink/objects/sequences/sequencer.cpp +++ b/engines/pink/objects/sequences/sequencer.cpp @@ -34,18 +34,18 @@ namespace Pink { Sequencer::Sequencer(GamePage *page) - : _context(nullptr), _page(page), _time(0) + : _context(nullptr), _page(page), _time(0) {} Sequencer::~Sequencer() { - for (uint i = 0; i < _sequences.size(); ++i) { - delete _sequences[i]; - } + for (uint i = 0; i < _sequences.size(); ++i) { + delete _sequences[i]; + } } void Sequencer::deserialize(Archive &archive) { - _sequences.deserialize(archive); - _timers.deserialize(archive); + _sequences.deserialize(archive); + _timers.deserialize(archive); } Sequence *Sequencer::findSequence(const Common::String &name) { @@ -57,75 +57,75 @@ Sequence *Sequencer::findSequence(const Common::String &name) { } void Sequencer::authorSequence(Sequence *sequence, bool unk) { - if (_context){ + if (_context){ - } + } - if (sequence){ - _context = new SequenceContext(sequence, this); - //unload array of unknown objects - _currentSequenceName = sequence->getName(); - sequence->init(unk); - } - else _currentSequenceName.clear(); + if (sequence){ + _context = new SequenceContext(sequence, this); + //unload array of unknown objects + _currentSequenceName = sequence->getName(); + sequence->init(unk); + } + else _currentSequenceName.clear(); } void Sequencer::toConsole() { - debug("Sequencer:"); - for (uint i = 0; i < _sequences.size(); ++i) { - _sequences[i]->toConsole(); - } - for (uint i = 0; i < _timers.size(); ++i) { - _timers[i]->toConsole(); - } + debug("Sequencer:"); + for (uint i = 0; i < _sequences.size(); ++i) { + _sequences[i]->toConsole(); + } + for (uint i = 0; i < _timers.size(); ++i) { + _timers[i]->toConsole(); + } } void Sequencer::update() { - if (_context) - _context->_sequence->update(); - updateTimers(); + if (_context) + _context->_sequence->update(); + updateTimers(); } void Sequencer::removeContext(SequenceContext *context) { - delete _context; - _context = nullptr; + delete _context; + _context = nullptr; } void Sequencer::skipSubSequence() { - if (_context) - _context->getSequence()->skipSubSequence(); + if (_context) + _context->getSequence()->skipSubSequence(); } void Sequencer::restartSequence() { - _context->getSequence()->restart(); + _context->getSequence()->restart(); } void Sequencer::skipToLastSubSequence() { - _context->getSequence()->skipToLastSubSequence(); + _context->getSequence()->skipToLastSubSequence(); } void Sequencer::updateTimers() { - uint time = _page->getGame()->getTotalPlayTime(); - if (time - _time <= kTimersUpdateTime) { - return; - } - - _time = time; - for (uint i = 0; i < _timers.size(); ++i) { - _timers[i]->update(); - } + uint time = _page->getGame()->getTotalPlayTime(); + if (time - _time <= kTimersUpdateTime) { + return; + } + + _time = time; + for (uint i = 0; i < _timers.size(); ++i) { + _timers[i]->update(); + } } SequenceActorState *Sequencer::findSequenceActorState(const Common::String &name) { - if (!_context) - return nullptr; + if (!_context) + return nullptr; - for (uint i = 0; i < _context->_states.size(); ++i) { - if (_context->_states[i].getActor() == name) - return &_context->_states[i]; - } + for (uint i = 0; i < _context->_states.size(); ++i) { + if (_context->_states[i].getActor() == name) + return &_context->_states[i]; + } - return nullptr; + return nullptr; } } // End of namespace Pink diff --git a/engines/pink/objects/sequences/sequencer.h b/engines/pink/objects/sequences/sequencer.h index 0213728bac..c1b957b995 100644 --- a/engines/pink/objects/sequences/sequencer.h +++ b/engines/pink/objects/sequences/sequencer.h @@ -35,36 +35,36 @@ class SequenceActorState; class Sequencer : public Object { public: - Sequencer(GamePage *page); - ~Sequencer(); + Sequencer(GamePage *page); + ~Sequencer(); - virtual void toConsole(); + virtual void toConsole(); - virtual void deserialize(Archive &archive); - Sequence* findSequence(const Common::String &name); - SequenceActorState *findSequenceActorState(const Common::String &name); + virtual void deserialize(Archive &archive); + Sequence* findSequence(const Common::String &name); + SequenceActorState *findSequenceActorState(const Common::String &name); - void authorSequence(Sequence *sequence, bool unk); + void authorSequence(Sequence *sequence, bool unk); - void removeContext(SequenceContext *context); + void removeContext(SequenceContext *context); - void update(); + void update(); - void skipSubSequence(); - void restartSequence(); - void skipToLastSubSequence(); + void skipSubSequence(); + void restartSequence(); + void skipToLastSubSequence(); public: - void updateTimers(); + void updateTimers(); - SequenceContext *_context; - // context array - Array<Sequence*> _sequences; - Array<SeqTimer*> _timers; + SequenceContext *_context; + // context array + Array<Sequence*> _sequences; + Array<SeqTimer*> _timers; Common::String _currentSequenceName; GamePage *_page; - uint _time; + uint _time; }; } // End of namespace Pink diff --git a/engines/pink/objects/side_effect.cpp b/engines/pink/objects/side_effect.cpp index 228b8d5dc8..3bf67e15f8 100644 --- a/engines/pink/objects/side_effect.cpp +++ b/engines/pink/objects/side_effect.cpp @@ -33,59 +33,59 @@ namespace Pink { void SideEffectExit::deserialize(Archive &archive) { - _nextModule = archive.readString(); - _nextPage = archive.readString(); + _nextModule = archive.readString(); + _nextPage = archive.readString(); } void SideEffectExit::execute(Actor *actor) { - actor->getPage()->getLeadActor()->setNextExecutors(_nextModule, _nextPage); + actor->getPage()->getLeadActor()->setNextExecutors(_nextModule, _nextPage); } void SideEffectExit::toConsole() { - debug("\t\tSideEffectExit: _nextModule=%s, _nextPage=%s", _nextModule.c_str(), _nextPage.c_str()); + debug("\t\tSideEffectExit: _nextModule=%s, _nextPage=%s", _nextModule.c_str(), _nextPage.c_str()); } void SideEffectLocation::deserialize(Archive &archive) { - _location = archive.readString(); + _location = archive.readString(); } void SideEffectLocation::execute(Actor *actor) { - WalkMgr *mgr = actor->getPage()->getWalkMgr(); - WalkLocation *location = mgr->findLocation(_location); - if (location) - mgr->setCurrentWayPoint(location); + WalkMgr *mgr = actor->getPage()->getWalkMgr(); + WalkLocation *location = mgr->findLocation(_location); + if (location) + mgr->setCurrentWayPoint(location); } void SideEffectLocation::toConsole() { - debug("\t\tSideEffectLocation: _location=%s", _location.c_str()); + debug("\t\tSideEffectLocation: _location=%s", _location.c_str()); } void SideEffectInventoryItemOwner::deserialize(Archive &archive) { - _item = archive.readString(); - _owner = archive.readString(); + _item = archive.readString(); + _owner = archive.readString(); } void SideEffectInventoryItemOwner::execute(Actor *actor) { - InventoryMgr *mgr = actor->getPage()->getModule()->getInventoryMgr(); - InventoryItem *item = mgr->findInventoryItem(_item); - mgr->setItemOwner(_owner, item); + InventoryMgr *mgr = actor->getPage()->getModule()->getInventoryMgr(); + InventoryItem *item = mgr->findInventoryItem(_item); + mgr->setItemOwner(_owner, item); } void SideEffectInventoryItemOwner::toConsole() { - debug("\t\tSideEffectInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); + debug("\t\tSideEffectInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); } void SideEffectVariable::deserialize(Pink::Archive &archive) { - _name = archive.readString(); - _value = archive.readString(); + _name = archive.readString(); + _value = archive.readString(); } void SideEffectGameVariable::execute(Actor *actor) { - actor->getPage()->getGame()->setVariable(_name, _value); + actor->getPage()->getGame()->setVariable(_name, _value); } void SideEffectGameVariable::toConsole() { - debug("\t\tSideEffectGameVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); + debug("\t\tSideEffectGameVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } void SideEffectModuleVariable::execute(Actor *actor) { @@ -93,39 +93,39 @@ void SideEffectModuleVariable::execute(Actor *actor) { } void SideEffectModuleVariable::toConsole() { - debug("\t\tSideEffectModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); + debug("\t\tSideEffectModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } void SideEffectPageVariable::execute(Actor *actor) { - actor->getPage()->setVariable(_name, _value); + actor->getPage()->setVariable(_name, _value); } void SideEffectPageVariable::toConsole() { - debug("\t\tSideEffectPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); + debug("\t\tSideEffectPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } void SideEffectRandomPageVariable::deserialize(Archive &archive) { - _name = archive.readString(); + _name = archive.readString(); _values.deserialize(archive); } void SideEffectRandomPageVariable::execute(Actor *actor) { - assert(!_values.empty()); + assert(!_values.empty()); - Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd(); - uint index = rnd.getRandomNumber(_values.size() - 1); + Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd(); + uint index = rnd.getRandomNumber(_values.size() - 1); - actor->getPage()->setVariable(_name, _values[index]); + actor->getPage()->setVariable(_name, _values[index]); } void SideEffectRandomPageVariable::toConsole() { - Common::String values("{"); - for (uint i = 0; i < _values.size(); ++i) { - values += _values[i]; - values += ','; - } - values += '}'; - debug("\t\tSideEffectRandomPageVariable: _name=%s, _values=%s", _name.c_str(), values.c_str()); + Common::String values("{"); + for (uint i = 0; i < _values.size(); ++i) { + values += _values[i]; + values += ','; + } + values += '}'; + debug("\t\tSideEffectRandomPageVariable: _name=%s, _values=%s", _name.c_str(), values.c_str()); } } // End of namespace Pink diff --git a/engines/pink/objects/side_effect.h b/engines/pink/objects/side_effect.h index 1a08d854e5..c917615b93 100644 --- a/engines/pink/objects/side_effect.h +++ b/engines/pink/objects/side_effect.h @@ -32,81 +32,81 @@ class Actor; class SideEffect : public Object { public: - virtual void deserialize(Archive &archive) = 0; - virtual void execute(Actor *actor) = 0; + virtual void deserialize(Archive &archive) = 0; + virtual void execute(Actor *actor) = 0; }; class SideEffectExit : public SideEffect { public: - virtual void deserialize(Archive &archive); - virtual void toConsole(); - virtual void execute(Actor *actor); + virtual void deserialize(Archive &archive); + virtual void toConsole(); + virtual void execute(Actor *actor); private: - Common::String _nextModule; - Common::String _nextPage; - Common::StringMap map; + Common::String _nextModule; + Common::String _nextPage; + Common::StringMap map; }; class SideEffectLocation : public SideEffect { public: - virtual void deserialize(Archive &archive); - virtual void execute(Actor *actor); - virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual void execute(Actor *actor); + virtual void toConsole(); private: - Common::String _location; + Common::String _location; }; class SideEffectInventoryItemOwner : public SideEffect { public: - virtual void deserialize(Archive &archive); - virtual void execute(Actor *actor); - virtual void toConsole(); + virtual void deserialize(Archive &archive); + virtual void execute(Actor *actor); + virtual void toConsole(); private: - Common::String _item; - Common::String _owner; + Common::String _item; + Common::String _owner; }; class SideEffectVariable : public SideEffect { public: - virtual void deserialize(Archive &archive); - virtual void execute(Actor *actor) = 0; + virtual void deserialize(Archive &archive); + virtual void execute(Actor *actor) = 0; protected: - Common::String _name; - Common::String _value; + Common::String _name; + Common::String _value; }; class SideEffectGameVariable : public SideEffectVariable { public: - virtual void toConsole(); - virtual void execute(Actor *actor); + virtual void toConsole(); + virtual void execute(Actor *actor); }; class SideEffectModuleVariable : public SideEffectVariable { public: - virtual void toConsole(); - virtual void execute(Actor *actor); + virtual void toConsole(); + virtual void execute(Actor *actor); }; class SideEffectPageVariable : public SideEffectVariable { public: - virtual void toConsole(); - virtual void execute(Actor *actor); + virtual void toConsole(); + virtual void execute(Actor *actor); }; class SideEffectRandomPageVariable : public SideEffect { public: - virtual void deserialize(Archive &archive); - virtual void toConsole(); - virtual void execute(Actor *actor); + virtual void deserialize(Archive &archive); + virtual void toConsole(); + virtual void execute(Actor *actor); private: - Common::String _name; - StringArray _values; + Common::String _name; + StringArray _values; }; } // End of namespace Pink diff --git a/engines/pink/objects/walk/walk_location.cpp b/engines/pink/objects/walk/walk_location.cpp index ec2dbc9be9..dd16882396 100644 --- a/engines/pink/objects/walk/walk_location.cpp +++ b/engines/pink/objects/walk/walk_location.cpp @@ -28,16 +28,16 @@ namespace Pink { void WalkLocation::deserialize(Pink::Archive &archive) { - NamedObject::deserialize(archive); - _neighbors.deserialize(archive); + NamedObject::deserialize(archive); + _neighbors.deserialize(archive); } void WalkLocation::toConsole() { - debug("\tWalkLocation: _name =%s", _name.c_str()); - debug("\tNeighbors:"); - for (uint i = 0; i < _neighbors.size(); ++i) { - debug("\t\t%s", _neighbors[i].c_str()); - } + debug("\tWalkLocation: _name =%s", _name.c_str()); + debug("\tNeighbors:"); + for (uint i = 0; i < _neighbors.size(); ++i) { + debug("\t\t%s", _neighbors[i].c_str()); + } } } // End of namespace Pink diff --git a/engines/pink/objects/walk/walk_location.h b/engines/pink/objects/walk/walk_location.h index ef1cbab192..1f77584076 100644 --- a/engines/pink/objects/walk/walk_location.h +++ b/engines/pink/objects/walk/walk_location.h @@ -28,12 +28,12 @@ namespace Pink { class WalkLocation : public NamedObject { public: - virtual void deserialize(Archive &archive); - void toConsole() override; - Common::StringArray &getNeigbors() { return _neighbors;} + virtual void deserialize(Archive &archive); + void toConsole() override; + Common::StringArray &getNeigbors() { return _neighbors;} private: - StringArray _neighbors; + StringArray _neighbors; }; } // End of namespace Pink diff --git a/engines/pink/objects/walk/walk_mgr.cpp b/engines/pink/objects/walk/walk_mgr.cpp index 989f69e4af..c9c28f0ffc 100644 --- a/engines/pink/objects/walk/walk_mgr.cpp +++ b/engines/pink/objects/walk/walk_mgr.cpp @@ -30,14 +30,14 @@ namespace Pink { WalkMgr::WalkMgr() - : _isWalking(false), _leadActor(nullptr) + : _isWalking(false), _leadActor(nullptr) { } void WalkMgr::deserialize(Pink::Archive &archive) { - _leadActor = static_cast<LeadActor *>(archive.readObject()); - _locations.deserialize(archive); + _leadActor = static_cast<LeadActor *>(archive.readObject()); + _locations.deserialize(archive); } WalkLocation *WalkMgr::findLocation(const Common::String &name) { @@ -50,103 +50,103 @@ WalkLocation *WalkMgr::findLocation(const Common::String &name) { } void WalkMgr::toConsole() { - debug("WalkMgr:"); - for (uint i = 0; i < _locations.size(); ++i) { - _locations[i]->toConsole(); - } + debug("WalkMgr:"); + for (uint i = 0; i < _locations.size(); ++i) { + _locations[i]->toConsole(); + } } void WalkMgr::start(WalkLocation *destination) { - if (_isWalking) - return; - - if (_current.name.empty()) { - _current.name = _locations[0]->getName(); - _current.coord = getLocationCoordinates(_locations[0]->getName()); - } - - _destination = destination; - - if (_current.name == _destination->getName()) { - end(); - } - else { - _isWalking = true; - WalkLocation *currentLocation = findLocation(_current.name); - WalkShortestPath path(this); - WalkLocation *nextLocation = path.next(currentLocation, _destination); - initNextWayPoint(nextLocation); - _leadActor->setAction(getWalkAction(), 0); - } + if (_isWalking) + return; + + if (_current.name.empty()) { + _current.name = _locations[0]->getName(); + _current.coord = getLocationCoordinates(_locations[0]->getName()); + } + + _destination = destination; + + if (_current.name == _destination->getName()) { + end(); + } + else { + _isWalking = true; + WalkLocation *currentLocation = findLocation(_current.name); + WalkShortestPath path(this); + WalkLocation *nextLocation = path.next(currentLocation, _destination); + initNextWayPoint(nextLocation); + _leadActor->setAction(getWalkAction(), 0); + } } void WalkMgr::initNextWayPoint(WalkLocation *location) { - _next.name = location->getName(); - _next.coord = getLocationCoordinates(location->getName()); + _next.name = location->getName(); + _next.coord = getLocationCoordinates(location->getName()); } WalkAction *WalkMgr::getWalkAction() { - Common::String walkActionName; - if (_current.coord.z == _next.coord.z){ - if (_next.coord.x > _current.coord.x){ - walkActionName = Common::String::format("%dRight", _current.coord.z); - } - else walkActionName = Common::String::format("%dLeft", _next.coord.z); - } - else walkActionName = Common::String::format("%dTo%d", _current.coord.z, _next.coord.z); + Common::String walkActionName; + if (_current.coord.z == _next.coord.z){ + if (_next.coord.x > _current.coord.x){ + walkActionName = Common::String::format("%dRight", _current.coord.z); + } + else walkActionName = Common::String::format("%dLeft", _next.coord.z); + } + else walkActionName = Common::String::format("%dTo%d", _current.coord.z, _next.coord.z); - Action *action = _leadActor->findAction(walkActionName); + Action *action = _leadActor->findAction(walkActionName); - return static_cast<WalkAction*>(action); + return static_cast<WalkAction*>(action); } double WalkMgr::getLengthBetweenLocations(WalkLocation *first, WalkLocation *second) { - Coordinates firstCoord = getLocationCoordinates(first->getName()); - Coordinates secondCoord = getLocationCoordinates(second->getName()); - return sqrt((secondCoord.x - firstCoord.x) * (secondCoord.x - firstCoord.x) + - (secondCoord.y - firstCoord.y) * (secondCoord.y - firstCoord.y)); + Coordinates firstCoord = getLocationCoordinates(first->getName()); + Coordinates secondCoord = getLocationCoordinates(second->getName()); + return sqrt((secondCoord.x - firstCoord.x) * (secondCoord.x - firstCoord.x) + + (secondCoord.y - firstCoord.y) * (secondCoord.y - firstCoord.y)); } WalkMgr::Coordinates WalkMgr::getLocationCoordinates(const Common::String &locationName) { - Coordinates coords; - ActionCEL *action = static_cast<ActionCEL*>(_leadActor->findAction(locationName)); + Coordinates coords; + ActionCEL *action = static_cast<ActionCEL*>(_leadActor->findAction(locationName)); - action->start(0); - CelDecoder *decoder = action->getDecoder(); + action->start(0); + CelDecoder *decoder = action->getDecoder(); - coords.x = decoder->getX() + decoder->getWidth() / 2; - coords.y = decoder->getY() + decoder->getHeight() / 2; - coords.z = action->getZ(); + coords.x = decoder->getX() + decoder->getWidth() / 2; + coords.y = decoder->getY() + decoder->getHeight() / 2; + coords.z = action->getZ(); - action->end(); + action->end(); - return coords; + return coords; } void WalkMgr::setCurrentWayPoint(WalkLocation *location) { - _current.name = location->getName(); - _current.coord = getLocationCoordinates(_current.name); + _current.name = location->getName(); + _current.coord = getLocationCoordinates(_current.name); } void WalkMgr::update() { - if (_leadActor->isPlaying()) - return; - - WalkShortestPath path(this); - _current = _next; - WalkLocation *next = path.next(findLocation(_current.name), _destination); - if (next){ - initNextWayPoint(next); - _leadActor->setAction(getWalkAction(), 0); - } - else end(); + if (_leadActor->isPlaying()) + return; + + WalkShortestPath path(this); + _current = _next; + WalkLocation *next = path.next(findLocation(_current.name), _destination); + if (next){ + initNextWayPoint(next); + _leadActor->setAction(getWalkAction(), 0); + } + else end(); } void WalkMgr::end() { - _isWalking = false; - _leadActor->onWalkEnd(); + _isWalking = false; + _leadActor->onWalkEnd(); } } // End of namespace Pink diff --git a/engines/pink/objects/walk/walk_mgr.h b/engines/pink/objects/walk/walk_mgr.h index 994796942b..64bd16e48b 100644 --- a/engines/pink/objects/walk/walk_mgr.h +++ b/engines/pink/objects/walk/walk_mgr.h @@ -34,39 +34,39 @@ class WalkAction; class WalkMgr : public Object { public: - WalkMgr(); - virtual void deserialize(Archive &archive); - void toConsole() override; + WalkMgr(); + virtual void deserialize(Archive &archive); + void toConsole() override; - WalkLocation *findLocation(const Common::String &name); - void start(WalkLocation *destination); - void update(); + WalkLocation *findLocation(const Common::String &name); + void start(WalkLocation *destination); + void update(); - double getLengthBetweenLocations(WalkLocation *first, WalkLocation *second); - void setCurrentWayPoint(WalkLocation *location); + double getLengthBetweenLocations(WalkLocation *first, WalkLocation *second); + void setCurrentWayPoint(WalkLocation *location); private: - struct Coordinates { - int x; - int y; - int z; - }; - struct WayPoint { - Common::String name; - Coordinates coord; - }; + struct Coordinates { + int x; + int y; + int z; + }; + struct WayPoint { + Common::String name; + Coordinates coord; + }; - Coordinates getLocationCoordinates(const Common::String &locationName); - void end(); - void initNextWayPoint(WalkLocation *location); - WalkAction *getWalkAction(); + Coordinates getLocationCoordinates(const Common::String &locationName); + void end(); + void initNextWayPoint(WalkLocation *location); + WalkAction *getWalkAction(); - LeadActor *_leadActor; - WalkLocation *_destination; - Array<WalkLocation*> _locations; - WayPoint _current; - WayPoint _next; - bool _isWalking; + LeadActor *_leadActor; + WalkLocation *_destination; + Array<WalkLocation*> _locations; + WayPoint _current; + WayPoint _next; + bool _isWalking; }; } // End of namespace Pink diff --git a/engines/pink/objects/walk/walk_shortest_path.cpp b/engines/pink/objects/walk/walk_shortest_path.cpp index 26253235bd..376e638d91 100644 --- a/engines/pink/objects/walk/walk_shortest_path.cpp +++ b/engines/pink/objects/walk/walk_shortest_path.cpp @@ -27,134 +27,134 @@ namespace Pink { WalkShortestPath::WalkShortestPath(WalkMgr *manager) - : _manager(manager) + : _manager(manager) {} WalkLocation *WalkShortestPath::next(WalkLocation *start, WalkLocation *destination) { - if (start == destination) - return nullptr; - add(start, 0.0, 0); - while (build() != destination); - return getNearestNeighbor(destination); + if (start == destination) + return nullptr; + add(start, 0.0, 0); + while (build() != destination); + return getNearestNeighbor(destination); } void WalkShortestPath::add(WalkLocation *wl, double val, WalkLocation *nearest) { - _locations.push_back(wl); - _visited.push_back(wl); - _weight.push_back(val); - _nearestNeigbor.push_back(nearest); + _locations.push_back(wl); + _visited.push_back(wl); + _weight.push_back(val); + _nearestNeigbor.push_back(nearest); } WalkLocation *WalkShortestPath::build() { - WalkLocation *nearest = nullptr; - WalkLocation *location = nullptr; - double len = -1.0; - addLocationsToVisit(); - for (uint i = 0; i < _toVisit.size(); ++i) { - double curLen = getLengthToNearestNeigbor(_toVisit[i]); - if (curLen < 0) { - remove(_toVisit[i]); - continue; - } - curLen += getWeight(_toVisit[i]); - if (len < 0.0 || len > curLen) { - len = curLen; - location = _toVisit[i]; - nearest = getNearestNeighbor(_toVisit[i]); - if (!nearest) - nearest = findNearestNeighbor(_toVisit[i]); - } - } - - WalkLocation *neighbor = findNearestNeighbor(location); - if (neighbor) - add(neighbor, len, nearest); - - return neighbor; + WalkLocation *nearest = nullptr; + WalkLocation *location = nullptr; + double len = -1.0; + addLocationsToVisit(); + for (uint i = 0; i < _toVisit.size(); ++i) { + double curLen = getLengthToNearestNeigbor(_toVisit[i]); + if (curLen < 0) { + remove(_toVisit[i]); + continue; + } + curLen += getWeight(_toVisit[i]); + if (len < 0.0 || len > curLen) { + len = curLen; + location = _toVisit[i]; + nearest = getNearestNeighbor(_toVisit[i]); + if (!nearest) + nearest = findNearestNeighbor(_toVisit[i]); + } + } + + WalkLocation *neighbor = findNearestNeighbor(location); + if (neighbor) + add(neighbor, len, nearest); + + return neighbor; } WalkLocation *WalkShortestPath::getNearestNeighbor(WalkLocation *location) { - for(uint i = 0; i < _visited.size(); ++i){ - if (_visited[i] == location) - return _nearestNeigbor[i]; - } + for(uint i = 0; i < _visited.size(); ++i){ + if (_visited[i] == location) + return _nearestNeigbor[i]; + } - return nullptr; + return nullptr; } void WalkShortestPath::addLocationsToVisit() { - _toVisit.resize(_locations.size()); - for (uint i = 0; i < _locations.size(); ++i) { - _toVisit[i] = _locations[i]; - } + _toVisit.resize(_locations.size()); + for (uint i = 0; i < _locations.size(); ++i) { + _toVisit[i] = _locations[i]; + } } double WalkShortestPath::getLengthToNearestNeigbor(WalkLocation *location) { - double minLength = -1.0; + double minLength = -1.0; Common::StringArray &neighbors = location->getNeigbors(); - for (uint i = 0; i < neighbors.size(); ++i) { - WalkLocation *neighbor = _manager->findLocation(neighbors[i]); - if (!isLocationVisited(neighbor)){ - double length = _manager->getLengthBetweenLocations(location, neighbor); - if (minLength >= 0.0) { - if (length < minLength) - minLength = length; - } - else minLength = length; - } - } - - return minLength; + for (uint i = 0; i < neighbors.size(); ++i) { + WalkLocation *neighbor = _manager->findLocation(neighbors[i]); + if (!isLocationVisited(neighbor)){ + double length = _manager->getLengthBetweenLocations(location, neighbor); + if (minLength >= 0.0) { + if (length < minLength) + minLength = length; + } + else minLength = length; + } + } + + return minLength; } WalkLocation *WalkShortestPath::findNearestNeighbor(WalkLocation *location) { - double minLength = -1.0; - WalkLocation *nearest = nullptr; - Common::StringArray &neighbors = location->getNeigbors(); - for (uint i = 0; i < neighbors.size(); ++i) { - WalkLocation *neighbor = _manager->findLocation(neighbors[i]); - if (!isLocationVisited(neighbor)){ - double length = _manager->getLengthBetweenLocations(location, neighbor); - if (minLength >= 0.0) { - if (length < minLength) { - nearest = neighbor; - minLength = length; - } - } - else { - nearest = neighbor; - minLength = length; - } - } - } - - return nearest; + double minLength = -1.0; + WalkLocation *nearest = nullptr; + Common::StringArray &neighbors = location->getNeigbors(); + for (uint i = 0; i < neighbors.size(); ++i) { + WalkLocation *neighbor = _manager->findLocation(neighbors[i]); + if (!isLocationVisited(neighbor)){ + double length = _manager->getLengthBetweenLocations(location, neighbor); + if (minLength >= 0.0) { + if (length < minLength) { + nearest = neighbor; + minLength = length; + } + } + else { + nearest = neighbor; + minLength = length; + } + } + } + + return nearest; } double WalkShortestPath::getWeight(WalkLocation *location) { - for (uint i = 0; i < _locations.size(); ++i) { - if (_locations[i] == location) - return _weight[i]; - } - return 0.0; + for (uint i = 0; i < _locations.size(); ++i) { + if (_locations[i] == location) + return _weight[i]; + } + return 0.0; } bool WalkShortestPath::isLocationVisited(WalkLocation *location) { - for (uint i = 0; i < _visited.size(); ++i) { - if (_visited[i] == location) - return true; - } - return false; + for (uint i = 0; i < _visited.size(); ++i) { + if (_visited[i] == location) + return true; + } + return false; } void WalkShortestPath::remove(WalkLocation *location) { - for (uint i = 0; i < _locations.size(); ++i) { - if (_locations[i] == location){ - _locations.remove_at(i); - _weight.remove_at(i); - break; - } - } + for (uint i = 0; i < _locations.size(); ++i) { + if (_locations[i] == location){ + _locations.remove_at(i); + _weight.remove_at(i); + break; + } + } } } // End of namespace Pink diff --git a/engines/pink/objects/walk/walk_shortest_path.h b/engines/pink/objects/walk/walk_shortest_path.h index deb7770061..a3ec85df1d 100644 --- a/engines/pink/objects/walk/walk_shortest_path.h +++ b/engines/pink/objects/walk/walk_shortest_path.h @@ -32,27 +32,27 @@ class WalkMgr; class WalkShortestPath { public: - WalkShortestPath(WalkMgr *manager); - WalkLocation *next(WalkLocation *start, WalkLocation *destination); + WalkShortestPath(WalkMgr *manager); + WalkLocation *next(WalkLocation *start, WalkLocation *destination); private: - void add(WalkLocation *wl, double val, WalkLocation *nearest); - void remove(WalkLocation *location); - WalkLocation *build(); - WalkLocation *getNearestNeighbor(WalkLocation *location); - WalkLocation *findNearestNeighbor(WalkLocation *location); - double getLengthToNearestNeigbor(WalkLocation *location); - double getWeight(WalkLocation *location); - void addLocationsToVisit(); - bool isLocationVisited(WalkLocation *location); - - - WalkMgr *_manager; - Common::Array<WalkLocation*> _locations; - Common::Array<WalkLocation*> _toVisit; - Common::Array<double> _weight; - Common::Array<WalkLocation*> _visited; - Common::Array<WalkLocation*> _nearestNeigbor; + void add(WalkLocation *wl, double val, WalkLocation *nearest); + void remove(WalkLocation *location); + WalkLocation *build(); + WalkLocation *getNearestNeighbor(WalkLocation *location); + WalkLocation *findNearestNeighbor(WalkLocation *location); + double getLengthToNearestNeigbor(WalkLocation *location); + double getWeight(WalkLocation *location); + void addLocationsToVisit(); + bool isLocationVisited(WalkLocation *location); + + + WalkMgr *_manager; + Common::Array<WalkLocation*> _locations; + Common::Array<WalkLocation*> _toVisit; + Common::Array<double> _weight; + Common::Array<WalkLocation*> _visited; + Common::Array<WalkLocation*> _nearestNeigbor; }; } // End of namespace Pink |