- fixed a bug with Flagstones of Trokair. There was no easy fix (cloned objects deleting stuff from their parents...) and I ended up using a "garbage collect at end of turn" technique the way I did with the ActionStack. As a result, the memory print of a turn will become bigger, and even more bugs might occur at the end of a turn... I'm ready to discuss this, although I think it's the best solution (in terms of result/amount of work) given the way abilities work right now
- Test suite now gives the number of failed/success at the end of the tests
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-09-26 14:25:29 +00:00
parent bb83817c82
commit 0bf83b6bf5
10 changed files with 76 additions and 41 deletions

View File

@@ -14,6 +14,27 @@ MTGAbility* ActionLayer::getAbility(int type){
return NULL;
}
int ActionLayer::moveToGarbage(ActionElement * e){
int i = getIndexOf(e);
if (i != -1){
e->destroy();
mObjects.erase(mObjects.begin()+i);
mCount--;
garbage.push_back(e);
return 1;
}
return 0;
}
int ActionLayer::cleanGarbage(){
for (size_t i = 0; i < garbage.size(); ++i){
delete(garbage[i]);
}
garbage.clear();
return 1;
}
int ActionLayer::reactToClick(ActionElement * ability, MTGCardInstance * card){
int result = ability->reactToClick(card);
if (result) stuffHappened = 1;
@@ -72,7 +93,7 @@ void ActionLayer::Update(float dt){
if (mObjects[i]!= NULL){
ActionElement * currentAction = (ActionElement *)mObjects[i];
if (currentAction->testDestroy())
game->removeObserver(currentAction);
game->removeObserver(currentAction);
}
}
int newPhase = game->getCurrentGamePhase();
@@ -254,4 +275,5 @@ void ActionLayer::ButtonPressed(int controllerid, int controlid){
ActionLayer::~ActionLayer(){
SAFE_DELETE(abilitiesMenu);
cleanGarbage();
}