瀏覽代碼

Little more changes.

Michał W. Urbańczyk 15 年之前
父節點
當前提交
69b97e0a51
共有 7 個文件被更改,包括 17 次插入20 次删除
  1. 11 14
      AI/GeniusAI/CGeniusAI.cpp
  2. 1 1
      AI/GeniusAI/CGeniusAI.h
  3. 1 1
      client/Client.h
  4. 1 1
      hch/CObjectHandler.cpp
  5. 1 1
      lib/IGameCallback.h
  6. 1 1
      server/CGameHandler.cpp
  7. 1 1
      server/CGameHandler.h

+ 11 - 14
AI/GeniusAI/CGeniusAI.cpp

@@ -60,7 +60,7 @@ CGeniusAI::HypotheticalGameState::TownModel::TownModel(
 {
 	hasBuilt = static_cast<bool>(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);

+ 1 - 1
AI/GeniusAI/CGeniusAI.h

@@ -61,7 +61,7 @@ private:
 			TownModel(const CGTownInstance *t);
 			const CGTownInstance *t;
 			std::vector<std::pair<ui32, std::vector<ui32> > > creaturesToRecruit;
-			CCreatureSet creaturesInGarrison;				//type, num
+			//CCreatureSet creaturesInGarrison;				//type, num
 			bool hasBuilt;
 		};
 		HypotheticalGameState(){}

+ 1 - 1
client/Client.h

@@ -110,7 +110,7 @@ public:
 	void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function<void()> &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<CStackBasicDescriptor> creatures){};
 	bool changeStackType(const StackLocation &sl, CCreature *c){return false;};

+ 1 - 1
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:

+ 1 - 1
lib/IGameCallback.h

@@ -87,7 +87,7 @@ public:
 	virtual void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function<void()> &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<CStackBasicDescriptor> creatures) =0;
 	virtual bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false) =0;

+ 1 - 1
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)

+ 1 - 1
server/CGameHandler.h

@@ -138,7 +138,7 @@ public:
 	void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function<void()> &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<CStackBasicDescriptor> creatures);
 	bool changeStackType(const StackLocation &sl, CCreature *c);
 	bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false);