missionigc.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. /*
  2. ** Copyright (C) 1996, 1997 Microsoft Corporation. All Rights Reserved.
  3. **
  4. ** File: missionIGC.h
  5. **
  6. ** Author:
  7. **
  8. ** Description:
  9. ** Header for the CmissionIGC class. This file was initially created by
  10. ** the ATL wizard.
  11. **
  12. ** History:
  13. */
  14. // missionIGC.h : Declaration of the CmissionIGC
  15. #ifndef __MISSIONIGC_H_
  16. #define __MISSIONIGC_H_
  17. struct Constants
  18. {
  19. float floatConstants[c_fcidMax];
  20. float damageConstants[c_dmgidMax][c_defidMax];
  21. };
  22. //Define a class that will handle all of the static data (for all missions)
  23. class CstaticIGC
  24. {
  25. public:
  26. CstaticIGC(void);
  27. ~CstaticIGC(void)
  28. {
  29. }
  30. // IstaticIGC
  31. void Initialize(void)
  32. {
  33. }
  34. void Terminate(void)
  35. {
  36. {
  37. DroneTypeLinkIGC* l;
  38. while ((l = m_droneTypes.first()) != NULL)
  39. {
  40. l->data()->Terminate();
  41. }
  42. }
  43. {
  44. StationTypeLinkIGC* l;
  45. while ((l = m_stationTypes.first()) != NULL)
  46. {
  47. l->data()->Terminate();
  48. }
  49. }
  50. {
  51. HullTypeLinkIGC* l;
  52. while ((l = m_hullTypes.first()) != NULL)
  53. {
  54. l->data()->Terminate();
  55. }
  56. }
  57. {
  58. ExpendableTypeLinkIGC* l;
  59. while ((l = m_expendableTypes.first()) != NULL)
  60. {
  61. l->data()->Terminate();
  62. }
  63. }
  64. {
  65. PartTypeLinkIGC* l;
  66. while ((l = m_partTypes.first()) != NULL)
  67. {
  68. l->data()->Terminate();
  69. }
  70. }
  71. {
  72. ProjectileTypeLinkIGC* l;
  73. while ((l = m_projectileTypes.first()) != NULL)
  74. {
  75. l->data()->Terminate();
  76. }
  77. }
  78. {
  79. DevelopmentLinkIGC* l;
  80. while ((l = m_developments.first()) != NULL)
  81. {
  82. l->data()->Terminate();
  83. }
  84. }
  85. {
  86. CivilizationLinkIGC* l;
  87. while ((l = m_civilizations.first()) != NULL)
  88. {
  89. l->data()->Terminate();
  90. }
  91. }
  92. {
  93. TreasureSetLinkIGC* l;
  94. while ((l = m_treasureSets.first()) != NULL)
  95. {
  96. l->data()->Terminate();
  97. }
  98. }
  99. assert (m_stationTypes.n() == 0);
  100. assert (m_hullTypes.n() == 0);
  101. assert (m_partTypes.n() == 0);
  102. assert (m_projectileTypes.n() == 0);
  103. assert (m_developments.n() == 0);
  104. assert (m_droneTypes.n() == 0);
  105. assert (m_civilizations.n() == 0);
  106. assert (m_treasureSets.n() == 0);
  107. if (m_pptAmmoPack)
  108. {
  109. m_pptAmmoPack->Release();
  110. m_pptAmmoPack = NULL;
  111. }
  112. if (m_pptFuelPack)
  113. {
  114. m_pptFuelPack->Release();
  115. m_pptFuelPack = NULL;
  116. }
  117. }
  118. virtual float GetFloatConstant(FloatConstantID fcid) const
  119. {
  120. assert (fcid >= 0);
  121. assert (fcid < c_fcidMax);
  122. return m_constants.floatConstants[fcid];
  123. }
  124. virtual void SetFloatConstant(FloatConstantID fcid, float f)
  125. {
  126. assert (fcid >= 0);
  127. assert (fcid < c_fcidMax);
  128. m_constants.floatConstants[fcid] = f;
  129. }
  130. virtual float GetDamageConstant(DamageTypeID dmgid, DefenseTypeID defid) const
  131. {
  132. assert ((dmgid & c_dmgidMask) >= 0);
  133. assert ((dmgid & c_dmgidMask) < c_dmgidMax);
  134. assert (defid >= 0);
  135. assert (defid < c_defidMax);
  136. return m_constants.damageConstants[dmgid & c_dmgidMask][defid];
  137. }
  138. virtual void SetDamageConstant(DamageTypeID dmgid, DefenseTypeID defid, float f)
  139. {
  140. assert ((dmgid & c_dmgidMask) >= 0);
  141. assert ((dmgid & c_dmgidMask) < c_dmgidMax);
  142. assert (defid >= 0);
  143. assert (defid < c_defidMax);
  144. m_constants.damageConstants[dmgid & c_dmgidMask][defid] = f;
  145. }
  146. virtual const void* GetConstants(void) const
  147. {
  148. return &m_constants;
  149. }
  150. virtual void SetConstants(const void* pf)
  151. {
  152. memcpy(&m_constants, pf, sizeof(m_constants));
  153. }
  154. virtual int GetSizeOfConstants(void) const
  155. {
  156. return sizeof(m_constants);
  157. }
  158. void AddDroneType(IdroneTypeIGC* dt)
  159. {
  160. AddIbaseIGC((BaseListIGC*)&m_droneTypes, dt);
  161. }
  162. void DeleteDroneType(IdroneTypeIGC* dt)
  163. {
  164. DeleteIbaseIGC((BaseListIGC*)&m_droneTypes, dt);
  165. }
  166. IdroneTypeIGC* GetDroneType(DroneTypeID id) const
  167. {
  168. return (IdroneTypeIGC*)GetIbaseIGC((BaseListIGC*)&m_droneTypes, id);
  169. }
  170. const DroneTypeListIGC* GetDroneTypes(void) const
  171. {
  172. return &m_droneTypes;
  173. }
  174. void AddDevelopment(IdevelopmentIGC* d)
  175. {
  176. AddIbaseIGC((BaseListIGC*)&m_developments, d);
  177. }
  178. void DeleteDevelopment(IdevelopmentIGC* d)
  179. {
  180. DeleteIbaseIGC((BaseListIGC*)&m_developments, d);
  181. }
  182. IdevelopmentIGC* GetDevelopment(DevelopmentID id) const
  183. {
  184. return (IdevelopmentIGC*)GetIbaseIGC((BaseListIGC*)&m_developments, id);
  185. }
  186. const DevelopmentListIGC* GetDevelopments(void) const
  187. {
  188. return &m_developments;
  189. }
  190. void AddStationType(IstationTypeIGC* st)
  191. {
  192. AddIbaseIGC((BaseListIGC*)&m_stationTypes, st);
  193. }
  194. void DeleteStationType(IstationTypeIGC* st)
  195. {
  196. DeleteIbaseIGC((BaseListIGC*)&m_stationTypes, st);
  197. }
  198. IstationTypeIGC* GetStationType(StationTypeID id) const
  199. {
  200. return (IstationTypeIGC*)GetIbaseIGC((BaseListIGC*)&m_stationTypes, id);
  201. }
  202. const StationTypeListIGC* GetStationTypes(void) const
  203. {
  204. return &m_stationTypes;
  205. }
  206. void AddCivilization(IcivilizationIGC* c)
  207. {
  208. AddIbaseIGC((BaseListIGC*)&m_civilizations, c);
  209. }
  210. void DeleteCivilization(IcivilizationIGC* c)
  211. {
  212. DeleteIbaseIGC((BaseListIGC*)&m_civilizations, c);
  213. }
  214. IcivilizationIGC* GetCivilization(CivID id) const
  215. {
  216. return (IcivilizationIGC*)GetIbaseIGC((BaseListIGC*)&m_civilizations, id);
  217. }
  218. const CivilizationListIGC* GetCivilizations(void) const
  219. {
  220. return &m_civilizations;
  221. }
  222. void AddHullType(IhullTypeIGC* ht)
  223. {
  224. AddIbaseIGC((BaseListIGC*)&m_hullTypes, ht);
  225. }
  226. void DeleteHullType(IhullTypeIGC* ht)
  227. {
  228. DeleteIbaseIGC((BaseListIGC*)&m_hullTypes, ht);
  229. }
  230. IhullTypeIGC* GetHullType(HullID id) const
  231. {
  232. return (IhullTypeIGC*)GetIbaseIGC((BaseListIGC*)&m_hullTypes, id);
  233. }
  234. const HullTypeListIGC* GetHullTypes(void) const
  235. {
  236. return &m_hullTypes;
  237. }
  238. void AddExpendableType(IexpendableTypeIGC* mt)
  239. {
  240. AddIbaseIGC((BaseListIGC*)&m_expendableTypes, mt);
  241. }
  242. void DeleteExpendableType(IexpendableTypeIGC* mt)
  243. {
  244. DeleteIbaseIGC((BaseListIGC*)&m_expendableTypes, mt);
  245. }
  246. IexpendableTypeIGC* GetExpendableType(ExpendableTypeID id) const
  247. {
  248. return (IexpendableTypeIGC*)GetIbaseIGC((BaseListIGC*)&m_expendableTypes, id);
  249. }
  250. const ExpendableTypeListIGC* GetExpendableTypes(void) const
  251. {
  252. return &m_expendableTypes;
  253. }
  254. void AddPartType(IpartTypeIGC* pt)
  255. {
  256. AddIbaseIGC((BaseListIGC*)&m_partTypes, pt);
  257. if (pt->GetEquipmentType() == ET_Pack)
  258. {
  259. DataPackTypeIGC* pdpt = (DataPackTypeIGC*)(pt->GetData());
  260. if (pdpt->packType == c_packAmmo)
  261. {
  262. if (m_pptAmmoPack == NULL)
  263. {
  264. m_pptAmmoPack = pt;
  265. pt->AddRef();
  266. }
  267. }
  268. else if (pdpt->packType == c_packFuel)
  269. {
  270. if (m_pptFuelPack == NULL)
  271. {
  272. m_pptFuelPack = pt;
  273. pt->AddRef();
  274. }
  275. }
  276. }
  277. }
  278. void DeletePartType(IpartTypeIGC* pt)
  279. {
  280. DeleteIbaseIGC((BaseListIGC*)&m_partTypes, pt);
  281. }
  282. IpartTypeIGC* GetPartType(PartID id) const
  283. {
  284. return (IpartTypeIGC*)GetIbaseIGC((BaseListIGC*)&m_partTypes, id);
  285. }
  286. const PartTypeListIGC* GetPartTypes(void) const
  287. {
  288. return &m_partTypes;
  289. }
  290. virtual void AddTreasureSet(ItreasureSetIGC* pt)
  291. {
  292. AddIbaseIGC((BaseListIGC*)&m_treasureSets, pt);
  293. }
  294. virtual void DeleteTreasureSet(ItreasureSetIGC* pt)
  295. {
  296. DeleteIbaseIGC((BaseListIGC*)&m_treasureSets, pt);
  297. }
  298. virtual ItreasureSetIGC* GetTreasureSet(TreasureSetID id) const
  299. {
  300. return (ItreasureSetIGC*)GetIbaseIGC((BaseListIGC*)&m_treasureSets, id);
  301. }
  302. virtual const TreasureSetListIGC* GetTreasureSets(void) const
  303. {
  304. return &m_treasureSets;
  305. }
  306. void AddProjectileType(IprojectileTypeIGC* pt)
  307. {
  308. AddIbaseIGC((BaseListIGC*)&m_projectileTypes, pt);
  309. }
  310. void DeleteProjectileType(IprojectileTypeIGC* pt)
  311. {
  312. DeleteIbaseIGC((BaseListIGC*)&m_projectileTypes, pt);
  313. }
  314. IprojectileTypeIGC* GetProjectileType(ProjectileTypeID id) const
  315. {
  316. return (IprojectileTypeIGC*)GetIbaseIGC((BaseListIGC*)&m_projectileTypes, id);
  317. }
  318. const ProjectileTypeListIGC* GetProjectileTypes(void) const
  319. {
  320. return &m_projectileTypes;
  321. }
  322. IpartTypeIGC* GetAmmoPack(void) const
  323. {
  324. return m_pptAmmoPack;
  325. }
  326. IpartTypeIGC* GetFuelPack(void) const
  327. {
  328. return m_pptFuelPack;
  329. }
  330. private:
  331. HullTypeListIGC m_hullTypes;
  332. PartTypeListIGC m_partTypes;
  333. ProjectileTypeListIGC m_projectileTypes;
  334. ExpendableTypeListIGC m_expendableTypes;
  335. StationTypeListIGC m_stationTypes;
  336. CivilizationListIGC m_civilizations;
  337. DroneTypeListIGC m_droneTypes;
  338. DevelopmentListIGC m_developments;
  339. TreasureSetListIGC m_treasureSets;
  340. IpartTypeIGC* m_pptAmmoPack;
  341. IpartTypeIGC* m_pptFuelPack;
  342. Constants m_constants;
  343. };
  344. /////////////////////////////////////////////////////////////////////////////
  345. // CmissionIGC
  346. class CmissionIGC : public ImissionIGC
  347. {
  348. public:
  349. CmissionIGC(void)
  350. :
  351. m_pIgcSite(NULL),
  352. m_dwPrivate(0),
  353. m_nextBuoyID(0),
  354. m_nextShipID(0),
  355. m_nextAsteroidID(0),
  356. m_nextTreasureID(0),
  357. m_nextMineID(0),
  358. m_nextProbeID(0),
  359. m_nextMissileID(0),
  360. m_nextStationID(0),
  361. m_stageMission(STAGE_NOTSTARTED),
  362. m_missionID(0),
  363. m_pStatic(NULL),
  364. m_bHasGenerated(false),
  365. m_nReplayCount(0)
  366. {
  367. // Record the creation time
  368. SYSTEMTIME st;
  369. ::GetLocalTime(&st);
  370. ::SystemTimeToFileTime(&st, &m_ftCreated);
  371. }
  372. virtual ~CmissionIGC(void);
  373. // IstaticIGC
  374. virtual void Initialize(void)
  375. {
  376. //Never called ... should use the initialize of ImissionIGC
  377. assert (false);
  378. }
  379. virtual void Terminate(void);
  380. virtual float GetFloatConstant(FloatConstantID fcid) const
  381. {
  382. return m_pStatic->GetFloatConstant(fcid);
  383. }
  384. virtual void SetFloatConstant(FloatConstantID fcid, float f)
  385. {
  386. m_pStatic->SetFloatConstant(fcid, f);
  387. }
  388. virtual float GetDamageConstant(DamageTypeID dmgid, DefenseTypeID defid) const
  389. {
  390. return m_pStatic->GetDamageConstant(dmgid, defid);
  391. }
  392. virtual void SetDamageConstant(DamageTypeID dmgid, DefenseTypeID defid, float f)
  393. {
  394. m_pStatic->SetDamageConstant(dmgid, defid, f);
  395. }
  396. virtual const void* GetConstants(void) const
  397. {
  398. return m_pStatic->GetConstants();
  399. }
  400. virtual void SetConstants(const void* pf)
  401. {
  402. m_pStatic->SetConstants(pf);
  403. }
  404. virtual int GetSizeOfConstants(void) const
  405. {
  406. return m_pStatic->GetSizeOfConstants();
  407. }
  408. virtual void AddDroneType(IdroneTypeIGC* dt)
  409. {
  410. m_pStatic->AddDroneType(dt);
  411. }
  412. virtual void DeleteDroneType(IdroneTypeIGC* dt)
  413. {
  414. m_pStatic->DeleteDroneType(dt);
  415. }
  416. virtual IdroneTypeIGC* GetDroneType(DroneTypeID id) const
  417. {
  418. return m_pStatic->GetDroneType(id);
  419. }
  420. virtual const DroneTypeListIGC* GetDroneTypes(void) const
  421. {
  422. return m_pStatic->GetDroneTypes();
  423. }
  424. virtual void AddDevelopment(IdevelopmentIGC* d)
  425. {
  426. m_pStatic->AddDevelopment(d);
  427. }
  428. virtual void DeleteDevelopment(IdevelopmentIGC* d)
  429. {
  430. m_pStatic->DeleteDevelopment(d);
  431. }
  432. virtual IdevelopmentIGC* GetDevelopment(DevelopmentID id) const
  433. {
  434. return m_pStatic->GetDevelopment(id);
  435. }
  436. virtual const DevelopmentListIGC* GetDevelopments(void) const
  437. {
  438. return m_pStatic->GetDevelopments();
  439. }
  440. virtual void AddStationType(IstationTypeIGC* st)
  441. {
  442. m_pStatic->AddStationType(st);
  443. }
  444. virtual void DeleteStationType(IstationTypeIGC* st)
  445. {
  446. m_pStatic->DeleteStationType(st);
  447. }
  448. virtual IstationTypeIGC* GetStationType(StationTypeID id) const
  449. {
  450. return m_pStatic->GetStationType(id);
  451. }
  452. virtual const StationTypeListIGC* GetStationTypes(void) const
  453. {
  454. return m_pStatic->GetStationTypes();
  455. }
  456. virtual void AddCivilization(IcivilizationIGC* c)
  457. {
  458. m_pStatic->AddCivilization(c);
  459. }
  460. virtual void DeleteCivilization(IcivilizationIGC* c)
  461. {
  462. m_pStatic->DeleteCivilization(c);
  463. }
  464. virtual IcivilizationIGC* GetCivilization(CivID id) const
  465. {
  466. return m_pStatic->GetCivilization(id);
  467. }
  468. virtual const CivilizationListIGC* GetCivilizations(void) const
  469. {
  470. return m_pStatic->GetCivilizations();
  471. }
  472. virtual void AddHullType(IhullTypeIGC* ht)
  473. {
  474. m_pStatic->AddHullType(ht);
  475. }
  476. virtual void DeleteHullType(IhullTypeIGC* ht)
  477. {
  478. m_pStatic->DeleteHullType(ht);
  479. }
  480. virtual IhullTypeIGC* GetHullType(HullID id) const
  481. {
  482. return m_pStatic->GetHullType(id);
  483. }
  484. virtual const HullTypeListIGC* GetHullTypes(void) const
  485. {
  486. return m_pStatic->GetHullTypes();
  487. }
  488. virtual void AddExpendableType(IexpendableTypeIGC* mt)
  489. {
  490. m_pStatic->AddExpendableType(mt);
  491. }
  492. virtual void DeleteExpendableType(IexpendableTypeIGC* mt)
  493. {
  494. m_pStatic->DeleteExpendableType(mt);
  495. }
  496. virtual IexpendableTypeIGC* GetExpendableType(ExpendableTypeID id) const
  497. {
  498. return m_pStatic->GetExpendableType(id);
  499. }
  500. virtual const ExpendableTypeListIGC* GetExpendableTypes(void) const
  501. {
  502. return m_pStatic->GetExpendableTypes();
  503. }
  504. virtual void AddPartType(IpartTypeIGC* pt)
  505. {
  506. m_pStatic->AddPartType(pt);
  507. {
  508. //Preload the art for the corresponding model
  509. m_pIgcSite->Preload(pt->GetModelName(), NULL);
  510. }
  511. }
  512. virtual void DeletePartType(IpartTypeIGC* pt)
  513. {
  514. m_pStatic->DeletePartType(pt);
  515. }
  516. virtual IpartTypeIGC* GetPartType(PartID id) const
  517. {
  518. return m_pStatic->GetPartType(id);
  519. }
  520. virtual const PartTypeListIGC* GetPartTypes(void) const
  521. {
  522. return m_pStatic->GetPartTypes();
  523. }
  524. virtual void AddTreasureSet(ItreasureSetIGC* pt)
  525. {
  526. m_pStatic->AddTreasureSet(pt);
  527. }
  528. virtual void DeleteTreasureSet(ItreasureSetIGC* pt)
  529. {
  530. m_pStatic->DeleteTreasureSet(pt);
  531. }
  532. virtual ItreasureSetIGC* GetTreasureSet(TreasureSetID id) const
  533. {
  534. return m_pStatic->GetTreasureSet(id);
  535. }
  536. virtual const TreasureSetListIGC* GetTreasureSets(void) const
  537. {
  538. return m_pStatic->GetTreasureSets();
  539. }
  540. virtual void AddProjectileType(IprojectileTypeIGC* pt)
  541. {
  542. m_pStatic->AddProjectileType(pt);
  543. }
  544. virtual void DeleteProjectileType(IprojectileTypeIGC* pt)
  545. {
  546. m_pStatic->DeleteProjectileType(pt);
  547. }
  548. virtual IprojectileTypeIGC* GetProjectileType(ProjectileTypeID id) const
  549. {
  550. return m_pStatic->GetProjectileType(id);
  551. }
  552. virtual const ProjectileTypeListIGC* GetProjectileTypes(void) const
  553. {
  554. return m_pStatic->GetProjectileTypes();
  555. }
  556. // ImissionIGC
  557. virtual void Initialize(Time now, IIgcSite* pIgcSite);
  558. virtual void Update(Time now);
  559. virtual MissionID GetMissionID(void) const
  560. {
  561. return m_missionID;
  562. }
  563. virtual int Export(__int64 maskTypes,
  564. char* pdata) const;
  565. virtual void Import(Time now,
  566. __int64 maskTypes,
  567. char* pdata,
  568. int datasize);
  569. virtual void SetMissionID(MissionID mid)
  570. {
  571. m_missionID = mid;
  572. }
  573. virtual IIgcSite* GetIgcSite(void) const
  574. {
  575. return m_pIgcSite;
  576. }
  577. virtual IbaseIGC* CreateObject(Time now, ObjectType objecttype,
  578. const void* data, int dataSize);
  579. virtual ImodelIGC* GetModel(ObjectType type, ObjectID id) const;
  580. virtual IbaseIGC* GetBase(ObjectType type, ObjectID id) const;
  581. virtual DamageTrack* CreateDamageTrack(void)
  582. {
  583. return m_damageTracks.Create();
  584. }
  585. //Global list of stations
  586. virtual void AddStation(IstationIGC* s);
  587. virtual void DeleteStation(IstationIGC* s);
  588. virtual IstationIGC* GetStation(StationID stationID) const;
  589. virtual const StationListIGC* GetStations(void) const;
  590. //Global list of warps
  591. virtual void AddWarp(IwarpIGC* w);
  592. virtual void DeleteWarp(IwarpIGC* w);
  593. virtual IwarpIGC* GetWarp(WarpID warpID) const;
  594. virtual const WarpListIGC* GetWarps(void) const;
  595. //Global list of asteroids
  596. virtual void AddAsteroid(IasteroidIGC* s);
  597. virtual void DeleteAsteroid(IasteroidIGC* s);
  598. virtual IasteroidIGC* GetAsteroid(AsteroidID id) const;
  599. virtual const AsteroidListIGC* GetAsteroids(void) const;
  600. //Global list of mines
  601. virtual void AddMine(ImineIGC* ms);
  602. virtual void DeleteMine(ImineIGC* m);
  603. virtual ImineIGC* GetMine(MineID mineID) const;
  604. virtual const MineListIGC* GetMines(void) const;
  605. //Global list of probes
  606. virtual void AddProbe(IprobeIGC* ms);
  607. virtual void DeleteProbe(IprobeIGC* m);
  608. virtual IprobeIGC* GetProbe(ProbeID probeID) const;
  609. virtual const ProbeListIGC* GetProbes(void) const;
  610. //Global list of treasures
  611. virtual void AddTreasure(ItreasureIGC* t);
  612. virtual void DeleteTreasure(ItreasureIGC* t);
  613. virtual ItreasureIGC* GetTreasure(TreasureID treasureID) const;
  614. virtual const TreasureListIGC* GetTreasures(void) const;
  615. //Global list of sides
  616. virtual void AddSide(IsideIGC* s);
  617. virtual void DeleteSide(IsideIGC* s);
  618. virtual IsideIGC* GetSide(SideID sideID) const;
  619. virtual const SideListIGC* GetSides(void) const;
  620. //Global list of clusters
  621. virtual void AddCluster(IclusterIGC* c);
  622. virtual void DeleteCluster(IclusterIGC* c);
  623. virtual IclusterIGC* GetCluster(SectorID clusterID) const;
  624. virtual const ClusterListIGC* GetClusters(void) const;
  625. //Global list of ships
  626. virtual void AddShip(IshipIGC* s);
  627. virtual void DeleteShip(IshipIGC* s);
  628. virtual IshipIGC* GetShip(ShipID shipID) const;
  629. virtual const ShipListIGC* GetShips(void) const;
  630. //Global list of buoys
  631. virtual void AddBuoy(IbuoyIGC* s);
  632. virtual void DeleteBuoy(IbuoyIGC* s);
  633. virtual IbuoyIGC* GetBuoy(BuoyID buoyID) const;
  634. virtual const BuoyListIGC* GetBuoys(void) const;
  635. virtual IpartTypeIGC* GetAmmoPack(void) const
  636. {
  637. return m_pStatic->GetAmmoPack();
  638. }
  639. virtual IpartTypeIGC* GetFuelPack(void) const
  640. {
  641. return m_pStatic->GetFuelPack();
  642. }
  643. IpartIGC* CreatePart(Time now,
  644. IpartTypeIGC* ppt)
  645. {
  646. static const ObjectType objectTypes[ET_MAX] =
  647. {OT_dispenser,
  648. OT_weapon,
  649. OT_magazine,
  650. OT_dispenser,
  651. OT_shield,
  652. OT_cloak,
  653. OT_pack,
  654. OT_afterburner
  655. };
  656. assert (objectTypes[ET_ChaffLauncher] == OT_dispenser);
  657. assert (objectTypes[ET_Weapon] == OT_weapon);
  658. assert (objectTypes[ET_Magazine] == OT_magazine);
  659. assert (objectTypes[ET_Dispenser] == OT_dispenser);
  660. assert (objectTypes[ET_Shield] == OT_shield);
  661. assert (objectTypes[ET_Cloak] == OT_cloak);
  662. assert (objectTypes[ET_Pack] == OT_pack);
  663. assert (objectTypes[ET_Afterburner] == OT_afterburner);
  664. //The "data" used to create a part is a pointer to the part type.
  665. return (IpartIGC*)CreateObject(now, objectTypes[ppt->GetEquipmentType()], &ppt, sizeof(ppt));
  666. }
  667. void SetMissionStage(STAGE st)
  668. {
  669. m_stageMission = st;
  670. }
  671. STAGE GetMissionStage()
  672. {
  673. return m_stageMission;
  674. }
  675. void EnterGame(void)
  676. {
  677. if (m_missionParams.IsProsperityGame())
  678. {
  679. IdevelopmentIGC* pdTeamMoney = GetDevelopment(c_didTeamMoney);
  680. assert (pdTeamMoney);
  681. assert (m_missionParams.fGoalTeamMoney > 0);
  682. for (SideLinkIGC* psl = m_sides.first(); (psl != NULL); psl = psl->next())
  683. {
  684. //It is something we might be able to build and it will actually
  685. //do something useful
  686. DataBucketIGC db = {pdTeamMoney, psl->data()};
  687. IbucketIGC* b = (IbucketIGC*)(CreateObject(m_lastUpdate,
  688. OT_bucket,
  689. &db,
  690. sizeof(db)));
  691. assert (b);
  692. b->SetPrice((Money)(m_missionParams.fGoalTeamMoney * GetFloatConstant(c_fcidWinTheGameMoney)));
  693. b->Release(); //Creating the bucket adds it to the side's list of buckets
  694. }
  695. }
  696. //Go through all sides and create the prosperity development (adjusting the price as needed)
  697. //Go through all the treasures and reset their expiration time
  698. for (TreasureLinkIGC* ptl = m_treasures.first(); (ptl != NULL); ptl = ptl->next())
  699. ptl->data()->ResetExpiration(m_lastUpdate);
  700. //Go through all stations and reset their start time
  701. for (StationLinkIGC* psl = m_stations.first(); (psl != NULL); psl = psl->next())
  702. psl->data()->SetLastUpdate(m_lastUpdate);
  703. }
  704. void UpdateSides(Time now,
  705. const MissionParams * pmp,
  706. const char sideNames[c_cSidesMax][c_cbSideName]);
  707. void ResetMission();
  708. void GenerateMission(Time now,
  709. const MissionParams * pmp,
  710. TechTreeBitMask * pttbmShouldOverride,
  711. TechTreeBitMask * pttbmOverrideValue);
  712. void GenerateTreasure(Time now,
  713. IclusterIGC* pcluster,
  714. short tsi);
  715. virtual void SetPrivateData(DWORD dwPrivate)
  716. {
  717. m_dwPrivate = dwPrivate;
  718. }
  719. virtual DWORD GetPrivateData(void) const
  720. {
  721. return m_dwPrivate;
  722. }
  723. BuoyID GenerateNewBuoyID(void)
  724. {
  725. return m_nextBuoyID++;
  726. }
  727. ShipID GenerateNewShipID(void)
  728. {
  729. return m_nextShipID++;
  730. }
  731. AsteroidID GenerateNewAsteroidID(void)
  732. {
  733. return m_nextAsteroidID++;
  734. }
  735. TreasureID GenerateNewTreasureID(void)
  736. {
  737. return m_nextTreasureID++;
  738. }
  739. MineID GenerateNewMineID(void)
  740. {
  741. return m_nextMineID++;
  742. }
  743. ProbeID GenerateNewProbeID(void)
  744. {
  745. return m_nextProbeID++;
  746. }
  747. MissileID GenerateNewMissileID(void)
  748. {
  749. return m_nextMissileID++;
  750. }
  751. StationID GenerateNewStationID(void)
  752. {
  753. return m_nextStationID++;
  754. }
  755. Time GetLastUpdate(void) const
  756. {
  757. return m_lastUpdate;
  758. }
  759. const MissionParams* GetMissionParams(void) const
  760. {
  761. return &m_missionParams;
  762. }
  763. void SetMissionParams(const MissionParams* pmp)
  764. {
  765. m_missionParams = *pmp;
  766. }
  767. virtual void SetStartTime(Time timeStart)
  768. {
  769. m_missionParams.timeStart = timeStart;
  770. }
  771. CstaticIGC* GetStaticCore(void) const
  772. {
  773. return m_pStatic;
  774. }
  775. void SetStaticCore(CstaticIGC* pStatic)
  776. {
  777. assert (m_pStatic == NULL);
  778. if (pStatic)
  779. m_pStatic = pStatic;
  780. else
  781. {
  782. m_pStatic = new CstaticIGC;
  783. m_pStatic->Initialize();
  784. }
  785. }
  786. short GetReplayCount(void) const;
  787. const char* GetContextName(void);
  788. private:
  789. MissionParams m_missionParams;
  790. DWORD m_dwPrivate;
  791. MissionID m_missionID;
  792. CstaticIGC* m_pStatic;
  793. IIgcSite* m_pIgcSite;
  794. DamageTrackSet m_damageTracks;
  795. ClusterListIGC m_clusters;
  796. BuoyListIGC m_buoys;
  797. ShipListIGC m_ships;
  798. WarpListIGC m_warps;
  799. StationListIGC m_stations;
  800. AsteroidListIGC m_asteroids;
  801. ProbeListIGC m_probes;
  802. MineListIGC m_mines;
  803. TreasureListIGC m_treasures;
  804. SideListIGC m_sides;
  805. IsideIGC* m_sideTeamLobby;
  806. Time m_lastUpdate;
  807. BuoyID m_nextBuoyID;
  808. ShipID m_nextShipID;
  809. AsteroidID m_nextAsteroidID;
  810. TreasureID m_nextTreasureID;
  811. MineID m_nextMineID;
  812. ProbeID m_nextProbeID;
  813. MissileID m_nextMissileID;
  814. StationID m_nextStationID;
  815. STAGE m_stageMission;
  816. FILETIME m_ftCreated;
  817. bool m_bHasGenerated;
  818. short m_nReplayCount;
  819. ZString m_strContextName;
  820. };
  821. #endif //__MISSIONIGC_H_