mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-28 23:06:24 +02:00
b9de3875d9
- Tweaking algorithm parameters - Refactorings
87 lines
2.0 KiB
C++
87 lines
2.0 KiB
C++
|
|
/*
|
|
* CMapGenerator.h, part of VCMI engine
|
|
*
|
|
* Authors: listed in file AUTHORS in main folder
|
|
*
|
|
* License: GNU General Public License v2.0 or later
|
|
* Full text of license available in license.txt file, in main folder
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "../GameConstants.h"
|
|
#include "../CRandomGenerator.h"
|
|
#include "CMapGenOptions.h"
|
|
#include "../CObjectHandler.h"
|
|
#include "../int3.h"
|
|
|
|
class CMap;
|
|
class CRmgTemplate;
|
|
class CRmgTemplateZone;
|
|
class CMapGenOptions;
|
|
class CTerrainViewPatternConfig;
|
|
class CMapEditManager;
|
|
class JsonNode;
|
|
|
|
typedef std::vector<JsonNode> JsonVector;
|
|
|
|
class CMapGenerator;
|
|
|
|
//static const int3 dirs[] = { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0),
|
|
// int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) };
|
|
|
|
class rmgException : std::exception
|
|
{
|
|
std::string msg;
|
|
public:
|
|
explicit rmgException(const std::string& _Message) : msg(_Message)
|
|
{
|
|
}
|
|
|
|
virtual ~rmgException() throw ()
|
|
{
|
|
};
|
|
|
|
const char *what() const throw () override
|
|
{
|
|
return msg.c_str();
|
|
}
|
|
};
|
|
|
|
/// The map generator creates a map randomly.
|
|
class DLL_LINKAGE CMapGenerator
|
|
{
|
|
public:
|
|
explicit CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int randomSeed = std::time(nullptr));
|
|
~CMapGenerator(); // required due to unique_ptr
|
|
|
|
std::unique_ptr<CMap> generate();
|
|
|
|
shared_ptr<CMapGenOptions> mapGenOptions;
|
|
std::unique_ptr<CMap> map;
|
|
CRandomGenerator rand;
|
|
int randomSeed;
|
|
CMapEditManager * editManager;
|
|
|
|
std::map<TRmgTemplateZoneId, CRmgTemplateZone*> getZones() const;
|
|
void foreach_neighbour(const int3 &pos, std::function<void(const int3& pos)> foo);
|
|
|
|
private:
|
|
std::map<TRmgTemplateZoneId, CRmgTemplateZone*> zones;
|
|
|
|
/// Generation methods
|
|
std::string getMapDescription() const;
|
|
void addPlayerInfo();
|
|
void addHeaderInfo();
|
|
void genZones();
|
|
void fillZones();
|
|
|
|
};
|
|
|
|
/* ---------------------------------------------------------------------------- */
|
|
/* Implementation/Detail classes, Private API */
|
|
/* ---------------------------------------------------------------------------- */
|
|
|