Parcourir la source

- fixed uninitialized access into modHander
- fixed #389

Ivan Savenko il y a 12 ans
Parent
commit
b20f8fd3d4
6 fichiers modifiés avec 12 ajouts et 6 suppressions
  1. 1 1
      client/GUIClasses.cpp
  2. 3 3
      lib/CGameState.cpp
  3. 4 1
      lib/CModHandler.cpp
  4. 1 0
      lib/CModHandler.h
  5. 2 0
      lib/VCMI_Lib.cpp
  6. 1 1
      lib/mapping/CMap.cpp

+ 1 - 1
client/GUIClasses.cpp

@@ -5254,7 +5254,7 @@ CPuzzleWindow::CPuzzleWindow(const int3 &GrailPos, double discoveredRatio):
 		auto piece = new CPicture(info.filename, info.x, info.y);
 
 		//piece that will slowly disappear
-		if(info.whenUncovered < GameConstants::PUZZLE_MAP_PIECES * discoveredRatio)
+		if(info.whenUncovered <= GameConstants::PUZZLE_MAP_PIECES * discoveredRatio)
 		{
 			piecesToRemove.push_back(piece);
 			piece->needRefresh = true;

+ 3 - 3
lib/CGameState.cpp

@@ -954,13 +954,13 @@ void CGameState::init(StartInfo * si)
 		if(!map->grailRadious) //radius not given -> anywhere on map
 			map->grailRadious = map->width * 2;
 
-
  		std::vector<int3> allowedPos;
+		static const int BORDER_WIDTH = 9; // grail must be at least 9 tiles away from border
 
 		// add all not blocked tiles in range
-		for (int i = 0; i < map->width ; i++)
+		for (int i = BORDER_WIDTH; i < map->width - BORDER_WIDTH ; i++)
 		{
-			for (int j = 0; j < map->height ; j++)
+			for (int j = BORDER_WIDTH; j < map->height - BORDER_WIDTH; j++)
 			{
 				for (int k = 0; k < (map->twoLevel ? 2 : 1); k++)
 				{

+ 4 - 1
lib/CModHandler.cpp

@@ -511,10 +511,13 @@ void CModHandler::handleData(Handler handler, const JsonNode & source, std::stri
 	}
 }
 
-void CModHandler::loadGameContent()
+void CModHandler::beforeLoad()
 {
 	loadConfigFromFile("defaultMods.json");
+}
 
+void CModHandler::loadGameContent()
+{
 	CStopWatch timer, totalTime;
 
 	CContentHandler content;

+ 1 - 0
lib/CModHandler.h

@@ -169,6 +169,7 @@ public:
 	CModInfo & getModData(TModID modId);
 
 	/// load content from all available mods
+	void beforeLoad();
 	void loadGameContent();
 
 	/// actions that should be triggered on map restart

+ 2 - 0
lib/VCMI_Lib.cpp

@@ -91,6 +91,8 @@ void LibClasses::init()
 {
 	CStopWatch pomtime, totalTime;
 
+	modh->beforeLoad();
+
 	createHandler(bth, "Bonus type", pomtime);
 	
 	createHandler(generaltexth, "General text", pomtime);

+ 1 - 1
lib/mapping/CMap.cpp

@@ -148,7 +148,7 @@ CMapHeader::~CMapHeader()
 
 }
 
-CMap::CMap() : checksum(0), grailRadious(0), terrain(nullptr)
+CMap::CMap() : checksum(0), grailPos(-1, -1, -1), grailRadious(0), terrain(nullptr)
 {
 	allowedAbilities = VLC->heroh->getDefaultAllowedAbilities();
 	allowedArtifact = VLC->arth->getDefaultAllowed();