1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Replaced Terrain::BORDER and WRONG with NONE

This commit is contained in:
Ivan Savenko 2023-01-10 20:09:09 +02:00
parent 1b25043dab
commit 1e37e66e6c
7 changed files with 15 additions and 13 deletions

View File

@ -2372,7 +2372,7 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
for (auto & elem : path.nodes)
elem.coord = h->convertFromVisitablePos(elem.coord);
TerrainId currentTerrain = ETerrainId::BORDER; // not init yet
TerrainId currentTerrain = ETerrainId::NONE;
TerrainId newTerrain;
bool wasOnRoad = true;
int sh = -1;

View File

@ -1222,8 +1222,7 @@ class BattleField : public BaseForID<BattleField, si32>
enum class ETerrainId {
NATIVE_TERRAIN = -4,
ANY_TERRAIN = -3,
WRONG = -2,
BORDER = -1,
NONE = -1,
FIRST_REGULAR_TERRAIN = 0,
DIRT = 0,
SAND,

View File

@ -721,7 +721,7 @@ DLL_LINKAGE void GiveHero::applyGs(CGameState *gs)
DLL_LINKAGE void NewObject::applyGs(CGameState *gs)
{
TerrainId terrainType = ETerrainId::BORDER;
TerrainId terrainType = ETerrainId::NONE;
if(ID == Obj::BOAT && !gs->isInTheMap(pos)) //special handling for bug #3060 - pos outside map but visitablePos is not
{

View File

@ -88,7 +88,7 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile & dest, const TerrainTile & f
}
else if(ti->nativeTerrain != from.terType->getId() &&//the terrain is not native
ti->nativeTerrain != ETerrainId::ANY_TERRAIN && //no special creature bonus
!ti->hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType->getId().getNum())) //no special movement bonus
!ti->hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType->getIndex())) //no special movement bonus
{
ret = VLC->heroh->terrCosts[from.terType->getId()];
@ -105,20 +105,21 @@ TerrainId CGHeroInstance::getNativeTerrain() const
// This is clearly bug in H3 however intended behaviour is not clear.
// Current VCMI behaviour will ignore neutrals in calculations so army in VCMI
// will always have best penalty without any influence from player-defined stacks order
// and army that consist solely from neutral will always be considered to be on native terrain
// TODO: What should we do if all hero stacks are neutral creatures?
TerrainId nativeTerrain = ETerrainId::BORDER;
TerrainId nativeTerrain = ETerrainId::ANY_TERRAIN;
for(auto stack : stacks)
{
TerrainId stackNativeTerrain = stack.second->type->getNativeTerrain(); //consider terrain bonuses e.g. Lodestar.
if(stackNativeTerrain == ETerrainId::BORDER) //where does this value come from?
if(stackNativeTerrain == ETerrainId::NONE)
continue;
if(nativeTerrain == ETerrainId::BORDER)
if(nativeTerrain == ETerrainId::ANY_TERRAIN)
nativeTerrain = stackNativeTerrain;
else if(nativeTerrain != stackNativeTerrain)
return ETerrainId::BORDER;
return ETerrainId::NONE;
}
return nativeTerrain;
}

View File

@ -942,8 +942,10 @@ void CMapLoaderH3M::readTerrain()
tile.roadType = const_cast<RoadType*>(VLC->roadTypeHandler->getByIndex(reader.readUInt8()));
tile.roadDir = reader.readUInt8();
tile.extTileFlags = reader.readUInt8();
tile.blocked = ((!tile.terType->isPassable() || tile.terType->getId() == ETerrainId::BORDER ) ? true : false); //underground tiles are always blocked
tile.blocked = !tile.terType->isPassable();
tile.visitable = 0;
assert(tile.terType->getId() != ETerrainId::NONE);
}
}
}

View File

@ -224,7 +224,7 @@ const std::set<TerrainId> & ZoneOptions::getTerrainTypes() const
void ZoneOptions::setTerrainTypes(const std::set<TerrainId> & value)
{
//assert(value.find(ETerrainType::WRONG) == value.end() && value.find(ETerrainType::BORDER) == value.end() &&
//assert(value.find(ETerrainType::NONE) == value.end() &&
// value.find(ETerrainType::WATER) == value.end() && value.find(ETerrainType::ROCK) == value.end());
terrainTypes = value;
}

View File

@ -195,7 +195,7 @@ void CZonePlacer::prepareZones(TZoneMap &zones, TZoneVector &zonesVector, const
else
{
auto & tt = (*VLC->townh)[faction]->nativeTerrain;
if(tt == ETerrainId::DIRT)
if(tt == ETerrainId::NONE)
{
//any / random
zonesToPlace.push_back(zone);