diff --git a/projects/mtg/include/ExtraCost.h b/projects/mtg/include/ExtraCost.h index eb1360dac..dcdbfafe8 100644 --- a/projects/mtg/include/ExtraCost.h +++ b/projects/mtg/include/ExtraCost.h @@ -26,6 +26,7 @@ public: MTGCardInstance * source; MTGAbility * action; ExtraCosts(); + ~ExtraCosts(); void Render(); int tryToSetPayment(MTGCardInstance * card); int isPaymentSet(); diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index e3def6518..24d12d983 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -113,6 +113,13 @@ int ExtraCosts::doPay(){ } return result; } + +ExtraCosts::~ExtraCosts(){ + for (size_t i = 0; i < costs.size(); i++){ + SAFE_DELETE(costs[i]); + } +} + void ExtraCosts::Dump(){ #ifdef WIN32 char buf[4096]; diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index e598e51fa..88a0db847 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -12,9 +12,6 @@ #endif ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstance * c){ -#if defined (WIN32) || defined (LINUX) - char buf[4096]; -#endif ManaCost * manaCost; if (_manaCost){ manaCost = _manaCost; @@ -159,6 +156,7 @@ void ManaCost::copy(ManaCost * _manaCost){ if (_manaCost->extraCosts){ //TODO Deep copy ? + if(!extraCostsIsCopy) SAFE_DELETE(extraCosts); extraCosts = _manaCost->extraCosts; extraCostsIsCopy = 1; }