From 17bf9e7f547d1893fbafb77dcc6703b21eca52c6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 15 Apr 2015 08:22:40 -0500 Subject: SHERLOCK: Refactored Chess class to be Map class --- engines/sherlock/map.cpp | 46 +++++++++++++++++++++++++++++++ engines/sherlock/map.h | 52 ++++++++++++++++++++++++++++++++++++ engines/sherlock/module.mk | 2 +- engines/sherlock/objects.cpp | 7 ++--- engines/sherlock/people.cpp | 5 ++-- engines/sherlock/scalpel/chess.cpp | 37 ------------------------- engines/sherlock/scalpel/chess.h | 45 ------------------------------- engines/sherlock/scalpel/scalpel.cpp | 14 ++++------ engines/sherlock/scalpel/scalpel.h | 4 +-- engines/sherlock/scene.cpp | 10 ++++--- engines/sherlock/sherlock.cpp | 3 +++ engines/sherlock/sherlock.h | 3 ++- engines/sherlock/talk.cpp | 6 ++--- 13 files changed, 126 insertions(+), 108 deletions(-) create mode 100644 engines/sherlock/map.cpp create mode 100644 engines/sherlock/map.h delete mode 100644 engines/sherlock/scalpel/chess.cpp delete mode 100644 engines/sherlock/scalpel/chess.h diff --git a/engines/sherlock/map.cpp b/engines/sherlock/map.cpp new file mode 100644 index 0000000000..8257c16a38 --- /dev/null +++ b/engines/sherlock/map.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "sherlock/map.h" + +namespace Sherlock { + +Map::Map(SherlockEngine *vm): _vm(vm) { +} + +/** + * 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 diff --git a/engines/sherlock/map.h b/engines/sherlock/map.h new file mode 100644 index 0000000000..88f2b75805 --- /dev/null +++ b/engines/sherlock/map.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#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 { + +class SherlockEngine; + +class Map { +private: + SherlockEngine *_vm; + Common::Array _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 show(); +}; + +} // End of namespace Sherlock + +#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/chess.cpp b/engines/sherlock/scalpel/chess.cpp deleted file mode 100644 index 95c662dd01..0000000000 --- a/engines/sherlock/scalpel/chess.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "sherlock/scalpel/chess.h" -#include "sherlock/scalpel/scalpel.h" - -namespace Sherlock { - -namespace Scalpel { - -int Chess::doChessBoard() { - // TODO - return 0; -} - -} // End of namespace Scalpel - -} // End of namespace Scalpel diff --git a/engines/sherlock/scalpel/chess.h b/engines/sherlock/scalpel/chess.h deleted file mode 100644 index 70607472c2..0000000000 --- a/engines/sherlock/scalpel/chess.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef SHERLOCK_CHESS_H -#define SHERLOCK_CHESS_H - -namespace Sherlock { - -namespace Scalpel { - -class ScalpelEngine; - -class Chess { -private: - ScalpelEngine *_vm; -public: - Chess(ScalpelEngine *vm) : _vm(vm) {} - - int doChessBoard(); -}; - -} // End of namespace Scalpel - -} // End of namespace Sherlock - -#endif 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 _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) { -- cgit v1.2.3