mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
@ -243,13 +243,13 @@ void CMapEditManager::clearTerrain(CRandomGenerator * gen)
|
||||
execute(make_unique<CClearTerrainOperation>(map, gen ? gen : &(this->gen)));
|
||||
}
|
||||
|
||||
void CMapEditManager::drawTerrain(ETerrainType terType, CRandomGenerator * gen)
|
||||
void CMapEditManager::drawTerrain(Terrain terType, CRandomGenerator * gen)
|
||||
{
|
||||
execute(make_unique<CDrawTerrainOperation>(map, terrainSel, terType, gen ? gen : &(this->gen)));
|
||||
terrainSel.clearSelection();
|
||||
}
|
||||
|
||||
void CMapEditManager::drawRoad(ERoadType::ERoadType roadType, CRandomGenerator* gen)
|
||||
void CMapEditManager::drawRoad(const std::string & roadType, CRandomGenerator* gen)
|
||||
{
|
||||
execute(make_unique<CDrawRoadsOperation>(map, terrainSel, roadType, gen ? gen : &(this->gen)));
|
||||
terrainSel.clearSelection();
|
||||
@ -534,7 +534,7 @@ void CTerrainViewPatternConfig::flipPattern(TerrainViewPattern & pattern, int fl
|
||||
}
|
||||
|
||||
|
||||
CDrawTerrainOperation::CDrawTerrainOperation(CMap * map, const CTerrainSelection & terrainSel, ETerrainType terType, CRandomGenerator * gen)
|
||||
CDrawTerrainOperation::CDrawTerrainOperation(CMap * map, const CTerrainSelection & terrainSel, Terrain terType, CRandomGenerator * gen)
|
||||
: CMapOperation(map), terrainSel(terrainSel), terType(terType), gen(gen)
|
||||
{
|
||||
|
||||
@ -760,21 +760,17 @@ void CDrawTerrainOperation::updateTerrainViews()
|
||||
}
|
||||
}
|
||||
|
||||
ETerrainGroup::ETerrainGroup CDrawTerrainOperation::getTerrainGroup(ETerrainType terType) const
|
||||
ETerrainGroup::ETerrainGroup CDrawTerrainOperation::getTerrainGroup(Terrain terType) const
|
||||
{
|
||||
switch(terType)
|
||||
{
|
||||
case ETerrainType::DIRT:
|
||||
if(terType == Terrain("dirt"))
|
||||
return ETerrainGroup::DIRT;
|
||||
case ETerrainType::SAND:
|
||||
if(terType == Terrain("sand"))
|
||||
return ETerrainGroup::SAND;
|
||||
case ETerrainType::WATER:
|
||||
if(terType.isWater())
|
||||
return ETerrainGroup::WATER;
|
||||
case ETerrainType::ROCK:
|
||||
if(!terType.isPassable())
|
||||
return ETerrainGroup::ROCK;
|
||||
default:
|
||||
return ETerrainGroup::NORMAL;
|
||||
}
|
||||
return ETerrainGroup::NORMAL;
|
||||
}
|
||||
|
||||
CDrawTerrainOperation::ValidationResult CDrawTerrainOperation::validateTerrainView(const int3 & pos, const std::vector<TerrainViewPattern> * pattern, int recDepth) const
|
||||
@ -811,7 +807,7 @@ CDrawTerrainOperation::ValidationResult CDrawTerrainOperation::validateTerrainVi
|
||||
int cy = pos.y + (i / 3) - 1;
|
||||
int3 currentPos(cx, cy, pos.z);
|
||||
bool isAlien = false;
|
||||
ETerrainType terType;
|
||||
Terrain terType;
|
||||
if(!map->isInTheMap(currentPos))
|
||||
{
|
||||
// position is not in the map, so take the ter type from the neighbor tile
|
||||
@ -949,17 +945,11 @@ CDrawTerrainOperation::ValidationResult CDrawTerrainOperation::validateTerrainVi
|
||||
}
|
||||
}
|
||||
|
||||
bool CDrawTerrainOperation::isSandType(ETerrainType terType) const
|
||||
bool CDrawTerrainOperation::isSandType(Terrain terType) const
|
||||
{
|
||||
switch(terType)
|
||||
{
|
||||
case ETerrainType::WATER:
|
||||
case ETerrainType::SAND:
|
||||
case ETerrainType::ROCK:
|
||||
if(terType.isWater() || terType == Terrain("sand") || !terType.isPassable())
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CDrawTerrainOperation::invalidateTerrainViews(const int3 & centerPos)
|
||||
@ -986,7 +976,7 @@ CDrawTerrainOperation::InvalidTiles CDrawTerrainOperation::getInvalidTiles(const
|
||||
auto valid = validateTerrainView(pos, ptrConfig->getTerrainTypePatternById("n1")).result;
|
||||
|
||||
// Special validity check for rock & water
|
||||
if(valid && (terType == ETerrainType::WATER || terType == ETerrainType::ROCK))
|
||||
if(valid && (terType.isWater() || !terType.isPassable()))
|
||||
{
|
||||
static const std::string patternIds[] = { "s1", "s2" };
|
||||
for(auto & patternId : patternIds)
|
||||
@ -996,7 +986,7 @@ CDrawTerrainOperation::InvalidTiles CDrawTerrainOperation::getInvalidTiles(const
|
||||
}
|
||||
}
|
||||
// Additional validity check for non rock OR water
|
||||
else if(!valid && (terType != ETerrainType::WATER && terType != ETerrainType::ROCK))
|
||||
else if(!valid && (terType.isLand() && terType.isPassable()))
|
||||
{
|
||||
static const std::string patternIds[] = { "n2", "n3" };
|
||||
for(auto & patternId : patternIds)
|
||||
@ -1040,7 +1030,7 @@ void CTerrainViewPatternUtils::printDebuggingInfoAboutTile(const CMap * map, int
|
||||
{
|
||||
auto debugTile = map->getTile(debugPos);
|
||||
|
||||
std::string terType = debugTile.terType.toString().substr(0, 6);
|
||||
std::string terType = static_cast<std::string>(debugTile.terType).substr(0, 6);
|
||||
line += terType;
|
||||
line.insert(line.end(), PADDED_LENGTH - terType.size(), ' ');
|
||||
}
|
||||
@ -1059,12 +1049,12 @@ CClearTerrainOperation::CClearTerrainOperation(CMap * map, CRandomGenerator * ge
|
||||
{
|
||||
CTerrainSelection terrainSel(map);
|
||||
terrainSel.selectRange(MapRect(int3(0, 0, 0), map->width, map->height));
|
||||
addOperation(make_unique<CDrawTerrainOperation>(map, terrainSel, ETerrainType::WATER, gen));
|
||||
addOperation(make_unique<CDrawTerrainOperation>(map, terrainSel, Terrain("water"), gen));
|
||||
if(map->twoLevel)
|
||||
{
|
||||
terrainSel.clearSelection();
|
||||
terrainSel.selectRange(MapRect(int3(0, 0, 1), map->width, map->height));
|
||||
addOperation(make_unique<CDrawTerrainOperation>(map, terrainSel, ETerrainType::ROCK, gen));
|
||||
addOperation(make_unique<CDrawTerrainOperation>(map, terrainSel, Terrain("rock"), gen));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user