mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Randomized connections placement (?)
This commit is contained in:
@ -318,6 +318,18 @@ std::set<int3> CRmgTemplateZone::getTileInfo () const
|
|||||||
|
|
||||||
void CRmgTemplateZone::createConnections(CMapGenerator* gen)
|
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)
|
for (auto connection : connections)
|
||||||
{
|
{
|
||||||
if (getId() > connection) //only one connection between each pair
|
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 otherZoneTiles = gen->getZones()[connection]->getTileInfo();
|
||||||
auto otherZoneCenter = gen->getZones()[connection]->getPos();
|
auto otherZoneCenter = gen->getZones()[connection]->getPos();
|
||||||
|
|
||||||
for (auto tile : tileinfo)
|
for (auto tile : tiles)
|
||||||
{
|
{
|
||||||
gen->foreach_neighbour (tile, [&guardPos, tile, &otherZoneTiles](int3 &pos)
|
gen->foreach_neighbour (tile, [&guardPos, tile, &otherZoneTiles](int3 &pos)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user