PacksForClient.h 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549
  1. /*
  2. * PacksForClient.h, 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. #pragma once
  11. #include "ArtifactLocation.h"
  12. #include "Component.h"
  13. #include "EInfoWindowMode.h"
  14. #include "EOpenWindowMode.h"
  15. #include "EntityChanges.h"
  16. #include "NetPacksBase.h"
  17. #include "ObjProperty.h"
  18. #include "../CCreatureSet.h"
  19. #include "../ResourceSet.h"
  20. #include "../TurnTimerInfo.h"
  21. #include "../gameState/EVictoryLossCheckResult.h"
  22. #include "../gameState/RumorState.h"
  23. #include "../gameState/QuestInfo.h"
  24. #include "../gameState/TavernSlot.h"
  25. #include "../gameState/GameStatistics.h"
  26. #include "../int3.h"
  27. #include "../mapping/CMapDefines.h"
  28. #include "../spells/ViewSpellInt.h"
  29. class CClient;
  30. class CGameHandler;
  31. VCMI_LIB_NAMESPACE_BEGIN
  32. class CGameState;
  33. class CArtifact;
  34. class CGObjectInstance;
  35. class CArtifactInstance;
  36. struct StackLocation;
  37. struct ArtSlotInfo;
  38. struct QuestInfo;
  39. class IBattleState;
  40. class BattleInfo;
  41. // This one teleport-specific, but has to be available everywhere in callbacks and netpacks
  42. // For now it's will be there till teleports code refactored and moved into own file
  43. using TTeleportExitsList = std::vector<std::pair<ObjectInstanceID, int3>>;
  44. /***********************************************************************************************************/
  45. struct DLL_LINKAGE PackageApplied : public CPackForClient
  46. {
  47. PackageApplied() = default;
  48. explicit PackageApplied(ui8 Result)
  49. : result(Result)
  50. {
  51. }
  52. void visitTyped(ICPackVisitor & visitor) override;
  53. void applyGs(CGameState *gs) override {}
  54. ui8 result = 0; //0 - something went wrong, request hasn't been realized; 1 - OK
  55. ui32 packType = 0; //type id of applied package
  56. ui32 requestID = 0; //an ID given by client to the request that was applied
  57. PlayerColor player;
  58. template <typename Handler> void serialize(Handler & h)
  59. {
  60. h & result;
  61. h & packType;
  62. h & requestID;
  63. h & player;
  64. }
  65. };
  66. struct DLL_LINKAGE SystemMessage : public CPackForClient
  67. {
  68. explicit SystemMessage(MetaString Text)
  69. : text(std::move(Text))
  70. {
  71. }
  72. SystemMessage() = default;
  73. void visitTyped(ICPackVisitor & visitor) override;
  74. void applyGs(CGameState *gs) override {}
  75. MetaString text;
  76. template <typename Handler> void serialize(Handler & h)
  77. {
  78. h & text;
  79. }
  80. };
  81. struct DLL_LINKAGE PlayerBlocked : public CPackForClient
  82. {
  83. enum EReason { UPCOMING_BATTLE, ONGOING_MOVEMENT };
  84. enum EMode { BLOCKADE_STARTED, BLOCKADE_ENDED };
  85. EReason reason = UPCOMING_BATTLE;
  86. EMode startOrEnd = BLOCKADE_STARTED;
  87. PlayerColor player;
  88. void visitTyped(ICPackVisitor & visitor) override;
  89. void applyGs(CGameState *gs) override {}
  90. template <typename Handler> void serialize(Handler & h)
  91. {
  92. h & reason;
  93. h & startOrEnd;
  94. h & player;
  95. }
  96. };
  97. struct DLL_LINKAGE PlayerCheated : public CPackForClient
  98. {
  99. void applyGs(CGameState * gs) override;
  100. PlayerColor player;
  101. bool losingCheatCode = false;
  102. bool winningCheatCode = false;
  103. void visitTyped(ICPackVisitor & visitor) override;
  104. template <typename Handler> void serialize(Handler & h)
  105. {
  106. h & player;
  107. h & losingCheatCode;
  108. h & winningCheatCode;
  109. }
  110. };
  111. struct DLL_LINKAGE TurnTimeUpdate : public CPackForClient
  112. {
  113. void applyGs(CGameState * gs) override;
  114. PlayerColor player;
  115. TurnTimerInfo turnTimer;
  116. template <typename Handler> void serialize(Handler & h)
  117. {
  118. h & player;
  119. h & turnTimer;
  120. }
  121. };
  122. struct DLL_LINKAGE PlayerStartsTurn : public Query
  123. {
  124. void applyGs(CGameState * gs) override;
  125. PlayerColor player;
  126. void visitTyped(ICPackVisitor & visitor) override;
  127. template <typename Handler> void serialize(Handler & h)
  128. {
  129. h & queryID;
  130. h & player;
  131. }
  132. };
  133. struct DLL_LINKAGE DaysWithoutTown : public CPackForClient
  134. {
  135. void applyGs(CGameState * gs) override;
  136. PlayerColor player;
  137. std::optional<int32_t> daysWithoutCastle;
  138. void visitTyped(ICPackVisitor & visitor) override;
  139. template <typename Handler> void serialize(Handler & h)
  140. {
  141. h & player;
  142. h & daysWithoutCastle;
  143. }
  144. };
  145. struct DLL_LINKAGE EntitiesChanged : public CPackForClient
  146. {
  147. std::vector<EntityChanges> changes;
  148. void applyGs(CGameState * gs) override;
  149. void visitTyped(ICPackVisitor & visitor) override;
  150. template <typename Handler> void serialize(Handler & h)
  151. {
  152. h & changes;
  153. }
  154. };
  155. struct DLL_LINKAGE SetResources : public CPackForClient
  156. {
  157. void applyGs(CGameState * gs) override;
  158. void visitTyped(ICPackVisitor & visitor) override;
  159. bool abs = true; //false - changes by value; 1 - sets to value
  160. PlayerColor player;
  161. ResourceSet res; //res[resid] => res amount
  162. template <typename Handler> void serialize(Handler & h)
  163. {
  164. h & abs;
  165. h & player;
  166. h & res;
  167. }
  168. };
  169. struct DLL_LINKAGE SetPrimSkill : public CPackForClient
  170. {
  171. void applyGs(CGameState * gs) override;
  172. void visitTyped(ICPackVisitor & visitor) override;
  173. ui8 abs = 0; //0 - changes by value; 1 - sets to value
  174. ObjectInstanceID id;
  175. PrimarySkill which = PrimarySkill::ATTACK;
  176. si64 val = 0;
  177. template <typename Handler> void serialize(Handler & h)
  178. {
  179. h & abs;
  180. h & id;
  181. h & which;
  182. h & val;
  183. }
  184. };
  185. struct DLL_LINKAGE SetSecSkill : public CPackForClient
  186. {
  187. void applyGs(CGameState * gs) override;
  188. void visitTyped(ICPackVisitor & visitor) override;
  189. ui8 abs = 0; //0 - changes by value; 1 - sets to value
  190. ObjectInstanceID id;
  191. SecondarySkill which;
  192. ui16 val = 0;
  193. template <typename Handler> void serialize(Handler & h)
  194. {
  195. h & abs;
  196. h & id;
  197. h & which;
  198. h & val;
  199. }
  200. };
  201. struct DLL_LINKAGE HeroVisitCastle : public CPackForClient
  202. {
  203. void applyGs(CGameState * gs) override;
  204. void visitTyped(ICPackVisitor & visitor) override;
  205. ui8 flags = 0; //1 - start
  206. ObjectInstanceID tid;
  207. ObjectInstanceID hid;
  208. bool start() const //if hero is entering castle (if false - leaving)
  209. {
  210. return flags & 1;
  211. }
  212. template <typename Handler> void serialize(Handler & h)
  213. {
  214. h & flags;
  215. h & tid;
  216. h & hid;
  217. }
  218. };
  219. struct DLL_LINKAGE ChangeSpells : public CPackForClient
  220. {
  221. void applyGs(CGameState * gs) override;
  222. void visitTyped(ICPackVisitor & visitor) override;
  223. ui8 learn = 1; //1 - gives spell, 0 - takes
  224. ObjectInstanceID hid;
  225. std::set<SpellID> spells;
  226. template <typename Handler> void serialize(Handler & h)
  227. {
  228. h & learn;
  229. h & hid;
  230. h & spells;
  231. }
  232. };
  233. struct DLL_LINKAGE SetResearchedSpells : public CPackForClient
  234. {
  235. void applyGs(CGameState * gs) override;
  236. void visitTyped(ICPackVisitor & visitor) override;
  237. ui8 level = 0;
  238. ObjectInstanceID tid;
  239. std::vector<SpellID> spells;
  240. bool accepted;
  241. template <typename Handler> void serialize(Handler & h)
  242. {
  243. h & level;
  244. h & tid;
  245. h & spells;
  246. h & accepted;
  247. }
  248. };
  249. struct DLL_LINKAGE SetMana : public CPackForClient
  250. {
  251. void applyGs(CGameState * gs) override;
  252. void visitTyped(ICPackVisitor & visitor) override;
  253. SetMana() = default;
  254. SetMana(ObjectInstanceID hid, si32 val, bool absolute)
  255. : hid(hid)
  256. , val(val)
  257. , absolute(absolute)
  258. {}
  259. ObjectInstanceID hid;
  260. si32 val = 0;
  261. bool absolute = true;
  262. template <typename Handler> void serialize(Handler & h)
  263. {
  264. h & val;
  265. h & hid;
  266. h & absolute;
  267. }
  268. };
  269. struct DLL_LINKAGE SetMovePoints : public CPackForClient
  270. {
  271. void applyGs(CGameState * gs) override;
  272. SetMovePoints() = default;
  273. SetMovePoints(ObjectInstanceID hid, si32 val, bool absolute)
  274. : hid(hid)
  275. , val(val)
  276. , absolute(absolute)
  277. {}
  278. ObjectInstanceID hid;
  279. si32 val = 0;
  280. bool absolute = true;
  281. void visitTyped(ICPackVisitor & visitor) override;
  282. template <typename Handler> void serialize(Handler & h)
  283. {
  284. h & val;
  285. h & hid;
  286. h & absolute;
  287. }
  288. };
  289. struct DLL_LINKAGE FoWChange : public CPackForClient
  290. {
  291. void applyGs(CGameState * gs) override;
  292. std::unordered_set<int3> tiles;
  293. PlayerColor player;
  294. ETileVisibility mode;
  295. bool waitForDialogs = false;
  296. void visitTyped(ICPackVisitor & visitor) override;
  297. template <typename Handler> void serialize(Handler & h)
  298. {
  299. h & tiles;
  300. h & player;
  301. h & mode;
  302. h & waitForDialogs;
  303. }
  304. };
  305. struct DLL_LINKAGE SetAvailableHero : public CPackForClient
  306. {
  307. SetAvailableHero()
  308. {
  309. army.clearSlots();
  310. }
  311. void applyGs(CGameState * gs) override;
  312. TavernHeroSlot slotID;
  313. TavernSlotRole roleID;
  314. PlayerColor player;
  315. HeroTypeID hid; //HeroTypeID::NONE if no hero
  316. CSimpleArmy army;
  317. bool replenishPoints;
  318. void visitTyped(ICPackVisitor & visitor) override;
  319. template <typename Handler> void serialize(Handler & h)
  320. {
  321. h & slotID;
  322. h & roleID;
  323. h & player;
  324. h & hid;
  325. h & army;
  326. h & replenishPoints;
  327. }
  328. };
  329. struct DLL_LINKAGE GiveBonus : public CPackForClient
  330. {
  331. enum class ETarget : int8_t { OBJECT, PLAYER, BATTLE };
  332. explicit GiveBonus(ETarget Who = ETarget::OBJECT)
  333. :who(Who)
  334. {
  335. }
  336. void applyGs(CGameState * gs) override;
  337. ETarget who = ETarget::OBJECT;
  338. VariantIdentifier<ObjectInstanceID, PlayerColor, BattleID> id;
  339. Bonus bonus;
  340. void visitTyped(ICPackVisitor & visitor) override;
  341. template <typename Handler> void serialize(Handler & h)
  342. {
  343. h & bonus;
  344. h & id;
  345. h & who;
  346. assert(id.getNum() != -1);
  347. }
  348. };
  349. struct DLL_LINKAGE ChangeObjPos : public CPackForClient
  350. {
  351. void applyGs(CGameState * gs) override;
  352. /// Object to move
  353. ObjectInstanceID objid;
  354. /// New position of visitable tile of an object
  355. int3 nPos;
  356. /// Player that initiated this action, if any
  357. PlayerColor initiator;
  358. void visitTyped(ICPackVisitor & visitor) override;
  359. template <typename Handler> void serialize(Handler & h)
  360. {
  361. h & objid;
  362. h & nPos;
  363. h & initiator;
  364. }
  365. };
  366. struct DLL_LINKAGE PlayerEndsTurn : public CPackForClient
  367. {
  368. void applyGs(CGameState * gs) override;
  369. PlayerColor player;
  370. void visitTyped(ICPackVisitor & visitor) override;
  371. template <typename Handler> void serialize(Handler & h)
  372. {
  373. h & player;
  374. }
  375. };
  376. struct DLL_LINKAGE PlayerEndsGame : public CPackForClient
  377. {
  378. void applyGs(CGameState * gs) override;
  379. PlayerColor player;
  380. EVictoryLossCheckResult victoryLossCheckResult;
  381. StatisticDataSet statistic;
  382. void visitTyped(ICPackVisitor & visitor) override;
  383. template <typename Handler> void serialize(Handler & h)
  384. {
  385. h & player;
  386. h & victoryLossCheckResult;
  387. if (h.version >= Handler::Version::STATISTICS_SCREEN)
  388. h & statistic;
  389. }
  390. };
  391. struct DLL_LINKAGE PlayerReinitInterface : public CPackForClient
  392. {
  393. void applyGs(CGameState * gs) override;
  394. std::vector<PlayerColor> players;
  395. ui8 playerConnectionId; //PLAYER_AI for AI player
  396. void visitTyped(ICPackVisitor & visitor) override;
  397. template <typename Handler> void serialize(Handler & h)
  398. {
  399. h & players;
  400. h & playerConnectionId;
  401. }
  402. };
  403. struct DLL_LINKAGE RemoveBonus : public CPackForClient
  404. {
  405. explicit RemoveBonus(GiveBonus::ETarget Who = GiveBonus::ETarget::OBJECT)
  406. :who(Who)
  407. {
  408. }
  409. void applyGs(CGameState * gs) override;
  410. GiveBonus::ETarget who; //who receives bonus
  411. VariantIdentifier<HeroTypeID, PlayerColor, BattleID, ObjectInstanceID> whoID;
  412. //vars to identify bonus: its source
  413. BonusSource source;
  414. BonusSourceID id; //source id
  415. //used locally: copy of removed bonus
  416. Bonus bonus;
  417. void visitTyped(ICPackVisitor & visitor) override;
  418. template <typename Handler> void serialize(Handler & h)
  419. {
  420. h & source;
  421. h & id;
  422. h & who;
  423. h & whoID;
  424. }
  425. };
  426. struct DLL_LINKAGE SetCommanderProperty : public CPackForClient
  427. {
  428. enum ECommanderProperty { ALIVE, BONUS, SECONDARY_SKILL, EXPERIENCE, SPECIAL_SKILL };
  429. void applyGs(CGameState * gs) override;
  430. ObjectInstanceID heroid;
  431. ECommanderProperty which = ALIVE;
  432. TExpType amount = 0; //0 for dead, >0 for alive
  433. si32 additionalInfo = 0; //for secondary skills choice
  434. Bonus accumulatedBonus;
  435. void visitTyped(ICPackVisitor & visitor) override;
  436. template <typename Handler> void serialize(Handler & h)
  437. {
  438. h & heroid;
  439. h & which;
  440. h & amount;
  441. h & additionalInfo;
  442. h & accumulatedBonus;
  443. }
  444. };
  445. struct DLL_LINKAGE AddQuest : public CPackForClient
  446. {
  447. void applyGs(CGameState * gs) override;
  448. PlayerColor player;
  449. QuestInfo quest;
  450. void visitTyped(ICPackVisitor & visitor) override;
  451. template <typename Handler> void serialize(Handler & h)
  452. {
  453. h & player;
  454. h & quest;
  455. }
  456. };
  457. struct DLL_LINKAGE UpdateArtHandlerLists : public CPackForClient
  458. {
  459. std::map<ArtifactID, int> allocatedArtifacts;
  460. void applyGs(CGameState * gs) override;
  461. void visitTyped(ICPackVisitor & visitor) override;
  462. template <typename Handler> void serialize(Handler & h)
  463. {
  464. h & allocatedArtifacts;
  465. }
  466. };
  467. struct DLL_LINKAGE ChangeFormation : public CPackForClient
  468. {
  469. ObjectInstanceID hid;
  470. EArmyFormation formation{};
  471. void applyGs(CGameState * gs) override;
  472. void visitTyped(ICPackVisitor & visitor) override;
  473. template <typename Handler> void serialize(Handler & h)
  474. {
  475. h & hid;
  476. h & formation;
  477. }
  478. };
  479. struct DLL_LINKAGE RemoveObject : public CPackForClient
  480. {
  481. RemoveObject() = default;
  482. RemoveObject(const ObjectInstanceID & objectID, const PlayerColor & initiator)
  483. : objectID(objectID)
  484. , initiator(initiator)
  485. {
  486. }
  487. void applyGs(CGameState * gs) override;
  488. void visitTyped(ICPackVisitor & visitor) override;
  489. /// ID of removed object
  490. ObjectInstanceID objectID;
  491. /// Player that initiated this action, if any
  492. PlayerColor initiator;
  493. template <typename Handler> void serialize(Handler & h)
  494. {
  495. h & objectID;
  496. h & initiator;
  497. }
  498. };
  499. struct DLL_LINKAGE TryMoveHero : public CPackForClient
  500. {
  501. void applyGs(CGameState * gs) override;
  502. enum EResult
  503. {
  504. FAILED,
  505. SUCCESS,
  506. TELEPORTATION,
  507. BLOCKING_VISIT,
  508. EMBARK,
  509. DISEMBARK
  510. };
  511. /// ID of moved hero
  512. ObjectInstanceID id;
  513. /// Movement points that hero will have after movement
  514. ui32 movePoints = 0;
  515. /// Result of movement attempt. FAILED should generally never happen unless client requested invalid operation
  516. EResult result = FAILED;
  517. /// Hero anchor position from which hero moves
  518. int3 start;
  519. /// Hero anchor position to which hero moves
  520. int3 end;
  521. /// Tiles that were revealed by this move
  522. std::unordered_set<int3> fowRevealed;
  523. /// If hero moves on guarded tile, this field will be set to visitable pos of attacked wandering monster
  524. int3 attackedFrom;
  525. void visitTyped(ICPackVisitor & visitor) override;
  526. bool stopMovement() const
  527. {
  528. return result != SUCCESS && result != EMBARK && result != DISEMBARK && result != TELEPORTATION;
  529. }
  530. template <typename Handler> void serialize(Handler & h)
  531. {
  532. h & id;
  533. h & result;
  534. h & start;
  535. h & end;
  536. h & movePoints;
  537. h & fowRevealed;
  538. h & attackedFrom;
  539. }
  540. };
  541. struct DLL_LINKAGE NewStructures : public CPackForClient
  542. {
  543. void applyGs(CGameState * gs) override;
  544. ObjectInstanceID tid;
  545. std::set<BuildingID> bid;
  546. si16 built = 0;
  547. void visitTyped(ICPackVisitor & visitor) override;
  548. template <typename Handler> void serialize(Handler & h)
  549. {
  550. h & tid;
  551. h & bid;
  552. h & built;
  553. }
  554. };
  555. struct DLL_LINKAGE RazeStructures : public CPackForClient
  556. {
  557. void applyGs(CGameState * gs) override;
  558. ObjectInstanceID tid;
  559. std::set<BuildingID> bid;
  560. si16 destroyed = 0;
  561. void visitTyped(ICPackVisitor & visitor) override;
  562. template <typename Handler> void serialize(Handler & h)
  563. {
  564. h & tid;
  565. h & bid;
  566. h & destroyed;
  567. }
  568. };
  569. struct DLL_LINKAGE SetAvailableCreatures : public CPackForClient
  570. {
  571. void applyGs(CGameState * gs) override;
  572. ObjectInstanceID tid;
  573. std::vector<std::pair<ui32, std::vector<CreatureID> > > creatures;
  574. void visitTyped(ICPackVisitor & visitor) override;
  575. template <typename Handler> void serialize(Handler & h)
  576. {
  577. h & tid;
  578. h & creatures;
  579. }
  580. };
  581. struct DLL_LINKAGE SetHeroesInTown : public CPackForClient
  582. {
  583. void applyGs(CGameState * gs) override;
  584. ObjectInstanceID tid; //id of town
  585. ObjectInstanceID visiting; //id of visiting hero
  586. ObjectInstanceID garrison; //id of hero in garrison
  587. void visitTyped(ICPackVisitor & visitor) override;
  588. template <typename Handler> void serialize(Handler & h)
  589. {
  590. h & tid;
  591. h & visiting;
  592. h & garrison;
  593. }
  594. };
  595. struct DLL_LINKAGE HeroRecruited : public CPackForClient
  596. {
  597. void applyGs(CGameState * gs) override;
  598. HeroTypeID hid; //subID of hero
  599. ObjectInstanceID tid;
  600. ObjectInstanceID boatId;
  601. int3 tile;
  602. PlayerColor player;
  603. void visitTyped(ICPackVisitor & visitor) override;
  604. template <typename Handler> void serialize(Handler & h)
  605. {
  606. h & hid;
  607. h & tid;
  608. h & boatId;
  609. h & tile;
  610. h & player;
  611. }
  612. };
  613. struct DLL_LINKAGE GiveHero : public CPackForClient
  614. {
  615. void applyGs(CGameState * gs) override;
  616. ObjectInstanceID id; //object id
  617. ObjectInstanceID boatId;
  618. PlayerColor player;
  619. void visitTyped(ICPackVisitor & visitor) override;
  620. template <typename Handler> void serialize(Handler & h)
  621. {
  622. h & id;
  623. h & boatId;
  624. h & player;
  625. }
  626. };
  627. struct DLL_LINKAGE OpenWindow : public Query
  628. {
  629. EOpenWindowMode window;
  630. ObjectInstanceID object;
  631. ObjectInstanceID visitor;
  632. void visitTyped(ICPackVisitor & visitor) override;
  633. void applyGs(CGameState *gs) override {}
  634. template <typename Handler> void serialize(Handler & h)
  635. {
  636. h & queryID;
  637. h & window;
  638. h & object;
  639. h & visitor;
  640. }
  641. };
  642. struct DLL_LINKAGE NewObject : public CPackForClient
  643. {
  644. void applyGs(CGameState * gs) override;
  645. /// Object ID to create
  646. CGObjectInstance * newObject;
  647. /// Which player initiated creation of this object
  648. PlayerColor initiator;
  649. void visitTyped(ICPackVisitor & visitor) override;
  650. template <typename Handler> void serialize(Handler & h)
  651. {
  652. h & newObject;
  653. h & initiator;
  654. }
  655. };
  656. struct DLL_LINKAGE SetAvailableArtifacts : public CPackForClient
  657. {
  658. void applyGs(CGameState * gs) override;
  659. //two variants: id < 0: set artifact pool for Artifact Merchants in towns; id >= 0: set pool for adv. map Black Market (id is the id of Black Market instance then)
  660. ObjectInstanceID id;
  661. std::vector<ArtifactID> arts;
  662. void visitTyped(ICPackVisitor & visitor) override;
  663. template <typename Handler> void serialize(Handler & h)
  664. {
  665. h & id;
  666. h & arts;
  667. }
  668. };
  669. struct DLL_LINKAGE CGarrisonOperationPack : CPackForClient
  670. {
  671. };
  672. struct DLL_LINKAGE ChangeStackCount : CGarrisonOperationPack
  673. {
  674. ObjectInstanceID army;
  675. SlotID slot;
  676. TQuantity count;
  677. bool absoluteValue; //if not -> count will be added (or subtracted if negative)
  678. void applyGs(CGameState * gs) override;
  679. void visitTyped(ICPackVisitor & visitor) override;
  680. template <typename Handler> void serialize(Handler & h)
  681. {
  682. h & army;
  683. h & slot;
  684. h & count;
  685. h & absoluteValue;
  686. }
  687. };
  688. struct DLL_LINKAGE SetStackType : CGarrisonOperationPack
  689. {
  690. ObjectInstanceID army;
  691. SlotID slot;
  692. CreatureID type;
  693. void applyGs(CGameState * gs) override;
  694. void visitTyped(ICPackVisitor & visitor) override;
  695. template <typename Handler> void serialize(Handler & h)
  696. {
  697. h & army;
  698. h & slot;
  699. h & type;
  700. }
  701. };
  702. struct DLL_LINKAGE EraseStack : CGarrisonOperationPack
  703. {
  704. ObjectInstanceID army;
  705. SlotID slot;
  706. void applyGs(CGameState * gs) override;
  707. void visitTyped(ICPackVisitor & visitor) override;
  708. template <typename Handler> void serialize(Handler & h)
  709. {
  710. h & army;
  711. h & slot;
  712. }
  713. };
  714. struct DLL_LINKAGE SwapStacks : CGarrisonOperationPack
  715. {
  716. ObjectInstanceID srcArmy;
  717. ObjectInstanceID dstArmy;
  718. SlotID srcSlot;
  719. SlotID dstSlot;
  720. void applyGs(CGameState * gs) override;
  721. void visitTyped(ICPackVisitor & visitor) override;
  722. template <typename Handler> void serialize(Handler & h)
  723. {
  724. h & srcArmy;
  725. h & dstArmy;
  726. h & srcSlot;
  727. h & dstSlot;
  728. }
  729. };
  730. struct DLL_LINKAGE InsertNewStack : CGarrisonOperationPack
  731. {
  732. ObjectInstanceID army;
  733. SlotID slot;
  734. CreatureID type;
  735. TQuantity count = 0;
  736. void applyGs(CGameState * gs) override;
  737. void visitTyped(ICPackVisitor & visitor) override;
  738. template <typename Handler> void serialize(Handler & h)
  739. {
  740. h & army;
  741. h & slot;
  742. h & type;
  743. h & count;
  744. }
  745. };
  746. ///moves creatures from src stack to dst slot, may be used for merging/splittint/moving stacks
  747. struct DLL_LINKAGE RebalanceStacks : CGarrisonOperationPack
  748. {
  749. ObjectInstanceID srcArmy;
  750. ObjectInstanceID dstArmy;
  751. SlotID srcSlot;
  752. SlotID dstSlot;
  753. TQuantity count;
  754. void applyGs(CGameState * gs) override;
  755. void visitTyped(ICPackVisitor & visitor) override;
  756. template <typename Handler> void serialize(Handler & h)
  757. {
  758. h & srcArmy;
  759. h & dstArmy;
  760. h & srcSlot;
  761. h & dstSlot;
  762. h & count;
  763. }
  764. };
  765. struct DLL_LINKAGE BulkRebalanceStacks : CGarrisonOperationPack
  766. {
  767. std::vector<RebalanceStacks> moves;
  768. void applyGs(CGameState * gs) override;
  769. void visitTyped(ICPackVisitor & visitor) override;
  770. template <typename Handler>
  771. void serialize(Handler & h)
  772. {
  773. h & moves;
  774. }
  775. };
  776. struct DLL_LINKAGE BulkSmartRebalanceStacks : CGarrisonOperationPack
  777. {
  778. std::vector<RebalanceStacks> moves;
  779. std::vector<ChangeStackCount> changes;
  780. void applyGs(CGameState * gs) override;
  781. void visitTyped(ICPackVisitor & visitor) override;
  782. template <typename Handler>
  783. void serialize(Handler & h)
  784. {
  785. h & moves;
  786. h & changes;
  787. }
  788. };
  789. struct DLL_LINKAGE CArtifactOperationPack : CPackForClient
  790. {
  791. };
  792. struct DLL_LINKAGE PutArtifact : CArtifactOperationPack
  793. {
  794. PutArtifact() = default;
  795. explicit PutArtifact(const ArtifactInstanceID & id, const ArtifactLocation & dst, bool askAssemble = true)
  796. : al(dst), askAssemble(askAssemble), id(id)
  797. {
  798. }
  799. ArtifactLocation al;
  800. bool askAssemble;
  801. ArtifactInstanceID id;
  802. void applyGs(CGameState * gs) override;
  803. void visitTyped(ICPackVisitor & visitor) override;
  804. template <typename Handler> void serialize(Handler & h)
  805. {
  806. h & al;
  807. h & askAssemble;
  808. h & id;
  809. }
  810. };
  811. struct DLL_LINKAGE NewArtifact : public CArtifactOperationPack
  812. {
  813. ObjectInstanceID artHolder;
  814. ArtifactID artId;
  815. SpellID spellId;
  816. ArtifactPosition pos;
  817. void applyGs(CGameState * gs) override;
  818. void visitTyped(ICPackVisitor & visitor) override;
  819. template <typename Handler> void serialize(Handler & h)
  820. {
  821. h & artHolder;
  822. h & artId;
  823. h & spellId;
  824. h & pos;
  825. }
  826. };
  827. struct DLL_LINKAGE BulkEraseArtifacts : CArtifactOperationPack
  828. {
  829. ObjectInstanceID artHolder;
  830. std::vector<ArtifactPosition> posPack;
  831. std::optional<SlotID> creature;
  832. void applyGs(CGameState * gs) override;
  833. void visitTyped(ICPackVisitor & visitor) override;
  834. template <typename Handler> void serialize(Handler & h)
  835. {
  836. h & artHolder;
  837. h & posPack;
  838. h & creature;
  839. }
  840. };
  841. struct DLL_LINKAGE BulkMoveArtifacts : CArtifactOperationPack
  842. {
  843. struct LinkedSlots
  844. {
  845. ArtifactPosition srcPos;
  846. ArtifactPosition dstPos;
  847. bool askAssemble;
  848. LinkedSlots() = default;
  849. LinkedSlots(const ArtifactPosition & srcPos, const ArtifactPosition & dstPos, bool askAssemble = false)
  850. : srcPos(srcPos)
  851. , dstPos(dstPos)
  852. , askAssemble(askAssemble)
  853. {
  854. }
  855. template <typename Handler> void serialize(Handler & h)
  856. {
  857. h & srcPos;
  858. h & dstPos;
  859. h & askAssemble;
  860. }
  861. };
  862. PlayerColor interfaceOwner;
  863. ObjectInstanceID srcArtHolder;
  864. ObjectInstanceID dstArtHolder;
  865. std::optional<SlotID> srcCreature;
  866. std::optional<SlotID> dstCreature;
  867. BulkMoveArtifacts()
  868. : interfaceOwner(PlayerColor::NEUTRAL)
  869. , srcArtHolder(ObjectInstanceID::NONE)
  870. , dstArtHolder(ObjectInstanceID::NONE)
  871. , srcCreature(std::nullopt)
  872. , dstCreature(std::nullopt)
  873. {
  874. }
  875. BulkMoveArtifacts(const PlayerColor & interfaceOwner, const ObjectInstanceID srcArtHolder, const ObjectInstanceID dstArtHolder, bool swap)
  876. : interfaceOwner(interfaceOwner)
  877. , srcArtHolder(srcArtHolder)
  878. , dstArtHolder(dstArtHolder)
  879. , srcCreature(std::nullopt)
  880. , dstCreature(std::nullopt)
  881. {
  882. }
  883. void applyGs(CGameState * gs) override;
  884. std::vector<LinkedSlots> artsPack0;
  885. std::vector<LinkedSlots> artsPack1;
  886. void visitTyped(ICPackVisitor & visitor) override;
  887. template <typename Handler> void serialize(Handler & h)
  888. {
  889. h & interfaceOwner;
  890. h & artsPack0;
  891. h & artsPack1;
  892. h & srcArtHolder;
  893. h & dstArtHolder;
  894. h & srcCreature;
  895. h & dstCreature;
  896. }
  897. };
  898. struct DLL_LINKAGE AssembledArtifact : CArtifactOperationPack
  899. {
  900. ArtifactLocation al;
  901. ArtifactID artId;
  902. void applyGs(CGameState * gs) override;
  903. void visitTyped(ICPackVisitor & visitor) override;
  904. template <typename Handler> void serialize(Handler & h)
  905. {
  906. h & al;
  907. h & artId;
  908. }
  909. };
  910. struct DLL_LINKAGE DisassembledArtifact : CArtifactOperationPack
  911. {
  912. ArtifactLocation al;
  913. void applyGs(CGameState * gs) override;
  914. void visitTyped(ICPackVisitor & visitor) override;
  915. template <typename Handler> void serialize(Handler & h)
  916. {
  917. h & al;
  918. }
  919. };
  920. struct DLL_LINKAGE HeroVisit : public CPackForClient
  921. {
  922. PlayerColor player;
  923. ObjectInstanceID heroId;
  924. ObjectInstanceID objId;
  925. bool starting; //false -> ending
  926. void applyGs(CGameState * gs) override;
  927. void visitTyped(ICPackVisitor & visitor) override;
  928. template <typename Handler> void serialize(Handler & h)
  929. {
  930. h & player;
  931. h & heroId;
  932. h & objId;
  933. h & starting;
  934. }
  935. };
  936. struct DLL_LINKAGE InfoWindow : public CPackForClient //103 - displays simple info window
  937. {
  938. EInfoWindowMode type = EInfoWindowMode::MODAL;
  939. MetaString text;
  940. std::vector<Component> components;
  941. PlayerColor player;
  942. ui16 soundID = 0;
  943. void visitTyped(ICPackVisitor & visitor) override;
  944. void applyGs(CGameState * gs) override {}
  945. template <typename Handler> void serialize(Handler & h)
  946. {
  947. h & type;
  948. h & text;
  949. h & components;
  950. h & player;
  951. h & soundID;
  952. }
  953. InfoWindow() = default;
  954. };
  955. struct DLL_LINKAGE NewTurn : public CPackForClient
  956. {
  957. void applyGs(CGameState * gs) override;
  958. void visitTyped(ICPackVisitor & visitor) override;
  959. ui32 day = 0;
  960. CreatureID creatureid; //for creature weeks
  961. EWeekType specialWeek = EWeekType::NORMAL;
  962. std::vector<SetMovePoints> heroesMovement;
  963. std::vector<SetMana> heroesMana;
  964. std::vector<SetAvailableCreatures> availableCreatures;
  965. std::map<PlayerColor, ResourceSet> playerIncome;
  966. std::optional<RumorState> newRumor; // only on new weeks
  967. std::optional<InfoWindow> newWeekNotification; // only on new week
  968. NewTurn() = default;
  969. template <typename Handler> void serialize(Handler & h)
  970. {
  971. h & day;
  972. h & creatureid;
  973. h & specialWeek;
  974. h & heroesMovement;
  975. h & heroesMana;
  976. h & availableCreatures;
  977. h & playerIncome;
  978. h & newRumor;
  979. h & newWeekNotification;
  980. }
  981. };
  982. struct DLL_LINKAGE SetObjectProperty : public CPackForClient
  983. {
  984. void applyGs(CGameState * gs) override;
  985. ObjectInstanceID id;
  986. ObjProperty what{};
  987. ObjPropertyID identifier;
  988. SetObjectProperty() = default;
  989. void visitTyped(ICPackVisitor & visitor) override;
  990. template <typename Handler> void serialize(Handler & h)
  991. {
  992. h & id;
  993. h & what;
  994. h & identifier;
  995. }
  996. };
  997. struct DLL_LINKAGE ChangeObjectVisitors : public CPackForClient
  998. {
  999. enum VisitMode
  1000. {
  1001. VISITOR_ADD_HERO, // mark hero as one that have visited this object
  1002. VISITOR_ADD_PLAYER, // mark player as one that have visited this object instance
  1003. VISITOR_GLOBAL, // mark player as one that have visited object of this type
  1004. VISITOR_SCOUTED, // marks targeted team as having scouted this object
  1005. VISITOR_CLEAR, // clear all visitors from this object (object reset)
  1006. };
  1007. VisitMode mode = VISITOR_CLEAR; // uses VisitMode enum
  1008. ObjectInstanceID object;
  1009. ObjectInstanceID hero; // note: hero owner will be also marked as "visited" this object
  1010. void applyGs(CGameState * gs) override;
  1011. void visitTyped(ICPackVisitor & visitor) override;
  1012. ChangeObjectVisitors() = default;
  1013. ChangeObjectVisitors(VisitMode mode, const ObjectInstanceID & object, const ObjectInstanceID & heroID = ObjectInstanceID(-1))
  1014. : mode(mode)
  1015. , object(object)
  1016. , hero(heroID)
  1017. {
  1018. }
  1019. template <typename Handler> void serialize(Handler & h)
  1020. {
  1021. h & object;
  1022. h & hero;
  1023. h & mode;
  1024. }
  1025. };
  1026. struct DLL_LINKAGE ChangeArtifactsCostume : public CPackForClient
  1027. {
  1028. std::map<ArtifactPosition, ArtifactID> costumeSet;
  1029. uint32_t costumeIdx = 0;
  1030. const PlayerColor player = PlayerColor::NEUTRAL;
  1031. void applyGs(CGameState * gs) override;
  1032. void visitTyped(ICPackVisitor & visitor) override;
  1033. ChangeArtifactsCostume() = default;
  1034. ChangeArtifactsCostume(const PlayerColor & player, const uint32_t costumeIdx)
  1035. : costumeIdx(costumeIdx)
  1036. , player(player)
  1037. {
  1038. }
  1039. template <typename Handler> void serialize(Handler & h)
  1040. {
  1041. h & costumeSet;
  1042. h & costumeIdx;
  1043. h & player;
  1044. }
  1045. };
  1046. struct DLL_LINKAGE HeroLevelUp : public Query
  1047. {
  1048. PlayerColor player;
  1049. ObjectInstanceID heroId;
  1050. PrimarySkill primskill = PrimarySkill::ATTACK;
  1051. std::vector<SecondarySkill> skills;
  1052. void applyGs(CGameState * gs) override;
  1053. void visitTyped(ICPackVisitor & visitor) override;
  1054. template <typename Handler> void serialize(Handler & h)
  1055. {
  1056. h & queryID;
  1057. h & player;
  1058. h & heroId;
  1059. h & primskill;
  1060. h & skills;
  1061. }
  1062. };
  1063. struct DLL_LINKAGE CommanderLevelUp : public Query
  1064. {
  1065. PlayerColor player;
  1066. ObjectInstanceID heroId;
  1067. std::vector<ui32> skills; //0-5 - secondary skills, val-100 - special skill
  1068. void applyGs(CGameState * gs) override;
  1069. void visitTyped(ICPackVisitor & visitor) override;
  1070. template <typename Handler> void serialize(Handler & h)
  1071. {
  1072. h & queryID;
  1073. h & player;
  1074. h & heroId;
  1075. h & skills;
  1076. }
  1077. };
  1078. //A dialog that requires making decision by player - it may contain components to choose between or has yes/no options
  1079. //Client responds with QueryReply, where answer: 0 - cancel pressed, choice doesn't matter; 1/2/... - first/second/... component selected and OK pressed
  1080. //Until sending reply player won't be allowed to take any actions
  1081. struct DLL_LINKAGE BlockingDialog : public Query
  1082. {
  1083. enum { ALLOW_CANCEL = 1, SELECTION = 2, SAFE_TO_AUTOACCEPT = 4 };
  1084. MetaString text;
  1085. std::vector<Component> components;
  1086. PlayerColor player;
  1087. ui8 flags = 0;
  1088. ui16 soundID = 0;
  1089. bool cancel() const
  1090. {
  1091. return flags & ALLOW_CANCEL;
  1092. }
  1093. bool selection() const
  1094. {
  1095. return flags & SELECTION;
  1096. }
  1097. bool safeToAutoaccept() const
  1098. {
  1099. return flags & SAFE_TO_AUTOACCEPT;
  1100. }
  1101. BlockingDialog(bool yesno, bool Selection)
  1102. {
  1103. if(yesno) flags |= ALLOW_CANCEL;
  1104. if(Selection) flags |= SELECTION;
  1105. }
  1106. BlockingDialog() = default;
  1107. void visitTyped(ICPackVisitor & visitor) override;
  1108. void applyGs(CGameState * gs) override {}
  1109. template <typename Handler> void serialize(Handler & h)
  1110. {
  1111. h & queryID;
  1112. h & text;
  1113. h & components;
  1114. h & player;
  1115. h & flags;
  1116. h & soundID;
  1117. }
  1118. };
  1119. struct DLL_LINKAGE GarrisonDialog : public Query
  1120. {
  1121. ObjectInstanceID objid;
  1122. ObjectInstanceID hid;
  1123. bool removableUnits = false;
  1124. void visitTyped(ICPackVisitor & visitor) override;
  1125. void applyGs(CGameState * gs) override {}
  1126. template <typename Handler> void serialize(Handler & h)
  1127. {
  1128. h & queryID;
  1129. h & objid;
  1130. h & hid;
  1131. h & removableUnits;
  1132. }
  1133. };
  1134. struct DLL_LINKAGE ExchangeDialog : public Query
  1135. {
  1136. PlayerColor player;
  1137. ObjectInstanceID hero1;
  1138. ObjectInstanceID hero2;
  1139. void visitTyped(ICPackVisitor & visitor) override;
  1140. void applyGs(CGameState * gs) override {}
  1141. template <typename Handler> void serialize(Handler & h)
  1142. {
  1143. h & queryID;
  1144. h & player;
  1145. h & hero1;
  1146. h & hero2;
  1147. }
  1148. };
  1149. struct DLL_LINKAGE TeleportDialog : public Query
  1150. {
  1151. TeleportDialog() = default;
  1152. TeleportDialog(const ObjectInstanceID & hero, const TeleportChannelID & Channel)
  1153. : hero(hero)
  1154. , channel(Channel)
  1155. {
  1156. }
  1157. ObjectInstanceID hero;
  1158. TeleportChannelID channel;
  1159. TTeleportExitsList exits;
  1160. bool impassable = false;
  1161. void visitTyped(ICPackVisitor & visitor) override;
  1162. void applyGs(CGameState * gs) override {}
  1163. template <typename Handler> void serialize(Handler & h)
  1164. {
  1165. h & queryID;
  1166. h & hero;
  1167. h & channel;
  1168. h & exits;
  1169. h & impassable;
  1170. }
  1171. };
  1172. struct DLL_LINKAGE MapObjectSelectDialog : public Query
  1173. {
  1174. PlayerColor player;
  1175. Component icon;
  1176. MetaString title;
  1177. MetaString description;
  1178. std::vector<ObjectInstanceID> objects;
  1179. void visitTyped(ICPackVisitor & visitor) override;
  1180. void applyGs(CGameState * gs) override {}
  1181. template <typename Handler> void serialize(Handler & h)
  1182. {
  1183. h & queryID;
  1184. h & player;
  1185. h & icon;
  1186. h & title;
  1187. h & description;
  1188. h & objects;
  1189. }
  1190. };
  1191. struct DLL_LINKAGE AdvmapSpellCast : public CPackForClient
  1192. {
  1193. ObjectInstanceID casterID;
  1194. SpellID spellID;
  1195. template <typename Handler> void serialize(Handler & h)
  1196. {
  1197. h & casterID;
  1198. h & spellID;
  1199. }
  1200. protected:
  1201. void visitTyped(ICPackVisitor & visitor) override;
  1202. void applyGs(CGameState * gs) override {}
  1203. };
  1204. struct DLL_LINKAGE ShowWorldViewEx : public CPackForClient
  1205. {
  1206. PlayerColor player;
  1207. bool showTerrain; // TODO: send terrain state
  1208. std::vector<ObjectPosInfo> objectPositions;
  1209. void applyGs(CGameState * gs) override {}
  1210. template <typename Handler> void serialize(Handler & h)
  1211. {
  1212. h & player;
  1213. h & showTerrain;
  1214. h & objectPositions;
  1215. }
  1216. protected:
  1217. void visitTyped(ICPackVisitor & visitor) override;
  1218. };
  1219. struct DLL_LINKAGE PlayerMessageClient : public CPackForClient
  1220. {
  1221. PlayerMessageClient() = default;
  1222. PlayerMessageClient(const PlayerColor & Player, std::string Text)
  1223. : player(Player)
  1224. , text(std::move(Text))
  1225. {
  1226. }
  1227. void visitTyped(ICPackVisitor & visitor) override;
  1228. void applyGs(CGameState * gs) override {}
  1229. PlayerColor player;
  1230. std::string text;
  1231. template <typename Handler> void serialize(Handler & h)
  1232. {
  1233. h & player;
  1234. h & text;
  1235. }
  1236. };
  1237. struct DLL_LINKAGE CenterView : public CPackForClient
  1238. {
  1239. PlayerColor player;
  1240. int3 pos;
  1241. ui32 focusTime = 0; //ms
  1242. void visitTyped(ICPackVisitor & visitor) override;
  1243. void applyGs(CGameState * gs) override {}
  1244. template <typename Handler> void serialize(Handler & h)
  1245. {
  1246. h & pos;
  1247. h & player;
  1248. h & focusTime;
  1249. }
  1250. };
  1251. VCMI_LIB_NAMESPACE_END