NetPacks.h 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444
  1. #ifndef __NETPACKS_H__
  2. #define __NETPACKS_H__
  3. #include "../global.h"
  4. #include "CGameState.h"
  5. #include "BattleAction.h"
  6. #include "HeroBonus.h"
  7. #include <set>
  8. /*
  9. * NetPacks.h, part of VCMI engine
  10. *
  11. * Authors: listed in file AUTHORS in main folder
  12. *
  13. * License: GNU General Public License v2.0 or later
  14. * Full text of license available in license.txt file, in main folder
  15. *
  16. */
  17. class CClient;
  18. class CGameState;
  19. class CGameHandler;
  20. class CConnection;
  21. struct CPack
  22. {
  23. ui16 type;
  24. CPack(){};
  25. virtual ~CPack(){};
  26. ui16 getType() const{return type;}
  27. template <typename Handler> void serialize(Handler &h, const int version)
  28. {
  29. tlog1 << "CPack serialized... this should not happen!\n";
  30. }
  31. DLL_EXPORT void applyGs(CGameState *gs)
  32. {};
  33. };
  34. struct CPackForClient : public CPack
  35. {
  36. CPackForClient(){type = 1;};
  37. CGameState* GS(CClient *cl);
  38. void applyFirstCl(CClient *cl)//called before applying to gs
  39. {};
  40. void applyCl(CClient *cl)//called after applying to gs
  41. {};
  42. };
  43. struct CPackForServer : public CPack
  44. {
  45. CConnection *c;
  46. CGameState* GS(CGameHandler *gh);
  47. CPackForServer()
  48. {
  49. type = 2;
  50. c = NULL;
  51. };
  52. bool applyGh(CGameHandler *gh);//called after applying to gs
  53. };
  54. struct Query : public CPackForClient
  55. {
  56. ui32 id;
  57. };
  58. struct MetaString : public CPack //2001 helper for object scrips
  59. {
  60. private:
  61. enum EMessage {TEXACT_STRING, TLOCAL_STRING, TNUMBER, TREPLACE_ESTRING, TREPLACE_LSTRING, TREPLACE_NUMBER};
  62. public:
  63. enum {GENERAL_TXT=1, XTRAINFO_TXT, OBJ_NAMES, RES_NAMES, ART_NAMES, ARRAY_TXT, CRE_PL_NAMES, CREGENS, MINE_NAMES,
  64. MINE_EVNTS, ADVOB_TXT, ART_EVNTS, SPELL_NAME, SEC_SKILL_NAME, CRE_SING_NAMES, CREGENS4, COLOR};
  65. std::vector<ui8> message; //vector of EMessage
  66. std::vector<std::pair<ui8,ui32> > localStrings; //pairs<text handler type, text number>; types: 1 - generaltexthandler->all; 2 - objh->xtrainfo; 3 - objh->names; 4 - objh->restypes; 5 - arth->artifacts[id].name; 6 - generaltexth->arraytxt; 7 - creh->creatures[os->subID].namePl; 8 - objh->creGens; 9 - objh->mines[ID].first; 10 - objh->mines[ID].second; 11 - objh->advobtxt
  67. std::vector<std::string> exactStrings;
  68. std::vector<si32> numbers;
  69. template <typename Handler> void serialize(Handler &h, const int version)
  70. {
  71. h & exactStrings & localStrings & message & numbers;
  72. }
  73. void addTxt(ui8 type, ui32 serial)
  74. {
  75. message.push_back(TLOCAL_STRING);
  76. localStrings.push_back(std::pair<ui8,ui32>(type, serial));
  77. }
  78. MetaString& operator<<(const std::pair<ui8,ui32> &txt)
  79. {
  80. message.push_back(TLOCAL_STRING);
  81. localStrings.push_back(txt);
  82. return *this;
  83. }
  84. MetaString& operator<<(const std::string &txt)
  85. {
  86. message.push_back(TEXACT_STRING);
  87. exactStrings.push_back(txt);
  88. return *this;
  89. }
  90. MetaString& operator<<(int txt)
  91. {
  92. message.push_back(TNUMBER);
  93. numbers.push_back(txt);
  94. return *this;
  95. }
  96. void addReplacement(ui8 type, ui32 serial)
  97. {
  98. message.push_back(TREPLACE_LSTRING);
  99. localStrings.push_back(std::pair<ui8,ui32>(type, serial));
  100. }
  101. void addReplacement(const std::string &txt)
  102. {
  103. message.push_back(TREPLACE_ESTRING);
  104. exactStrings.push_back(txt);
  105. }
  106. void addReplacement(int txt)
  107. {
  108. message.push_back(TREPLACE_NUMBER);
  109. numbers.push_back(txt);
  110. }
  111. DLL_EXPORT std::string buildList () const;
  112. void clear()
  113. {
  114. exactStrings.clear();
  115. localStrings.clear();
  116. message.clear();
  117. numbers.clear();
  118. }
  119. DLL_EXPORT void toString(std::string &dst) const;
  120. void getLocalString(const std::pair<ui8,ui32> &txt, std::string &dst) const;
  121. MetaString()
  122. {
  123. type = 2001;
  124. }
  125. };
  126. /***********************************************************************************************************/
  127. struct PackageApplied : public CPackForClient //94
  128. {
  129. PackageApplied() {type = 94;}
  130. PackageApplied(ui8 Result) : result(Result) {type = 94;}
  131. void applyCl(CClient *cl);
  132. ui8 result; //0 - something went wrong, request hasn't been realized; 1 - OK
  133. ui32 packType; //type id of applied package
  134. template <typename Handler> void serialize(Handler &h, const int version)
  135. {
  136. h & result & packType;
  137. }
  138. };
  139. struct SystemMessage : public CPackForClient //95
  140. {
  141. SystemMessage(const std::string Text) : text(Text){type = 95;};
  142. SystemMessage(){type = 95;};
  143. void applyCl(CClient *cl);
  144. std::string text;
  145. template <typename Handler> void serialize(Handler &h, const int version)
  146. {
  147. h & text;
  148. }
  149. };
  150. struct PlayerBlocked : public CPackForClient //96
  151. {
  152. PlayerBlocked(){type = 96;};
  153. void applyCl(CClient *cl);
  154. enum EReason { UPCOMING_BATTLE };
  155. ui8 reason;
  156. ui8 player;
  157. template <typename Handler> void serialize(Handler &h, const int version)
  158. {
  159. h & reason & player;
  160. }
  161. };
  162. struct YourTurn : public CPackForClient //100
  163. {
  164. YourTurn(){type = 100;};
  165. void applyCl(CClient *cl);
  166. DLL_EXPORT void applyGs(CGameState *gs);
  167. ui8 player;
  168. template <typename Handler> void serialize(Handler &h, const int version)
  169. {
  170. h & player;
  171. }
  172. };
  173. struct SetResource : public CPackForClient //102
  174. {
  175. SetResource(){type = 102;};
  176. void applyCl(CClient *cl);
  177. DLL_EXPORT void applyGs(CGameState *gs);
  178. ui8 player, resid;
  179. si32 val;
  180. template <typename Handler> void serialize(Handler &h, const int version)
  181. {
  182. h & player & resid & val;
  183. }
  184. };
  185. struct SetResources : public CPackForClient //104
  186. {
  187. SetResources(){res.resize(RESOURCE_QUANTITY);type = 104;};
  188. void applyCl(CClient *cl);
  189. DLL_EXPORT void applyGs(CGameState *gs);
  190. ui8 player;
  191. std::vector<si32> res; //res[resid] => res amount
  192. template <typename Handler> void serialize(Handler &h, const int version)
  193. {
  194. h & player & res;
  195. }
  196. };
  197. struct SetPrimSkill : public CPackForClient //105
  198. {
  199. SetPrimSkill(){type = 105;};
  200. void applyCl(CClient *cl);
  201. DLL_EXPORT void applyGs(CGameState *gs);
  202. ui8 abs; //0 - changes by value; 1 - sets to value
  203. si32 id;
  204. ui16 which;
  205. si64 val;
  206. template <typename Handler> void serialize(Handler &h, const int version)
  207. {
  208. h & abs & id & which & val;
  209. }
  210. };
  211. struct SetSecSkill : public CPackForClient //106
  212. {
  213. SetSecSkill(){type = 106;};
  214. void applyCl(CClient *cl);
  215. DLL_EXPORT void applyGs(CGameState *gs);
  216. ui8 abs; //0 - changes by value; 1 - sets to value
  217. si32 id;
  218. ui16 which, val;
  219. template <typename Handler> void serialize(Handler &h, const int version)
  220. {
  221. h & abs & id & which & val;
  222. }
  223. };
  224. struct HeroVisitCastle : public CPackForClient //108
  225. {
  226. HeroVisitCastle(){flags=0;type = 108;};
  227. void applyCl(CClient *cl);
  228. DLL_EXPORT void applyGs(CGameState *gs);
  229. ui8 flags; //1 - start, 2 - garrison
  230. ui32 tid, hid;
  231. bool start() //if hero is entering castle (if false - leaving)
  232. {
  233. return flags & 1;
  234. }
  235. bool garrison() //if hero is entering/leaving garrison (if false - it's only visiting hero)
  236. {
  237. return flags & 2;
  238. }
  239. template <typename Handler> void serialize(Handler &h, const int version)
  240. {
  241. h & flags & tid & hid;
  242. }
  243. };
  244. struct ChangeSpells : public CPackForClient //109
  245. {
  246. ChangeSpells(){type = 109;};
  247. void applyCl(CClient *cl);
  248. DLL_EXPORT void applyGs(CGameState *gs);
  249. ui8 learn; //1 - gives spell, 0 - takes
  250. ui32 hid;
  251. std::set<ui32> spells;
  252. template <typename Handler> void serialize(Handler &h, const int version)
  253. {
  254. h & learn & hid & spells;
  255. }
  256. };
  257. struct SetMana : public CPackForClient //110
  258. {
  259. SetMana(){type = 110;};
  260. void applyCl(CClient *cl);
  261. DLL_EXPORT void applyGs(CGameState *gs);
  262. si32 hid, val;
  263. template <typename Handler> void serialize(Handler &h, const int version)
  264. {
  265. h & val & hid;
  266. }
  267. };
  268. struct SetMovePoints : public CPackForClient //111
  269. {
  270. SetMovePoints(){type = 111;};
  271. void applyCl(CClient *cl);
  272. DLL_EXPORT void applyGs(CGameState *gs);
  273. ui32 hid, val;
  274. template <typename Handler> void serialize(Handler &h, const int version)
  275. {
  276. h & val & hid;
  277. }
  278. };
  279. struct FoWChange : public CPackForClient //112
  280. {
  281. FoWChange(){type = 112;};
  282. void applyCl(CClient *cl);
  283. DLL_EXPORT void applyGs(CGameState *gs);
  284. std::set<int3> tiles;
  285. ui8 player, mode; //mode==0 - hide, mode==1 - reveal
  286. template <typename Handler> void serialize(Handler &h, const int version)
  287. {
  288. h & tiles & player & mode;
  289. }
  290. };
  291. struct SetAvailableHeroes : public CPackForClient //113
  292. {
  293. SetAvailableHeroes(){type = 113;flags=0;};
  294. void applyCl(CClient *cl);
  295. DLL_EXPORT void applyGs(CGameState *gs);
  296. ui8 player;
  297. si32 hid1, hid2;
  298. ui8 flags; //1 - reset army of hero1; 2 - reset army of hero 2
  299. template <typename Handler> void serialize(Handler &h, const int version)
  300. {
  301. h & player & hid1 & hid2 & flags;
  302. }
  303. };
  304. struct GiveBonus : public CPackForClient //115
  305. {
  306. GiveBonus(){type = 115;};
  307. void applyCl(CClient *cl);
  308. DLL_EXPORT void applyGs(CGameState *gs);
  309. ui32 hid;
  310. HeroBonus bonus;
  311. MetaString bdescr;
  312. template <typename Handler> void serialize(Handler &h, const int version)
  313. {
  314. h & bonus & hid & bdescr;
  315. }
  316. };
  317. struct ChangeObjPos : public CPackForClient //116
  318. {
  319. ChangeObjPos(){type = 116;};
  320. void applyFirstCl(CClient *cl);
  321. void applyCl(CClient *cl);
  322. DLL_EXPORT void applyGs(CGameState *gs);
  323. ui32 objid;
  324. int3 nPos;
  325. ui8 flags; //bit flags: 1 - redraw
  326. template <typename Handler> void serialize(Handler &h, const int version)
  327. {
  328. h & objid & nPos & flags;
  329. }
  330. };
  331. struct PlayerEndsGame : public CPackForClient //117
  332. {
  333. PlayerEndsGame()
  334. {
  335. type = 117;
  336. }
  337. void applyCl(CClient *cl);
  338. DLL_EXPORT void applyGs(CGameState *gs);
  339. ui8 player;
  340. ui8 victory;
  341. template <typename Handler> void serialize(Handler &h, const int version)
  342. {
  343. h & player & victory;
  344. }
  345. };
  346. struct RemoveObject : public CPackForClient //500
  347. {
  348. RemoveObject(){type = 500;};
  349. RemoveObject(si32 ID){id = ID;type = 500;};
  350. void applyFirstCl(CClient *cl);
  351. void applyCl(CClient *cl);
  352. DLL_EXPORT void applyGs(CGameState *gs);
  353. si32 id;
  354. template <typename Handler> void serialize(Handler &h, const int version)
  355. {
  356. h & id;
  357. }
  358. };
  359. struct TryMoveHero : public CPackForClient //501
  360. {
  361. TryMoveHero(){type = 501;humanKnows=false;};
  362. void applyFirstCl(CClient *cl);
  363. void applyCl(CClient *cl);
  364. void applyGs(CGameState *gs);
  365. enum EResult
  366. {
  367. FAILED, SUCCESS, TELEPORTATION, RESERVED___, BLOCKING_VISIT, EMBARK, DISEMBARK
  368. };
  369. ui32 id, movePoints;
  370. ui8 result; //uses EResult
  371. int3 start, end;
  372. std::set<int3> fowRevealed; //revealed tiles
  373. bool humanKnows; //used locally during applying to client
  374. template <typename Handler> void serialize(Handler &h, const int version)
  375. {
  376. h & id & result & start & end & movePoints & fowRevealed;
  377. }
  378. };
  379. struct SetGarrisons : public CPackForClient //502
  380. {
  381. SetGarrisons(){type = 502;};
  382. void applyCl(CClient *cl);
  383. DLL_EXPORT void applyGs(CGameState *gs);
  384. std::map<ui32,CCreatureSet> garrs;
  385. template <typename Handler> void serialize(Handler &h, const int version)
  386. {
  387. h & garrs;
  388. }
  389. };
  390. struct NewStructures : public CPackForClient //504
  391. {
  392. NewStructures(){type = 504;};
  393. void applyCl(CClient *cl);
  394. DLL_EXPORT virtual void applyGs(CGameState *gs);
  395. si32 tid;
  396. std::set<si32> bid;
  397. si16 builded;
  398. template <typename Handler> void serialize(Handler &h, const int version)
  399. {
  400. h & tid & bid & builded;
  401. }
  402. };
  403. struct RazeStructures : public CPackForClient //505
  404. {
  405. RazeStructures() {type = 505;};
  406. void applyCl (CClient *cl);
  407. DLL_EXPORT void applyGs(CGameState *gs);
  408. si32 tid;
  409. std::set<si32> bid;
  410. si16 destroyed;
  411. template <typename Handler> void serialize(Handler &h, const int version)
  412. {
  413. h & tid & bid & destroyed;
  414. }
  415. };
  416. struct SetAvailableCreatures : public CPackForClient //506
  417. {
  418. SetAvailableCreatures(){type = 506;};
  419. void applyCl(CClient *cl);
  420. DLL_EXPORT void applyGs(CGameState *gs);
  421. si32 tid;
  422. std::vector<std::pair<ui32, std::vector<ui32> > > creatures;
  423. template <typename Handler> void serialize(Handler &h, const int version)
  424. {
  425. h & tid & creatures;
  426. }
  427. };
  428. struct SetHeroesInTown : public CPackForClient //508
  429. {
  430. SetHeroesInTown(){type = 508;};
  431. void applyCl(CClient *cl);
  432. DLL_EXPORT void applyGs(CGameState *gs);
  433. si32 tid, visiting, garrison; //id of town, visiting hero, hero in garrison
  434. template <typename Handler> void serialize(Handler &h, const int version)
  435. {
  436. h & tid & visiting & garrison;
  437. }
  438. };
  439. struct SetHeroArtifacts : public CPackForClient //509
  440. {
  441. SetHeroArtifacts(){type = 509;};
  442. void applyCl(CClient *cl);
  443. DLL_EXPORT void applyGs(CGameState *gs);
  444. DLL_EXPORT void setArtAtPos(ui16 pos, int art);
  445. si32 hid;
  446. std::vector<ui32> artifacts; //hero's artifacts from bag
  447. std::map<ui16,ui32> artifWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
  448. template <typename Handler> void serialize(Handler &h, const int version)
  449. {
  450. h & hid & artifacts & artifWorn;
  451. }
  452. std::vector<HeroBonus*> gained, lost; //used locally as hlp when applying
  453. };
  454. struct HeroRecruited : public CPackForClient //515
  455. {
  456. HeroRecruited(){type = 515;};
  457. void applyCl(CClient *cl);
  458. DLL_EXPORT void applyGs(CGameState *gs);
  459. si32 hid, tid; //subID of hero
  460. int3 tile;
  461. ui8 player;
  462. template <typename Handler> void serialize(Handler &h, const int version)
  463. {
  464. h & hid & tid & tile & player;
  465. }
  466. };
  467. struct GiveHero : public CPackForClient //516
  468. {
  469. GiveHero(){type = 516;};
  470. void applyFirstCl(CClient *cl);
  471. void applyCl(CClient *cl);
  472. DLL_EXPORT void applyGs(CGameState *gs);
  473. ui32 id; //object id
  474. ui8 player;
  475. template <typename Handler> void serialize(Handler &h, const int version)
  476. {
  477. h & id & player;
  478. }
  479. };
  480. struct OpenWindow : public CPackForClient //517
  481. {
  482. OpenWindow(){type = 517;};
  483. void applyCl(CClient *cl);
  484. enum EWindow {EXCHANGE_WINDOW, RECRUITMENT_FIRST, RECRUITMENT_ALL, SHIPYARD_WINDOW};
  485. ui8 window;
  486. ui32 id1, id2;
  487. template <typename Handler> void serialize(Handler &h, const int version)
  488. {
  489. h & window & id1 & id2;
  490. }
  491. };
  492. struct NewObject : public CPackForClient //518
  493. {
  494. NewObject(){type = 518;};
  495. void applyCl(CClient *cl);
  496. DLL_EXPORT void applyGs(CGameState *gs);
  497. ui32 ID, subID;
  498. int3 pos;
  499. int id; //used internally
  500. template <typename Handler> void serialize(Handler &h, const int version)
  501. {
  502. h & ID & subID & pos;
  503. }
  504. };
  505. struct NewTurn : public CPackForClient //101
  506. {
  507. DLL_EXPORT void applyGs(CGameState *gs);
  508. struct Hero
  509. {
  510. ui32 id, move, mana; //id is a general serial id
  511. template <typename Handler> void serialize(Handler &h, const int version)
  512. {
  513. h & id & move & mana;
  514. }
  515. bool operator<(const Hero&h)const{return id < h.id;}
  516. };
  517. std::set<Hero> heroes; //updates movement and mana points
  518. //std::vector<SetResources> res;//resource list
  519. std::map<ui8, std::vector<si32> > res; //player ID => resource value[res_id]
  520. std::vector<SetAvailableCreatures> cres;//creatures to be placed in towns
  521. ui32 day;
  522. bool resetBuilded;
  523. NewTurn(){type = 101;};
  524. template <typename Handler> void serialize(Handler &h, const int version)
  525. {
  526. h & heroes & cres & res & day & resetBuilded;
  527. }
  528. };
  529. struct Component : public CPack //2002 helper for object scrips informations
  530. {
  531. enum {PRIM_SKILL, SEC_SKILL, RESOURCE, CREATURE, ARTIFACT, EXPERIENCE, SPELL, MORALE=8, LUCK, BUILDING, HERO, FLAG};
  532. ui16 id, subtype; //id uses ^^^ enums, when id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels)
  533. si32 val; // + give; - take
  534. si16 when; // 0 - now; +x - within x days; -x - per x days
  535. template <typename Handler> void serialize(Handler &h, const int version)
  536. {
  537. h & id & subtype & val & when;
  538. }
  539. Component(){type = 2002;};
  540. Component(ui16 Type, ui16 Subtype, si32 Val, si16 When):id(Type),subtype(Subtype),val(Val),when(When){type = 2002;};
  541. };
  542. struct InfoWindow : public CPackForClient //103 - displays simple info window
  543. {
  544. void applyCl(CClient *cl);
  545. MetaString text;
  546. std::vector<Component> components;
  547. ui8 player;
  548. ui16 soundID;
  549. template <typename Handler> void serialize(Handler &h, const int version)
  550. {
  551. h & text & components & player & soundID;
  552. }
  553. InfoWindow() {
  554. type = 103;
  555. soundID = 0;
  556. };
  557. };
  558. struct SetObjectProperty : public CPackForClient//1001
  559. {
  560. DLL_EXPORT void applyGs(CGameState *gs);
  561. void applyCl(CClient *cl);
  562. ui32 id;
  563. ui8 what; //1 - owner; 2 - blockvis; 3 - first stack count; 4 - visitors; 5 - visited; 6 - ID (if 34 then also def is replaced)
  564. ui32 val;
  565. SetObjectProperty(){type = 1001;};
  566. SetObjectProperty(ui32 ID, ui8 What, ui32 Val):id(ID),what(What),val(Val){type = 1001;};
  567. template <typename Handler> void serialize(Handler &h, const int version)
  568. {
  569. h & id & what & val;
  570. }
  571. };
  572. struct SetHoverName : public CPackForClient//1002
  573. {
  574. DLL_EXPORT void applyGs(CGameState *gs);
  575. ui32 id;
  576. MetaString name;
  577. SetHoverName(){type = 1002;};
  578. SetHoverName(ui32 ID, MetaString& Name):id(ID),name(Name){type = 1002;};
  579. template <typename Handler> void serialize(Handler &h, const int version)
  580. {
  581. h & id & name;
  582. }
  583. };
  584. struct HeroLevelUp : public Query//2000
  585. {
  586. void applyCl(CClient *cl);
  587. DLL_EXPORT void applyGs(CGameState *gs);
  588. si32 heroid;
  589. ui8 primskill, level;
  590. std::vector<ui16> skills;
  591. HeroLevelUp(){type = 2000;};
  592. template <typename Handler> void serialize(Handler &h, const int version)
  593. {
  594. h & id & heroid & primskill & level & skills;
  595. }
  596. };
  597. struct TradeComponents : public CPackForClient, public CPackForServer
  598. {
  599. ///used to handle info about components available in shops
  600. void applyCl(CClient *cl);
  601. DLL_EXPORT void applyGs(CGameState *gs);
  602. si32 heroid;
  603. ui32 objectid;
  604. std::map<ui16, Component> available, chosen, bought;
  605. template <typename Handler> void serialize(Handler &h, const int version)
  606. {
  607. h & heroid & objectid & available & chosen & bought;
  608. }
  609. };
  610. //A dialog that requires making decision by player - it may contain components to choose between or has yes/no options
  611. //Client responds with QueryReply, where answer: 0 - cancel pressed, choice doesn't matter; 1/2/... - first/second/... component selected and OK pressed
  612. //Until sending reply player won't be allowed to take any actions
  613. struct BlockingDialog : public Query//2003
  614. {
  615. enum {ALLOW_CANCEL = 1, SELECTION = 2};
  616. void applyCl(CClient *cl);
  617. MetaString text;
  618. std::vector<Component> components;
  619. ui8 player;
  620. ui8 flags;
  621. ui16 soundID;
  622. bool cancel() const
  623. {
  624. return flags & ALLOW_CANCEL;
  625. }
  626. bool selection() const
  627. {
  628. return flags & SELECTION;
  629. }
  630. BlockingDialog(bool yesno, bool Selection)
  631. {
  632. type = 2003;
  633. flags = 0;
  634. soundID = 0;
  635. if(yesno) flags |= ALLOW_CANCEL;
  636. if(Selection) flags |= SELECTION;
  637. }
  638. BlockingDialog()
  639. {
  640. type = 2003;
  641. flags = 0;
  642. soundID = 0;
  643. };
  644. template <typename Handler> void serialize(Handler &h, const int version)
  645. {
  646. h & id & text & components & player & flags & soundID;
  647. }
  648. };
  649. struct GarrisonDialog : public Query//2004
  650. {
  651. GarrisonDialog(){type = 2004;}
  652. void applyCl(CClient *cl);
  653. si32 objid, hid;
  654. bool removableUnits;
  655. template <typename Handler> void serialize(Handler &h, const int version)
  656. {
  657. h & id & objid & hid & removableUnits;
  658. }
  659. };
  660. struct BattleInfo;
  661. struct BattleStart : public CPackForClient//3000
  662. {
  663. BattleStart(){type = 3000;};
  664. void applyCl(CClient *cl);
  665. DLL_EXPORT void applyGs(CGameState *gs);
  666. BattleInfo * info;
  667. template <typename Handler> void serialize(Handler &h, const int version)
  668. {
  669. h & info;
  670. }
  671. };
  672. struct BattleNextRound : public CPackForClient//3001
  673. {
  674. BattleNextRound(){type = 3001;};
  675. void applyCl(CClient *cl);
  676. DLL_EXPORT void applyGs(CGameState *gs);
  677. si32 round;
  678. template <typename Handler> void serialize(Handler &h, const int version)
  679. {
  680. h & round;
  681. }
  682. };
  683. struct BattleSetActiveStack : public CPackForClient//3002
  684. {
  685. BattleSetActiveStack(){type = 3002;};
  686. void applyCl(CClient *cl);
  687. DLL_EXPORT void applyGs(CGameState *gs);
  688. ui32 stack;
  689. template <typename Handler> void serialize(Handler &h, const int version)
  690. {
  691. h & stack;
  692. }
  693. };
  694. struct BattleResult : public CPackForClient//3003
  695. {
  696. BattleResult(){type = 3003;};
  697. void applyFirstCl(CClient *cl);
  698. void applyGs(CGameState *gs);
  699. ui8 result; //0 - normal victory; 1 - escape; 2 - surrender
  700. ui8 winner; //0 - attacker, 1 - defender, [2 - draw (should be possible?)]
  701. std::map<ui32,si32> casualties[2]; //first => casualties of attackers - map crid => number
  702. ui32 exp[2]; //exp for attacker and defender
  703. std::set<ui32> artifacts; //artifacts taken from loser to winner
  704. template <typename Handler> void serialize(Handler &h, const int version)
  705. {
  706. h & result & winner & casualties[0] & casualties[1] & exp & artifacts;
  707. }
  708. };
  709. struct BattleStackMoved : public CPackForClient//3004
  710. {
  711. ui32 stack, tile;
  712. ui8 ending, distance;
  713. BattleStackMoved(){type = 3004;};
  714. void applyFirstCl(CClient *cl);
  715. void applyGs(CGameState *gs);
  716. template <typename Handler> void serialize(Handler &h, const int version)
  717. {
  718. h & stack & tile & ending & distance;
  719. }
  720. };
  721. struct BattleStackAttacked : public CPackForClient//3005
  722. {
  723. BattleStackAttacked(){flags = 0; type = 3005;};
  724. void applyCl(CClient *cl);
  725. DLL_EXPORT void applyGs(CGameState *gs);
  726. ui32 stackAttacked, attackerID;
  727. ui32 newAmount, newHP, killedAmount, damageAmount;
  728. ui8 flags; //1 - is stack killed; 2 - is there special effect to be shown;
  729. ui32 effect; //set only if flag 2 is present
  730. bool killed() const//if target stack was killed
  731. {
  732. return flags & 1;
  733. }
  734. bool isEffect() const//if target stack was killed
  735. {
  736. return flags & 2;
  737. }
  738. template <typename Handler> void serialize(Handler &h, const int version)
  739. {
  740. h & stackAttacked & attackerID & newAmount & newHP & flags & killedAmount & damageAmount & effect;
  741. }
  742. bool operator<(const BattleStackAttacked &b) const
  743. {
  744. return stackAttacked < b.stackAttacked;
  745. }
  746. };
  747. struct BattleAttack : public CPackForClient//3006
  748. {
  749. BattleAttack(){flags = 0; type = 3006;};
  750. void applyFirstCl(CClient *cl);
  751. DLL_EXPORT void applyGs(CGameState *gs);
  752. void applyCl(CClient *cl);
  753. std::set<BattleStackAttacked> bsa;
  754. ui32 stackAttacking;
  755. ui8 flags;
  756. bool shot()//distance attack - decrease number of shots
  757. {
  758. return flags & 1;
  759. }
  760. bool counter()//is it counterattack?
  761. {
  762. return flags & 2;
  763. }
  764. bool lucky()
  765. {
  766. return flags & 4;
  767. }
  768. bool unlucky()
  769. {
  770. //TODO: support?
  771. return flags & 8;
  772. }
  773. //bool killed() //if target stack was killed
  774. //{
  775. // return bsa.killed();
  776. //}
  777. template <typename Handler> void serialize(Handler &h, const int version)
  778. {
  779. h & bsa & stackAttacking & flags;
  780. }
  781. };
  782. struct StartAction : public CPackForClient//3007
  783. {
  784. StartAction(){type = 3007;};
  785. StartAction(const BattleAction &act){ba = act; type = 3007;};
  786. void applyFirstCl(CClient *cl);
  787. DLL_EXPORT void applyGs(CGameState *gs);
  788. BattleAction ba;
  789. template <typename Handler> void serialize(Handler &h, const int version)
  790. {
  791. h & ba;
  792. }
  793. };
  794. struct EndAction : public CPackForClient//3008
  795. {
  796. EndAction(){type = 3008;};
  797. void applyCl(CClient *cl);
  798. template <typename Handler> void serialize(Handler &h, const int version)
  799. {
  800. }
  801. };
  802. struct SpellCast : public CPackForClient//3009
  803. {
  804. SpellCast(){type = 3009;};
  805. DLL_EXPORT void applyGs(CGameState *gs);
  806. void applyCl(CClient *cl);
  807. si32 dmgToDisplay; //this amount will be displayed as amount of damage dealt by spell
  808. ui8 side; //which hero did cast spell: 0 - attacker, 1 - defender
  809. ui32 id; //id of spell
  810. ui8 skill; //caster's skill level
  811. ui16 tile; //destination tile (may not be set in some global/mass spells
  812. std::vector<ui32> resisted; //ids of creatures that resisted this spell
  813. std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure)
  814. template <typename Handler> void serialize(Handler &h, const int version)
  815. {
  816. h & dmgToDisplay & side & id & skill & tile & resisted & affectedCres;
  817. }
  818. };
  819. struct SetStackEffect : public CPackForClient //3010
  820. {
  821. SetStackEffect(){type = 3010;};
  822. DLL_EXPORT void applyGs(CGameState *gs);
  823. void applyCl(CClient *cl);
  824. std::set<ui32> stacks; //affected stacks (IDs)
  825. CStack::StackEffect effect; //type of effect
  826. template <typename Handler> void serialize(Handler &h, const int version)
  827. {
  828. h & stacks & effect;
  829. }
  830. };
  831. struct StacksInjured : public CPackForClient //3011
  832. {
  833. StacksInjured(){type = 3011;}
  834. DLL_EXPORT void applyGs(CGameState *gs);
  835. void applyCl(CClient *cl);
  836. std::set<BattleStackAttacked> stacks;
  837. template <typename Handler> void serialize(Handler &h, const int version)
  838. {
  839. h & stacks;
  840. }
  841. };
  842. struct BattleResultsApplied : public CPackForClient //3012
  843. {
  844. BattleResultsApplied(){type = 3012;}
  845. ui8 player1, player2;
  846. void applyCl(CClient *cl);
  847. template <typename Handler> void serialize(Handler &h, const int version)
  848. {
  849. h & player1 & player2;
  850. }
  851. };
  852. struct StacksHealedOrResurrected : public CPackForClient //3013
  853. {
  854. StacksHealedOrResurrected(){type = 3013;}
  855. DLL_EXPORT void applyGs(CGameState *gs);
  856. void applyCl(CClient *cl);
  857. struct HealInfo
  858. {
  859. ui32 stackID;
  860. ui32 healedHP;
  861. ui8 lowLevelResurrection; //in case this stack is resurrected by this heal, it will be marked as SUMMONED
  862. template <typename Handler> void serialize(Handler &h, const int version)
  863. {
  864. h & stackID & healedHP & lowLevelResurrection;
  865. }
  866. };
  867. std::vector<HealInfo> healedStacks;
  868. template <typename Handler> void serialize(Handler &h, const int version)
  869. {
  870. h & healedStacks;
  871. }
  872. };
  873. struct ObstaclesRemoved : public CPackForClient //3014
  874. {
  875. ObstaclesRemoved(){type = 3014;}
  876. DLL_EXPORT void applyGs(CGameState *gs);
  877. void applyCl(CClient *cl);
  878. std::set<si32> obstacles; //uniqueIDs of removed obstacles
  879. template <typename Handler> void serialize(Handler &h, const int version)
  880. {
  881. h & obstacles;
  882. }
  883. };
  884. struct CatapultAttack : public CPackForClient //3015
  885. {
  886. CatapultAttack(){type = 3015;}
  887. DLL_EXPORT void applyGs(CGameState *gs);
  888. void applyCl(CClient *cl);
  889. std::set< std::pair< std::pair< ui8, si16 >, ui8> > attackedParts; // < <attackedPartOfWall, attacked hex >, damageDealt>
  890. //attackedPartOfWall; //[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate;
  891. //damageDealt;
  892. int attacker; //if -1, then a spell caused this
  893. template <typename Handler> void serialize(Handler &h, const int version)
  894. {
  895. h & attackedParts & attacker;
  896. }
  897. };
  898. struct BattleStacksRemoved : public CPackForClient //3016
  899. {
  900. BattleStacksRemoved(){type = 3016;}
  901. DLL_EXPORT void applyGs(CGameState *gs);
  902. void applyCl(CClient *cl);
  903. std::set<ui32> stackIDs; //IDs of removed stacks
  904. template <typename Handler> void serialize(Handler &h, const int version)
  905. {
  906. h & stackIDs;
  907. }
  908. };
  909. struct ShowInInfobox : public CPackForClient //107
  910. {
  911. ShowInInfobox(){type = 107;};
  912. ui8 player;
  913. Component c;
  914. MetaString text;
  915. void applyCl(CClient *cl);
  916. template <typename Handler> void serialize(Handler &h, const int version)
  917. {
  918. h & player & c & text;
  919. }
  920. };
  921. /***********************************************************************************************************/
  922. struct CloseServer : public CPackForServer
  923. {
  924. bool applyGh(CGameHandler *gh);
  925. template <typename Handler> void serialize(Handler &h, const int version)
  926. {}
  927. };
  928. struct EndTurn : public CPackForServer
  929. {
  930. bool applyGh(CGameHandler *gh);
  931. template <typename Handler> void serialize(Handler &h, const int version)
  932. {}
  933. };
  934. struct DismissHero : public CPackForServer
  935. {
  936. DismissHero(){};
  937. DismissHero(si32 HID) : hid(HID) {};
  938. si32 hid;
  939. bool applyGh(CGameHandler *gh);
  940. template <typename Handler> void serialize(Handler &h, const int version)
  941. {
  942. h & hid;
  943. }
  944. };
  945. struct MoveHero : public CPackForServer
  946. {
  947. MoveHero(){};
  948. MoveHero(const int3 &Dest, si32 HID) : dest(Dest), hid(HID){};
  949. int3 dest;
  950. si32 hid;
  951. bool applyGh(CGameHandler *gh);
  952. template <typename Handler> void serialize(Handler &h, const int version)
  953. {
  954. h & dest & hid;
  955. }
  956. };
  957. struct ArrangeStacks : public CPackForServer
  958. {
  959. ArrangeStacks(){};
  960. ArrangeStacks(ui8 W, ui8 P1, ui8 P2, si32 ID1, si32 ID2, si32 VAL)
  961. :what(W),p1(P1),p2(P2),id1(ID1),id2(ID2),val(VAL) {};
  962. ui8 what; //1 - swap; 2 - merge; 3 - split
  963. ui8 p1, p2; //positions of first and second stack
  964. si32 id1, id2; //ids of objects with garrison
  965. si32 val;
  966. bool applyGh(CGameHandler *gh);
  967. template <typename Handler> void serialize(Handler &h, const int version)
  968. {
  969. h & what & p1 & p2 & id1 & id2 & val;
  970. }
  971. };
  972. struct DisbandCreature : public CPackForServer
  973. {
  974. DisbandCreature(){};
  975. DisbandCreature(ui8 Pos, si32 ID):pos(Pos),id(ID){};
  976. ui8 pos; //stack pos
  977. si32 id; //object id
  978. bool applyGh(CGameHandler *gh);
  979. template <typename Handler> void serialize(Handler &h, const int version)
  980. {
  981. h & pos & id;
  982. }
  983. };
  984. struct BuildStructure : public CPackForServer
  985. {
  986. BuildStructure(){};
  987. BuildStructure(si32 TID, si32 BID):bid(BID),tid(TID){};
  988. si32 bid, tid; //structure and town ids
  989. bool applyGh(CGameHandler *gh);
  990. template <typename Handler> void serialize(Handler &h, const int version)
  991. {
  992. h & tid & bid;
  993. }
  994. };
  995. struct RazeStructure : public BuildStructure
  996. {
  997. RazeStructure(){};
  998. //RazeStructure(si32 TID, si32 BID):bid(BID),tid(TID){};
  999. bool applyGh(CGameHandler *gh);
  1000. };
  1001. struct RecruitCreatures : public CPackForServer
  1002. {
  1003. RecruitCreatures(){};
  1004. RecruitCreatures(si32 TID, si32 CRID, si32 Amount):tid(TID),crid(CRID),amount(Amount){};
  1005. si32 tid; //town id
  1006. ui32 crid, amount;//creature ID and amount
  1007. bool applyGh(CGameHandler *gh);
  1008. template <typename Handler> void serialize(Handler &h, const int version)
  1009. {
  1010. h & tid & crid & amount;
  1011. }
  1012. };
  1013. struct UpgradeCreature : public CPackForServer
  1014. {
  1015. UpgradeCreature(){};
  1016. UpgradeCreature(ui8 Pos, si32 ID, si32 CRID):pos(Pos),id(ID), cid(CRID){};
  1017. ui8 pos; //stack pos
  1018. si32 id; //object id
  1019. si32 cid; //id of type to which we want make upgrade
  1020. bool applyGh(CGameHandler *gh);
  1021. template <typename Handler> void serialize(Handler &h, const int version)
  1022. {
  1023. h & pos & id & cid;
  1024. }
  1025. };
  1026. struct GarrisonHeroSwap : public CPackForServer
  1027. {
  1028. GarrisonHeroSwap(){};
  1029. GarrisonHeroSwap(si32 TID):tid(TID){};
  1030. si32 tid;
  1031. bool applyGh(CGameHandler *gh);
  1032. template <typename Handler> void serialize(Handler &h, const int version)
  1033. {
  1034. h & tid;
  1035. }
  1036. };
  1037. struct ExchangeArtifacts : public CPackForServer
  1038. {
  1039. ExchangeArtifacts(){};
  1040. ExchangeArtifacts(si32 H1, si32 H2, ui16 S1, ui16 S2)
  1041. :hid1(H1),hid2(H2),slot1(S1),slot2(S2){};
  1042. si32 hid1, hid2;
  1043. ui16 slot1, slot2;
  1044. bool applyGh(CGameHandler *gh);
  1045. template <typename Handler> void serialize(Handler &h, const int version)
  1046. {
  1047. h & hid1 & hid2 & slot1 & slot2;
  1048. }
  1049. };
  1050. struct BuyArtifact : public CPackForServer
  1051. {
  1052. BuyArtifact(){};
  1053. BuyArtifact(si32 HID, si32 AID):hid(HID),aid(AID){};
  1054. si32 hid, aid; //hero and artifact id
  1055. bool applyGh(CGameHandler *gh);
  1056. template <typename Handler> void serialize(Handler &h, const int version)
  1057. {
  1058. h & hid & aid;
  1059. }
  1060. };
  1061. struct TradeOnMarketplace : public CPackForServer
  1062. {
  1063. TradeOnMarketplace(){};
  1064. TradeOnMarketplace(ui8 Player, ui8 Mode, /*si32 ID, */ui32 R1, ui32 R2, ui32 Val)
  1065. :player(Player),mode(Mode),/*id(ID),*/r1(R1),r2(R2),val(Val){};
  1066. ui8 player;
  1067. ui8 mode;//0 - res<->res;
  1068. //si32 id; //object id
  1069. ui32 r1, r2; //mode 0: r1 - sold resource, r2 - bought res
  1070. ui32 val; //units of sold resource
  1071. bool applyGh(CGameHandler *gh);
  1072. template <typename Handler> void serialize(Handler &h, const int version)
  1073. {
  1074. h & player & mode & /*id & */r1 & r2 & val;
  1075. }
  1076. };
  1077. struct SetFormation : public CPackForServer
  1078. {
  1079. SetFormation(){};
  1080. SetFormation(si32 HID, ui8 Formation):hid(HID),formation(Formation){};
  1081. si32 hid;
  1082. ui8 formation;
  1083. bool applyGh(CGameHandler *gh);
  1084. template <typename Handler> void serialize(Handler &h, const int version)
  1085. {
  1086. h & hid & formation;
  1087. }
  1088. };
  1089. struct HireHero : public CPackForServer
  1090. {
  1091. HireHero(){};
  1092. HireHero(si32 HID, si32 TID):hid(HID),tid(TID){};
  1093. si32 hid, tid; //available hero serial and town id
  1094. bool applyGh(CGameHandler *gh);
  1095. template <typename Handler> void serialize(Handler &h, const int version)
  1096. {
  1097. h & hid & tid;
  1098. }
  1099. };
  1100. struct BuildBoat : public CPackForServer
  1101. {
  1102. BuildBoat(){};
  1103. si32 objid; //where player wants to buy a boat
  1104. bool applyGh(CGameHandler *gh);
  1105. template <typename Handler> void serialize(Handler &h, const int version)
  1106. {
  1107. h & objid;
  1108. }
  1109. };
  1110. struct QueryReply : public CPackForServer
  1111. {
  1112. QueryReply(){type = 6000;};
  1113. QueryReply(ui32 QID, ui32 Answer):qid(QID),answer(Answer){type = 6000;};
  1114. ui32 qid, answer; //hero and artifact id
  1115. bool applyGh(CGameHandler *gh);
  1116. template <typename Handler> void serialize(Handler &h, const int version)
  1117. {
  1118. h & qid & answer;
  1119. }
  1120. };
  1121. struct MakeAction : public CPackForServer
  1122. {
  1123. MakeAction(){};
  1124. MakeAction(const BattleAction &BA):ba(BA){};
  1125. BattleAction ba;
  1126. bool applyGh(CGameHandler *gh);
  1127. template <typename Handler> void serialize(Handler &h, const int version)
  1128. {
  1129. h & ba;
  1130. }
  1131. };
  1132. struct MakeCustomAction : public CPackForServer
  1133. {
  1134. MakeCustomAction(){};
  1135. MakeCustomAction(const BattleAction &BA):ba(BA){};
  1136. BattleAction ba;
  1137. bool applyGh(CGameHandler *gh);
  1138. template <typename Handler> void serialize(Handler &h, const int version)
  1139. {
  1140. h & ba;
  1141. }
  1142. };
  1143. /***********************************************************************************************************/
  1144. struct SaveGame : public CPackForClient, public CPackForServer
  1145. {
  1146. SaveGame(){};
  1147. SaveGame(const std::string &Fname) :fname(Fname){};
  1148. std::string fname;
  1149. void applyCl(CClient *cl);
  1150. void applyGs(CGameState *gs){};
  1151. bool applyGh(CGameHandler *gh);
  1152. template <typename Handler> void serialize(Handler &h, const int version)
  1153. {
  1154. h & fname;
  1155. }
  1156. };
  1157. struct PlayerMessage : public CPackForClient, public CPackForServer //513
  1158. {
  1159. PlayerMessage(){CPackForClient::type = 513;};
  1160. PlayerMessage(ui8 Player, const std::string &Text)
  1161. :player(Player),text(Text)
  1162. {CPackForClient::type = 513;};
  1163. void applyCl(CClient *cl);
  1164. void applyGs(CGameState *gs){};
  1165. bool applyGh(CGameHandler *gh);
  1166. ui8 player;
  1167. std::string text;
  1168. template <typename Handler> void serialize(Handler &h, const int version)
  1169. {
  1170. h & text & player;
  1171. }
  1172. };
  1173. struct SetSelection : public CPackForClient, public CPackForServer //514
  1174. {
  1175. SetSelection(){CPackForClient::type = 514;};
  1176. DLL_EXPORT void applyGs(CGameState *gs);
  1177. bool applyGh(CGameHandler *gh);
  1178. void applyCl(CClient *cl);
  1179. ui8 player;
  1180. ui32 id;
  1181. template <typename Handler> void serialize(Handler &h, const int version)
  1182. {
  1183. h & id & player;
  1184. }
  1185. };
  1186. struct CenterView : public CPackForClient//515
  1187. {
  1188. CenterView(){CPackForClient::type = 515;};
  1189. void applyCl(CClient *cl);
  1190. ui8 player;
  1191. int3 pos;
  1192. ui32 focusTime; //ms
  1193. template <typename Handler> void serialize(Handler &h, const int version)
  1194. {
  1195. h & pos & player & focusTime;
  1196. }
  1197. };
  1198. struct SShowThievesGuildWindow : public CPackForClient //516
  1199. {
  1200. SShowThievesGuildWindow(){CPackForClient::type = 516;};
  1201. void applyCl(CClient *cl);
  1202. si32 requestingObject;
  1203. template <typename Handler> void serialize(Handler &h, const int version)
  1204. {
  1205. h & requestingObject;
  1206. }
  1207. };
  1208. #endif //__NETPACKS_H__