diff options
author | uruk | 2014-07-21 19:52:46 +0200 |
---|---|---|
committer | uruk | 2014-07-21 19:52:46 +0200 |
commit | 1176721034b07ddc6517e0a8b96c5eedb0b57e08 (patch) | |
tree | 05150cf21d9de01145883f4fb1c4d4639308f7c8 /engines | |
parent | db9e503cfcca7096a1260c96ed24aef3dc4ed450 (diff) | |
download | scummvm-rg350-1176721034b07ddc6517e0a8b96c5eedb0b57e08.tar.gz scummvm-rg350-1176721034b07ddc6517e0a8b96c5eedb0b57e08.tar.bz2 scummvm-rg350-1176721034b07ddc6517e0a8b96c5eedb0b57e08.zip |
CGE2: Fix the issue of loading sprites with changed _ref.
It fixes the problem with the multiply displayed Vulcanizer after giving him the glasses/basket ball, then saving and loading.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cge2/spare.cpp | 24 | ||||
-rw-r--r-- | engines/cge2/spare.h | 1 |
2 files changed, 23 insertions, 2 deletions
diff --git a/engines/cge2/spare.cpp b/engines/cge2/spare.cpp index 411327e40a..54918f7920 100644 --- a/engines/cge2/spare.cpp +++ b/engines/cge2/spare.cpp @@ -47,7 +47,17 @@ void Spare::sync(Common::Serializer &s) { for (int i = 0; i < size; i++) { Sprite *sprite = new Sprite(_vm); sprite->sync(s); - update(sprite); + + // In case the reference of the sprite is changed comapred to CGE.INI + // TODO: Rework the whole loading so it doesn't load every sprite from CGE.INI + // and then update them, but load everything from file, so this check isn't + // needed anymore. To do that, I also have to save/load the toolbar's sprites too. + Sprite *loc = locate(sprite->_file); + if (loc->_ref != sprite->_ref) { + loc->contract(); + *loc = *sprite; + } else + update(sprite); } } } @@ -67,6 +77,14 @@ Sprite *Spare::locate(int ref) { return nullptr; } +Sprite *Spare::locate(char *file) { + for (uint i = 0; i < _container.size(); ++i) { + if (strcmp(_container[i]->_file, file) == 0) + return _container[i]; + } + return nullptr; +} + Sprite *Spare::take(int ref) { Sprite *spr = nullptr; if ((spr = locate(ref)) != nullptr) { @@ -101,8 +119,10 @@ void Spare::update(Sprite *spr) { Sprite *sp = locate(spr->_ref); if (sp == nullptr) store(spr); - else + else { + sp->contract(); *sp = *spr; + } } void Spare::dispose(Sprite *spr) { diff --git a/engines/cge2/spare.h b/engines/cge2/spare.h index 7dc6ce60f5..cfc158d4b6 100644 --- a/engines/cge2/spare.h +++ b/engines/cge2/spare.h @@ -40,6 +40,7 @@ public: ~Spare() { clear(); } void store(Sprite *spr); Sprite *locate(int ref); + Sprite *locate(char *file); Sprite *take(int ref); void takeScene(int cav); void update(Sprite *spr); |