mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Restored old function signature for sanity.
This commit is contained in:
parent
713912574a
commit
3acbda75ef
@ -815,8 +815,8 @@ void CGameState::initNewGame()
|
|||||||
CStopWatch sw;
|
CStopWatch sw;
|
||||||
|
|
||||||
// Gen map
|
// Gen map
|
||||||
CMapGenerator mapGenerator(scenarioOps->mapGenOptions, scenarioOps->seedToBeUsed);
|
CMapGenerator mapGenerator;
|
||||||
map = mapGenerator.generate().release();
|
map = mapGenerator.generate(scenarioOps->mapGenOptions.get(), scenarioOps->seedToBeUsed).release();
|
||||||
|
|
||||||
// Update starting options
|
// Update starting options
|
||||||
for(int i = 0; i < map->players.size(); ++i)
|
for(int i = 0; i < map->players.size(); ++i)
|
||||||
|
@ -24,10 +24,9 @@ void CMapGenerator::foreach_neighbour(const int3 &pos, std::function<void(int3&
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CMapGenerator::CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int RandomSeed /*= std::time(nullptr)*/) :
|
CMapGenerator::CMapGenerator() :
|
||||||
mapGenOptions(mapGenOptions), randomSeed(RandomSeed), monolithIndex(0), zonesTotal(0)
|
monolithIndex(0), zonesTotal(0)
|
||||||
{
|
{
|
||||||
rand.setSeed(randomSeed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapGenerator::initTiles()
|
void CMapGenerator::initTiles()
|
||||||
@ -78,8 +77,11 @@ void CMapGenerator::initPrisonsRemaining()
|
|||||||
prisonsRemaining = std::max<int> (0, prisonsRemaining - 16 * map->players.size()); //so at least 16 heroes will be available for every player
|
prisonsRemaining = std::max<int> (0, prisonsRemaining - 16 * map->players.size()); //so at least 16 heroes will be available for every player
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CMap> CMapGenerator::generate()
|
std::unique_ptr<CMap> CMapGenerator::generate(CMapGenOptions * mapGenOptions, int randomSeed /*= std::time(nullptr)*/)
|
||||||
{
|
{
|
||||||
|
this->mapGenOptions = mapGenOptions;
|
||||||
|
this->randomSeed = randomSeed;
|
||||||
|
rand.setSeed(this->randomSeed);
|
||||||
mapGenOptions->finalize(rand);
|
mapGenOptions->finalize(rand);
|
||||||
|
|
||||||
map = make_unique<CMap>();
|
map = make_unique<CMap>();
|
||||||
@ -95,7 +97,7 @@ std::unique_ptr<CMap> CMapGenerator::generate()
|
|||||||
genZones();
|
genZones();
|
||||||
map->calculateGuardingGreaturePositions(); //clear map so that all tiles are unguarded
|
map->calculateGuardingGreaturePositions(); //clear map so that all tiles are unguarded
|
||||||
fillZones();
|
fillZones();
|
||||||
//updated fuarded tiles will be calculated in CGameState::initMapObjects()
|
//updated guarded tiles will be calculated in CGameState::initMapObjects()
|
||||||
}
|
}
|
||||||
catch (rmgException &e)
|
catch (rmgException &e)
|
||||||
{
|
{
|
||||||
|
@ -51,12 +51,12 @@ public:
|
|||||||
class DLL_LINKAGE CMapGenerator
|
class DLL_LINKAGE CMapGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int RandomSeed = std::time(nullptr));
|
explicit CMapGenerator();
|
||||||
~CMapGenerator(); // required due to unique_ptr
|
~CMapGenerator(); // required due to unique_ptr
|
||||||
|
|
||||||
std::unique_ptr<CMap> generate();
|
std::unique_ptr<CMap> generate(CMapGenOptions * mapGenOptions, int RandomSeed = std::time(nullptr));
|
||||||
|
|
||||||
shared_ptr<CMapGenOptions> mapGenOptions;
|
CMapGenOptions * mapGenOptions;
|
||||||
std::unique_ptr<CMap> map;
|
std::unique_ptr<CMap> map;
|
||||||
CRandomGenerator rand;
|
CRandomGenerator rand;
|
||||||
int randomSeed;
|
int randomSeed;
|
||||||
|
@ -38,7 +38,7 @@ int3 CZonePlacer::cords (const float3 f) const
|
|||||||
return int3(std::max(0.f, (f.x * gen->map->width)-1), std::max(0.f, (f.y * gen->map->height-1)), f.z);
|
return int3(std::max(0.f, (f.x * gen->map->width)-1), std::max(0.f, (f.y * gen->map->height-1)), f.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CZonePlacer::placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGenerator * rand)
|
void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenerator * rand)
|
||||||
{
|
{
|
||||||
//gravity-based algorithm
|
//gravity-based algorithm
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ d = 0.01 * dx^3 - 0.1618 * dx^2 + 1 * dx + ...
|
|||||||
return dx * (1 + dx * (0.1 + dx * 0.01)) + dy * (1.618 + dy * (-0.1618 + dy * 0.01618));
|
return dx * (1 + dx * (0.1 + dx * 0.01)) + dy * (1.618 + dy * (-0.1618 + dy * 0.01618));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CZonePlacer::assignZones(shared_ptr<CMapGenOptions> mapGenOptions)
|
void CZonePlacer::assignZones(const CMapGenOptions * mapGenOptions)
|
||||||
{
|
{
|
||||||
logGlobal->infoStream() << "Starting zone colouring";
|
logGlobal->infoStream() << "Starting zone colouring";
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ public:
|
|||||||
float metric (const int3 &a, const int3 &b) const;
|
float metric (const int3 &a, const int3 &b) const;
|
||||||
~CZonePlacer();
|
~CZonePlacer();
|
||||||
|
|
||||||
void placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGenerator * rand);
|
void placeZones(const CMapGenOptions * mapGenOptions, CRandomGenerator * rand);
|
||||||
void assignZones(shared_ptr<CMapGenOptions> mapGenOptions);
|
void assignZones(const CMapGenOptions * mapGenOptions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//metric coefiicients
|
//metric coefiicients
|
||||||
|
Loading…
Reference in New Issue
Block a user