|
@@ -140,7 +140,7 @@ CVCMIServer & CGameHandler::gameLobby() const
|
|
|
|
|
|
void CGameHandler::levelUpHero(const CGHeroInstance * hero, SecondarySkill skill)
|
|
|
{
|
|
|
- changeSecSkill(hero, skill, 1, 0);
|
|
|
+ changeSecSkill(hero, skill, 1, ChangeValueMode::RELATIVE);
|
|
|
expGiven(hero);
|
|
|
}
|
|
|
|
|
@@ -161,7 +161,7 @@ void CGameHandler::levelUpHero(const CGHeroInstance * hero)
|
|
|
SetPrimSkill sps;
|
|
|
sps.id = hero->id;
|
|
|
sps.which = primarySkill;
|
|
|
- sps.abs = false;
|
|
|
+ sps.mode = ChangeValueMode::RELATIVE;
|
|
|
sps.val = 1;
|
|
|
sendAndApply(sps);
|
|
|
|
|
@@ -369,7 +369,7 @@ void CGameHandler::giveExperience(const CGHeroInstance * hero, TExpType amountTo
|
|
|
SetPrimSkill sps;
|
|
|
sps.id = hero->id;
|
|
|
sps.which = PrimarySkill::EXPERIENCE;
|
|
|
- sps.abs = false;
|
|
|
+ sps.mode = ChangeValueMode::RELATIVE;
|
|
|
sps.val = amountToGain;
|
|
|
sendAndApply(sps);
|
|
|
|
|
@@ -387,17 +387,17 @@ void CGameHandler::giveExperience(const CGHeroInstance * hero, TExpType amountTo
|
|
|
expGiven(hero);
|
|
|
}
|
|
|
|
|
|
-void CGameHandler::changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs)
|
|
|
+void CGameHandler::changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, ChangeValueMode mode)
|
|
|
{
|
|
|
SetPrimSkill sps;
|
|
|
sps.id = hero->id;
|
|
|
sps.which = which;
|
|
|
- sps.abs = abs;
|
|
|
+ sps.mode = mode;
|
|
|
sps.val = val;
|
|
|
sendAndApply(sps);
|
|
|
}
|
|
|
|
|
|
-void CGameHandler::changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs)
|
|
|
+void CGameHandler::changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, ChangeValueMode mode)
|
|
|
{
|
|
|
if(!hero)
|
|
|
{
|
|
@@ -408,7 +408,7 @@ void CGameHandler::changeSecSkill(const CGHeroInstance * hero, SecondarySkill wh
|
|
|
sss.id = hero->id;
|
|
|
sss.which = which;
|
|
|
sss.val = val;
|
|
|
- sss.abs = abs;
|
|
|
+ sss.mode = mode;
|
|
|
sendAndApply(sss);
|
|
|
|
|
|
if (hero->getVisitedTown())
|
|
@@ -1133,7 +1133,7 @@ void CGameHandler::giveResource(PlayerColor player, GameResID which, int val) //
|
|
|
void CGameHandler::giveResources(PlayerColor player, TResources resources)
|
|
|
{
|
|
|
SetResources sr;
|
|
|
- sr.abs = false;
|
|
|
+ sr.mode = ChangeValueMode::RELATIVE;
|
|
|
sr.player = player;
|
|
|
sr.res = resources;
|
|
|
sendAndApply(sr);
|
|
@@ -1182,7 +1182,7 @@ void CGameHandler::takeCreatures(ObjectInstanceID objid, const std::vector<CStac
|
|
|
{
|
|
|
// take part of the stack
|
|
|
collected = stackToTake.getCount();
|
|
|
- changeStackCount(StackLocation(army->id, armySlot.first), collected - stackToTake.getCount(), false);
|
|
|
+ changeStackCount(StackLocation(army->id, armySlot.first), collected - stackToTake.getCount(), ChangeValueMode::RELATIVE);
|
|
|
}
|
|
|
foundSth = true;
|
|
|
break;
|
|
@@ -1291,12 +1291,12 @@ void CGameHandler::setMovePoints(SetMovePoints * smp)
|
|
|
sendAndApply(*smp);
|
|
|
}
|
|
|
|
|
|
-void CGameHandler::setMovePoints(ObjectInstanceID hid, int val, bool absolute)
|
|
|
+void CGameHandler::setMovePoints(ObjectInstanceID hid, int val, ChangeValueMode mode)
|
|
|
{
|
|
|
SetMovePoints smp;
|
|
|
smp.hid = hid;
|
|
|
smp.val = val;
|
|
|
- smp.absolute = absolute;
|
|
|
+ smp.mode = mode;
|
|
|
sendAndApply(smp);
|
|
|
}
|
|
|
|
|
@@ -1305,7 +1305,7 @@ void CGameHandler::setManaPoints(ObjectInstanceID hid, int val)
|
|
|
SetMana sm;
|
|
|
sm.hid = hid;
|
|
|
sm.val = val;
|
|
|
- sm.absolute = true;
|
|
|
+ sm.mode = ChangeValueMode::ABSOLUTE;
|
|
|
sendAndApply(sm);
|
|
|
}
|
|
|
|
|
@@ -3143,7 +3143,7 @@ bool CGameHandler::buySecSkill(const IMarket *m, const CGHeroInstance *h, Second
|
|
|
|
|
|
giveResource(h->tempOwner, EGameResID::GOLD, -GameConstants::SKILL_GOLD_COST);
|
|
|
|
|
|
- changeSecSkill(h, skill, 1, true);
|
|
|
+ changeSecSkill(h, skill, 1, ChangeValueMode::ABSOLUTE);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -3198,7 +3198,7 @@ bool CGameHandler::sellCreatures(ui32 count, const IMarket *market, const CGHero
|
|
|
assert(0);
|
|
|
}
|
|
|
|
|
|
- changeStackCount(StackLocation(hero->id, slot), -(TQuantity)count);
|
|
|
+ changeStackCount(StackLocation(hero->id, slot), -(TQuantity)count, ChangeValueMode::RELATIVE);
|
|
|
|
|
|
giveResource(hero->tempOwner, resourceID, b2 * units);
|
|
|
|
|
@@ -3705,7 +3705,7 @@ bool CGameHandler::sacrificeCreatures(const IMarket * market, const CGHeroInstan
|
|
|
|
|
|
int crid = hero->getStack(slot[i]).getId();
|
|
|
|
|
|
- changeStackCount(StackLocation(hero->id, slot[i]), -(TQuantity)count[i]);
|
|
|
+ changeStackCount(StackLocation(hero->id, slot[i]), -(TQuantity)count[i], ChangeValueMode::RELATIVE);
|
|
|
|
|
|
int dump;
|
|
|
int exp;
|
|
@@ -3806,19 +3806,19 @@ bool CGameHandler::eraseStack(const StackLocation &sl, bool forceRemoval)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-bool CGameHandler::changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue)
|
|
|
+bool CGameHandler::changeStackCount(const StackLocation &sl, TQuantity count, ChangeValueMode mode)
|
|
|
{
|
|
|
auto army = dynamic_cast<const CArmedInstance*>(getObj(sl.army));
|
|
|
|
|
|
TQuantity currentCount = army->getStackCount(sl.slot);
|
|
|
- if ((absoluteValue && count < 0)
|
|
|
- || (!absoluteValue && -count > currentCount))
|
|
|
+ if ((mode == ChangeValueMode::RELATIVE && count < 0)
|
|
|
+ || (mode == ChangeValueMode::RELATIVE && -count > currentCount))
|
|
|
{
|
|
|
COMPLAIN_RET("Cannot take more stacks than present!");
|
|
|
}
|
|
|
|
|
|
- if ((currentCount == -count && !absoluteValue)
|
|
|
- || (!count && absoluteValue))
|
|
|
+ if ((currentCount == -count && mode == ChangeValueMode::RELATIVE)
|
|
|
+ || (count == 0 && mode == ChangeValueMode::ABSOLUTE))
|
|
|
{
|
|
|
eraseStack(sl);
|
|
|
}
|
|
@@ -3828,7 +3828,7 @@ bool CGameHandler::changeStackCount(const StackLocation &sl, TQuantity count, bo
|
|
|
csc.army = army->id;
|
|
|
csc.slot = sl.slot;
|
|
|
csc.count = count;
|
|
|
- csc.absoluteValue = absoluteValue;
|
|
|
+ csc.mode = mode;
|
|
|
sendAndApply(csc);
|
|
|
}
|
|
|
return true;
|
|
@@ -3842,7 +3842,7 @@ bool CGameHandler::addToSlot(const StackLocation &sl, const CCreature *c, TQuant
|
|
|
if (!slotC) //slot is empty
|
|
|
insertNewStack(sl, c, count);
|
|
|
else if (c == slotC)
|
|
|
- changeStackCount(sl, count);
|
|
|
+ changeStackCount(sl, count, ChangeValueMode::RELATIVE);
|
|
|
else
|
|
|
{
|
|
|
COMPLAIN_RET("Cannot add " + c->getNamePluralTranslated() + " to slot " + boost::lexical_cast<std::string>(sl.slot) + "!");
|