CMap.cpp 17 KB

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