aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-08-16 13:42:58 -0400
committerPaul Gilbert2015-08-16 13:42:58 -0400
commit8950549b440d6649bf1021015f72c2af919703fe (patch)
tree5a9c255a815d77f5be062e4b2266dbf7cd9cb2d3
parent621a37bbe30756a7983c1e5463389539898d41a5 (diff)
downloadscummvm-rg350-8950549b440d6649bf1021015f72c2af919703fe.tar.gz
scummvm-rg350-8950549b440d6649bf1021015f72c2af919703fe.tar.bz2
scummvm-rg350-8950549b440d6649bf1021015f72c2af919703fe.zip
SHERLOCK: Further fixes to character movement across saves
Restoring movement across save didn't work, so properly handle stopping any moving characters when loading a savegame
-rw-r--r--engines/sherlock/people.cpp46
-rw-r--r--engines/sherlock/people.h17
-rw-r--r--engines/sherlock/saveload.cpp4
-rw-r--r--engines/sherlock/scalpel/scalpel_people.cpp10
-rw-r--r--engines/sherlock/tattoo/tattoo_people.cpp15
5 files changed, 17 insertions, 75 deletions
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp
index 25f379b68b..739abb0c07 100644
--- a/engines/sherlock/people.cpp
+++ b/engines/sherlock/people.cpp
@@ -64,40 +64,6 @@ const char *const WALK_LIB_NAMES[NUM_IN_WALK_LIB] = {
/*----------------------------------------------------------------*/
-void PointQueue::push(const Common::Point &pt) {
- _impl.push_back(pt);
-}
-
-Common::Point PointQueue::pop() {
- Common::Point tmp = front();
- _impl.pop_front();
- return tmp;
-}
-
-void PointQueue::synchronize(Common::Serializer &s) {
- int count = _impl.size();
- s.syncAsUint16LE(count);
-
- if (s.isSaving()) {
- for (Common::List<Common::Point>::iterator i = _impl.begin(); i != _impl.end(); ++i) {
- Common::Point &pt = *i;
- s.syncAsSint16LE(pt.x);
- s.syncAsSint16LE(pt.y);
- }
- } else {
- int xp, yp;
-
- _impl.clear();
- for (int idx = 0; idx < count; ++idx) {
- s.syncAsSint16LE(xp);
- s.syncAsSint16LE(yp);
- _impl.push_back(Common::Point(xp, yp));
- }
- }
-}
-
-/*----------------------------------------------------------------*/
-
Person::Person() : Sprite() {
_walkLoaded = false;
_oldWalkSequence = -1;
@@ -219,25 +185,19 @@ void People::reset() {
if (IS_SERRATED_SCALPEL) {
p._type = CHARACTER;
- p._sequenceNumber = (int)Tattoo::STOP_DOWNRIGHT;
p._position = Point32(100 * FIXED_INT_MULTIPLIER, 110 * FIXED_INT_MULTIPLIER);
} else if (!talk._scriptMoreFlag && !saves._justLoaded) {
p._type = (idx == 0) ? CHARACTER : INVALID;
- p._sequenceNumber = (int)Scalpel::STOP_DOWNRIGHT;
p._position = Point32(36 * FIXED_INT_MULTIPLIER, 29 * FIXED_INT_MULTIPLIER);
p._use[0]._verb = "";
p._use[1]._verb = "";
}
- if (!saves._justLoaded) {
- p._walkCount = 0;
- p._walkTo.clear();
- p._delta = Point32(0, 0);
- }
-
+ p._sequenceNumber = IS_SERRATED_SCALPEL ? (int)Tattoo::STOP_DOWNRIGHT : (int)Tattoo::STOP_DOWNRIGHT;
p._imageFrame = nullptr;
p._frameNumber = 1;
p._startSeq = 0;
+ p._delta = Point32(0, 0);
p._oldPosition = Common::Point(0, 0);
p._oldSize = Common::Point(0, 0);
p._misc = 0;
@@ -258,6 +218,8 @@ void People::reset() {
p._adjust = Common::Point(0, 0);
// Load the default walk sequences
+ p._walkCount = 0;
+ p._walkTo.clear();
p._oldWalkSequence = -1;
p._walkSequences.clear();
if (IS_SERRATED_SCALPEL) {
diff --git a/engines/sherlock/people.h b/engines/sherlock/people.h
index b97dc715cc..d790e4ccb0 100644
--- a/engines/sherlock/people.h
+++ b/engines/sherlock/people.h
@@ -56,21 +56,6 @@ struct PersonData {
_name(name), _portrait(portrait), _stillSequences(stillSequences), _talkSequences(talkSequences) {}
};
-class PointQueue {
-private:
- Common::List<Common::Point> _impl;
-public:
- PointQueue() : _impl() {}
-
- bool empty() const { return _impl.empty(); }
- void clear() { _impl.clear(); }
- Common::Point &front() { return _impl.front(); }
- const Common::Point &front() const { return _impl.front(); }
- void push(const Common::Point &pt);
- Common::Point pop();
- void synchronize(Common::Serializer &s);
-};
-
class Person : public Sprite {
protected:
/**
@@ -78,7 +63,7 @@ protected:
*/
virtual Common::Point getSourcePoint() const = 0;
public:
- PointQueue _walkTo;
+ Common::Queue<Common::Point> _walkTo;
int _srcZone, _destZone;
bool _walkLoaded;
Common::String _portrait;
diff --git a/engines/sherlock/saveload.cpp b/engines/sherlock/saveload.cpp
index c20f783bfd..f32552c7ea 100644
--- a/engines/sherlock/saveload.cpp
+++ b/engines/sherlock/saveload.cpp
@@ -201,6 +201,7 @@ void SaveManager::createThumbnail() {
}
void SaveManager::loadGame(int slot) {
+ Events &events = *_vm->_events;
Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
generateSaveName(slot));
if (!saveFile)
@@ -222,9 +223,11 @@ void SaveManager::loadGame(int slot) {
synchronize(s);
delete saveFile;
+ events.clearEvents();
}
void SaveManager::saveGame(int slot, const Common::String &name) {
+ Events &events = *_vm->_events;
Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(
generateSaveName(slot));
@@ -239,6 +242,7 @@ void SaveManager::saveGame(int slot, const Common::String &name) {
out->finalize();
delete out;
+ events.clearEvents();
}
Common::String SaveManager::generateSaveName(int slot) {
diff --git a/engines/sherlock/scalpel/scalpel_people.cpp b/engines/sherlock/scalpel/scalpel_people.cpp
index 9ff3127020..0b8caf3721 100644
--- a/engines/sherlock/scalpel/scalpel_people.cpp
+++ b/engines/sherlock/scalpel/scalpel_people.cpp
@@ -371,15 +371,11 @@ Common::Point ScalpelPerson::getSourcePoint() const {
}
void ScalpelPerson::synchronize(Serializer &s) {
+ if (_walkCount)
+ gotoStand();
+
s.syncAsSint32LE(_position.x);
s.syncAsSint32LE(_position.y);
- s.syncAsSint32LE(_delta.x);
- s.syncAsSint32LE(_delta.y);
- s.syncAsSint16LE(_sequenceNumber);
- s.syncAsSint16LE(_walkCount);
-
- // Walk to list
- _walkTo.synchronize(s);
}
/*----------------------------------------------------------------*/
diff --git a/engines/sherlock/tattoo/tattoo_people.cpp b/engines/sherlock/tattoo/tattoo_people.cpp
index 19010a6578..c5b03b285d 100644
--- a/engines/sherlock/tattoo/tattoo_people.cpp
+++ b/engines/sherlock/tattoo/tattoo_people.cpp
@@ -968,20 +968,18 @@ void TattooPerson::checkWalkGraphics() {
}
void TattooPerson::synchronize(Serializer &s) {
- s.syncAsSint32LE(_position.x);
- s.syncAsSint32LE(_position.y);
- s.syncAsSint32LE(_delta.x);
- s.syncAsSint32LE(_delta.y);
- s.syncAsSint16LE(_sequenceNumber);
- s.syncAsSint16LE(_walkCount);
-
if (s.isSaving()) {
SpriteType type = (_type == INVALID && _walkLoaded) ? HIDDEN_CHARACTER : _type;
s.syncAsSint16LE(type);
} else {
+ if (_walkCount)
+ gotoStand();
+
s.syncAsSint16LE(_type);
}
+ s.syncAsSint32LE(_position.x);
+ s.syncAsSint32LE(_position.y);
s.syncString(_walkVGSName);
s.syncString(_description);
s.syncString(_examine);
@@ -992,9 +990,6 @@ void TattooPerson::synchronize(Serializer &s) {
s.syncAsSint32LE(_npcPause);
s.syncAsByte(_lookHolmes);
s.syncAsByte(_updateNPCPath);
-
- // Walk to list
- _walkTo.synchronize(s);
// Verbs
for (int idx = 0; idx < 2; ++idx)