aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-02-14 14:45:08 +0200
committerFilippos Karapetis2015-02-14 15:08:28 +0200
commit14914b2a31399ceb6b2e4d7616535e346ee3acd6 (patch)
tree5b2640d61a292c8e47c2e443367cee849138dfd2
parent2d2cfbe005b93397f1e121888b0358e137ccc863 (diff)
downloadscummvm-rg350-14914b2a31399ceb6b2e4d7616535e346ee3acd6.tar.gz
scummvm-rg350-14914b2a31399ceb6b2e4d7616535e346ee3acd6.tar.bz2
scummvm-rg350-14914b2a31399ceb6b2e4d7616535e346ee3acd6.zip
ZVISION: Add custom equality operators for game location
This makes the location checks more readable
-rw-r--r--engines/zvision/core/events.cpp2
-rw-r--r--engines/zvision/scripting/effects/music_effect.cpp3
-rw-r--r--engines/zvision/scripting/script_manager.cpp7
-rw-r--r--engines/zvision/scripting/script_manager.h22
4 files changed, 27 insertions, 7 deletions
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 9cf5d04a7a..cc1c00b6d0 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -152,7 +152,7 @@ void ZVision::cheatCodes(uint8 key) {
if (checkCode("HELLOSAILOR")) {
Audio::AudioStream *soundStream;
- if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') {
+ if (loc == "vb10") {
soundStream = makeRawZorkStream("v000hpta.raw", this);
} else {
soundStream = makeRawZorkStream("v000hnta.raw", this);
diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp
index 2e2084783d..ad3c0f6d22 100644
--- a/engines/zvision/scripting/effects/music_effect.cpp
+++ b/engines/zvision/scripting/effects/music_effect.cpp
@@ -227,8 +227,7 @@ bool PanTrackNode::process(uint32 deltaTimeInMillis) {
int volumeCorrection = 2;
if (_engine->getGameId() == GID_GRANDINQUISITOR) {
- Location loc = scriptManager->getCurrentLocation();
- if (loc.world == 'd' && loc.room == 'c' && loc.node == '1' && loc.view == '0')
+ if (scriptManager->getCurrentLocation() == "dc10")
volumeCorrection = 5;
}
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 71966b3125..70eaab2a0a 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -72,8 +72,7 @@ void ScriptManager::initialize() {
}
void ScriptManager::update(uint deltaTimeMillis) {
- if (_currentLocation.node != _nextLocation.node || _currentLocation.room != _nextLocation.room ||
- _currentLocation.view != _nextLocation.view || _currentLocation.world != _nextLocation.world) {
+ if (_currentLocation != _nextLocation) {
ChangeLocationReal(false);
}
@@ -543,7 +542,7 @@ void ScriptManager::changeLocation(char _world, char _room, char _node, char _vi
_nextLocation.view = _view;
_nextLocation.offset = offset;
// If next location is 0000, return to the previous location.
- if (_nextLocation.world == '0' && _nextLocation.room == '0' && _nextLocation.node == '0' && _nextLocation.view == '0') {
+ if (_nextLocation == "0000") {
if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') {
_nextLocation.world = getStateValue(StateKey_LastWorld);
_nextLocation.room = getStateValue(StateKey_LastRoom);
@@ -680,7 +679,7 @@ void ScriptManager::ChangeLocationReal(bool isLoading) {
// Change the background position
_engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
- if (_currentLocation.world == 0 && _currentLocation.room == 0 && _currentLocation.node == 0 && _currentLocation.view == 0) {
+ if (_currentLocation == "0000") {
_currentLocation = _nextLocation;
execScope(world);
execScope(room);
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index d8e3721d43..7c276bf917 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -113,6 +113,28 @@ struct Location {
uint32 offset;
};
+inline bool operator==(const Location& lhs, const Location& rhs) {
+ return (
+ lhs.world == rhs.world &&
+ lhs.room == rhs.room &&
+ lhs.node == rhs.node &&
+ lhs.view == rhs.view
+ );
+}
+
+inline bool operator==(const Location& lhs, const char* rhs) {
+ Common::String lhsStr = Common::String::format("%c%c%c%c", lhs.world, lhs.room, lhs.node, lhs.view);
+ return lhsStr == rhs;
+}
+
+inline bool operator!=(const Location& lhs, const Location& rhs) {
+ return !(lhs == rhs);
+}
+
+inline bool operator!=(const Location& lhs, const char* rhs) {
+ return !(lhs == rhs);
+}
+
typedef Common::List<Puzzle *> PuzzleList;
typedef Common::Queue<Puzzle *> PuzzleQueue;
typedef Common::List<Control *> ControlList;