diff options
Diffstat (limited to 'engines/pink/objects')
38 files changed, 247 insertions, 296 deletions
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<ActionSfx*> _sfxArray; + Array<ActionSfx *> _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<Action*> _actions; + Array<Action *> _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<SupportingActor*>(actor); + _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){ + } 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<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()); + 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<Condition*> _conditions; - Array<SideEffect*> _sideEffects; + Array<Condition *> _conditions; + Array<SideEffect *> _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<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 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<InventoryItem*> _items; + Array<InventoryItem *> _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<GamePage*> _pages; + Array<GamePage *> _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<HandlerStartPage*> _handlers; + Array<HandlerStartPage *> _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<Actor*> _actors; + Array<Actor *> _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<SupportingActor*>(_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<SequenceItem*> &getItems(); + Common::Array<SequenceItem *> &getItems(); void setContext(SequenceContext *context); virtual void init(int unk); @@ -56,7 +56,7 @@ public: public: SequenceContext *_context; Sequencer *_sequencer; - Array<SequenceItem*> _items; + Array<SequenceItem *> _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<Sequence*> _sequences; - Array<SeqTimer*> _timers; + Array<Sequence *> _sequences; + Array<SeqTimer *> _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<LeadActor *>(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<WalkAction*>(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<WalkLocation*> _locations; + Array<WalkLocation *> _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<WalkLocation*> _locations; - Common::Array<WalkLocation*> _toVisit; + Common::Array<WalkLocation *> _locations; + Common::Array<WalkLocation *> _toVisit; Common::Array<double> _weight; - Common::Array<WalkLocation*> _visited; - Common::Array<WalkLocation*> _nearestNeigbor; + Common::Array<WalkLocation *> _visited; + Common::Array<WalkLocation *> _nearestNeigbor; }; } // End of namespace Pink |