NetPacks.h 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088
  1. #ifndef __NETPACKS_H__
  2. #define __NETPACKS_H__
  3. #include <boost/unordered_set.hpp>
  4. #include "../global.h"
  5. #include "BattleAction.h"
  6. #include "HeroBonus.h"
  7. #include <set>
  8. #include "CCreatureSet.h"
  9. #include "CMapInfo.h"
  10. #include "../StartInfo.h"
  11. #include "ConstTransitivePtr.h"
  12. #include "../int3.h"
  13. #include "ResourceSet.h"
  14. /*
  15. * NetPacks.h, part of VCMI engine
  16. *
  17. * Authors: listed in file AUTHORS in main folder
  18. *
  19. * License: GNU General Public License v2.0 or later
  20. * Full text of license available in license.txt file, in main folder
  21. *
  22. */
  23. class CClient;
  24. class CGameState;
  25. class CGameHandler;
  26. class CConnection;
  27. class CCampaignState;
  28. class CArtifact;
  29. class CSelectionScreen;
  30. class CGObjectInstance;
  31. class CArtifactInstance;
  32. //class CMapInfo;
  33. struct ArtSlotInfo;
  34. struct CPack
  35. {
  36. ui16 type;
  37. CPack(){};
  38. virtual ~CPack(){};
  39. ui16 getType() const{return type;}
  40. template <typename Handler> void serialize(Handler &h, const int version)
  41. {
  42. tlog1 << "CPack serialized... this should not happen!\n";
  43. }
  44. DLL_EXPORT void applyGs(CGameState *gs)
  45. {};
  46. };
  47. struct CPackForClient : public CPack
  48. {
  49. CPackForClient(){type = 1;};
  50. CGameState* GS(CClient *cl);
  51. void applyFirstCl(CClient *cl)//called before applying to gs
  52. {};
  53. void applyCl(CClient *cl)//called after applying to gs
  54. {};
  55. };
  56. struct CPackForServer : public CPack
  57. {
  58. CConnection *c;
  59. CGameState* GS(CGameHandler *gh);
  60. CPackForServer()
  61. {
  62. type = 2;
  63. c = NULL;
  64. };
  65. bool applyGh(CGameHandler *gh);//called after applying to gs
  66. };
  67. struct Query : public CPackForClient
  68. {
  69. ui32 id;
  70. };
  71. struct MetaString : public CPack //2001 helper for object scrips
  72. {
  73. private:
  74. enum EMessage {TEXACT_STRING, TLOCAL_STRING, TNUMBER, TREPLACE_ESTRING, TREPLACE_LSTRING, TREPLACE_NUMBER, TREPLACE_PLUSNUMBER};
  75. public:
  76. enum {GENERAL_TXT=1, XTRAINFO_TXT, OBJ_NAMES, RES_NAMES, ART_NAMES, ARRAY_TXT, CRE_PL_NAMES, CREGENS, MINE_NAMES,
  77. MINE_EVNTS, ADVOB_TXT, ART_EVNTS, SPELL_NAME, SEC_SKILL_NAME, CRE_SING_NAMES, CREGENS4, COLOR, ART_DESCR};
  78. std::vector<ui8> message; //vector of EMessage
  79. 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
  80. std::vector<std::string> exactStrings;
  81. std::vector<si32> numbers;
  82. template <typename Handler> void serialize(Handler &h, const int version)
  83. {
  84. h & exactStrings & localStrings & message & numbers;
  85. }
  86. void addTxt(ui8 type, ui32 serial)
  87. {
  88. message.push_back(TLOCAL_STRING);
  89. localStrings.push_back(std::pair<ui8,ui32>(type, serial));
  90. }
  91. MetaString& operator<<(const std::pair<ui8,ui32> &txt)
  92. {
  93. message.push_back(TLOCAL_STRING);
  94. localStrings.push_back(txt);
  95. return *this;
  96. }
  97. MetaString& operator<<(const std::string &txt)
  98. {
  99. message.push_back(TEXACT_STRING);
  100. exactStrings.push_back(txt);
  101. return *this;
  102. }
  103. MetaString& operator<<(int txt)
  104. {
  105. message.push_back(TNUMBER);
  106. numbers.push_back(txt);
  107. return *this;
  108. }
  109. void addReplacement(ui8 type, ui32 serial)
  110. {
  111. message.push_back(TREPLACE_LSTRING);
  112. localStrings.push_back(std::pair<ui8,ui32>(type, serial));
  113. }
  114. void addReplacement(const std::string &txt)
  115. {
  116. message.push_back(TREPLACE_ESTRING);
  117. exactStrings.push_back(txt);
  118. }
  119. void addReplacement(int txt)
  120. {
  121. message.push_back(TREPLACE_NUMBER);
  122. numbers.push_back(txt);
  123. }
  124. void addReplacement2(int txt)
  125. {
  126. message.push_back(TREPLACE_PLUSNUMBER);
  127. numbers.push_back(txt);
  128. }
  129. DLL_EXPORT void addCreReplacement(TCreature id, TQuantity count); //adds sing or plural name;
  130. DLL_EXPORT void addReplacement(const CStackBasicDescriptor &stack); //adds sing or plural name;
  131. DLL_EXPORT std::string buildList () const;
  132. void clear()
  133. {
  134. exactStrings.clear();
  135. localStrings.clear();
  136. message.clear();
  137. numbers.clear();
  138. }
  139. DLL_EXPORT void toString(std::string &dst) const;
  140. DLL_EXPORT std::string toString() const;
  141. void getLocalString(const std::pair<ui8,ui32> &txt, std::string &dst) const;
  142. MetaString()
  143. {
  144. type = 2001;
  145. }
  146. };
  147. /***********************************************************************************************************/
  148. struct PackageApplied : public CPackForClient //94
  149. {
  150. PackageApplied() {type = 94;}
  151. PackageApplied(ui8 Result) : result(Result) {type = 94;}
  152. void applyCl(CClient *cl);
  153. ui8 result; //0 - something went wrong, request hasn't been realized; 1 - OK
  154. ui32 packType; //type id of applied package
  155. template <typename Handler> void serialize(Handler &h, const int version)
  156. {
  157. h & result & packType;
  158. }
  159. };
  160. struct SystemMessage : public CPackForClient //95
  161. {
  162. SystemMessage(const std::string Text) : text(Text){type = 95;};
  163. SystemMessage(){type = 95;};
  164. void applyCl(CClient *cl);
  165. std::string text;
  166. template <typename Handler> void serialize(Handler &h, const int version)
  167. {
  168. h & text;
  169. }
  170. };
  171. struct PlayerBlocked : public CPackForClient //96
  172. {
  173. PlayerBlocked(){type = 96;};
  174. void applyCl(CClient *cl);
  175. enum EReason { UPCOMING_BATTLE };
  176. ui8 reason;
  177. ui8 player;
  178. template <typename Handler> void serialize(Handler &h, const int version)
  179. {
  180. h & reason & player;
  181. }
  182. };
  183. struct YourTurn : public CPackForClient //100
  184. {
  185. YourTurn(){type = 100;};
  186. void applyCl(CClient *cl);
  187. DLL_EXPORT void applyGs(CGameState *gs);
  188. ui8 player;
  189. template <typename Handler> void serialize(Handler &h, const int version)
  190. {
  191. h & player;
  192. }
  193. };
  194. struct SetResource : public CPackForClient //102
  195. {
  196. SetResource(){type = 102;};
  197. void applyCl(CClient *cl);
  198. DLL_EXPORT void applyGs(CGameState *gs);
  199. ui8 player, resid;
  200. si32 val;
  201. template <typename Handler> void serialize(Handler &h, const int version)
  202. {
  203. h & player & resid & val;
  204. }
  205. };
  206. struct SetResources : public CPackForClient //104
  207. {
  208. SetResources(){type = 104;};
  209. void applyCl(CClient *cl);
  210. DLL_EXPORT void applyGs(CGameState *gs);
  211. ui8 player;
  212. TResources res; //res[resid] => res amount
  213. template <typename Handler> void serialize(Handler &h, const int version)
  214. {
  215. h & player & res;
  216. }
  217. };
  218. struct SetPrimSkill : public CPackForClient //105
  219. {
  220. SetPrimSkill(){type = 105;};
  221. void applyCl(CClient *cl);
  222. DLL_EXPORT void applyGs(CGameState *gs);
  223. ui8 abs; //0 - changes by value; 1 - sets to value
  224. si32 id;
  225. ui16 which;
  226. si64 val;
  227. template <typename Handler> void serialize(Handler &h, const int version)
  228. {
  229. h & abs & id & which & val;
  230. }
  231. };
  232. struct SetSecSkill : public CPackForClient //106
  233. {
  234. SetSecSkill(){type = 106;};
  235. void applyCl(CClient *cl);
  236. DLL_EXPORT void applyGs(CGameState *gs);
  237. ui8 abs; //0 - changes by value; 1 - sets to value
  238. si32 id;
  239. ui16 which, val;
  240. template <typename Handler> void serialize(Handler &h, const int version)
  241. {
  242. h & abs & id & which & val;
  243. }
  244. };
  245. struct HeroVisitCastle : public CPackForClient //108
  246. {
  247. HeroVisitCastle(){flags=0;type = 108;};
  248. void applyCl(CClient *cl);
  249. DLL_EXPORT void applyGs(CGameState *gs);
  250. ui8 flags; //1 - start
  251. ui32 tid, hid;
  252. bool start() //if hero is entering castle (if false - leaving)
  253. {
  254. return flags & 1;
  255. }
  256. // bool garrison() //if hero is entering/leaving garrison (if false - it's only visiting hero)
  257. // {
  258. // return flags & 2;
  259. // }
  260. template <typename Handler> void serialize(Handler &h, const int version)
  261. {
  262. h & flags & tid & hid;
  263. }
  264. };
  265. struct ChangeSpells : public CPackForClient //109
  266. {
  267. ChangeSpells(){type = 109;};
  268. void applyCl(CClient *cl);
  269. DLL_EXPORT void applyGs(CGameState *gs);
  270. ui8 learn; //1 - gives spell, 0 - takes
  271. ui32 hid;
  272. std::set<ui32> spells;
  273. template <typename Handler> void serialize(Handler &h, const int version)
  274. {
  275. h & learn & hid & spells;
  276. }
  277. };
  278. struct SetMana : public CPackForClient //110
  279. {
  280. SetMana(){type = 110;};
  281. void applyCl(CClient *cl);
  282. DLL_EXPORT void applyGs(CGameState *gs);
  283. si32 hid, val;
  284. template <typename Handler> void serialize(Handler &h, const int version)
  285. {
  286. h & val & hid;
  287. }
  288. };
  289. struct SetMovePoints : public CPackForClient //111
  290. {
  291. SetMovePoints(){type = 111;};
  292. void applyCl(CClient *cl);
  293. DLL_EXPORT void applyGs(CGameState *gs);
  294. ui32 hid, val;
  295. template <typename Handler> void serialize(Handler &h, const int version)
  296. {
  297. h & val & hid;
  298. }
  299. };
  300. struct FoWChange : public CPackForClient //112
  301. {
  302. FoWChange(){type = 112;};
  303. void applyCl(CClient *cl);
  304. DLL_EXPORT void applyGs(CGameState *gs);
  305. boost::unordered_set<int3, struct ShashInt3 > tiles;
  306. ui8 player, mode; //mode==0 - hide, mode==1 - reveal
  307. template <typename Handler> void serialize(Handler &h, const int version)
  308. {
  309. h & tiles & player & mode;
  310. }
  311. };
  312. struct SetAvailableHeroes : public CPackForClient //113
  313. {
  314. SetAvailableHeroes()
  315. {
  316. type = 113;
  317. for (int i = 0; i < AVAILABLE_HEROES_PER_PLAYER; i++)
  318. army[i].clear();
  319. }
  320. ~SetAvailableHeroes()
  321. {
  322. }
  323. void applyCl(CClient *cl);
  324. DLL_EXPORT void applyGs(CGameState *gs);
  325. ui8 player;
  326. si32 hid[AVAILABLE_HEROES_PER_PLAYER]; //-1 if no hero
  327. CSimpleArmy army[AVAILABLE_HEROES_PER_PLAYER];
  328. template <typename Handler> void serialize(Handler &h, const int version)
  329. {
  330. h & player & hid & army;
  331. }
  332. };
  333. struct GiveBonus : public CPackForClient //115
  334. {
  335. GiveBonus(ui8 Who = 0)
  336. {
  337. who = Who;
  338. type = 115;
  339. }
  340. void applyCl(CClient *cl);
  341. DLL_EXPORT void applyGs(CGameState *gs);
  342. enum {HERO, PLAYER, TOWN};
  343. ui8 who; //who receives bonus, uses enum above
  344. ui32 id; //hero. town or player id - whoever receives it
  345. Bonus bonus;
  346. MetaString bdescr;
  347. template <typename Handler> void serialize(Handler &h, const int version)
  348. {
  349. h & bonus & id & bdescr & who;
  350. }
  351. };
  352. struct ChangeObjPos : public CPackForClient //116
  353. {
  354. ChangeObjPos()
  355. {
  356. type = 116;
  357. flags = 0;
  358. }
  359. void applyFirstCl(CClient *cl);
  360. void applyCl(CClient *cl);
  361. DLL_EXPORT void applyGs(CGameState *gs);
  362. ui32 objid;
  363. int3 nPos;
  364. ui8 flags; //bit flags: 1 - redraw
  365. template <typename Handler> void serialize(Handler &h, const int version)
  366. {
  367. h & objid & nPos & flags;
  368. }
  369. };
  370. struct PlayerEndsGame : public CPackForClient //117
  371. {
  372. PlayerEndsGame()
  373. {
  374. type = 117;
  375. }
  376. void applyCl(CClient *cl);
  377. DLL_EXPORT void applyGs(CGameState *gs);
  378. ui8 player;
  379. ui8 victory;
  380. template <typename Handler> void serialize(Handler &h, const int version)
  381. {
  382. h & player & victory;
  383. }
  384. };
  385. struct RemoveBonus : public CPackForClient //118
  386. {
  387. RemoveBonus(ui8 Who = 0)
  388. {
  389. who = Who;
  390. type = 118;
  391. }
  392. void applyCl(CClient *cl);
  393. DLL_EXPORT void applyGs(CGameState *gs);
  394. enum {HERO, PLAYER, TOWN};
  395. ui8 who; //who receives bonus, uses enum above
  396. ui32 whoID; //hero, town or player id - whoever loses bonus
  397. //vars to identify bonus: its source
  398. ui8 source;
  399. ui32 id; //source id
  400. //used locally: copy of removed bonus
  401. Bonus bonus;
  402. template <typename Handler> void serialize(Handler &h, const int version)
  403. {
  404. h & source & id & who & whoID;
  405. }
  406. };
  407. struct UpdateCampaignState : public CPackForClient //119
  408. {
  409. UpdateCampaignState()
  410. {
  411. type = 119;
  412. }
  413. CCampaignState *camp;
  414. void applyCl(CClient *cl);
  415. template <typename Handler> void serialize(Handler &h, const int version)
  416. {
  417. h & camp;
  418. }
  419. };
  420. struct RemoveObject : public CPackForClient //500
  421. {
  422. RemoveObject(){type = 500;};
  423. RemoveObject(si32 ID){id = ID;type = 500;};
  424. void applyFirstCl(CClient *cl);
  425. void applyCl(CClient *cl);
  426. DLL_EXPORT void applyGs(CGameState *gs);
  427. si32 id;
  428. template <typename Handler> void serialize(Handler &h, const int version)
  429. {
  430. h & id;
  431. }
  432. };
  433. struct TryMoveHero : public CPackForClient //501
  434. {
  435. TryMoveHero(){type = 501;humanKnows=false; attackedFrom = int3(-1, -1, -1);};
  436. void applyFirstCl(CClient *cl);
  437. void applyCl(CClient *cl);
  438. void applyGs(CGameState *gs);
  439. enum EResult
  440. {
  441. FAILED, SUCCESS, TELEPORTATION, RESERVED___, BLOCKING_VISIT, EMBARK, DISEMBARK
  442. };
  443. ui32 id, movePoints;
  444. ui8 result; //uses EResult
  445. int3 start, end; //h3m format
  446. boost::unordered_set<int3, ShashInt3> fowRevealed; //revealed tiles
  447. int3 attackedFrom; // Set when stepping into endangered tile.
  448. bool humanKnows; //used locally during applying to client
  449. template <typename Handler> void serialize(Handler &h, const int version)
  450. {
  451. h & id & result & start & end & movePoints & fowRevealed & attackedFrom;
  452. }
  453. };
  454. // struct SetGarrisons : public CPackForClient //502
  455. // {
  456. // SetGarrisons(){type = 502;};
  457. // void applyCl(CClient *cl);
  458. // DLL_EXPORT void applyGs(CGameState *gs);
  459. //
  460. // std::map<ui32,CCreatureSet> garrs;
  461. //
  462. // template <typename Handler> void serialize(Handler &h, const int version)
  463. // {
  464. // h & garrs;
  465. // }
  466. // };
  467. struct NewStructures : public CPackForClient //504
  468. {
  469. NewStructures(){type = 504;};
  470. void applyCl(CClient *cl);
  471. DLL_EXPORT virtual void applyGs(CGameState *gs);
  472. si32 tid;
  473. std::set<si32> bid;
  474. si16 builded;
  475. template <typename Handler> void serialize(Handler &h, const int version)
  476. {
  477. h & tid & bid & builded;
  478. }
  479. };
  480. struct RazeStructures : public CPackForClient //505
  481. {
  482. RazeStructures() {type = 505;};
  483. void applyCl (CClient *cl);
  484. DLL_EXPORT void applyGs(CGameState *gs);
  485. si32 tid;
  486. std::set<si32> bid;
  487. si16 destroyed;
  488. template <typename Handler> void serialize(Handler &h, const int version)
  489. {
  490. h & tid & bid & destroyed;
  491. }
  492. };
  493. struct SetAvailableCreatures : public CPackForClient //506
  494. {
  495. SetAvailableCreatures(){type = 506;};
  496. void applyCl(CClient *cl);
  497. DLL_EXPORT void applyGs(CGameState *gs);
  498. si32 tid;
  499. std::vector<std::pair<ui32, std::vector<ui32> > > creatures;
  500. template <typename Handler> void serialize(Handler &h, const int version)
  501. {
  502. h & tid & creatures;
  503. }
  504. };
  505. struct SetHeroesInTown : public CPackForClient //508
  506. {
  507. SetHeroesInTown(){type = 508;};
  508. void applyCl(CClient *cl);
  509. DLL_EXPORT void applyGs(CGameState *gs);
  510. si32 tid, visiting, garrison; //id of town, visiting hero, hero in garrison
  511. template <typename Handler> void serialize(Handler &h, const int version)
  512. {
  513. h & tid & visiting & garrison;
  514. }
  515. };
  516. // struct SetHeroArtifacts : public CPackForClient //509
  517. // {
  518. // SetHeroArtifacts(){type = 509;};
  519. // void applyCl(CClient *cl);
  520. // DLL_EXPORT void applyGs(CGameState *gs);
  521. // DLL_EXPORT void setArtAtPos(ui16 pos, const CArtifact* art);
  522. //
  523. // si32 hid;
  524. // std::vector<const CArtifact*> artifacts; //hero's artifacts from bag
  525. // std::map<ui16, const CArtifact*> 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
  526. //
  527. // template <typename Handler> void serialize(Handler &h, const int version)
  528. // {
  529. // h & hid & artifacts & artifWorn;
  530. // }
  531. //
  532. // std::vector<const CArtifact*> equiped, unequiped; //used locally
  533. // BonusList gained, lost; //used locally as hlp when applying
  534. // };
  535. struct HeroRecruited : public CPackForClient //515
  536. {
  537. HeroRecruited(){type = 515;};
  538. void applyCl(CClient *cl);
  539. DLL_EXPORT void applyGs(CGameState *gs);
  540. si32 hid, tid; //subID of hero
  541. int3 tile;
  542. ui8 player;
  543. template <typename Handler> void serialize(Handler &h, const int version)
  544. {
  545. h & hid & tid & tile & player;
  546. }
  547. };
  548. struct GiveHero : public CPackForClient //516
  549. {
  550. GiveHero(){type = 516;};
  551. void applyFirstCl(CClient *cl);
  552. void applyCl(CClient *cl);
  553. DLL_EXPORT void applyGs(CGameState *gs);
  554. ui32 id; //object id
  555. ui8 player;
  556. template <typename Handler> void serialize(Handler &h, const int version)
  557. {
  558. h & id & player;
  559. }
  560. };
  561. struct OpenWindow : public CPackForClient //517
  562. {
  563. OpenWindow(){type = 517;};
  564. void applyCl(CClient *cl);
  565. enum EWindow {EXCHANGE_WINDOW, RECRUITMENT_FIRST, RECRUITMENT_ALL, SHIPYARD_WINDOW, THIEVES_GUILD,
  566. UNIVERSITY_WINDOW, HILL_FORT_WINDOW, MARKET_WINDOW, PUZZLE_MAP, TAVERN_WINDOW};
  567. ui8 window;
  568. ui32 id1, id2;
  569. template <typename Handler> void serialize(Handler &h, const int version)
  570. {
  571. h & window & id1 & id2;
  572. }
  573. };
  574. struct NewObject : public CPackForClient //518
  575. {
  576. NewObject()
  577. {
  578. type = 518;
  579. id = -1;
  580. }
  581. void applyCl(CClient *cl);
  582. DLL_EXPORT void applyGs(CGameState *gs);
  583. ui32 ID, subID;
  584. int3 pos;
  585. int id; //used locally, filled during applyGs
  586. template <typename Handler> void serialize(Handler &h, const int version)
  587. {
  588. h & ID & subID & pos;
  589. }
  590. };
  591. struct SetAvailableArtifacts : public CPackForClient //519
  592. {
  593. SetAvailableArtifacts(){type = 519;};
  594. void applyCl(CClient *cl);
  595. DLL_EXPORT void applyGs(CGameState *gs);
  596. si32 id; //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)
  597. std::vector<const CArtifact *> arts;
  598. template <typename Handler> void serialize(Handler &h, const int version)
  599. {
  600. h & id & arts;
  601. }
  602. };
  603. struct NewArtifact : public CPackForClient //520
  604. {
  605. NewArtifact(){type = 520;};
  606. //void applyCl(CClient *cl);
  607. DLL_EXPORT void applyGs(CGameState *gs);
  608. ConstTransitivePtr<CArtifactInstance> art;
  609. template <typename Handler> void serialize(Handler &h, const int version)
  610. {
  611. h & art;
  612. }
  613. };
  614. struct StackLocation
  615. {
  616. ConstTransitivePtr<CArmedInstance> army;
  617. TSlot slot;
  618. StackLocation()
  619. {
  620. slot = -1;
  621. }
  622. StackLocation(const CArmedInstance *Army, TSlot Slot)
  623. {
  624. army = const_cast<CArmedInstance*>(Army); //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
  625. slot = Slot;
  626. }
  627. DLL_EXPORT const CStackInstance *getStack();
  628. template <typename Handler> void serialize(Handler &h, const int version)
  629. {
  630. h & army & slot;
  631. }
  632. };
  633. struct CGarrisonOperationPack : CPackForClient
  634. {
  635. };
  636. struct CArtifactOperationPack : CPackForClient
  637. {
  638. };
  639. struct ChangeStackCount : CGarrisonOperationPack //521
  640. {
  641. StackLocation sl;
  642. TQuantity count;
  643. ui8 absoluteValue; //if not -> count will be added (or subtracted if negative)
  644. void applyCl(CClient *cl);
  645. DLL_EXPORT void applyGs(CGameState *gs);
  646. template <typename Handler> void serialize(Handler &h, const int version)
  647. {
  648. h & sl & count & absoluteValue;
  649. }
  650. };
  651. struct SetStackType : CGarrisonOperationPack //522
  652. {
  653. StackLocation sl;
  654. CCreature *type;
  655. void applyCl(CClient *cl);
  656. DLL_EXPORT void applyGs(CGameState *gs);
  657. template <typename Handler> void serialize(Handler &h, const int version)
  658. {
  659. h & sl & type;
  660. }
  661. };
  662. struct EraseStack : CGarrisonOperationPack //523
  663. {
  664. StackLocation sl;
  665. void applyCl(CClient *cl);
  666. DLL_EXPORT void applyGs(CGameState *gs);
  667. template <typename Handler> void serialize(Handler &h, const int version)
  668. {
  669. h & sl;
  670. }
  671. };
  672. struct SwapStacks : CGarrisonOperationPack //524
  673. {
  674. StackLocation sl1, sl2;
  675. void applyCl(CClient *cl);
  676. DLL_EXPORT void applyGs(CGameState *gs);
  677. template <typename Handler> void serialize(Handler &h, const int version)
  678. {
  679. h & sl1 & sl2;
  680. }
  681. };
  682. struct InsertNewStack : CGarrisonOperationPack //525
  683. {
  684. StackLocation sl;
  685. CStackBasicDescriptor stack;
  686. void applyCl(CClient *cl);
  687. DLL_EXPORT void applyGs(CGameState *gs);
  688. template <typename Handler> void serialize(Handler &h, const int version)
  689. {
  690. h & sl & stack;
  691. }
  692. };
  693. //moves creatures from src stack to dst slot, may be used for merging/splittint/moving stacks
  694. struct RebalanceStacks : CGarrisonOperationPack //526
  695. {
  696. StackLocation src, dst;
  697. TQuantity count;
  698. void applyCl(CClient *cl);
  699. DLL_EXPORT void applyGs(CGameState *gs);
  700. template <typename Handler> void serialize(Handler &h, const int version)
  701. {
  702. h & src & dst & count;
  703. }
  704. };
  705. typedef si32 TArtPos;
  706. struct ArtifactLocation
  707. {
  708. ConstTransitivePtr<CGHeroInstance> hero;
  709. TArtPos slot;
  710. ArtifactLocation()
  711. {
  712. slot = -1;
  713. }
  714. ArtifactLocation(const CGHeroInstance *Hero, TArtPos Slot)
  715. {
  716. hero = const_cast<CGHeroInstance*>(Hero); //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
  717. slot = Slot;
  718. }
  719. DLL_EXPORT const CArtifactInstance *getArt() const;
  720. DLL_EXPORT CArtifactInstance *getArt();
  721. DLL_EXPORT const ArtSlotInfo *getSlot() const;
  722. template <typename Handler> void serialize(Handler &h, const int version)
  723. {
  724. h & hero & slot;
  725. }
  726. };
  727. struct PutArtifact : CArtifactOperationPack //526
  728. {
  729. ArtifactLocation al;
  730. ConstTransitivePtr<CArtifactInstance> art;
  731. void applyCl(CClient *cl);
  732. DLL_EXPORT void applyGs(CGameState *gs);
  733. template <typename Handler> void serialize(Handler &h, const int version)
  734. {
  735. h & al & art;
  736. }
  737. };
  738. struct EraseArtifact : CArtifactOperationPack //527
  739. {
  740. ArtifactLocation al;
  741. void applyCl(CClient *cl);
  742. DLL_EXPORT void applyGs(CGameState *gs);
  743. template <typename Handler> void serialize(Handler &h, const int version)
  744. {
  745. h & al;
  746. }
  747. };
  748. struct MoveArtifact : CArtifactOperationPack //528
  749. {
  750. ArtifactLocation src, dst;
  751. void applyCl(CClient *cl);
  752. DLL_EXPORT void applyGs(CGameState *gs);
  753. template <typename Handler> void serialize(Handler &h, const int version)
  754. {
  755. h & src & dst;
  756. }
  757. };
  758. struct AssembledArtifact : CArtifactOperationPack //529
  759. {
  760. ArtifactLocation al; //where assembly will be put
  761. CArtifact *builtArt;
  762. //std::vector<CArtifactInstance *> constituents;
  763. void applyCl(CClient *cl);
  764. DLL_EXPORT void applyGs(CGameState *gs);
  765. template <typename Handler> void serialize(Handler &h, const int version)
  766. {
  767. h & al & builtArt/* & constituents*/;
  768. }
  769. };
  770. struct DisassembledArtifact : CArtifactOperationPack //530
  771. {
  772. ArtifactLocation al;
  773. void applyCl(CClient *cl);
  774. DLL_EXPORT void applyGs(CGameState *gs);
  775. template <typename Handler> void serialize(Handler &h, const int version)
  776. {
  777. h & al;
  778. }
  779. };
  780. struct HeroVisit : CPackForClient //531
  781. {
  782. const CGHeroInstance *hero;
  783. const CGObjectInstance *obj;
  784. bool starting; //false -> ending
  785. void applyCl(CClient *cl);
  786. DLL_EXPORT void applyGs(CGameState *gs);
  787. template <typename Handler> void serialize(Handler &h, const int version)
  788. {
  789. h & hero & obj & starting;
  790. }
  791. };
  792. struct NewTurn : public CPackForClient //101
  793. {
  794. enum weekType {NORMAL, DOUBLE_GROWTH, BONUS_GROWTH, DEITYOFFIRE, PLAGUE, CUSTOM, NO_ACTION, NONE};
  795. DLL_EXPORT void applyGs(CGameState *gs);
  796. struct Hero
  797. {
  798. ui32 id, move, mana; //id is a general serial id
  799. template <typename Handler> void serialize(Handler &h, const int version)
  800. {
  801. h & id & move & mana;
  802. }
  803. bool operator<(const Hero&h)const{return id < h.id;}
  804. };
  805. std::set<Hero> heroes; //updates movement and mana points
  806. //std::vector<SetResources> res;//resource list
  807. std::map<ui8, TResources> res; //player ID => resource value[res_id]
  808. std::vector<SetAvailableCreatures> cres;//creatures to be placed in towns
  809. ui32 day;
  810. bool resetBuilded;
  811. ui8 specialWeek; //weekType
  812. TCreature creatureid; //for creature weeks
  813. NewTurn(){type = 101;};
  814. template <typename Handler> void serialize(Handler &h, const int version)
  815. {
  816. h & heroes & cres & res & day & resetBuilded & specialWeek & creatureid;
  817. }
  818. };
  819. struct Component : public CPack //2002 helper for object scrips informations
  820. {
  821. enum EComponentType {PRIM_SKILL, SEC_SKILL, RESOURCE, CREATURE, ARTIFACT, EXPERIENCE, SPELL, MORALE=8, LUCK, BUILDING, HERO, FLAG};
  822. ui16 id, subtype; //id uses ^^^ enums, when id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels)
  823. si32 val; // + give; - take
  824. si16 when; // 0 - now; +x - within x days; -x - per x days
  825. template <typename Handler> void serialize(Handler &h, const int version)
  826. {
  827. h & id & subtype & val & when;
  828. }
  829. Component()
  830. {
  831. type = 2002;
  832. }
  833. DLL_EXPORT explicit Component(const CStackBasicDescriptor &stack);
  834. Component(ui16 Type, ui16 Subtype, si32 Val, si16 When)
  835. :id(Type),subtype(Subtype),val(Val),when(When)
  836. {
  837. type = 2002;
  838. }
  839. };
  840. struct InfoWindow : public CPackForClient //103 - displays simple info window
  841. {
  842. void applyCl(CClient *cl);
  843. MetaString text;
  844. std::vector<Component> components;
  845. ui8 player;
  846. ui16 soundID;
  847. template <typename Handler> void serialize(Handler &h, const int version)
  848. {
  849. h & text & components & player & soundID;
  850. }
  851. InfoWindow()
  852. {
  853. type = 103;
  854. soundID = 0;
  855. }
  856. };
  857. namespace ObjProperty
  858. {
  859. //TODO: move non general properties out to the appropriate objs classes
  860. enum {OWNER = 1, BLOCKVIS = 2, PRIMARY_STACK_COUNT = 3, VISITORS = 4, VISITED = 5, ID = 6, AVAILABLE_CREATURE = 7, SUBID = 8,
  861. MONSTER_COUNT = 10, MONSTER_POWER = 11, MONSTER_EXP = 12};
  862. }
  863. struct SetObjectProperty : public CPackForClient//1001
  864. {
  865. DLL_EXPORT void applyGs(CGameState *gs);
  866. void applyCl(CClient *cl);
  867. ui32 id;
  868. ui8 what; //1 - owner; 2 - blockvis; 3 - first stack count; 4 - visitors; 5 - visited; 6 - ID (if 34 then also def is replaced)
  869. ui32 val;
  870. SetObjectProperty(){type = 1001;};
  871. SetObjectProperty(ui32 ID, ui8 What, ui32 Val):id(ID),what(What),val(Val){type = 1001;};
  872. template <typename Handler> void serialize(Handler &h, const int version)
  873. {
  874. h & id & what & val;
  875. }
  876. };
  877. struct SetHoverName : public CPackForClient//1002
  878. {
  879. DLL_EXPORT void applyGs(CGameState *gs);
  880. ui32 id;
  881. MetaString name;
  882. SetHoverName(){type = 1002;};
  883. SetHoverName(ui32 ID, MetaString& Name):id(ID),name(Name){type = 1002;};
  884. template <typename Handler> void serialize(Handler &h, const int version)
  885. {
  886. h & id & name;
  887. }
  888. };
  889. struct HeroLevelUp : public Query//2000
  890. {
  891. void applyCl(CClient *cl);
  892. DLL_EXPORT void applyGs(CGameState *gs);
  893. si32 heroid;
  894. ui8 primskill, level;
  895. std::vector<ui16> skills;
  896. HeroLevelUp(){type = 2000;};
  897. template <typename Handler> void serialize(Handler &h, const int version)
  898. {
  899. h & id & heroid & primskill & level & skills;
  900. }
  901. };
  902. struct TradeComponents : public CPackForClient, public CPackForServer
  903. {
  904. ///used to handle info about components available in shops
  905. void applyCl(CClient *cl);
  906. DLL_EXPORT void applyGs(CGameState *gs);
  907. si32 heroid;
  908. ui32 objectid;
  909. std::map<ui16, Component> available, chosen, bought;
  910. template <typename Handler> void serialize(Handler &h, const int version)
  911. {
  912. h & heroid & objectid & available & chosen & bought;
  913. }
  914. };
  915. //A dialog that requires making decision by player - it may contain components to choose between or has yes/no options
  916. //Client responds with QueryReply, where answer: 0 - cancel pressed, choice doesn't matter; 1/2/... - first/second/... component selected and OK pressed
  917. //Until sending reply player won't be allowed to take any actions
  918. struct BlockingDialog : public Query//2003
  919. {
  920. enum {ALLOW_CANCEL = 1, SELECTION = 2};
  921. void applyCl(CClient *cl);
  922. MetaString text;
  923. std::vector<Component> components;
  924. ui8 player;
  925. ui8 flags;
  926. ui16 soundID;
  927. bool cancel() const
  928. {
  929. return flags & ALLOW_CANCEL;
  930. }
  931. bool selection() const
  932. {
  933. return flags & SELECTION;
  934. }
  935. BlockingDialog(bool yesno, bool Selection)
  936. {
  937. type = 2003;
  938. flags = 0;
  939. soundID = 0;
  940. if(yesno) flags |= ALLOW_CANCEL;
  941. if(Selection) flags |= SELECTION;
  942. }
  943. BlockingDialog()
  944. {
  945. type = 2003;
  946. flags = 0;
  947. soundID = 0;
  948. };
  949. template <typename Handler> void serialize(Handler &h, const int version)
  950. {
  951. h & id & text & components & player & flags & soundID;
  952. }
  953. };
  954. struct GarrisonDialog : public Query//2004
  955. {
  956. GarrisonDialog(){type = 2004;}
  957. void applyCl(CClient *cl);
  958. si32 objid, hid;
  959. bool removableUnits;
  960. template <typename Handler> void serialize(Handler &h, const int version)
  961. {
  962. h & id & objid & hid & removableUnits;
  963. }
  964. };
  965. struct BattleInfo;
  966. struct BattleStart : public CPackForClient//3000
  967. {
  968. BattleStart(){type = 3000;};
  969. void applyCl(CClient *cl);
  970. DLL_EXPORT void applyGs(CGameState *gs);
  971. BattleInfo * info;
  972. template <typename Handler> void serialize(Handler &h, const int version)
  973. {
  974. h & info;
  975. }
  976. };
  977. struct BattleNextRound : public CPackForClient//3001
  978. {
  979. BattleNextRound(){type = 3001;};
  980. void applyFirstCl(CClient *cl);
  981. void applyCl(CClient *cl);
  982. DLL_EXPORT void applyGs( CGameState *gs );
  983. si32 round;
  984. template <typename Handler> void serialize(Handler &h, const int version)
  985. {
  986. h & round;
  987. }
  988. };
  989. struct BattleSetActiveStack : public CPackForClient//3002
  990. {
  991. BattleSetActiveStack(){type = 3002;};
  992. void applyCl(CClient *cl);
  993. DLL_EXPORT void applyGs(CGameState *gs);
  994. ui32 stack;
  995. template <typename Handler> void serialize(Handler &h, const int version)
  996. {
  997. h & stack;
  998. }
  999. };
  1000. struct BattleResult : public CPackForClient//3003
  1001. {
  1002. BattleResult(){type = 3003;};
  1003. void applyFirstCl(CClient *cl);
  1004. void applyGs(CGameState *gs);
  1005. ui8 result; //0 - normal victory; 1 - escape; 2 - surrender
  1006. ui8 winner; //0 - attacker, 1 - defender, [2 - draw (should be possible?)]
  1007. std::map<ui32,si32> casualties[2]; //first => casualties of attackers - map crid => number
  1008. expType exp[2]; //exp for attacker and defender
  1009. std::set<ui32> artifacts; //artifacts taken from loser to winner
  1010. template <typename Handler> void serialize(Handler &h, const int version)
  1011. {
  1012. h & result & winner & casualties[0] & casualties[1] & exp & artifacts;
  1013. }
  1014. };
  1015. struct BattleStackMoved : public CPackForClient//3004
  1016. {
  1017. ui32 stack;
  1018. THex tile;
  1019. ui8 ending, distance, teleporting;
  1020. BattleStackMoved(){type = 3004;};
  1021. void applyFirstCl(CClient *cl);
  1022. void applyGs(CGameState *gs);
  1023. template <typename Handler> void serialize(Handler &h, const int version)
  1024. {
  1025. h & stack & tile & ending & distance;
  1026. }
  1027. };
  1028. struct StacksHealedOrResurrected : public CPackForClient //3013
  1029. {
  1030. StacksHealedOrResurrected(){type = 3013;}
  1031. DLL_EXPORT void applyGs(CGameState *gs);
  1032. void applyCl(CClient *cl);
  1033. struct HealInfo
  1034. {
  1035. ui32 stackID;
  1036. ui32 healedHP;
  1037. ui8 lowLevelResurrection; //in case this stack is resurrected by this heal, it will be marked as SUMMONED
  1038. template <typename Handler> void serialize(Handler &h, const int version)
  1039. {
  1040. h & stackID & healedHP & lowLevelResurrection;
  1041. }
  1042. };
  1043. std::vector<HealInfo> healedStacks;
  1044. ui8 lifeDrain; //if true, this heal is an effect of life drain
  1045. ui8 tentHealing; //if true, than it's healing via First Aid Tent
  1046. si32 drainedFrom; //if life drain - then stack life was drain from, if tentHealing - stack that is a healer
  1047. template <typename Handler> void serialize(Handler &h, const int version)
  1048. {
  1049. h & healedStacks & lifeDrain & tentHealing & drainedFrom;
  1050. }
  1051. };
  1052. struct BattleStackAttacked : public CPackForClient//3005
  1053. {
  1054. BattleStackAttacked(){flags = 0; type = 3005;};
  1055. void applyCl(CClient *cl);
  1056. DLL_EXPORT void applyGs(CGameState *gs);
  1057. ui32 stackAttacked, attackerID;
  1058. ui32 newAmount, newHP, killedAmount, damageAmount;
  1059. enum EFlags {KILLED = 1, EFFECT = 2, SECONDARY = 4};
  1060. ui8 flags; //uses EFlags (above)
  1061. ui32 effect; //set only if flag EFFECT is set
  1062. std::vector<StacksHealedOrResurrected> healedStacks; //used when life drain
  1063. bool killed() const//if target stack was killed
  1064. {
  1065. return flags & KILLED;
  1066. }
  1067. bool isEffect() const//if stack has been attacked by a spell
  1068. {
  1069. return flags & EFFECT;
  1070. }
  1071. bool isSecondary() const//if stack was not a primary target (receives no spell effects)
  1072. {
  1073. return flags & SECONDARY;
  1074. }
  1075. bool lifeDrain() const //if this attack involves life drain effect
  1076. {
  1077. return healedStacks.size() > 0;
  1078. }
  1079. template <typename Handler> void serialize(Handler &h, const int version)
  1080. {
  1081. h & stackAttacked & attackerID & newAmount & newHP & flags & killedAmount & damageAmount & effect
  1082. & healedStacks;
  1083. }
  1084. bool operator<(const BattleStackAttacked &b) const
  1085. {
  1086. return stackAttacked < b.stackAttacked;
  1087. }
  1088. };
  1089. struct BattleAttack : public CPackForClient//3006
  1090. {
  1091. BattleAttack(){flags = 0; type = 3006;};
  1092. void applyFirstCl(CClient *cl);
  1093. DLL_EXPORT void applyGs(CGameState *gs);
  1094. void applyCl(CClient *cl);
  1095. std::vector<BattleStackAttacked> bsa;
  1096. ui32 stackAttacking;
  1097. ui8 flags; //uses Eflags (below)
  1098. enum EFlags{SHOT = 1, COUNTER = 2, LUCKY = 4, UNLUCKY = 8, BALLISTA_DOUBLE_DMG = 16};
  1099. bool shot() const//distance attack - decrease number of shots
  1100. {
  1101. return flags & SHOT;
  1102. }
  1103. bool counter() const//is it counterattack?
  1104. {
  1105. return flags & COUNTER;
  1106. }
  1107. bool lucky() const
  1108. {
  1109. return flags & LUCKY;
  1110. }
  1111. bool unlucky() const
  1112. {
  1113. //TODO: support?
  1114. return flags & UNLUCKY;
  1115. }
  1116. bool ballistaDoubleDmg() const //if it's ballista attack and does double dmg
  1117. {
  1118. return flags & BALLISTA_DOUBLE_DMG;
  1119. }
  1120. //bool killed() //if target stack was killed
  1121. //{
  1122. // return bsa.killed();
  1123. //}
  1124. template <typename Handler> void serialize(Handler &h, const int version)
  1125. {
  1126. h & bsa & stackAttacking & flags;
  1127. }
  1128. };
  1129. struct StartAction : public CPackForClient//3007
  1130. {
  1131. StartAction(){type = 3007;};
  1132. StartAction(const BattleAction &act){ba = act; type = 3007;};
  1133. void applyFirstCl(CClient *cl);
  1134. DLL_EXPORT void applyGs(CGameState *gs);
  1135. BattleAction ba;
  1136. template <typename Handler> void serialize(Handler &h, const int version)
  1137. {
  1138. h & ba;
  1139. }
  1140. };
  1141. struct EndAction : public CPackForClient//3008
  1142. {
  1143. EndAction(){type = 3008;};
  1144. void applyCl(CClient *cl);
  1145. template <typename Handler> void serialize(Handler &h, const int version)
  1146. {
  1147. }
  1148. };
  1149. struct BattleSpellCast : public CPackForClient//3009
  1150. {
  1151. BattleSpellCast(){type = 3009;};
  1152. DLL_EXPORT void applyGs(CGameState *gs);
  1153. void applyCl(CClient *cl);
  1154. si32 dmgToDisplay; //this amount will be displayed as amount of damage dealt by spell
  1155. ui8 side; //which hero did cast spell: 0 - attacker, 1 - defender
  1156. ui32 id; //id of spell
  1157. ui8 skill; //caster's skill level
  1158. THex tile; //destination tile (may not be set in some global/mass spells
  1159. std::vector<ui32> resisted; //ids of creatures that resisted this spell
  1160. std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure)
  1161. TCreature attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact)
  1162. ui8 castedByHero; //if true - spell has been casted by hero, otherwise by a creature
  1163. template <typename Handler> void serialize(Handler &h, const int version)
  1164. {
  1165. h & dmgToDisplay & side & id & skill & tile & resisted & affectedCres & attackerType & castedByHero;
  1166. }
  1167. };
  1168. struct SetStackEffect : public CPackForClient //3010
  1169. {
  1170. SetStackEffect(){type = 3010;};
  1171. DLL_EXPORT void applyGs(CGameState *gs);
  1172. void applyCl(CClient *cl);
  1173. std::vector<ui32> stacks; //affected stacks (IDs)
  1174. std::vector<Bonus> effect; //bonuses to apply
  1175. std::vector<std::pair<ui32, Bonus> > uniqueBonuses; //bonuses per single stack
  1176. template <typename Handler> void serialize(Handler &h, const int version)
  1177. {
  1178. h & stacks & effect & uniqueBonuses;
  1179. }
  1180. };
  1181. struct StacksInjured : public CPackForClient //3011
  1182. {
  1183. StacksInjured(){type = 3011;}
  1184. DLL_EXPORT void applyGs(CGameState *gs);
  1185. void applyCl(CClient *cl);
  1186. std::vector<BattleStackAttacked> stacks;
  1187. template <typename Handler> void serialize(Handler &h, const int version)
  1188. {
  1189. h & stacks;
  1190. }
  1191. };
  1192. struct BattleResultsApplied : public CPackForClient //3012
  1193. {
  1194. BattleResultsApplied(){type = 3012;}
  1195. ui8 player1, player2;
  1196. void applyCl(CClient *cl);
  1197. template <typename Handler> void serialize(Handler &h, const int version)
  1198. {
  1199. h & player1 & player2;
  1200. }
  1201. };
  1202. struct ObstaclesRemoved : public CPackForClient //3014
  1203. {
  1204. ObstaclesRemoved(){type = 3014;}
  1205. DLL_EXPORT void applyGs(CGameState *gs);
  1206. void applyCl(CClient *cl);
  1207. std::set<si32> obstacles; //uniqueIDs of removed obstacles
  1208. template <typename Handler> void serialize(Handler &h, const int version)
  1209. {
  1210. h & obstacles;
  1211. }
  1212. };
  1213. struct CatapultAttack : public CPackForClient //3015
  1214. {
  1215. CatapultAttack(){type = 3015;}
  1216. DLL_EXPORT void applyGs(CGameState *gs);
  1217. void applyCl(CClient *cl);
  1218. std::set< std::pair< std::pair< ui8, si16 >, ui8> > attackedParts; // < <attackedPartOfWall, attacked hex >, damageDealt>
  1219. //attackedPartOfWall; //[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate;
  1220. //damageDealt;
  1221. int attacker; //if -1, then a spell caused this
  1222. template <typename Handler> void serialize(Handler &h, const int version)
  1223. {
  1224. h & attackedParts & attacker;
  1225. }
  1226. };
  1227. struct BattleStacksRemoved : public CPackForClient //3016
  1228. {
  1229. BattleStacksRemoved(){type = 3016;}
  1230. DLL_EXPORT void applyGs(CGameState *gs);
  1231. void applyCl(CClient *cl);
  1232. std::set<ui32> stackIDs; //IDs of removed stacks
  1233. template <typename Handler> void serialize(Handler &h, const int version)
  1234. {
  1235. h & stackIDs;
  1236. }
  1237. };
  1238. struct ShowInInfobox : public CPackForClient //107
  1239. {
  1240. ShowInInfobox(){type = 107;};
  1241. ui8 player;
  1242. Component c;
  1243. MetaString text;
  1244. void applyCl(CClient *cl);
  1245. template <typename Handler> void serialize(Handler &h, const int version)
  1246. {
  1247. h & player & c & text;
  1248. }
  1249. };
  1250. struct AdvmapSpellCast : public CPackForClient //108
  1251. {
  1252. AdvmapSpellCast(){type = 108;}
  1253. const CGHeroInstance * caster;
  1254. si32 spellID;
  1255. void applyCl(CClient *cl);
  1256. template <typename Handler> void serialize(Handler &h, const int version)
  1257. {
  1258. h & caster & spellID;
  1259. }
  1260. };
  1261. /***********************************************************************************************************/
  1262. struct CommitPackage : public CPackForServer
  1263. {
  1264. bool freePack; //for local usage, DO NOT serialize
  1265. bool applyGh(CGameHandler *gh);
  1266. CPackForClient *packToCommit;
  1267. CommitPackage()
  1268. {
  1269. freePack = true;
  1270. }
  1271. ~CommitPackage()
  1272. {
  1273. if(freePack)
  1274. delete packToCommit;
  1275. }
  1276. template <typename Handler> void serialize(Handler &h, const int version)
  1277. {
  1278. h & packToCommit;
  1279. }
  1280. };
  1281. struct CloseServer : public CPackForServer
  1282. {
  1283. bool applyGh(CGameHandler *gh);
  1284. template <typename Handler> void serialize(Handler &h, const int version)
  1285. {}
  1286. };
  1287. struct EndTurn : public CPackForServer
  1288. {
  1289. bool applyGh(CGameHandler *gh);
  1290. template <typename Handler> void serialize(Handler &h, const int version)
  1291. {}
  1292. };
  1293. struct DismissHero : public CPackForServer
  1294. {
  1295. DismissHero(){};
  1296. DismissHero(si32 HID) : hid(HID) {};
  1297. si32 hid;
  1298. bool applyGh(CGameHandler *gh);
  1299. template <typename Handler> void serialize(Handler &h, const int version)
  1300. {
  1301. h & hid;
  1302. }
  1303. };
  1304. struct MoveHero : public CPackForServer
  1305. {
  1306. MoveHero(){};
  1307. MoveHero(const int3 &Dest, si32 HID) : dest(Dest), hid(HID){};
  1308. int3 dest;
  1309. si32 hid;
  1310. bool applyGh(CGameHandler *gh);
  1311. template <typename Handler> void serialize(Handler &h, const int version)
  1312. {
  1313. h & dest & hid;
  1314. }
  1315. };
  1316. struct CastleTeleportHero : public CPackForServer
  1317. {
  1318. CastleTeleportHero(){};
  1319. CastleTeleportHero(const si32 HID, si32 Dest, ui8 Source ) : dest(Dest), hid(HID), source(Source){};
  1320. si32 dest;
  1321. si32 hid;
  1322. si8 source;//who give teleporting, 1=castle gate
  1323. bool applyGh(CGameHandler *gh);
  1324. template <typename Handler> void serialize(Handler &h, const int version)
  1325. {
  1326. h & dest & hid;
  1327. }
  1328. };
  1329. struct ArrangeStacks : public CPackForServer
  1330. {
  1331. ArrangeStacks(){};
  1332. ArrangeStacks(ui8 W, ui8 P1, ui8 P2, si32 ID1, si32 ID2, si32 VAL)
  1333. :what(W),p1(P1),p2(P2),id1(ID1),id2(ID2),val(VAL) {};
  1334. ui8 what; //1 - swap; 2 - merge; 3 - split
  1335. ui8 p1, p2; //positions of first and second stack
  1336. si32 id1, id2; //ids of objects with garrison
  1337. si32 val;
  1338. bool applyGh(CGameHandler *gh);
  1339. template <typename Handler> void serialize(Handler &h, const int version)
  1340. {
  1341. h & what & p1 & p2 & id1 & id2 & val;
  1342. }
  1343. };
  1344. struct DisbandCreature : public CPackForServer
  1345. {
  1346. DisbandCreature(){};
  1347. DisbandCreature(ui8 Pos, si32 ID):pos(Pos),id(ID){};
  1348. ui8 pos; //stack pos
  1349. si32 id; //object id
  1350. bool applyGh(CGameHandler *gh);
  1351. template <typename Handler> void serialize(Handler &h, const int version)
  1352. {
  1353. h & pos & id;
  1354. }
  1355. };
  1356. struct BuildStructure : public CPackForServer
  1357. {
  1358. BuildStructure(){};
  1359. BuildStructure(si32 TID, si32 BID):bid(BID),tid(TID){};
  1360. si32 bid, tid; //structure and town ids
  1361. bool applyGh(CGameHandler *gh);
  1362. template <typename Handler> void serialize(Handler &h, const int version)
  1363. {
  1364. h & tid & bid;
  1365. }
  1366. };
  1367. struct RazeStructure : public BuildStructure
  1368. {
  1369. RazeStructure(){};
  1370. //RazeStructure(si32 TID, si32 BID):bid(BID),tid(TID){};
  1371. bool applyGh(CGameHandler *gh);
  1372. };
  1373. struct RecruitCreatures : public CPackForServer
  1374. {
  1375. RecruitCreatures(){};
  1376. RecruitCreatures(si32 TID, si32 CRID, si32 Amount, si32 Level):tid(TID),crid(CRID),amount(Amount),level(Level){};
  1377. si32 tid; //town id
  1378. ui32 crid, amount;//creature ID and amount
  1379. si32 level;//dwelling level to buy from, -1 if any
  1380. bool applyGh(CGameHandler *gh);
  1381. template <typename Handler> void serialize(Handler &h, const int version)
  1382. {
  1383. h & tid & crid & amount & level;
  1384. }
  1385. };
  1386. struct UpgradeCreature : public CPackForServer
  1387. {
  1388. UpgradeCreature(){};
  1389. UpgradeCreature(ui8 Pos, si32 ID, si32 CRID):pos(Pos),id(ID), cid(CRID){};
  1390. ui8 pos; //stack pos
  1391. si32 id; //object id
  1392. si32 cid; //id of type to which we want make upgrade
  1393. bool applyGh(CGameHandler *gh);
  1394. template <typename Handler> void serialize(Handler &h, const int version)
  1395. {
  1396. h & pos & id & cid;
  1397. }
  1398. };
  1399. struct GarrisonHeroSwap : public CPackForServer
  1400. {
  1401. GarrisonHeroSwap(){};
  1402. GarrisonHeroSwap(si32 TID):tid(TID){};
  1403. si32 tid;
  1404. bool applyGh(CGameHandler *gh);
  1405. template <typename Handler> void serialize(Handler &h, const int version)
  1406. {
  1407. h & tid;
  1408. }
  1409. };
  1410. struct ExchangeArtifacts : public CPackForServer
  1411. {
  1412. ExchangeArtifacts(){};
  1413. ExchangeArtifacts(si32 H1, si32 H2, ui16 S1, ui16 S2)
  1414. :hid1(H1),hid2(H2),slot1(S1),slot2(S2){};
  1415. si32 hid1, hid2;
  1416. ui16 slot1, slot2;
  1417. bool applyGh(CGameHandler *gh);
  1418. template <typename Handler> void serialize(Handler &h, const int version)
  1419. {
  1420. h & hid1 & hid2 & slot1 & slot2;
  1421. }
  1422. };
  1423. struct AssembleArtifacts : public CPackForServer
  1424. {
  1425. AssembleArtifacts(){};
  1426. AssembleArtifacts(si32 _heroID, ui16 _artifactSlot, bool _assemble, ui32 _assembleTo)
  1427. : heroID(_heroID), artifactSlot(_artifactSlot), assemble(_assemble), assembleTo(_assembleTo){};
  1428. si32 heroID;
  1429. ui16 artifactSlot;
  1430. bool assemble; // True to assemble artifact, false to disassemble.
  1431. ui32 assembleTo; // Artifact to assemble into.
  1432. bool applyGh(CGameHandler *gh);
  1433. template <typename Handler> void serialize(Handler &h, const int version)
  1434. {
  1435. h & heroID & artifactSlot & assemble & assembleTo;
  1436. }
  1437. };
  1438. struct BuyArtifact : public CPackForServer
  1439. {
  1440. BuyArtifact(){};
  1441. BuyArtifact(si32 HID, si32 AID):hid(HID),aid(AID){};
  1442. si32 hid, aid; //hero and artifact id
  1443. bool applyGh(CGameHandler *gh);
  1444. template <typename Handler> void serialize(Handler &h, const int version)
  1445. {
  1446. h & hid & aid;
  1447. }
  1448. };
  1449. struct TradeOnMarketplace : public CPackForServer
  1450. {
  1451. TradeOnMarketplace(){};
  1452. const CGObjectInstance *market;
  1453. const CGHeroInstance *hero; //needed when trading artifacts / creatures
  1454. ui8 mode;//enum EMarketMode
  1455. ui32 r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?]
  1456. ui32 val; //units of sold resource
  1457. bool applyGh(CGameHandler *gh);
  1458. template <typename Handler> void serialize(Handler &h, const int version)
  1459. {
  1460. h & market & hero & mode & r1 & r2 & val;
  1461. }
  1462. };
  1463. struct SetFormation : public CPackForServer
  1464. {
  1465. SetFormation(){};
  1466. SetFormation(si32 HID, ui8 Formation):hid(HID),formation(Formation){};
  1467. si32 hid;
  1468. ui8 formation;
  1469. bool applyGh(CGameHandler *gh);
  1470. template <typename Handler> void serialize(Handler &h, const int version)
  1471. {
  1472. h & hid & formation;
  1473. }
  1474. };
  1475. struct HireHero : public CPackForServer
  1476. {
  1477. HireHero(){};
  1478. HireHero(si32 HID, si32 TID):hid(HID),tid(TID){};
  1479. si32 hid, tid; //available hero serial and town (tavern) id
  1480. ui8 player;
  1481. bool applyGh(CGameHandler *gh);
  1482. template <typename Handler> void serialize(Handler &h, const int version)
  1483. {
  1484. h & hid & tid & player;
  1485. }
  1486. };
  1487. struct BuildBoat : public CPackForServer
  1488. {
  1489. BuildBoat(){};
  1490. si32 objid; //where player wants to buy a boat
  1491. bool applyGh(CGameHandler *gh);
  1492. template <typename Handler> void serialize(Handler &h, const int version)
  1493. {
  1494. h & objid;
  1495. }
  1496. };
  1497. struct QueryReply : public CPackForServer
  1498. {
  1499. QueryReply(){type = 6000;};
  1500. QueryReply(ui32 QID, ui32 Answer):qid(QID),answer(Answer){type = 6000;};
  1501. ui32 qid, answer; //hero and artifact id
  1502. bool applyGh(CGameHandler *gh);
  1503. template <typename Handler> void serialize(Handler &h, const int version)
  1504. {
  1505. h & qid & answer;
  1506. }
  1507. };
  1508. struct MakeAction : public CPackForServer
  1509. {
  1510. MakeAction(){};
  1511. MakeAction(const BattleAction &BA):ba(BA){};
  1512. BattleAction ba;
  1513. bool applyGh(CGameHandler *gh);
  1514. template <typename Handler> void serialize(Handler &h, const int version)
  1515. {
  1516. h & ba;
  1517. }
  1518. };
  1519. struct MakeCustomAction : public CPackForServer
  1520. {
  1521. MakeCustomAction(){};
  1522. MakeCustomAction(const BattleAction &BA):ba(BA){};
  1523. BattleAction ba;
  1524. bool applyGh(CGameHandler *gh);
  1525. template <typename Handler> void serialize(Handler &h, const int version)
  1526. {
  1527. h & ba;
  1528. }
  1529. };
  1530. struct DigWithHero : public CPackForServer
  1531. {
  1532. DigWithHero(){}
  1533. si32 id; //digging hero id
  1534. bool applyGh(CGameHandler *gh);
  1535. template <typename Handler> void serialize(Handler &h, const int version)
  1536. {
  1537. h & id;
  1538. }
  1539. };
  1540. struct CastAdvSpell : public CPackForServer
  1541. {
  1542. CastAdvSpell(){}
  1543. si32 hid; //hero id
  1544. ui32 sid; //spell id
  1545. int3 pos; //selected tile (not always used)
  1546. bool applyGh(CGameHandler *gh);
  1547. template <typename Handler> void serialize(Handler &h, const int version)
  1548. {
  1549. h & hid & sid & pos;
  1550. }
  1551. };
  1552. /***********************************************************************************************************/
  1553. struct SaveGame : public CPackForClient, public CPackForServer
  1554. {
  1555. SaveGame(){};
  1556. SaveGame(const std::string &Fname) :fname(Fname){};
  1557. std::string fname;
  1558. void applyCl(CClient *cl);
  1559. void applyGs(CGameState *gs){};
  1560. bool applyGh(CGameHandler *gh);
  1561. template <typename Handler> void serialize(Handler &h, const int version)
  1562. {
  1563. h & fname;
  1564. }
  1565. };
  1566. struct PlayerMessage : public CPackForClient, public CPackForServer //513
  1567. {
  1568. PlayerMessage(){CPackForClient::type = 513;};
  1569. PlayerMessage(ui8 Player, const std::string &Text)
  1570. :player(Player),text(Text)
  1571. {CPackForClient::type = 513;};
  1572. void applyCl(CClient *cl);
  1573. void applyGs(CGameState *gs){};
  1574. bool applyGh(CGameHandler *gh);
  1575. ui8 player;
  1576. std::string text;
  1577. template <typename Handler> void serialize(Handler &h, const int version)
  1578. {
  1579. h & text & player;
  1580. }
  1581. };
  1582. struct SetSelection : public CPackForClient, public CPackForServer //514
  1583. {
  1584. SetSelection(){CPackForClient::type = 514;};
  1585. DLL_EXPORT void applyGs(CGameState *gs);
  1586. bool applyGh(CGameHandler *gh);
  1587. void applyCl(CClient *cl);
  1588. ui8 player;
  1589. ui32 id;
  1590. template <typename Handler> void serialize(Handler &h, const int version)
  1591. {
  1592. h & id & player;
  1593. }
  1594. };
  1595. struct CenterView : public CPackForClient//515
  1596. {
  1597. CenterView(){CPackForClient::type = 515;};
  1598. void applyCl(CClient *cl);
  1599. ui8 player;
  1600. int3 pos;
  1601. ui32 focusTime; //ms
  1602. template <typename Handler> void serialize(Handler &h, const int version)
  1603. {
  1604. h & pos & player & focusTime;
  1605. }
  1606. };
  1607. /***********************************************************************************************************/
  1608. struct CPackForSelectionScreen : public CPack
  1609. {
  1610. void apply(CSelectionScreen *selScreen){}; //that functions are implemented in CPreGame.cpp
  1611. };
  1612. class CPregamePackToPropagate : public CPackForSelectionScreen
  1613. {};
  1614. class CPregamePackToHost : public CPackForSelectionScreen
  1615. {};
  1616. struct ChatMessage : public CPregamePackToPropagate
  1617. {
  1618. std::string playerName, message;
  1619. void apply(CSelectionScreen *selScreen);
  1620. template <typename Handler> void serialize(Handler &h, const int version)
  1621. {
  1622. h & playerName & message;
  1623. }
  1624. };
  1625. struct QuitMenuWithoutStarting : public CPregamePackToPropagate
  1626. {
  1627. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1628. template <typename Handler> void serialize(Handler &h, const int version)
  1629. {}
  1630. };
  1631. struct PlayerJoined : public CPregamePackToHost
  1632. {
  1633. std::string playerName;
  1634. ui8 connectionID;
  1635. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1636. template <typename Handler> void serialize(Handler &h, const int version)
  1637. {
  1638. h & playerName & connectionID;
  1639. }
  1640. };
  1641. struct SelectMap : public CPregamePackToPropagate
  1642. {
  1643. const CMapInfo *mapInfo;
  1644. bool free;
  1645. SelectMap(const CMapInfo &src)
  1646. {
  1647. mapInfo = &src;
  1648. free = false;
  1649. }
  1650. SelectMap()
  1651. {
  1652. mapInfo = NULL;
  1653. free = true;
  1654. }
  1655. ~SelectMap()
  1656. {
  1657. if(free)
  1658. delete mapInfo;
  1659. }
  1660. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1661. template <typename Handler> void serialize(Handler &h, const int version)
  1662. {
  1663. h & mapInfo;
  1664. }
  1665. };
  1666. struct UpdateStartOptions : public CPregamePackToPropagate
  1667. {
  1668. StartInfo *options;
  1669. bool free;
  1670. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1671. UpdateStartOptions(StartInfo &src)
  1672. {
  1673. options = &src;
  1674. free = false;
  1675. }
  1676. UpdateStartOptions()
  1677. {
  1678. options = NULL;
  1679. free = true;
  1680. }
  1681. ~UpdateStartOptions()
  1682. {
  1683. if(free)
  1684. delete options;
  1685. }
  1686. template <typename Handler> void serialize(Handler &h, const int version)
  1687. {
  1688. h & options;
  1689. }
  1690. };
  1691. struct PregameGuiAction : public CPregamePackToPropagate
  1692. {
  1693. enum {NO_TAB, OPEN_OPTIONS, OPEN_SCENARIO_LIST};
  1694. ui8 action;
  1695. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1696. template <typename Handler> void serialize(Handler &h, const int version)
  1697. {
  1698. h & action;
  1699. }
  1700. };
  1701. struct RequestOptionsChange : public CPregamePackToHost
  1702. {
  1703. enum {TOWN, HERO, BONUS};
  1704. ui8 what;
  1705. si8 direction; //-1 or +1
  1706. ui8 playerID;
  1707. RequestOptionsChange(ui8 What, si8 Dir, ui8 Player)
  1708. :what(What), direction(Dir), playerID(Player)
  1709. {}
  1710. RequestOptionsChange(){}
  1711. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1712. template <typename Handler> void serialize(Handler &h, const int version)
  1713. {
  1714. h & what & direction & playerID;
  1715. }
  1716. };
  1717. struct PlayerLeft : public CPregamePackToPropagate
  1718. {
  1719. ui8 playerID;
  1720. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1721. template <typename Handler> void serialize(Handler &h, const int version)
  1722. {
  1723. h & playerID;
  1724. }
  1725. };
  1726. struct PlayersNames : public CPregamePackToPropagate
  1727. {
  1728. public:
  1729. std::map<ui32, std::string> playerNames;
  1730. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1731. template <typename Handler> void serialize(Handler &h, const int version)
  1732. {
  1733. h & playerNames;
  1734. }
  1735. };
  1736. struct StartWithCurrentSettings : public CPregamePackToPropagate
  1737. {
  1738. public:
  1739. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1740. template <typename Handler> void serialize(Handler &h, const int version)
  1741. {
  1742. //h & playerNames;
  1743. }
  1744. };
  1745. #endif //__NETPACKS_H__