diff --git a/client/Client.h b/client/Client.h index 6e0cabf00..ccd822009 100644 --- a/client/Client.h +++ b/client/Client.h @@ -194,6 +194,7 @@ public: void showCompInfo(ShowInInfobox * comp) override {}; void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}; + void visitCastleObjects(const CGTownInstance * obj, const CGHeroInstance * hero) override {}; void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}; void startBattlePrimary(const CArmedInstance * army1, const CArmedInstance * army2, int3 tile, const CGHeroInstance * hero1, const CGHeroInstance * hero2, bool creatureBank = false, const CGTownInstance * town = nullptr) override {}; //use hero=nullptr for no hero void startBattleI(const CArmedInstance * army1, const CArmedInstance * army2, int3 tile, bool creatureBank = false) override {}; //if any of armies is hero, hero will be used diff --git a/lib/CPathfinder.h b/lib/CPathfinder.h index 906c333a4..cd0fc882c 100644 --- a/lib/CPathfinder.h +++ b/lib/CPathfinder.h @@ -118,11 +118,11 @@ struct DLL_LINKAGE CGPathNode { if(getUpNode) { - pq->increase(this->pqHandle, this); + pq->increase(this->pqHandle); } else { - pq->decrease(this->pqHandle, this); + pq->decrease(this->pqHandle); } } } diff --git a/lib/IGameCallback.h b/lib/IGameCallback.h index dda1da39b..40f6f0c4e 100644 --- a/lib/IGameCallback.h +++ b/lib/IGameCallback.h @@ -80,6 +80,7 @@ public: virtual void showCompInfo(ShowInInfobox * comp)=0; virtual void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)=0; + virtual void visitCastleObjects(const CGTownInstance * obj, const CGHeroInstance * hero)=0; virtual void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)=0; virtual void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr)=0; //use hero=nullptr for no hero 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 diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 981d21286..d9ee3ad24 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -798,6 +798,14 @@ void CGTownInstance::newTurn(CRandomGenerator & rand) const cb->setObjProperty (id, ObjProperty::STRUCTURE_CLEAR_VISITORS, (elem)->id); //reset visitors for Mana Vortex } + //get Mana Vortex or Stables bonuses + //same code is in the CGameHandler::buildStructure method + if (visitingHero != nullptr) + cb->visitCastleObjects(this, visitingHero); + + if (garrisonHero != nullptr) + cb->visitCastleObjects(this, garrisonHero); + if (tempOwner == PlayerColor::NEUTRAL) //garrison growth for neutral towns { std::vector nativeCrits; //slots @@ -1536,13 +1544,15 @@ void COPWBonus::onHeroVisit (const CGHeroInstance * h) const } break; case ETownType::DUNGEON: //Mana Vortex - if (visitors.empty() && h->mana <= h->manaLimit() * 2) + if (visitors.empty()) { - cb->setManaPoints (heroID, 2 * h->manaLimit()); + if (h->mana < h->manaLimit() * 2) + cb->setManaPoints(heroID, 2 * h->manaLimit()); //TODO: investigate line below //cb->setObjProperty (town->id, ObjProperty::VISITED, true); iw.text << VLC->generaltexth->allTexts[579]; cb->showInfoDialog(&iw); + //extra visit penalty if hero alredy had double mana points (or even more?!) town->addHeroToStructureVisitors(h, id); } break; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 8cd46c11b..5408f96e2 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2508,13 +2508,13 @@ void CGameHandler::heroVisitCastle(const CGTownInstance * obj, const CGHeroInsta vc.tid = obj->id; vc.flags |= 1; sendAndApply(&vc); - vistiCastleObjects (obj, hero); - giveSpells (obj, hero); + visitCastleObjects(obj, hero); + giveSpells(obj, hero); checkVictoryLossConditionsForPlayer(hero->tempOwner); //transported artifact? } -void CGameHandler::vistiCastleObjects (const CGTownInstance *t, const CGHeroInstance *h) +void CGameHandler::visitCastleObjects(const CGTownInstance * t, const CGHeroInstance * h) { std::vector::const_iterator i; for (i = t->bonusingBuildings.begin(); i != t->bonusingBuildings.end(); i++) @@ -3161,9 +3161,9 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID, sendAndApply(&fw); if (t->visitingHero) - vistiCastleObjects (t, t->visitingHero); + visitCastleObjects(t, t->visitingHero); if (t->garrisonHero) - vistiCastleObjects (t, t->garrisonHero); + visitCastleObjects(t, t->garrisonHero); checkVictoryLossConditionsForPlayer(t->tempOwner); return true; @@ -3828,7 +3828,7 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, PlayerColor pl if (t) { - vistiCastleObjects (t, nh); + visitCastleObjects(t, nh); giveSpells (t,nh); } return true; diff --git a/server/CGameHandler.h b/server/CGameHandler.h index d8ebc10ef..13dff2e1c 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -181,7 +181,7 @@ public: void setPortalDwelling(const CGTownInstance * town, bool forced, bool clear); void visitObjectOnTile(const TerrainTile &t, const CGHeroInstance * h); bool teleportHero(ObjectInstanceID hid, ObjectInstanceID dstid, ui8 source, PlayerColor asker = PlayerColor::NEUTRAL); - void vistiCastleObjects (const CGTownInstance *t, const CGHeroInstance *h); + void visitCastleObjects(const CGTownInstance * obj, const CGHeroInstance * hero) override; void levelUpHero(const CGHeroInstance * hero, SecondarySkill skill);//handle client respond and send one more request if needed void levelUpHero(const CGHeroInstance * hero);//initial call - check if hero have remaining levelups & handle them void levelUpCommander (const CCommanderInstance * c, int skill); //secondary skill 1 to 6, special skill : skill - 100 diff --git a/test/mock/mock_IGameCallback.h b/test/mock/mock_IGameCallback.h index 1670f4982..095acdbfc 100644 --- a/test/mock/mock_IGameCallback.h +++ b/test/mock/mock_IGameCallback.h @@ -70,6 +70,7 @@ public: void showCompInfo(ShowInInfobox * comp) override {}; void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}; void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}; + void visitCastleObjects(const CGTownInstance * obj, const CGHeroInstance * hero) override {}; void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr) override {}; //use hero=nullptr for no hero 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