aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-04-26 18:29:20 -0500
committerPaul Gilbert2015-04-26 18:29:20 -0500
commit65eb390ead25c54b1e3c547f3e189a7ccb73becb (patch)
treeab235ea8c28d422eccd43d4f03359ab9f793ee09
parentf3bd61607017fe0ef0f5143e6ad8dbdb4743b246 (diff)
downloadscummvm-rg350-65eb390ead25c54b1e3c547f3e189a7ccb73becb.tar.gz
scummvm-rg350-65eb390ead25c54b1e3c547f3e189a7ccb73becb.tar.bz2
scummvm-rg350-65eb390ead25c54b1e3c547f3e189a7ccb73becb.zip
SHERLOCK: Cleanup and moving of map variables into Map class
-rw-r--r--engines/sherlock/map.cpp29
-rw-r--r--engines/sherlock/map.h8
-rw-r--r--engines/sherlock/objects.cpp4
-rw-r--r--engines/sherlock/people.cpp5
-rw-r--r--engines/sherlock/saveload.cpp2
-rw-r--r--engines/sherlock/scalpel/scalpel.cpp18
-rw-r--r--engines/sherlock/scene.cpp18
-rw-r--r--engines/sherlock/scene.h3
-rw-r--r--engines/sherlock/sherlock.h2
-rw-r--r--engines/sherlock/talk.cpp6
10 files changed, 50 insertions, 45 deletions
diff --git a/engines/sherlock/map.cpp b/engines/sherlock/map.cpp
index c3a5ba7b17..5865f34fa0 100644
--- a/engines/sherlock/map.cpp
+++ b/engines/sherlock/map.cpp
@@ -62,6 +62,9 @@ Map::Map(SherlockEngine *vm): _vm(vm), _topLine(SHERLOCK_SCREEN_WIDTH, 12) {
_cursorIndex = -1;
_drawMap = false;
_overPos = Common::Point(13000, 12600);
+ _charPoint = 0;
+ _oldCharPoint = 39;
+
for (int idx = 0; idx < MAX_HOLMES_SEQUENCE; ++idx)
Common::fill(&_sequences[idx][0], &_sequences[idx][MAX_FRAME], 0);
@@ -126,7 +129,6 @@ void Map::loadData() {
int Map::show() {
Events &events = *_vm->_events;
People &people = *_vm->_people;
- Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
Common::Point lDrawn(-1, -1);
bool changed = false, exitFlag = false;
@@ -230,7 +232,7 @@ int Map::show() {
if ((events._released || events._rightReleased) && _point != -1) {
if (people[AL]._walkCount == 0) {
people._walkDest = _points[_point] + Common::Point(4, 9);
- scene._charPoint = _point;
+ _charPoint = _point;
// Start walking to selected location
walkTheStreets();
@@ -243,7 +245,7 @@ int Map::show() {
// Check if a scene has beeen selected and we've finished "moving" to it
if (people[AL]._walkCount == 0) {
- if (scene._charPoint >= 1 && scene._charPoint < (int)_points.size())
+ if (_charPoint >= 1 && _charPoint < (int)_points.size())
exitFlag = true;
}
@@ -267,7 +269,7 @@ int Map::show() {
screen.setFont(oldFont);
_active = false;
- return scene._charPoint;
+ return _charPoint;
}
/**
@@ -443,8 +445,8 @@ void Map::walkTheStreets() {
Common::Array<Common::Point> tempPath;
// Get indexes into the path lists for the start and destination scenes
- int start = _points[scene._oldCharPoint]._translate;
- int dest = _points[scene._charPoint]._translate;
+ int start = _points[_oldCharPoint]._translate;
+ int dest = _points[_charPoint]._translate;
// Get pointer to start of path
const byte *path = _paths.getPath(start, dest);
@@ -454,10 +456,10 @@ void Map::walkTheStreets() {
Common::Point destPos = people._walkDest;
// Check for any intermediate points between the two locations
- if (path[0] || scene._charPoint > 50 || scene._oldCharPoint > 50) {
+ if (path[0] || _charPoint > 50 || _oldCharPoint > 50) {
people[AL]._sequenceNumber = -1;
- if (scene._charPoint == 51 || scene._oldCharPoint == 51) {
+ if (_charPoint == 51 || _oldCharPoint == 51) {
people.setWalking();
} else {
// Check for moving the path backwards or forwards
@@ -583,4 +585,15 @@ void Map::highlightIcon(const Common::Point &pt) {
}
}
+/**
+* Synchronize the data for a savegame
+*/
+void Map::synchronize(Common::Serializer &s) {
+ s.syncAsSint16LE(_bigPos.x);
+ s.syncAsSint16LE(_bigPos.y);
+ s.syncAsSint16LE(_overPos.x);
+ s.syncAsSint16LE(_overPos.y);
+ s.syncAsSint16LE(_oldCharPoint);
+}
+
} // End of namespace Sherlock
diff --git a/engines/sherlock/map.h b/engines/sherlock/map.h
index a91e7ae968..564ae73691 100644
--- a/engines/sherlock/map.h
+++ b/engines/sherlock/map.h
@@ -26,6 +26,7 @@
#include "common/scummsys.h"
#include "common/array.h"
#include "common/rect.h"
+#include "common/serializer.h"
#include "common/str.h"
#include "common/str-array.h"
#include "sherlock/graphics.h"
@@ -67,8 +68,6 @@ private:
ImageFile *_shapes;
ImageFile *_iconShapes;
byte _sequences[MAX_HOLMES_SEQUENCE][MAX_FRAME];
- Common::Point _bigPos;
- Common::Point _overPos;
Common::Point _lDrawnPos;
int _point;
bool _placesShown;
@@ -97,6 +96,9 @@ private:
void highlightIcon(const Common::Point &pt);
public:
bool _active;
+ Common::Point _overPos;
+ Common::Point _bigPos;
+ int _charPoint, _oldCharPoint;
public:
Map(SherlockEngine *vm);
@@ -106,6 +108,8 @@ public:
void loadSequences(int count, const byte *seq);
int show();
+
+ void synchronize(Common::Serializer &s);
};
} // End of namespace Sherlock
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index 7341fc3b30..62a1a35f4a 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -861,8 +861,8 @@ int Object::checkNameForCodes(const Common::String &name, const char *const mess
scene._goToScene = atoi(name.c_str() + 1);
if (scene._goToScene < 97 && map[scene._goToScene].x) {
- _vm->_over.x = map[scene._goToScene].x * 100 - 600;
- _vm->_over.y = map[scene._goToScene].y * 100 + 900;
+ map._overPos.x = map[scene._goToScene].x * 100 - 600;
+ map._overPos.y = map[scene._goToScene].y * 100 + 900;
}
if ((p = strchr(name.c_str(), ',')) != nullptr) {
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp
index 43e1fa046b..2eff1a0973 100644
--- a/engines/sherlock/people.cpp
+++ b/engines/sherlock/people.cpp
@@ -421,7 +421,6 @@ void People::setWalking() {
*/
void People::gotoStand(Sprite &sprite) {
Map &map = *_vm->_map;
- Scene &scene = *_vm->_scene;
_walkTo.clear();
sprite._walkCount = 0;
@@ -454,8 +453,8 @@ void People::gotoStand(Sprite &sprite) {
if (map._active) {
sprite._sequenceNumber = 0;
- _data[AL]._position.x = (map[scene._charPoint].x - 6) * 100;
- _data[AL]._position.y = (map[scene._charPoint].x + 10) * 100;
+ _player._position.x = (map[map._charPoint].x - 6) * 100;
+ _player._position.y = (map[map._charPoint].x + 10) * 100;
}
_oldWalkSequence = -1;
diff --git a/engines/sherlock/saveload.cpp b/engines/sherlock/saveload.cpp
index a694e21b28..86a4e8417a 100644
--- a/engines/sherlock/saveload.cpp
+++ b/engines/sherlock/saveload.cpp
@@ -368,6 +368,7 @@ Common::String SaveManager::generateSaveName(int slot) {
void SaveManager::synchronize(Common::Serializer &s) {
Inventory &inv = *_vm->_inventory;
Journal &journal = *_vm->_journal;
+ Map &map = *_vm->_map;
People &people = *_vm->_people;
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
@@ -378,6 +379,7 @@ void SaveManager::synchronize(Common::Serializer &s) {
inv.synchronize(s);
journal.synchronize(s);
people.synchronize(s);
+ map.synchronize(s);
scene.synchronize(s);
screen.synchronize(s);
talk.synchronize(s);
diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp
index 65ca61b09f..89e042d382 100644
--- a/engines/sherlock/scalpel/scalpel.cpp
+++ b/engines/sherlock/scalpel/scalpel.cpp
@@ -576,23 +576,23 @@ void ScalpelEngine::startScene() {
switch (_scene->_goToScene) {
case 52:
_scene->_goToScene = 27; // Go to the Lawyer's Office
- _scene->_bigPos = Common::Point(0, 0); // Overland scroll position
- _scene->_overPos = Common::Point(22900 - 600, 9400 + 900); // Overland position
- _scene->_oldCharPoint = 27;
+ _map->_bigPos = Common::Point(0, 0); // Overland scroll position
+ _map->_overPos = Common::Point(22900 - 600, 9400 + 900); // Overland position
+ _map->_oldCharPoint = 27;
break;
case 53:
_scene->_goToScene = 17; // Go to St. Pancras Station
- _scene->_bigPos = Common::Point(0, 0); // Overland scroll position
- _scene->_overPos = Common::Point(32500 - 600, 3000 + 900); // Overland position
- _scene->_oldCharPoint = 17;
+ _map->_bigPos = Common::Point(0, 0); // Overland scroll position
+ _map->_overPos = Common::Point(32500 - 600, 3000 + 900); // Overland position
+ _map->_oldCharPoint = 17;
break;
default:
_scene->_goToScene = 4; // Back to Baker st.
- _scene->_bigPos = Common::Point(0, 0); // Overland scroll position
- _scene->_overPos = Common::Point(14500 - 600, 8400 + 900); // Overland position
- _scene->_oldCharPoint = 4;
+ _map->_bigPos = Common::Point(0, 0); // Overland scroll position
+ _map->_overPos = Common::Point(14500 - 600, 8400 + 900); // Overland position
+ _map->_oldCharPoint = 4;
break;
}
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index 2d0f6fd751..7c31788a2f 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -89,8 +89,6 @@ Scene::Scene(SherlockEngine *vm): _vm(vm) {
_currentScene = -1;
_goToScene = -1;
_changes = false;
- _charPoint = 0;
- _oldCharPoint = 39;
_keyboardInput = 0;
_walkedInScene = false;
_ongoingCans = 0;
@@ -438,10 +436,10 @@ bool Scene::loadScene(const Common::String &filename) {
_walkedInScene = false;
saves._justLoaded = false;
- // Reset the position on the overland map
- _vm->_oldCharPoint = _currentScene;
- _vm->_over.x = map[_currentScene].x * 100 - 600;
- _vm->_over.y = map[_currentScene].y * 100 + 900;
+ // Reset the previous map location and position on overhead map
+ map._oldCharPoint = _currentScene;
+ map._overPos.x = map[_currentScene].x * 100 - 600;
+ map._overPos.y = map[_currentScene].y * 100 + 900;
events.clearEvents();
return flag;
@@ -1043,7 +1041,7 @@ int Scene::startCAnim(int cAnimNum, int playRate) {
_goToScene = gotoCode;
if (_goToScene < 97 && map[_goToScene].x) {
- _overPos = map[_goToScene];
+ map._overPos = map[_goToScene];
}
}
@@ -1474,12 +1472,6 @@ void Scene::synchronize(Common::Serializer &s) {
if (s.isSaving())
saveSceneStatus();
- s.syncAsSint16LE(_bigPos.x);
- s.syncAsSint16LE(_bigPos.y);
- s.syncAsSint16LE(_overPos.x);
- s.syncAsSint16LE(_overPos.y);
- s.syncAsSint16LE(_oldCharPoint);
-
if (s.isSaving())
s.syncAsSint16LE(_currentScene);
else
diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h
index 892163a2f6..159f281bdf 100644
--- a/engines/sherlock/scene.h
+++ b/engines/sherlock/scene.h
@@ -107,9 +107,6 @@ public:
bool _changes;
bool _sceneStats[SCENES_COUNT][65];
bool _savedStats[SCENES_COUNT][9];
- Common::Point _bigPos;
- Common::Point _overPos;
- int _charPoint, _oldCharPoint;
int _keyboardInput;
int _oldKey, _help, _oldHelp;
int _oldTemp, _temp;
diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h
index ce126c0dcc..921559183d 100644
--- a/engines/sherlock/sherlock.h
+++ b/engines/sherlock/sherlock.h
@@ -104,8 +104,6 @@ public:
Common::String _titleOverride;
bool _useEpilogue2;
bool _loadingSavedGame;
- int _oldCharPoint; // Old scene
- Common::Point _over; // Old map position
bool _slowChess;
int _keyPadSpeed;
int _loadGameSlot;
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index 0793552846..94779ae760 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -1355,9 +1355,9 @@ void Talk::doScript(const Common::String &script) {
if (scene._goToScene != 100) {
// Not going to the map overview
- scene._oldCharPoint = scene._goToScene;
- scene._overPos.x = map[scene._goToScene].x * 100 - 600;
- scene._overPos.y = map[scene._goToScene].y * 100 + 900;
+ map._oldCharPoint = scene._goToScene;
+ map._overPos.x = map[scene._goToScene].x * 100 - 600;
+ map._overPos.y = map[scene._goToScene].y * 100 + 900;
// Run a canimation?
if (str[2] > 100) {