NetPacks.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. #ifndef __NETPACKS_H__
  2. #define __NETPACKS_H__
  3. #include "../global.h"
  4. #include "../CGameState.h"
  5. #include "BattleAction.h"
  6. #include "HeroBonus.h"
  7. #include <set>
  8. class CClient;
  9. class CGameState;
  10. struct CPack
  11. {
  12. ui16 type;
  13. CPack(){};
  14. ~CPack(){};
  15. ui16 getType() const{return type;}
  16. template <typename Handler> void serialize(Handler &h, const int version)
  17. {
  18. }
  19. };
  20. struct CPackForClient : public CPack
  21. {
  22. CGameState* GS(CClient *cl);
  23. void applyFirstCl(CClient *cl)//called before applying to gs
  24. {
  25. tlog1 << "CPackForClient::applyFirstCl - We should not be here!\n";
  26. };
  27. DLL_EXPORT void applyGs(CGameState *gs)
  28. {
  29. tlog1 << "CPackForClient::applyGs - We should not be here!\n";
  30. };
  31. void applyCl(CClient *cl)//called after applying to gs
  32. {
  33. tlog1 << "CPackForClient::applyCl - We should not be here!\n";
  34. };
  35. };
  36. struct Query : public CPackForClient
  37. {
  38. ui32 id;
  39. };
  40. struct MetaString : public CPack //2001 helper for object scrips
  41. {
  42. std::vector<std::string> strings;
  43. std::vector<std::pair<ui8,ui32> > texts; //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
  44. std::vector<si32> message;
  45. std::vector<std::string> replacements;
  46. template <typename Handler> void serialize(Handler &h, const int version)
  47. {
  48. h & strings & texts & message & replacements;
  49. }
  50. MetaString& operator<<(const std::pair<ui8,ui32> &txt)
  51. {
  52. message.push_back(-((si32)texts.size())-1);
  53. texts.push_back(txt);
  54. return *this;
  55. }
  56. MetaString& operator<<(const std::string &txt)
  57. {
  58. message.push_back(strings.size()+1);
  59. strings.push_back(txt);
  60. return *this;
  61. }
  62. void clear()
  63. {
  64. strings.clear();
  65. texts.clear();
  66. message.clear();
  67. }
  68. MetaString(){type = 2001;};
  69. };
  70. struct SystemMessage : public CPackForClient //95
  71. {
  72. SystemMessage(){type = 95;};
  73. void applyCl(CClient *cl);
  74. std::string text;
  75. template <typename Handler> void serialize(Handler &h, const int version)
  76. {
  77. h & text;
  78. }
  79. };
  80. struct YourTurn : public CPackForClient //100
  81. {
  82. YourTurn(){type = 100;};
  83. void applyCl(CClient *cl);
  84. DLL_EXPORT void applyGs(CGameState *gs);
  85. ui8 player;
  86. template <typename Handler> void serialize(Handler &h, const int version)
  87. {
  88. h & player;
  89. }
  90. };
  91. struct SetResource : public CPackForClient //102
  92. {
  93. SetResource(){type = 102;};
  94. void applyCl(CClient *cl);
  95. DLL_EXPORT void applyGs(CGameState *gs);
  96. ui8 player, resid;
  97. si32 val;
  98. template <typename Handler> void serialize(Handler &h, const int version)
  99. {
  100. h & player & resid & val;
  101. }
  102. };
  103. struct SetResources : public CPackForClient //104
  104. {
  105. SetResources(){res.resize(RESOURCE_QUANTITY);type = 104;};
  106. void applyCl(CClient *cl);
  107. DLL_EXPORT void applyGs(CGameState *gs);
  108. ui8 player;
  109. std::vector<si32> res; //res[resid] => res amount
  110. template <typename Handler> void serialize(Handler &h, const int version)
  111. {
  112. h & player & res;
  113. }
  114. };
  115. struct SetPrimSkill : public CPackForClient //105
  116. {
  117. SetPrimSkill(){type = 105;};
  118. void applyCl(CClient *cl);
  119. DLL_EXPORT void applyGs(CGameState *gs);
  120. ui8 abs; //0 - changes by value; 1 - sets to value
  121. si32 id;
  122. ui16 which, val;
  123. template <typename Handler> void serialize(Handler &h, const int version)
  124. {
  125. h & abs & id & which & val;
  126. }
  127. };
  128. struct SetSecSkill : public CPackForClient //106
  129. {
  130. SetSecSkill(){type = 106;};
  131. void applyCl(CClient *cl);
  132. DLL_EXPORT void applyGs(CGameState *gs);
  133. ui8 abs; //0 - changes by value; 1 - sets to value
  134. si32 id;
  135. ui16 which, val;
  136. template <typename Handler> void serialize(Handler &h, const int version)
  137. {
  138. h & abs & id & which & val;
  139. }
  140. };
  141. struct HeroVisitCastle : public CPackForClient //108
  142. {
  143. HeroVisitCastle(){flags=0;type = 108;};
  144. void applyCl(CClient *cl);
  145. DLL_EXPORT void applyGs(CGameState *gs);
  146. ui8 flags; //1 - start, 2 - garrison
  147. ui32 tid, hid;
  148. bool start() //if hero is entering castle (if false - leaving)
  149. {
  150. return flags & 1;
  151. }
  152. bool garrison() //if hero is entering/leaving garrison (if false - it's only visiting hero)
  153. {
  154. return flags & 2;
  155. }
  156. template <typename Handler> void serialize(Handler &h, const int version)
  157. {
  158. h & flags & tid & hid;
  159. }
  160. };
  161. struct ChangeSpells : public CPackForClient //109
  162. {
  163. ChangeSpells(){type = 109;};
  164. void applyCl(CClient *cl);
  165. DLL_EXPORT void applyGs(CGameState *gs);
  166. ui8 learn; //1 - gives spell, 0 - takes
  167. ui32 hid;
  168. std::set<ui32> spells;
  169. template <typename Handler> void serialize(Handler &h, const int version)
  170. {
  171. h & learn & hid & spells;
  172. }
  173. };
  174. struct SetMana : public CPackForClient //110
  175. {
  176. SetMana(){type = 110;};
  177. void applyCl(CClient *cl);
  178. DLL_EXPORT void applyGs(CGameState *gs);
  179. ui32 hid, val;
  180. template <typename Handler> void serialize(Handler &h, const int version)
  181. {
  182. h & val & hid;
  183. }
  184. };
  185. struct SetMovePoints : public CPackForClient //111
  186. {
  187. SetMovePoints(){type = 111;};
  188. void applyCl(CClient *cl);
  189. DLL_EXPORT void applyGs(CGameState *gs);
  190. ui32 hid, val;
  191. template <typename Handler> void serialize(Handler &h, const int version)
  192. {
  193. h & val & hid;
  194. }
  195. };
  196. struct FoWChange : public CPackForClient //112
  197. {
  198. FoWChange(){type = 112;};
  199. void applyCl(CClient *cl);
  200. DLL_EXPORT void applyGs(CGameState *gs);
  201. std::set<int3> tiles;
  202. ui8 player, mode; //mode==0 - hide, mode==1 - reveal
  203. template <typename Handler> void serialize(Handler &h, const int version)
  204. {
  205. h & tiles & player;
  206. }
  207. };
  208. struct SetAvailableHeroes : public CPackForClient //113
  209. {
  210. SetAvailableHeroes(){type = 113;flags=0;};
  211. void applyCl(CClient *cl);
  212. DLL_EXPORT void applyGs(CGameState *gs);
  213. ui8 player;
  214. si32 hid1, hid2;
  215. ui8 flags; //1 - reset army of hero1; 2 - reset army of hero 2
  216. template <typename Handler> void serialize(Handler &h, const int version)
  217. {
  218. h & player & hid1 & hid2 & flags;
  219. }
  220. };
  221. struct GiveBonus : public CPackForClient //115
  222. {
  223. GiveBonus(){type = 115;};
  224. void applyCl(CClient *cl);
  225. DLL_EXPORT void applyGs(CGameState *gs);
  226. ui32 hid;
  227. HeroBonus bonus;
  228. MetaString bdescr;
  229. template <typename Handler> void serialize(Handler &h, const int version)
  230. {
  231. h & bonus & hid & bdescr;
  232. }
  233. };
  234. struct ChangeObjPos : public CPackForClient //116
  235. {
  236. ChangeObjPos(){type = 116;};
  237. void applyFirstCl(CClient *cl);
  238. void applyCl(CClient *cl);
  239. DLL_EXPORT void applyGs(CGameState *gs);
  240. ui32 objid;
  241. int3 nPos;
  242. ui8 flags; //bit flags: 1 - redraw
  243. template <typename Handler> void serialize(Handler &h, const int version)
  244. {
  245. h & objid & nPos & flags;
  246. }
  247. };
  248. struct RemoveObject : public CPackForClient //500
  249. {
  250. RemoveObject(){type = 500;};
  251. RemoveObject(si32 ID){id = ID;type = 500;};
  252. void applyFirstCl(CClient *cl);
  253. void applyCl(CClient *cl);
  254. DLL_EXPORT void applyGs(CGameState *gs);
  255. si32 id;
  256. template <typename Handler> void serialize(Handler &h, const int version)
  257. {
  258. h & id;
  259. }
  260. };
  261. struct TryMoveHero : public CPackForClient //501
  262. {
  263. TryMoveHero(){type = 501;};
  264. void applyFirstCl(CClient *cl);
  265. void applyCl(CClient *cl);
  266. void applyqGs(CGameState *gs);
  267. ui32 id, movePoints;
  268. ui8 result; //0 - failed; 1- succes -normal move; 2 - teleportation, 3 - instant jump
  269. int3 start, end;
  270. std::set<int3> fowRevealed; //revealed tiles
  271. template <typename Handler> void serialize(Handler &h, const int version)
  272. {
  273. h & id & result & start & end & movePoints & fowRevealed;
  274. }
  275. };
  276. struct SetGarrisons : public CPackForClient //502
  277. {
  278. SetGarrisons(){type = 502;};
  279. void applyCl(CClient *cl);
  280. DLL_EXPORT void applyGs(CGameState *gs);
  281. std::map<ui32,CCreatureSet> garrs;
  282. template <typename Handler> void serialize(Handler &h, const int version)
  283. {
  284. h & garrs;
  285. }
  286. };
  287. struct NewStructures : public CPackForClient //504
  288. {
  289. NewStructures(){type = 504;};
  290. void applyCl(CClient *cl);
  291. DLL_EXPORT void applyGs(CGameState *gs);
  292. si32 tid;
  293. std::set<si32> bid;
  294. si16 builded;
  295. template <typename Handler> void serialize(Handler &h, const int version)
  296. {
  297. h & tid & bid & builded;
  298. }
  299. };
  300. struct SetAvailableCreatures : public CPackForClient //506
  301. {
  302. SetAvailableCreatures(){type = 506;};
  303. void applyCl(CClient *cl);
  304. DLL_EXPORT void applyGs(CGameState *gs);
  305. si32 tid;
  306. std::map<si32,ui32> creatures;
  307. template <typename Handler> void serialize(Handler &h, const int version)
  308. {
  309. h & tid & creatures;
  310. }
  311. };
  312. struct SetHeroesInTown : public CPackForClient //508
  313. {
  314. SetHeroesInTown(){type = 508;};
  315. void applyCl(CClient *cl);
  316. DLL_EXPORT void applyGs(CGameState *gs);
  317. si32 tid, visiting, garrison; //id of town, visiting hero, hero in garrison
  318. template <typename Handler> void serialize(Handler &h, const int version)
  319. {
  320. h & tid & visiting & garrison;
  321. }
  322. };
  323. struct SetHeroArtifacts : public CPackForClient //509
  324. {
  325. SetHeroArtifacts(){type = 509;};
  326. void applyCl(CClient *cl);
  327. DLL_EXPORT void applyGs(CGameState *gs);
  328. si32 hid;
  329. std::vector<ui32> artifacts; //hero's artifacts from bag
  330. std::map<ui16,ui32> artifWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
  331. template <typename Handler> void serialize(Handler &h, const int version)
  332. {
  333. h & hid & artifacts & artifWorn;
  334. }
  335. };
  336. struct PlayerMessage : public CPackForClient //513
  337. {
  338. PlayerMessage(){type = 513;};
  339. void applyCl(CClient *cl);
  340. ui8 player;
  341. std::string text;
  342. template <typename Handler> void serialize(Handler &h, const int version)
  343. {
  344. h & text & player;
  345. }
  346. };
  347. struct SetSelection : public CPackForClient //514
  348. {
  349. SetSelection(){type = 514;};
  350. DLL_EXPORT void applyGs(CGameState *gs);
  351. ui8 player;
  352. ui32 id;
  353. template <typename Handler> void serialize(Handler &h, const int version)
  354. {
  355. h & id & player;
  356. }
  357. };
  358. struct HeroRecruited : public CPackForClient //515
  359. {
  360. HeroRecruited(){type = 515;};
  361. void applyCl(CClient *cl);
  362. DLL_EXPORT void applyGs(CGameState *gs);
  363. si32 hid, tid; //subID of hero
  364. int3 tile;
  365. ui8 player;
  366. template <typename Handler> void serialize(Handler &h, const int version)
  367. {
  368. h & hid & tid & tile & player;
  369. }
  370. };
  371. struct GiveHero : public CPackForClient //516
  372. {
  373. GiveHero(){type = 516;};
  374. void applyFirstCl(CClient *cl);
  375. void applyCl(CClient *cl);
  376. DLL_EXPORT void applyGs(CGameState *gs);
  377. ui32 id; //object id
  378. ui8 player;
  379. template <typename Handler> void serialize(Handler &h, const int version)
  380. {
  381. h & id & player;
  382. }
  383. };
  384. struct NewTurn : public CPackForClient //101
  385. {
  386. DLL_EXPORT void applyGs(CGameState *gs);
  387. struct Hero
  388. {
  389. ui32 id, move, mana; //id is a general serial id
  390. template <typename Handler> void serialize(Handler &h, const int version)
  391. {
  392. h & id & move & mana;
  393. }
  394. bool operator<(const Hero&h)const{return id < h.id;}
  395. };
  396. std::set<Hero> heroes; //updates movement and mana points
  397. std::vector<SetResources> res;//resource list
  398. std::vector<SetAvailableCreatures> cres;//resource list
  399. ui32 day;
  400. bool resetBuilded;
  401. NewTurn(){type = 101;};
  402. template <typename Handler> void serialize(Handler &h, const int version)
  403. {
  404. h & heroes & cres & res & day & resetBuilded;
  405. }
  406. };
  407. struct Component : public CPack //2002 helper for object scrips informations
  408. {
  409. ui16 id, subtype; //ids: 0 - primskill; 1 - secskill; 2 - resource; 3 - creature; 4 - artifact; 5 - experience (sub==0 exp points; sub==1 levels)
  410. si32 val; // + give; - take
  411. si16 when; // 0 - now; +x - within x days; -x - per x days
  412. template <typename Handler> void serialize(Handler &h, const int version)
  413. {
  414. h & id & subtype & val & when;
  415. }
  416. Component(){type = 2002;};
  417. Component(ui16 Type, ui16 Subtype, si32 Val, si16 When):id(Type),subtype(Subtype),val(Val),when(When){type = 2002;};
  418. };
  419. struct InfoWindow : public CPackForClient //103 - displays simple info window
  420. {
  421. void applyCl(CClient *cl);
  422. MetaString text;
  423. std::vector<Component> components;
  424. ui8 player;
  425. template <typename Handler> void serialize(Handler &h, const int version)
  426. {
  427. h & text & components & player;
  428. }
  429. InfoWindow(){type = 103;};
  430. };
  431. struct SetObjectProperty : public CPackForClient//1001
  432. {
  433. DLL_EXPORT void applyGs(CGameState *gs);
  434. ui32 id;
  435. ui8 what; //1 - owner; 2 - blockvis; 3 - first stack count; 4 - visitors; 5 - visited; 6 - ID (if 34 then also def is replaced)
  436. ui32 val;
  437. SetObjectProperty(){type = 1001;};
  438. SetObjectProperty(ui32 ID, ui8 What, ui32 Val):id(ID),what(What),val(Val){type = 1001;};
  439. template <typename Handler> void serialize(Handler &h, const int version)
  440. {
  441. h & id & what & val;
  442. }
  443. };
  444. struct SetHoverName : public CPackForClient//1002
  445. {
  446. DLL_EXPORT void applyGs(CGameState *gs);
  447. ui32 id;
  448. MetaString name;
  449. SetHoverName(){type = 1002;};
  450. SetHoverName(ui32 ID, MetaString& Name):id(ID),name(Name){type = 1002;};
  451. template <typename Handler> void serialize(Handler &h, const int version)
  452. {
  453. h & id & name;
  454. }
  455. };
  456. struct HeroLevelUp : public Query//2000
  457. {
  458. void applyCl(CClient *cl);
  459. DLL_EXPORT void applyGs(CGameState *gs);
  460. si32 heroid;
  461. ui8 primskill, level;
  462. std::vector<ui16> skills;
  463. HeroLevelUp(){type = 2000;};
  464. template <typename Handler> void serialize(Handler &h, const int version)
  465. {
  466. h & id & heroid & primskill & level & skills;
  467. }
  468. };
  469. struct SelectionDialog : public Query//2001
  470. {
  471. void applyCl(CClient *cl);
  472. MetaString text;
  473. std::vector<Component> components;
  474. ui8 player;
  475. SelectionDialog(){type = 2001;};
  476. template <typename Handler> void serialize(Handler &h, const int version)
  477. {
  478. h & id & text & components & player;
  479. }
  480. };
  481. struct YesNoDialog : public Query//2002
  482. {
  483. void applyCl(CClient *cl);
  484. MetaString text;
  485. std::vector<Component> components;
  486. ui8 player;
  487. YesNoDialog(){type = 2002;};
  488. template <typename Handler> void serialize(Handler &h, const int version)
  489. {
  490. h & id & text & components & player;
  491. }
  492. };
  493. struct BattleInfo;
  494. struct BattleStart : public CPackForClient//3000
  495. {
  496. BattleStart(){type = 3000;};
  497. void applyCl(CClient *cl);
  498. DLL_EXPORT void applyGs(CGameState *gs);
  499. BattleInfo * info;
  500. template <typename Handler> void serialize(Handler &h, const int version)
  501. {
  502. h & info;
  503. }
  504. };
  505. struct BattleNextRound : public CPackForClient//3001
  506. {
  507. BattleNextRound(){type = 3001;};
  508. void applyCl(CClient *cl);
  509. DLL_EXPORT void applyGs(CGameState *gs);
  510. si32 round;
  511. template <typename Handler> void serialize(Handler &h, const int version)
  512. {
  513. h & round;
  514. }
  515. };
  516. struct BattleSetActiveStack : public CPackForClient//3002
  517. {
  518. BattleSetActiveStack(){type = 3002;};
  519. void applyCl(CClient *cl);
  520. DLL_EXPORT void applyGs(CGameState *gs);
  521. ui32 stack;
  522. template <typename Handler> void serialize(Handler &h, const int version)
  523. {
  524. h & stack;
  525. }
  526. };
  527. struct BattleResult : public CPackForClient//3003
  528. {
  529. BattleResult(){type = 3003;};
  530. void applyFirstCl(CClient *cl);
  531. void applyqGs(CGameState *gs);
  532. ui8 result; //0 - normal victory; 1 - escape; 2 - surrender
  533. ui8 winner; //0 - attacker, 1 - defender, [2 - draw (should be possible?)]
  534. std::set<std::pair<ui32,si32> > casualties[2]; //first => casualties of attackers - set of pairs crid<>number
  535. ui32 exp[2]; //exp for attacker and defender
  536. std::set<ui32> artifacts; //artifacts taken from loser to winner
  537. template <typename Handler> void serialize(Handler &h, const int version)
  538. {
  539. h & result & winner & casualties[0] & casualties[1] & exp & artifacts;
  540. }
  541. };
  542. struct BattleStackMoved : public CPackForClient//3004
  543. {
  544. BattleStackMoved(){type = 3004;};
  545. void applyFirstCl(CClient *cl);
  546. void applyqGs(CGameState *gs);
  547. ui32 stack, tile;
  548. template <typename Handler> void serialize(Handler &h, const int version)
  549. {
  550. h & stack & tile;
  551. }
  552. };
  553. struct BattleStackAttacked : public CPackForClient//3005
  554. {
  555. BattleStackAttacked(){flags = 0; type = 3005;};
  556. void applyCl(CClient *cl);
  557. DLL_EXPORT void applyGs(CGameState *gs);
  558. ui32 stackAttacked;
  559. ui32 newAmount, newHP, killedAmount, damageAmount;
  560. ui8 flags; //1 - is stack killed; 2 - is there special effect to be shown; 4 - lucky hit
  561. ui32 effect; //set only if flag 2 is present
  562. bool killed() //if target stack was killed
  563. {
  564. return flags & 1;
  565. }
  566. bool isEffect() //if target stack was killed
  567. {
  568. return flags & 2;
  569. }
  570. bool lucky()
  571. {
  572. return flags & 4;
  573. }
  574. template <typename Handler> void serialize(Handler &h, const int version)
  575. {
  576. h & stackAttacked & newAmount & newHP & flags & killedAmount & damageAmount & effect;
  577. }
  578. };
  579. struct BattleAttack : public CPackForClient//3006
  580. {
  581. BattleAttack(){flags = 0; type = 3006;};
  582. void applyFirstCl(CClient *cl);
  583. DLL_EXPORT void applyGs(CGameState *gs);
  584. void applyCl(CClient *cl);
  585. BattleStackAttacked bsa;
  586. ui32 stackAttacking;
  587. ui8 flags;
  588. bool shot()//distance attack - decrease number of shots
  589. {
  590. return flags & 1;
  591. }
  592. bool counter()//is it counterattack?
  593. {
  594. return flags & 2;
  595. }
  596. bool killed() //if target stack was killed
  597. {
  598. return bsa.killed();
  599. }
  600. template <typename Handler> void serialize(Handler &h, const int version)
  601. {
  602. h & bsa & stackAttacking & flags;
  603. }
  604. };
  605. struct StartAction : public CPackForClient//3007
  606. {
  607. StartAction(){type = 3007;};
  608. StartAction(const BattleAction &act){ba = act; type = 3007;};
  609. void applyFirstCl(CClient *cl);
  610. DLL_EXPORT void applyGs(CGameState *gs);
  611. BattleAction ba;
  612. template <typename Handler> void serialize(Handler &h, const int version)
  613. {
  614. h & ba;
  615. }
  616. };
  617. struct EndAction : public CPackForClient//3008
  618. {
  619. EndAction(){type = 3008;};
  620. void applyCl(CClient *cl);
  621. template <typename Handler> void serialize(Handler &h, const int version)
  622. {
  623. }
  624. };
  625. struct SpellCasted : public CPackForClient//3009
  626. {
  627. SpellCasted(){type = 3009;};
  628. DLL_EXPORT void applyGs(CGameState *gs);
  629. void applyCl(CClient *cl);
  630. ui8 side; //which hero casted spell: 0 - attacker, 1 - defender
  631. ui32 id;
  632. ui8 skill;
  633. ui16 tile; //destination tile (may not be set in some global/mass spells
  634. template <typename Handler> void serialize(Handler &h, const int version)
  635. {
  636. h & side & id & skill & tile;
  637. }
  638. };
  639. struct SetStackEffect : public CPackForClient //3010
  640. {
  641. SetStackEffect(){type = 3010;};
  642. DLL_EXPORT void applyGs(CGameState *gs);
  643. void applyCl(CClient *cl);
  644. ui32 stack;
  645. CStack::StackEffect effect;
  646. template <typename Handler> void serialize(Handler &h, const int version)
  647. {
  648. h & stack & effect;
  649. }
  650. };
  651. struct ShowInInfobox : public CPackForClient //107
  652. {
  653. ShowInInfobox(){type = 107;};
  654. ui8 player;
  655. Component c;
  656. MetaString text;
  657. void applyCl(CClient *cl);
  658. template <typename Handler> void serialize(Handler &h, const int version)
  659. {
  660. h & player & c & text;
  661. }
  662. };
  663. #endif //__NETPACKS_H__