NetPacksClient.cpp 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  1. /*
  2. * NetPacksClient.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 "ClientNetPackVisitors.h"
  12. #include "Client.h"
  13. #include "CPlayerInterface.h"
  14. #include "CGameInfo.h"
  15. #include "windows/GUIClasses.h"
  16. #include "mapView/mapHandler.h"
  17. #include "adventureMap/CInGameConsole.h"
  18. #include "battle/BattleInterface.h"
  19. #include "gui/CGuiHandler.h"
  20. #include "widgets/MiscWidgets.h"
  21. #include "CMT.h"
  22. #include "CServerHandler.h"
  23. #include "../CCallback.h"
  24. #include "../lib/filesystem/Filesystem.h"
  25. #include "../lib/filesystem/FileInfo.h"
  26. #include "../lib/serializer/Connection.h"
  27. #include "../lib/serializer/BinarySerializer.h"
  28. #include "../lib/CGeneralTextHandler.h"
  29. #include "../lib/CHeroHandler.h"
  30. #include "../lib/VCMI_Lib.h"
  31. #include "../lib/mapping/CMap.h"
  32. #include "../lib/VCMIDirs.h"
  33. #include "../lib/spells/CSpellHandler.h"
  34. #include "../lib/CSoundBase.h"
  35. #include "../lib/StartInfo.h"
  36. #include "../lib/CConfigHandler.h"
  37. #include "../lib/mapObjects/CGMarket.h"
  38. #include "../lib/gameState/CGameState.h"
  39. #include "../lib/CStack.h"
  40. #include "../lib/battle/BattleInfo.h"
  41. #include "../lib/GameConstants.h"
  42. #include "../lib/CPlayerState.h"
  43. // TODO: as Tow suggested these template should all be part of CClient
  44. // This will require rework spectator interface properly though
  45. template<typename T, typename ... Args, typename ... Args2>
  46. bool callOnlyThatInterface(CClient & cl, PlayerColor player, void (T::*ptr)(Args...), Args2 && ...args)
  47. {
  48. if(vstd::contains(cl.playerint, player))
  49. {
  50. ((*cl.playerint[player]).*ptr)(std::forward<Args2>(args)...);
  51. return true;
  52. }
  53. return false;
  54. }
  55. template<typename T, typename ... Args, typename ... Args2>
  56. bool callInterfaceIfPresent(CClient & cl, PlayerColor player, void (T::*ptr)(Args...), Args2 && ...args)
  57. {
  58. bool called = callOnlyThatInterface(cl, player, ptr, std::forward<Args2>(args)...);
  59. return called;
  60. }
  61. template<typename T, typename ... Args, typename ... Args2>
  62. void callOnlyThatBattleInterface(CClient & cl, PlayerColor player, void (T::*ptr)(Args...), Args2 && ...args)
  63. {
  64. if(vstd::contains(cl.battleints,player))
  65. ((*cl.battleints[player]).*ptr)(std::forward<Args2>(args)...);
  66. if(cl.additionalBattleInts.count(player))
  67. {
  68. for(auto bInt : cl.additionalBattleInts[player])
  69. ((*bInt).*ptr)(std::forward<Args2>(args)...);
  70. }
  71. }
  72. template<typename T, typename ... Args, typename ... Args2>
  73. void callBattleInterfaceIfPresent(CClient & cl, PlayerColor player, void (T::*ptr)(Args...), Args2 && ...args)
  74. {
  75. callOnlyThatInterface(cl, player, ptr, std::forward<Args2>(args)...);
  76. }
  77. //calls all normal interfaces and privileged ones, playerints may be updated when iterating over it, so we need a copy
  78. template<typename T, typename ... Args, typename ... Args2>
  79. void callAllInterfaces(CClient & cl, void (T::*ptr)(Args...), Args2 && ...args)
  80. {
  81. for(auto pInt : cl.playerint)
  82. ((*pInt.second).*ptr)(std::forward<Args2>(args)...);
  83. }
  84. //calls all normal interfaces and privileged ones, playerints may be updated when iterating over it, so we need a copy
  85. template<typename T, typename ... Args, typename ... Args2>
  86. void callBattleInterfaceIfPresentForBothSides(CClient & cl, void (T::*ptr)(Args...), Args2 && ...args)
  87. {
  88. assert(cl.gameState()->curB);
  89. if (!cl.gameState()->curB)
  90. {
  91. logGlobal->error("Attempt to call battle interface without ongoing battle!");
  92. return;
  93. }
  94. callOnlyThatBattleInterface(cl, cl.gameState()->curB->sides[0].color, ptr, std::forward<Args2>(args)...);
  95. callOnlyThatBattleInterface(cl, cl.gameState()->curB->sides[1].color, ptr, std::forward<Args2>(args)...);
  96. if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool() && LOCPLINT->battleInt)
  97. {
  98. callOnlyThatBattleInterface(cl, PlayerColor::SPECTATOR, ptr, std::forward<Args2>(args)...);
  99. }
  100. }
  101. void ApplyClientNetPackVisitor::visitSetResources(SetResources & pack)
  102. {
  103. //todo: inform on actual resource set transfered
  104. callInterfaceIfPresent(cl, pack.player, &IGameEventsReceiver::receivedResource);
  105. }
  106. void ApplyClientNetPackVisitor::visitSetPrimSkill(SetPrimSkill & pack)
  107. {
  108. const CGHeroInstance * h = cl.getHero(pack.id);
  109. if(!h)
  110. {
  111. logNetwork->error("Cannot find hero with pack.id %d", pack.id.getNum());
  112. return;
  113. }
  114. callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroPrimarySkillChanged, h, pack.which, pack.val);
  115. }
  116. void ApplyClientNetPackVisitor::visitSetSecSkill(SetSecSkill & pack)
  117. {
  118. const CGHeroInstance *h = cl.getHero(pack.id);
  119. if(!h)
  120. {
  121. logNetwork->error("Cannot find hero with pack.id %d", pack.id.getNum());
  122. return;
  123. }
  124. callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroSecondarySkillChanged, h, pack.which, pack.val);
  125. }
  126. void ApplyClientNetPackVisitor::visitHeroVisitCastle(HeroVisitCastle & pack)
  127. {
  128. const CGHeroInstance *h = cl.getHero(pack.hid);
  129. if(pack.start())
  130. {
  131. callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroVisitsTown, h, gs.getTown(pack.tid));
  132. }
  133. }
  134. void ApplyClientNetPackVisitor::visitSetMana(SetMana & pack)
  135. {
  136. const CGHeroInstance *h = cl.getHero(pack.hid);
  137. callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroManaPointsChanged, h);
  138. }
  139. void ApplyClientNetPackVisitor::visitSetMovePoints(SetMovePoints & pack)
  140. {
  141. const CGHeroInstance *h = cl.getHero(pack.hid);
  142. cl.invalidatePaths();
  143. callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroMovePointsChanged, h);
  144. }
  145. void ApplyClientNetPackVisitor::visitFoWChange(FoWChange & pack)
  146. {
  147. for(auto &i : cl.playerint)
  148. {
  149. if(cl.getPlayerRelations(i.first, pack.player) == PlayerRelations::SAME_PLAYER && pack.waitForDialogs && LOCPLINT == i.second.get())
  150. {
  151. LOCPLINT->waitWhileDialog();
  152. }
  153. if(cl.getPlayerRelations(i.first, pack.player) != PlayerRelations::ENEMIES)
  154. {
  155. if(pack.mode)
  156. i.second->tileRevealed(pack.tiles);
  157. else
  158. i.second->tileHidden(pack.tiles);
  159. }
  160. }
  161. cl.invalidatePaths();
  162. }
  163. static void dispatchGarrisonChange(CClient & cl, ObjectInstanceID army1, ObjectInstanceID army2)
  164. {
  165. auto obj1 = cl.getObj(army1);
  166. if(!obj1)
  167. {
  168. logNetwork->error("Cannot find army with pack.id %d", army1.getNum());
  169. return;
  170. }
  171. callInterfaceIfPresent(cl, obj1->tempOwner, &IGameEventsReceiver::garrisonsChanged, army1, army2);
  172. if(army2 != ObjectInstanceID() && army2 != army1)
  173. {
  174. auto obj2 = cl.getObj(army2);
  175. if(!obj2)
  176. {
  177. logNetwork->error("Cannot find army with pack.id %d", army2.getNum());
  178. return;
  179. }
  180. if(obj1->tempOwner != obj2->tempOwner)
  181. callInterfaceIfPresent(cl, obj2->tempOwner, &IGameEventsReceiver::garrisonsChanged, army1, army2);
  182. }
  183. }
  184. void ApplyClientNetPackVisitor::visitChangeStackCount(ChangeStackCount & pack)
  185. {
  186. dispatchGarrisonChange(cl, pack.army, ObjectInstanceID());
  187. }
  188. void ApplyClientNetPackVisitor::visitSetStackType(SetStackType & pack)
  189. {
  190. dispatchGarrisonChange(cl, pack.army, ObjectInstanceID());
  191. }
  192. void ApplyClientNetPackVisitor::visitEraseStack(EraseStack & pack)
  193. {
  194. dispatchGarrisonChange(cl, pack.army, ObjectInstanceID());
  195. }
  196. void ApplyClientNetPackVisitor::visitSwapStacks(SwapStacks & pack)
  197. {
  198. dispatchGarrisonChange(cl, pack.srcArmy, pack.dstArmy);
  199. }
  200. void ApplyClientNetPackVisitor::visitInsertNewStack(InsertNewStack & pack)
  201. {
  202. dispatchGarrisonChange(cl, pack.army, ObjectInstanceID());
  203. }
  204. void ApplyClientNetPackVisitor::visitRebalanceStacks(RebalanceStacks & pack)
  205. {
  206. dispatchGarrisonChange(cl, pack.srcArmy, pack.dstArmy);
  207. }
  208. void ApplyClientNetPackVisitor::visitBulkRebalanceStacks(BulkRebalanceStacks & pack)
  209. {
  210. if(!pack.moves.empty())
  211. {
  212. auto destArmy = pack.moves[0].srcArmy == pack.moves[0].dstArmy
  213. ? ObjectInstanceID()
  214. : pack.moves[0].dstArmy;
  215. dispatchGarrisonChange(cl, pack.moves[0].srcArmy, destArmy);
  216. }
  217. }
  218. void ApplyClientNetPackVisitor::visitBulkSmartRebalanceStacks(BulkSmartRebalanceStacks & pack)
  219. {
  220. if(!pack.moves.empty())
  221. {
  222. assert(pack.moves[0].srcArmy == pack.moves[0].dstArmy);
  223. dispatchGarrisonChange(cl, pack.moves[0].srcArmy, ObjectInstanceID());
  224. }
  225. else if(!pack.changes.empty())
  226. {
  227. dispatchGarrisonChange(cl, pack.changes[0].army, ObjectInstanceID());
  228. }
  229. }
  230. void ApplyClientNetPackVisitor::visitPutArtifact(PutArtifact & pack)
  231. {
  232. callInterfaceIfPresent(cl, pack.al.owningPlayer(), &IGameEventsReceiver::artifactPut, pack.al);
  233. if(pack.askAssemble)
  234. callInterfaceIfPresent(cl, pack.al.owningPlayer(), &IGameEventsReceiver::askToAssembleArtifact, pack.al);
  235. }
  236. void ApplyClientNetPackVisitor::visitEraseArtifact(EraseArtifact & pack)
  237. {
  238. callInterfaceIfPresent(cl, pack.al.owningPlayer(), &IGameEventsReceiver::artifactRemoved, pack.al);
  239. }
  240. void ApplyClientNetPackVisitor::visitMoveArtifact(MoveArtifact & pack)
  241. {
  242. auto moveArtifact = [this, &pack](PlayerColor player) -> void
  243. {
  244. callInterfaceIfPresent(cl, player, &IGameEventsReceiver::artifactMoved, pack.src, pack.dst);
  245. if(pack.askAssemble)
  246. callInterfaceIfPresent(cl, player, &IGameEventsReceiver::askToAssembleArtifact, pack.dst);
  247. };
  248. moveArtifact(pack.src.owningPlayer());
  249. if(pack.src.owningPlayer() != pack.dst.owningPlayer())
  250. moveArtifact(pack.dst.owningPlayer());
  251. cl.invalidatePaths(); // hero might have equipped/unequipped Angel Wings
  252. }
  253. void ApplyClientNetPackVisitor::visitBulkMoveArtifacts(BulkMoveArtifacts & pack)
  254. {
  255. auto applyMove = [this, &pack](std::vector<BulkMoveArtifacts::LinkedSlots> & artsPack) -> void
  256. {
  257. for(auto & slotToMove : artsPack)
  258. {
  259. auto srcLoc = ArtifactLocation(pack.srcArtHolder, slotToMove.srcPos);
  260. auto dstLoc = ArtifactLocation(pack.dstArtHolder, slotToMove.dstPos);
  261. MoveArtifact ma(&srcLoc, &dstLoc, false);
  262. visitMoveArtifact(ma);
  263. }
  264. };
  265. // Begin a session of bulk movement of arts. It is not necessary but useful for the client optimization.
  266. callInterfaceIfPresent(cl, cl.getCurrentPlayer(), &IGameEventsReceiver::bulkArtMovementStart,
  267. pack.artsPack0.size() + pack.artsPack1.size());
  268. applyMove(pack.artsPack0);
  269. if(pack.swap)
  270. applyMove(pack.artsPack1);
  271. }
  272. void ApplyClientNetPackVisitor::visitAssembledArtifact(AssembledArtifact & pack)
  273. {
  274. callInterfaceIfPresent(cl, pack.al.owningPlayer(), &IGameEventsReceiver::artifactAssembled, pack.al);
  275. cl.invalidatePaths(); // hero might have equipped/unequipped Angel Wings
  276. }
  277. void ApplyClientNetPackVisitor::visitDisassembledArtifact(DisassembledArtifact & pack)
  278. {
  279. callInterfaceIfPresent(cl, pack.al.owningPlayer(), &IGameEventsReceiver::artifactDisassembled, pack.al);
  280. cl.invalidatePaths(); // hero might have equipped/unequipped Angel Wings
  281. }
  282. void ApplyClientNetPackVisitor::visitHeroVisit(HeroVisit & pack)
  283. {
  284. auto hero = cl.getHero(pack.heroId);
  285. auto obj = cl.getObj(pack.objId, false);
  286. callInterfaceIfPresent(cl, pack.player, &IGameEventsReceiver::heroVisit, hero, obj, pack.starting);
  287. }
  288. void ApplyClientNetPackVisitor::visitNewTurn(NewTurn & pack)
  289. {
  290. cl.invalidatePaths();
  291. }
  292. void ApplyClientNetPackVisitor::visitGiveBonus(GiveBonus & pack)
  293. {
  294. cl.invalidatePaths();
  295. switch(pack.who)
  296. {
  297. case GiveBonus::ETarget::HERO:
  298. {
  299. const CGHeroInstance *h = gs.getHero(ObjectInstanceID(pack.id));
  300. callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroBonusChanged, h, pack.bonus, true);
  301. }
  302. break;
  303. case GiveBonus::ETarget::PLAYER:
  304. {
  305. callInterfaceIfPresent(cl, PlayerColor(pack.id), &IGameEventsReceiver::playerBonusChanged, pack.bonus, true);
  306. }
  307. break;
  308. }
  309. }
  310. void ApplyFirstClientNetPackVisitor::visitChangeObjPos(ChangeObjPos & pack)
  311. {
  312. CGObjectInstance *obj = gs.getObjInstance(pack.objid);
  313. if(CGI->mh)
  314. CGI->mh->onObjectFadeOut(obj);
  315. CGI->mh->waitForOngoingAnimations();
  316. }
  317. void ApplyClientNetPackVisitor::visitChangeObjPos(ChangeObjPos & pack)
  318. {
  319. CGObjectInstance *obj = gs.getObjInstance(pack.objid);
  320. if(CGI->mh)
  321. CGI->mh->onObjectFadeIn(obj);
  322. CGI->mh->waitForOngoingAnimations();
  323. cl.invalidatePaths();
  324. }
  325. void ApplyClientNetPackVisitor::visitPlayerEndsGame(PlayerEndsGame & pack)
  326. {
  327. callAllInterfaces(cl, &IGameEventsReceiver::gameOver, pack.player, pack.victoryLossCheckResult);
  328. // In auto testing pack.mode we always close client if red pack.player won or lose
  329. if(!settings["session"]["testmap"].isNull() && pack.player == PlayerColor(0))
  330. handleQuit(settings["session"]["spectate"].Bool()); // if spectator is active ask to close client or not
  331. }
  332. void ApplyClientNetPackVisitor::visitPlayerReinitInterface(PlayerReinitInterface & pack)
  333. {
  334. auto initInterfaces = [this]()
  335. {
  336. cl.initPlayerInterfaces();
  337. auto currentPlayer = cl.gameState()->currentPlayer;
  338. callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, currentPlayer);
  339. callOnlyThatInterface(cl, currentPlayer, &CGameInterface::yourTurn);
  340. };
  341. for(auto player : pack.players)
  342. {
  343. auto & plSettings = CSH->si->getIthPlayersSettings(player);
  344. if(pack.playerConnectionId == PlayerSettings::PLAYER_AI)
  345. {
  346. plSettings.connectedPlayerIDs.clear();
  347. cl.initPlayerEnvironments();
  348. initInterfaces();
  349. }
  350. else if(pack.playerConnectionId == CSH->c->connectionID)
  351. {
  352. plSettings.connectedPlayerIDs.insert(pack.playerConnectionId);
  353. cl.playerint.clear();
  354. initInterfaces();
  355. }
  356. }
  357. }
  358. void ApplyClientNetPackVisitor::visitRemoveBonus(RemoveBonus & pack)
  359. {
  360. cl.invalidatePaths();
  361. switch(pack.who)
  362. {
  363. case GiveBonus::ETarget::HERO:
  364. {
  365. const CGHeroInstance *h = gs.getHero(ObjectInstanceID(pack.id));
  366. callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroBonusChanged, h, pack.bonus, false);
  367. }
  368. break;
  369. case GiveBonus::ETarget::PLAYER:
  370. {
  371. //const PlayerState *p = gs.getPlayerState(pack.id);
  372. callInterfaceIfPresent(cl, PlayerColor(pack.id), &IGameEventsReceiver::playerBonusChanged, pack.bonus, false);
  373. }
  374. break;
  375. }
  376. }
  377. void ApplyFirstClientNetPackVisitor::visitRemoveObject(RemoveObject & pack)
  378. {
  379. const CGObjectInstance *o = cl.getObj(pack.id);
  380. if(CGI->mh)
  381. CGI->mh->onObjectFadeOut(o);
  382. //notify interfaces about removal
  383. for(auto i=cl.playerint.begin(); i!=cl.playerint.end(); i++)
  384. {
  385. //below line contains little cheat for AI so it will be aware of deletion of enemy heroes that moved or got re-covered by FoW
  386. //TODO: loose requirements as next AI related crashes appear, for example another pack.player collects object that got re-covered by FoW, unsure if AI code workarounds this
  387. if(gs.isVisible(o, i->first) || (!cl.getPlayerState(i->first)->human && o->ID == Obj::HERO && o->tempOwner != i->first))
  388. i->second->objectRemoved(o);
  389. }
  390. CGI->mh->waitForOngoingAnimations();
  391. }
  392. void ApplyClientNetPackVisitor::visitRemoveObject(RemoveObject & pack)
  393. {
  394. cl.invalidatePaths();
  395. for(auto i=cl.playerint.begin(); i!=cl.playerint.end(); i++)
  396. i->second->objectRemovedAfter();
  397. }
  398. void ApplyFirstClientNetPackVisitor::visitTryMoveHero(TryMoveHero & pack)
  399. {
  400. CGHeroInstance *h = gs.getHero(pack.id);
  401. if(CGI->mh)
  402. {
  403. switch (pack.result)
  404. {
  405. case TryMoveHero::EMBARK:
  406. CGI->mh->onBeforeHeroEmbark(h, pack.start, pack.end);
  407. break;
  408. case TryMoveHero::TELEPORTATION:
  409. CGI->mh->onBeforeHeroTeleported(h, pack.start, pack.end);
  410. break;
  411. case TryMoveHero::DISEMBARK:
  412. CGI->mh->onBeforeHeroDisembark(h, pack.start, pack.end);
  413. break;
  414. }
  415. CGI->mh->waitForOngoingAnimations();
  416. }
  417. }
  418. void ApplyClientNetPackVisitor::visitTryMoveHero(TryMoveHero & pack)
  419. {
  420. const CGHeroInstance *h = cl.getHero(pack.id);
  421. cl.invalidatePaths();
  422. if(CGI->mh)
  423. {
  424. switch(pack.result)
  425. {
  426. case TryMoveHero::SUCCESS:
  427. CGI->mh->onHeroMoved(h, pack.start, pack.end);
  428. break;
  429. case TryMoveHero::EMBARK:
  430. CGI->mh->onAfterHeroEmbark(h, pack.start, pack.end);
  431. break;
  432. case TryMoveHero::TELEPORTATION:
  433. CGI->mh->onAfterHeroTeleported(h, pack.start, pack.end);
  434. break;
  435. case TryMoveHero::DISEMBARK:
  436. CGI->mh->onAfterHeroDisembark(h, pack.start, pack.end);
  437. break;
  438. }
  439. }
  440. PlayerColor player = h->tempOwner;
  441. for(auto &i : cl.playerint)
  442. if(cl.getPlayerRelations(i.first, player) != PlayerRelations::ENEMIES)
  443. i.second->tileRevealed(pack.fowRevealed);
  444. for(auto i=cl.playerint.begin(); i!=cl.playerint.end(); i++)
  445. {
  446. if(i->first != PlayerColor::SPECTATOR && gs.checkForStandardLoss(i->first)) // Do not notify vanquished pack.player's interface
  447. continue;
  448. if(gs.isVisible(h->convertToVisitablePos(pack.start), i->first)
  449. || gs.isVisible(h->convertToVisitablePos(pack.end), i->first))
  450. {
  451. // pack.src and pack.dst of enemy hero move may be not visible => 'verbose' should be false
  452. const bool verbose = cl.getPlayerRelations(i->first, player) != PlayerRelations::ENEMIES;
  453. i->second->heroMoved(pack, verbose);
  454. }
  455. }
  456. }
  457. void ApplyClientNetPackVisitor::visitNewStructures(NewStructures & pack)
  458. {
  459. CGTownInstance *town = gs.getTown(pack.tid);
  460. for(const auto & id : pack.bid)
  461. {
  462. callInterfaceIfPresent(cl, town->tempOwner, &IGameEventsReceiver::buildChanged, town, id, 1);
  463. }
  464. // invalidate section of map view with our object and force an update
  465. CGI->mh->onObjectInstantRemove(town);
  466. CGI->mh->onObjectInstantAdd(town);
  467. }
  468. void ApplyClientNetPackVisitor::visitRazeStructures(RazeStructures & pack)
  469. {
  470. CGTownInstance * town = gs.getTown(pack.tid);
  471. for(const auto & id : pack.bid)
  472. {
  473. callInterfaceIfPresent(cl, town->tempOwner, &IGameEventsReceiver::buildChanged, town, id, 2);
  474. }
  475. // invalidate section of map view with our object and force an update
  476. CGI->mh->onObjectInstantRemove(town);
  477. CGI->mh->onObjectInstantAdd(town);
  478. }
  479. void ApplyClientNetPackVisitor::visitSetAvailableCreatures(SetAvailableCreatures & pack)
  480. {
  481. const CGDwelling * dw = static_cast<const CGDwelling*>(cl.getObj(pack.tid));
  482. PlayerColor p;
  483. if(dw->ID == Obj::WAR_MACHINE_FACTORY) //War Machines Factory is not flaggable, it's "owned" by visitor
  484. p = cl.getTile(dw->visitablePos())->visitableObjects.back()->tempOwner;
  485. else
  486. p = dw->tempOwner;
  487. callInterfaceIfPresent(cl, p, &IGameEventsReceiver::availableCreaturesChanged, dw);
  488. }
  489. void ApplyClientNetPackVisitor::visitSetHeroesInTown(SetHeroesInTown & pack)
  490. {
  491. CGTownInstance * t = gs.getTown(pack.tid);
  492. CGHeroInstance * hGarr = gs.getHero(pack.garrison);
  493. CGHeroInstance * hVisit = gs.getHero(pack.visiting);
  494. //inform all players that see this object
  495. for(auto i = cl.playerint.cbegin(); i != cl.playerint.cend(); ++i)
  496. {
  497. if(i->first >= PlayerColor::PLAYER_LIMIT)
  498. continue;
  499. if(gs.isVisible(t, i->first) ||
  500. (hGarr && gs.isVisible(hGarr, i->first)) ||
  501. (hVisit && gs.isVisible(hVisit, i->first)))
  502. {
  503. cl.playerint[i->first]->heroInGarrisonChange(t);
  504. }
  505. }
  506. }
  507. void ApplyClientNetPackVisitor::visitHeroRecruited(HeroRecruited & pack)
  508. {
  509. CGHeroInstance *h = gs.map->heroesOnMap.back();
  510. if(h->subID != pack.hid)
  511. {
  512. logNetwork->error("Something wrong with hero recruited!");
  513. }
  514. if(callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroCreated, h))
  515. {
  516. if(const CGTownInstance *t = gs.getTown(pack.tid))
  517. callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroInGarrisonChange, t);
  518. }
  519. if(CGI->mh)
  520. CGI->mh->onObjectInstantAdd(h);
  521. }
  522. void ApplyClientNetPackVisitor::visitGiveHero(GiveHero & pack)
  523. {
  524. CGHeroInstance *h = gs.getHero(pack.id);
  525. if(CGI->mh)
  526. CGI->mh->onObjectInstantAdd(h);
  527. callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroCreated, h);
  528. }
  529. void ApplyFirstClientNetPackVisitor::visitGiveHero(GiveHero & pack)
  530. {
  531. }
  532. void ApplyClientNetPackVisitor::visitInfoWindow(InfoWindow & pack)
  533. {
  534. std::string str = pack.text.toString();
  535. if(!callInterfaceIfPresent(cl, pack.player, &CGameInterface::showInfoDialog, pack.type, str, pack.components,(soundBase::soundID)pack.soundID))
  536. logNetwork->warn("We received InfoWindow for not our player...");
  537. }
  538. void ApplyFirstClientNetPackVisitor::visitSetObjectProperty(SetObjectProperty & pack)
  539. {
  540. //inform all players that see this object
  541. for(auto it = cl.playerint.cbegin(); it != cl.playerint.cend(); ++it)
  542. {
  543. if(gs.isVisible(gs.getObjInstance(pack.id), it->first))
  544. callInterfaceIfPresent(cl, it->first, &IGameEventsReceiver::beforeObjectPropertyChanged, &pack);
  545. }
  546. // invalidate section of map view with our object and force an update with new flag color
  547. if (pack.what == ObjProperty::OWNER)
  548. CGI->mh->onObjectInstantRemove(gs.getObjInstance(pack.id));
  549. }
  550. void ApplyClientNetPackVisitor::visitSetObjectProperty(SetObjectProperty & pack)
  551. {
  552. //inform all players that see this object
  553. for(auto it = cl.playerint.cbegin(); it != cl.playerint.cend(); ++it)
  554. {
  555. if(gs.isVisible(gs.getObjInstance(pack.id), it->first))
  556. callInterfaceIfPresent(cl, it->first, &IGameEventsReceiver::objectPropertyChanged, &pack);
  557. }
  558. // invalidate section of map view with our object and force an update with new flag color
  559. if (pack.what == ObjProperty::OWNER)
  560. CGI->mh->onObjectInstantAdd(gs.getObjInstance(pack.id));
  561. }
  562. void ApplyClientNetPackVisitor::visitHeroLevelUp(HeroLevelUp & pack)
  563. {
  564. const CGHeroInstance * hero = cl.getHero(pack.heroId);
  565. assert(hero);
  566. callOnlyThatInterface(cl, pack.player, &CGameInterface::heroGotLevel, hero, pack.primskill, pack.skills, pack.queryID);
  567. }
  568. void ApplyClientNetPackVisitor::visitCommanderLevelUp(CommanderLevelUp & pack)
  569. {
  570. const CGHeroInstance * hero = cl.getHero(pack.heroId);
  571. assert(hero);
  572. const CCommanderInstance * commander = hero->commander;
  573. assert(commander);
  574. assert(commander->armyObj); //is it possible for Commander to exist beyond armed instance?
  575. callOnlyThatInterface(cl, pack.player, &CGameInterface::commanderGotLevel, commander, pack.skills, pack.queryID);
  576. }
  577. void ApplyClientNetPackVisitor::visitBlockingDialog(BlockingDialog & pack)
  578. {
  579. std::string str = pack.text.toString();
  580. if(!callOnlyThatInterface(cl, pack.player, &CGameInterface::showBlockingDialog, str, pack.components, pack.queryID, (soundBase::soundID)pack.soundID, pack.selection(), pack.cancel()))
  581. logNetwork->warn("We received YesNoDialog for not our player...");
  582. }
  583. void ApplyClientNetPackVisitor::visitGarrisonDialog(GarrisonDialog & pack)
  584. {
  585. const CGHeroInstance *h = cl.getHero(pack.hid);
  586. const CArmedInstance *obj = static_cast<const CArmedInstance*>(cl.getObj(pack.objid));
  587. callOnlyThatInterface(cl, h->getOwner(), &CGameInterface::showGarrisonDialog, obj, h, pack.removableUnits, pack.queryID);
  588. }
  589. void ApplyClientNetPackVisitor::visitExchangeDialog(ExchangeDialog & pack)
  590. {
  591. callInterfaceIfPresent(cl, pack.player, &IGameEventsReceiver::heroExchangeStarted, pack.hero1, pack.hero2, pack.queryID);
  592. }
  593. void ApplyClientNetPackVisitor::visitTeleportDialog(TeleportDialog & pack)
  594. {
  595. callOnlyThatInterface(cl, pack.player, &CGameInterface::showTeleportDialog, pack.channel, pack.exits, pack.impassable, pack.queryID);
  596. }
  597. void ApplyClientNetPackVisitor::visitMapObjectSelectDialog(MapObjectSelectDialog & pack)
  598. {
  599. callOnlyThatInterface(cl, pack.player, &CGameInterface::showMapObjectSelectDialog, pack.queryID, pack.icon, pack.title, pack.description, pack.objects);
  600. }
  601. void ApplyFirstClientNetPackVisitor::visitBattleStart(BattleStart & pack)
  602. {
  603. // Cannot use the usual code because curB is not set yet
  604. callOnlyThatBattleInterface(cl, pack.info->sides[0].color, &IBattleEventsReceiver::battleStartBefore, pack.info->sides[0].armyObject, pack.info->sides[1].armyObject,
  605. pack.info->tile, pack.info->sides[0].hero, pack.info->sides[1].hero);
  606. callOnlyThatBattleInterface(cl, pack.info->sides[1].color, &IBattleEventsReceiver::battleStartBefore, pack.info->sides[0].armyObject, pack.info->sides[1].armyObject,
  607. pack.info->tile, pack.info->sides[0].hero, pack.info->sides[1].hero);
  608. callOnlyThatBattleInterface(cl, PlayerColor::SPECTATOR, &IBattleEventsReceiver::battleStartBefore, pack.info->sides[0].armyObject, pack.info->sides[1].armyObject,
  609. pack.info->tile, pack.info->sides[0].hero, pack.info->sides[1].hero);
  610. }
  611. void ApplyClientNetPackVisitor::visitBattleStart(BattleStart & pack)
  612. {
  613. cl.battleStarted(pack.info);
  614. }
  615. void ApplyFirstClientNetPackVisitor::visitBattleNextRound(BattleNextRound & pack)
  616. {
  617. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleNewRoundFirst, pack.round);
  618. }
  619. void ApplyClientNetPackVisitor::visitBattleNextRound(BattleNextRound & pack)
  620. {
  621. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleNewRound, pack.round);
  622. }
  623. void ApplyClientNetPackVisitor::visitBattleSetActiveStack(BattleSetActiveStack & pack)
  624. {
  625. if(!pack.askPlayerInterface)
  626. return;
  627. const CStack *activated = gs.curB->battleGetStackByID(pack.stack);
  628. PlayerColor playerToCall; //pack.player that will move activated stack
  629. if (activated->hasBonusOfType(BonusType::HYPNOTIZED))
  630. {
  631. playerToCall = (gs.curB->sides[0].color == activated->unitOwner()
  632. ? gs.curB->sides[1].color
  633. : gs.curB->sides[0].color);
  634. }
  635. else
  636. {
  637. playerToCall = activated->unitOwner();
  638. }
  639. cl.startPlayerBattleAction(playerToCall);
  640. }
  641. void ApplyClientNetPackVisitor::visitBattleLogMessage(BattleLogMessage & pack)
  642. {
  643. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleLogMessage, pack.lines);
  644. }
  645. void ApplyClientNetPackVisitor::visitBattleTriggerEffect(BattleTriggerEffect & pack)
  646. {
  647. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleTriggerEffect, pack);
  648. }
  649. void ApplyFirstClientNetPackVisitor::visitBattleUpdateGateState(BattleUpdateGateState & pack)
  650. {
  651. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleGateStateChanged, pack.state);
  652. }
  653. void ApplyFirstClientNetPackVisitor::visitBattleResult(BattleResult & pack)
  654. {
  655. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleEnd, &pack, pack.queryID);
  656. cl.battleFinished();
  657. }
  658. void ApplyFirstClientNetPackVisitor::visitBattleStackMoved(BattleStackMoved & pack)
  659. {
  660. const CStack * movedStack = gs.curB->battleGetStackByID(pack.stack);
  661. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStackMoved, movedStack, pack.tilesToMove, pack.distance, pack.teleporting);
  662. }
  663. void ApplyFirstClientNetPackVisitor::visitBattleAttack(BattleAttack & pack)
  664. {
  665. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleAttack, &pack);
  666. // battleStacksAttacked should be excuted before BattleAttack.applyGs() to play animation before damaging unit
  667. // so this has to be here instead of ApplyClientNetPackVisitor::visitBattleAttack()
  668. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStacksAttacked, pack.bsa, pack.shot());
  669. }
  670. void ApplyClientNetPackVisitor::visitBattleAttack(BattleAttack & pack)
  671. {
  672. }
  673. void ApplyFirstClientNetPackVisitor::visitStartAction(StartAction & pack)
  674. {
  675. cl.curbaction = std::make_optional(pack.ba);
  676. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::actionStarted, pack.ba);
  677. }
  678. void ApplyClientNetPackVisitor::visitBattleSpellCast(BattleSpellCast & pack)
  679. {
  680. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleSpellCast, &pack);
  681. }
  682. void ApplyClientNetPackVisitor::visitSetStackEffect(SetStackEffect & pack)
  683. {
  684. //informing about effects
  685. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStacksEffectsSet, pack);
  686. }
  687. void ApplyClientNetPackVisitor::visitStacksInjured(StacksInjured & pack)
  688. {
  689. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStacksAttacked, pack.stacks, false);
  690. }
  691. void ApplyClientNetPackVisitor::visitBattleResultsApplied(BattleResultsApplied & pack)
  692. {
  693. callInterfaceIfPresent(cl, pack.player1, &IGameEventsReceiver::battleResultsApplied);
  694. callInterfaceIfPresent(cl, pack.player2, &IGameEventsReceiver::battleResultsApplied);
  695. callInterfaceIfPresent(cl, PlayerColor::SPECTATOR, &IGameEventsReceiver::battleResultsApplied);
  696. }
  697. void ApplyClientNetPackVisitor::visitBattleUnitsChanged(BattleUnitsChanged & pack)
  698. {
  699. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleUnitsChanged, pack.changedStacks);
  700. }
  701. void ApplyClientNetPackVisitor::visitBattleObstaclesChanged(BattleObstaclesChanged & pack)
  702. {
  703. //inform interfaces about removed obstacles
  704. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleObstaclesChanged, pack.changes);
  705. }
  706. void ApplyClientNetPackVisitor::visitCatapultAttack(CatapultAttack & pack)
  707. {
  708. //inform interfaces about catapult attack
  709. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleCatapultAttacked, pack);
  710. }
  711. void ApplyClientNetPackVisitor::visitEndAction(EndAction & pack)
  712. {
  713. callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::actionFinished, *cl.curbaction);
  714. cl.curbaction.reset();
  715. }
  716. void ApplyClientNetPackVisitor::visitPackageApplied(PackageApplied & pack)
  717. {
  718. callInterfaceIfPresent(cl, pack.player, &IGameEventsReceiver::requestRealized, &pack);
  719. if(!CClient::waitingRequest.tryRemovingElement(pack.requestID))
  720. logNetwork->warn("Surprising server message! PackageApplied for unknown requestID!");
  721. }
  722. void ApplyClientNetPackVisitor::visitSystemMessage(SystemMessage & pack)
  723. {
  724. std::ostringstream str;
  725. str << "System message: " << pack.text;
  726. logNetwork->error(str.str()); // usually used to receive error messages from server
  727. if(LOCPLINT && !settings["session"]["hideSystemMessages"].Bool())
  728. LOCPLINT->cingconsole->print(str.str());
  729. }
  730. void ApplyClientNetPackVisitor::visitPlayerBlocked(PlayerBlocked & pack)
  731. {
  732. callInterfaceIfPresent(cl, pack.player, &IGameEventsReceiver::playerBlocked, pack.reason, pack.startOrEnd == PlayerBlocked::BLOCKADE_STARTED);
  733. }
  734. void ApplyClientNetPackVisitor::visitYourTurn(YourTurn & pack)
  735. {
  736. logNetwork->debug("Server gives turn to %s", pack.player.getStr());
  737. callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, pack.player);
  738. callOnlyThatInterface(cl, pack.player, &CGameInterface::yourTurn);
  739. }
  740. void ApplyClientNetPackVisitor::visitPlayerMessageClient(PlayerMessageClient & pack)
  741. {
  742. logNetwork->debug("pack.player %s sends a message: %s", pack.player.getStr(), pack.text);
  743. std::ostringstream str;
  744. if(pack.player.isSpectator())
  745. str << "Spectator: " << pack.text;
  746. else
  747. str << cl.getPlayerState(pack.player)->nodeName() <<": " << pack.text;
  748. if(LOCPLINT)
  749. LOCPLINT->cingconsole->print(str.str());
  750. }
  751. void ApplyClientNetPackVisitor::visitAdvmapSpellCast(AdvmapSpellCast & pack)
  752. {
  753. cl.invalidatePaths();
  754. auto caster = cl.getHero(pack.casterID);
  755. if(caster)
  756. //consider notifying other interfaces that see hero?
  757. callInterfaceIfPresent(cl, caster->getOwner(), &IGameEventsReceiver::advmapSpellCast, caster, pack.spellID);
  758. else
  759. logNetwork->error("Invalid hero instance");
  760. }
  761. void ApplyClientNetPackVisitor::visitShowWorldViewEx(ShowWorldViewEx & pack)
  762. {
  763. callOnlyThatInterface(cl, pack.player, &CGameInterface::showWorldViewEx, pack.objectPositions, pack.showTerrain);
  764. }
  765. void ApplyClientNetPackVisitor::visitOpenWindow(OpenWindow & pack)
  766. {
  767. switch(pack.window)
  768. {
  769. case EOpenWindowMode::RECRUITMENT_FIRST:
  770. case EOpenWindowMode::RECRUITMENT_ALL:
  771. {
  772. const CGDwelling *dw = dynamic_cast<const CGDwelling*>(cl.getObj(ObjectInstanceID(pack.id1)));
  773. const CArmedInstance *dst = dynamic_cast<const CArmedInstance*>(cl.getObj(ObjectInstanceID(pack.id2)));
  774. callInterfaceIfPresent(cl, dst->tempOwner, &IGameEventsReceiver::showRecruitmentDialog, dw, dst, pack.window == EOpenWindowMode::RECRUITMENT_FIRST ? 0 : -1);
  775. }
  776. break;
  777. case EOpenWindowMode::SHIPYARD_WINDOW:
  778. {
  779. const IShipyard *sy = IShipyard::castFrom(cl.getObj(ObjectInstanceID(pack.id1)));
  780. callInterfaceIfPresent(cl, sy->getObject()->getOwner(), &IGameEventsReceiver::showShipyardDialog, sy);
  781. }
  782. break;
  783. case EOpenWindowMode::THIEVES_GUILD:
  784. {
  785. //displays Thieves' Guild window (when hero enters Den of Thieves)
  786. const CGObjectInstance *obj = cl.getObj(ObjectInstanceID(pack.id2));
  787. callInterfaceIfPresent(cl, PlayerColor(pack.id1), &IGameEventsReceiver::showThievesGuildWindow, obj);
  788. }
  789. break;
  790. case EOpenWindowMode::UNIVERSITY_WINDOW:
  791. {
  792. //displays University window (when hero enters University on adventure map)
  793. const IMarket *market = IMarket::castFrom(cl.getObj(ObjectInstanceID(pack.id1)));
  794. const CGHeroInstance *hero = cl.getHero(ObjectInstanceID(pack.id2));
  795. callInterfaceIfPresent(cl, hero->tempOwner, &IGameEventsReceiver::showUniversityWindow, market, hero);
  796. }
  797. break;
  798. case EOpenWindowMode::MARKET_WINDOW:
  799. {
  800. //displays Thieves' Guild window (when hero enters Den of Thieves)
  801. const CGObjectInstance *obj = cl.getObj(ObjectInstanceID(pack.id1));
  802. const CGHeroInstance *hero = cl.getHero(ObjectInstanceID(pack.id2));
  803. const IMarket *market = IMarket::castFrom(obj);
  804. callInterfaceIfPresent(cl, cl.getTile(obj->visitablePos())->visitableObjects.back()->tempOwner, &IGameEventsReceiver::showMarketWindow, market, hero);
  805. }
  806. break;
  807. case EOpenWindowMode::HILL_FORT_WINDOW:
  808. {
  809. //displays Hill fort window
  810. const CGObjectInstance *obj = cl.getObj(ObjectInstanceID(pack.id1));
  811. const CGHeroInstance *hero = cl.getHero(ObjectInstanceID(pack.id2));
  812. callInterfaceIfPresent(cl, cl.getTile(obj->visitablePos())->visitableObjects.back()->tempOwner, &IGameEventsReceiver::showHillFortWindow, obj, hero);
  813. }
  814. break;
  815. case EOpenWindowMode::PUZZLE_MAP:
  816. {
  817. callInterfaceIfPresent(cl, PlayerColor(pack.id1), &IGameEventsReceiver::showPuzzleMap);
  818. }
  819. break;
  820. case EOpenWindowMode::TAVERN_WINDOW:
  821. const CGObjectInstance *obj1 = cl.getObj(ObjectInstanceID(pack.id1)),
  822. *obj2 = cl.getObj(ObjectInstanceID(pack.id2));
  823. callInterfaceIfPresent(cl, obj1->tempOwner, &IGameEventsReceiver::showTavernWindow, obj2);
  824. break;
  825. }
  826. }
  827. void ApplyClientNetPackVisitor::visitCenterView(CenterView & pack)
  828. {
  829. callInterfaceIfPresent(cl, pack.player, &IGameEventsReceiver::centerView, pack.pos, pack.focusTime);
  830. }
  831. void ApplyClientNetPackVisitor::visitNewObject(NewObject & pack)
  832. {
  833. cl.invalidatePaths();
  834. const CGObjectInstance *obj = cl.getObj(pack.createdObjectID);
  835. if(CGI->mh)
  836. CGI->mh->onObjectFadeIn(obj);
  837. for(auto i=cl.playerint.begin(); i!=cl.playerint.end(); i++)
  838. {
  839. if(gs.isVisible(obj, i->first))
  840. i->second->newObject(obj);
  841. }
  842. CGI->mh->waitForOngoingAnimations();
  843. }
  844. void ApplyClientNetPackVisitor::visitSetAvailableArtifacts(SetAvailableArtifacts & pack)
  845. {
  846. if(pack.id < 0) //artifact merchants globally
  847. {
  848. callAllInterfaces(cl, &IGameEventsReceiver::availableArtifactsChanged, nullptr);
  849. }
  850. else
  851. {
  852. const CGBlackMarket *bm = dynamic_cast<const CGBlackMarket *>(cl.getObj(ObjectInstanceID(pack.id)));
  853. assert(bm);
  854. callInterfaceIfPresent(cl, cl.getTile(bm->visitablePos())->visitableObjects.back()->tempOwner, &IGameEventsReceiver::availableArtifactsChanged, bm);
  855. }
  856. }
  857. void ApplyClientNetPackVisitor::visitEntitiesChanged(EntitiesChanged & pack)
  858. {
  859. cl.invalidatePaths();
  860. }