mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Fix loading of some user-made maps
This commit is contained in:
@@ -75,7 +75,7 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesAB()
|
|||||||
result.factionsBytes = 2; // + Conflux
|
result.factionsBytes = 2; // + Conflux
|
||||||
result.factionsCount = 9;
|
result.factionsCount = 9;
|
||||||
|
|
||||||
result.creaturesCount = 144; // + Conflux and new neutrals
|
result.creaturesCount = 145; // + Conflux and new neutrals
|
||||||
|
|
||||||
result.heroesCount = 156; // + Conflux and campaign heroes
|
result.heroesCount = 156; // + Conflux and campaign heroes
|
||||||
result.heroesPortraitsCount = 163;
|
result.heroesPortraitsCount = 163;
|
||||||
|
|||||||
@@ -38,8 +38,11 @@ ArtifactID MapReaderH3M::readArtifact()
|
|||||||
if(result == features.artifactIdentifierInvalid)
|
if(result == features.artifactIdentifierInvalid)
|
||||||
return ArtifactID::NONE;
|
return ArtifactID::NONE;
|
||||||
|
|
||||||
assert(result < features.artifactsCount);
|
if (result < features.artifactsCount)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
logGlobal->warn("Map contains invalid artifact %d. Will be removed!", result.getNum());
|
||||||
|
return ArtifactID::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArtifactID MapReaderH3M::readArtifact32()
|
ArtifactID MapReaderH3M::readArtifact32()
|
||||||
@@ -49,8 +52,11 @@ ArtifactID MapReaderH3M::readArtifact32()
|
|||||||
if(result == ArtifactID::NONE)
|
if(result == ArtifactID::NONE)
|
||||||
return ArtifactID::NONE;
|
return ArtifactID::NONE;
|
||||||
|
|
||||||
assert(result < features.artifactsCount);
|
if (result < features.artifactsCount)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
logGlobal->warn("Map contains invalid artifact %d. Will be removed!", result.getNum());
|
||||||
|
return ArtifactID::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeroTypeID MapReaderH3M::readHero()
|
HeroTypeID MapReaderH3M::readHero()
|
||||||
@@ -76,16 +82,18 @@ CreatureID MapReaderH3M::readCreature()
|
|||||||
if(result == features.creatureIdentifierInvalid)
|
if(result == features.creatureIdentifierInvalid)
|
||||||
return CreatureID::NONE;
|
return CreatureID::NONE;
|
||||||
|
|
||||||
if(result > features.creaturesCount)
|
if(result < features.creaturesCount)
|
||||||
{
|
return result;
|
||||||
// this may be random creature in army/town, to be randomized later
|
|
||||||
CreatureID randomIndex(result.getNum() - features.creatureIdentifierInvalid - 1);
|
|
||||||
assert(randomIndex < CreatureID::NONE);
|
|
||||||
assert(randomIndex > -16);
|
|
||||||
return randomIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
// this may be random creature in army/town, to be randomized later
|
||||||
|
CreatureID randomIndex(result.getNum() - features.creatureIdentifierInvalid - 1);
|
||||||
|
assert(randomIndex < CreatureID::NONE);
|
||||||
|
|
||||||
|
if (randomIndex > -16)
|
||||||
|
return randomIndex;
|
||||||
|
|
||||||
|
logGlobal->warn("Map contains invalid creature %d. Will be removed!", result.getNum());
|
||||||
|
return CreatureID::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrainId MapReaderH3M::readTerrain()
|
TerrainId MapReaderH3M::readTerrain()
|
||||||
|
|||||||
Reference in New Issue
Block a user