OMP_CRC.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OMP_CRC.CPP
  21. //Description : crc checking for multiplayer debugging
  22. //Owner : Alex
  23. #include <CRC.h>
  24. #include <OU_GOD.h>
  25. #include <OU_VEHI.h>
  26. #include <OU_MONS.h>
  27. #include <OU_CART.h>
  28. #include <OU_MARI.h>
  29. #include <OU_CARA.h>
  30. #include <OFIRM.h>
  31. #include <OF_BASE.h>
  32. #include <OF_CAMP.h>
  33. #include <OF_FACT.h>
  34. #include <OF_INN.h>
  35. #include <OF_MARK.h>
  36. #include <OF_MINE.h>
  37. #include <OF_RESE.h>
  38. #include <OF_WAR.h>
  39. #include <OF_HARB.h>
  40. #include <OF_MONS.h>
  41. #include <OTOWN.h>
  42. #include <ONATIONB.h>
  43. #include <OBULLET.h>
  44. #include <OB_PROJ.h>
  45. #include <OB_HOMIN.h>
  46. #include <OB_FLAME.h>
  47. // ###### patch begin Gilbert 20/1 #######//
  48. #include <OREBEL.h>
  49. #include <OSPY.h>
  50. // ###### patch end Gilbert 20/1 #######//
  51. #include <OTALKRES.h>
  52. // ###### patch begin Gilbert 21/1 #####//
  53. #define RTRIM_ARRAY(a,s) { if(s<sizeof(a)/sizeof(*a)) memset(a+s,0,sizeof(a)-s*sizeof(*a)); }
  54. // ###### patch end Gilbert 21/1 #####//
  55. static union
  56. {
  57. char sprite[sizeof(Sprite)];
  58. char unit[sizeof(Unit)];
  59. char unit_god[sizeof(UnitGod)];
  60. char unit_vehicle[sizeof(UnitVehicle)];
  61. char unit_monster[sizeof(UnitMonster)];
  62. char unit_exp_cart[sizeof(UnitExpCart)];
  63. char unit_marine[sizeof(UnitMarine)];
  64. char unit_caravan[sizeof(UnitCaravan)];
  65. char firm[sizeof(Firm)];
  66. char firm_base[sizeof(FirmBase)];
  67. char firm_camp[sizeof(FirmCamp)];
  68. char firm_factory[sizeof(FirmFactory)];
  69. char firm_inn[sizeof(FirmInn)];
  70. char firm_market[sizeof(FirmMarket)];
  71. char firm_mine[sizeof(FirmMine)];
  72. char firm_research[sizeof(FirmResearch)];
  73. char firm_war[sizeof(FirmWar)];
  74. char firm_harbor[sizeof(FirmHarbor)];
  75. char firm_monster[sizeof(FirmMonster)];
  76. char town[sizeof(Town)];
  77. char nation[sizeof(NationBase)];
  78. char bullet[sizeof(Bullet)];
  79. char projectile[sizeof(Projectile)];
  80. char bullet_homing[sizeof(BulletHoming)];
  81. char bullet_flame[sizeof(BulletFlame)];
  82. // ###### patch begin Gilbert 20/1 #######//
  83. char rebel[sizeof(Rebel)];
  84. char spy[sizeof(Spy)];
  85. // ###### patch end Gilbert 20/1 #######//
  86. char talk_msg[sizeof(TalkMsg)];
  87. } temp_obj;
  88. //----------- End of function Sprite::crc8 -----------//
  89. UCHAR Sprite::crc8()
  90. {
  91. Sprite &dummySprite = *(Sprite *)temp_obj.sprite;
  92. memcpy(&dummySprite, this, sizeof(Sprite));
  93. dummySprite.clear_ptr();
  94. *((char**) &dummySprite) = NULL;
  95. UCHAR c = ::crc8((UCHAR*)&dummySprite, sizeof(Sprite));
  96. return c;
  97. }
  98. //----------- End of function Sprite::crc8 -----------//
  99. //----------- End of function Sprite::clear_ptr -----------//
  100. void Sprite::clear_ptr()
  101. {
  102. sprite_info = NULL;
  103. }
  104. //----------- End of function Sprite::clear_ptr -----------//
  105. //----------- End of function Unit::crc8 -----------//
  106. UCHAR Unit::crc8()
  107. {
  108. Unit &dummyUnit = *(Unit *)temp_obj.unit;
  109. memcpy(&dummyUnit, this, sizeof(Unit));
  110. dummyUnit.clear_ptr();
  111. *((char**) &dummyUnit) = NULL;
  112. UCHAR c = ::crc8((UCHAR*)&dummyUnit, sizeof(Unit));
  113. return c;
  114. }
  115. //----------- End of function Unit::crc8 -----------//
  116. //----------- End of function Unit::clear_ptr -----------//
  117. void Unit::clear_ptr()
  118. {
  119. Sprite::clear_ptr();
  120. selected_flag = 0;
  121. group_select_id = 0;
  122. attack_info_array = NULL;
  123. result_node_array = NULL;
  124. way_point_array = NULL;
  125. team_info = NULL;
  126. if( !original_action_mode )
  127. {
  128. original_action_para = 0;
  129. original_action_x_loc = 0;
  130. original_action_y_loc = 0;
  131. original_target_x_loc = 0;
  132. original_target_y_loc = 0;
  133. ai_original_target_x_loc = 0;
  134. ai_original_target_y_loc = 0;
  135. }
  136. }
  137. //----------- End of function Unit::clear_ptr -----------//
  138. //----------- End of function UnitGod::crc8 -----------//
  139. UCHAR UnitGod::crc8()
  140. {
  141. UnitGod &dummyUnitGod = *(UnitGod *)temp_obj.unit_god;
  142. memcpy(&dummyUnitGod, this, sizeof(UnitGod));
  143. dummyUnitGod.clear_ptr();
  144. *((char**) &dummyUnitGod) = NULL;
  145. UCHAR c = ::crc8((UCHAR*)&dummyUnitGod, sizeof(UnitGod));
  146. return c;
  147. }
  148. //----------- End of function UnitGod::crc8 -----------//
  149. //----------- End of function UnitGod::clear_ptr -----------//
  150. void UnitGod::clear_ptr()
  151. {
  152. Unit::clear_ptr();
  153. if( !cast_power_type )
  154. {
  155. cast_origin_x = 0;
  156. cast_origin_y = 0;
  157. cast_target_x = 0;
  158. cast_target_y = 0;
  159. }
  160. }
  161. //----------- End of function UnitGod::clear_ptr -----------//
  162. //----------- End of function UnitVehicle::crc8 -----------//
  163. UCHAR UnitVehicle::crc8()
  164. {
  165. UnitVehicle &dummyUnitVehicle = *(UnitVehicle *)temp_obj.unit_vehicle;
  166. memcpy(&dummyUnitVehicle, this, sizeof(UnitVehicle));
  167. dummyUnitVehicle.clear_ptr();
  168. *((char**) &dummyUnitVehicle) = NULL;
  169. UCHAR c = ::crc8((UCHAR*)&dummyUnitVehicle, sizeof(UnitVehicle));
  170. return c;
  171. }
  172. //----------- End of function UnitVehicle::crc8 -----------//
  173. //----------- End of function UnitVehicle::clear_ptr -----------//
  174. void UnitVehicle::clear_ptr()
  175. {
  176. Unit::clear_ptr();
  177. }
  178. //----------- End of function UnitVehicle::clear_ptr -----------//
  179. //----------- End of function UnitMonster::crc8 -----------//
  180. UCHAR UnitMonster::crc8()
  181. {
  182. UnitMonster &dummyUnitMonster = *(UnitMonster *)temp_obj.unit_monster;
  183. memcpy(&dummyUnitMonster, this, sizeof(UnitMonster));
  184. dummyUnitMonster.clear_ptr();
  185. *((char**) &dummyUnitMonster) = NULL;
  186. UCHAR c = ::crc8((UCHAR*)&dummyUnitMonster, sizeof(UnitMonster));
  187. return c;
  188. }
  189. //----------- End of function UnitMonster::crc8 -----------//
  190. //----------- End of function UnitMonster::clear_ptr -----------//
  191. void UnitMonster::clear_ptr()
  192. {
  193. Unit::clear_ptr();
  194. }
  195. //----------- End of function UnitMonster::clear_ptr -----------//
  196. //----------- End of function UnitExpCart::crc8 -----------//
  197. UCHAR UnitExpCart::crc8()
  198. {
  199. UnitExpCart &dummyUnitExpCart = *(UnitExpCart *)temp_obj.unit_exp_cart;
  200. memcpy(&dummyUnitExpCart, this, sizeof(UnitExpCart));
  201. dummyUnitExpCart.clear_ptr();
  202. *((char**) &dummyUnitExpCart) = NULL;
  203. UCHAR c = ::crc8((UCHAR*)&dummyUnitExpCart, sizeof(UnitExpCart));
  204. return c;
  205. }
  206. //----------- End of function UnitExpCart::crc8 -----------//
  207. //----------- End of function UnitExpCart::clear_ptr -----------//
  208. void UnitExpCart::clear_ptr()
  209. {
  210. Unit::clear_ptr();
  211. }
  212. //----------- End of function UnitExpCart::clear_ptr -----------//
  213. //----------- End of function UnitMarine::crc8 -----------//
  214. UCHAR UnitMarine::crc8()
  215. {
  216. UnitMarine &dummyUnitMarine = *(UnitMarine *)temp_obj.unit_marine;
  217. memcpy(&dummyUnitMarine, this, sizeof(UnitMarine));
  218. dummyUnitMarine.clear_ptr();
  219. *((char**) &dummyUnitMarine) = NULL;
  220. UCHAR c = ::crc8((UCHAR*)&dummyUnitMarine, sizeof(UnitMarine));
  221. return c;
  222. }
  223. //----------- End of function UnitMarine::crc8 -----------//
  224. //----------- End of function UnitMarine::clear_ptr -----------//
  225. void UnitMarine::clear_ptr()
  226. {
  227. memset(&splash, 0, sizeof(splash));
  228. //### begin alex 23/10 ###//
  229. selected_unit_id = 0;
  230. menu_mode = 0;
  231. //#### end alex 23/10 ####//
  232. // ###### patch begin Gilbert 21/1 ######//
  233. // must do this step before clear_ptr(), attack_info_array is reset there
  234. if( !attack_info_array )
  235. memset(&ship_attack_info, 0, sizeof(ship_attack_info));
  236. // ###### patch end Gilbert 21/1 ######//
  237. Unit::clear_ptr();
  238. RTRIM_ARRAY(unit_recno_array, unit_count);
  239. for( int i = 0; i < sizeof(stop_array)/sizeof(*stop_array); ++i)
  240. {
  241. if( !stop_array[i].firm_recno )
  242. {
  243. memset(&stop_array[i], 0, sizeof(*stop_array));
  244. }
  245. }
  246. }
  247. //----------- End of function UnitMarine::clear_ptr -----------//
  248. //----------- End of function UnitCaravan::crc8 -----------//
  249. UCHAR UnitCaravan::crc8()
  250. {
  251. UnitCaravan &dummyUnitCaravan = *(UnitCaravan *)temp_obj.unit_caravan;
  252. memcpy(&dummyUnitCaravan, this, sizeof(UnitCaravan));
  253. dummyUnitCaravan.clear_ptr();
  254. *((char**) &dummyUnitCaravan) = NULL;
  255. UCHAR c = ::crc8((UCHAR*)&dummyUnitCaravan, sizeof(UnitCaravan));
  256. return c;
  257. }
  258. //----------- End of function UnitCaravan::crc8 -----------//
  259. //----------- End of function UnitCaravan::clear_ptr -----------//
  260. void UnitCaravan::clear_ptr()
  261. {
  262. Unit::clear_ptr();
  263. caravan_id = 0; // caravan_id is no longer valid
  264. for( int i = 0; i < sizeof(stop_array)/sizeof(*stop_array); ++i)
  265. {
  266. if( !stop_array[i].firm_recno )
  267. {
  268. memset(&stop_array[i], 0, sizeof(*stop_array));
  269. }
  270. }
  271. }
  272. //----------- End of function UnitCaravan::clear_ptr -----------//
  273. //----------- End of function Firm::crc8 -----------//
  274. UCHAR Firm::crc8()
  275. {
  276. Firm &dummyFirm = *(Firm *)temp_obj.firm;
  277. memcpy(&dummyFirm, this, sizeof(Firm));
  278. dummyFirm.clear_ptr();
  279. *((char**) &dummyFirm) = NULL;
  280. UCHAR c = ::crc8((UCHAR*)&dummyFirm, sizeof(Firm));
  281. return c;
  282. }
  283. //----------- End of function Firm::crc8 -----------//
  284. //----------- End of function Firm::clear_ptr -----------//
  285. void Firm::clear_ptr()
  286. {
  287. worker_array = NULL;
  288. selected_worker_id = 0;
  289. player_spy_count = 0;
  290. // clear unused element in linked_firm_array, linked_firm_enable_array
  291. RTRIM_ARRAY(linked_firm_array, linked_firm_count);
  292. RTRIM_ARRAY(linked_firm_enable_array, linked_firm_count);
  293. // clear unused element in linked_town_array, linked_town_enable_array
  294. RTRIM_ARRAY(linked_town_array, linked_town_count);
  295. RTRIM_ARRAY(linked_town_enable_array, linked_town_count);
  296. }
  297. //----------- End of function Firm::clear_ptr -----------//
  298. //----------- End of function FirmBase::crc8 -----------//
  299. UCHAR FirmBase::crc8()
  300. {
  301. FirmBase &dummyFirmBase = *(FirmBase *)temp_obj.firm_base;
  302. memcpy(&dummyFirmBase, this, sizeof(FirmBase));
  303. dummyFirmBase.clear_ptr();
  304. *((char**) &dummyFirmBase) = NULL;
  305. UCHAR c = ::crc8((UCHAR*)&dummyFirmBase, sizeof(FirmBase));
  306. return c;
  307. }
  308. //----------- End of function FirmBase::crc8 -----------//
  309. //----------- End of function FirmBase::clear_ptr -----------//
  310. void FirmBase::clear_ptr()
  311. {
  312. Firm::clear_ptr();
  313. }
  314. //----------- End of function FirmBase::clear_ptr -----------//
  315. //----------- End of function FirmCamp::crc8 -----------//
  316. UCHAR FirmCamp::crc8()
  317. {
  318. FirmCamp &dummyFirmCamp = *(FirmCamp *)temp_obj.firm_camp;
  319. memcpy(&dummyFirmCamp, this, sizeof(FirmCamp));
  320. dummyFirmCamp.clear_ptr();
  321. *((char**) &dummyFirmCamp) = NULL;
  322. UCHAR c = ::crc8((UCHAR*)&dummyFirmCamp, sizeof(FirmCamp));
  323. return c;
  324. }
  325. //----------- End of function FirmCamp::crc8 -----------//
  326. //----------- End of function FirmCamp::clear_ptr -----------//
  327. void FirmCamp::clear_ptr()
  328. {
  329. Firm::clear_ptr();
  330. // clear unused element in defense_array
  331. for( int i = 0; i < sizeof(defense_array)/sizeof(*defense_array); ++i )
  332. {
  333. if( !defense_array[i].unit_recno )
  334. {
  335. memset(&defense_array[i], 0, sizeof(*defense_array));
  336. }
  337. }
  338. // clear unused element in patrol_unit_array
  339. RTRIM_ARRAY(patrol_unit_array, patrol_unit_count);
  340. // clear unused element in coming_unit_array
  341. RTRIM_ARRAY(coming_unit_array, coming_unit_count);
  342. }
  343. //----------- End of function FirmCamp::clear_ptr -----------//
  344. //----------- End of function FirmFactory::crc8 -----------//
  345. UCHAR FirmFactory::crc8()
  346. {
  347. FirmFactory &dummyFirmFactory = *(FirmFactory *)temp_obj.firm_factory;
  348. memcpy(&dummyFirmFactory, this, sizeof(FirmFactory));
  349. dummyFirmFactory.clear_ptr();
  350. *((char**) &dummyFirmFactory) = NULL;
  351. UCHAR c = ::crc8((UCHAR*)&dummyFirmFactory, sizeof(FirmFactory));
  352. return c;
  353. }
  354. //----------- End of function FirmFactory::crc8 -----------//
  355. //----------- End of function FirmFactory::clear_ptr -----------//
  356. void FirmFactory::clear_ptr()
  357. {
  358. Firm::clear_ptr();
  359. }
  360. //----------- End of function FirmFactory::clear_ptr -----------//
  361. //----------- End of function FirmInn::crc8 -----------//
  362. UCHAR FirmInn::crc8()
  363. {
  364. FirmInn &dummyFirmInn = *(FirmInn *)temp_obj.firm_inn;
  365. memcpy(&dummyFirmInn, this, sizeof(FirmInn));
  366. dummyFirmInn.clear_ptr();
  367. *((char**) &dummyFirmInn) = NULL;
  368. UCHAR c = ::crc8((UCHAR*)&dummyFirmInn, sizeof(FirmInn));
  369. return c;
  370. }
  371. //----------- End of function FirmInn::crc8 -----------//
  372. //----------- End of function FirmInn::clear_ptr -----------//
  373. void FirmInn::clear_ptr()
  374. {
  375. Firm::clear_ptr();
  376. // clear unused element in inn_unit_array
  377. RTRIM_ARRAY(inn_unit_array, inn_unit_count);
  378. }
  379. //----------- End of function FirmInn::clear_ptr -----------//
  380. //----------- End of function FirmMarket::crc8 -----------//
  381. UCHAR FirmMarket::crc8()
  382. {
  383. FirmMarket &dummyFirmMarket = *(FirmMarket *)temp_obj.firm_market;
  384. memcpy(&dummyFirmMarket, this, sizeof(FirmMarket));
  385. dummyFirmMarket.clear_ptr();
  386. *((char**) &dummyFirmMarket) = NULL;
  387. UCHAR c = ::crc8((UCHAR*)&dummyFirmMarket, sizeof(FirmMarket));
  388. return c;
  389. }
  390. //----------- End of function FirmMarket::crc8 -----------//
  391. //----------- End of function FirmMarket::clear_ptr -----------//
  392. void FirmMarket::clear_ptr()
  393. {
  394. int i;
  395. for(i=0; i<MAX_RAW; ++i)
  396. market_raw_array[i] = NULL;
  397. for(i=0; i<MAX_PRODUCT; ++i)
  398. market_product_array[i] = NULL;
  399. // clear unused element in defense_array
  400. for( i = 0; i < sizeof(market_goods_array)/sizeof(*market_goods_array); ++i )
  401. {
  402. if( !market_goods_array[i].raw_id && !market_goods_array[i].product_raw_id )
  403. {
  404. memset(&market_goods_array[i], 0, sizeof(*market_goods_array));
  405. }
  406. }
  407. Firm::clear_ptr();
  408. }
  409. //----------- End of function FirmMarket::clear_ptr -----------//
  410. //----------- End of function FirmMine::crc8 -----------//
  411. UCHAR FirmMine::crc8()
  412. {
  413. FirmMine &dummyFirmMine = *(FirmMine *)temp_obj.firm_mine;
  414. memcpy(&dummyFirmMine, this, sizeof(FirmMine));
  415. dummyFirmMine.clear_ptr();
  416. *((char**) &dummyFirmMine) = NULL;
  417. UCHAR c = ::crc8((UCHAR*)&dummyFirmMine, sizeof(FirmMine));
  418. return c;
  419. }
  420. //----------- End of function FirmMine::crc8 -----------//
  421. //----------- End of function FirmMine::clear_ptr -----------//
  422. void FirmMine::clear_ptr()
  423. {
  424. Firm::clear_ptr();
  425. }
  426. //----------- End of function FirmMine::clear_ptr -----------//
  427. //----------- End of function FirmResearch::crc8 -----------//
  428. UCHAR FirmResearch::crc8()
  429. {
  430. FirmResearch &dummyFirmResearch = *(FirmResearch *)temp_obj.firm_research;
  431. memcpy(&dummyFirmResearch, this, sizeof(FirmResearch));
  432. dummyFirmResearch.clear_ptr();
  433. *((char**) &dummyFirmResearch) = NULL;
  434. UCHAR c = ::crc8((UCHAR*)&dummyFirmResearch, sizeof(FirmResearch));
  435. return c;
  436. }
  437. //----------- End of function FirmResearch::crc8 -----------//
  438. //----------- End of function FirmResearch::clear_ptr -----------//
  439. void FirmResearch::clear_ptr()
  440. {
  441. Firm::clear_ptr();
  442. }
  443. //----------- End of function FirmResearch::clear_ptr -----------//
  444. //----------- End of function FirmWar::crc8 -----------//
  445. UCHAR FirmWar::crc8()
  446. {
  447. FirmWar &dummyFirmWar = *(FirmWar *)temp_obj.firm_war;
  448. memcpy(&dummyFirmWar, this, sizeof(FirmWar));
  449. dummyFirmWar.clear_ptr();
  450. *((char**) &dummyFirmWar) = NULL;
  451. UCHAR c = ::crc8((UCHAR*)&dummyFirmWar, sizeof(FirmWar));
  452. return c;
  453. }
  454. //----------- End of function FirmWar::crc8 -----------//
  455. //----------- End of function FirmWar::clear_ptr -----------//
  456. void FirmWar::clear_ptr()
  457. {
  458. Firm::clear_ptr();
  459. // if nothing building clear some variables
  460. if( !build_unit_id )
  461. {
  462. last_process_build_frame_no = 0;
  463. build_progress_days = (float)0.0;
  464. }
  465. // clear unused build_queue_array
  466. RTRIM_ARRAY(build_queue_array, build_queue_count);
  467. }
  468. //----------- End of function FirmWar::clear_ptr -----------//
  469. //----------- End of function FirmHarbor::crc8 -----------//
  470. UCHAR FirmHarbor::crc8()
  471. {
  472. FirmHarbor &dummyFirmHarbor = *(FirmHarbor *)temp_obj.firm_harbor;
  473. memcpy(&dummyFirmHarbor, this, sizeof(FirmHarbor));
  474. dummyFirmHarbor.clear_ptr();
  475. *((char**) &dummyFirmHarbor) = NULL;
  476. UCHAR c = ::crc8((UCHAR*)&dummyFirmHarbor, sizeof(FirmHarbor));
  477. return c;
  478. }
  479. //----------- End of function FirmHarbor::crc8 -----------//
  480. //----------- End of function FirmHarbor::clear_ptr -----------//
  481. void FirmHarbor::clear_ptr()
  482. {
  483. Firm::clear_ptr();
  484. if(!build_unit_id)
  485. start_build_frame_no = 0;
  486. RTRIM_ARRAY(ship_recno_array, ship_count);
  487. RTRIM_ARRAY(build_queue_array, build_queue_count);
  488. RTRIM_ARRAY(linked_mine_array, linked_mine_num);
  489. RTRIM_ARRAY(linked_factory_array, linked_factory_num);
  490. RTRIM_ARRAY(linked_market_array, linked_market_num);
  491. }
  492. //----------- End of function FirmHarbor::clear_ptr -----------//
  493. //----------- End of function FirmMonster::crc8 -----------//
  494. UCHAR FirmMonster::crc8()
  495. {
  496. FirmMonster &dummyFirmMonster = *(FirmMonster *)temp_obj.firm_monster;
  497. memcpy(&dummyFirmMonster, this, sizeof(FirmMonster));
  498. dummyFirmMonster.clear_ptr();
  499. *((char**) &dummyFirmMonster) = NULL;
  500. UCHAR c = ::crc8((UCHAR*)&dummyFirmMonster, sizeof(FirmMonster));
  501. return c;
  502. }
  503. //----------- End of function FirmMonster::crc8 -----------//
  504. //----------- End of function FirmMonster::clear_ptr -----------//
  505. void FirmMonster::clear_ptr()
  506. {
  507. Firm::clear_ptr();
  508. if( !monster_king.monster_id )
  509. {
  510. monster_king.unit_id = 0;
  511. monster_king.mobile_unit_recno = 0;
  512. monster_king.combat_level = 0;
  513. monster_king.hit_points = 0;
  514. monster_king.max_hit_points = 0;
  515. }
  516. RTRIM_ARRAY(monster_general_array, monster_general_count);
  517. RTRIM_ARRAY(waiting_soldier_array, waiting_soldier_count);
  518. RTRIM_ARRAY(patrol_unit_array, patrol_unit_count);
  519. }
  520. //----------- End of function FirmMonster::clear_ptr -----------//
  521. //----------- End of function Town::crc8 -----------//
  522. UCHAR Town::crc8()
  523. {
  524. Town &dummyTown = *(Town *)temp_obj.town;
  525. memcpy(&dummyTown, this, sizeof(Town));
  526. dummyTown.clear_ptr();
  527. // to clear virtual table pointer, possibly in the future
  528. if( (void *)&dummyTown != (void *)&dummyTown.town_recno )
  529. *((char**) &dummyTown) = NULL;
  530. UCHAR c = ::crc8((UCHAR*)&dummyTown, sizeof(Town));
  531. return c;
  532. }
  533. //----------- End of function Town::crc8 -----------//
  534. //----------- End of function Town::clear_ptr -----------//
  535. void Town::clear_ptr()
  536. {
  537. int layoutCount = town_res.get_layout(layout_id)->slot_count;
  538. RTRIM_ARRAY(slot_object_id_array, layoutCount);
  539. RTRIM_ARRAY(train_queue_skill_array, train_queue_count);
  540. RTRIM_ARRAY(train_queue_race_array, train_queue_count);
  541. RTRIM_ARRAY(linked_firm_array, linked_firm_count);
  542. RTRIM_ARRAY(linked_firm_enable_array, linked_firm_count);
  543. RTRIM_ARRAY(linked_town_array, linked_town_count);
  544. RTRIM_ARRAY(linked_town_enable_array, linked_town_count);
  545. }
  546. //----------- End of function Town::clear_ptr -----------//
  547. //----------- End of function NationBase::crc8 -----------//
  548. UCHAR NationBase::crc8()
  549. {
  550. NationBase &dummyNationBase = *(NationBase *)temp_obj.nation;
  551. memcpy(&dummyNationBase, this, sizeof(NationBase));
  552. dummyNationBase.clear_ptr();
  553. *((char**) &dummyNationBase) = NULL;
  554. UCHAR c = ::crc8((UCHAR*)&dummyNationBase, sizeof(NationBase));
  555. return c;
  556. }
  557. //----------- End of function NationBase::crc8 -----------//
  558. //----------- End of function NationBase::clear_ptr -----------//
  559. void NationBase::clear_ptr()
  560. {
  561. nation_type = 0;
  562. memset(nation_name_str, 0, sizeof(nation_name_str) ); // garbage may exist after the '\0'
  563. next_frame_ready = 0;
  564. is_allied_with_player = 0;
  565. // ignore contact_msg_flag in relation_array
  566. for(short nationRecno=1; nationRecno <= MAX_NATION; ++nationRecno)
  567. {
  568. get_relation(nationRecno)->contact_msg_flag = 0;
  569. }
  570. }
  571. //----------- End of function NationBase::clear_ptr -----------//
  572. //----------- End of function Bullet::crc8 -----------//
  573. UCHAR Bullet::crc8()
  574. {
  575. Bullet &dummyBullet = *(Bullet *)temp_obj.bullet;
  576. memcpy(&dummyBullet, this, sizeof(Bullet));
  577. dummyBullet.clear_ptr();
  578. *((char**) &dummyBullet) = NULL;
  579. UCHAR c = ::crc8((UCHAR*)&dummyBullet, sizeof(Bullet));
  580. return c;
  581. }
  582. //----------- End of function Bullet::crc8 -----------//
  583. //----------- End of function Bullet::clear_ptr -----------//
  584. void Bullet::clear_ptr()
  585. {
  586. Sprite::clear_ptr();
  587. }
  588. //----------- End of function Bullet::clear_ptr -----------//
  589. //----------- End of function Projectile::crc8 -----------//
  590. UCHAR Projectile::crc8()
  591. {
  592. Projectile &dummyProjectile = *(Projectile *)temp_obj.projectile;
  593. memcpy(&dummyProjectile, this, sizeof(Projectile));
  594. dummyProjectile.clear_ptr();
  595. *((char**) &dummyProjectile) = NULL;
  596. UCHAR c = ::crc8((UCHAR*)&dummyProjectile, sizeof(Projectile));
  597. return c;
  598. }
  599. //----------- End of function Projectile::crc8 -----------//
  600. //----------- End of function Projectile::clear_ptr -----------//
  601. void Projectile::clear_ptr()
  602. {
  603. memset(&act_bullet, 0, sizeof(act_bullet));
  604. memset(&bullet_shadow, 0, sizeof(bullet_shadow));
  605. Bullet::clear_ptr();
  606. }
  607. //----------- End of function Projectile::clear_ptr -----------//
  608. //----------- End of function BulletHoming::crc8 -----------//
  609. UCHAR BulletHoming::crc8()
  610. {
  611. BulletHoming &dummyBulletHoming = *(BulletHoming *)temp_obj.bullet_homing;
  612. memcpy(&dummyBulletHoming, this, sizeof(BulletHoming));
  613. dummyBulletHoming.clear_ptr();
  614. *((char**) &dummyBulletHoming) = NULL;
  615. UCHAR c = ::crc8((UCHAR*)&dummyBulletHoming, sizeof(BulletHoming));
  616. return c;
  617. }
  618. //----------- End of function BulletHoming::crc8 -----------//
  619. //----------- End of function BulletHoming::clear_ptr -----------//
  620. void BulletHoming::clear_ptr()
  621. {
  622. Bullet::clear_ptr();
  623. }
  624. //----------- End of function BulletHoming::clear_ptr -----------//
  625. //----------- End of function BulletFlame::crc8 -----------//
  626. UCHAR BulletFlame::crc8()
  627. {
  628. BulletFlame &dummyBulletFlame = *(BulletFlame *)temp_obj.bullet_flame;
  629. memcpy(&dummyBulletFlame, this, sizeof(BulletFlame));
  630. dummyBulletFlame.clear_ptr();
  631. *((char**) &dummyBulletFlame) = NULL;
  632. UCHAR c = ::crc8((UCHAR*)&dummyBulletFlame, sizeof(BulletFlame));
  633. return c;
  634. }
  635. //----------- End of function BulletFlame::crc8 -----------//
  636. //----------- Begin of function BulletFlame::clear_ptr -----------//
  637. void BulletFlame::clear_ptr()
  638. {
  639. Bullet::clear_ptr();
  640. }
  641. //----------- End of function BulletFlame::clear_ptr -----------//
  642. // ###### patch begin Gilbert 20/1 #######//
  643. //----------- Begin of function Rebel::crc8 -----------//
  644. UCHAR Rebel::crc8()
  645. {
  646. Rebel &dummyRebel = *(Rebel *)temp_obj.rebel;
  647. memcpy(&dummyRebel, this, sizeof(Rebel));
  648. dummyRebel.clear_ptr();
  649. UCHAR c = ::crc8((UCHAR *)&dummyRebel, sizeof(Rebel));
  650. return c;
  651. }
  652. //----------- End of function Rebel::crc8 -----------//
  653. //----------- Begin of function Rebel::clear_ptr -----------//
  654. void Rebel::clear_ptr()
  655. {
  656. }
  657. //----------- End of function Rebel::clear_ptr -----------//
  658. //----------- Begin of function Spy::crc8 -----------//
  659. UCHAR Spy::crc8()
  660. {
  661. Spy &dummySpy = *(Spy *)temp_obj.spy;
  662. memcpy(&dummySpy, this, sizeof(Spy));
  663. dummySpy.clear_ptr();
  664. UCHAR c = ::crc8((UCHAR *)&dummySpy, sizeof(Spy));
  665. return c;
  666. }
  667. //----------- End of function Spy::crc8 -----------//
  668. //----------- Begin of function Spy::clear_ptr -----------//
  669. void Spy::clear_ptr()
  670. {
  671. }
  672. //----------- End of function Spy::clear_ptr -----------//
  673. // ###### patch end Gilbert 20/1 #######//
  674. //----------- Begin of function TalkMsg::crc8 -----------//
  675. UCHAR TalkMsg::crc8()
  676. {
  677. TalkMsg &dummyTalkMsg = *(TalkMsg *)temp_obj.talk_msg;
  678. memcpy(&dummyTalkMsg, this, sizeof(TalkMsg));
  679. dummyTalkMsg.clear_ptr();
  680. // *((char**) &dummyTalkMsg) = NULL;
  681. UCHAR c = ::crc8((UCHAR*)&dummyTalkMsg, sizeof(TalkMsg));
  682. return c;
  683. }
  684. //----------- End of function TalkMsg::crc8 -----------//
  685. //----------- Begin of function TalkMsg::clear_ptr -----------//
  686. void TalkMsg::clear_ptr()
  687. {
  688. }
  689. //----------- End of function TalkMsg::clear_ptr -----------//