aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-05-02 18:15:24 -1000
committerPaul Gilbert2015-05-02 18:15:24 -1000
commit0a2c50deb5c61500410a91556ed5e3ceb0cc9742 (patch)
treeadcdb3625a30e7fdd58cfd6fe1b604bdaa3faabc /engines
parentf97e550d8631bc1821da1c126ae545db15769c9c (diff)
downloadscummvm-rg350-0a2c50deb5c61500410a91556ed5e3ceb0cc9742.tar.gz
scummvm-rg350-0a2c50deb5c61500410a91556ed5e3ceb0cc9742.tar.bz2
scummvm-rg350-0a2c50deb5c61500410a91556ed5e3ceb0cc9742.zip
SHERLOCK: Revised door close fix due to new bug when entering morgue
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/scene.cpp31
-rw-r--r--engines/sherlock/scene.h7
2 files changed, 23 insertions, 15 deletions
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index e3c1799d66..6e7f628616 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -83,6 +83,17 @@ void SceneSound::synchronize(Common::SeekableReadStream &s) {
/*----------------------------------------------------------------*/
+int ObjectArray::indexOf(const Object &obj) const {
+ for (uint idx = 0; idx < size(); ++idx) {
+ if (&(*this)[idx] == &obj)
+ return idx;
+ }
+
+ return -1;
+}
+
+/*----------------------------------------------------------------*/
+
Scene::Scene(SherlockEngine *vm): _vm(vm) {
for (int idx = 0; idx < SCENES_COUNT; ++idx)
Common::fill(&_sceneStats[idx][0], &_sceneStats[idx][65], false);
@@ -1047,18 +1058,9 @@ int Scene::startCAnim(int cAnimNum, int playRate) {
if (cObj._frameNumber <= 26)
gotoCode = cObj._sequences[cObj._frameNumber + 3];
- // Set canim to REMOVE type and free memory
- cObj.checkObject();
- for (uint idx = 0; idx < _canimShapes.size(); ++idx) {
- if (&_canimShapes[idx] == &cObj) {
- // Do a final call to doBgAnim to erase the anim shape before it's erased
- doBgAnim();
-
- // Remove the completed sprite from the animation shapes array
- _canimShapes.remove_at(idx);
- break;
- }
- }
+ // Unless anim shape has already been freed, set it to REMOVE so doBgAnim can free it
+ if (_canimShapes.indexOf(cObj) != -1)
+ cObj.checkObject();
if (gotoCode > 0 && !talk._talkToAbort) {
_goToScene = gotoCode;
@@ -1377,13 +1379,14 @@ void Scene::doBgAnim() {
}
}
- for (uint idx = 0; idx < _canimShapes.size(); ++idx) {
+ for (int idx = _canimShapes.size() - 1; idx >= 0; --idx) {
Object &o = _canimShapes[idx];
if (o._type == REMOVE) {
if (_goToScene == -1)
screen.slamArea(o._position.x, o._position.y, o._delta.x, o._delta.y);
- _canimShapes[idx]._type = INVALID;
+ // Shape for an animation is no longer needed, so remove it completely
+ _canimShapes.remove_at(idx);
} else if (o._type == ACTIVE_BG_SHAPE) {
screen.flushImage(o._imageFrame, o._position,
&o._oldPosition.x, &o._oldPosition.y, &o._oldSize.x, &o._oldSize.y);
diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h
index 7ee7db1119..c2cca8bad2 100644
--- a/engines/sherlock/scene.h
+++ b/engines/sherlock/scene.h
@@ -83,6 +83,11 @@ struct SceneSound {
void synchronize(Common::SeekableReadStream &s);
};
+class ObjectArray: public Common::Array<Object> {
+public:
+ int indexOf(const Object &obj) const;
+};
+
class Scene {
private:
SherlockEngine *_vm;
@@ -127,7 +132,7 @@ public:
Common::Array<Exit> _exits;
SceneEntry _entrance;
Common::Array<SceneSound> _sounds;
- Common::Array<Object> _canimShapes;
+ ObjectArray _canimShapes;
bool _restoreFlag;
int _animating;
bool _doBgAnimDone;