NetPacksClient.cpp 35 KB

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