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

added experimental usage of roads

This commit is contained in:
AlexVinS 2015-01-03 06:59:51 +03:00
parent 6520d2a577
commit 4c4ad480c5
5 changed files with 46 additions and 20 deletions

View File

@ -482,6 +482,23 @@ enum class ETeleportChannelType
MIXED
};
namespace ERiverType
{
enum ERiverType
{
NO_RIVER, CLEAR_RIVER, ICY_RIVER, MUDDY_RIVER, LAVA_RIVER
};
}
namespace ERoadType
{
enum ERoadType
{
NO_ROAD, DIRT_ROAD, GRAVEL_ROAD, COBBLESTONE_ROAD
};
}
class Obj
{
public:

View File

@ -261,22 +261,6 @@ public:
}
};
namespace ERiverType
{
enum ERiverType
{
NO_RIVER, CLEAR_RIVER, ICY_RIVER, MUDDY_RIVER, LAVA_RIVER
};
}
namespace ERoadType
{
enum ERoadType
{
NO_ROAD, DIRT_ROAD, GRAVEL_ROAD, COBBLESTONE_ROAD
};
}
/// The terrain tile describes the terrain type and the visual representation of the terrain.
/// Furthermore the struct defines whether the tile is visitable or/and blocked and which objects reside in it.
struct DLL_LINKAGE TerrainTile

View File

@ -132,7 +132,7 @@ std::string CMapGenerator::getMapDescription() const
std::stringstream ss;
ss << boost::str(boost::format(std::string("Map created by the Random Map Generator.\nTemplate was %s, Random seed was %d, size %dx%d") +
", levels %s, humans %d, computers %d, water %s, monster %s, second expansion map") % mapGenOptions->getMapTemplate()->getName() %
", levels %s, humans %d, computers %d, water %s, monster %s, VCMI map") % mapGenOptions->getMapTemplate()->getName() %
randomSeed % map->width % map->height % (map->twoLevel ? "2" : "1") % static_cast<int>(mapGenOptions->getPlayerCount()) %
static_cast<int>(mapGenOptions->getCompOnlyPlayerCount()) % waterContentStr[mapGenOptions->getWaterContent()] %
monsterStrengthStr[monsterStrengthIndex]);

View File

@ -81,7 +81,7 @@ void CRmgTemplateZone::CTownInfo::setCastleDensity(int value)
castleDensity = value;
}
CTileInfo::CTileInfo():nearestObjectDistance(INT_MAX), terrain(ETerrainType::WRONG)
CTileInfo::CTileInfo():nearestObjectDistance(INT_MAX), terrain(ETerrainType::WRONG),roadType(ERoadType::NO_ROAD)
{
occupied = ETileType::POSSIBLE; //all tiles are initially possible to place objects or passages
}
@ -135,6 +135,13 @@ void CTileInfo::setTerrainType(ETerrainType value)
terrain = value;
}
void CTileInfo::setRoadType(ERoadType::ERoadType value)
{
roadType = value;
// setOccupied(ETileType::FREE);
}
CRmgTemplateZone::CRmgTemplateZone() :
id(0),
type(ETemplateZoneType::PLAYER_START),
@ -1424,6 +1431,19 @@ void CRmgTemplateZone::createObstacles2(CMapGenerator* gen)
}
}
void CRmgTemplateZone::drawRoads(CMapGenerator* gen)
{
std::vector<int3> tiles;
for (auto tile : freePaths)
{
tiles.push_back (tile);
}
gen->editManager->getTerrainSelection().setSelection(tiles);
gen->editManager->drawRoad(ERoadType::COBBLESTONE_ROAD, &gen->rand);
}
bool CRmgTemplateZone::fill(CMapGenerator* gen)
{
initTerrainType(gen);
@ -1436,7 +1456,9 @@ bool CRmgTemplateZone::fill(CMapGenerator* gen)
createRequiredObjects(gen);
fractalize(gen); //after required objects are created and linked with their own paths
createTreasures(gen);
drawRoads(gen);
logGlobal->infoStream() << boost::format ("Zone %d filled successfully") %id;
return true;
}

View File

@ -51,11 +51,12 @@ public:
ETerrainType getTerrainType() const;
ETileType::ETileType getTileType() const;
void setTerrainType(ETerrainType value);
void setRoadType(ERoadType::ERoadType value);
private:
float nearestObjectDistance;
ETileType::ETileType occupied;
ETerrainType terrain;
ERoadType::ERoadType roadType;
};
class DLL_LINKAGE CTreasureInfo
@ -215,6 +216,8 @@ private:
std::set<int3> possibleTiles; //optimization purposes for treasure generation
std::vector<TRmgTemplateZoneId> connections; //list of adjacent zones
std::set<int3> freePaths; //core paths of free tiles that all other objects will be linked to
void drawRoads(CMapGenerator* gen);
bool pointIsIn(int x, int y);
void addAllPossibleObjects (CMapGenerator* gen); //add objects, including zone-specific, to possibleObjects