1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Corrected road generation - they will be straight whenever possible.

This commit is contained in:
DjWarmonger
2016-12-15 12:36:47 +01:00
parent f18d3d9844
commit 4102546977
3 changed files with 41 additions and 19 deletions

View File

@@ -12,6 +12,7 @@
#include "../mapObjects/CObjectClassesHandler.h"
static const int3 dirs4[] = {int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0)};
static const int3 dirsDiagonal[] = { int3(1,1,0),int3(1,-1,0),int3(-1,1,0),int3(-1,-1,0) };
void CMapGenerator::foreach_neighbour(const int3 &pos, std::function<void(int3& pos)> foo)
{
@@ -35,6 +36,16 @@ void CMapGenerator::foreachDirectNeighbour(const int3& pos, std::function<void(i
}
}
void CMapGenerator::foreachDiagonaltNeighbour(const int3& pos, std::function<void(int3& pos)> foo)
{
for (const int3 &dir : dirsDiagonal)
{
int3 n = pos + dir;
if (map->isInTheMap(n))
foo(n);
}
}
CMapGenerator::CMapGenerator() :
mapGenOptions(nullptr), randomSeed(0), editManager(nullptr),