NetPacks.h 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096
  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. std::vector<THex> tilesToMove;
  1019. ui8 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 & tilesToMove & 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, REBIRTH = 8};
  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 willRebirth() const//if stack was not a primary target (receives no spell effects)
  1076. {
  1077. return flags & REBIRTH;
  1078. }
  1079. bool lifeDrain() const //if this attack involves life drain effect
  1080. {
  1081. return healedStacks.size() > 0;
  1082. }
  1083. template <typename Handler> void serialize(Handler &h, const int version)
  1084. {
  1085. h & stackAttacked & attackerID & newAmount & newHP & flags & killedAmount & damageAmount & effect
  1086. & healedStacks;
  1087. }
  1088. bool operator<(const BattleStackAttacked &b) const
  1089. {
  1090. return stackAttacked < b.stackAttacked;
  1091. }
  1092. };
  1093. struct BattleAttack : public CPackForClient//3006
  1094. {
  1095. BattleAttack(){flags = 0; type = 3006;};
  1096. void applyFirstCl(CClient *cl);
  1097. DLL_EXPORT void applyGs(CGameState *gs);
  1098. void applyCl(CClient *cl);
  1099. std::vector<BattleStackAttacked> bsa;
  1100. ui32 stackAttacking;
  1101. ui8 flags; //uses Eflags (below)
  1102. enum EFlags{SHOT = 1, COUNTER = 2, LUCKY = 4, UNLUCKY = 8, BALLISTA_DOUBLE_DMG = 16, DEATH_BLOW = 32};
  1103. bool shot() const//distance attack - decrease number of shots
  1104. {
  1105. return flags & SHOT;
  1106. }
  1107. bool counter() const//is it counterattack?
  1108. {
  1109. return flags & COUNTER;
  1110. }
  1111. bool lucky() const
  1112. {
  1113. return flags & LUCKY;
  1114. }
  1115. bool unlucky() const
  1116. {
  1117. //TODO: support?
  1118. return flags & UNLUCKY;
  1119. }
  1120. bool ballistaDoubleDmg() const //if it's ballista attack and does double dmg
  1121. {
  1122. return flags & BALLISTA_DOUBLE_DMG;
  1123. }
  1124. bool deathBlow() const
  1125. {
  1126. return flags & DEATH_BLOW;
  1127. }
  1128. //bool killed() //if target stack was killed
  1129. //{
  1130. // return bsa.killed();
  1131. //}
  1132. template <typename Handler> void serialize(Handler &h, const int version)
  1133. {
  1134. h & bsa & stackAttacking & flags;
  1135. }
  1136. };
  1137. struct StartAction : public CPackForClient//3007
  1138. {
  1139. StartAction(){type = 3007;};
  1140. StartAction(const BattleAction &act){ba = act; type = 3007;};
  1141. void applyFirstCl(CClient *cl);
  1142. DLL_EXPORT void applyGs(CGameState *gs);
  1143. BattleAction ba;
  1144. template <typename Handler> void serialize(Handler &h, const int version)
  1145. {
  1146. h & ba;
  1147. }
  1148. };
  1149. struct EndAction : public CPackForClient//3008
  1150. {
  1151. EndAction(){type = 3008;};
  1152. void applyCl(CClient *cl);
  1153. template <typename Handler> void serialize(Handler &h, const int version)
  1154. {
  1155. }
  1156. };
  1157. struct BattleSpellCast : public CPackForClient//3009
  1158. {
  1159. BattleSpellCast(){type = 3009;};
  1160. DLL_EXPORT void applyGs(CGameState *gs);
  1161. void applyCl(CClient *cl);
  1162. si32 dmgToDisplay; //this amount will be displayed as amount of damage dealt by spell
  1163. ui8 side; //which hero did cast spell: 0 - attacker, 1 - defender
  1164. ui32 id; //id of spell
  1165. ui8 skill; //caster's skill level
  1166. THex tile; //destination tile (may not be set in some global/mass spells
  1167. std::vector<ui32> resisted; //ids of creatures that resisted this spell
  1168. std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure)
  1169. TCreature attackerType;//id of caster to generate console message; -1 if not set (eg. spell casted by artifact)
  1170. ui8 castedByHero; //if true - spell has been casted by hero, otherwise by a creature
  1171. template <typename Handler> void serialize(Handler &h, const int version)
  1172. {
  1173. h & dmgToDisplay & side & id & skill & tile & resisted & affectedCres & attackerType & castedByHero;
  1174. }
  1175. };
  1176. struct SetStackEffect : public CPackForClient //3010
  1177. {
  1178. SetStackEffect(){type = 3010;};
  1179. DLL_EXPORT void applyGs(CGameState *gs);
  1180. void applyCl(CClient *cl);
  1181. std::vector<ui32> stacks; //affected stacks (IDs)
  1182. std::vector<Bonus> effect; //bonuses to apply
  1183. std::vector<std::pair<ui32, Bonus> > uniqueBonuses; //bonuses per single stack
  1184. template <typename Handler> void serialize(Handler &h, const int version)
  1185. {
  1186. h & stacks & effect & uniqueBonuses;
  1187. }
  1188. };
  1189. struct StacksInjured : public CPackForClient //3011
  1190. {
  1191. StacksInjured(){type = 3011;}
  1192. DLL_EXPORT void applyGs(CGameState *gs);
  1193. void applyCl(CClient *cl);
  1194. std::vector<BattleStackAttacked> stacks;
  1195. template <typename Handler> void serialize(Handler &h, const int version)
  1196. {
  1197. h & stacks;
  1198. }
  1199. };
  1200. struct BattleResultsApplied : public CPackForClient //3012
  1201. {
  1202. BattleResultsApplied(){type = 3012;}
  1203. ui8 player1, player2;
  1204. void applyCl(CClient *cl);
  1205. template <typename Handler> void serialize(Handler &h, const int version)
  1206. {
  1207. h & player1 & player2;
  1208. }
  1209. };
  1210. struct ObstaclesRemoved : public CPackForClient //3014
  1211. {
  1212. ObstaclesRemoved(){type = 3014;}
  1213. DLL_EXPORT void applyGs(CGameState *gs);
  1214. void applyCl(CClient *cl);
  1215. std::set<si32> obstacles; //uniqueIDs of removed obstacles
  1216. template <typename Handler> void serialize(Handler &h, const int version)
  1217. {
  1218. h & obstacles;
  1219. }
  1220. };
  1221. struct CatapultAttack : public CPackForClient //3015
  1222. {
  1223. CatapultAttack(){type = 3015;}
  1224. DLL_EXPORT void applyGs(CGameState *gs);
  1225. void applyCl(CClient *cl);
  1226. std::set< std::pair< std::pair< ui8, si16 >, ui8> > attackedParts; // < <attackedPartOfWall, attacked hex >, damageDealt>
  1227. //attackedPartOfWall; //[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate;
  1228. //damageDealt;
  1229. int attacker; //if -1, then a spell caused this
  1230. template <typename Handler> void serialize(Handler &h, const int version)
  1231. {
  1232. h & attackedParts & attacker;
  1233. }
  1234. };
  1235. struct BattleStacksRemoved : public CPackForClient //3016
  1236. {
  1237. BattleStacksRemoved(){type = 3016;}
  1238. DLL_EXPORT void applyGs(CGameState *gs);
  1239. void applyCl(CClient *cl);
  1240. std::set<ui32> stackIDs; //IDs of removed stacks
  1241. template <typename Handler> void serialize(Handler &h, const int version)
  1242. {
  1243. h & stackIDs;
  1244. }
  1245. };
  1246. struct ShowInInfobox : public CPackForClient //107
  1247. {
  1248. ShowInInfobox(){type = 107;};
  1249. ui8 player;
  1250. Component c;
  1251. MetaString text;
  1252. void applyCl(CClient *cl);
  1253. template <typename Handler> void serialize(Handler &h, const int version)
  1254. {
  1255. h & player & c & text;
  1256. }
  1257. };
  1258. struct AdvmapSpellCast : public CPackForClient //108
  1259. {
  1260. AdvmapSpellCast(){type = 108;}
  1261. const CGHeroInstance * caster;
  1262. si32 spellID;
  1263. void applyCl(CClient *cl);
  1264. template <typename Handler> void serialize(Handler &h, const int version)
  1265. {
  1266. h & caster & spellID;
  1267. }
  1268. };
  1269. /***********************************************************************************************************/
  1270. struct CommitPackage : public CPackForServer
  1271. {
  1272. bool freePack; //for local usage, DO NOT serialize
  1273. bool applyGh(CGameHandler *gh);
  1274. CPackForClient *packToCommit;
  1275. CommitPackage()
  1276. {
  1277. freePack = true;
  1278. }
  1279. ~CommitPackage()
  1280. {
  1281. if(freePack)
  1282. delete packToCommit;
  1283. }
  1284. template <typename Handler> void serialize(Handler &h, const int version)
  1285. {
  1286. h & packToCommit;
  1287. }
  1288. };
  1289. struct CloseServer : public CPackForServer
  1290. {
  1291. bool applyGh(CGameHandler *gh);
  1292. template <typename Handler> void serialize(Handler &h, const int version)
  1293. {}
  1294. };
  1295. struct EndTurn : public CPackForServer
  1296. {
  1297. bool applyGh(CGameHandler *gh);
  1298. template <typename Handler> void serialize(Handler &h, const int version)
  1299. {}
  1300. };
  1301. struct DismissHero : public CPackForServer
  1302. {
  1303. DismissHero(){};
  1304. DismissHero(si32 HID) : hid(HID) {};
  1305. si32 hid;
  1306. bool applyGh(CGameHandler *gh);
  1307. template <typename Handler> void serialize(Handler &h, const int version)
  1308. {
  1309. h & hid;
  1310. }
  1311. };
  1312. struct MoveHero : public CPackForServer
  1313. {
  1314. MoveHero(){};
  1315. MoveHero(const int3 &Dest, si32 HID) : dest(Dest), hid(HID){};
  1316. int3 dest;
  1317. si32 hid;
  1318. bool applyGh(CGameHandler *gh);
  1319. template <typename Handler> void serialize(Handler &h, const int version)
  1320. {
  1321. h & dest & hid;
  1322. }
  1323. };
  1324. struct CastleTeleportHero : public CPackForServer
  1325. {
  1326. CastleTeleportHero(){};
  1327. CastleTeleportHero(const si32 HID, si32 Dest, ui8 Source ) : dest(Dest), hid(HID), source(Source){};
  1328. si32 dest;
  1329. si32 hid;
  1330. si8 source;//who give teleporting, 1=castle gate
  1331. bool applyGh(CGameHandler *gh);
  1332. template <typename Handler> void serialize(Handler &h, const int version)
  1333. {
  1334. h & dest & hid;
  1335. }
  1336. };
  1337. struct ArrangeStacks : public CPackForServer
  1338. {
  1339. ArrangeStacks(){};
  1340. ArrangeStacks(ui8 W, ui8 P1, ui8 P2, si32 ID1, si32 ID2, si32 VAL)
  1341. :what(W),p1(P1),p2(P2),id1(ID1),id2(ID2),val(VAL) {};
  1342. ui8 what; //1 - swap; 2 - merge; 3 - split
  1343. ui8 p1, p2; //positions of first and second stack
  1344. si32 id1, id2; //ids of objects with garrison
  1345. si32 val;
  1346. bool applyGh(CGameHandler *gh);
  1347. template <typename Handler> void serialize(Handler &h, const int version)
  1348. {
  1349. h & what & p1 & p2 & id1 & id2 & val;
  1350. }
  1351. };
  1352. struct DisbandCreature : public CPackForServer
  1353. {
  1354. DisbandCreature(){};
  1355. DisbandCreature(ui8 Pos, si32 ID):pos(Pos),id(ID){};
  1356. ui8 pos; //stack pos
  1357. si32 id; //object id
  1358. bool applyGh(CGameHandler *gh);
  1359. template <typename Handler> void serialize(Handler &h, const int version)
  1360. {
  1361. h & pos & id;
  1362. }
  1363. };
  1364. struct BuildStructure : public CPackForServer
  1365. {
  1366. BuildStructure(){};
  1367. BuildStructure(si32 TID, si32 BID):bid(BID),tid(TID){};
  1368. si32 bid, tid; //structure and town ids
  1369. bool applyGh(CGameHandler *gh);
  1370. template <typename Handler> void serialize(Handler &h, const int version)
  1371. {
  1372. h & tid & bid;
  1373. }
  1374. };
  1375. struct RazeStructure : public BuildStructure
  1376. {
  1377. RazeStructure(){};
  1378. //RazeStructure(si32 TID, si32 BID):bid(BID),tid(TID){};
  1379. bool applyGh(CGameHandler *gh);
  1380. };
  1381. struct RecruitCreatures : public CPackForServer
  1382. {
  1383. RecruitCreatures(){};
  1384. RecruitCreatures(si32 TID, si32 CRID, si32 Amount, si32 Level):tid(TID),crid(CRID),amount(Amount),level(Level){};
  1385. si32 tid; //town id
  1386. ui32 crid, amount;//creature ID and amount
  1387. si32 level;//dwelling level to buy from, -1 if any
  1388. bool applyGh(CGameHandler *gh);
  1389. template <typename Handler> void serialize(Handler &h, const int version)
  1390. {
  1391. h & tid & crid & amount & level;
  1392. }
  1393. };
  1394. struct UpgradeCreature : public CPackForServer
  1395. {
  1396. UpgradeCreature(){};
  1397. UpgradeCreature(ui8 Pos, si32 ID, si32 CRID):pos(Pos),id(ID), cid(CRID){};
  1398. ui8 pos; //stack pos
  1399. si32 id; //object id
  1400. si32 cid; //id of type to which we want make upgrade
  1401. bool applyGh(CGameHandler *gh);
  1402. template <typename Handler> void serialize(Handler &h, const int version)
  1403. {
  1404. h & pos & id & cid;
  1405. }
  1406. };
  1407. struct GarrisonHeroSwap : public CPackForServer
  1408. {
  1409. GarrisonHeroSwap(){};
  1410. GarrisonHeroSwap(si32 TID):tid(TID){};
  1411. si32 tid;
  1412. bool applyGh(CGameHandler *gh);
  1413. template <typename Handler> void serialize(Handler &h, const int version)
  1414. {
  1415. h & tid;
  1416. }
  1417. };
  1418. struct ExchangeArtifacts : public CPackForServer
  1419. {
  1420. ExchangeArtifacts(){};
  1421. ExchangeArtifacts(si32 H1, si32 H2, ui16 S1, ui16 S2)
  1422. :hid1(H1),hid2(H2),slot1(S1),slot2(S2){};
  1423. si32 hid1, hid2;
  1424. ui16 slot1, slot2;
  1425. bool applyGh(CGameHandler *gh);
  1426. template <typename Handler> void serialize(Handler &h, const int version)
  1427. {
  1428. h & hid1 & hid2 & slot1 & slot2;
  1429. }
  1430. };
  1431. struct AssembleArtifacts : public CPackForServer
  1432. {
  1433. AssembleArtifacts(){};
  1434. AssembleArtifacts(si32 _heroID, ui16 _artifactSlot, bool _assemble, ui32 _assembleTo)
  1435. : heroID(_heroID), artifactSlot(_artifactSlot), assemble(_assemble), assembleTo(_assembleTo){};
  1436. si32 heroID;
  1437. ui16 artifactSlot;
  1438. bool assemble; // True to assemble artifact, false to disassemble.
  1439. ui32 assembleTo; // Artifact to assemble into.
  1440. bool applyGh(CGameHandler *gh);
  1441. template <typename Handler> void serialize(Handler &h, const int version)
  1442. {
  1443. h & heroID & artifactSlot & assemble & assembleTo;
  1444. }
  1445. };
  1446. struct BuyArtifact : public CPackForServer
  1447. {
  1448. BuyArtifact(){};
  1449. BuyArtifact(si32 HID, si32 AID):hid(HID),aid(AID){};
  1450. si32 hid, aid; //hero and artifact id
  1451. bool applyGh(CGameHandler *gh);
  1452. template <typename Handler> void serialize(Handler &h, const int version)
  1453. {
  1454. h & hid & aid;
  1455. }
  1456. };
  1457. struct TradeOnMarketplace : public CPackForServer
  1458. {
  1459. TradeOnMarketplace(){};
  1460. const CGObjectInstance *market;
  1461. const CGHeroInstance *hero; //needed when trading artifacts / creatures
  1462. ui8 mode;//enum EMarketMode
  1463. ui32 r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?]
  1464. ui32 val; //units of sold resource
  1465. bool applyGh(CGameHandler *gh);
  1466. template <typename Handler> void serialize(Handler &h, const int version)
  1467. {
  1468. h & market & hero & mode & r1 & r2 & val;
  1469. }
  1470. };
  1471. struct SetFormation : public CPackForServer
  1472. {
  1473. SetFormation(){};
  1474. SetFormation(si32 HID, ui8 Formation):hid(HID),formation(Formation){};
  1475. si32 hid;
  1476. ui8 formation;
  1477. bool applyGh(CGameHandler *gh);
  1478. template <typename Handler> void serialize(Handler &h, const int version)
  1479. {
  1480. h & hid & formation;
  1481. }
  1482. };
  1483. struct HireHero : public CPackForServer
  1484. {
  1485. HireHero(){};
  1486. HireHero(si32 HID, si32 TID):hid(HID),tid(TID){};
  1487. si32 hid, tid; //available hero serial and town (tavern) id
  1488. ui8 player;
  1489. bool applyGh(CGameHandler *gh);
  1490. template <typename Handler> void serialize(Handler &h, const int version)
  1491. {
  1492. h & hid & tid & player;
  1493. }
  1494. };
  1495. struct BuildBoat : public CPackForServer
  1496. {
  1497. BuildBoat(){};
  1498. si32 objid; //where player wants to buy a boat
  1499. bool applyGh(CGameHandler *gh);
  1500. template <typename Handler> void serialize(Handler &h, const int version)
  1501. {
  1502. h & objid;
  1503. }
  1504. };
  1505. struct QueryReply : public CPackForServer
  1506. {
  1507. QueryReply(){type = 6000;};
  1508. QueryReply(ui32 QID, ui32 Answer):qid(QID),answer(Answer){type = 6000;};
  1509. ui32 qid, answer; //hero and artifact id
  1510. bool applyGh(CGameHandler *gh);
  1511. template <typename Handler> void serialize(Handler &h, const int version)
  1512. {
  1513. h & qid & answer;
  1514. }
  1515. };
  1516. struct MakeAction : public CPackForServer
  1517. {
  1518. MakeAction(){};
  1519. MakeAction(const BattleAction &BA):ba(BA){};
  1520. BattleAction ba;
  1521. bool applyGh(CGameHandler *gh);
  1522. template <typename Handler> void serialize(Handler &h, const int version)
  1523. {
  1524. h & ba;
  1525. }
  1526. };
  1527. struct MakeCustomAction : public CPackForServer
  1528. {
  1529. MakeCustomAction(){};
  1530. MakeCustomAction(const BattleAction &BA):ba(BA){};
  1531. BattleAction ba;
  1532. bool applyGh(CGameHandler *gh);
  1533. template <typename Handler> void serialize(Handler &h, const int version)
  1534. {
  1535. h & ba;
  1536. }
  1537. };
  1538. struct DigWithHero : public CPackForServer
  1539. {
  1540. DigWithHero(){}
  1541. si32 id; //digging hero id
  1542. bool applyGh(CGameHandler *gh);
  1543. template <typename Handler> void serialize(Handler &h, const int version)
  1544. {
  1545. h & id;
  1546. }
  1547. };
  1548. struct CastAdvSpell : public CPackForServer
  1549. {
  1550. CastAdvSpell(){}
  1551. si32 hid; //hero id
  1552. ui32 sid; //spell id
  1553. int3 pos; //selected tile (not always used)
  1554. bool applyGh(CGameHandler *gh);
  1555. template <typename Handler> void serialize(Handler &h, const int version)
  1556. {
  1557. h & hid & sid & pos;
  1558. }
  1559. };
  1560. /***********************************************************************************************************/
  1561. struct SaveGame : public CPackForClient, public CPackForServer
  1562. {
  1563. SaveGame(){};
  1564. SaveGame(const std::string &Fname) :fname(Fname){};
  1565. std::string fname;
  1566. void applyCl(CClient *cl);
  1567. void applyGs(CGameState *gs){};
  1568. bool applyGh(CGameHandler *gh);
  1569. template <typename Handler> void serialize(Handler &h, const int version)
  1570. {
  1571. h & fname;
  1572. }
  1573. };
  1574. struct PlayerMessage : public CPackForClient, public CPackForServer //513
  1575. {
  1576. PlayerMessage(){CPackForClient::type = 513;};
  1577. PlayerMessage(ui8 Player, const std::string &Text)
  1578. :player(Player),text(Text)
  1579. {CPackForClient::type = 513;};
  1580. void applyCl(CClient *cl);
  1581. void applyGs(CGameState *gs){};
  1582. bool applyGh(CGameHandler *gh);
  1583. ui8 player;
  1584. std::string text;
  1585. template <typename Handler> void serialize(Handler &h, const int version)
  1586. {
  1587. h & text & player;
  1588. }
  1589. };
  1590. struct SetSelection : public CPackForClient, public CPackForServer //514
  1591. {
  1592. SetSelection(){CPackForClient::type = 514;};
  1593. DLL_EXPORT void applyGs(CGameState *gs);
  1594. bool applyGh(CGameHandler *gh);
  1595. void applyCl(CClient *cl);
  1596. ui8 player;
  1597. ui32 id;
  1598. template <typename Handler> void serialize(Handler &h, const int version)
  1599. {
  1600. h & id & player;
  1601. }
  1602. };
  1603. struct CenterView : public CPackForClient//515
  1604. {
  1605. CenterView(){CPackForClient::type = 515;};
  1606. void applyCl(CClient *cl);
  1607. ui8 player;
  1608. int3 pos;
  1609. ui32 focusTime; //ms
  1610. template <typename Handler> void serialize(Handler &h, const int version)
  1611. {
  1612. h & pos & player & focusTime;
  1613. }
  1614. };
  1615. /***********************************************************************************************************/
  1616. struct CPackForSelectionScreen : public CPack
  1617. {
  1618. void apply(CSelectionScreen *selScreen){}; //that functions are implemented in CPreGame.cpp
  1619. };
  1620. class CPregamePackToPropagate : public CPackForSelectionScreen
  1621. {};
  1622. class CPregamePackToHost : public CPackForSelectionScreen
  1623. {};
  1624. struct ChatMessage : public CPregamePackToPropagate
  1625. {
  1626. std::string playerName, message;
  1627. void apply(CSelectionScreen *selScreen);
  1628. template <typename Handler> void serialize(Handler &h, const int version)
  1629. {
  1630. h & playerName & message;
  1631. }
  1632. };
  1633. struct QuitMenuWithoutStarting : public CPregamePackToPropagate
  1634. {
  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. };
  1639. struct PlayerJoined : public CPregamePackToHost
  1640. {
  1641. std::string playerName;
  1642. ui8 connectionID;
  1643. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1644. template <typename Handler> void serialize(Handler &h, const int version)
  1645. {
  1646. h & playerName & connectionID;
  1647. }
  1648. };
  1649. struct SelectMap : public CPregamePackToPropagate
  1650. {
  1651. const CMapInfo *mapInfo;
  1652. bool free;
  1653. SelectMap(const CMapInfo &src)
  1654. {
  1655. mapInfo = &src;
  1656. free = false;
  1657. }
  1658. SelectMap()
  1659. {
  1660. mapInfo = NULL;
  1661. free = true;
  1662. }
  1663. ~SelectMap()
  1664. {
  1665. if(free)
  1666. delete mapInfo;
  1667. }
  1668. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1669. template <typename Handler> void serialize(Handler &h, const int version)
  1670. {
  1671. h & mapInfo;
  1672. }
  1673. };
  1674. struct UpdateStartOptions : public CPregamePackToPropagate
  1675. {
  1676. StartInfo *options;
  1677. bool free;
  1678. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1679. UpdateStartOptions(StartInfo &src)
  1680. {
  1681. options = &src;
  1682. free = false;
  1683. }
  1684. UpdateStartOptions()
  1685. {
  1686. options = NULL;
  1687. free = true;
  1688. }
  1689. ~UpdateStartOptions()
  1690. {
  1691. if(free)
  1692. delete options;
  1693. }
  1694. template <typename Handler> void serialize(Handler &h, const int version)
  1695. {
  1696. h & options;
  1697. }
  1698. };
  1699. struct PregameGuiAction : public CPregamePackToPropagate
  1700. {
  1701. enum {NO_TAB, OPEN_OPTIONS, OPEN_SCENARIO_LIST};
  1702. ui8 action;
  1703. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1704. template <typename Handler> void serialize(Handler &h, const int version)
  1705. {
  1706. h & action;
  1707. }
  1708. };
  1709. struct RequestOptionsChange : public CPregamePackToHost
  1710. {
  1711. enum {TOWN, HERO, BONUS};
  1712. ui8 what;
  1713. si8 direction; //-1 or +1
  1714. ui8 playerID;
  1715. RequestOptionsChange(ui8 What, si8 Dir, ui8 Player)
  1716. :what(What), direction(Dir), playerID(Player)
  1717. {}
  1718. RequestOptionsChange(){}
  1719. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1720. template <typename Handler> void serialize(Handler &h, const int version)
  1721. {
  1722. h & what & direction & playerID;
  1723. }
  1724. };
  1725. struct PlayerLeft : public CPregamePackToPropagate
  1726. {
  1727. ui8 playerID;
  1728. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1729. template <typename Handler> void serialize(Handler &h, const int version)
  1730. {
  1731. h & playerID;
  1732. }
  1733. };
  1734. struct PlayersNames : public CPregamePackToPropagate
  1735. {
  1736. public:
  1737. std::map<ui32, std::string> playerNames;
  1738. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1739. template <typename Handler> void serialize(Handler &h, const int version)
  1740. {
  1741. h & playerNames;
  1742. }
  1743. };
  1744. struct StartWithCurrentSettings : public CPregamePackToPropagate
  1745. {
  1746. public:
  1747. void apply(CSelectionScreen *selScreen); //that functions are implemented in CPreGame.cpp
  1748. template <typename Handler> void serialize(Handler &h, const int version)
  1749. {
  1750. //h & playerNames;
  1751. }
  1752. };
  1753. #endif //__NETPACKS_H__