NetPacks.h 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098
  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*> equipped, unequipped; //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, NO_ACTION};
  795. void applyCl(CClient *cl);
  796. DLL_EXPORT void applyGs(CGameState *gs);
  797. struct Hero
  798. {
  799. ui32 id, move, mana; //id is a general serial id
  800. template <typename Handler> void serialize(Handler &h, const int version)
  801. {
  802. h & id & move & mana;
  803. }
  804. bool operator<(const Hero&h)const{return id < h.id;}
  805. };
  806. std::set<Hero> heroes; //updates movement and mana points
  807. //std::vector<SetResources> res;//resource list
  808. std::map<ui8, TResources> res; //player ID => resource value[res_id]
  809. std::vector<SetAvailableCreatures> cres;//creatures to be placed in towns
  810. ui32 day;
  811. bool resetBuilded;
  812. ui8 specialWeek; //weekType
  813. TCreature creatureid; //for creature weeks
  814. NewTurn(){type = 101;};
  815. template <typename Handler> void serialize(Handler &h, const int version)
  816. {
  817. h & heroes & cres & res & day & resetBuilded & specialWeek & creatureid;
  818. }
  819. };
  820. struct Component : public CPack //2002 helper for object scrips informations
  821. {
  822. enum EComponentType {PRIM_SKILL, SEC_SKILL, RESOURCE, CREATURE, ARTIFACT, EXPERIENCE, SPELL, MORALE=8, LUCK, BUILDING, HERO, FLAG};
  823. ui16 id, subtype; //id uses ^^^ enums, when id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels)
  824. si32 val; // + give; - take
  825. si16 when; // 0 - now; +x - within x days; -x - per x days
  826. template <typename Handler> void serialize(Handler &h, const int version)
  827. {
  828. h & id & subtype & val & when;
  829. }
  830. Component()
  831. {
  832. type = 2002;
  833. }
  834. DLL_EXPORT explicit Component(const CStackBasicDescriptor &stack);
  835. Component(ui16 Type, ui16 Subtype, si32 Val, si16 When)
  836. :id(Type),subtype(Subtype),val(Val),when(When)
  837. {
  838. type = 2002;
  839. }
  840. };
  841. struct InfoWindow : public CPackForClient //103 - displays simple info window
  842. {
  843. void applyCl(CClient *cl);
  844. MetaString text;
  845. std::vector<Component> components;
  846. ui8 player;
  847. ui16 soundID;
  848. template <typename Handler> void serialize(Handler &h, const int version)
  849. {
  850. h & text & components & player & soundID;
  851. }
  852. InfoWindow()
  853. {
  854. type = 103;
  855. soundID = 0;
  856. }
  857. };
  858. namespace ObjProperty
  859. {
  860. //TODO: move non general properties out to the appropriate objs classes
  861. enum {OWNER = 1, BLOCKVIS = 2, PRIMARY_STACK_COUNT = 3, VISITORS = 4, VISITED = 5, ID = 6, AVAILABLE_CREATURE = 7, SUBID = 8,
  862. MONSTER_COUNT = 10, MONSTER_POWER = 11, MONSTER_EXP = 12, MONSTER_RESTORE_TYPE = 13};
  863. }
  864. struct SetObjectProperty : public CPackForClient//1001
  865. {
  866. DLL_EXPORT void applyGs(CGameState *gs);
  867. void applyCl(CClient *cl);
  868. ui32 id;
  869. ui8 what; //1 - owner; 2 - blockvis; 3 - first stack count; 4 - visitors; 5 - visited; 6 - ID (if 34 then also def is replaced)
  870. ui32 val;
  871. SetObjectProperty(){type = 1001;};
  872. SetObjectProperty(ui32 ID, ui8 What, ui32 Val):id(ID),what(What),val(Val){type = 1001;};
  873. template <typename Handler> void serialize(Handler &h, const int version)
  874. {
  875. h & id & what & val;
  876. }
  877. };
  878. struct SetHoverName : public CPackForClient//1002
  879. {
  880. DLL_EXPORT void applyGs(CGameState *gs);
  881. ui32 id;
  882. MetaString name;
  883. SetHoverName(){type = 1002;};
  884. SetHoverName(ui32 ID, MetaString& Name):id(ID),name(Name){type = 1002;};
  885. template <typename Handler> void serialize(Handler &h, const int version)
  886. {
  887. h & id & name;
  888. }
  889. };
  890. struct HeroLevelUp : public Query//2000
  891. {
  892. void applyCl(CClient *cl);
  893. DLL_EXPORT void applyGs(CGameState *gs);
  894. si32 heroid;
  895. ui8 primskill, level;
  896. std::vector<ui16> skills;
  897. HeroLevelUp(){type = 2000;};
  898. template <typename Handler> void serialize(Handler &h, const int version)
  899. {
  900. h & id & heroid & primskill & level & skills;
  901. }
  902. };
  903. struct TradeComponents : public CPackForClient, public CPackForServer
  904. {
  905. ///used to handle info about components available in shops
  906. void applyCl(CClient *cl);
  907. DLL_EXPORT void applyGs(CGameState *gs);
  908. si32 heroid;
  909. ui32 objectid;
  910. std::map<ui16, Component> available, chosen, bought;
  911. template <typename Handler> void serialize(Handler &h, const int version)
  912. {
  913. h & heroid & objectid & available & chosen & bought;
  914. }
  915. };
  916. //A dialog that requires making decision by player - it may contain components to choose between or has yes/no options
  917. //Client responds with QueryReply, where answer: 0 - cancel pressed, choice doesn't matter; 1/2/... - first/second/... component selected and OK pressed
  918. //Until sending reply player won't be allowed to take any actions
  919. struct BlockingDialog : public Query//2003
  920. {
  921. enum {ALLOW_CANCEL = 1, SELECTION = 2};
  922. void applyCl(CClient *cl);
  923. MetaString text;
  924. std::vector<Component> components;
  925. ui8 player;
  926. ui8 flags;
  927. ui16 soundID;
  928. bool cancel() const
  929. {
  930. return flags & ALLOW_CANCEL;
  931. }
  932. bool selection() const
  933. {
  934. return flags & SELECTION;
  935. }
  936. BlockingDialog(bool yesno, bool Selection)
  937. {
  938. type = 2003;
  939. flags = 0;
  940. soundID = 0;
  941. if(yesno) flags |= ALLOW_CANCEL;
  942. if(Selection) flags |= SELECTION;
  943. }
  944. BlockingDialog()
  945. {
  946. type = 2003;
  947. flags = 0;
  948. soundID = 0;
  949. };
  950. template <typename Handler> void serialize(Handler &h, const int version)
  951. {
  952. h & id & text & components & player & flags & soundID;
  953. }
  954. };
  955. struct GarrisonDialog : public Query//2004
  956. {
  957. GarrisonDialog(){type = 2004;}
  958. void applyCl(CClient *cl);
  959. si32 objid, hid;
  960. bool removableUnits;
  961. template <typename Handler> void serialize(Handler &h, const int version)
  962. {
  963. h & id & objid & hid & removableUnits;
  964. }
  965. };
  966. struct BattleInfo;
  967. struct BattleStart : public CPackForClient//3000
  968. {
  969. BattleStart(){type = 3000;};
  970. void applyCl(CClient *cl);
  971. DLL_EXPORT void applyGs(CGameState *gs);
  972. BattleInfo * info;
  973. template <typename Handler> void serialize(Handler &h, const int version)
  974. {
  975. h & info;
  976. }
  977. };
  978. struct BattleNextRound : public CPackForClient//3001
  979. {
  980. BattleNextRound(){type = 3001;};
  981. void applyFirstCl(CClient *cl);
  982. void applyCl(CClient *cl);
  983. DLL_EXPORT void applyGs( CGameState *gs );
  984. si32 round;
  985. template <typename Handler> void serialize(Handler &h, const int version)
  986. {
  987. h & round;
  988. }
  989. };
  990. struct BattleSetActiveStack : public CPackForClient//3002
  991. {
  992. BattleSetActiveStack(){type = 3002;};
  993. void applyCl(CClient *cl);
  994. DLL_EXPORT void applyGs(CGameState *gs);
  995. ui32 stack;
  996. template <typename Handler> void serialize(Handler &h, const int version)
  997. {
  998. h & stack;
  999. }
  1000. };
  1001. struct BattleResult : public CPackForClient//3003
  1002. {
  1003. BattleResult(){type = 3003;};
  1004. void applyFirstCl(CClient *cl);
  1005. void applyGs(CGameState *gs);
  1006. ui8 result; //0 - normal victory; 1 - escape; 2 - surrender
  1007. ui8 winner; //0 - attacker, 1 - defender, [2 - draw (should be possible?)]
  1008. std::map<ui32,si32> casualties[2]; //first => casualties of attackers - map crid => number
  1009. expType exp[2]; //exp for attacker and defender
  1010. std::set<ui32> artifacts; //artifacts taken from loser to winner
  1011. template <typename Handler> void serialize(Handler &h, const int version)
  1012. {
  1013. h & result & winner & casualties[0] & casualties[1] & exp & artifacts;
  1014. }
  1015. };
  1016. struct BattleStackMoved : public CPackForClient//3004
  1017. {
  1018. ui32 stack;
  1019. std::vector<THex> tilesToMove;
  1020. ui8 distance, teleporting;
  1021. BattleStackMoved(){type = 3004;};
  1022. void applyFirstCl(CClient *cl);
  1023. void applyGs(CGameState *gs);
  1024. template <typename Handler> void serialize(Handler &h, const int version)
  1025. {
  1026. h & stack & tilesToMove & distance;
  1027. }
  1028. };
  1029. struct StacksHealedOrResurrected : public CPackForClient //3013
  1030. {
  1031. StacksHealedOrResurrected(){type = 3013;}
  1032. DLL_EXPORT void applyGs(CGameState *gs);
  1033. void applyCl(CClient *cl);
  1034. struct HealInfo
  1035. {
  1036. ui32 stackID;
  1037. ui32 healedHP;
  1038. ui8 lowLevelResurrection; //in case this stack is resurrected by this heal, it will be marked as SUMMONED
  1039. template <typename Handler> void serialize(Handler &h, const int version)
  1040. {
  1041. h & stackID & healedHP & lowLevelResurrection;
  1042. }
  1043. };
  1044. std::vector<HealInfo> healedStacks;
  1045. ui8 lifeDrain; //if true, this heal is an effect of life drain
  1046. ui8 tentHealing; //if true, than it's healing via First Aid Tent
  1047. si32 drainedFrom; //if life drain - then stack life was drain from, if tentHealing - stack that is a healer
  1048. template <typename Handler> void serialize(Handler &h, const int version)
  1049. {
  1050. h & healedStacks & lifeDrain & tentHealing & drainedFrom;
  1051. }
  1052. };
  1053. struct BattleStackAttacked : public CPackForClient//3005
  1054. {
  1055. BattleStackAttacked(){flags = 0; type = 3005;};
  1056. void applyCl(CClient *cl);
  1057. DLL_EXPORT void applyGs(CGameState *gs);
  1058. ui32 stackAttacked, attackerID;
  1059. ui32 newAmount, newHP, killedAmount, damageAmount;
  1060. enum EFlags {KILLED = 1, EFFECT = 2, SECONDARY = 4, REBIRTH = 8};
  1061. ui8 flags; //uses EFlags (above)
  1062. ui32 effect; //set only if flag EFFECT is set
  1063. std::vector<StacksHealedOrResurrected> healedStacks; //used when life drain
  1064. bool killed() const//if target stack was killed
  1065. {
  1066. return flags & KILLED;
  1067. }
  1068. bool isEffect() const//if stack has been attacked by a spell
  1069. {
  1070. return flags & EFFECT;
  1071. }
  1072. bool isSecondary() const//if stack was not a primary target (receives no spell effects)
  1073. {
  1074. return flags & SECONDARY;
  1075. }
  1076. bool willRebirth() const//if stack was not a primary target (receives no spell effects)
  1077. {
  1078. return flags & REBIRTH;
  1079. }
  1080. bool lifeDrain() const //if this attack involves life drain effect
  1081. {
  1082. return healedStacks.size() > 0;
  1083. }
  1084. template <typename Handler> void serialize(Handler &h, const int version)
  1085. {
  1086. h & stackAttacked & attackerID & newAmount & newHP & flags & killedAmount & damageAmount & effect
  1087. & healedStacks;
  1088. }
  1089. bool operator<(const BattleStackAttacked &b) const
  1090. {
  1091. return stackAttacked < b.stackAttacked;
  1092. }
  1093. };
  1094. struct BattleAttack : public CPackForClient//3006
  1095. {
  1096. BattleAttack(){flags = 0; type = 3006;};
  1097. void applyFirstCl(CClient *cl);
  1098. DLL_EXPORT void applyGs(CGameState *gs);
  1099. void applyCl(CClient *cl);
  1100. std::vector<BattleStackAttacked> bsa;
  1101. ui32 stackAttacking;
  1102. ui8 flags; //uses Eflags (below)
  1103. enum EFlags{SHOT = 1, COUNTER = 2, LUCKY = 4, UNLUCKY = 8, BALLISTA_DOUBLE_DMG = 16, DEATH_BLOW = 32};
  1104. bool shot() const//distance attack - decrease number of shots
  1105. {
  1106. return flags & SHOT;
  1107. }
  1108. bool counter() const//is it counterattack?
  1109. {
  1110. return flags & COUNTER;
  1111. }
  1112. bool lucky() const
  1113. {
  1114. return flags & LUCKY;
  1115. }
  1116. bool unlucky() const
  1117. {
  1118. //TODO: support?
  1119. return flags & UNLUCKY;
  1120. }
  1121. bool ballistaDoubleDmg() const //if it's ballista attack and does double dmg
  1122. {
  1123. return flags & BALLISTA_DOUBLE_DMG;
  1124. }
  1125. bool deathBlow() const
  1126. {
  1127. return flags & DEATH_BLOW;
  1128. }
  1129. //bool killed() //if target stack was killed
  1130. //{
  1131. // return bsa.killed();
  1132. //}
  1133. template <typename Handler> void serialize(Handler &h, const int version)
  1134. {
  1135. h & bsa & stackAttacking & flags;
  1136. }
  1137. };
  1138. struct StartAction : public CPackForClient//3007
  1139. {
  1140. StartAction(){type = 3007;};
  1141. StartAction(const BattleAction &act){ba = act; type = 3007;};
  1142. void applyFirstCl(CClient *cl);
  1143. DLL_EXPORT void applyGs(CGameState *gs);
  1144. BattleAction ba;
  1145. template <typename Handler> void serialize(Handler &h, const int version)
  1146. {
  1147. h & ba;
  1148. }
  1149. };
  1150. struct EndAction : public CPackForClient//3008
  1151. {
  1152. EndAction(){type = 3008;};
  1153. void applyCl(CClient *cl);
  1154. template <typename Handler> void serialize(Handler &h, const int version)
  1155. {
  1156. }
  1157. };
  1158. struct BattleSpellCast : public CPackForClient//3009
  1159. {
  1160. BattleSpellCast(){type = 3009;};
  1161. DLL_EXPORT void applyGs(CGameState *gs);
  1162. void applyCl(CClient *cl);
  1163. si32 dmgToDisplay; //this amount will be displayed as amount of damage dealt by spell
  1164. ui8 side; //which hero did cast spell: 0 - attacker, 1 - defender
  1165. ui32 id; //id of spell
  1166. ui8 skill; //caster's skill level
  1167. THex tile; //destination tile (may not be set in some global/mass spells
  1168. std::vector<ui32> resisted; //ids of creatures that resisted this spell
  1169. std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure)
  1170. TCreature attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact)
  1171. ui8 castedByHero; //if true - spell has been casted by hero, otherwise by a creature
  1172. template <typename Handler> void serialize(Handler &h, const int version)
  1173. {
  1174. h & dmgToDisplay & side & id & skill & tile & resisted & affectedCres & attackerType & castedByHero;
  1175. }
  1176. };
  1177. struct SetStackEffect : public CPackForClient //3010
  1178. {
  1179. SetStackEffect(){type = 3010;};
  1180. DLL_EXPORT void applyGs(CGameState *gs);
  1181. void applyCl(CClient *cl);
  1182. std::vector<ui32> stacks; //affected stacks (IDs)
  1183. std::vector<Bonus> effect; //bonuses to apply
  1184. std::vector<std::pair<ui32, Bonus> > uniqueBonuses; //bonuses per single stack
  1185. template <typename Handler> void serialize(Handler &h, const int version)
  1186. {
  1187. h & stacks & effect & uniqueBonuses;
  1188. }
  1189. };
  1190. struct StacksInjured : public CPackForClient //3011
  1191. {
  1192. StacksInjured(){type = 3011;}
  1193. DLL_EXPORT void applyGs(CGameState *gs);
  1194. void applyCl(CClient *cl);
  1195. std::vector<BattleStackAttacked> stacks;
  1196. template <typename Handler> void serialize(Handler &h, const int version)
  1197. {
  1198. h & stacks;
  1199. }
  1200. };
  1201. struct BattleResultsApplied : public CPackForClient //3012
  1202. {
  1203. BattleResultsApplied(){type = 3012;}
  1204. ui8 player1, player2;
  1205. void applyCl(CClient *cl);
  1206. template <typename Handler> void serialize(Handler &h, const int version)
  1207. {
  1208. h & player1 & player2;
  1209. }
  1210. };
  1211. struct ObstaclesRemoved : public CPackForClient //3014
  1212. {
  1213. ObstaclesRemoved(){type = 3014;}
  1214. DLL_EXPORT void applyGs(CGameState *gs);
  1215. void applyCl(CClient *cl);
  1216. std::set<si32> obstacles; //uniqueIDs of removed obstacles
  1217. template <typename Handler> void serialize(Handler &h, const int version)
  1218. {
  1219. h & obstacles;
  1220. }
  1221. };
  1222. struct CatapultAttack : public CPackForClient //3015
  1223. {
  1224. CatapultAttack(){type = 3015;}
  1225. DLL_EXPORT void applyGs(CGameState *gs);
  1226. void applyCl(CClient *cl);
  1227. std::set< std::pair< std::pair< ui8, si16 >, ui8> > attackedParts; // < <attackedPartOfWall, attacked hex >, damageDealt>
  1228. //attackedPartOfWall; //[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate;
  1229. //damageDealt;
  1230. int attacker; //if -1, then a spell caused this
  1231. template <typename Handler> void serialize(Handler &h, const int version)
  1232. {
  1233. h & attackedParts & attacker;
  1234. }
  1235. };
  1236. struct BattleStacksRemoved : public CPackForClient //3016
  1237. {
  1238. BattleStacksRemoved(){type = 3016;}
  1239. DLL_EXPORT void applyGs(CGameState *gs);
  1240. void applyCl(CClient *cl);
  1241. std::set<ui32> stackIDs; //IDs of removed stacks
  1242. template <typename Handler> void serialize(Handler &h, const int version)
  1243. {
  1244. h & stackIDs;
  1245. }
  1246. };
  1247. struct ShowInInfobox : public CPackForClient //107
  1248. {
  1249. ShowInInfobox(){type = 107;};
  1250. ui8 player;
  1251. Component c;
  1252. MetaString text;
  1253. void applyCl(CClient *cl);
  1254. template <typename Handler> void serialize(Handler &h, const int version)
  1255. {
  1256. h & player & c & text;
  1257. }
  1258. };
  1259. struct AdvmapSpellCast : public CPackForClient //108
  1260. {
  1261. AdvmapSpellCast(){type = 108;}
  1262. const CGHeroInstance * caster;
  1263. si32 spellID;
  1264. void applyCl(CClient *cl);
  1265. template <typename Handler> void serialize(Handler &h, const int version)
  1266. {
  1267. h & caster & spellID;
  1268. }
  1269. };
  1270. /***********************************************************************************************************/
  1271. struct CommitPackage : public CPackForServer
  1272. {
  1273. bool freePack; //for local usage, DO NOT serialize
  1274. bool applyGh(CGameHandler *gh);
  1275. CPackForClient *packToCommit;
  1276. CommitPackage()
  1277. {
  1278. freePack = true;
  1279. }
  1280. ~CommitPackage()
  1281. {
  1282. if(freePack)
  1283. delete packToCommit;
  1284. }
  1285. template <typename Handler> void serialize(Handler &h, const int version)
  1286. {
  1287. h & packToCommit;
  1288. }
  1289. };
  1290. struct CloseServer : public CPackForServer
  1291. {
  1292. bool applyGh(CGameHandler *gh);
  1293. template <typename Handler> void serialize(Handler &h, const int version)
  1294. {}
  1295. };
  1296. struct EndTurn : public CPackForServer
  1297. {
  1298. bool applyGh(CGameHandler *gh);
  1299. template <typename Handler> void serialize(Handler &h, const int version)
  1300. {}
  1301. };
  1302. struct DismissHero : public CPackForServer
  1303. {
  1304. DismissHero(){};
  1305. DismissHero(si32 HID) : hid(HID) {};
  1306. si32 hid;
  1307. bool applyGh(CGameHandler *gh);
  1308. template <typename Handler> void serialize(Handler &h, const int version)
  1309. {
  1310. h & hid;
  1311. }
  1312. };
  1313. struct MoveHero : public CPackForServer
  1314. {
  1315. MoveHero(){};
  1316. MoveHero(const int3 &Dest, si32 HID) : dest(Dest), hid(HID){};
  1317. int3 dest;
  1318. si32 hid;
  1319. bool applyGh(CGameHandler *gh);
  1320. template <typename Handler> void serialize(Handler &h, const int version)
  1321. {
  1322. h & dest & hid;
  1323. }
  1324. };
  1325. struct CastleTeleportHero : public CPackForServer
  1326. {
  1327. CastleTeleportHero(){};
  1328. CastleTeleportHero(const si32 HID, si32 Dest, ui8 Source ) : dest(Dest), hid(HID), source(Source){};
  1329. si32 dest;
  1330. si32 hid;
  1331. si8 source;//who give teleporting, 1=castle gate
  1332. bool applyGh(CGameHandler *gh);
  1333. template <typename Handler> void serialize(Handler &h, const int version)
  1334. {
  1335. h & dest & hid;
  1336. }
  1337. };
  1338. struct ArrangeStacks : public CPackForServer
  1339. {
  1340. ArrangeStacks(){};
  1341. ArrangeStacks(ui8 W, ui8 P1, ui8 P2, si32 ID1, si32 ID2, si32 VAL)
  1342. :what(W),p1(P1),p2(P2),id1(ID1),id2(ID2),val(VAL) {};
  1343. ui8 what; //1 - swap; 2 - merge; 3 - split
  1344. ui8 p1, p2; //positions of first and second stack
  1345. si32 id1, id2; //ids of objects with garrison
  1346. si32 val;
  1347. bool applyGh(CGameHandler *gh);
  1348. template <typename Handler> void serialize(Handler &h, const int version)
  1349. {
  1350. h & what & p1 & p2 & id1 & id2 & val;
  1351. }
  1352. };
  1353. struct DisbandCreature : public CPackForServer
  1354. {
  1355. DisbandCreature(){};
  1356. DisbandCreature(ui8 Pos, si32 ID):pos(Pos),id(ID){};
  1357. ui8 pos; //stack pos
  1358. si32 id; //object id
  1359. bool applyGh(CGameHandler *gh);
  1360. template <typename Handler> void serialize(Handler &h, const int version)
  1361. {
  1362. h & pos & id;
  1363. }
  1364. };
  1365. struct BuildStructure : public CPackForServer
  1366. {
  1367. BuildStructure(){};
  1368. BuildStructure(si32 TID, si32 BID):bid(BID),tid(TID){};
  1369. si32 bid, tid; //structure and town ids
  1370. bool applyGh(CGameHandler *gh);
  1371. template <typename Handler> void serialize(Handler &h, const int version)
  1372. {
  1373. h & tid & bid;
  1374. }
  1375. };
  1376. struct RazeStructure : public BuildStructure
  1377. {
  1378. RazeStructure(){};
  1379. //RazeStructure(si32 TID, si32 BID):bid(BID),tid(TID){};
  1380. bool applyGh(CGameHandler *gh);
  1381. };
  1382. struct RecruitCreatures : public CPackForServer
  1383. {
  1384. RecruitCreatures(){};
  1385. RecruitCreatures(si32 TID, si32 CRID, si32 Amount, si32 Level):tid(TID),crid(CRID),amount(Amount),level(Level){};
  1386. si32 tid; //town id
  1387. ui32 crid, amount;//creature ID and amount
  1388. si32 level;//dwelling level to buy from, -1 if any
  1389. bool applyGh(CGameHandler *gh);
  1390. template <typename Handler> void serialize(Handler &h, const int version)
  1391. {
  1392. h & tid & crid & amount & level;
  1393. }
  1394. };
  1395. struct UpgradeCreature : public CPackForServer
  1396. {
  1397. UpgradeCreature(){};
  1398. UpgradeCreature(ui8 Pos, si32 ID, si32 CRID):pos(Pos),id(ID), cid(CRID){};
  1399. ui8 pos; //stack pos
  1400. si32 id; //object id
  1401. si32 cid; //id of type to which we want make upgrade
  1402. bool applyGh(CGameHandler *gh);
  1403. template <typename Handler> void serialize(Handler &h, const int version)
  1404. {
  1405. h & pos & id & cid;
  1406. }
  1407. };
  1408. struct GarrisonHeroSwap : public CPackForServer
  1409. {
  1410. GarrisonHeroSwap(){};
  1411. GarrisonHeroSwap(si32 TID):tid(TID){};
  1412. si32 tid;
  1413. bool applyGh(CGameHandler *gh);
  1414. template <typename Handler> void serialize(Handler &h, const int version)
  1415. {
  1416. h & tid;
  1417. }
  1418. };
  1419. struct ExchangeArtifacts : public CPackForServer
  1420. {
  1421. ExchangeArtifacts(){};
  1422. ExchangeArtifacts(si32 H1, si32 H2, ui16 S1, ui16 S2)
  1423. :hid1(H1),hid2(H2),slot1(S1),slot2(S2){};
  1424. si32 hid1, hid2;
  1425. ui16 slot1, slot2;
  1426. bool applyGh(CGameHandler *gh);
  1427. template <typename Handler> void serialize(Handler &h, const int version)
  1428. {
  1429. h & hid1 & hid2 & slot1 & slot2;
  1430. }
  1431. };
  1432. struct AssembleArtifacts : public CPackForServer
  1433. {
  1434. AssembleArtifacts(){};
  1435. AssembleArtifacts(si32 _heroID, ui16 _artifactSlot, bool _assemble, ui32 _assembleTo)
  1436. : heroID(_heroID), artifactSlot(_artifactSlot), assemble(_assemble), assembleTo(_assembleTo){};
  1437. si32 heroID;
  1438. ui16 artifactSlot;
  1439. bool assemble; // True to assemble artifact, false to disassemble.
  1440. ui32 assembleTo; // Artifact to assemble into.
  1441. bool applyGh(CGameHandler *gh);
  1442. template <typename Handler> void serialize(Handler &h, const int version)
  1443. {
  1444. h & heroID & artifactSlot & assemble & assembleTo;
  1445. }
  1446. };
  1447. struct BuyArtifact : public CPackForServer
  1448. {
  1449. BuyArtifact(){};
  1450. BuyArtifact(si32 HID, si32 AID):hid(HID),aid(AID){};
  1451. si32 hid, aid; //hero and artifact id
  1452. bool applyGh(CGameHandler *gh);
  1453. template <typename Handler> void serialize(Handler &h, const int version)
  1454. {
  1455. h & hid & aid;
  1456. }
  1457. };
  1458. struct TradeOnMarketplace : public CPackForServer
  1459. {
  1460. TradeOnMarketplace(){};
  1461. const CGObjectInstance *market;
  1462. const CGHeroInstance *hero; //needed when trading artifacts / creatures
  1463. ui8 mode;//enum EMarketMode
  1464. ui32 r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?]
  1465. ui32 val; //units of sold resource
  1466. bool applyGh(CGameHandler *gh);
  1467. template <typename Handler> void serialize(Handler &h, const int version)
  1468. {
  1469. h & market & hero & mode & r1 & r2 & val;
  1470. }
  1471. };
  1472. struct SetFormation : public CPackForServer
  1473. {
  1474. SetFormation(){};
  1475. SetFormation(si32 HID, ui8 Formation):hid(HID),formation(Formation){};
  1476. si32 hid;
  1477. ui8 formation;
  1478. bool applyGh(CGameHandler *gh);
  1479. template <typename Handler> void serialize(Handler &h, const int version)
  1480. {
  1481. h & hid & formation;
  1482. }
  1483. };
  1484. struct HireHero : public CPackForServer
  1485. {
  1486. HireHero(){};
  1487. HireHero(si32 HID, si32 TID):hid(HID),tid(TID){};
  1488. si32 hid, tid; //available hero serial and town (tavern) id
  1489. ui8 player;
  1490. bool applyGh(CGameHandler *gh);
  1491. template <typename Handler> void serialize(Handler &h, const int version)
  1492. {
  1493. h & hid & tid & player;
  1494. }
  1495. };
  1496. struct BuildBoat : public CPackForServer
  1497. {
  1498. BuildBoat(){};
  1499. si32 objid; //where player wants to buy a boat
  1500. bool applyGh(CGameHandler *gh);
  1501. template <typename Handler> void serialize(Handler &h, const int version)
  1502. {
  1503. h & objid;
  1504. }
  1505. };
  1506. struct QueryReply : public CPackForServer
  1507. {
  1508. QueryReply(){type = 6000;};
  1509. QueryReply(ui32 QID, ui32 Answer):qid(QID),answer(Answer){type = 6000;};
  1510. ui32 qid, answer; //hero and artifact id
  1511. ui8 player;
  1512. bool applyGh(CGameHandler *gh);
  1513. template <typename Handler> void serialize(Handler &h, const int version)
  1514. {
  1515. h & qid & answer & player;
  1516. }
  1517. };
  1518. struct MakeAction : public CPackForServer
  1519. {
  1520. MakeAction(){};
  1521. MakeAction(const BattleAction &BA):ba(BA){};
  1522. BattleAction ba;
  1523. bool applyGh(CGameHandler *gh);
  1524. template <typename Handler> void serialize(Handler &h, const int version)
  1525. {
  1526. h & ba;
  1527. }
  1528. };
  1529. struct MakeCustomAction : public CPackForServer
  1530. {
  1531. MakeCustomAction(){};
  1532. MakeCustomAction(const BattleAction &BA):ba(BA){};
  1533. BattleAction ba;
  1534. bool applyGh(CGameHandler *gh);
  1535. template <typename Handler> void serialize(Handler &h, const int version)
  1536. {
  1537. h & ba;
  1538. }
  1539. };
  1540. struct DigWithHero : public CPackForServer
  1541. {
  1542. DigWithHero(){}
  1543. si32 id; //digging hero id
  1544. bool applyGh(CGameHandler *gh);
  1545. template <typename Handler> void serialize(Handler &h, const int version)
  1546. {
  1547. h & id;
  1548. }
  1549. };
  1550. struct CastAdvSpell : public CPackForServer
  1551. {
  1552. CastAdvSpell(){}
  1553. si32 hid; //hero id
  1554. ui32 sid; //spell id
  1555. int3 pos; //selected tile (not always used)
  1556. bool applyGh(CGameHandler *gh);
  1557. template <typename Handler> void serialize(Handler &h, const int version)
  1558. {
  1559. h & hid & sid & pos;
  1560. }
  1561. };
  1562. /***********************************************************************************************************/
  1563. struct SaveGame : public CPackForClient, public CPackForServer
  1564. {
  1565. SaveGame(){};
  1566. SaveGame(const std::string &Fname) :fname(Fname){};
  1567. std::string fname;
  1568. void applyCl(CClient *cl);
  1569. void applyGs(CGameState *gs){};
  1570. bool applyGh(CGameHandler *gh);
  1571. template <typename Handler> void serialize(Handler &h, const int version)
  1572. {
  1573. h & fname;
  1574. }
  1575. };
  1576. struct PlayerMessage : public CPackForClient, public CPackForServer //513
  1577. {
  1578. PlayerMessage(){CPackForClient::type = 513;};
  1579. PlayerMessage(ui8 Player, const std::string &Text)
  1580. :player(Player),text(Text)
  1581. {CPackForClient::type = 513;};
  1582. void applyCl(CClient *cl);
  1583. void applyGs(CGameState *gs){};
  1584. bool applyGh(CGameHandler *gh);
  1585. ui8 player;
  1586. std::string text;
  1587. template <typename Handler> void serialize(Handler &h, const int version)
  1588. {
  1589. h & text & player;
  1590. }
  1591. };
  1592. struct SetSelection : public CPackForClient, public CPackForServer //514
  1593. {
  1594. SetSelection(){CPackForClient::type = 514;};
  1595. DLL_EXPORT void applyGs(CGameState *gs);
  1596. bool applyGh(CGameHandler *gh);
  1597. void applyCl(CClient *cl);
  1598. ui8 player;
  1599. ui32 id;
  1600. template <typename Handler> void serialize(Handler &h, const int version)
  1601. {
  1602. h & id & player;
  1603. }
  1604. };
  1605. struct CenterView : public CPackForClient//515
  1606. {
  1607. CenterView(){CPackForClient::type = 515;};
  1608. void applyCl(CClient *cl);
  1609. ui8 player;
  1610. int3 pos;
  1611. ui32 focusTime; //ms
  1612. template <typename Handler> void serialize(Handler &h, const int version)
  1613. {
  1614. h & pos & player & focusTime;
  1615. }
  1616. };
  1617. /***********************************************************************************************************/
  1618. struct CPackForSelectionScreen : public CPack
  1619. {
  1620. void apply(CSelectionScreen *selScreen){}; //that functions are implemented in CPreGame.cpp
  1621. };
  1622. class CPregamePackToPropagate : public CPackForSelectionScreen
  1623. {};
  1624. class CPregamePackToHost : public CPackForSelectionScreen
  1625. {};
  1626. struct ChatMessage : public CPregamePackToPropagate
  1627. {
  1628. std::string playerName, message;
  1629. void apply(CSelectionScreen *selScreen);
  1630. template <typename Handler> void serialize(Handler &h, const int version)
  1631. {
  1632. h & playerName & message;
  1633. }
  1634. };
  1635. struct QuitMenuWithoutStarting : public CPregamePackToPropagate
  1636. {
  1637. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1638. template <typename Handler> void serialize(Handler &h, const int version)
  1639. {}
  1640. };
  1641. struct PlayerJoined : public CPregamePackToHost
  1642. {
  1643. std::string playerName;
  1644. ui8 connectionID;
  1645. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1646. template <typename Handler> void serialize(Handler &h, const int version)
  1647. {
  1648. h & playerName & connectionID;
  1649. }
  1650. };
  1651. struct SelectMap : public CPregamePackToPropagate
  1652. {
  1653. const CMapInfo *mapInfo;
  1654. bool free;
  1655. SelectMap(const CMapInfo &src)
  1656. {
  1657. mapInfo = &src;
  1658. free = false;
  1659. }
  1660. SelectMap()
  1661. {
  1662. mapInfo = NULL;
  1663. free = true;
  1664. }
  1665. ~SelectMap()
  1666. {
  1667. if(free)
  1668. delete mapInfo;
  1669. }
  1670. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1671. template <typename Handler> void serialize(Handler &h, const int version)
  1672. {
  1673. h & mapInfo;
  1674. }
  1675. };
  1676. struct UpdateStartOptions : public CPregamePackToPropagate
  1677. {
  1678. StartInfo *options;
  1679. bool free;
  1680. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1681. UpdateStartOptions(StartInfo &src)
  1682. {
  1683. options = &src;
  1684. free = false;
  1685. }
  1686. UpdateStartOptions()
  1687. {
  1688. options = NULL;
  1689. free = true;
  1690. }
  1691. ~UpdateStartOptions()
  1692. {
  1693. if(free)
  1694. delete options;
  1695. }
  1696. template <typename Handler> void serialize(Handler &h, const int version)
  1697. {
  1698. h & options;
  1699. }
  1700. };
  1701. struct PregameGuiAction : public CPregamePackToPropagate
  1702. {
  1703. enum {NO_TAB, OPEN_OPTIONS, OPEN_SCENARIO_LIST};
  1704. ui8 action;
  1705. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1706. template <typename Handler> void serialize(Handler &h, const int version)
  1707. {
  1708. h & action;
  1709. }
  1710. };
  1711. struct RequestOptionsChange : public CPregamePackToHost
  1712. {
  1713. enum {TOWN, HERO, BONUS};
  1714. ui8 what;
  1715. si8 direction; //-1 or +1
  1716. ui8 playerID;
  1717. RequestOptionsChange(ui8 What, si8 Dir, ui8 Player)
  1718. :what(What), direction(Dir), playerID(Player)
  1719. {}
  1720. RequestOptionsChange(){}
  1721. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1722. template <typename Handler> void serialize(Handler &h, const int version)
  1723. {
  1724. h & what & direction & playerID;
  1725. }
  1726. };
  1727. struct PlayerLeft : public CPregamePackToPropagate
  1728. {
  1729. ui8 playerID;
  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 & playerID;
  1734. }
  1735. };
  1736. struct PlayersNames : public CPregamePackToPropagate
  1737. {
  1738. public:
  1739. std::map<ui32, std::string> playerNames;
  1740. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1741. template <typename Handler> void serialize(Handler &h, const int version)
  1742. {
  1743. h & playerNames;
  1744. }
  1745. };
  1746. struct StartWithCurrentSettings : public CPregamePackToPropagate
  1747. {
  1748. public:
  1749. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1750. template <typename Handler> void serialize(Handler &h, const int version)
  1751. {
  1752. //h & playerNames;
  1753. }
  1754. };
  1755. #endif //__NETPACKS_H__