mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Merge pull request #5847 from IvanSavenko/movement_fix
Fix incorrect movement gain from objects like Rally Flag
This commit is contained in:
@@ -104,7 +104,7 @@ public:
|
||||
virtual bool moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveMove, bool transit = false, PlayerColor asker = PlayerColor::NEUTRAL)=0;
|
||||
virtual void giveHeroBonus(GiveBonus * bonus)=0;
|
||||
virtual void setMovePoints(SetMovePoints * smp)=0;
|
||||
virtual void setMovePoints(ObjectInstanceID hid, int val, ChangeValueMode mode)=0;
|
||||
virtual void setMovePoints(ObjectInstanceID hid, int val)=0;
|
||||
virtual void setManaPoints(ObjectInstanceID hid, int val)=0;
|
||||
virtual void giveHero(ObjectInstanceID id, PlayerColor player, ObjectInstanceID boatId = ObjectInstanceID()) = 0;
|
||||
virtual void changeObjPos(ObjectInstanceID objid, int3 newPos, const PlayerColor & initiator)=0;
|
||||
|
||||
@@ -176,13 +176,8 @@ void GameStatePackVisitor::visitSetMana(SetMana & pack)
|
||||
void GameStatePackVisitor::visitSetMovePoints(SetMovePoints & pack)
|
||||
{
|
||||
CGHeroInstance *hero = gs.getHero(pack.hid);
|
||||
|
||||
assert(hero);
|
||||
|
||||
if(pack.mode == ChangeValueMode::ABSOLUTE)
|
||||
hero->setMovementPoints(pack.val);
|
||||
else
|
||||
hero->setMovementPoints(hero->movementPointsRemaining() + pack.val);
|
||||
}
|
||||
|
||||
void GameStatePackVisitor::visitFoWChange(FoWChange & pack)
|
||||
|
||||
@@ -351,15 +351,13 @@ struct DLL_LINKAGE SetMana : public CPackForClient
|
||||
struct DLL_LINKAGE SetMovePoints : public CPackForClient
|
||||
{
|
||||
SetMovePoints() = default;
|
||||
SetMovePoints(ObjectInstanceID hid, si32 val, ChangeValueMode mode)
|
||||
SetMovePoints(ObjectInstanceID hid, si32 val)
|
||||
: hid(hid)
|
||||
, val(val)
|
||||
, mode(mode)
|
||||
{}
|
||||
|
||||
ObjectInstanceID hid;
|
||||
si32 val = 0;
|
||||
ChangeValueMode mode = ChangeValueMode::RELATIVE;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@@ -367,7 +365,6 @@ struct DLL_LINKAGE SetMovePoints : public CPackForClient
|
||||
{
|
||||
h & val;
|
||||
h & hid;
|
||||
h & mode;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1335,12 +1335,11 @@ void CGameHandler::setMovePoints(SetMovePoints * smp)
|
||||
sendAndApply(*smp);
|
||||
}
|
||||
|
||||
void CGameHandler::setMovePoints(ObjectInstanceID hid, int val, ChangeValueMode mode)
|
||||
void CGameHandler::setMovePoints(ObjectInstanceID hid, int val)
|
||||
{
|
||||
SetMovePoints smp;
|
||||
smp.hid = hid;
|
||||
smp.val = val;
|
||||
smp.mode = mode;
|
||||
sendAndApply(smp);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
bool moveHero(ObjectInstanceID hid, int3 dst, EMovementMode movementMode, bool transit = false, PlayerColor asker = PlayerColor::NEUTRAL) override;
|
||||
void giveHeroBonus(GiveBonus * bonus) override;
|
||||
void setMovePoints(SetMovePoints * smp) override;
|
||||
void setMovePoints(ObjectInstanceID hid, int val, ChangeValueMode mode) override;
|
||||
void setMovePoints(ObjectInstanceID hid, int val) override;
|
||||
void setManaPoints(ObjectInstanceID hid, int val) override;
|
||||
void giveHero(ObjectInstanceID id, PlayerColor player, ObjectInstanceID boatId = ObjectInstanceID()) override;
|
||||
void changeObjPos(ObjectInstanceID objid, int3 newPos, const PlayerColor & initiator) override;
|
||||
|
||||
@@ -590,7 +590,7 @@ std::vector<SetMovePoints> NewTurnProcessor::updateHeroesMovementPoints()
|
||||
int32_t newMovementPoints = h->movementPointsLimitCached(gameHandler->gameState().getMap().getTile(h->visitablePos()).isLand(), ti.get());
|
||||
|
||||
if (newMovementPoints != h->movementPointsRemaining())
|
||||
result.emplace_back(h->id, newMovementPoints, ChangeValueMode::ABSOLUTE);
|
||||
result.emplace_back(h->id, newMovementPoints);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
bool moveHero(ObjectInstanceID hid, int3 dst, EMovementMode movementMode, bool transit, PlayerColor asker) override {return false;}
|
||||
void giveHeroBonus(GiveBonus * bonus) override {}
|
||||
void setMovePoints(SetMovePoints * smp) override {}
|
||||
void setMovePoints(ObjectInstanceID hid, int val, ChangeValueMode mode) override {};
|
||||
void setMovePoints(ObjectInstanceID hid, int val) override {};
|
||||
void setManaPoints(ObjectInstanceID hid, int val) override {}
|
||||
void giveHero(ObjectInstanceID id, PlayerColor player, ObjectInstanceID boatId) override {}
|
||||
void changeObjPos(ObjectInstanceID objid, int3 newPos, const PlayerColor & initiator) override {}
|
||||
|
||||
Reference in New Issue
Block a user