瀏覽代碼

- fixed crash on loading of some maps
- minor fixes

Ivan Savenko 13 年之前
父節點
當前提交
4e92859cee
共有 3 個文件被更改,包括 15 次插入19 次删除
  1. 13 13
      AI/EmptyAI/CEmptyAI.h
  2. 0 2
      lib/CGameState.cpp
  3. 2 4
      lib/map.cpp

+ 13 - 13
AI/EmptyAI/CEmptyAI.h

@@ -10,19 +10,19 @@ class CEmptyAI : public CGlobalAI
 	CCallback *cb;
 	CCallback *cb;
 
 
 public:
 public:
-	void init(CCallback * CB);
-	void yourTurn();
-	void heroKilled(const CGHeroInstance *);
-	void heroCreated(const CGHeroInstance *);
-	void heroMoved(const TryMoveHero&);
-	void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val) {};
-	void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID){};
-	void tileRevealed(int3 pos){};
-	void tileHidden(int3 pos){};
-	void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, int soundID, bool selection, bool cancel){};
-	void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, boost::function<void()> &onEnd) {};
-	void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback);
-	void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, boost::function<void(ui32)> &callback) {}; //TODO
+	void init(CCallback * CB) override;
+	void yourTurn() override;
+	void heroKilled(const CGHeroInstance *) override;
+	void heroCreated(const CGHeroInstance *) override;
+	void heroMoved(const TryMoveHero&) override;
+	void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override {};
+	void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID) override {};
+	void tileRevealed(const boost::unordered_set<int3, ShashInt3> &pos) override {};
+	void tileHidden(const boost::unordered_set<int3, ShashInt3> &pos) override {};
+	void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, int soundID, bool selection, bool cancel) override {};
+	void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, boost::function<void()> &onEnd) override {};
+	void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback) override;
+	void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, boost::function<void(ui32)> &callback) override {}; //TODO
 };
 };
 
 
 #define NAME "EmptyAI 0.1"
 #define NAME "EmptyAI 0.1"

+ 0 - 2
lib/CGameState.cpp

@@ -651,8 +651,6 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
 			BOOST_FOREACH(auto &iter, VLC->objh->cregens)
 			BOOST_FOREACH(auto &iter, VLC->objh->cregens)
 				if (iter.second == cid)
 				if (iter.second == cid)
 					result = std::pair<int,int>(17, iter.first);
 					result = std::pair<int,int>(17, iter.first);
-
-			tlog3 << "Cannot find a dwelling for creature "<< cid << std::endl;
 			return result;
 			return result;
 		}
 		}
 	}
 	}

+ 2 - 4
lib/map.cpp

@@ -1260,7 +1260,7 @@ void Mapa::readObjects( const ui8 * bufor, int &i)
 		int defnum = read_le_u32(bufor + i); i+=4;
 		int defnum = read_le_u32(bufor + i); i+=4;
 		int idToBeGiven = objects.size();
 		int idToBeGiven = objects.size();
 
 
-		CGDefInfo * defInfo = defy[defnum];
+		CGDefInfo * defInfo = defy.at(defnum);
 		i+=5;
 		i+=5;
 
 
 		switch(defInfo->id)
 		switch(defInfo->id)
@@ -1705,8 +1705,6 @@ void Mapa::readObjects( const ui8 * bufor, int &i)
 						castleSpec->asCastle = true;
 						castleSpec->asCastle = true;
 					}
 					}
 				}
 				}
-				else
-					i+=3; //only for 218
 
 
 				//216 and 218
 				//216 and 218
 				if (auto lvlSpec = dynamic_cast<CCreGenLeveledInfo*>(spec))
 				if (auto lvlSpec = dynamic_cast<CCreGenLeveledInfo*>(spec))
@@ -2211,4 +2209,4 @@ bool TerrainTile::hasFavourableWinds() const
 bool TerrainTile::isWater() const
 bool TerrainTile::isWater() const
 {
 {
 	return tertype == water;
 	return tertype == water;
-}
+}