CMap.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. /*
  2. * CMap.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "CMap.h"
  12. #include "../CArtHandler.h"
  13. #include "../VCMI_Lib.h"
  14. #include "../CCreatureHandler.h"
  15. #include "../CTownHandler.h"
  16. #include "../CHeroHandler.h"
  17. #include "../RiverHandler.h"
  18. #include "../RoadHandler.h"
  19. #include "../TerrainHandler.h"
  20. #include "../mapObjects/CGHeroInstance.h"
  21. #include "../mapObjects/CGTownInstance.h"
  22. #include "../mapObjects/CQuest.h"
  23. #include "../mapObjects/ObjectTemplate.h"
  24. #include "../CGeneralTextHandler.h"
  25. #include "../spells/CSpellHandler.h"
  26. #include "../CSkillHandler.h"
  27. #include "CMapEditManager.h"
  28. #include "CMapOperation.h"
  29. #include "../serializer/JsonSerializeFormat.h"
  30. VCMI_LIB_NAMESPACE_BEGIN
  31. void Rumor::serializeJson(JsonSerializeFormat & handler)
  32. {
  33. handler.serializeString("name", name);
  34. handler.serializeStruct("text", text);
  35. }
  36. DisposedHero::DisposedHero() : heroId(0), portrait(255)
  37. {
  38. }
  39. CMapEvent::CMapEvent() : players(0), humanAffected(0), computerAffected(0),
  40. firstOccurence(0), nextOccurence(0)
  41. {
  42. }
  43. bool CMapEvent::earlierThan(const CMapEvent & other) const
  44. {
  45. return firstOccurence < other.firstOccurence;
  46. }
  47. bool CMapEvent::earlierThanOrEqual(const CMapEvent & other) const
  48. {
  49. return firstOccurence <= other.firstOccurence;
  50. }
  51. void CMapEvent::serializeJson(JsonSerializeFormat & handler)
  52. {
  53. handler.serializeString("name", name);
  54. handler.serializeStruct("message", message);
  55. handler.serializeInt("players", players);
  56. handler.serializeInt("humanAffected", humanAffected);
  57. handler.serializeInt("computerAffected", computerAffected);
  58. handler.serializeInt("firstOccurence", firstOccurence);
  59. handler.serializeInt("nextOccurence", nextOccurence);
  60. resources.serializeJson(handler, "resources");
  61. }
  62. void CCastleEvent::serializeJson(JsonSerializeFormat & handler)
  63. {
  64. CMapEvent::serializeJson(handler);
  65. // TODO: handler.serializeIdArray("buildings", buildings);
  66. {
  67. std::vector<BuildingID> temp(buildings.begin(), buildings.end());
  68. auto a = handler.enterArray("buildings");
  69. a.syncSize(temp);
  70. for(int i = 0; i < temp.size(); ++i)
  71. {
  72. int buildingID = temp[i].getNum();
  73. a.serializeInt(i, buildingID);
  74. buildings.insert(buildingID);
  75. }
  76. }
  77. {
  78. auto a = handler.enterArray("creatures");
  79. a.syncSize(creatures);
  80. for(int i = 0; i < creatures.size(); ++i)
  81. a.serializeInt(i, creatures[i]);
  82. }
  83. }
  84. TerrainTile::TerrainTile():
  85. terType(nullptr),
  86. terView(0),
  87. riverType(VLC->riverTypeHandler->getById(River::NO_RIVER)),
  88. riverDir(0),
  89. roadType(VLC->roadTypeHandler->getById(Road::NO_ROAD)),
  90. roadDir(0),
  91. extTileFlags(0),
  92. visitable(false),
  93. blocked(false)
  94. {
  95. }
  96. bool TerrainTile::entrableTerrain(const TerrainTile * from) const
  97. {
  98. return entrableTerrain(from ? from->terType->isLand() : true, from ? from->terType->isWater() : true);
  99. }
  100. bool TerrainTile::entrableTerrain(bool allowLand, bool allowSea) const
  101. {
  102. return terType->isPassable()
  103. && ((allowSea && terType->isWater()) || (allowLand && terType->isLand()));
  104. }
  105. bool TerrainTile::isClear(const TerrainTile * from) const
  106. {
  107. return entrableTerrain(from) && !blocked;
  108. }
  109. Obj TerrainTile::topVisitableId(bool excludeTop) const
  110. {
  111. return topVisitableObj(excludeTop) ? topVisitableObj(excludeTop)->ID : Obj(Obj::NO_OBJ);
  112. }
  113. CGObjectInstance * TerrainTile::topVisitableObj(bool excludeTop) const
  114. {
  115. if(visitableObjects.empty() || (excludeTop && visitableObjects.size() == 1))
  116. return nullptr;
  117. if(excludeTop)
  118. return visitableObjects[visitableObjects.size()-2];
  119. return visitableObjects.back();
  120. }
  121. EDiggingStatus TerrainTile::getDiggingStatus(const bool excludeTop) const
  122. {
  123. if(terType->isWater() || !terType->isPassable())
  124. return EDiggingStatus::WRONG_TERRAIN;
  125. int allowedBlocked = excludeTop ? 1 : 0;
  126. if(blockingObjects.size() > allowedBlocked || topVisitableObj(excludeTop))
  127. return EDiggingStatus::TILE_OCCUPIED;
  128. else
  129. return EDiggingStatus::CAN_DIG;
  130. }
  131. bool TerrainTile::hasFavorableWinds() const
  132. {
  133. return extTileFlags & 128;
  134. }
  135. bool TerrainTile::isWater() const
  136. {
  137. return terType->isWater();
  138. }
  139. CMap::CMap(IGameCallback * cb)
  140. : GameCallbackHolder(cb)
  141. , checksum(0)
  142. , grailPos(-1, -1, -1)
  143. , grailRadius(0)
  144. , uidCounter(0)
  145. {
  146. allHeroes.resize(VLC->heroh->objects.size());
  147. allowedAbilities = VLC->skillh->getDefaultAllowed();
  148. allowedArtifact = VLC->arth->getDefaultAllowed();
  149. allowedSpells = VLC->spellh->getDefaultAllowed();
  150. }
  151. CMap::~CMap()
  152. {
  153. getEditManager()->getUndoManager().clearAll();
  154. for(auto obj : objects)
  155. obj.dellNull();
  156. for(auto quest : quests)
  157. quest.dellNull();
  158. for(auto artInstance : artInstances)
  159. artInstance.dellNull();
  160. resetStaticData();
  161. }
  162. void CMap::removeBlockVisTiles(CGObjectInstance * obj, bool total)
  163. {
  164. const int zVal = obj->pos.z;
  165. for(int fx = 0; fx < obj->getWidth(); ++fx)
  166. {
  167. int xVal = obj->pos.x - fx;
  168. for(int fy = 0; fy < obj->getHeight(); ++fy)
  169. {
  170. int yVal = obj->pos.y - fy;
  171. if(xVal>=0 && xVal < width && yVal>=0 && yVal < height)
  172. {
  173. TerrainTile & curt = terrain[zVal][xVal][yVal];
  174. if(total || obj->visitableAt(xVal, yVal))
  175. {
  176. curt.visitableObjects -= obj;
  177. curt.visitable = curt.visitableObjects.size();
  178. }
  179. if(total || obj->blockingAt(xVal, yVal))
  180. {
  181. curt.blockingObjects -= obj;
  182. curt.blocked = curt.blockingObjects.size();
  183. }
  184. }
  185. }
  186. }
  187. }
  188. void CMap::addBlockVisTiles(CGObjectInstance * obj)
  189. {
  190. const int zVal = obj->pos.z;
  191. for(int fx = 0; fx < obj->getWidth(); ++fx)
  192. {
  193. int xVal = obj->pos.x - fx;
  194. for(int fy = 0; fy < obj->getHeight(); ++fy)
  195. {
  196. int yVal = obj->pos.y - fy;
  197. if(xVal>=0 && xVal < width && yVal >= 0 && yVal < height)
  198. {
  199. TerrainTile & curt = terrain[zVal][xVal][yVal];
  200. if(obj->visitableAt(xVal, yVal))
  201. {
  202. curt.visitableObjects.push_back(obj);
  203. curt.visitable = true;
  204. }
  205. if(obj->blockingAt(xVal, yVal))
  206. {
  207. curt.blockingObjects.push_back(obj);
  208. curt.blocked = true;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. void CMap::calculateGuardingGreaturePositions()
  215. {
  216. int levels = twoLevel ? 2 : 1;
  217. for(int z = 0; z < levels; z++)
  218. {
  219. for(int x = 0; x < width; x++)
  220. {
  221. for(int y = 0; y < height; y++)
  222. {
  223. guardingCreaturePositions[z][x][y] = guardingCreaturePosition(int3(x, y, z));
  224. }
  225. }
  226. }
  227. }
  228. CGHeroInstance * CMap::getHero(HeroTypeID heroID)
  229. {
  230. for(auto & elem : heroesOnMap)
  231. if(elem->getHeroType() == heroID)
  232. return elem;
  233. return nullptr;
  234. }
  235. bool CMap::isCoastalTile(const int3 & pos) const
  236. {
  237. //todo: refactoring: extract neighbor tile iterator and use it in GameState
  238. static const int3 dirs[] = { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0),
  239. int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) };
  240. if(!isInTheMap(pos))
  241. {
  242. logGlobal->error("Coastal check outside of map: %s", pos.toString());
  243. return false;
  244. }
  245. if(isWaterTile(pos))
  246. return false;
  247. for(const auto & dir : dirs)
  248. {
  249. const int3 hlp = pos + dir;
  250. if(!isInTheMap(hlp))
  251. continue;
  252. const TerrainTile &hlpt = getTile(hlp);
  253. if(hlpt.isWater())
  254. return true;
  255. }
  256. return false;
  257. }
  258. bool CMap::isInTheMap(const int3 & pos) const
  259. {
  260. return pos.x >= 0 && pos.y >= 0 && pos.z >= 0 && pos.x < width && pos.y < height && pos.z <= (twoLevel ? 1 : 0);
  261. }
  262. TerrainTile & CMap::getTile(const int3 & tile)
  263. {
  264. assert(isInTheMap(tile));
  265. return terrain[tile.z][tile.x][tile.y];
  266. }
  267. const TerrainTile & CMap::getTile(const int3 & tile) const
  268. {
  269. assert(isInTheMap(tile));
  270. return terrain[tile.z][tile.x][tile.y];
  271. }
  272. bool CMap::isWaterTile(const int3 &pos) const
  273. {
  274. return isInTheMap(pos) && getTile(pos).isWater();
  275. }
  276. bool CMap::canMoveBetween(const int3 &src, const int3 &dst) const
  277. {
  278. const TerrainTile * dstTile = &getTile(dst);
  279. const TerrainTile * srcTile = &getTile(src);
  280. return checkForVisitableDir(src, dstTile, dst) && checkForVisitableDir(dst, srcTile, src);
  281. }
  282. bool CMap::checkForVisitableDir(const int3 & src, const TerrainTile * pom, const int3 & dst) const
  283. {
  284. if (!pom->entrableTerrain()) //rock is never accessible
  285. return false;
  286. for(auto * obj : pom->visitableObjects) //checking destination tile
  287. {
  288. if(!vstd::contains(pom->blockingObjects, obj)) //this visitable object is not blocking, ignore
  289. continue;
  290. if (!obj->appearance->isVisitableFrom(src.x - dst.x, src.y - dst.y))
  291. return false;
  292. }
  293. return true;
  294. }
  295. int3 CMap::guardingCreaturePosition (int3 pos) const
  296. {
  297. const int3 originalPos = pos;
  298. // Give monster at position priority.
  299. if (!isInTheMap(pos))
  300. return int3(-1, -1, -1);
  301. const TerrainTile &posTile = getTile(pos);
  302. if (posTile.visitable)
  303. {
  304. for (CGObjectInstance* obj : posTile.visitableObjects)
  305. {
  306. if (obj->ID == Obj::MONSTER)
  307. return pos;
  308. }
  309. }
  310. // See if there are any monsters adjacent.
  311. bool water = posTile.isWater();
  312. pos -= int3(1, 1, 0); // Start with top left.
  313. for (int dx = 0; dx < 3; dx++)
  314. {
  315. for (int dy = 0; dy < 3; dy++)
  316. {
  317. if (isInTheMap(pos))
  318. {
  319. const auto & tile = getTile(pos);
  320. if (tile.visitable && (tile.isWater() == water))
  321. {
  322. for (CGObjectInstance* obj : tile.visitableObjects)
  323. {
  324. if (obj->ID == Obj::MONSTER && checkForVisitableDir(pos, &posTile, originalPos)) // Monster being able to attack investigated tile
  325. {
  326. return pos;
  327. }
  328. }
  329. }
  330. }
  331. pos.y++;
  332. }
  333. pos.y -= 3;
  334. pos.x++;
  335. }
  336. return int3(-1, -1, -1);
  337. }
  338. const CGObjectInstance * CMap::getObjectiveObjectFrom(const int3 & pos, Obj type)
  339. {
  340. for (CGObjectInstance * object : getTile(pos).visitableObjects)
  341. {
  342. if (object->ID == type)
  343. return object;
  344. }
  345. // There is weird bug because of which sometimes heroes will not be found properly despite having correct position
  346. // Try to workaround that and find closest object that we can use
  347. logGlobal->error("Failed to find object of type %d at %s", type.getNum(), pos.toString());
  348. logGlobal->error("Will try to find closest matching object");
  349. CGObjectInstance * bestMatch = nullptr;
  350. for (CGObjectInstance * object : objects)
  351. {
  352. if (object && object->ID == type)
  353. {
  354. if (bestMatch == nullptr)
  355. bestMatch = object;
  356. else
  357. {
  358. if (object->pos.dist2dSQ(pos) < bestMatch->pos.dist2dSQ(pos))
  359. bestMatch = object;// closer than one we already found
  360. }
  361. }
  362. }
  363. assert(bestMatch != nullptr); // if this happens - victory conditions or map itself is very, very broken
  364. logGlobal->error("Will use %s from %s", bestMatch->getObjectName(), bestMatch->pos.toString());
  365. return bestMatch;
  366. }
  367. void CMap::checkForObjectives()
  368. {
  369. // NOTE: probably should be moved to MapFormatH3M.cpp
  370. for (TriggeredEvent & event : triggeredEvents)
  371. {
  372. auto patcher = [&](EventCondition cond) -> EventExpression::Variant
  373. {
  374. switch (cond.condition)
  375. {
  376. case EventCondition::HAVE_ARTIFACT:
  377. event.onFulfill.replaceTextID(cond.objectType.as<ArtifactID>().toEntity(VLC)->getNameTextID());
  378. break;
  379. case EventCondition::HAVE_CREATURES:
  380. event.onFulfill.replaceTextID(cond.objectType.as<CreatureID>().toEntity(VLC)->getNameSingularTextID());
  381. event.onFulfill.replaceNumber(cond.value);
  382. break;
  383. case EventCondition::HAVE_RESOURCES:
  384. event.onFulfill.replaceName(cond.objectType.as<GameResID>());
  385. event.onFulfill.replaceNumber(cond.value);
  386. break;
  387. case EventCondition::HAVE_BUILDING:
  388. if (isInTheMap(cond.position))
  389. cond.objectID = getObjectiveObjectFrom(cond.position, Obj::TOWN)->id;
  390. break;
  391. case EventCondition::CONTROL:
  392. if (isInTheMap(cond.position))
  393. cond.objectID = getObjectiveObjectFrom(cond.position, cond.objectType.as<MapObjectID>())->id;
  394. if (cond.objectID != ObjectInstanceID::NONE)
  395. {
  396. const auto * town = dynamic_cast<const CGTownInstance *>(objects[cond.objectID].get());
  397. if (town)
  398. event.onFulfill.replaceRawString(town->getNameTranslated());
  399. const auto * hero = dynamic_cast<const CGHeroInstance *>(objects[cond.objectID].get());
  400. if (hero)
  401. event.onFulfill.replaceRawString(hero->getNameTranslated());
  402. }
  403. break;
  404. case EventCondition::DESTROY:
  405. if (isInTheMap(cond.position))
  406. cond.objectID = getObjectiveObjectFrom(cond.position, cond.objectType.as<MapObjectID>())->id;
  407. if (cond.objectID != ObjectInstanceID::NONE)
  408. {
  409. const auto * hero = dynamic_cast<const CGHeroInstance *>(objects[cond.objectID].get());
  410. if (hero)
  411. event.onFulfill.replaceRawString(hero->getNameTranslated());
  412. }
  413. break;
  414. case EventCondition::TRANSPORT:
  415. cond.objectID = getObjectiveObjectFrom(cond.position, Obj::TOWN)->id;
  416. break;
  417. //break; case EventCondition::DAYS_PASSED:
  418. //break; case EventCondition::IS_HUMAN:
  419. //break; case EventCondition::DAYS_WITHOUT_TOWN:
  420. //break; case EventCondition::STANDARD_WIN:
  421. }
  422. return cond;
  423. };
  424. event.trigger = event.trigger.morph(patcher);
  425. }
  426. }
  427. void CMap::addNewArtifactInstance(ConstTransitivePtr<CArtifactInstance> art)
  428. {
  429. art->setId(static_cast<ArtifactInstanceID>(artInstances.size()));
  430. artInstances.emplace_back(art);
  431. }
  432. void CMap::eraseArtifactInstance(CArtifactInstance * art)
  433. {
  434. //TODO: handle for artifacts removed in map editor
  435. assert(artInstances[art->getId().getNum()] == art);
  436. artInstances[art->getId().getNum()].dellNull();
  437. }
  438. void CMap::addNewQuestInstance(CQuest* quest)
  439. {
  440. quest->qid = static_cast<si32>(quests.size());
  441. quests.emplace_back(quest);
  442. }
  443. void CMap::removeQuestInstance(CQuest * quest)
  444. {
  445. //TODO: should be called only by map editor.
  446. //During game, completed quests or quests from removed objects stay forever
  447. //Shift indexes
  448. auto iter = std::next(quests.begin(), quest->qid);
  449. iter = quests.erase(iter);
  450. for (int i = quest->qid; iter != quests.end(); ++i, ++iter)
  451. {
  452. (*iter)->qid = i;
  453. }
  454. }
  455. void CMap::setUniqueInstanceName(CGObjectInstance * obj)
  456. {
  457. //this gives object unique name even if objects are removed later
  458. auto uid = uidCounter++;
  459. boost::format fmt("%s_%d");
  460. fmt % obj->typeName % uid;
  461. obj->instanceName = fmt.str();
  462. }
  463. void CMap::addNewObject(CGObjectInstance * obj)
  464. {
  465. if(obj->id != ObjectInstanceID(static_cast<si32>(objects.size())))
  466. throw std::runtime_error("Invalid object instance id");
  467. if(obj->instanceName.empty())
  468. throw std::runtime_error("Object instance name missing");
  469. if (vstd::contains(instanceNames, obj->instanceName))
  470. throw std::runtime_error("Object instance name duplicated: "+obj->instanceName);
  471. objects.emplace_back(obj);
  472. instanceNames[obj->instanceName] = obj;
  473. addBlockVisTiles(obj);
  474. //TODO: how about defeated heroes recruited again?
  475. obj->afterAddToMap(this);
  476. }
  477. void CMap::moveObject(CGObjectInstance * obj, const int3 & pos)
  478. {
  479. removeBlockVisTiles(obj);
  480. obj->pos = pos;
  481. addBlockVisTiles(obj);
  482. }
  483. void CMap::removeObject(CGObjectInstance * obj)
  484. {
  485. removeBlockVisTiles(obj);
  486. instanceNames.erase(obj->instanceName);
  487. //update indeces
  488. auto iter = std::next(objects.begin(), obj->id.getNum());
  489. iter = objects.erase(iter);
  490. for(int i = obj->id.getNum(); iter != objects.end(); ++i, ++iter)
  491. {
  492. (*iter)->id = ObjectInstanceID(i);
  493. }
  494. obj->afterRemoveFromMap(this);
  495. //TOOD: Clean artifact instances (mostly worn by hero?) and quests related to this object
  496. }
  497. bool CMap::isWaterMap() const
  498. {
  499. return waterMap;
  500. }
  501. bool CMap::calculateWaterContent()
  502. {
  503. size_t totalTiles = height * width * levels();
  504. size_t waterTiles = 0;
  505. for(auto tile = terrain.origin(); tile < (terrain.origin() + terrain.num_elements()); ++tile)
  506. {
  507. if (tile->isWater())
  508. {
  509. waterTiles++;
  510. }
  511. }
  512. if (waterTiles >= totalTiles / 100) //At least 1% of area is water
  513. {
  514. waterMap = true;
  515. }
  516. return waterMap;
  517. }
  518. void CMap::banWaterContent()
  519. {
  520. banWaterHeroes();
  521. banWaterArtifacts();
  522. banWaterSpells();
  523. banWaterSkills();
  524. }
  525. void CMap::banWaterSpells()
  526. {
  527. vstd::erase_if(allowedSpells, [&](SpellID spell)
  528. {
  529. return spell.toSpell()->onlyOnWaterMap && !isWaterMap();
  530. });
  531. }
  532. void CMap::banWaterArtifacts()
  533. {
  534. vstd::erase_if(allowedArtifact, [&](ArtifactID artifact)
  535. {
  536. return artifact.toArtifact()->onlyOnWaterMap && !isWaterMap();
  537. });
  538. }
  539. void CMap::banWaterSkills()
  540. {
  541. vstd::erase_if(allowedAbilities, [&](SecondarySkill skill)
  542. {
  543. return skill.toSkill()->onlyOnWaterMap && !isWaterMap();
  544. });
  545. }
  546. void CMap::banWaterHeroes()
  547. {
  548. vstd::erase_if(allowedHeroes, [&](HeroTypeID hero)
  549. {
  550. return hero.toHeroType()->onlyOnWaterMap && !isWaterMap();
  551. });
  552. vstd::erase_if(allowedHeroes, [&](HeroTypeID hero)
  553. {
  554. return hero.toHeroType()->onlyOnMapWithoutWater && isWaterMap();
  555. });
  556. }
  557. void CMap::banHero(const HeroTypeID & id)
  558. {
  559. if (!vstd::contains(allowedHeroes, id))
  560. logGlobal->warn("Attempt to ban hero %s, who is already not allowed", id.encode(id));
  561. allowedHeroes.erase(id);
  562. }
  563. void CMap::unbanHero(const HeroTypeID & id)
  564. {
  565. if (vstd::contains(allowedHeroes, id))
  566. logGlobal->warn("Attempt to unban hero %s, who is already allowed", id.encode(id));
  567. allowedHeroes.insert(id);
  568. }
  569. void CMap::initTerrain()
  570. {
  571. terrain.resize(boost::extents[levels()][width][height]);
  572. guardingCreaturePositions.resize(boost::extents[levels()][width][height]);
  573. }
  574. CMapEditManager * CMap::getEditManager()
  575. {
  576. if(!editManager) editManager = std::make_unique<CMapEditManager>(this);
  577. return editManager.get();
  578. }
  579. void CMap::resetStaticData()
  580. {
  581. obeliskCount = 0;
  582. obelisksVisited.clear();
  583. townMerchantArtifacts.clear();
  584. townUniversitySkills.clear();
  585. }
  586. VCMI_LIB_NAMESPACE_END