1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Merge pull request #1638 from rilian-la-te/fix-road-river

vcmi: fix road and river loading
This commit is contained in:
Ivan Savenko 2023-03-09 15:53:10 +02:00 committed by GitHub
commit a503c9d413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1005,27 +1005,20 @@ void CMapLoaderJson::readTerrainTile(const std::string & src, TerrainTile & tile
if (startPos >= src.size())
return;
bool hasRoad = true;
//FIXME: check without exceptions?
{//road type
const std::string typeCode = src.substr(startPos, 2);
startPos += 2;
try
tile.roadType = getRoadByCode(typeCode);
if(!tile.roadType) //it's not a road, it's a river
{
tile.roadType = getRoadByCode(typeCode);
}
catch (const std::exception&) //it's not a road, it's a river
{
try
{
tile.riverType = getRiverByCode(typeCode);
hasRoad = false;
}
catch (const std::exception&)
tile.roadType = VLC->roadTypeHandler->getById(Road::NO_ROAD);
tile.riverType = getRiverByCode(typeCode);
hasRoad = false;
if(!tile.riverType)
{
throw std::runtime_error("Invalid river type in " + src);
}
}
}
}
if (hasRoad)
{//road dir