SHERLOCK: RT: Cleanup of Exit class and fix exiting scenes

This commit is contained in:
Paul Gilbert 2015-07-02 20:53:40 -04:00
parent d6bf970a58
commit 480003f48d
16 changed files with 53 additions and 51 deletions

View file

@ -526,18 +526,17 @@ int BaseObject::checkNameForCodes(const Common::String &name, FixedTextActionId
++p; ++p;
Common::String s(p, p + 3); Common::String s(p, p + 3);
people._hSavedPos.x = atoi(s.c_str()); people._savedPos.x = atoi(s.c_str());
s = Common::String(p + 3, p + 6); s = Common::String(p + 3, p + 6);
people._hSavedPos.y = atoi(s.c_str()); people._savedPos.y = atoi(s.c_str());
s = Common::String(p + 6, p + 9); s = Common::String(p + 6, p + 9);
people._hSavedFacing = atoi(s.c_str()); people._savedPos._facing = atoi(s.c_str());
if (people._hSavedFacing == 0) if (people._savedPos._facing == 0)
people._hSavedFacing = 10; people._savedPos._facing = 10;
} else if ((p = strchr(name.c_str(), '/')) != nullptr) { } else if ((p = strchr(name.c_str(), '/')) != nullptr) {
people._hSavedPos = Common::Point(1, 0); people._savedPos = PositionFacing(1, 0, 100 + atoi(p + 1));
people._hSavedFacing = 100 + atoi(p + 1);
} }
} else { } else {
scene._goToScene = 100; scene._goToScene = 100;

View file

@ -122,6 +122,11 @@ public:
int _facing; int _facing;
PositionFacing() : Point32(), _facing(0) {} PositionFacing() : Point32(), _facing(0) {}
PositionFacing(int xp, int yp, int theFacing) : Point32(xp, yp), _facing(theFacing) {}
PositionFacing &operator=(const Point32 &pt) {
x = pt.x; y = pt.y;
return *this;
}
}; };
struct WalkSequence { struct WalkSequence {

View file

@ -172,8 +172,8 @@ People::People(SherlockEngine *vm) : _vm(vm) {
_speakerFlip = false; _speakerFlip = false;
_holmesFlip = false; _holmesFlip = false;
_holmesQuotient = 0; _holmesQuotient = 0;
_hSavedPos = Point32(-1, -1); _savedPos = Point32(-1, -1);
_hSavedFacing = -1; _savedPos._facing = -1;
_forceWalkReload = false; _forceWalkReload = false;
_useWalkLib = false; _useWalkLib = false;
_walkControl = 0; _walkControl = 0;
@ -336,8 +336,8 @@ void People::synchronize(Serializer &s) {
s.syncAsSint16LE(_holmesQuotient); s.syncAsSint16LE(_holmesQuotient);
if (s.isLoading()) { if (s.isLoading()) {
_hSavedPos = _data[HOLMES]->_position; _savedPos = _data[HOLMES]->_position;
_hSavedFacing = _data[HOLMES]->_sequenceNumber; _savedPos._facing = _data[HOLMES]->_sequenceNumber;
} }
} }

View file

@ -99,8 +99,7 @@ protected:
public: public:
Common::Array<PersonData> _characters; Common::Array<PersonData> _characters;
ImageFile *_talkPics; ImageFile *_talkPics;
Point32 _hSavedPos; PositionFacing _savedPos;
int _hSavedFacing;
bool _holmesOn; bool _holmesOn;
bool _portraitLoaded; bool _portraitLoaded;
bool _portraitsOn; bool _portraitsOn;

View file

@ -922,8 +922,8 @@ void ScalpelEngine::startScene() {
_scene->_goToScene = _map->show(); _scene->_goToScene = _map->show();
_music->freeSong(); _music->freeSong();
_people->_hSavedPos = Common::Point(-1, -1); _people->_savedPos = Common::Point(-1, -1);
_people->_hSavedFacing = -1; _people->_savedPos._facing = -1;
} }
// Some rooms are prologue cutscenes, rather than normal game scenes. These are: // Some rooms are prologue cutscenes, rather than normal game scenes. These are:

View file

@ -126,11 +126,10 @@ void ScalpelPerson::adjustSprite() {
scene._goToScene = exit->_scene; scene._goToScene = exit->_scene;
if (exit->_newPosition.x != 0) { if (exit->_newPosition.x != 0) {
people._hSavedPos = exit->_newPosition; people._savedPos = exit->_newPosition;
people._hSavedFacing = exit->_newFacing;
if (people._hSavedFacing > 100 && people._hSavedPos.x < 1) if (people._savedPos._facing > 100 && people._savedPos.x < 1)
people._hSavedPos.x = 100; people._savedPos.x = 100;
} }
} }
} }
@ -444,8 +443,8 @@ void ScalpelPeople::synchronize(Serializer &s) {
s.syncAsSint16LE(_holmesQuotient); s.syncAsSint16LE(_holmesQuotient);
if (s.isLoading()) { if (s.isLoading()) {
_hSavedPos = _data[HOLMES]->_position; _savedPos = _data[HOLMES]->_position;
_hSavedFacing = _data[HOLMES]->_sequenceNumber; _savedPos._facing = _data[HOLMES]->_sequenceNumber;
} }
} }

View file

@ -320,15 +320,13 @@ OpcodeReturn ScalpelTalk::cmdGotoScene(const byte *&str) {
// Run a canimation? // Run a canimation?
if (str[2] > 100) { if (str[2] > 100) {
people._hSavedFacing = str[2]; people._savedPos = PositionFacing(160, 100, str[2]);
people._hSavedPos = Point32(160, 100);
} else { } else {
people._hSavedFacing = str[2] - 1;
int32 posX = (str[3] - 1) * 256 + str[4] - 1; int32 posX = (str[3] - 1) * 256 + str[4] - 1;
int32 posY = str[5] - 1; int32 posY = str[5] - 1;
people._hSavedPos = Point32(posX, posY); people._savedPos = PositionFacing(posX, posY, str[2] - 1);
}
} }
} // if (scene._goToScene != 100)
str += 6; str += 6;

View file

@ -116,7 +116,7 @@ void Exit::load(Common::SeekableReadStream &s, bool isRoseTattoo) {
_newPosition.x = s.readSint16LE(); _newPosition.x = s.readSint16LE();
_newPosition.y = s.readSint16LE(); _newPosition.y = s.readSint16LE();
_newFacing = s.readUint16LE(); _newPosition._facing = s.readUint16LE();
if (isRoseTattoo) if (isRoseTattoo)
_allow = s.readSint16LE(); _allow = s.readSint16LE();
@ -135,7 +135,7 @@ void Exit::load3DO(Common::SeekableReadStream &s) {
_newPosition.x = s.readSint16BE(); _newPosition.x = s.readSint16BE();
_newPosition.y = s.readSint16BE(); _newPosition.y = s.readSint16BE();
_newFacing = s.readUint16BE(); _newPosition._facing = s.readUint16BE();
s.skip(2); // Filler s.skip(2); // Filler
} }
@ -231,7 +231,6 @@ Scene::Scene(SherlockEngine *vm): _vm(vm) {
_animating = 0; _animating = 0;
_doBgAnimDone = true; _doBgAnimDone = true;
_tempFadeStyle = 0; _tempFadeStyle = 0;
_exitZone = -1;
_doBgAnimDone = false; _doBgAnimDone = false;
} }
@ -603,7 +602,6 @@ bool Scene::loadScene(const Common::String &filename) {
} }
// Read in the exits // Read in the exits
_exitZone = -1;
int numExits = rrmStream->readByte(); int numExits = rrmStream->readByte();
_exits.resize(numExits); _exits.resize(numExits);
@ -922,7 +920,6 @@ bool Scene::loadScene(const Common::String &filename) {
int exitsCount = header3DO_exits_size / 20; int exitsCount = header3DO_exits_size / 20;
_exitZone = -1;
_exits.resize(exitsCount); _exits.resize(exitsCount);
for (int idx = 0; idx < exitsCount; ++idx) for (int idx = 0; idx < exitsCount; ++idx)
_exits[idx].load3DO(*roomStream); _exits[idx].load3DO(*roomStream);
@ -1157,8 +1154,8 @@ void Scene::transitionToScene() {
SaveManager &saves = *_vm->_saves; SaveManager &saves = *_vm->_saves;
Screen &screen = *_vm->_screen; Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk; Talk &talk = *_vm->_talk;
Point32 &hSavedPos = people._hSavedPos; Point32 &hSavedPos = people._savedPos;
int &hSavedFacing = people._hSavedFacing; int &hSavedFacing = people._savedPos._facing;
if (hSavedPos.x < 1) { if (hSavedPos.x < 1) {
// No exit information from last scene-check entrance info // No exit information from last scene-check entrance info

View file

@ -79,8 +79,7 @@ class Exit: public Common::Rect {
public: public:
int _scene; int _scene;
int _allow; int _allow;
Common::Point _newPosition; PositionFacing _newPosition;
int _newFacing;
Common::String _dest; Common::String _dest;
int _image; // Arrow image to use int _image; // Arrow image to use
@ -228,7 +227,6 @@ public:
int _walkDirectory[MAX_ZONES][MAX_ZONES]; int _walkDirectory[MAX_ZONES][MAX_ZONES];
Common::Array<WalkArray> _walkPoints; Common::Array<WalkArray> _walkPoints;
Common::Array<Exit> _exits; Common::Array<Exit> _exits;
int _exitZone;
SceneEntry _entrance; SceneEntry _entrance;
Common::Array<SceneSound> _sounds; Common::Array<SceneSound> _sounds;
ObjectArray _canimShapes; ObjectArray _canimShapes;

View file

@ -179,7 +179,7 @@ void SherlockEngine::sceneLoop() {
// Handle any input from the keyboard or mouse // Handle any input from the keyboard or mouse
handleInput(); handleInput();
if (_people->_hSavedPos.x == -1) { if (_people->_savedPos.x == -1) {
_canLoadSave = true; _canLoadSave = true;
_scene->doBgAnim(); _scene->doBgAnim();
_canLoadSave = false; _canLoadSave = false;

View file

@ -85,8 +85,8 @@ void TattooEngine::startScene() {
_scene->_currentScene = OVERHEAD_MAP; _scene->_currentScene = OVERHEAD_MAP;
_scene->_goToScene = _map->show(); _scene->_goToScene = _map->show();
_people->_hSavedPos = Common::Point(-1, -1); _people->_savedPos = Common::Point(-1, -1);
_people->_hSavedFacing = -1; _people->_savedPos._facing = -1;
} }
// TODO // TODO

View file

@ -23,6 +23,7 @@
#include "sherlock/tattoo/tattoo_people.h" #include "sherlock/tattoo/tattoo_people.h"
#include "sherlock/tattoo/tattoo_scene.h" #include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/tattoo/tattoo_talk.h" #include "sherlock/tattoo/tattoo_talk.h"
#include "sherlock/tattoo/tattoo_user_interface.h"
#include "sherlock/tattoo/tattoo.h" #include "sherlock/tattoo/tattoo.h"
namespace Sherlock { namespace Sherlock {
@ -131,6 +132,7 @@ void TattooPerson::freeAltGraphics() {
void TattooPerson::adjustSprite() { void TattooPerson::adjustSprite() {
People &people = *_vm->_people; People &people = *_vm->_people;
TattooScene &scene = *(TattooScene *)_vm->_scene; TattooScene &scene = *(TattooScene *)_vm->_scene;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
if (_type == INVALID) if (_type == INVALID)
return; return;
@ -192,13 +194,17 @@ void TattooPerson::adjustSprite() {
// See if the player has come to a stop after clicking on an Arrow zone to leave the scene. // See if the player has come to a stop after clicking on an Arrow zone to leave the scene.
// If so, this will set up the exit information for the scene transition // If so, this will set up the exit information for the scene transition
if (!_walkCount && scene._exitZone != -1 && scene._walkedInScene && scene._goToScene != -1 && if (!_walkCount && ui._exitZone != -1 && scene._walkedInScene && scene._goToScene == -1 &&
!_description.compareToIgnoreCase(people[HOLMES]._description)) { !_description.compareToIgnoreCase(people[HOLMES]._description)) {
people._hSavedPos = scene._exits[scene._exitZone]._newPosition; Exit &exit = scene._exits[ui._exitZone];
people._hSavedFacing = scene._exits[scene._exitZone]._newFacing; scene._goToScene = exit._scene;
if (people._hSavedFacing > 100 && people._hSavedPos.x < 1) if (exit._newPosition.x != 0) {
people._hSavedPos.x = 100; people._savedPos = exit._newPosition;
if (people._savedPos._facing > 100 && people._savedPos.x < 1)
people._savedPos.x = 100;
}
} }
} }
@ -1184,8 +1190,9 @@ void TattooPeople::synchronize(Serializer &s) {
s.syncAsSint16LE(_holmesQuotient); s.syncAsSint16LE(_holmesQuotient);
if (s.isLoading()) { if (s.isLoading()) {
_hSavedPos = _data[HOLMES]->_position; _savedPos.x = _data[HOLMES]->_position.x;
_hSavedFacing = _data[HOLMES]->_sequenceNumber; _savedPos.y = _data[HOLMES]->_position.y;
_savedPos._facing = _data[HOLMES]->_sequenceNumber;
} }
} }

View file

@ -267,15 +267,13 @@ OpcodeReturn TattooTalk::cmdGotoScene(const byte *&str) {
// Run a canimation? // Run a canimation?
if (str[2] > 100) { if (str[2] > 100) {
people._hSavedFacing = str[2]; people._savedPos = PositionFacing(160, 100, str[2]);
people._hSavedPos = Point32(160, 100);
} else { } else {
people._hSavedFacing = str[2] - 1;
int32 posX = (str[3] - 1) * 256 + str[4] - 1; int32 posX = (str[3] - 1) * 256 + str[4] - 1;
if (posX > 16384) if (posX > 16384)
posX = -1 * (posX - 16384); posX = -1 * (posX - 16384);
int32 posY = (str[5] - 1) * 256 + str[6] - 1; int32 posY = (str[5] - 1) * 256 + str[6] - 1;
people._hSavedPos = Point32(posX, posY); people._savedPos = PositionFacing(posX, posY, str[2] - 1);
} }
_scriptMoreFlag = 1; _scriptMoreFlag = 1;

View file

@ -45,7 +45,6 @@ class TattooUserInterface : public UserInterface {
private: private:
int _lockoutTimer; int _lockoutTimer;
SaveMode _fileMode; SaveMode _fileMode;
int _exitZone;
int _scriptZone; int _scriptZone;
int _cAnimFramePause; int _cAnimFramePause;
WidgetInventory _inventoryWidget; WidgetInventory _inventoryWidget;

View file

@ -46,6 +46,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) {
_helpStyle = false; _helpStyle = false;
_windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, SHERLOCK_SCREEN_HEIGHT - 1); _windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, SHERLOCK_SCREEN_HEIGHT - 1);
_lookScriptFlag = false; _lookScriptFlag = false;
_exitZone = -1;
_bgFound = _oldBgFound = -1; _bgFound = _oldBgFound = -1;
_key = _oldKey = '\0'; _key = _oldKey = '\0';
@ -193,6 +194,7 @@ void UserInterface::reset() {
_bgFound = _oldBgFound = -1; _bgFound = _oldBgFound = -1;
_oldKey = -1; _oldKey = -1;
_oldTemp = _temp = -1; _oldTemp = _temp = -1;
_exitZone = -1;
} }

View file

@ -73,6 +73,7 @@ public:
Common::Rect _windowBounds; Common::Rect _windowBounds;
bool _lookScriptFlag; bool _lookScriptFlag;
int _bgFound, _oldBgFound; int _bgFound, _oldBgFound;
int _exitZone;
// TODO: Not so sure these should be in the base class. May want to refactor them to SherlockEngine, or refactor // TODO: Not so sure these should be in the base class. May want to refactor them to SherlockEngine, or refactor
// various Scalpel dialogs to keep their own private state of key/selections // various Scalpel dialogs to keep their own private state of key/selections