Procházet zdrojové kódy

Restored old function signature for sanity.

DjWarmonger před 11 roky
rodič
revize
3acbda75ef

+ 2 - 2
lib/CGameState.cpp

@@ -815,8 +815,8 @@ void CGameState::initNewGame()
 		CStopWatch sw;
 
 		// Gen map
-		CMapGenerator mapGenerator(scenarioOps->mapGenOptions, scenarioOps->seedToBeUsed);
-		map = mapGenerator.generate().release();
+		CMapGenerator mapGenerator;
+		map = mapGenerator.generate(scenarioOps->mapGenOptions.get(), scenarioOps->seedToBeUsed).release();
 
 		// Update starting options
 		for(int i = 0; i < map->players.size(); ++i)

+ 7 - 5
lib/rmg/CMapGenerator.cpp

@@ -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)*/) :
-	mapGenOptions(mapGenOptions), randomSeed(RandomSeed), monolithIndex(0), zonesTotal(0)
+CMapGenerator::CMapGenerator() :
+	monolithIndex(0), zonesTotal(0)
 {
-	rand.setSeed(randomSeed);
 }
 
 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
 }
 
-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);
 
 	map = make_unique<CMap>();
@@ -95,7 +97,7 @@ std::unique_ptr<CMap> CMapGenerator::generate()
 		genZones();
 		map->calculateGuardingGreaturePositions(); //clear map so that all tiles are unguarded
 		fillZones();
-		//updated fuarded tiles will be calculated in CGameState::initMapObjects()
+		//updated guarded tiles will be calculated in CGameState::initMapObjects()
 	}
 	catch (rmgException &e)
 	{

+ 3 - 3
lib/rmg/CMapGenerator.h

@@ -51,12 +51,12 @@ public:
 class DLL_LINKAGE CMapGenerator
 {
 public:
-	explicit CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int RandomSeed = std::time(nullptr));
+	explicit CMapGenerator();
 	~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;
 	CRandomGenerator rand;
 	int randomSeed;

+ 2 - 2
lib/rmg/CZonePlacer.cpp

@@ -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);
 }
 
-void CZonePlacer::placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGenerator * rand)
+void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenerator * rand)
 {
 	//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));
 }
 
-void CZonePlacer::assignZones(shared_ptr<CMapGenOptions> mapGenOptions)
+void CZonePlacer::assignZones(const CMapGenOptions * mapGenOptions)
 {
 	logGlobal->infoStream()  << "Starting zone colouring";
 

+ 2 - 2
lib/rmg/CZonePlacer.h

@@ -43,8 +43,8 @@ public:
 	float metric (const int3 &a, const int3 &b) const;
 	~CZonePlacer();
 
-	void placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGenerator * rand);
-	void assignZones(shared_ptr<CMapGenOptions> mapGenOptions);
+	void placeZones(const CMapGenOptions * mapGenOptions, CRandomGenerator * rand);
+	void assignZones(const CMapGenOptions * mapGenOptions);
 
 private:
 	//metric coefiicients