aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-04-15 08:22:40 -0500
committerPaul Gilbert2015-04-15 08:22:40 -0500
commit17bf9e7f547d1893fbafb77dcc6703b21eca52c6 (patch)
treec10440b147f0d0ca68130c848ea89bbf83e04420
parenta830d7732537a913aa29ae4a4bc10e80e79dbc82 (diff)
downloadscummvm-rg350-17bf9e7f547d1893fbafb77dcc6703b21eca52c6.tar.gz
scummvm-rg350-17bf9e7f547d1893fbafb77dcc6703b21eca52c6.tar.bz2
scummvm-rg350-17bf9e7f547d1893fbafb77dcc6703b21eca52c6.zip
SHERLOCK: Refactored Chess class to be Map class
-rw-r--r--engines/sherlock/map.cpp (renamed from engines/sherlock/scalpel/chess.h)35
-rw-r--r--engines/sherlock/map.h (renamed from engines/sherlock/scalpel/chess.cpp)33
-rw-r--r--engines/sherlock/module.mk2
-rw-r--r--engines/sherlock/objects.cpp7
-rw-r--r--engines/sherlock/people.cpp5
-rw-r--r--engines/sherlock/scalpel/scalpel.cpp14
-rw-r--r--engines/sherlock/scalpel/scalpel.h4
-rw-r--r--engines/sherlock/scene.cpp10
-rw-r--r--engines/sherlock/sherlock.cpp3
-rw-r--r--engines/sherlock/sherlock.h3
-rw-r--r--engines/sherlock/talk.cpp6
11 files changed, 70 insertions, 52 deletions
diff --git a/engines/sherlock/scalpel/chess.h b/engines/sherlock/map.cpp
index 70607472c2..8257c16a38 100644
--- a/engines/sherlock/scalpel/chess.h
+++ b/engines/sherlock/map.cpp
@@ -20,26 +20,27 @@
*
*/
-#ifndef SHERLOCK_CHESS_H
-#define SHERLOCK_CHESS_H
+#include "sherlock/map.h"
namespace Sherlock {
-namespace Scalpel {
+Map::Map(SherlockEngine *vm): _vm(vm) {
+}
-class ScalpelEngine;
-
-class Chess {
-private:
- ScalpelEngine *_vm;
-public:
- Chess(ScalpelEngine *vm) : _vm(vm) {}
-
- int doChessBoard();
-};
-
-} // End of namespace Scalpel
+/**
+ * Loads the list of points for locations on the map for each scene
+ */
+void Map::loadPoints(int count, const int *xList, const int *yList) {
+ for (int idx = 0; idx < count; ++idx, ++xList, ++yList) {
+ _points.push_back(Common::Point(*xList, *yList));
+ }
+}
+
+/**
+ * Show the map
+ */
+int Map::show() {
+ return 0;
+}
} // End of namespace Sherlock
-
-#endif
diff --git a/engines/sherlock/scalpel/chess.cpp b/engines/sherlock/map.h
index 95c662dd01..88f2b75805 100644
--- a/engines/sherlock/scalpel/chess.cpp
+++ b/engines/sherlock/map.h
@@ -20,18 +20,33 @@
*
*/
-#include "sherlock/scalpel/chess.h"
-#include "sherlock/scalpel/scalpel.h"
+#ifndef SHERLOCK_MAP_H
+#define SHERLOCK_MAP_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
+#include "common/str.h"
namespace Sherlock {
-namespace Scalpel {
+class SherlockEngine;
+
+class Map {
+private:
+ SherlockEngine *_vm;
+ Common::Array<Common::Point> _points; // Map locations for each scene
+public:
+public:
+ Map(SherlockEngine *vm);
+
+ const Common::Point &operator[](int idx) { return _points[idx]; }
+
+ void loadPoints(int count, const int *xList, const int *yList);
-int Chess::doChessBoard() {
- // TODO
- return 0;
-}
+ int show();
+};
-} // End of namespace Scalpel
+} // End of namespace Sherlock
-} // End of namespace Scalpel
+#endif
diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk
index 4101769a80..171f704a1e 100644
--- a/engines/sherlock/module.mk
+++ b/engines/sherlock/module.mk
@@ -1,7 +1,6 @@
MODULE := engines/sherlock
MODULE_OBJS = \
- scalpel/chess.o \
scalpel/darts.o \
scalpel/scalpel.o \
tattoo/tattoo.o \
@@ -13,6 +12,7 @@ MODULE_OBJS = \
graphics.o \
inventory.o \
journal.o \
+ map.o \
objects.o \
people.o \
resources.o \
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index ca1bdfb2c5..82daa90a38 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -801,6 +801,7 @@ void Object::setObjSequence(int seq, bool wait) {
* @returns 0 if no codes are found, 1 if codes were found
*/
int Object::checkNameForCodes(const Common::String &name, const char *const messages[]) {
+ Map &map = *_vm->_map;
People &people = *_vm->_people;
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
@@ -847,9 +848,9 @@ int Object::checkNameForCodes(const Common::String &name, const char *const mess
if (ch >= '0' && ch <= '9') {
scene._goToScene = atoi(name.c_str() + 1);
- if (scene._goToScene < 97 && _vm->_map[scene._goToScene].x) {
- _vm->_over.x = _vm->_map[scene._goToScene].x * 100 - 600;
- _vm->_over.y = _vm->_map[scene._goToScene].y * 100 + 900;
+ 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;
}
if ((p = strchr(name.c_str(), ',')) != nullptr) {
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp
index cc26339bde..d22c08f625 100644
--- a/engines/sherlock/people.cpp
+++ b/engines/sherlock/people.cpp
@@ -415,6 +415,7 @@ void People::setWalking() {
* is being displayed, then the chraracter will always face down.
*/
void People::gotoStand(Sprite &sprite) {
+ Map &map = *_vm->_map;
Scene &scene = *_vm->_scene;
_walkTo.clear();
sprite._walkCount = 0;
@@ -448,8 +449,8 @@ void People::gotoStand(Sprite &sprite) {
if (_vm->_onChessboard) {
sprite._sequenceNumber = 0;
- _data[AL]._position.x = (_vm->_map[scene._charPoint].x - 6) * 100;
- _data[AL]._position.y = (_vm->_map[scene._charPoint].x + 10) * 100;
+ _data[AL]._position.x = (map[scene._charPoint].x - 6) * 100;
+ _data[AL]._position.y = (map[scene._charPoint].x + 10) * 100;
}
_oldWalkSequence = -1;
diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp
index 954ea12aec..0742d05366 100644
--- a/engines/sherlock/scalpel/scalpel.cpp
+++ b/engines/sherlock/scalpel/scalpel.cpp
@@ -183,13 +183,11 @@ byte TALK_SEQUENCES[MAX_PEOPLE][MAX_TALK_SEQUENCES] = {
ScalpelEngine::ScalpelEngine(OSystem *syst, const SherlockGameDescription *gameDesc) :
SherlockEngine(syst, gameDesc) {
- _chess = nullptr;
_darts = nullptr;
- _chessResult = 0;
+ _mapResult = 0;
}
ScalpelEngine::~ScalpelEngine() {
- delete _chess;
delete _darts;
}
@@ -199,7 +197,6 @@ ScalpelEngine::~ScalpelEngine() {
void ScalpelEngine::initialize() {
SherlockEngine::initialize();
- _chess = new Chess(this);
_darts = new Darts(this);
_flags.resize(100 * 8);
@@ -207,8 +204,7 @@ void ScalpelEngine::initialize() {
_flags[39] = true; // Turn on Baker Street
// Load the map co-ordinates for each scene
- for (int idx = 0; idx < NUM_PLACES; ++idx)
- _map.push_back(Common::Point(MAP_X[idx], MAP_Y[idx]));
+ _map->loadPoints(NUM_PLACES, &MAP_X[0], &MAP_Y[0]);
// Load the inventory
loadInventory();
@@ -393,7 +389,7 @@ void ScalpelEngine::startScene() {
}
}
- _scene->_goToScene = _chess->doChessBoard();
+ _scene->_goToScene = _map->show();
_sound->freeSong();
_scene->_hsavedPos = Common::Point(-1, -1);
@@ -533,10 +529,10 @@ void ScalpelEngine::startScene() {
if (_scene->_goToScene == 99) {
// Chess Board
_darts->playDarts();
- _chessResult = _scene->_goToScene = 19; // Go back to the bar
+ _mapResult = _scene->_goToScene = 19; // Go back to the bar
}
- _chessResult = _scene->_goToScene;
+ _mapResult = _scene->_goToScene;
}
/**
diff --git a/engines/sherlock/scalpel/scalpel.h b/engines/sherlock/scalpel/scalpel.h
index 34d017e757..aa00acab84 100644
--- a/engines/sherlock/scalpel/scalpel.h
+++ b/engines/sherlock/scalpel/scalpel.h
@@ -24,7 +24,6 @@
#define SHERLOCK_SCALPEL_H
#include "sherlock/sherlock.h"
-#include "sherlock/scalpel/chess.h"
#include "sherlock/scalpel/darts.h"
namespace Sherlock {
@@ -33,9 +32,8 @@ namespace Scalpel {
class ScalpelEngine : public SherlockEngine {
private:
- Chess *_chess;
Darts *_darts;
- int _chessResult;
+ int _mapResult;
bool showCityCutscene();
bool showAlleyCutscene();
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index 46ddbc425f..575523bc45 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -193,6 +193,7 @@ void Scene::freeScene() {
*/
bool Scene::loadScene(const Common::String &filename) {
Events &events = *_vm->_events;
+ Map &map = *_vm->_map;
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
Sound &sound = *_vm->_sound;
@@ -437,8 +438,8 @@ bool Scene::loadScene(const Common::String &filename) {
// Reset the position on the overland map
_vm->_oldCharPoint = _currentScene;
- _vm->_over.x = _vm->_map[_currentScene].x * 100 - 600;
- _vm->_over.y = _vm->_map[_currentScene].y * 100 + 900;
+ _vm->_over.x = map[_currentScene].x * 100 - 600;
+ _vm->_over.y = map[_currentScene].y * 100 + 900;
events.clearEvents();
return flag;
@@ -843,6 +844,7 @@ void Scene::checkBgShapes(ImageFrame *frame, const Common::Point &pt) {
*/
int Scene::startCAnim(int cAnimNum, int playRate) {
Events &events = *_vm->_events;
+ Map &map = *_vm->_map;
People &people = *_vm->_people;
Resources &res = *_vm->_res;
Talk &talk = *_vm->_talk;
@@ -1027,8 +1029,8 @@ int Scene::startCAnim(int cAnimNum, int playRate) {
if (gotoCode > 0 && !talk._talkToAbort) {
_goToScene = gotoCode;
- if (_goToScene < 97 && _vm->_map[_goToScene].x) {
- _overPos = _vm->_map[_goToScene];
+ if (_goToScene < 97 && map[_goToScene].x) {
+ _overPos = map[_goToScene];
}
}
diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp
index c65a70a20f..632e388642 100644
--- a/engines/sherlock/sherlock.cpp
+++ b/engines/sherlock/sherlock.cpp
@@ -35,6 +35,7 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam
_events = nullptr;
_inventory = nullptr;
_journal = nullptr;
+ _map = nullptr;
_people = nullptr;
_res = nullptr;
_scene = nullptr;
@@ -55,6 +56,7 @@ SherlockEngine::~SherlockEngine() {
delete _debugger;
delete _events;
delete _journal;
+ delete _map;
delete _people;
delete _scene;
delete _screen;
@@ -78,6 +80,7 @@ void SherlockEngine::initialize() {
_debugger = new Debugger(this);
_events = new Events(this);
_inventory = new Inventory(this);
+ _map = new Map(this);
_journal = new Journal(this);
_people = new People(this);
_scene = new Scene(this);
diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h
index ec8e0c3148..42e2cf8b38 100644
--- a/engines/sherlock/sherlock.h
+++ b/engines/sherlock/sherlock.h
@@ -36,6 +36,7 @@
#include "sherlock/events.h"
#include "sherlock/inventory.h"
#include "sherlock/journal.h"
+#include "sherlock/map.h"
#include "sherlock/people.h"
#include "sherlock/resources.h"
#include "sherlock/scene.h"
@@ -85,6 +86,7 @@ public:
Events *_events;
Inventory *_inventory;
Journal *_journal;
+ Map *_map;
People *_people;
Resources *_res;
Scene *_scene;
@@ -101,7 +103,6 @@ public:
bool _loadingSavedGame;
int _oldCharPoint; // Old scene
Common::Point _over; // Old map position
- Common::Array<Common::Point> _map; // Map locations for each scene
bool _onChessboard;
bool _slowChess;
bool _joystick;
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index ee1e6201d2..158cae38a9 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -574,7 +574,6 @@ void Talk::freeTalkVars() {
* conversation. If found, the data for that conversation is loaded
*/
void Talk::loadTalkFile(const Common::String &filename) {
- People &people = *_vm->_people;
Resources &res = *_vm->_res;
Sound &sound = *_vm->_sound;
@@ -1000,6 +999,7 @@ void Talk::doScript(const Common::String &script) {
Animation &anim = *_vm->_animation;
Events &events = *_vm->_events;
Inventory &inv = *_vm->_inventory;
+ Map &map = *_vm->_map;
People &people = *_vm->_people;
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
@@ -1351,8 +1351,8 @@ void Talk::doScript(const Common::String &script) {
if (scene._goToScene != 100) {
// Not going to the map overview
scene._oldCharPoint = scene._goToScene;
- scene._overPos.x = _vm->_map[scene._goToScene].x * 100 - 600;
- scene._overPos.y = _vm->_map[scene._goToScene].y * 100 + 900;
+ scene._overPos.x = map[scene._goToScene].x * 100 - 600;
+ scene._overPos.y = map[scene._goToScene].y * 100 + 900;
// Run a canimation?
if (str[2] > 100) {