From e3992de50e52999a6d51f35b25b40f46178e6925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= Date: Thu, 11 May 2017 20:52:10 +0200 Subject: [PATCH] Give hero move points at day of visiting stable, fixes #2598 --- lib/NetPacks.h | 5 +++-- lib/NetPacksLib.cpp | 10 +++++++++- lib/mapObjects/CGTownInstance.cpp | 7 +++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/NetPacks.h b/lib/NetPacks.h index 0540585b4..758e7ded8 100644 --- a/lib/NetPacks.h +++ b/lib/NetPacks.h @@ -276,16 +276,17 @@ struct SetMana : public CPackForClient struct SetMovePoints : public CPackForClient { - SetMovePoints(){val = 0;} + SetMovePoints(){val = 0; absolute=true;} void applyCl(CClient *cl); DLL_LINKAGE void applyGs(CGameState *gs); ObjectInstanceID hid; si32 val; + bool absolute; template void serialize(Handler &h, const int version) { - h & val & hid; + h & val & hid & absolute; } }; diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 938562fff..498f26d0e 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -206,7 +206,15 @@ DLL_LINKAGE void SetMana::applyGs(CGameState *gs) DLL_LINKAGE void SetMovePoints::applyGs(CGameState *gs) { CGHeroInstance *hero = gs->getHero(hid); - hero->movement = val; + + assert(hero); + + if(absolute) + hero->movement = val; + else + hero->movement += val; + + vstd::amax(hero->movement, 0); //not less than 0 } DLL_LINKAGE void FoWChange::applyGs(CGameState *gs) diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 8bad6042f..2ca352ce8 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -1302,6 +1302,13 @@ void COPWBonus::onHeroVisit (const CGHeroInstance * h) const gb.bonus = Bonus(Bonus::ONE_WEEK, Bonus::LAND_MOVEMENT, Bonus::OBJECT, 600, 94, VLC->generaltexth->arraytxt[100]); gb.id = heroID.getNum(); cb->giveHeroBonus(&gb); + + SetMovePoints mp; + mp.val = 600; + mp.absolute = false; + mp.hid = heroID; + cb->setMovePoints(&mp); + iw.text << VLC->generaltexth->allTexts[580]; cb->showInfoDialog(&iw); }