瀏覽代碼

Support of parsing of all hota 1.7.1 h3m's and h3c's

Ivan Savenko 8 月之前
父節點
當前提交
a12ea45276
共有 3 個文件被更改,包括 30 次插入16 次删除
  1. 7 9
      lib/mapping/MapFeaturesH3M.cpp
  2. 3 2
      lib/mapping/MapFeaturesH3M.h
  3. 20 5
      lib/mapping/MapFormatH3M.cpp

+ 7 - 9
lib/mapping/MapFeaturesH3M.cpp

@@ -131,7 +131,7 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
 {
 	// even if changes are minimal, we might not be able to parse map header in map selection screen
 	// throw exception - to be caught by map selection screen & excluded as invalid
-	if(hotaVersion > 5)
+	if(hotaVersion > 6)
 		throw std::runtime_error("Invalid map format!");
 
 	MapFormatFeaturesH3M result = getFeaturesSOD();
@@ -139,6 +139,7 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
 	result.levelHOTA1 = hotaVersion > 0;
 	result.levelHOTA3 = hotaVersion > 2;
 	result.levelHOTA5 = hotaVersion > 4;
+	result.levelHOTA6 = hotaVersion > 5;
 
 	result.artifactsBytes = 21;
 	result.heroesBytes = 23;
@@ -147,20 +148,17 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
 	result.skillsCount = 29; // + Interference
 	result.factionsCount = 10; // + Cove
 	result.creaturesCount = 171; // + Cove + neutrals
+	result.artifactsCount = 163; // + HotA artifacts
+	result.heroesCount = 178; // + Cove
+	result.heroesPortraitsCount = 186; // + Cove
 
-	if(hotaVersion < 3)
-	{
-		result.artifactsCount = 163; // + HotA artifacts
-		result.heroesCount = 178; // + Cove
-		result.heroesPortraitsCount = 186; // + Cove
-	}
-	if(hotaVersion == 3)
+	if(hotaVersion >= 3)
 	{
 		result.artifactsCount = 165; // + HotA artifacts
 		result.heroesCount = 179; // + Giselle
 		result.heroesPortraitsCount = 188; // + campaign portrait + Giselle
 	}
-	if (hotaVersion == 5)
+	if (hotaVersion >= 5)
 	{
 		result.factionsCount = 11; // + Factory
 		result.creaturesCount = 186; // + 16 Factory

+ 3 - 2
lib/mapping/MapFeaturesH3M.h

@@ -69,8 +69,9 @@ public:
 	bool levelWOG = false;
 	bool levelHOTA0 = false;
 	bool levelHOTA1 = false;
-	bool levelHOTA3 = false;
-	bool levelHOTA5 = false;
+	bool levelHOTA3 = false; // 1.6.0
+	bool levelHOTA5 = false; // 1.7.0
+	bool levelHOTA6 = false; // 1.7.1
 };
 
 VCMI_LIB_NAMESPACE_END

+ 20 - 5
lib/mapping/MapFormatH3M.cpp

@@ -193,10 +193,9 @@ void CMapLoaderH3M::readHeader()
 		if(hotaVersion > 4)
 		{
 			int32_t townTypesCount = reader->readUInt32();
-			uint8_t allowedDifficultiesMask = reader->readUInt8();
+			int8_t allowedDifficultiesMask = reader->readInt8Checked(0, 31);
 
 			assert(features.factionsCount == townTypesCount);
-			assert(allowedDifficultiesMask < 32);
 
 			if (features.factionsCount != townTypesCount)
 				logGlobal->warn("Map '%s': Expected %d factions, but %d found!", mapName, features.factionsCount, townTypesCount);
@@ -1083,7 +1082,15 @@ CGObjectInstance * CMapLoaderH3M::readEvent(const int3 & mapPosition, const Obje
 
 		assert(movementMode >= 0 && movementMode <= 4);
 		if (movementMode != 0 || movementAmount != 0)
-			logGlobal->warn("Map '%s': Option to modify (mode %d) movement points by %d in event is not implemented!", mapName, movementMode, movementAmount);
+			logGlobal->warn("Map '%s': Even %s option to modify (mode %d) movement points by %d is not implemented!", mapName, mapPosition.toString(), movementMode, movementAmount);
+	}
+
+	if(features.levelHOTA6)
+	{
+		int32_t allowedDifficultiesMask = reader->readInt32();
+		assert(allowedDifficultiesMask >= 0 && allowedDifficultiesMask < 32);
+		if (allowedDifficultiesMask != 0)
+			logGlobal->warn("Map '%s': Event %s availability by difficulty (mode %d) is not implemented!", mapName, mapPosition.toString(), allowedDifficultiesMask);
 	}
 
 	return object;
@@ -1103,9 +1110,17 @@ CGObjectInstance * CMapLoaderH3M::readPandora(const int3 & mapPosition, const Ob
 		assert(movementMode >= 0 && movementMode <= 4);
 		assert(unknown == 0);
 		if (unknown != 0)
-			logGlobal->warn("Map '%s': Unknown option in pandora box has been set!", mapName);
+			logGlobal->warn("Map '%s': Pandora %s Unknown option has been set!", mapName, mapPosition.toString());
 		if (movementMode != 0 || movementAmount != 0)
-			logGlobal->warn("Map '%s': Option to modify (mode %d) movement points by %d in event is not implemented!", mapName, movementMode, movementAmount);
+			logGlobal->warn("Map '%s': Pandora %s ption to modify (mode %d) movement points by %d is not implemented!", mapName, mapPosition.toString(), movementMode, movementAmount);
+	}
+
+	if(features.levelHOTA6)
+	{
+		int32_t allowedDifficultiesMask = reader->readInt32();
+		assert(allowedDifficultiesMask >= 0 && allowedDifficultiesMask < 32);
+		if (allowedDifficultiesMask != 0)
+			logGlobal->warn("Map '%s': Pandora %s availability by difficulty (mode %d) is not implemented!", mapName, mapPosition.toString(), allowedDifficultiesMask);
 	}
 
 	return object;