Pārlūkot izejas kodu

Fixed parsing of hota format '0'

Ivan Savenko 2 gadi atpakaļ
vecāks
revīzija
b1e7774bbd

+ 6 - 5
lib/mapping/MapFeaturesH3M.cpp

@@ -115,10 +115,11 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesWOG()
 
 MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
 {
-	assert(hotaVersion == 1 || hotaVersion == 2 || hotaVersion == 3);
+	assert(hotaVersion < 4);
 
 	MapFormatFeaturesH3M result = getFeaturesSOD();
-	result.levelHOTA = true;
+	result.levelHOTA0 = true;
+	result.levelHOTA1 = hotaVersion > 0;
 	//result.levelHOTA2 = hotaVersion > 1; // HOTA2 seems to be identical to HOTA1 so far
 	result.levelHOTA3 = hotaVersion > 2;
 
@@ -130,17 +131,17 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
 	result.factionsCount = 10; // + Cove
 	result.creaturesCount = 171; // + Cove + neutrals
 
-	if(hotaVersion == 1 || hotaVersion == 2)
+	if(hotaVersion == 0 || hotaVersion == 1 || hotaVersion == 2)
 	{
 		result.artifactsCount = 163; // + HotA artifacts
 		result.heroesCount = 178; // + Cove
-		result.heroesPortraitsCount = 186; // + Cove
+		result.heroesPortraitsCount = 187; // + Cove
 	}
 	if(hotaVersion == 3)
 	{
 		result.artifactsCount = 165; // + HotA artifacts
 		result.heroesCount = 179; // + Cove
-		result.heroesPortraitsCount = 186; // + Cove
+		result.heroesPortraitsCount = 187; // + Cove
 	}
 
 	assert((result.heroesCount + 7) / 8 == result.heroesBytes);

+ 2 - 1
lib/mapping/MapFeaturesH3M.h

@@ -63,7 +63,8 @@ public:
 	bool levelAB = false;
 	bool levelSOD = false;
 	bool levelWOG = false;
-	bool levelHOTA = false;
+	bool levelHOTA0 = false;
+	bool levelHOTA1 = false;
 	bool levelHOTA3 = false;
 };
 

+ 19 - 8
lib/mapping/MapFormatH3M.cpp

@@ -125,7 +125,15 @@ void CMapLoaderH3M::readHeader()
 		features = MapFormatFeaturesH3M::find(mapHeader->version, hotaVersion);
 		reader->setFormatLevel(mapHeader->version, hotaVersion);
 
-		reader->skipZero(2);
+		if(hotaVersion > 0)
+		{
+			reader->skipZero(1);
+			//TODO: HotA
+			bool isDuelMap = reader->readBool();
+			if (isDuelMap)
+				logGlobal->warn("Map '%s': Duel maps are not supported!", mapName);
+		}
+
 		if(hotaVersion > 1)
 		{
 			uint8_t unknown = reader->readUInt32();
@@ -587,7 +595,7 @@ void CMapLoaderH3M::readAllowedHeroes()
 	uint32_t heroesCount = features.heroesCount;
 	uint32_t heroesBytes = features.heroesBytes;
 
-	if(features.levelHOTA)
+	if(features.levelHOTA0)
 	{
 		heroesCount = reader->readUInt32();
 		heroesBytes = (heroesCount + 7) / 8;
@@ -627,14 +635,17 @@ void CMapLoaderH3M::readMapOptions()
 	//omitting NULLS
 	reader->skipZero(31);
 
-	if(features.levelHOTA)
+	if(features.levelHOTA0)
 	{
 		//TODO: HotA
 		bool allowSpecialMonths = reader->readBool();
 		if(!allowSpecialMonths)
 			logGlobal->warn("Map '%s': Option 'allow special months' is not implemented!", mapName);
-
 		reader->skipZero(3);
+	}
+
+	if(features.levelHOTA1)
+	{
 		uint8_t unknownConstant = reader->readUInt8();
 		assert(unknownConstant == 16);
 		MAYBE_UNUSED(unknownConstant);
@@ -657,7 +668,7 @@ void CMapLoaderH3M::readAllowedArtifacts()
 	uint32_t artifactsCount = features.artifactsCount;
 	uint32_t artifactsBytes = features.artifactsBytes;
 
-	if(features.levelHOTA)
+	if(features.levelHOTA0)
 	{
 		artifactsCount = reader->readUInt32();
 		artifactsBytes = (artifactsCount + 7) / 8;
@@ -730,7 +741,7 @@ void CMapLoaderH3M::readPredefinedHeroes()
 
 	uint32_t heroesCount = features.heroesCount;
 
-	if(features.levelHOTA)
+	if(features.levelHOTA0)
 		heroesCount = reader->readUInt32();
 
 	assert(heroesCount <= features.heroesCount);
@@ -1988,7 +1999,7 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
 				object->possibleSpells.emplace_back(i);
 	}
 
-	if(features.levelHOTA)
+	if(features.levelHOTA1)
 	{
 		// TODO: HOTA support
 		bool spellResearchAvailable = reader->readBool();
@@ -2033,7 +2044,7 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
 		object->events.push_back(event);
 	}
 
-	if(features.levelHOTA)
+	if(features.levelHOTA0)
 	{
 		// TODO: HOTA support
 		uint8_t alignment = reader->readUInt8();