From e98c14c3d7d790f6ba77ab4d4925b608c55e2e22 Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Tue, 22 May 2018 11:58:02 +0300 Subject: PINK: fix formatting --- engines/pink/archive.cpp | 12 +- engines/pink/cel_decoder.cpp | 45 ++-- engines/pink/cursor_mgr.cpp | 22 +- engines/pink/detection.cpp | 3 +- engines/pink/detection_tables.h | 42 +-- engines/pink/director.cpp | 15 +- engines/pink/director.h | 4 +- engines/pink/file.cpp | 13 +- engines/pink/objects/actions/action.h | 4 +- engines/pink/objects/actions/action_cel.cpp | 6 +- engines/pink/objects/actions/action_cel.h | 2 +- engines/pink/objects/actions/action_loop.cpp | 19 +- engines/pink/objects/actions/action_play.cpp | 2 +- .../pink/objects/actions/action_play_with_sfx.cpp | 6 +- .../pink/objects/actions/action_play_with_sfx.h | 2 +- engines/pink/objects/actions/action_sound.cpp | 3 +- engines/pink/objects/actors/actor.cpp | 12 +- engines/pink/objects/actors/actor.h | 7 +- engines/pink/objects/actors/lead_actor.cpp | 284 ++++++++++----------- engines/pink/objects/actors/supporting_actor.cpp | 14 +- engines/pink/objects/actors/supporting_actor.h | 1 - engines/pink/objects/handlers/handler.cpp | 3 +- engines/pink/objects/handlers/handler.h | 4 +- engines/pink/objects/handlers/handler_mgr.h | 6 +- engines/pink/objects/handlers/handler_timer.cpp | 1 - engines/pink/objects/inventory.cpp | 21 +- engines/pink/objects/inventory.h | 2 +- engines/pink/objects/module.cpp | 6 +- engines/pink/objects/module.h | 2 +- engines/pink/objects/object.cpp | 7 +- engines/pink/objects/object.h | 8 +- engines/pink/objects/pages/game_page.cpp | 8 +- engines/pink/objects/pages/game_page.h | 2 +- engines/pink/objects/pages/page.h | 2 +- engines/pink/objects/sequences/seq_timer.cpp | 2 +- engines/pink/objects/sequences/sequence.cpp | 18 +- engines/pink/objects/sequences/sequence.h | 4 +- .../pink/objects/sequences/sequence_context.cpp | 7 +- engines/pink/objects/sequences/sequence_item.cpp | 3 +- engines/pink/objects/sequences/sequencer.cpp | 11 +- engines/pink/objects/sequences/sequencer.h | 6 +- engines/pink/objects/side_effect.h | 3 +- engines/pink/objects/walk/walk_mgr.cpp | 30 +-- engines/pink/objects/walk/walk_mgr.h | 2 +- engines/pink/objects/walk/walk_shortest_path.cpp | 15 +- engines/pink/objects/walk/walk_shortest_path.h | 8 +- engines/pink/pink.cpp | 69 +++-- engines/pink/pink.h | 4 +- engines/pink/resource_mgr.cpp | 6 +- engines/pink/sound.cpp | 9 +- 50 files changed, 359 insertions(+), 428 deletions(-) diff --git a/engines/pink/archive.cpp b/engines/pink/archive.cpp index 36eda115b7..beec60baa7 100644 --- a/engines/pink/archive.cpp +++ b/engines/pink/archive.cpp @@ -212,22 +212,17 @@ static Object* createObject(int objectId){ } Archive::Archive(Common::SeekableReadStream *stream) - : _readStream(stream), _writeStream(nullptr) -{ + : _readStream(stream), _writeStream(nullptr) { _objectMap.push_back(0); _objectIdMap.push_back(kNullObject); } Archive::Archive(Common::WriteStream *stream) - : _writeStream(stream), _readStream(nullptr) -{ + : _writeStream(stream), _readStream(nullptr) { _objectMap.push_back(0); _objectIdMap.push_back(kNullObject); } -Archive::~Archive() -{} - void Archive::mapObject(Object *obj) { _objectMap.push_back(obj); _objectIdMap.push_back(0); @@ -246,9 +241,8 @@ Object *Archive::readObject() { bool isCopyReturned; Object *res = parseObject(isCopyReturned); - if (res && !isCopyReturned) { + if (res && !isCopyReturned) res->deserialize(*this); - } return res; } diff --git a/engines/pink/cel_decoder.cpp b/engines/pink/cel_decoder.cpp index 7a2a91ed85..0bdba49a31 100644 --- a/engines/pink/cel_decoder.cpp +++ b/engines/pink/cel_decoder.cpp @@ -129,15 +129,15 @@ void CelDecoder::CelVideoTrack::readPrefixChunk() { uint16 subchunkType = _fileStream->readUint16LE(); switch (subchunkType) { - case CEL_DATA: - _fileStream->readUint16LE(); - _center.x = _fileStream->readUint16LE(); - _center.y = _fileStream->readUint16LE(); - break; - default: - error("Unknown subchunk type"); - _fileStream->skip(subchunkSize - 6); - break; + case CEL_DATA: + _fileStream->readUint16LE(); + _center.x = _fileStream->readUint16LE(); + _center.y = _fileStream->readUint16LE(); + break; + default: + error("Unknown subchunk type"); + _fileStream->skip(subchunkSize - 6); + break; } _rect = Common::Rect::center(_center.x, _center.y, _surface->w, _surface->h); } @@ -151,9 +151,8 @@ void CelDecoder::CelVideoTrack::readHeader() { _offsetFrame1 = _fileStream->readUint32LE(); _offsetFrame2 = _fileStream->readUint32LE(); - if (_offsetFrame1 > 0x80) { + if (_offsetFrame1 > 0x80) readPrefixChunk(); - } _fileStream->seek(_offsetFrame1); } @@ -190,12 +189,12 @@ void CelDecoder::CelVideoTrack::skipFrame() { uint16 frameType = _fileStream->readUint16LE(); switch (frameType) { - case FRAME_TYPE: - handleFrame(); - break; - default: - error("FlicDecoder::decodeFrame(): unknown main chunk type (type = 0x%02X)", frameType); - break; + case FRAME_TYPE: + handleFrame(); + break; + default: + error("FlicDecoder::decodeFrame(): unknown main chunk type (type = 0x%02X)", frameType); + break; } _curFrame++; @@ -218,12 +217,12 @@ const Graphics::Surface *CelDecoder::CelVideoTrack::decodeNextFrame() { uint16 frameType = _fileStream->readUint16LE(); switch (frameType) { - case FRAME_TYPE: - handleFrame(); - break; - default: - error("FlicDecoder::decodeFrame(): unknown main chunk type (type = 0x%02X)", frameType); - break; + case FRAME_TYPE: + handleFrame(); + break; + default: + error("FlicDecoder::decodeFrame(): unknown main chunk type (type = 0x%02X)", frameType); + break; } _curFrame++; diff --git a/engines/pink/cursor_mgr.cpp b/engines/pink/cursor_mgr.cpp index 81fb61aa04..d15f695cac 100644 --- a/engines/pink/cursor_mgr.cpp +++ b/engines/pink/cursor_mgr.cpp @@ -31,8 +31,7 @@ namespace Pink { CursorMgr::CursorMgr(PinkEngine *game, GamePage *page) : _actor(nullptr), _page(page), _game(game), - _isPlayingAnimation(0), _firstFrameIndex(0) -{} + _isPlayingAnimation(0), _firstFrameIndex(0) {} CursorMgr::~CursorMgr() {} @@ -40,8 +39,7 @@ void CursorMgr::setCursor(uint index, Common::Point point, const Common::String if (index == kClickableFirstFrameCursor) { startAnimation(index); return hideItem(); - } - else if (index != kHoldingItemCursor){ + } else if (index != kHoldingItemCursor){ if (index != kPDASecondCursor) { _game->setCursor(index); @@ -67,8 +65,7 @@ void CursorMgr::setCursor(uint index, Common::Point point, const Common::String CelDecoder *decoder = static_cast(action)->getDecoder(); decoder->setX(point.x); decoder->setY(point.y); - } - else { + } else { CelDecoder *decoder = static_cast(action)->getDecoder(); decoder->setX(point.x); decoder->setY(point.y); @@ -90,22 +87,21 @@ void CursorMgr::update() { void CursorMgr::setCursor(Common::String &cursorName, Common::Point point) { uint index; - if (cursorName == kCursorNameExitLeft) { + if (cursorName == kCursorNameExitLeft) index = kExitLeftCursor; - } - else if (cursorName == kCursorNameExitRight){ + else if (cursorName == kCursorNameExitRight) index = kExitRightCursor; - } else //if (cursorName == kCursorNameExitForward || cursorName == kCursorNameExitUp) index = kExitForwardCursor; - //else assert(0); - + //else + //assert(0); setCursor(index, point, Common::String()); } void CursorMgr::hideItem() { - if (_actor) _actor->hide(); + if (_actor) + _actor->hide(); } void CursorMgr::startAnimation(int index) { diff --git a/engines/pink/detection.cpp b/engines/pink/detection.cpp index f0a0901cbf..771db19e8e 100644 --- a/engines/pink/detection.cpp +++ b/engines/pink/detection.cpp @@ -55,9 +55,8 @@ public: }; bool PinkMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { - if (desc) { + if (desc) *engine = new Pink::PinkEngine(syst, desc); - } return desc != 0; } diff --git a/engines/pink/detection_tables.h b/engines/pink/detection_tables.h index e14e8895ac..5a9f27af46 100644 --- a/engines/pink/detection_tables.h +++ b/engines/pink/detection_tables.h @@ -29,27 +29,31 @@ namespace Pink { static const ADGameDescription gameDescriptions[] = { { - "peril", - 0,{ - {"PPTP.ORB", NULL, NULL, -1}, - {"PPTP.BRO", NULL, NULL, -1}, - {"PPTP.EXE", NULL, NULL, -1}, - AD_LISTEND}, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO1(GUIO_NONE) + "peril", + 0, + { + {"PPTP.ORB", NULL, NULL, -1}, + {"PPTP.BRO", NULL, NULL, -1}, + {"PPTP.EXE", NULL, NULL, -1}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO1(GUIO_NONE) }, { - "pokus", - 0, { - {"HPP.orb", NULL, NULL, -1}, - {"hpp.exe", NULL, NULL, -1}, - AD_LISTEND}, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO1(GUIO_NONE) + "pokus", + 0, + { + {"HPP.orb", NULL, NULL, -1}, + {"hpp.exe", NULL, NULL, -1}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO1(GUIO_NONE) }, AD_TABLE_END_MARKER }; diff --git a/engines/pink/director.cpp b/engines/pink/director.cpp index 4ac5c9424f..14aa40db3c 100644 --- a/engines/pink/director.cpp +++ b/engines/pink/director.cpp @@ -43,11 +43,10 @@ void Director::draw() { void Director::drawSprite(ActionCEL *sprite) { CelDecoder *decoder = sprite->getDecoder(); const Graphics::Surface *surface; - if (decoder->needsUpdate()) { - + if (decoder->needsUpdate()) surface = decoder->decodeNextFrame(); - } - else surface = decoder->getCurrentFrame(); + else + surface = decoder->getCurrentFrame(); int h = surface->h; if (surface->h + decoder->getY() > 480) @@ -69,7 +68,8 @@ void Director::drawSprite(ActionCEL *sprite) { } _system->unlockScreen(); } - else _system->copyRectToScreen(surface->getPixels(), surface->pitch, + else + _system->copyRectToScreen(surface->getPixels(), surface->pitch, decoder->getX(), decoder->getY(), w, h); @@ -80,9 +80,10 @@ void Director::addSprite(ActionCEL *sprite) { _sprites.push_back(sprite); int i; for (i = _sprites.size() - 1; i > 0 ; --i) { - if (sprite->getZ() < _sprites[i - 1]->getZ()){ + if (sprite->getZ() < _sprites[i - 1]->getZ()) _sprites[i] = _sprites[i - 1]; - } else break; + else + break; } _sprites[i] = sprite; } diff --git a/engines/pink/director.h b/engines/pink/director.h index b1566e7000..99622e3c0b 100644 --- a/engines/pink/director.h +++ b/engines/pink/director.h @@ -56,8 +56,8 @@ public: private: void drawSprite(ActionCEL *sprite); OSystem *_system; - Common::Array _sprites; - Common::Array _sounds; + Common::Array _sprites; + Common::Array _sounds; }; } // End of namespace Pink diff --git a/engines/pink/file.cpp b/engines/pink/file.cpp index 68fc53c618..77c1873e73 100644 --- a/engines/pink/file.cpp +++ b/engines/pink/file.cpp @@ -41,22 +41,19 @@ bool OrbFile::open(const Common::String &name) { if (!File::open(name)) return false; - if (readUint32BE() != 'ORB\0'){ + if (readUint32BE() != 'ORB\0') return false; - } uint16 minor = readUint16LE(); uint16 major = readUint16LE(); debug("Orb v%hu.%hu loaded", major, minor); - if (major != kOrbMajorVersion || minor != kOrbMinorVersion){ + if (major != kOrbMajorVersion || minor != kOrbMinorVersion) return false; - } - if (!(_timestamp = readUint32LE())){ + if (!(_timestamp = readUint32LE())) return false; - } _tableOffset = readUint32LE(); _tableSize = readUint32LE(); @@ -120,7 +117,6 @@ ResourceDescription *OrbFile::getResDescTable(ObjectDescription *objDesc){ return table; } - bool BroFile::open(const Common::String &name, uint32 orbTimestamp) { if (!File::open(name) || readUint32BE() != 'BRO\0') return false; @@ -130,9 +126,8 @@ bool BroFile::open(const Common::String &name, uint32 orbTimestamp) { debug("Bro v%hu.%hu loaded", major, minor); - if (major != kBroMajorVersion || minor != kBroMinorVersion){ + if (major != kBroMajorVersion || minor != kBroMinorVersion) return false; - } uint32 timestamp = readUint32LE(); diff --git a/engines/pink/objects/actions/action.h b/engines/pink/objects/actions/action.h index 241aee821f..7dd0d2a9be 100644 --- a/engines/pink/objects/actions/action.h +++ b/engines/pink/objects/actions/action.h @@ -38,9 +38,9 @@ public: 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() {}; diff --git a/engines/pink/objects/actions/action_cel.cpp b/engines/pink/objects/actions/action_cel.cpp index f38c127782..8e868a199b 100644 --- a/engines/pink/objects/actions/action_cel.cpp +++ b/engines/pink/objects/actions/action_cel.cpp @@ -32,9 +32,7 @@ namespace Pink { ActionCEL::ActionCEL() - : _decoder(nullptr) { - -} + : _decoder(nullptr) {} void ActionCEL::deserialize(Archive &archive) { Action::deserialize(archive); @@ -74,7 +72,7 @@ bool ActionCEL::initPalette(Director *director) { } void ActionCEL::update() { - if (_decoder->endOfVideo()){ + if (_decoder->endOfVideo()) { _decoder->stop(); _actor->endAction(); } diff --git a/engines/pink/objects/actions/action_cel.h b/engines/pink/objects/actions/action_cel.h index 765fe8dd61..bf1ae2961d 100644 --- a/engines/pink/objects/actions/action_cel.h +++ b/engines/pink/objects/actions/action_cel.h @@ -49,7 +49,7 @@ public: void unpause() override; protected: - virtual void onStart() {} ; + virtual void onStart() {}; CelDecoder *_decoder; Common::String _fileName; uint32 _z; diff --git a/engines/pink/objects/actions/action_loop.cpp b/engines/pink/objects/actions/action_loop.cpp index f32a3a4035..f61ed5d35a 100644 --- a/engines/pink/objects/actions/action_loop.cpp +++ b/engines/pink/objects/actions/action_loop.cpp @@ -33,15 +33,14 @@ void ActionLoop::deserialize(Archive &archive) { _intro = archive.readDWORD(); style = archive.readWORD(); switch (style) { - case kPingPong: - _style = kPingPong; - break; - case kRandom: - _style = kRandom; - break; - default: - _style = kForward; - break; + case kPingPong: + _style = kPingPong; + break; + case kRandom: + _style = kRandom; + break; + default: + _style = kForward; } } @@ -54,7 +53,7 @@ void ActionLoop::toConsole() { void ActionLoop::update() { // for now it supports only forward loop animation if (_style == kForward) { - if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame){ + if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame) { //debug("ACTION LOOP : NEXT ITERATION"); _decoder->rewind(); } diff --git a/engines/pink/objects/actions/action_play.cpp b/engines/pink/objects/actions/action_play.cpp index 6ae56df349..a2b8b0a0a8 100644 --- a/engines/pink/objects/actions/action_play.cpp +++ b/engines/pink/objects/actions/action_play.cpp @@ -54,7 +54,7 @@ void ActionPlay::onStart() { } void ActionPlay::update() { - if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame){ + if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame) { _decoder->stop(); _actor->endAction(); } diff --git a/engines/pink/objects/actions/action_play_with_sfx.cpp b/engines/pink/objects/actions/action_play_with_sfx.cpp index 62488ac302..6ab8fa6b82 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.cpp +++ b/engines/pink/objects/actions/action_play_with_sfx.cpp @@ -66,9 +66,8 @@ void ActionPlayWithSfx::updateSound() { return; for (uint i = 0; i < _sfxArray.size(); ++i) { - if (_sfxArray[i]->getFrame() == _decoder->getCurFrame()) { + if (_sfxArray[i]->getFrame() == _decoder->getCurFrame()) _sfxArray[i]->play(_actor->getPage()); - } } } @@ -107,8 +106,7 @@ uint32 ActionSfx::getFrame() { } ActionSfx::ActionSfx() - : _sound(nullptr) -{} + : _sound(nullptr) {} void ActionSfx::end() { delete _sound; diff --git a/engines/pink/objects/actions/action_play_with_sfx.h b/engines/pink/objects/actions/action_play_with_sfx.h index 89b2ec61ab..c9fd348b6b 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.h +++ b/engines/pink/objects/actions/action_play_with_sfx.h @@ -42,7 +42,7 @@ protected: private: void updateSound(); uint32 _isLoop; - Array _sfxArray; + Array _sfxArray; }; class Sound; diff --git a/engines/pink/objects/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp index 2e69228dd3..ffbd29389e 100644 --- a/engines/pink/objects/actions/action_sound.cpp +++ b/engines/pink/objects/actions/action_sound.cpp @@ -32,8 +32,7 @@ namespace Pink { ActionSound::ActionSound() - : _sound(nullptr) -{} + : _sound(nullptr) {} ActionSound::~ActionSound(){ end(); diff --git a/engines/pink/objects/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp index e6545f3a1f..abcb66502e 100644 --- a/engines/pink/objects/actors/actor.cpp +++ b/engines/pink/objects/actors/actor.cpp @@ -48,9 +48,8 @@ Sequencer *Actor::getSequencer() const { Action *Actor::findAction(const Common::String &name) { for (uint i = 0; i < _actions.size(); ++i) { - if (_actions[i]->getName() == name) { + if (_actions[i]->getName() == name) return _actions[i]; - } } return nullptr; } @@ -60,14 +59,12 @@ GamePage *Actor::getPage() const { } void Actor::init(bool unk) { - if (!_action) { + if (!_action) _action = findAction(kIdleAction); - } if (!_action) { _isActionEnded = 1; - } - else { + } else { _isActionEnded = 0; _action->start(unk); } @@ -103,8 +100,7 @@ void Actor::setAction(Action *newAction, bool unk) { assert(0); // want to see this _isActionEnded = 1; _action = newAction; - } - else { + } else { setAction(newAction); } } diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h index cfbc358d70..b4fe437cf5 100644 --- a/engines/pink/objects/actors/actor.h +++ b/engines/pink/objects/actors/actor.h @@ -41,8 +41,7 @@ class Actor : public NamedObject { public: Actor() : _page(nullptr), _action(nullptr), - _isActionEnded(1) - {}; + _isActionEnded(1) {}; ~Actor(); virtual void deserialize(Archive &archive); @@ -72,7 +71,7 @@ public: 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(); @@ -80,7 +79,7 @@ public: protected: GamePage *_page; Action *_action; - Array _actions; + Array _actions; bool _isActionEnded; }; diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp index f414cd6e30..484871a6e9 100644 --- a/engines/pink/objects/actors/lead_actor.cpp +++ b/engines/pink/objects/actors/lead_actor.cpp @@ -49,9 +49,9 @@ void LeadActor::setNextExecutors(Common::String &nextModule, Common::String &nex } void LeadActor::init(bool unk) { - if (_state == kUnk_Loading){ + if (_state == kUnk_Loading) _state = kReady; - } + _page->getModule()->getInventoryMgr()->setLeadActor(this); _page->getGame()->setLeadActor(this); Actor::init(unk); @@ -70,79 +70,79 @@ LeadActor::State LeadActor::getState() const { 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; + 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; + default: + 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; - } + 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; - 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; + 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){ + if (isHandler && _state != kPlayingVideo) { _state = kInDialog1; _nextState = kReady; } @@ -152,38 +152,39 @@ void LeadActor::start(bool isHandler) { void LeadActor::onMouseMove(Common::Point point) { if (_state != kPDA) updateCursor(point); - else error("pda is not supported"); + 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: + 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; - default: - break; + 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; } } @@ -191,8 +192,8 @@ void LeadActor::onLeftButtonClick(Common::Point point) { InventoryMgr *invMgr = _page->getModule()->getInventoryMgr(); switch (_state) { - case kReady: - case kMoving: { + case kReady: + case kMoving: { Actor *actor = _page->getGame()->getDirector()->getActorByPoint(point); if (this == actor) { @@ -200,48 +201,50 @@ void LeadActor::onLeftButtonClick(Common::Point point) { return; } - _recipient = dynamic_cast(actor); + _recipient = dynamic_cast(actor); if (actor->isClickable() && isInteractingWith(_recipient)) { WalkLocation *location = getWalkDestination(); if (location) { _state = kMoving; _nextState = kInDialog1; _walkMgr->start(location); - } - else if (_state == kReady){ + } else if (_state == kReady) { if (_isHaveItem) sendUseClickMessage(_recipient); - else sendLeftClickMessage(_recipient); + else + sendLeftClickMessage(_recipient); } } break; - } - case kPDA: + } + case kPDA: - break; - case kInventory: - invMgr->onClick(point); - break; - default: - break; + 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); + else + Actor::onMouseOver(point, mgr); } void LeadActor::onWalkEnd() { State oldNextState = _nextState; _state = kReady; _nextState = kUnk_Loading; - if (_recipient && oldNextState == kInDialog1){ + if (_recipient && oldNextState == kInDialog1) { if (_isHaveItem) sendUseClickMessage(_recipient); - else sendLeftClickMessage(_recipient); + else + sendLeftClickMessage(_recipient); } } @@ -267,13 +270,12 @@ void LeadActor::onClick() { _isHaveItem = false; _nextState = (_state != kMoving) ? kUnk_Loading : kReady; - } - else { + } else { if (_state == kMoving) { _recipient = nullptr; _nextState = kReady; } - if (_page->getModule()->getInventoryMgr()->start(1)){ + if (_page->getModule()->getInventoryMgr()->start(1)) { _stateCopy = _state; _state = kInventory; _page->pause(); @@ -282,11 +284,9 @@ void LeadActor::onClick() { } 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; @@ -320,17 +320,14 @@ void ParlSqPink::toConsole() { } WalkLocation *ParlSqPink::getWalkDestination() { - if (_recipient->getName() == kBoy && - _page->checkValueOfVariable(kBoyBlocked, kUndefined)) - { + 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()); @@ -352,13 +349,11 @@ void PubPink::onClick() { void PubPink::updateCursor(Common::Point point) { if (playingMiniGame()) { SupportingActor *actor = dynamic_cast(_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()); + 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); } @@ -367,36 +362,31 @@ WalkLocation *PubPink::getWalkDestination() { if (playingMiniGame()) return nullptr; - if (_recipient->getName() == kJackson && - !_page->checkValueOfVariable(kDrunkLocation, kBolted)) - { + if (_recipient->getName() == kJackson && !_page->checkValueOfVariable(kDrunkLocation, kBolted)) return _walkMgr->findLocation(_page->findActor(kDrunk)->getName()); - } return LeadActor::getWalkDestination(); } bool PubPink::sendUseClickMessage(SupportingActor *actor) { - if (!LeadActor::sendUseClickMessage(actor) && - playingMiniGame()) { + 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; + case 0: + roundName = kFirstRound; + break; + case 1: + roundName = kSecondRound; + break; + case 2: + roundName = kThirdRound; + break; + default: + roundName = nullptr; + assert(0); } _sequencer->authorSequence(_sequencer->findSequence(roundName), 0); } diff --git a/engines/pink/objects/actors/supporting_actor.cpp b/engines/pink/objects/actors/supporting_actor.cpp index 3ba10366ed..9e5eaa6786 100644 --- a/engines/pink/objects/actors/supporting_actor.cpp +++ b/engines/pink/objects/actors/supporting_actor.cpp @@ -48,12 +48,13 @@ void SupportingActor::toConsole() { void SupportingActor::onMouseOver(Common::Point point, CursorMgr *mgr) { if (isLeftClickHandlers()){ - if (!_cursor.empty()){ + if (!_cursor.empty()) mgr->setCursor(_cursor, point); - } - else mgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); + else + mgr->setCursor(kClickableFirstFrameCursor, point, Common::String()); } - else Actor::onMouseOver(point, mgr); + else + Actor::onMouseOver(point, mgr); } bool SupportingActor::isLeftClickHandlers() { @@ -80,13 +81,10 @@ const Common::String &SupportingActor::getLocation() const { 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)) { + if (_handlerMgr.isUseClickHandler(this, itemName)) item += kClickable; - } Actor::onHover(point, item, cursorMgr); } diff --git a/engines/pink/objects/actors/supporting_actor.h b/engines/pink/objects/actors/supporting_actor.h index d47959dfa9..d9b77f7498 100644 --- a/engines/pink/objects/actors/supporting_actor.h +++ b/engines/pink/objects/actors/supporting_actor.h @@ -33,7 +33,6 @@ class InventoryMgr; class SupportingActor : public Actor { public: - virtual ~SupportingActor(); virtual void deserialize(Archive &archive); virtual void toConsole(); diff --git a/engines/pink/objects/handlers/handler.cpp b/engines/pink/objects/handlers/handler.cpp index 2f73553f2a..f27b79a5de 100644 --- a/engines/pink/objects/handlers/handler.cpp +++ b/engines/pink/objects/handlers/handler.cpp @@ -39,9 +39,8 @@ void Handler::deserialize(Archive &archive) { bool Handler::isSuitable(Actor *actor) { for (uint i = 0; i < _conditions.size(); ++i) { - if (!_conditions[i]->evaluate(actor)){ + if (!_conditions[i]->evaluate(actor)) return false; - } } return true; } diff --git a/engines/pink/objects/handlers/handler.h b/engines/pink/objects/handlers/handler.h index 98d26620b5..3d795f8d7c 100644 --- a/engines/pink/objects/handlers/handler.h +++ b/engines/pink/objects/handlers/handler.h @@ -44,8 +44,8 @@ public: protected: void executeSideEffects(Actor *actor); - Array _conditions; - Array _sideEffects; + Array _conditions; + Array _sideEffects; }; class Sequence; diff --git a/engines/pink/objects/handlers/handler_mgr.h b/engines/pink/objects/handlers/handler_mgr.h index dabb329d27..75ba40cff6 100644 --- a/engines/pink/objects/handlers/handler_mgr.h +++ b/engines/pink/objects/handlers/handler_mgr.h @@ -56,9 +56,9 @@ private: HandlerLeftClick *findSuitableHandlerLeftClick(Actor *actor); HandlerUseClick *findSuitableHandlerUseClick(Actor *actor, InventoryItem *item); - Array _leftClickHandlers; - Array _useClickHandlers; - Array _timerHandlers; + Array _leftClickHandlers; + Array _useClickHandlers; + Array _timerHandlers; }; } diff --git a/engines/pink/objects/handlers/handler_timer.cpp b/engines/pink/objects/handlers/handler_timer.cpp index e27d4bb207..8f6e3a222a 100644 --- a/engines/pink/objects/handlers/handler_timer.cpp +++ b/engines/pink/objects/handlers/handler_timer.cpp @@ -34,7 +34,6 @@ namespace Pink { - void HandlerTimerActions::deserialize(Archive &archive) { Handler::deserialize(archive); _actions.deserialize(archive); diff --git a/engines/pink/objects/inventory.cpp b/engines/pink/objects/inventory.cpp index 677b18fb8f..13d0dfdc6f 100644 --- a/engines/pink/objects/inventory.cpp +++ b/engines/pink/objects/inventory.cpp @@ -33,9 +33,7 @@ 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); @@ -129,14 +127,13 @@ bool InventoryMgr::start(bool playOpening) { } void InventoryMgr::update() { - if (_state == kOpening && !_window->isPlaying()){ + 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()){ + } else if (_state == kClosing && !_window->isPlaying()) { _window->setAction(kIdleAction); _lead->onInventoryClosed(_isClickedOnItem); @@ -157,14 +154,12 @@ void InventoryMgr::onClick(Common::Point point) { if (actor == _itemActor || actor == _window) { _isClickedOnItem = true; close(); - } - else if (actor == _leftArrow) { + } else if (actor == _leftArrow) { showNextItem(kLeft); - } - else if (actor == _rightArrow) { + } else if (actor == _rightArrow) { showNextItem(kRight); - } - else close(); + } else + close(); } void InventoryMgr::close() { @@ -188,7 +183,7 @@ void InventoryMgr::showNextItem(bool direction) { uint i = 0; do { index = (direction == kLeft) ? index - 1 : index + 1; - } while(_items[index % _items.size()]->getCurrentOwner() != _item->getCurrentOwner() && ++i < _items.size()); + } while (_items[index % _items.size()]->getCurrentOwner() != _item->getCurrentOwner() && ++i < _items.size()); if (i != _items.size()) { _item = _items[index % _items.size()]; diff --git a/engines/pink/objects/inventory.h b/engines/pink/objects/inventory.h index a6f67c6f87..f09e1e8161 100644 --- a/engines/pink/objects/inventory.h +++ b/engines/pink/objects/inventory.h @@ -84,7 +84,7 @@ private: Actor *_leftArrow; InventoryItem *_item; - Array _items; + Array _items; enum State { kIdle = 0, diff --git a/engines/pink/objects/module.cpp b/engines/pink/objects/module.cpp index 5a7dd6bbc9..cdb374612a 100644 --- a/engines/pink/objects/module.cpp +++ b/engines/pink/objects/module.cpp @@ -27,14 +27,12 @@ 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) { diff --git a/engines/pink/objects/module.h b/engines/pink/objects/module.h index 5c253ebcbe..a0735bfac7 100644 --- a/engines/pink/objects/module.h +++ b/engines/pink/objects/module.h @@ -65,7 +65,7 @@ private: PinkEngine *_game; GamePage *_page; - Array _pages; + Array _pages; InventoryMgr _invMgr; Common::StringMap _variables; }; diff --git a/engines/pink/objects/object.cpp b/engines/pink/objects/object.cpp index 4d9041f891..02249a3020 100644 --- a/engines/pink/objects/object.cpp +++ b/engines/pink/objects/object.cpp @@ -27,8 +27,7 @@ namespace Pink { Pink::NamedObject::NamedObject(const Common::String &name) - : _name(name) -{} + : _name(name) {} void Pink::NamedObject::deserialize(Archive &archive) { _name = archive.readString(); @@ -38,8 +37,6 @@ const Common::String &Pink::NamedObject::getName() const { return _name; } -void NamedObject::store(Archive &archive) { - -} +void NamedObject::store(Archive &archive) {} } // End of namespace Pink diff --git a/engines/pink/objects/object.h b/engines/pink/objects/object.h index 62ca9f758a..e69fa4b406 100644 --- a/engines/pink/objects/object.h +++ b/engines/pink/objects/object.h @@ -32,16 +32,16 @@ class Archive; class Object { public: virtual ~Object() {}; - virtual void load(Archive &){}; - virtual void store(Archive &){}; - virtual void deserialize(Archive &){}; + 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() {}; NamedObject(const Common::String &name); void deserialize(Archive &archive); diff --git a/engines/pink/objects/pages/game_page.cpp b/engines/pink/objects/pages/game_page.cpp index 83df359b80..8e534443d5 100644 --- a/engines/pink/objects/pages/game_page.cpp +++ b/engines/pink/objects/pages/game_page.cpp @@ -32,8 +32,7 @@ namespace Pink { GamePage::GamePage() : _cursorMgr(nullptr), _walkMgr(nullptr), _sequencer(nullptr), - _isLoaded(false), _memFile(nullptr) -{} + _isLoaded(false), _memFile(nullptr) {} GamePage::~GamePage() { clear(); @@ -87,16 +86,15 @@ void GamePage::init(bool isLoadingSave) { } bool isHandler = false; - if (!isLoadingSave) { + if (!isLoadingSave) isHandler = initHandler(); - } _leadActor->start(isHandler); } bool GamePage::initHandler() { for (uint i = 0; i < _handlers.size(); ++i) { - if (_handlers[i]->isSuitable(_leadActor)){ + if (_handlers[i]->isSuitable(_leadActor)) { _handlers[i]->handle(_leadActor); return true; } diff --git a/engines/pink/objects/pages/game_page.h b/engines/pink/objects/pages/game_page.h index 1bae58d768..1c7e5cf217 100644 --- a/engines/pink/objects/pages/game_page.h +++ b/engines/pink/objects/pages/game_page.h @@ -67,7 +67,7 @@ private: CursorMgr *_cursorMgr; WalkMgr *_walkMgr; Sequencer *_sequencer; - Array _handlers; + Array _handlers; Common::StringMap _variables; }; diff --git a/engines/pink/objects/pages/page.h b/engines/pink/objects/pages/page.h index 3b5708f530..f8b582a52f 100644 --- a/engines/pink/objects/pages/page.h +++ b/engines/pink/objects/pages/page.h @@ -51,7 +51,7 @@ public: protected: void init(); - Array _actors; + Array _actors; ResourceMgr _resMgr; LeadActor *_leadActor; }; diff --git a/engines/pink/objects/sequences/seq_timer.cpp b/engines/pink/objects/sequences/seq_timer.cpp index 9f8ee31a4c..5026051b33 100644 --- a/engines/pink/objects/sequences/seq_timer.cpp +++ b/engines/pink/objects/sequences/seq_timer.cpp @@ -53,7 +53,7 @@ void SeqTimer::update() { _updatesToMessage = _range ? _period + rnd.getRandomNumber(_range) : _period; SupportingActor *actor = static_cast(_sequencer->_page->findActor(_actor)); - if (actor && !_sequencer->findSequenceActorState(actor->getName())){ + if (actor && !_sequencer->findSequenceActorState(actor->getName())) { actor->onTimerMessage(); } } diff --git a/engines/pink/objects/sequences/sequence.cpp b/engines/pink/objects/sequences/sequence.cpp index f388b7cd66..8e2f38c549 100644 --- a/engines/pink/objects/sequences/sequence.cpp +++ b/engines/pink/objects/sequences/sequence.cpp @@ -34,8 +34,8 @@ 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) { @@ -72,7 +72,8 @@ void Sequence::init(int unk) { } void Sequence::start(int unk) { - if (_context->_nextItemIndex >= _items.size() || !_items[_context->_nextItemIndex]->execute(_context->_index, this, unk)){ + if (_context->_nextItemIndex >= _items.size() || + !_items[_context->_nextItemIndex]->execute(_context->_index, this, unk)) { debug("Sequence %s ended", _name.c_str()); end(); return; @@ -95,7 +96,7 @@ void Sequence::start(int unk) { } void Sequence::update() { - if (!_context->_actor->isPlaying()){ + if (!_context->_actor->isPlaying()) { debug("Sequence step ended"); start(0); } @@ -114,9 +115,9 @@ void Sequence::restart() { } void Sequence::skipToLastSubSequence() { - if (_unk && _context->getNextItemIndex() < _items.size()){ + if (_unk && _context->getNextItemIndex() < _items.size()) { int i = _items.size() - 1; - while(i >= 0 && !_items[--i]->isLeader()); + while (i >= 0 && !_items[--i]->isLeader()) {}; assert(i >= 0); _context->setNextItemIndex(i); _context->clearActionsFromActorStates(); @@ -126,7 +127,7 @@ void Sequence::skipToLastSubSequence() { } void Sequence::skipItemsTo(int index) { - for(int i = 0; i < index; ++i){ + for (int i = 0; i < index; ++i) { _items[i]->skip(this); } } @@ -167,9 +168,8 @@ void SequenceAudio::end() { void SequenceAudio::update() { if (!_sound->isPlaying()) end(); - else if (_sample <= _sound->getCurrentSample()){ + else if (_sample <= _sound->getCurrentSample()) start(0); - } } void SequenceAudio::init(int unk) { diff --git a/engines/pink/objects/sequences/sequence.h b/engines/pink/objects/sequences/sequence.h index f4c6c5a1b3..34863256f2 100644 --- a/engines/pink/objects/sequences/sequence.h +++ b/engines/pink/objects/sequences/sequence.h @@ -39,7 +39,7 @@ public: virtual void toConsole(); - Common::Array &getItems(); + Common::Array &getItems(); void setContext(SequenceContext *context); virtual void init(int unk); @@ -56,7 +56,7 @@ public: public: SequenceContext *_context; Sequencer *_sequencer; - Array _items; + Array _items; int _unk; }; diff --git a/engines/pink/objects/sequences/sequence_context.cpp b/engines/pink/objects/sequences/sequence_context.cpp index 65911ec832..200fcb416a 100644 --- a/engines/pink/objects/sequences/sequence_context.cpp +++ b/engines/pink/objects/sequences/sequence_context.cpp @@ -32,8 +32,7 @@ namespace Pink { SequenceActorState::SequenceActorState(const Common::String &name) - :_actorName(name), _index(0) -{} + :_actorName(name), _index(0) {} const Common::String &SequenceActorState::getActor() const { return _actorName; @@ -42,7 +41,7 @@ const Common::String &SequenceActorState::getActor() const { 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()){ + if (_index != index && !_actionName.empty()) { Action *action = actor->findAction(_actionName); if (actor->getAction() != action) actor->setAction(action, unk); @@ -60,7 +59,7 @@ SequenceContext::SequenceContext(Sequence *sequence, Sequencer *sequencer) 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()){ + if (items[i]->getActor() == _states[j].getActor()) { found = 1; break; } diff --git a/engines/pink/objects/sequences/sequence_item.cpp b/engines/pink/objects/sequences/sequence_item.cpp index 7cc3f1b153..2d048b0b08 100644 --- a/engines/pink/objects/sequences/sequence_item.cpp +++ b/engines/pink/objects/sequences/sequence_item.cpp @@ -54,9 +54,8 @@ bool SequenceItem::execute(int index, Sequence *sequence, bool unk2) { Actor *actor; Action *action; if (!(actor = sequence->_sequencer->_page->findActor(_actor)) || - !(action = actor->findAction(_action))) { + !(action = actor->findAction(_action))) return false; - } actor->setAction(action, unk2); diff --git a/engines/pink/objects/sequences/sequencer.cpp b/engines/pink/objects/sequences/sequencer.cpp index 430c8c2da0..37947d6e4b 100644 --- a/engines/pink/objects/sequences/sequencer.cpp +++ b/engines/pink/objects/sequences/sequencer.cpp @@ -34,8 +34,7 @@ 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) { @@ -57,17 +56,17 @@ Sequence *Sequencer::findSequence(const Common::String &name) { } void Sequencer::authorSequence(Sequence *sequence, bool unk) { - if (_context){ + if (_context) { } - if (sequence){ + if (sequence) { _context = new SequenceContext(sequence, this); //unload array of unknown objects _currentSequenceName = sequence->getName(); sequence->init(unk); - } - else _currentSequenceName.clear(); + } else + _currentSequenceName.clear(); } void Sequencer::toConsole() { diff --git a/engines/pink/objects/sequences/sequencer.h b/engines/pink/objects/sequences/sequencer.h index c1b957b995..5f4bebde9c 100644 --- a/engines/pink/objects/sequences/sequencer.h +++ b/engines/pink/objects/sequences/sequencer.h @@ -41,7 +41,7 @@ public: virtual void toConsole(); virtual void deserialize(Archive &archive); - Sequence* findSequence(const Common::String &name); + Sequence *findSequence(const Common::String &name); SequenceActorState *findSequenceActorState(const Common::String &name); void authorSequence(Sequence *sequence, bool unk); @@ -60,8 +60,8 @@ public: SequenceContext *_context; // context array - Array _sequences; - Array _timers; + Array _sequences; + Array _timers; Common::String _currentSequenceName; GamePage *_page; uint _time; diff --git a/engines/pink/objects/side_effect.h b/engines/pink/objects/side_effect.h index c917615b93..71146a7c72 100644 --- a/engines/pink/objects/side_effect.h +++ b/engines/pink/objects/side_effect.h @@ -97,8 +97,7 @@ public: virtual void execute(Actor *actor); }; -class SideEffectRandomPageVariable : public SideEffect -{ +class SideEffectRandomPageVariable : public SideEffect { public: virtual void deserialize(Archive &archive); virtual void toConsole(); diff --git a/engines/pink/objects/walk/walk_mgr.cpp b/engines/pink/objects/walk/walk_mgr.cpp index c9c28f0ffc..5b57107a44 100644 --- a/engines/pink/objects/walk/walk_mgr.cpp +++ b/engines/pink/objects/walk/walk_mgr.cpp @@ -30,10 +30,7 @@ namespace Pink { WalkMgr::WalkMgr() - : _isWalking(false), _leadActor(nullptr) -{ - -} + : _isWalking(false), _leadActor(nullptr) {} void WalkMgr::deserialize(Pink::Archive &archive) { _leadActor = static_cast(archive.readObject()); @@ -42,9 +39,8 @@ void WalkMgr::deserialize(Pink::Archive &archive) { WalkLocation *WalkMgr::findLocation(const Common::String &name) { for (uint i = 0; i < _locations.size(); ++i) { - if (_locations[i]->getName() == name) { + if (_locations[i]->getName() == name) return _locations[i]; - } } return nullptr; } @@ -69,8 +65,7 @@ void WalkMgr::start(WalkLocation *destination) { if (_current.name == _destination->getName()) { end(); - } - else { + } else { _isWalking = true; WalkLocation *currentLocation = findLocation(_current.name); WalkShortestPath path(this); @@ -87,17 +82,16 @@ void WalkMgr::initNextWayPoint(WalkLocation *location) { WalkAction *WalkMgr::getWalkAction() { Common::String walkActionName; - if (_current.coord.z == _next.coord.z){ - if (_next.coord.x > _current.coord.x){ + 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); + } 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); - return static_cast(action); } @@ -136,11 +130,11 @@ void WalkMgr::update() { WalkShortestPath path(this); _current = _next; WalkLocation *next = path.next(findLocation(_current.name), _destination); - if (next){ + if (next) { initNextWayPoint(next); _leadActor->setAction(getWalkAction(), 0); - } - else end(); + } else + end(); } diff --git a/engines/pink/objects/walk/walk_mgr.h b/engines/pink/objects/walk/walk_mgr.h index 64bd16e48b..9060f08a20 100644 --- a/engines/pink/objects/walk/walk_mgr.h +++ b/engines/pink/objects/walk/walk_mgr.h @@ -63,7 +63,7 @@ private: LeadActor *_leadActor; WalkLocation *_destination; - Array _locations; + Array _locations; WayPoint _current; WayPoint _next; bool _isWalking; diff --git a/engines/pink/objects/walk/walk_shortest_path.cpp b/engines/pink/objects/walk/walk_shortest_path.cpp index 376e638d91..4f16f54328 100644 --- a/engines/pink/objects/walk/walk_shortest_path.cpp +++ b/engines/pink/objects/walk/walk_shortest_path.cpp @@ -34,7 +34,7 @@ WalkLocation *WalkShortestPath::next(WalkLocation *start, WalkLocation *destinat if (start == destination) return nullptr; add(start, 0.0, 0); - while (build() != destination); + while (build() != destination) {} return getNearestNeighbor(destination); } @@ -94,13 +94,13 @@ double WalkShortestPath::getLengthToNearestNeigbor(WalkLocation *location) { Common::StringArray &neighbors = location->getNeigbors(); for (uint i = 0; i < neighbors.size(); ++i) { WalkLocation *neighbor = _manager->findLocation(neighbors[i]); - if (!isLocationVisited(neighbor)){ + if (!isLocationVisited(neighbor)) { double length = _manager->getLengthBetweenLocations(location, neighbor); if (minLength >= 0.0) { if (length < minLength) minLength = length; - } - else minLength = length; + } else + minLength = length; } } @@ -113,15 +113,14 @@ WalkLocation *WalkShortestPath::findNearestNeighbor(WalkLocation *location) { Common::StringArray &neighbors = location->getNeigbors(); for (uint i = 0; i < neighbors.size(); ++i) { WalkLocation *neighbor = _manager->findLocation(neighbors[i]); - if (!isLocationVisited(neighbor)){ + if (!isLocationVisited(neighbor)) { double length = _manager->getLengthBetweenLocations(location, neighbor); if (minLength >= 0.0) { if (length < minLength) { nearest = neighbor; minLength = length; } - } - else { + } else { nearest = neighbor; minLength = length; } @@ -149,7 +148,7 @@ bool WalkShortestPath::isLocationVisited(WalkLocation *location) { void WalkShortestPath::remove(WalkLocation *location) { for (uint i = 0; i < _locations.size(); ++i) { - if (_locations[i] == location){ + if (_locations[i] == location) { _locations.remove_at(i); _weight.remove_at(i); break; diff --git a/engines/pink/objects/walk/walk_shortest_path.h b/engines/pink/objects/walk/walk_shortest_path.h index a3ec85df1d..441b6e6a88 100644 --- a/engines/pink/objects/walk/walk_shortest_path.h +++ b/engines/pink/objects/walk/walk_shortest_path.h @@ -48,11 +48,11 @@ private: WalkMgr *_manager; - Common::Array _locations; - Common::Array _toVisit; + Common::Array _locations; + Common::Array _toVisit; Common::Array _weight; - Common::Array _visited; - Common::Array _nearestNeigbor; + Common::Array _visited; + Common::Array _nearestNeigbor; }; } // End of namespace Pink diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp index 74b38cf6e2..0e5952bbd4 100644 --- a/engines/pink/pink.cpp +++ b/engines/pink/pink.cpp @@ -38,8 +38,8 @@ namespace Pink { Pink::PinkEngine::PinkEngine(OSystem *system, const ADGameDescription *desc) : Engine(system), _console(nullptr), _rnd("pink"), - _desc(*desc), _bro(nullptr), _module(nullptr), _director(_system) -{ + _desc(*desc), _bro(nullptr), _module(nullptr), + _director(_system) { debug("PinkEngine constructed"); DebugMan.addDebugChannel(kPinkDebugGeneral, "general", "General issues"); @@ -72,14 +72,13 @@ Common::Error PinkEngine::init() { const Common::String orbName = _desc.filesDescriptions[0].fileName; const Common::String broName = _desc.filesDescriptions[1].fileName; - if (strcmp(_desc.gameId, kPeril) == 0){ + if (strcmp(_desc.gameId, kPeril) == 0) _bro = new BroFile(); - } - else debug("This game doesn't need to use bro"); + else + debug("This game doesn't need to use bro"); - if (!_orb.open(orbName) || (_bro && !_bro->open(broName, _orb.getTimestamp()))){ + if (!_orb.open(orbName) || (_bro && !_bro->open(broName, _orb.getTimestamp()))) return Common::kNoGameDataFoundError; - } if (!loadCursors()) return Common::kNoGameDataFoundError; @@ -99,34 +98,33 @@ Common::Error Pink::PinkEngine::run() { if (error.getCode() != Common::kNoError) return error; - while(!shouldQuit()){ + while (!shouldQuit()) { Common::Event event; - while(_eventMan->pollEvent(event)){ - switch (event.type){ - case Common::EVENT_QUIT: - case Common::EVENT_RTL: - return Common::kNoError; - case Common::EVENT_MOUSEMOVE: - _actor->onMouseMove(event.mouse); - break; - case Common::EVENT_LBUTTONDOWN: - _actor->onLeftButtonClick(event.mouse); - break; - case Common::EVENT_KEYDOWN: - if (event.kbd.keycode == Common::KEYCODE_d) - _director.showBounds = !_director.showBounds; - else _actor->onKeyboardButtonClick(event.kbd.keycode); - break; - - // don't know why it is used in original - case Common::EVENT_LBUTTONUP: - case Common::EVENT_RBUTTONDOWN: - default: - break; + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_QUIT: + case Common::EVENT_RTL: + return Common::kNoError; + case Common::EVENT_MOUSEMOVE: + _actor->onMouseMove(event.mouse); + break; + case Common::EVENT_LBUTTONDOWN: + _actor->onLeftButtonClick(event.mouse); + break; + case Common::EVENT_KEYDOWN: + if (event.kbd.keycode == Common::KEYCODE_d) + _director.showBounds = !_director.showBounds; + else + _actor->onKeyboardButtonClick(event.kbd.keycode); + break; + // don't know why it is used in original + case Common::EVENT_LBUTTONUP: + case Common::EVENT_RBUTTONDOWN: + default: + break; } } - _actor->update(); _director.update(); _director.draw(); @@ -145,7 +143,7 @@ void PinkEngine::load(Archive &archive) { void PinkEngine::initModule(const Common::String &moduleName, bool isLoadingFromSave, const Common::String &pageName) { if (_module) { for (uint i = 0; i < _modules.size(); ++i) { - if (_module == _modules[i]){ + if (_module == _modules[i]) { _modules[i] = new ModuleProxy(_module->getName()); delete _module; @@ -170,12 +168,10 @@ void PinkEngine::changeScene(GamePage *page) { setCursor(kLoadingCursor); if (!_nextModule.empty() && _nextModule.compareTo(_module->getName())) { initModule(_nextModule, kLoadingNewGame, _nextPage); - } - else { + } else { assert(!_nextPage.empty()); _module->changePage(_nextPage); } - } void PinkEngine::setNextExecutors(const Common::String &nextModule, const Common::String &nextPage) { @@ -222,8 +218,7 @@ bool PinkEngine::loadCursors() { _cursors.push_back(Graphics::WinCursorGroup::createCursorGroup(exeResources, kPokusClickableThirdCursorID)); _cursors.push_back(Graphics::WinCursorGroup::createCursorGroup(exeResources, kPokusNotClickableCursorID)); _cursors.push_back(Graphics::WinCursorGroup::createCursorGroup(exeResources, kPokusHoldingItemCursorID)); - } - else { + } else { _cursors.push_back(Graphics::WinCursorGroup::createCursorGroup(exeResources, kPerilClickableThirdCursorID)); _cursors.push_back(Graphics::WinCursorGroup::createCursorGroup(exeResources, kPerilNotClickableCursorID)); _cursors.push_back(Graphics::WinCursorGroup::createCursorGroup(exeResources, kPerilHoldingItemCursorID)); diff --git a/engines/pink/pink.h b/engines/pink/pink.h index 98d962e34a..0faf4d5e66 100644 --- a/engines/pink/pink.h +++ b/engines/pink/pink.h @@ -111,7 +111,7 @@ private: Console *_console; Common::RandomSource _rnd; - Common::Array _cursors; + Common::Array _cursors; Common::String _nextModule; Common::String _nextPage; @@ -123,7 +123,7 @@ private: LeadActor *_actor; Module *_module; - Array _modules; + Array _modules; Common::StringMap _variables; diff --git a/engines/pink/resource_mgr.cpp b/engines/pink/resource_mgr.cpp index fbba3828db..810f412553 100644 --- a/engines/pink/resource_mgr.cpp +++ b/engines/pink/resource_mgr.cpp @@ -32,8 +32,7 @@ namespace Pink { ResourceMgr::ResourceMgr() - : _game(nullptr), _resDescTable(nullptr), - _resCount(0) {} + : _game(nullptr), _resDescTable(nullptr), _resCount(0) {} ResourceMgr::~ResourceMgr() { clear(); @@ -64,7 +63,8 @@ Common::SafeSeekableSubReadStream *ResourceMgr::getResourceStream(Common::String if (desc.inBro) stream = _game->getBro(); - else stream = _game->getOrb(); + else + stream = _game->getOrb(); stream->seek(desc.offset); diff --git a/engines/pink/sound.cpp b/engines/pink/sound.cpp index db6ff8c442..10fb049727 100644 --- a/engines/pink/sound.cpp +++ b/engines/pink/sound.cpp @@ -31,10 +31,7 @@ namespace Pink { Sound::Sound(Audio::Mixer *mixer, Common::SafeSeekableSubReadStream *stream) - : _mixer(mixer), _fileStream(stream) -{ - -} + : _mixer(mixer), _fileStream(stream) {} Sound::~Sound() { stop(); @@ -67,8 +64,8 @@ void Sound::play(Audio::Mixer::SoundType type, int volume, bool isLoop) { Audio::SeekableAudioStream *wavStream = Audio::makeWAVStream(_fileStream, DisposeAfterUse::NO); if (isLoop) { audioStream = Audio::makeLoopingAudioStream(wavStream, 0, 0, 0); - } - else audioStream = wavStream; + } else + audioStream = wavStream; _mixer->playStream(type, &_handle , audioStream, -1 , 50, 0, DisposeAfterUse::YES); } -- cgit v1.2.3