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;
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);
people._hSavedPos.y = atoi(s.c_str());
people._savedPos.y = atoi(s.c_str());
s = Common::String(p + 6, p + 9);
people._hSavedFacing = atoi(s.c_str());
if (people._hSavedFacing == 0)
people._hSavedFacing = 10;
people._savedPos._facing = atoi(s.c_str());
if (people._savedPos._facing == 0)
people._savedPos._facing = 10;
} else if ((p = strchr(name.c_str(), '/')) != nullptr) {
people._hSavedPos = Common::Point(1, 0);
people._hSavedFacing = 100 + atoi(p + 1);
people._savedPos = PositionFacing(1, 0, 100 + atoi(p + 1));
}
} else {
scene._goToScene = 100;

View File

@ -122,6 +122,11 @@ public:
int _facing;
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 {

View File

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

View File

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

View File

@ -922,8 +922,8 @@ void ScalpelEngine::startScene() {
_scene->_goToScene = _map->show();
_music->freeSong();
_people->_hSavedPos = Common::Point(-1, -1);
_people->_hSavedFacing = -1;
_people->_savedPos = Common::Point(-1, -1);
_people->_savedPos._facing = -1;
}
// 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;
if (exit->_newPosition.x != 0) {
people._hSavedPos = exit->_newPosition;
people._hSavedFacing = exit->_newFacing;
people._savedPos = exit->_newPosition;
if (people._hSavedFacing > 100 && people._hSavedPos.x < 1)
people._hSavedPos.x = 100;
if (people._savedPos._facing > 100 && people._savedPos.x < 1)
people._savedPos.x = 100;
}
}
}
@ -444,8 +443,8 @@ void ScalpelPeople::synchronize(Serializer &s) {
s.syncAsSint16LE(_holmesQuotient);
if (s.isLoading()) {
_hSavedPos = _data[HOLMES]->_position;
_hSavedFacing = _data[HOLMES]->_sequenceNumber;
_savedPos = _data[HOLMES]->_position;
_savedPos._facing = _data[HOLMES]->_sequenceNumber;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,6 +23,7 @@
#include "sherlock/tattoo/tattoo_people.h"
#include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/tattoo/tattoo_talk.h"
#include "sherlock/tattoo/tattoo_user_interface.h"
#include "sherlock/tattoo/tattoo.h"
namespace Sherlock {
@ -131,6 +132,7 @@ void TattooPerson::freeAltGraphics() {
void TattooPerson::adjustSprite() {
People &people = *_vm->_people;
TattooScene &scene = *(TattooScene *)_vm->_scene;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
if (_type == INVALID)
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.
// 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)) {
people._hSavedPos = scene._exits[scene._exitZone]._newPosition;
people._hSavedFacing = scene._exits[scene._exitZone]._newFacing;
Exit &exit = scene._exits[ui._exitZone];
scene._goToScene = exit._scene;
if (people._hSavedFacing > 100 && people._hSavedPos.x < 1)
people._hSavedPos.x = 100;
if (exit._newPosition.x != 0) {
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);
if (s.isLoading()) {
_hSavedPos = _data[HOLMES]->_position;
_hSavedFacing = _data[HOLMES]->_sequenceNumber;
_savedPos.x = _data[HOLMES]->_position.x;
_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?
if (str[2] > 100) {
people._hSavedFacing = str[2];
people._hSavedPos = Point32(160, 100);
people._savedPos = PositionFacing(160, 100, str[2]);
} else {
people._hSavedFacing = str[2] - 1;
int32 posX = (str[3] - 1) * 256 + str[4] - 1;
if (posX > 16384)
posX = -1 * (posX - 16384);
int32 posY = (str[5] - 1) * 256 + str[6] - 1;
people._hSavedPos = Point32(posX, posY);
people._savedPos = PositionFacing(posX, posY, str[2] - 1);
}
_scriptMoreFlag = 1;

View File

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

View File

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

View File

@ -73,6 +73,7 @@ public:
Common::Rect _windowBounds;
bool _lookScriptFlag;
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
// various Scalpel dialogs to keep their own private state of key/selections