Erwan
-removed memory leak introduced in r.789 -added "blocked" bool in MTGCardInstance
This commit is contained in:
@@ -39,6 +39,8 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
MTGCardInstance * getNextPartner();
|
||||
void initMTGCI();
|
||||
int setDefenser(MTGCardInstance * c);
|
||||
int addBlocker(MTGCardInstance * c);
|
||||
int removeBlocker(MTGCardInstance * c);
|
||||
int setAttacker(int value);
|
||||
public:
|
||||
Pos* view;
|
||||
@@ -62,6 +64,7 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
const string getDisplayName() const;
|
||||
MTGCardInstance * target;
|
||||
void addType(int type);
|
||||
bool blocked; //Blocked this turn or not?
|
||||
|
||||
//Combat
|
||||
MTGCardInstance * defenser;
|
||||
|
||||
@@ -105,6 +105,7 @@ void MTGCardInstance::initMTGCI(){
|
||||
next = NULL;
|
||||
lastController = NULL;
|
||||
regenerateTokens = 0;
|
||||
blocked = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -171,10 +172,6 @@ int MTGCardInstance::has(int basicAbility){
|
||||
return basicAbilities[basicAbility];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Taps the card
|
||||
void MTGCardInstance::tap(){
|
||||
if (tapped) return;
|
||||
@@ -182,7 +179,6 @@ void MTGCardInstance::tap(){
|
||||
WEvent * e = NEW WEventCardTap(this, 0, 1);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
//delete e;
|
||||
}
|
||||
|
||||
void MTGCardInstance::untap(){
|
||||
@@ -191,7 +187,6 @@ void MTGCardInstance::untap(){
|
||||
WEvent * e = NEW WEventCardTap(this, 1, 0);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
//delete e;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,9 +212,6 @@ int MTGCardInstance::isTapped(){
|
||||
}
|
||||
|
||||
void MTGCardInstance::resetAllDamage(){
|
||||
//for (int i=0;i<nb_damages;i++){
|
||||
// delete damages[i];
|
||||
//}
|
||||
nb_damages = 0;
|
||||
}
|
||||
|
||||
@@ -242,6 +234,7 @@ int MTGCardInstance::initAttackersDefensers(){
|
||||
setDefenser(NULL);
|
||||
banding = NULL;
|
||||
blockers.clear();
|
||||
blocked = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -409,7 +402,6 @@ int MTGCardInstance::setAttacker(int value){
|
||||
attacker = value;
|
||||
WEvent * e = NEW WEventCreatureAttacker(this,previousTarget, target);
|
||||
GameObserver::GetInstance()->receiveEvent(e);
|
||||
//delete e;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -491,6 +483,18 @@ int MTGCardInstance::bringBlockerToFrontOfOrder(MTGCardInstance * blocker){
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MTGCardInstance::removeBlocker(MTGCardInstance * blocker){
|
||||
blockers.remove(blocker);
|
||||
if (!blockers.size()) blocked = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MTGCardInstance::addBlocker(MTGCardInstance * blocker){
|
||||
blockers.push_back(blocker);
|
||||
blocked = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Returns opponents to this card for this turn. This * should * take into account banding
|
||||
MTGCardInstance * MTGCardInstance::getNextOpponent(MTGCardInstance * previous){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
@@ -530,13 +534,13 @@ int MTGCardInstance::setDefenser(MTGCardInstance * opponent){
|
||||
if (defenser) {
|
||||
if (g->players[0]->game->battlefield->hasCard(defenser) ||
|
||||
g->players[1]->game->battlefield->hasCard(defenser) ) {
|
||||
defenser->blockers.remove(this);
|
||||
defenser->removeBlocker(this);
|
||||
}
|
||||
}
|
||||
WEvent * e = NULL;
|
||||
if (defenser != opponent) e = NEW WEventCreatureBlocker(this, defenser, opponent);
|
||||
defenser = opponent;
|
||||
if (defenser) defenser->blockers.push_back(this);
|
||||
if (defenser) defenser->addBlocker(this);
|
||||
if (e) g->receiveEvent(e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,6 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
|
||||
cardsMap.erase(card);
|
||||
for (i=0; i<(nb_cards); i++) {
|
||||
if (cards[i] == card){
|
||||
//cards[i] = cards[nb_cards -1];
|
||||
nb_cards--;
|
||||
cards.erase(cards.begin()+i);
|
||||
MTGCardInstance * copy = card;
|
||||
|
||||
@@ -852,12 +852,14 @@ int WResourceManager::fileOK(string filename, bool relative){
|
||||
else
|
||||
fp = NEW std::ifstream(filename.c_str());
|
||||
|
||||
if(fp && *fp){
|
||||
int result = 0;
|
||||
if(fp){
|
||||
if(*fp) result = 1;
|
||||
fp->close();
|
||||
return 1;
|
||||
delete fp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
int WResourceManager::CreateTexture(const string &textureName) {
|
||||
|
||||
Reference in New Issue
Block a user