aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2017-01-03 16:26:39 -0500
committerPaul Gilbert2017-01-03 16:26:39 -0500
commit759f69fe1ef445feddb28a1410c4e0821ae7ac40 (patch)
treee9608e5e855cd7e1005f8279a0cba72b4d3f1140 /engines
parentd490e11d4c90ed530eedb56e941683c1a7008987 (diff)
downloadscummvm-rg350-759f69fe1ef445feddb28a1410c4e0821ae7ac40.tar.gz
scummvm-rg350-759f69fe1ef445feddb28a1410c4e0821ae7ac40.tar.bz2
scummvm-rg350-759f69fe1ef445feddb28a1410c4e0821ae7ac40.zip
TITANIC: Fixes and cleanup for the hammer dispensor
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/game/hammer_dispensor.cpp30
-rw-r--r--engines/titanic/game/hammer_dispensor.h4
-rw-r--r--engines/titanic/game/hammer_dispensor_button.cpp67
-rw-r--r--engines/titanic/game/hammer_dispensor_button.h11
4 files changed, 53 insertions, 59 deletions
diff --git a/engines/titanic/game/hammer_dispensor.cpp b/engines/titanic/game/hammer_dispensor.cpp
index bc6a3d5ad8..2450868b14 100644
--- a/engines/titanic/game/hammer_dispensor.cpp
+++ b/engines/titanic/game/hammer_dispensor.cpp
@@ -32,13 +32,13 @@ BEGIN_MESSAGE_MAP(CHammerDispensor, CBackground)
END_MESSAGE_MAP()
CHammerDispensor::CHammerDispensor() : CBackground(),
- _fieldE0(false), _fieldE4(true), _state(0) {
+ _isOpen(false), _panUp(true), _state(0) {
}
void CHammerDispensor::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_fieldE0, indent);
- file->writeNumberLine(_fieldE4, indent);
+ file->writeNumberLine(_isOpen, indent);
+ file->writeNumberLine(_panUp, indent);
file->writeNumberLine(_state, indent);
CBackground::save(file, indent);
@@ -46,44 +46,44 @@ void CHammerDispensor::save(SimpleFile *file, int indent) {
void CHammerDispensor::load(SimpleFile *file) {
file->readNumber();
- _fieldE0 = file->readNumber();
- _fieldE4 = file->readNumber();
+ _isOpen = file->readNumber();
+ _panUp = file->readNumber();
_state = file->readNumber();
CBackground::load(file);
}
bool CHammerDispensor::ActMsg(CActMsg *msg) {
- if (msg->_action == "DispenseHammer" && !_fieldE0) {
+ if (msg->_action == "DispenseHammer" && !_isOpen) {
_state = 1;
playMovie(15, 31, MOVIE_NOTIFY_OBJECT);
- _fieldE0 = true;
+ _isOpen = true;
}
- if (msg->_action == "HammerTaken" && _fieldE0)
+ if (msg->_action == "HammerTaken" && _isOpen)
loadFrame(32);
return true;
}
bool CHammerDispensor::EnterViewMsg(CEnterViewMsg *msg) {
- if (_fieldE4) {
+ if (_panUp) {
playMovie(7, 14, 0);
- _fieldE4 = false;
+ _panUp = false;
}
return true;
}
bool CHammerDispensor::LeaveViewMsg(CLeaveViewMsg *msg) {
- _fieldE4 = true;
- _fieldE0 = 0;
- _state = 2;
-
- if (_fieldE0)
+ if (_isOpen)
playMovie(32, 50, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
else
playMovie(0, 7, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+
+ _panUp = true;
+ _isOpen = false;
+ _state = 2;
return true;
}
diff --git a/engines/titanic/game/hammer_dispensor.h b/engines/titanic/game/hammer_dispensor.h
index 2383a3349e..f93f4141ab 100644
--- a/engines/titanic/game/hammer_dispensor.h
+++ b/engines/titanic/game/hammer_dispensor.h
@@ -34,8 +34,8 @@ class CHammerDispensor : public CBackground {
bool LeaveViewMsg(CLeaveViewMsg *msg);
bool MovieEndMsg(CMovieEndMsg *msg);
private:
- bool _fieldE0;
- bool _fieldE4;
+ bool _isOpen;
+ bool _panUp;
int _state;
public:
CLASSDEF;
diff --git a/engines/titanic/game/hammer_dispensor_button.cpp b/engines/titanic/game/hammer_dispensor_button.cpp
index 89d37a0476..661a92eb17 100644
--- a/engines/titanic/game/hammer_dispensor_button.cpp
+++ b/engines/titanic/game/hammer_dispensor_button.cpp
@@ -34,36 +34,36 @@ BEGIN_MESSAGE_MAP(CHammerDispensorButton, CStartAction)
END_MESSAGE_MAP()
CHammerDispensorButton::CHammerDispensorButton() : CStartAction(),
- _fieldF8(0), _fieldFC(0), _field100(0), _btnPos(Point(56, 6)),
- _field10C(nullptr), _field110(0) {
+ _active(false), _open(false), _hitCounter(0), _btnPos(Point(56, 6)),
+ _perch(nullptr), _hammerTaken(0) {
}
void CHammerDispensorButton::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_fieldF8, indent);
- file->writeNumberLine(_fieldFC, indent);
- file->writeNumberLine(_field100, indent);
+ file->writeNumberLine(_active, indent);
+ file->writeNumberLine(_open, indent);
+ file->writeNumberLine(_hitCounter, indent);
file->writeNumberLine(_btnPos.x, indent);
file->writeNumberLine(_btnPos.y, indent);
- file->writeNumberLine(_field110, indent);
+ file->writeNumberLine(_hammerTaken, indent);
CStartAction::save(file, indent);
}
void CHammerDispensorButton::load(SimpleFile *file) {
file->readNumber();
- _fieldF8 = file->readNumber();
- _fieldFC = file->readNumber();
- _field100 = file->readNumber();
+ _active = file->readNumber();
+ _open = file->readNumber();
+ _hitCounter = file->readNumber();
_btnPos.x = file->readNumber();
_btnPos.y = file->readNumber();
- _field110 = file->readNumber();
+ _hammerTaken = file->readNumber();
CStartAction::load(file);
}
bool CHammerDispensorButton::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) {
- _fieldF8 = 1;
+ _active = true;
return true;
}
@@ -75,54 +75,47 @@ bool CHammerDispensorButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
bool CHammerDispensorButton::ActMsg(CActMsg *msg) {
if (msg->_action == "HammerTaken")
- _field110 = true;
+ _hammerTaken = true;
return true;
}
bool CHammerDispensorButton::FrameMsg(CFrameMsg *msg) {
- if (!_fieldF8)
+ if (!_active)
return true;
- if (!_field10C) {
+ if (!_perch) {
CGameObject *obj = getDraggingObject();
if (obj) {
if (obj->isEquals("Perch") && getView() == findView())
- _field10C = obj;
+ _perch = static_cast<CPerch *>(obj);
}
}
- if (_field10C) {
- Point pt(_btnPos.x + _bounds.left, _btnPos.y + _bounds.top);
+ if (_perch) {
+ Point pt(_btnPos.x + _perch->_bounds.left, _btnPos.y + _perch->_bounds.top);
bool flag = checkPoint(pt, true);
- switch (_fieldFC) {
- case 0:
+ if (!_open) {
if (flag) {
playSound("z#93.wav");
- if (++_field100 == 5) {
- if (!_field110) {
+ if (++_hitCounter == 5) {
+ if (!_hammerTaken) {
CActMsg actMsg(_msgAction);
actMsg.execute(_msgTarget);
}
setVisible(false);
- _fieldF8 = 0;
- _field100 = 0;
+ _active = false;
+ _hitCounter = 0;
}
- _fieldFC = 1;
+ _open = true;
}
- break;
-
- case 1:
+ } else {
if (!flag) {
- _fieldFC = 0;
- ++_field100;
+ _open = false;
+ ++_hitCounter;
}
- break;
-
- default:
- break;
}
}
@@ -130,15 +123,15 @@ bool CHammerDispensorButton::FrameMsg(CFrameMsg *msg) {
}
bool CHammerDispensorButton::LeaveViewMsg(CLeaveViewMsg *msg) {
- _field10C = nullptr;
- _field100 = 0;
- _fieldFC = 0;
+ _perch = nullptr;
+ _hitCounter = 0;
+ _open = false;
return true;
}
bool CHammerDispensorButton::EnterViewMsg(CEnterViewMsg *msg) {
setVisible(true);
- _fieldF8 = 1;
+ _active = true;
return true;
}
diff --git a/engines/titanic/game/hammer_dispensor_button.h b/engines/titanic/game/hammer_dispensor_button.h
index f497b9dae1..0194021943 100644
--- a/engines/titanic/game/hammer_dispensor_button.h
+++ b/engines/titanic/game/hammer_dispensor_button.h
@@ -24,6 +24,7 @@
#define TITANIC_HAMMER_DISPENSOR_BUTTON_H
#include "titanic/game/start_action.h"
+#include "titanic/carry/perch.h"
namespace Titanic {
@@ -36,12 +37,12 @@ class CHammerDispensorButton : public CStartAction {
bool LeaveViewMsg(CLeaveViewMsg *msg);
bool EnterViewMsg(CEnterViewMsg *msg);
private:
- int _fieldF8;
- int _fieldFC;
- int _field100;
+ bool _active;
+ bool _open;
+ int _hitCounter;
Point _btnPos;
- CGameObject *_field10C;
- int _field110;
+ CPerch *_perch;
+ bool _hammerTaken;
public:
CLASSDEF;
CHammerDispensorButton();