mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Fix loading of some user-made maps
This commit is contained in:
parent
eff6551f80
commit
402823e3d5
@ -75,7 +75,7 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesAB()
|
||||
result.factionsBytes = 2; // + Conflux
|
||||
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.heroesPortraitsCount = 163;
|
||||
|
@ -38,8 +38,11 @@ ArtifactID MapReaderH3M::readArtifact()
|
||||
if(result == features.artifactIdentifierInvalid)
|
||||
return ArtifactID::NONE;
|
||||
|
||||
assert(result < features.artifactsCount);
|
||||
return result;
|
||||
if (result < features.artifactsCount)
|
||||
return result;
|
||||
|
||||
logGlobal->warn("Map contains invalid artifact %d. Will be removed!", result.getNum());
|
||||
return ArtifactID::NONE;
|
||||
}
|
||||
|
||||
ArtifactID MapReaderH3M::readArtifact32()
|
||||
@ -49,8 +52,11 @@ ArtifactID MapReaderH3M::readArtifact32()
|
||||
if(result == ArtifactID::NONE)
|
||||
return ArtifactID::NONE;
|
||||
|
||||
assert(result < features.artifactsCount);
|
||||
return result;
|
||||
if (result < features.artifactsCount)
|
||||
return result;
|
||||
|
||||
logGlobal->warn("Map contains invalid artifact %d. Will be removed!", result.getNum());
|
||||
return ArtifactID::NONE;
|
||||
}
|
||||
|
||||
HeroTypeID MapReaderH3M::readHero()
|
||||
@ -76,16 +82,18 @@ CreatureID MapReaderH3M::readCreature()
|
||||
if(result == features.creatureIdentifierInvalid)
|
||||
return CreatureID::NONE;
|
||||
|
||||
if(result > features.creaturesCount)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
if(result < features.creaturesCount)
|
||||
return result;
|
||||
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user