1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Merge branch 'develop' into FFMpeg

This commit is contained in:
AlexVinS
2014-07-26 13:07:45 +04:00
5 changed files with 18 additions and 27 deletions

View File

@@ -223,9 +223,6 @@ if (NOT APPLE)
install(DIRECTORY config DESTINATION ${DATA_DIR} PATTERN ".svn" EXCLUDE) install(DIRECTORY config DESTINATION ${DATA_DIR} PATTERN ".svn" EXCLUDE)
# copy vcmi mod along with all its content # copy vcmi mod along with all its content
install(DIRECTORY Mods/vcmi DESTINATION ${DATA_DIR}/Mods PATTERN ".svn" EXCLUDE) install(DIRECTORY Mods/vcmi DESTINATION ${DATA_DIR}/Mods PATTERN ".svn" EXCLUDE)
# copy only files added by vcmi for WoG
install(FILES Mods/WoG/mod.json DESTINATION ${DATA_DIR}/Mods/WoG)
install(DIRECTORY Mods/WoG/config DESTINATION ${DATA_DIR}/Mods/WoG PATTERN ".svn" EXCLUDE)
install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS
OWNER_WRITE OWNER_READ OWNER_EXECUTE OWNER_WRITE OWNER_READ OWNER_EXECUTE

View File

@@ -64,7 +64,6 @@
}, },
"azureDragon" : "azureDragon" :
{ {
"special" : true,
"index": 132, "index": 132,
"level": 10, "level": 10,
"faction": "neutral", "faction": "neutral",
@@ -107,7 +106,6 @@
}, },
"crystalDragon" : "crystalDragon" :
{ {
"special" : true,
"index": 133, "index": 133,
"level": 10, "level": 10,
"faction": "neutral", "faction": "neutral",
@@ -141,7 +139,6 @@
}, },
"fairieDragon" : "fairieDragon" :
{ {
"special" : true,
"index": 134, "index": 134,
"level": 8, "level": 8,
"faction": "neutral", "faction": "neutral",
@@ -239,7 +236,6 @@
}, },
"rustDragon" : "rustDragon" :
{ {
"special" : true,
"index": 135, "index": 135,
"level": 10, "level": 10,
"faction": "neutral", "faction": "neutral",
@@ -277,7 +273,6 @@
}, },
"enchanter" : "enchanter" :
{ {
"special" : true,
"index": 136, "index": 136,
"level": 6, "level": 6,
"extraNames": [ "enchanters" ], "extraNames": [ "enchanters" ],
@@ -357,7 +352,6 @@
}, },
"sharpshooter" : "sharpshooter" :
{ {
"special" : true,
"index": 137, "index": 137,
"level": 4, "level": 4,
"extraNames": [ "sharpshooters" ], "extraNames": [ "sharpshooters" ],

View File

@@ -470,7 +470,7 @@ int CMapGenerator::getPrisonsRemaning() const
} }
void CMapGenerator::decreasePrisonsRemaining() void CMapGenerator::decreasePrisonsRemaining()
{ {
prisonsRemaining = std::max (0, prisonsRemaining--); prisonsRemaining = std::max (0, prisonsRemaining - 1);
} }
void CMapGenerator::registerZone (TFaction faction) void CMapGenerator::registerZone (TFaction faction)

View File

@@ -1159,7 +1159,7 @@ void CRmgTemplateZone::createObstacles(CMapGenerator* gen)
{ {
possibleObstacles.push_back (std::make_pair(o.first, o.second)); possibleObstacles.push_back (std::make_pair(o.first, o.second));
} }
boost::sort (possibleObstacles, [](obstaclePair &p1, obstaclePair &p2) -> bool boost::sort (possibleObstacles, [](const obstaclePair &p1, const obstaclePair &p2) -> bool
{ {
return p1.first > p2.first; //bigger obstacles first return p1.first > p2.first; //bigger obstacles first
}); });
@@ -1184,7 +1184,7 @@ void CRmgTemplateZone::createObstacles(CMapGenerator* gen)
for (auto tile : boost::adaptors::reverse(tileinfo)) for (auto tile : boost::adaptors::reverse(tileinfo))
{ {
//fill tiles that should be blocked with obstacles or are just possible (with some probability) //fill tiles that should be blocked with obstacles or are just possible (with some probability)
if (gen->shouldBeBlocked(tile) || gen->isPossible(tile) && gen->rand.nextInt(1,100) < 60) if (gen->shouldBeBlocked(tile) || (gen->isPossible(tile) && gen->rand.nextInt(1,100) < 60))
{ {
//start from biggets obstacles //start from biggets obstacles
for (int i = 0; i < possibleObstacles.size(); i++) for (int i = 0; i < possibleObstacles.size(); i++)

View File

@@ -40,12 +40,11 @@ int3 CZonePlacer::cords (const float3 f) const
void CZonePlacer::placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGenerator * rand) void CZonePlacer::placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGenerator * rand)
{ {
//some relaxation-simmulated annealing algorithm //gravity-based algorithm
const int iterations = 100; float gravityConstant = 1e-2;
float temperatureConstant = 1e-2; float zoneScale = 0.5f; //zones starts small and then inflate
float currentTemperature = 2; //geater temperature - stronger gravity, weaker pushing away const float inflateModifier = 1.02;
const float temperatureModifier = 0.99;
logGlobal->infoStream() << "Starting zone placement"; logGlobal->infoStream() << "Starting zone placement";
@@ -108,7 +107,7 @@ void CZonePlacer::placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGe
}; };
std::map <CRmgTemplateZone *, float3> forces; std::map <CRmgTemplateZone *, float3> forces;
for (int i = 0; i < iterations; ++i) while (zoneScale < 1) //until zones reach their desired size and fill the map tightly
{ {
for (auto zone : zones) for (auto zone : zones)
{ {
@@ -121,11 +120,11 @@ void CZonePlacer::placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGe
auto otherZone = zones[con]; auto otherZone = zones[con];
float3 otherZoneCenter = otherZone->getCenter(); float3 otherZoneCenter = otherZone->getCenter();
float distance = pos.dist2d (otherZoneCenter); float distance = pos.dist2d (otherZoneCenter);
float minDistance = (zone.second->getSize() + otherZone->getSize())/mapSize; //scale down to (0,1) coordinates float minDistance = (zone.second->getSize() + otherZone->getSize())/mapSize * zoneScale; //scale down to (0,1) coordinates
if (distance > minDistance) if (distance > minDistance)
{ {
//WARNING: compiler used to 'optimize' that line so it never actually worked //WARNING: compiler used to 'optimize' that line so it never actually worked
forceVector += (((otherZoneCenter - pos) / getDistance(distance)) * currentTemperature); //positive value forceVector += (((otherZoneCenter - pos) / getDistance(distance))); //positive value
} }
} }
//separate overlaping zones //separate overlaping zones
@@ -137,21 +136,22 @@ void CZonePlacer::placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGe
continue; continue;
float distance = pos.dist2d (otherZoneCenter); float distance = pos.dist2d (otherZoneCenter);
float minDistance = (zone.second->getSize() + otherZone.second->getSize())/mapSize; float minDistance = (zone.second->getSize() + otherZone.second->getSize())/mapSize * zoneScale;
if (distance < minDistance) if (distance < minDistance)
{ {
forceVector -= (otherZoneCenter - pos) / getDistance(distance) / currentTemperature; //negative value forceVector -= (otherZoneCenter - pos) / getDistance(distance); //negative value
} }
} }
//move zones away from boundaries //move zones away from boundaries
//do not scale boundary distance - zones tend to get squashed
float size = zone.second->getSize() / mapSize; float size = zone.second->getSize() / mapSize;
auto pushAwayFromBoundary = [&forceVector, pos, currentTemperature, &getDistance](float x, float y) auto pushAwayFromBoundary = [&forceVector, pos, &getDistance](float x, float y)
{ {
float3 boundary = float3 (x, y, pos.z); float3 boundary = float3 (x, y, pos.z);
float distance = pos.dist2d(boundary); float distance = pos.dist2d(boundary);
forceVector -= (boundary - pos) / getDistance(distance) / currentTemperature; //negative value forceVector -= (boundary - pos) / getDistance(distance); //negative value
}; };
if (pos.x < size) if (pos.x < size)
{ {
@@ -171,14 +171,14 @@ void CZonePlacer::placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGe
} }
forceVector.z = 0; //operator - doesn't preserve z coordinate :/ forceVector.z = 0; //operator - doesn't preserve z coordinate :/
forces[zone.second] = forceVector * temperatureConstant; forces[zone.second] = forceVector * gravityConstant;
} }
//update positions //update positions
for (auto zone : forces) for (auto zone : forces)
{ {
zone.first->setCenter (zone.first->getCenter() + zone.second); zone.first->setCenter (zone.first->getCenter() + zone.second);
} }
currentTemperature *= temperatureModifier; //decrease temperature (needed?) zoneScale *= inflateModifier; //increase size
} }
for (auto zone : zones) //finalize zone positions for (auto zone : zones) //finalize zone positions
{ {