diff --git a/CCallback.cpp b/CCallback.cpp index 825202162..e67c01749 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -48,9 +48,9 @@ bool CCallback::teleportHero(const CGHeroInstance *who, const CGTownInstance *wh return true; } -bool CCallback::moveHero(const CGHeroInstance *h, int3 dst) +bool CCallback::moveHero(const CGHeroInstance *h, int3 dst, bool transit) { - MoveHero pack(dst,h->id); + MoveHero pack(dst,h->id,transit); sendRequest(&pack); return true; } diff --git a/CCallback.h b/CCallback.h index 0ac677be7..6b6edd96b 100644 --- a/CCallback.h +++ b/CCallback.h @@ -46,7 +46,7 @@ class IGameActionCallback { public: //hero - virtual bool moveHero(const CGHeroInstance *h, int3 dst) =0; //dst must be free, neighbouring tile (this function can move hero only by one tile) + virtual bool moveHero(const CGHeroInstance *h, int3 dst, bool transit) =0; //dst must be free, neighbouring tile (this function can move hero only by one tile) virtual bool dismissHero(const CGHeroInstance * hero)=0; //dismisses given hero; true - successfuly, false - not successfuly virtual void dig(const CGObjectInstance *hero)=0; virtual void castSpell(const CGHeroInstance *hero, SpellID spellID, const int3 &pos = int3(-1, -1, -1))=0; //cast adventure map spell @@ -119,7 +119,7 @@ public: void unregisterAllInterfaces(); //stops delivering information about game events to player interfaces -> can be called ONLY after victory/loss //commands - bool moveHero(const CGHeroInstance *h, int3 dst); //dst must be free, neighbouring tile (this function can move hero only by one tile) + bool moveHero(const CGHeroInstance *h, int3 dst, bool transit = false); //dst must be free, neighbouring tile (this function can move hero only by one tile) bool teleportHero(const CGHeroInstance *who, const CGTownInstance *where); int selectionMade(int selection, QueryID queryID); int swapCreatures(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2); diff --git a/client/Client.h b/client/Client.h index 9f1e346d7..3f7e1b1d2 100644 --- a/client/Client.h +++ b/client/Client.h @@ -213,7 +213,7 @@ public: void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false) override {}; //if any of armies is hero, hero will be used void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, bool creatureBank = false) override {}; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle void setAmount(ObjectInstanceID objid, ui32 val) override {}; - bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, PlayerColor asker = PlayerColor::NEUTRAL) override {return false;}; + bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, bool transit = false, PlayerColor asker = PlayerColor::NEUTRAL) override {return false;}; void giveHeroBonus(GiveBonus * bonus) override {}; void setMovePoints(SetMovePoints * smp) override {}; void setManaPoints(ObjectInstanceID hid, int val) override {}; diff --git a/lib/IGameCallback.h b/lib/IGameCallback.h index 280e7d0d9..eb391e2a8 100644 --- a/lib/IGameCallback.h +++ b/lib/IGameCallback.h @@ -85,7 +85,7 @@ public: virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false)=0; //if any of armies is hero, hero will be used virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, bool creatureBank = false)=0; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle virtual void setAmount(ObjectInstanceID objid, ui32 val)=0; - virtual bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, PlayerColor asker = PlayerColor::NEUTRAL)=0; + virtual bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, bool transit = false, PlayerColor asker = PlayerColor::NEUTRAL)=0; virtual void giveHeroBonus(GiveBonus * bonus)=0; virtual void setMovePoints(SetMovePoints * smp)=0; virtual void setManaPoints(ObjectInstanceID hid, int val)=0; diff --git a/lib/NetPacks.h b/lib/NetPacks.h index 0a6dca03e..7a3e3cf45 100644 --- a/lib/NetPacks.h +++ b/lib/NetPacks.h @@ -1762,14 +1762,15 @@ struct DismissHero : public CPackForServer struct MoveHero : public CPackForServer { MoveHero(){}; - MoveHero(const int3 &Dest, ObjectInstanceID HID) : dest(Dest), hid(HID){}; + MoveHero(const int3 &Dest, ObjectInstanceID HID, bool Transit) : dest(Dest), hid(HID), transit(Transit) {}; int3 dest; ObjectInstanceID hid; + bool transit; bool applyGh(CGameHandler *gh); template void serialize(Handler &h, const int version) { - h & dest & hid; + h & dest & hid & transit; } }; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 8070a49ad..f581b9439 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1662,7 +1662,7 @@ void CGameHandler::setAmount(ObjectInstanceID objid, ui32 val) sendAndApply(&sop); } -bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, PlayerColor asker /*= 255*/ ) +bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, bool transit, PlayerColor asker /*= 255*/ ) { const CGHeroInstance *h = getHero(hid); diff --git a/server/CGameHandler.h b/server/CGameHandler.h index f3bab3a8b..3adc1f710 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -168,7 +168,7 @@ public: void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false) override; //if any of armies is hero, hero will be used void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, bool creatureBank = false) override; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle//void startBattleI(int heroID, CCreatureSet army, int3 tile, std::function cb) override; //for hero<=>neutral army void setAmount(ObjectInstanceID objid, ui32 val) override; - bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, PlayerColor asker = PlayerColor::NEUTRAL) override; + bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, bool transit = false, PlayerColor asker = PlayerColor::NEUTRAL) override; void giveHeroBonus(GiveBonus * bonus) override; void setMovePoints(SetMovePoints * smp) override; void setManaPoints(ObjectInstanceID hid, int val) override; diff --git a/server/NetPacksServer.cpp b/server/NetPacksServer.cpp index 7f925f727..1fc2596b2 100644 --- a/server/NetPacksServer.cpp +++ b/server/NetPacksServer.cpp @@ -83,7 +83,7 @@ bool DismissHero::applyGh( CGameHandler *gh ) bool MoveHero::applyGh( CGameHandler *gh ) { ERROR_IF_NOT_OWNS(hid); - return gh->moveHero(hid,dest,0,gh->getPlayerAt(c)); + return gh->moveHero(hid,dest,0,transit,gh->getPlayerAt(c)); } bool CastleTeleportHero::applyGh( CGameHandler *gh )