[Scummvm-cvs-logs] scummvm master -> 0f02cdb4aa0a0e29bea414583a6db8a5ae389f49
dreammaster
dreammaster at scummvm.org
Sat Mar 14 15:12:19 CET 2015
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0f02cdb4aa MADS: Fix crash in stream crossing death, simplify SpriteSets class
Commit: 0f02cdb4aa0a0e29bea414583a6db8a5ae389f49
https://github.com/scummvm/scummvm/commit/0f02cdb4aa0a0e29bea414583a6db8a5ae389f49
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-03-14T10:11:19-04:00
Commit Message:
MADS: Fix crash in stream crossing death, simplify SpriteSets class
Changed paths:
engines/mads/game.cpp
engines/mads/player.cpp
engines/mads/scene.cpp
engines/mads/sprites.cpp
engines/mads/sprites.h
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 74c2a3f..b601a12 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -160,7 +160,7 @@ void Game::gameLoop() {
sectionLoop();
_player.releasePlayerSprites();
- assert(_scene._sprites._assetCount == 0);
+ assert(_scene._sprites.size() == 0);
_vm->_palette->unlock();
_vm->_events->waitCursor();
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 38e8638..f61a5a1 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -709,7 +709,7 @@ void Player::releasePlayerSprites() {
_spritesLoaded = false;
_spritesChanged = true;
- if (scene._sprites._assetCount > 0) {
+ if (scene._sprites.size() > 0) {
warning("Player::releasePlayerSprites(): leftover sprites remain, clearing list");
scene._sprites.clear();
}
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index bbc83a7..463d4a6 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -676,7 +676,7 @@ void Scene::freeCurrentScene() {
}
void Scene::removeSprites() {
- for (int idx = _sprites._assetCount - 1; idx >= _spritesCount; --idx)
+ for (int idx = _sprites.size() - 1; idx >= _spritesCount; --idx)
_sprites.remove(idx);
}
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 19742e2..6488add 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -368,19 +368,18 @@ SpriteSets::~SpriteSets() {
}
int SpriteSets::add(SpriteAsset *asset, int idx) {
- if (idx)
- idx = idx + 49;
- else
- idx = _assetCount++;
+ if (idx) {
+ assert(idx == 1);
+ delete _uiSprites;
+ _uiSprites = asset;
- if (idx >= (int)size())
- resize(idx + 1);
+ return SPRITE_SLOTS_MAX_SIZE;
+ } else {
+ assert(size() < SPRITE_SLOTS_MAX_SIZE);
+ push_back(asset);
- if ((*this)[idx])
- delete (*this)[idx];
-
- (*this)[idx] = asset;
- return idx;
+ return (int)size() - 1;
+ }
}
int SpriteSets::addSprites(const Common::String &resName, int flags) {
@@ -390,26 +389,29 @@ int SpriteSets::addSprites(const Common::String &resName, int flags) {
void SpriteSets::clear() {
for (uint i = 0; i < size(); ++i)
delete (*this)[i];
-
- _assetCount = 0;
Common::Array<SpriteAsset *>::clear();
+
+ delete _uiSprites;
+ _uiSprites = nullptr;
}
void SpriteSets::remove(int idx) {
- if (idx >= 0) {
- if (idx < ((int)size() - 1)) {
- delete (*this)[idx];
- (*this)[idx] = nullptr;
- } else {
- do {
- delete (*this)[size() - 1];
- remove_at(size() - 1);
- } while (size() > 0 && (*this)[size() - 1] == nullptr);
- }
+ if (idx == SPRITE_SLOTS_MAX_SIZE) {
+ delete _uiSprites;
+ _uiSprites = nullptr;
+ } else if (idx >= 0) {
+ delete (*this)[idx];
- if (idx < 50 && _assetCount > 0)
- --_assetCount;
+ if (idx == ((int)size() - 1))
+ remove_at(size() - 1);
+ else
+ (*this)[idx] = nullptr;
}
}
+SpriteAsset *&SpriteSets::operator[](int idx) {
+ return (idx == SPRITE_SLOTS_MAX_SIZE) ? _uiSprites :
+ Common::Array<SpriteAsset *>::operator[](idx);
+}
+
} // End of namespace MADS
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 6ea3c9e..bb5fdbe 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -202,12 +202,12 @@ class SpriteSets : public Common::Array<SpriteAsset *> {
private:
MADSEngine *_vm;
public:
- int _assetCount;
-
+ SpriteAsset *_uiSprites;
+public:
/**
* Constructor
*/
- SpriteSets(MADSEngine *vm) : _vm(vm), _assetCount(0) {}
+ SpriteSets(MADSEngine *vm) : _vm(vm), _uiSprites(nullptr) {}
/**
* Destructor
@@ -233,6 +233,8 @@ public:
* Remove an asset from the list
*/
void remove(int idx);
+
+ SpriteAsset *&operator[](int idx);
};
} // End of namespace MADS
More information about the Scummvm-git-logs
mailing list