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