CGE2: Implement Spare::dispose(), add Spare::update().

This commit is contained in:
uruk 2014-05-18 11:37:06 +02:00
parent 3e97ade388
commit 938a2e66c2
2 changed files with 15 additions and 6 deletions

View File

@ -58,16 +58,24 @@ void Spare::store(Sprite *spr) {
_container.insert_at(_container.size(), spr);
}
void Spare::dispose(Sprite *spr) {
warning("STUB: Spare::Dispose()");
void Spare::update(Sprite *spr) {
Sprite *sp = locate(spr->_ref);
if (sp == nullptr)
store(spr);
}
void Spare::dispose(Sprite *spr) {
if (spr) {
_vm->_vga->_showQ->remove(spr);
for (int i = 0; i < _container.size(); i++) {
if (spr == _container[i]) {
_container.remove_at(i);
update(spr->contract());
if (spr->_ref / 10 != 14) { // IIRC if it's == 14, it's the sprite of a Hero. No idea yet why it shouldn't be deleted then.
for (int i = 0; i < _container.size(); i++) {
if (spr == _container[i]) {
_container.remove_at(i);
}
}
delete spr;
}
}
}

View File

@ -41,6 +41,7 @@ public:
void store(Sprite *spr);
Sprite *locate(int ref);
void takeCave(int ref); // Note that it takes the ref of the sprite now, not the number of the scene, like the original!
void update(Sprite *spr);
void dispose(Sprite *spr);
void dispose(int ref);
void dispose();