From 69b97e0a51aee42a7cce38f6a041a73c18cbff8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Thu, 9 Dec 2010 23:10:28 +0000 Subject: [PATCH] Little more changes. --- AI/GeniusAI/CGeniusAI.cpp | 25 +++++++++++-------------- AI/GeniusAI/CGeniusAI.h | 2 +- client/Client.h | 2 +- hch/CObjectHandler.cpp | 2 +- lib/IGameCallback.h | 2 +- server/CGameHandler.cpp | 2 +- server/CGameHandler.h | 2 +- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/AI/GeniusAI/CGeniusAI.cpp b/AI/GeniusAI/CGeniusAI.cpp index 487073d8f..43bf7c734 100644 --- a/AI/GeniusAI/CGeniusAI.cpp +++ b/AI/GeniusAI/CGeniusAI.cpp @@ -60,7 +60,7 @@ CGeniusAI::HypotheticalGameState::TownModel::TownModel( { hasBuilt = static_cast(t->builded); creaturesToRecruit = t->creatures; - creaturesInGarrison = t->getArmy(); + //creaturesInGarrison = t->getArmy(); } CGeniusAI::HypotheticalGameState::HypotheticalGameState(CGeniusAI& ai) @@ -317,8 +317,8 @@ float CGeniusAI::TownObjective::getValue() const case upgradeCreatures: UpgradeInfo ui = AI->m_cb->getUpgradeInfo(whichTown->t,which); - ID = whichTown->creaturesInGarrison.getCreature(which)->idNumber; - howMany = whichTown->creaturesInGarrison.getStackCount(which); + ID = whichTown->t->getCreature(which)->idNumber; + howMany = whichTown->t->getStackCount(which); newID = ui.newID.back(); int upgrade_serial = ui.newID.size() - 1; @@ -425,7 +425,7 @@ void CGeniusAI::TownObjective::print() const case upgradeCreatures: UpgradeInfo ui = AI->m_cb->getUpgradeInfo (whichTown->t, which); - ID = whichTown->creaturesInGarrison.getCreature(which)->idNumber; + ID = whichTown->t->getCreature(which)->idNumber; tlog6 << "upgrade " << VLC->creh->creatures[ID]->namePl; //ui.cost break; @@ -746,8 +746,7 @@ void CGeniusAI::HeroObjective::fulfill(CGeniusAI& cg, HypotheticalGameState& hgs { //upgrade hero's units tlog6 << "visiting town" << endl; - CCreatureSet hcreatures = h->h->getArmy(); - for (TSlots::const_iterator i = hcreatures.Slots().begin(); i != hcreatures.Slots().end(); i++) + for (TSlots::const_iterator i = h->h->Slots().begin(); i != h->h->Slots().end(); i++) { // For each hero slot. UpgradeInfo ui = cg.m_cb->getUpgradeInfo(h->h,i->first); @@ -773,11 +772,10 @@ void CGeniusAI::HeroObjective::fulfill(CGeniusAI& cg, HypotheticalGameState& hgs } // Give town's units to hero. - CCreatureSet tcreatures = town->getArmy(); int weakestCreatureStack; int weakestCreatureAIValue = 99999; // we will lower it in the process - for (TSlots::const_iterator i = tcreatures.Slots().begin(); i != tcreatures.Slots().end(); i++) + for (TSlots::const_iterator i = town->Slots().begin(); i != town->Slots().end(); i++) { if (i->second->type->AIValue < weakestCreatureAIValue) { @@ -785,15 +783,14 @@ void CGeniusAI::HeroObjective::fulfill(CGeniusAI& cg, HypotheticalGameState& hgs weakestCreatureStack = i->first; } } - for (TSlots::const_iterator i = tcreatures.Slots().begin(); i != tcreatures.Slots().end(); i++)\ + for (TSlots::const_iterator i = town->Slots().begin(); i != town->Slots().end(); i++)\ { // For each town slot. - hcreatures = h->h->getArmy(); - int hSlot = hcreatures.getSlotFor(i->second->type->idNumber); + int hSlot = h->h->getSlotFor(i->second->type->idNumber); if (hSlot == -1) continue; tlog6 << "giving hero " << i->second->type->namePl << endl; - if (!hcreatures.slotEmpty(hSlot)) + if (!h->h->slotEmpty(hSlot)) { // Can't take garrisonHero's last unit. if ( (i->first == weakestCreatureStack) && (town->garrisonHero != NULL) ) @@ -878,7 +875,7 @@ void CGeniusAI::addTownObjectives (HypotheticalGameState::TownModel& t, Hypothet } // Upgrade creatures. - for (TSlots::const_iterator i = t.creaturesInGarrison.Slots().begin(); i != t.creaturesInGarrison.Slots().end(); i++) + for (TSlots::const_iterator i = t.t->Slots().begin(); i != t.t->Slots().end(); i++) { UpgradeInfo ui = m_cb->getUpgradeInfo(t.t, i->first); if (ui.newID.size()) @@ -955,7 +952,7 @@ void CGeniusAI::TownObjective::fulfill(CGeniusAI& cg, case upgradeCreatures: UpgradeInfo ui = cg.m_cb->getUpgradeInfo(whichTown->t, which); - ID = whichTown->creaturesInGarrison.getCreature(which)->idNumber; + ID = whichTown->t->getCreature(which)->idNumber; newID = ui.newID.back(); // TODO: reduce resources in hgs cg.m_cb->upgradeCreature(whichTown->t, which, newID); diff --git a/AI/GeniusAI/CGeniusAI.h b/AI/GeniusAI/CGeniusAI.h index 8fbad0afc..8cd1e5f8a 100644 --- a/AI/GeniusAI/CGeniusAI.h +++ b/AI/GeniusAI/CGeniusAI.h @@ -61,7 +61,7 @@ private: TownModel(const CGTownInstance *t); const CGTownInstance *t; std::vector > > creaturesToRecruit; - CCreatureSet creaturesInGarrison; //type, num + //CCreatureSet creaturesInGarrison; //type, num bool hasBuilt; }; HypotheticalGameState(){} diff --git a/client/Client.h b/client/Client.h index 688fbc0dc..92eb300a8 100644 --- a/client/Client.h +++ b/client/Client.h @@ -110,7 +110,7 @@ public: void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function &cb){}; void showThievesGuildWindow(int requestingObjId){}; void giveResource(int player, int which, int val){}; - void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet creatures, bool remove) {}; + void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet &creatures, bool remove) {}; void takeCreatures (int objid, TSlots creatures){}; void takeCreatures (int objid, std::vector creatures){}; bool changeStackType(const StackLocation &sl, CCreature *c){return false;}; diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index f3d6d52d8..74d8004ac 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -4456,7 +4456,7 @@ void CGSeerHut::completeQuest (const CGHeroInstance * h) const //reward { CCreatureSet creatures; creatures.setCreature(0, rID, rVal); - cb->giveCreatures (id, h, creatures,false); + cb->giveCreatures(id, h, creatures, false); } break; default: diff --git a/lib/IGameCallback.h b/lib/IGameCallback.h index 284bef83c..40e8ebe32 100644 --- a/lib/IGameCallback.h +++ b/lib/IGameCallback.h @@ -87,7 +87,7 @@ public: virtual void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function &cb) =0; //cb will be called when player closes garrison window virtual void showThievesGuildWindow(int requestingObjId) =0; virtual void giveResource(int player, int which, int val)=0; - virtual void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet creatures, bool remove) =0; + virtual void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet &creatures, bool remove) =0; //virtual void takeCreatures (int objid, TSlots creatures) =0; virtual void takeCreatures (int objid, std::vector creatures) =0; virtual bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false) =0; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 9d602e18a..6e51aca74 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2087,7 +2087,7 @@ void CGameHandler::giveResource(int player, int which, int val) sr.val = gs->players.find(player)->second.resources[which]+val; sendAndApply(&sr); } -void CGameHandler::giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet creatures, bool remove) +void CGameHandler::giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet &creatures, bool remove) { assert(0); // if (creatures.stacksCount() <= 0) diff --git a/server/CGameHandler.h b/server/CGameHandler.h index 58830866b..89fd34381 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -138,7 +138,7 @@ public: void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function &cb); void showThievesGuildWindow(int requestingObjId); //TODO: make something more general? void giveResource(int player, int which, int val); - void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet creatures, bool remove); + void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet &creatures, bool remove); void takeCreatures (int objid, std::vector creatures); bool changeStackType(const StackLocation &sl, CCreature *c); bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false);