- Removed "isClone" flag. This flag was error prone. The "core" classes now have decent copy constructors, and ideally long term we should create copy constructors for the abilities that have additional pointers in them.

-- The test suite passes but this is a big change. I might have introduced some memory leaks or bugs. I might have fixed some bugs, too
This commit is contained in:
wagic.the.homebrew
2011-07-27 14:31:27 +00:00
parent a26125ee4c
commit ef5e011e23
14 changed files with 520 additions and 610 deletions
+5 -4
View File
@@ -274,8 +274,7 @@ ManaCost::ManaCost(ManaCost * manaCost)
morph = NEW ManaCost( manaCost->morph );
suspend = NEW ManaCost( manaCost->suspend );
// TODO: Need to figure out if a deep copy is necessary
extraCosts = manaCost->extraCosts;
extraCosts = manaCost->extraCosts ? manaCost->extraCosts->clone() : NULL;
}
// Copy Constructor
@@ -301,8 +300,7 @@ ManaCost::ManaCost(const ManaCost& manaCost)
morph = NEW ManaCost( manaCost.morph );
suspend = NEW ManaCost( manaCost.suspend );
// TODO: Need to figure out if a deep copy is necessary
extraCosts = manaCost.extraCosts;
extraCosts = manaCost.extraCosts ? manaCost.extraCosts->clone() : NULL;
}
// operator=
@@ -674,6 +672,9 @@ int ManaCost::tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybr
//compute the difference between two mana costs
ManaCost * ManaCost::Diff(ManaCost * _cost)
{
if (!_cost)
return NEW ManaCost(*this); //diff with null is equivalent to diff with 0
int8_t diff[(Constants::MTG_NB_COLORS + 1) * 2];
diff[Constants::MTG_NB_COLORS * 2] = Constants::MTG_NB_COLORS;
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)