CMapGenerator.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. #include "StdInc.h"
  2. #include "CMapGenerator.h"
  3. #include "../mapping/CMap.h"
  4. #include "../VCMI_Lib.h"
  5. #include "../CGeneralTextHandler.h"
  6. #include "../mapping/CMapEditManager.h"
  7. #include "../CTownHandler.h"
  8. #include "../StringConstants.h"
  9. #include "../filesystem/Filesystem.h"
  10. #include "CRmgTemplate.h"
  11. #include "CRmgTemplateZone.h"
  12. #include "CZonePlacer.h"
  13. #include "../mapObjects/CObjectClassesHandler.h"
  14. void CMapGenerator::foreach_neighbour(const int3 &pos, std::function<void(int3& pos)> foo)
  15. {
  16. for(const int3 &dir : dirs)
  17. {
  18. int3 n = pos + dir;
  19. if(map->isInTheMap(n))
  20. foo(n);
  21. }
  22. }
  23. CMapGenerator::CMapGenerator() :
  24. zonesTotal(0), monolithIndex(0)
  25. {
  26. }
  27. void CMapGenerator::initTiles()
  28. {
  29. map->initTerrain();
  30. int width = map->width;
  31. int height = map->height;
  32. int level = map->twoLevel ? 2 : 1;
  33. tiles = new CTileInfo**[width];
  34. for (int i = 0; i < width; ++i)
  35. {
  36. tiles[i] = new CTileInfo*[height];
  37. for (int j = 0; j < height; ++j)
  38. {
  39. tiles[i][j] = new CTileInfo[level];
  40. }
  41. }
  42. }
  43. CMapGenerator::~CMapGenerator()
  44. {
  45. if (tiles)
  46. {
  47. int width = mapGenOptions->getWidth();
  48. int height = mapGenOptions->getHeight();
  49. for (int i=0; i < width; i++)
  50. {
  51. for(int j=0; j < height; j++)
  52. {
  53. delete [] tiles[i][j];
  54. }
  55. delete [] tiles[i];
  56. }
  57. delete [] tiles;
  58. }
  59. }
  60. void CMapGenerator::initPrisonsRemaining()
  61. {
  62. prisonsRemaining = 0;
  63. for (auto isAllowed : map->allowedHeroes)
  64. {
  65. if (isAllowed)
  66. prisonsRemaining++;
  67. }
  68. prisonsRemaining = std::max<int> (0, prisonsRemaining - 16 * mapGenOptions->getPlayerCount()); //so at least 16 heroes will be available for every player
  69. }
  70. void CMapGenerator::initQuestArtsRemaining()
  71. {
  72. for (auto art : VLC->arth->artifacts)
  73. {
  74. if (art->aClass == CArtifact::ART_TREASURE && art->constituentOf.empty()) //don't use parts of combined artifacts
  75. questArtifacts.push_back(art->id);
  76. }
  77. }
  78. std::unique_ptr<CMap> CMapGenerator::generate(CMapGenOptions * mapGenOptions, int randomSeed /*= std::time(nullptr)*/)
  79. {
  80. this->mapGenOptions = mapGenOptions;
  81. this->randomSeed = randomSeed;
  82. assert(mapGenOptions);
  83. rand.setSeed(this->randomSeed);
  84. mapGenOptions->finalize(rand);
  85. map = make_unique<CMap>();
  86. editManager = map->getEditManager();
  87. try
  88. {
  89. editManager->getUndoManager().setUndoRedoLimit(0);
  90. //FIXME: somehow mapGenOption is nullptr at this point :?
  91. addHeaderInfo();
  92. initTiles();
  93. initPrisonsRemaining();
  94. initQuestArtsRemaining();
  95. genZones();
  96. map->calculateGuardingGreaturePositions(); //clear map so that all tiles are unguarded
  97. fillZones();
  98. //updated guarded tiles will be calculated in CGameState::initMapObjects()
  99. }
  100. catch (rmgException &e)
  101. {
  102. logGlobal->errorStream() << "Random map generation received exception: " << e.what();
  103. }
  104. return std::move(map);
  105. }
  106. std::string CMapGenerator::getMapDescription() const
  107. {
  108. assert(mapGenOptions);
  109. assert(map);
  110. const std::string waterContentStr[3] = { "none", "normal", "islands" };
  111. const std::string monsterStrengthStr[3] = { "weak", "normal", "strong" };
  112. int monsterStrengthIndex = mapGenOptions->getMonsterStrength() - EMonsterStrength::GLOBAL_WEAK; //does not start from 0
  113. std::stringstream ss;
  114. ss << boost::str(boost::format(std::string("Map created by the Random Map Generator.\nTemplate was %s, Random seed was %d, size %dx%d") +
  115. ", levels %s, humans %d, computers %d, water %s, monster %s, VCMI map") % mapGenOptions->getMapTemplate()->getName() %
  116. randomSeed % map->width % map->height % (map->twoLevel ? "2" : "1") % static_cast<int>(mapGenOptions->getPlayerCount()) %
  117. static_cast<int>(mapGenOptions->getCompOnlyPlayerCount()) % waterContentStr[mapGenOptions->getWaterContent()] %
  118. monsterStrengthStr[monsterStrengthIndex]);
  119. for(const auto & pair : mapGenOptions->getPlayersSettings())
  120. {
  121. const auto & pSettings = pair.second;
  122. if(pSettings.getPlayerType() == EPlayerType::HUMAN)
  123. {
  124. ss << ", " << GameConstants::PLAYER_COLOR_NAMES[pSettings.getColor().getNum()] << " is human";
  125. }
  126. if(pSettings.getStartingTown() != CMapGenOptions::CPlayerSettings::RANDOM_TOWN)
  127. {
  128. ss << ", " << GameConstants::PLAYER_COLOR_NAMES[pSettings.getColor().getNum()]
  129. << " town choice is " << VLC->townh->factions[pSettings.getStartingTown()]->name;
  130. }
  131. }
  132. return ss.str();
  133. }
  134. void CMapGenerator::addPlayerInfo()
  135. {
  136. // Calculate which team numbers exist
  137. std::array<std::list<int>, 2> teamNumbers; // 0= cpu/human, 1= cpu only
  138. int teamOffset = 0;
  139. for(int i = 0; i < 2; ++i)
  140. {
  141. int playerCount = i == 0 ? mapGenOptions->getPlayerCount() : mapGenOptions->getCompOnlyPlayerCount();
  142. int teamCount = i == 0 ? mapGenOptions->getTeamCount() : mapGenOptions->getCompOnlyTeamCount();
  143. if(playerCount == 0)
  144. {
  145. continue;
  146. }
  147. int playersPerTeam = playerCount /
  148. (teamCount == 0 ? playerCount : teamCount);
  149. int teamCountNorm = teamCount;
  150. if(teamCountNorm == 0)
  151. {
  152. teamCountNorm = playerCount;
  153. }
  154. for(int j = 0; j < teamCountNorm; ++j)
  155. {
  156. for(int k = 0; k < playersPerTeam; ++k)
  157. {
  158. teamNumbers[i].push_back(j + teamOffset);
  159. }
  160. }
  161. for(int j = 0; j < playerCount - teamCountNorm * playersPerTeam; ++j)
  162. {
  163. teamNumbers[i].push_back(j + teamOffset);
  164. }
  165. teamOffset += teamCountNorm;
  166. }
  167. // Team numbers are assigned randomly to every player
  168. for(const auto & pair : mapGenOptions->getPlayersSettings())
  169. {
  170. const auto & pSettings = pair.second;
  171. PlayerInfo player;
  172. player.canComputerPlay = true;
  173. int j = pSettings.getPlayerType() == EPlayerType::COMP_ONLY ? 1 : 0;
  174. if(j == 0)
  175. {
  176. player.canHumanPlay = true;
  177. }
  178. auto itTeam = RandomGeneratorUtil::nextItem(teamNumbers[j], rand);
  179. player.team = TeamID(*itTeam);
  180. teamNumbers[j].erase(itTeam);
  181. map->players[pSettings.getColor().getNum()] = player;
  182. }
  183. map->howManyTeams = (mapGenOptions->getTeamCount() == 0 ? mapGenOptions->getPlayerCount() : mapGenOptions->getTeamCount())
  184. + (mapGenOptions->getCompOnlyTeamCount() == 0 ? mapGenOptions->getCompOnlyPlayerCount() : mapGenOptions->getCompOnlyTeamCount());
  185. }
  186. void CMapGenerator::genZones()
  187. {
  188. editManager->clearTerrain(&rand);
  189. editManager->getTerrainSelection().selectRange(MapRect(int3(0, 0, 0), mapGenOptions->getWidth(), mapGenOptions->getHeight()));
  190. editManager->drawTerrain(ETerrainType::GRASS, &rand);
  191. auto tmpl = mapGenOptions->getMapTemplate();
  192. zones = tmpl->getZones(); //copy from template (refactor?)
  193. CZonePlacer placer(this);
  194. placer.placeZones(mapGenOptions, &rand);
  195. placer.assignZones(mapGenOptions);
  196. logGlobal->infoStream() << "Zones generated successfully";
  197. }
  198. void CMapGenerator::fillZones()
  199. {
  200. //init native town count with 0
  201. for (auto faction : VLC->townh->getAllowedFactions())
  202. zonesPerFaction[faction] = 0;
  203. logGlobal->infoStream() << "Started filling zones";
  204. //initialize possible tiles before any object is actually placed
  205. for (auto it : zones)
  206. {
  207. it.second->initFreeTiles(this);
  208. }
  209. findZonesForQuestArts();
  210. createConnections();
  211. //make sure all connections are passable before creating borders
  212. for (auto it : zones)
  213. {
  214. it.second->createBorder(this);
  215. //we need info about all town types to evaluate dwellings and pandoras with creatures properly
  216. it.second->initTownType(this);
  217. }
  218. std::vector<CRmgTemplateZone*> treasureZones;
  219. for (auto it : zones)
  220. {
  221. it.second->fill(this);
  222. if (it.second->getType() == ETemplateZoneType::TREASURE)
  223. treasureZones.push_back(it.second);
  224. }
  225. //set apriopriate free/occupied tiles, including blocked underground rock
  226. createObstaclesCommon1();
  227. //set back original terrain for underground zones
  228. for (auto it : zones)
  229. it.second->createObstacles1(this);
  230. createObstaclesCommon2();
  231. //place actual obstacles matching zone terrain
  232. for (auto it : zones)
  233. it.second->createObstacles2(this);
  234. //find place for Grail
  235. if (treasureZones.empty())
  236. {
  237. for (auto it : zones)
  238. treasureZones.push_back(it.second);
  239. }
  240. auto grailZone = *RandomGeneratorUtil::nextItem(treasureZones, rand);
  241. map->grailPos = *RandomGeneratorUtil::nextItem(*grailZone->getFreePaths(), rand);
  242. logGlobal->infoStream() << "Zones filled successfully";
  243. }
  244. void CMapGenerator::createObstaclesCommon1()
  245. {
  246. if (map->twoLevel) //underground
  247. {
  248. //negative approach - create rock tiles first, then make sure all accessible tiles have no rock
  249. std::vector<int3> rockTiles;
  250. for (int x = 0; x < map->width; x++)
  251. {
  252. for (int y = 0; y < map->height; y++)
  253. {
  254. int3 tile(x, y, 1);
  255. if (shouldBeBlocked(tile))
  256. {
  257. rockTiles.push_back(tile);
  258. }
  259. }
  260. }
  261. editManager->getTerrainSelection().setSelection(rockTiles);
  262. editManager->drawTerrain(ETerrainType::ROCK, &rand);
  263. }
  264. }
  265. void CMapGenerator::createObstaclesCommon2()
  266. {
  267. if (map->twoLevel)
  268. {
  269. //finally mark rock tiles as occupied, spawn no obstacles there
  270. for (int x = 0; x < map->width; x++)
  271. {
  272. for (int y = 0; y < map->height; y++)
  273. {
  274. int3 tile(x, y, 1);
  275. if (map->getTile(tile).terType == ETerrainType::ROCK)
  276. {
  277. setOccupied(tile, ETileType::USED);
  278. }
  279. }
  280. }
  281. }
  282. //tighten obstacles to improve visuals
  283. for (int i = 0; i < 3; ++i)
  284. {
  285. int blockedTiles = 0;
  286. int freeTiles = 0;
  287. for (int z = 0; z < (map->twoLevel ? 2 : 1); z++)
  288. {
  289. for (int x = 0; x < map->width; x++)
  290. {
  291. for (int y = 0; y < map->height; y++)
  292. {
  293. int3 tile(x, y, z);
  294. if (!isPossible(tile)) //only possible tiles can change
  295. continue;
  296. int blockedNeighbours = 0;
  297. int freeNeighbours = 0;
  298. foreach_neighbour(tile, [this, &blockedNeighbours, &freeNeighbours](int3 &pos)
  299. {
  300. if (this->isBlocked(pos))
  301. blockedNeighbours++;
  302. if (this->isFree(pos))
  303. freeNeighbours++;
  304. });
  305. if (blockedNeighbours > 4)
  306. {
  307. setOccupied(tile, ETileType::BLOCKED);
  308. blockedTiles++;
  309. }
  310. else if (freeNeighbours > 4)
  311. {
  312. setOccupied(tile, ETileType::FREE);
  313. freeTiles++;
  314. }
  315. }
  316. }
  317. }
  318. logGlobal->traceStream() << boost::format("Set %d tiles to BLOCKED and %d tiles to FREE") % blockedTiles % freeTiles;
  319. }
  320. }
  321. void CMapGenerator::findZonesForQuestArts()
  322. {
  323. //we want to place arties in zones that were not yet filled (higher index)
  324. for (auto connection : mapGenOptions->getMapTemplate()->getConnections())
  325. {
  326. auto zoneA = connection.getZoneA();
  327. auto zoneB = connection.getZoneB();
  328. if (zoneA->getId() > zoneB->getId())
  329. {
  330. zoneB->setQuestArtZone(zoneA);
  331. }
  332. else if (zoneA->getId() < zoneB->getId())
  333. {
  334. zoneA->setQuestArtZone(zoneB);
  335. }
  336. }
  337. }
  338. void CMapGenerator::createConnections()
  339. {
  340. for (auto connection : mapGenOptions->getMapTemplate()->getConnections())
  341. {
  342. auto zoneA = connection.getZoneA();
  343. auto zoneB = connection.getZoneB();
  344. //rearrange tiles in random order
  345. auto tilesCopy = zoneA->getTileInfo();
  346. std::vector<int3> tiles(tilesCopy.begin(), tilesCopy.end());
  347. RandomGeneratorUtil::randomShuffle(tiles, rand);
  348. int3 guardPos(-1,-1,-1);
  349. auto otherZoneTiles = zoneB->getTileInfo();
  350. int3 posA = zoneA->getPos();
  351. int3 posB = zoneB->getPos();
  352. if (posA.z == posB.z)
  353. {
  354. for (auto tile : tiles)
  355. {
  356. if (isBlocked(tile)) //tiles may be occupied by subterranean gates already placed
  357. continue;
  358. foreach_neighbour (tile, [&guardPos, tile, &otherZoneTiles, this](int3 &pos)
  359. {
  360. //if (vstd::contains(otherZoneTiles, pos) && !this->isBlocked(pos))
  361. if (vstd::contains(otherZoneTiles, pos))
  362. guardPos = tile;
  363. });
  364. if (guardPos.valid())
  365. {
  366. setOccupied (guardPos, ETileType::FREE); //just in case monster is too weak to spawn
  367. zoneA->addMonster (this, guardPos, connection.getGuardStrength(), false, true);
  368. //zones can make paths only in their own area
  369. zoneA->crunchPath (this, guardPos, posA, zoneA->getId(), zoneA->getFreePaths()); //make connection towards our zone center
  370. zoneB->crunchPath (this, guardPos, posB, zoneB->getId(), zoneB->getFreePaths()); //make connection towards other zone center
  371. break; //we're done with this connection
  372. }
  373. }
  374. }
  375. else //create subterranean gates between two zones
  376. {
  377. //find point on the path between zones
  378. float3 offset (posB.x - posA.x, posB.y - posA.y, 0);
  379. float distance = posB.dist2d(posA);
  380. vstd::amax (distance, 0.5f);
  381. offset /= distance; //get unit vector
  382. float3 vec (0, 0, 0);
  383. //use reduced size of underground zone - make sure gate does not stand on rock
  384. int3 tile = posA;
  385. int3 otherTile = tile;
  386. bool stop = false;
  387. while (!stop)
  388. {
  389. vec += offset; //this vector may extend beyond line between zone centers, in case they are directly over each other
  390. tile = posA + int3(vec.x, vec.y, 0);
  391. float distanceFromA = posA.dist2d(tile);
  392. float distanceFromB = posB.dist2d(tile);
  393. if (distanceFromA + distanceFromB > std::max<int>(zoneA->getSize() + zoneB->getSize(), distance))
  394. break; //we are too far away to ever connect
  395. //if zone is underground, gate must fit within its (reduced) radius
  396. if (distanceFromA > 5 && (!posA.z || distanceFromA < zoneA->getSize() - 3) &&
  397. distanceFromB > 5 && (!posB.z || distanceFromB < zoneB->getSize() - 3))
  398. {
  399. otherTile = tile;
  400. otherTile.z = posB.z;
  401. if (vstd::contains(tiles, tile) && vstd::contains(otherZoneTiles, otherTile))
  402. {
  403. bool withinZone = true;
  404. foreach_neighbour (tile, [&withinZone, &tiles](int3 &pos)
  405. {
  406. if (!vstd::contains(tiles, pos))
  407. withinZone = false;
  408. });
  409. foreach_neighbour (otherTile, [&withinZone, &otherZoneTiles](int3 &pos)
  410. {
  411. if (!vstd::contains(otherZoneTiles, pos))
  412. withinZone = false;
  413. });
  414. if (withinZone)
  415. {
  416. auto gate1 = new CGSubterraneanGate;
  417. gate1->ID = Obj::SUBTERRANEAN_GATE;
  418. gate1->subID = 0;
  419. zoneA->placeAndGuardObject(this, gate1, tile, connection.getGuardStrength());
  420. auto gate2 = new CGSubterraneanGate(*gate1);
  421. zoneB->placeAndGuardObject(this, gate2, otherTile, connection.getGuardStrength());
  422. stop = true; //we are done, go to next connection
  423. }
  424. }
  425. }
  426. }
  427. if (stop)
  428. continue;
  429. }
  430. if (!guardPos.valid())
  431. {
  432. auto teleport1 = new CGMonolith;
  433. teleport1->ID = Obj::MONOLITH_TWO_WAY;
  434. teleport1->subID = getNextMonlithIndex();
  435. auto teleport2 = new CGMonolith(*teleport1);
  436. zoneA->addRequiredObject (teleport1, connection.getGuardStrength());
  437. zoneB->addRequiredObject (teleport2, connection.getGuardStrength());
  438. }
  439. }
  440. }
  441. void CMapGenerator::addHeaderInfo()
  442. {
  443. map->version = EMapFormat::SOD;
  444. map->width = mapGenOptions->getWidth();
  445. map->height = mapGenOptions->getHeight();
  446. map->twoLevel = mapGenOptions->getHasTwoLevels();
  447. map->name = VLC->generaltexth->allTexts[740];
  448. map->description = getMapDescription();
  449. map->difficulty = 1;
  450. addPlayerInfo();
  451. }
  452. std::map<TRmgTemplateZoneId, CRmgTemplateZone*> CMapGenerator::getZones() const
  453. {
  454. return zones;
  455. }
  456. bool CMapGenerator::isBlocked(const int3 &tile) const
  457. {
  458. if (!map->isInTheMap(tile))
  459. throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
  460. return tiles[tile.x][tile.y][tile.z].isBlocked();
  461. }
  462. bool CMapGenerator::shouldBeBlocked(const int3 &tile) const
  463. {
  464. if (!map->isInTheMap(tile))
  465. throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
  466. return tiles[tile.x][tile.y][tile.z].shouldBeBlocked();
  467. }
  468. bool CMapGenerator::isPossible(const int3 &tile) const
  469. {
  470. if (!map->isInTheMap(tile))
  471. throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
  472. return tiles[tile.x][tile.y][tile.z].isPossible();
  473. }
  474. bool CMapGenerator::isFree(const int3 &tile) const
  475. {
  476. if (!map->isInTheMap(tile))
  477. throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
  478. return tiles[tile.x][tile.y][tile.z].isFree();
  479. }
  480. bool CMapGenerator::isUsed(const int3 &tile) const
  481. {
  482. if (!map->isInTheMap(tile))
  483. throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
  484. return tiles[tile.x][tile.y][tile.z].isUsed();
  485. }
  486. void CMapGenerator::setOccupied(const int3 &tile, ETileType::ETileType state)
  487. {
  488. if (!map->isInTheMap(tile))
  489. throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
  490. tiles[tile.x][tile.y][tile.z].setOccupied(state);
  491. }
  492. CTileInfo CMapGenerator::getTile(const int3& tile) const
  493. {
  494. if (!map->isInTheMap(tile))
  495. throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
  496. return tiles[tile.x][tile.y][tile.z];
  497. }
  498. void CMapGenerator::setNearestObjectDistance(int3 &tile, float value)
  499. {
  500. if (!map->isInTheMap(tile))
  501. throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
  502. tiles[tile.x][tile.y][tile.z].setNearestObjectDistance(value);
  503. }
  504. float CMapGenerator::getNearestObjectDistance(const int3 &tile) const
  505. {
  506. if (!map->isInTheMap(tile))
  507. throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
  508. return tiles[tile.x][tile.y][tile.z].getNearestObjectDistance();
  509. }
  510. int CMapGenerator::getNextMonlithIndex()
  511. {
  512. if (monolithIndex >= VLC->objtypeh->knownSubObjects(Obj::MONOLITH_TWO_WAY).size())
  513. {
  514. //logGlobal->errorStream() << boost::to_string(boost::format("RMG Error! There is no Monolith Two Way with index %d available!") % monolithIndex);
  515. //monolithIndex++;
  516. //return VLC->objtypeh->knownSubObjects(Obj::MONOLITH_TWO_WAY).size() - 1;
  517. //TODO: interrupt map generation and report error
  518. throw rmgException(boost::to_string(boost::format("There is no Monolith Two Way with index %d available!") % monolithIndex));
  519. }
  520. else
  521. return monolithIndex++;
  522. }
  523. int CMapGenerator::getPrisonsRemaning() const
  524. {
  525. return prisonsRemaining;
  526. }
  527. void CMapGenerator::decreasePrisonsRemaining()
  528. {
  529. prisonsRemaining = std::max (0, prisonsRemaining - 1);
  530. }
  531. std::vector<ArtifactID> CMapGenerator::getQuestArtsRemaning() const
  532. {
  533. return questArtifacts;
  534. }
  535. void CMapGenerator::banQuestArt(ArtifactID id)
  536. {
  537. map->allowedArtifact[id] = false;
  538. vstd::erase_if_present (questArtifacts, id);
  539. }
  540. void CMapGenerator::registerZone (TFaction faction)
  541. {
  542. zonesPerFaction[faction]++;
  543. zonesTotal++;
  544. }
  545. ui32 CMapGenerator::getZoneCount(TFaction faction)
  546. {
  547. return zonesPerFaction[faction];
  548. }
  549. ui32 CMapGenerator::getTotalZoneCount() const
  550. {
  551. return zonesTotal;
  552. }