1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Randomized connections placement (?)

This commit is contained in:
DjWarmonger 2014-06-01 10:15:03 +02:00
parent 3c6a1fb715
commit e97933035c

View File

@ -318,6 +318,18 @@ std::set<int3> CRmgTemplateZone::getTileInfo () const
void CRmgTemplateZone::createConnections(CMapGenerator* gen)
{
//rearrange tiles in random order
std::vector<int3> tiles(tileinfo.begin(), tileinfo.end());
//TODO: hwo to use std::shuffle with our generator?
//std::random_shuffle (tiles.begin(), tiles.end(), &gen->rand.nextInt);
int i, n;
n = (tiles.end() - tiles.begin());
for (i=n-1; i>0; --i)
{
std::swap (tiles.begin()[i],tiles.begin()[gen->rand.nextInt(i+1)]);
}
for (auto connection : connections)
{
if (getId() > connection) //only one connection between each pair
@ -328,7 +340,7 @@ void CRmgTemplateZone::createConnections(CMapGenerator* gen)
auto otherZoneTiles = gen->getZones()[connection]->getTileInfo();
auto otherZoneCenter = gen->getZones()[connection]->getPos();
for (auto tile : tileinfo)
for (auto tile : tiles)
{
gen->foreach_neighbour (tile, [&guardPos, tile, &otherZoneTiles](int3 &pos)
{