Replaced ManaCost's int array with int8_t. Shrinks ManaCost by another 24 bytes, which in turn lowers CardPrimitive's footprint by the same amount.
This commit is contained in:
@@ -3857,7 +3857,7 @@ public:
|
|||||||
MTGAbility(id, _source)
|
MTGAbility(id, _source)
|
||||||
{
|
{
|
||||||
counters = 0;
|
counters = 0;
|
||||||
int _cost[] = { Constants::MTG_COLOR_ARTIFACT, 4 };
|
int8_t _cost[] = { Constants::MTG_COLOR_ARTIFACT, 4 };
|
||||||
cost = ManaCost(_cost, 1);
|
cost = ManaCost(_cost, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3921,7 +3921,7 @@ public:
|
|||||||
MTGAbility(_id, _source)
|
MTGAbility(_id, _source)
|
||||||
{
|
{
|
||||||
canprevent = 0;
|
canprevent = 0;
|
||||||
int _cost[] = { Constants::MTG_COLOR_ARTIFACT, 2 };
|
int8_t _cost[] = { Constants::MTG_COLOR_ARTIFACT, 2 };
|
||||||
cost = ManaCost(_cost, 1);
|
cost = ManaCost(_cost, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4017,7 +4017,7 @@ public:
|
|||||||
AFarmstead(int _id, MTGCardInstance * source, MTGCardInstance * _target) :
|
AFarmstead(int _id, MTGCardInstance * source, MTGCardInstance * _target) :
|
||||||
ActivatedAbility(_id, source, 0, 1)
|
ActivatedAbility(_id, source, 0, 1)
|
||||||
{
|
{
|
||||||
int _cost[] = { Constants::MTG_COLOR_WHITE, 2 };
|
int8_t _cost[] = { Constants::MTG_COLOR_WHITE, 2 };
|
||||||
cost = NEW ManaCost(_cost, 1);
|
cost = NEW ManaCost(_cost, 1);
|
||||||
target = _target;
|
target = _target;
|
||||||
usedThisTurn = 0;
|
usedThisTurn = 0;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class ManaCost
|
|||||||
friend std::ostream& operator<<(std::ostream& out, ManaCost m);
|
friend std::ostream& operator<<(std::ostream& out, ManaCost m);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int cost[Constants::MTG_NB_COLORS+1];
|
int8_t cost[Constants::MTG_NB_COLORS+1];
|
||||||
std::vector<ManaCostHybrid> hybrids;
|
std::vector<ManaCostHybrid> hybrids;
|
||||||
|
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
virtual void reinit();
|
virtual void reinit();
|
||||||
void x();
|
void x();
|
||||||
int hasX();
|
int hasX();
|
||||||
ManaCost(int _cost[], int nb_elems = 1);
|
ManaCost(int8_t _cost[], int nb_elems = 1);
|
||||||
ManaCost();
|
ManaCost();
|
||||||
~ManaCost();
|
~ManaCost();
|
||||||
ManaCost(ManaCost * _manaCost);
|
ManaCost(ManaCost * _manaCost);
|
||||||
@@ -82,8 +82,8 @@ public:
|
|||||||
int doPayExtra();
|
int doPayExtra();
|
||||||
|
|
||||||
int addHybrid(int c1, int v1, int c2, int v2);
|
int addHybrid(int c1, int v1, int c2, int v2);
|
||||||
int tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids, int diff[]);
|
int tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids, int8_t diff[]);
|
||||||
void randomDiffHybrids(ManaCost * _cost, int diff[]);
|
void randomDiffHybrids(ManaCost * _cost, int8_t diff[]);
|
||||||
int add(ManaCost * _cost);
|
int add(ManaCost * _cost);
|
||||||
int remove(ManaCost * _cost);
|
int remove(ManaCost * _cost);
|
||||||
int removeAll(int color);
|
int removeAll(int color);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ int AIMomirPlayer::momir()
|
|||||||
|
|
||||||
if (efficiency >= chance)
|
if (efficiency >= chance)
|
||||||
{
|
{
|
||||||
int _cost[] = { Constants::MTG_COLOR_ARTIFACT, converted };
|
int8_t _cost[] = { Constants::MTG_COLOR_ARTIFACT, converted };
|
||||||
ManaCost * cost = NEW ManaCost(_cost);
|
ManaCost * cost = NEW ManaCost(_cost);
|
||||||
MTGAbility * ability = getMomirAbility();
|
MTGAbility * ability = getMomirAbility();
|
||||||
MTGCardInstance * card = game->hand->cards[0];
|
MTGCardInstance * card = game->hand->cards[0];
|
||||||
|
|||||||
@@ -2710,7 +2710,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
|||||||
|
|
||||||
case 1103: //Crystal Rod
|
case 1103: //Crystal Rod
|
||||||
{
|
{
|
||||||
int cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||||
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_BLUE, NEW ManaCost(cost, 1), 1);
|
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_BLUE, NEW ManaCost(cost, 1), 1);
|
||||||
game->addObserver(ability);
|
game->addObserver(ability);
|
||||||
break;
|
break;
|
||||||
@@ -2742,7 +2742,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
|||||||
}
|
}
|
||||||
case 1113: //Iron Star
|
case 1113: //Iron Star
|
||||||
{
|
{
|
||||||
int cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||||
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_RED, NEW ManaCost(cost, 1), 1);
|
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_RED, NEW ManaCost(cost, 1), 1);
|
||||||
game->addObserver(ability);
|
game->addObserver(ability);
|
||||||
break;
|
break;
|
||||||
@@ -2754,7 +2754,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
|||||||
}
|
}
|
||||||
case 1114: //Ivory cup
|
case 1114: //Ivory cup
|
||||||
{
|
{
|
||||||
int cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||||
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_WHITE, NEW ManaCost(cost, 1), 1);
|
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_WHITE, NEW ManaCost(cost, 1), 1);
|
||||||
game->addObserver(ability);
|
game->addObserver(ability);
|
||||||
break;
|
break;
|
||||||
@@ -2827,7 +2827,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
|||||||
|
|
||||||
case 1140: //Throne of Bone
|
case 1140: //Throne of Bone
|
||||||
{
|
{
|
||||||
int cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||||
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_BLACK, NEW ManaCost(cost, 1), 1);
|
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_BLACK, NEW ManaCost(cost, 1), 1);
|
||||||
game->addObserver(ability);
|
game->addObserver(ability);
|
||||||
break;
|
break;
|
||||||
@@ -2835,7 +2835,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
|||||||
|
|
||||||
case 1142: //Wooden Sphere
|
case 1142: //Wooden Sphere
|
||||||
{
|
{
|
||||||
int cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||||
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_GREEN, NEW ManaCost(cost, 1), 1);
|
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_GREEN, NEW ManaCost(cost, 1), 1);
|
||||||
game->addObserver(ability);
|
game->addObserver(ability);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ ManaCost::ManaCost()
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ManaCost::ManaCost(int _cost[], int nb_elems)
|
ManaCost::ManaCost(int8_t _cost[], int nb_elems)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
for (int i = 0; i < nb_elems; i++)
|
for (int i = 0; i < nb_elems; i++)
|
||||||
@@ -624,7 +624,7 @@ int ManaCost::isPositive()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManaCost::randomDiffHybrids(ManaCost * _cost, int diff[])
|
void ManaCost::randomDiffHybrids(ManaCost * _cost, int8_t diff[])
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < _cost->hybrids.size(); i++)
|
for (size_t i = 0; i < _cost->hybrids.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -636,7 +636,7 @@ void ManaCost::randomDiffHybrids(ManaCost * _cost, int diff[])
|
|||||||
/**
|
/**
|
||||||
starting from the end of the array (diff)
|
starting from the end of the array (diff)
|
||||||
*/
|
*/
|
||||||
int ManaCost::tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids, int diff[])
|
int ManaCost::tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids, int8_t diff[])
|
||||||
{
|
{
|
||||||
if (!_nbhybrids)
|
if (!_nbhybrids)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -664,7 +664,7 @@ int ManaCost::tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybr
|
|||||||
//compute the difference between two mana costs
|
//compute the difference between two mana costs
|
||||||
ManaCost * ManaCost::Diff(ManaCost * _cost)
|
ManaCost * ManaCost::Diff(ManaCost * _cost)
|
||||||
{
|
{
|
||||||
int diff[(Constants::MTG_NB_COLORS + 1) * 2];
|
int8_t diff[(Constants::MTG_NB_COLORS + 1) * 2];
|
||||||
diff[Constants::MTG_NB_COLORS * 2] = Constants::MTG_NB_COLORS;
|
diff[Constants::MTG_NB_COLORS * 2] = Constants::MTG_NB_COLORS;
|
||||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user