comcentergameobj.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/comcentergameobj.cpp $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 7/16/01 12:10p $*
  29. * *
  30. * $Revision:: 4 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "comcentergameobj.h"
  36. #include "basecontroller.h"
  37. #include "wwhack.h"
  38. #include "simpledefinitionfactory.h"
  39. #include "persistfactory.h"
  40. #include "definitionmgr.h"
  41. #include "combatchunkid.h"
  42. #include "debug.h"
  43. #include "wwprofile.h"
  44. #include "basecontroller.h"
  45. #include "combat.h"
  46. ////////////////////////////////////////////////////////////////
  47. // Hacks
  48. ////////////////////////////////////////////////////////////////
  49. DECLARE_FORCE_LINK (ComCenter)
  50. ////////////////////////////////////////////////////////////////
  51. // Editable and persist factories
  52. ////////////////////////////////////////////////////////////////
  53. SimplePersistFactoryClass <ComCenterGameObjDef, CHUNKID_GAME_OBJECT_DEF_COMCENTER> _ComCenterGameObjDefPersistFactory;
  54. SimplePersistFactoryClass <ComCenterGameObj, CHUNKID_GAME_OBJECT_COMCENTER> _ComCenterGameObjPersistFactory;
  55. DECLARE_DEFINITION_FACTORY (ComCenterGameObjDef, CLASSID_GAME_OBJECT_DEF_COMCENTER, "Com Center") _ComCenterGameObjDefDefFactory;
  56. ////////////////////////////////////////////////////////////////
  57. // Save/Load constants
  58. ////////////////////////////////////////////////////////////////
  59. enum
  60. {
  61. CHUNKID_DEF_PARENT = 0x02211153,
  62. CHUNKID_DEF_VARIABLES,
  63. MICROCHUNKID_DEF_UNUSED = 1,
  64. };
  65. enum
  66. {
  67. CHUNKID_PARENT = 0x02211154,
  68. CHUNKID_VARIABLES,
  69. MICROCHUNKID_UNUSED = 1,
  70. };
  71. ////////////////////////////////////////////////////////////////
  72. //
  73. // ComCenterGameObjDef
  74. //
  75. ////////////////////////////////////////////////////////////////
  76. ComCenterGameObjDef::ComCenterGameObjDef (void)
  77. {
  78. return ;
  79. }
  80. ////////////////////////////////////////////////////////////////
  81. //
  82. // ~ComCenterGameObjDef
  83. //
  84. ////////////////////////////////////////////////////////////////
  85. ComCenterGameObjDef::~ComCenterGameObjDef (void)
  86. {
  87. return ;
  88. }
  89. ////////////////////////////////////////////////////////////////
  90. //
  91. // Get_Class_ID
  92. //
  93. ////////////////////////////////////////////////////////////////
  94. uint32
  95. ComCenterGameObjDef::Get_Class_ID (void) const
  96. {
  97. return CLASSID_GAME_OBJECT_DEF_COMCENTER;
  98. }
  99. ////////////////////////////////////////////////////////////////
  100. //
  101. // Create
  102. //
  103. ////////////////////////////////////////////////////////////////
  104. PersistClass *
  105. ComCenterGameObjDef::Create (void) const
  106. {
  107. ComCenterGameObj *building = new ComCenterGameObj;
  108. building->Init (*this);
  109. return building;
  110. }
  111. ////////////////////////////////////////////////////////////////
  112. //
  113. // Create
  114. //
  115. ////////////////////////////////////////////////////////////////
  116. bool
  117. ComCenterGameObjDef::Save (ChunkSaveClass &csave)
  118. {
  119. csave.Begin_Chunk (CHUNKID_DEF_PARENT);
  120. BuildingGameObjDef::Save (csave);
  121. csave.End_Chunk ();
  122. csave.Begin_Chunk (CHUNKID_DEF_VARIABLES);
  123. csave.End_Chunk ();
  124. return true;
  125. }
  126. ////////////////////////////////////////////////////////////////
  127. //
  128. // Load
  129. //
  130. ////////////////////////////////////////////////////////////////
  131. bool
  132. ComCenterGameObjDef::Load (ChunkLoadClass &cload)
  133. {
  134. while (cload.Open_Chunk ())
  135. {
  136. switch (cload.Cur_Chunk_ID ())
  137. {
  138. case CHUNKID_DEF_PARENT:
  139. BuildingGameObjDef::Load (cload);
  140. break;
  141. case CHUNKID_DEF_VARIABLES:
  142. Load_Variables (cload);
  143. break;
  144. default:
  145. Debug_Say (("Unrecognized Com Center Def chunkID\n"));
  146. break;
  147. }
  148. cload.Close_Chunk ();
  149. }
  150. return true;
  151. }
  152. ////////////////////////////////////////////////////////////////
  153. //
  154. // Load_Variables
  155. //
  156. ////////////////////////////////////////////////////////////////
  157. void
  158. ComCenterGameObjDef::Load_Variables (ChunkLoadClass &cload)
  159. {
  160. while (cload.Open_Micro_Chunk ()) {
  161. /*switch (cload.Cur_Micro_Chunk_ID ())
  162. {
  163. default:
  164. Debug_Say (("Unrecognized Com Center Def Variable chunkID\n"));
  165. break;
  166. }*/
  167. cload.Close_Micro_Chunk();
  168. }
  169. return ;
  170. }
  171. ////////////////////////////////////////////////////////////////
  172. //
  173. // Get_Factory
  174. //
  175. ////////////////////////////////////////////////////////////////
  176. const PersistFactoryClass &
  177. ComCenterGameObjDef::Get_Factory (void) const
  178. {
  179. return _ComCenterGameObjDefPersistFactory;
  180. }
  181. ////////////////////////////////////////////////////////////////
  182. //
  183. // ComCenterGameObj
  184. //
  185. ////////////////////////////////////////////////////////////////
  186. ComCenterGameObj::ComCenterGameObj (void)
  187. {
  188. return ;
  189. }
  190. ////////////////////////////////////////////////////////////////
  191. //
  192. // ~ComCenterGameObj
  193. //
  194. ////////////////////////////////////////////////////////////////
  195. ComCenterGameObj::~ComCenterGameObj (void)
  196. {
  197. return ;
  198. }
  199. ////////////////////////////////////////////////////////////////
  200. //
  201. // Get_Factory
  202. //
  203. ////////////////////////////////////////////////////////////////
  204. const PersistFactoryClass &
  205. ComCenterGameObj::Get_Factory (void) const
  206. {
  207. return _ComCenterGameObjPersistFactory;
  208. }
  209. ////////////////////////////////////////////////////////////////
  210. //
  211. // Init
  212. //
  213. ////////////////////////////////////////////////////////////////
  214. void ComCenterGameObj::Init( void )
  215. {
  216. Init( Get_Definition() );
  217. }
  218. ////////////////////////////////////////////////////////////////
  219. //
  220. // Init
  221. //
  222. ////////////////////////////////////////////////////////////////
  223. void
  224. ComCenterGameObj::Init (const ComCenterGameObjDef &definition)
  225. {
  226. BuildingGameObj::Init (definition);
  227. return ;
  228. }
  229. ////////////////////////////////////////////////////////////////
  230. //
  231. // Get_Definition
  232. //
  233. ////////////////////////////////////////////////////////////////
  234. const ComCenterGameObjDef &
  235. ComCenterGameObj::Get_Definition (void) const
  236. {
  237. return (const ComCenterGameObjDef &)BaseGameObj::Get_Definition ();
  238. }
  239. ////////////////////////////////////////////////////////////////
  240. //
  241. // Save
  242. //
  243. ////////////////////////////////////////////////////////////////
  244. bool
  245. ComCenterGameObj::Save (ChunkSaveClass &csave)
  246. {
  247. csave.Begin_Chunk (CHUNKID_PARENT);
  248. BuildingGameObj::Save (csave);
  249. csave.End_Chunk ();
  250. csave.Begin_Chunk (CHUNKID_VARIABLES);
  251. csave.End_Chunk ();
  252. return true;
  253. }
  254. ////////////////////////////////////////////////////////////////
  255. //
  256. // Load
  257. //
  258. ////////////////////////////////////////////////////////////////
  259. bool
  260. ComCenterGameObj::Load (ChunkLoadClass &cload)
  261. {
  262. while (cload.Open_Chunk ()) {
  263. switch (cload.Cur_Chunk_ID ()) {
  264. case CHUNKID_PARENT:
  265. BuildingGameObj::Load (cload);
  266. break;
  267. case CHUNKID_VARIABLES:
  268. Load_Variables (cload);
  269. break;
  270. default:
  271. Debug_Say (("Unrecognized Com Center chunkID\n"));
  272. break;
  273. }
  274. cload.Close_Chunk();
  275. }
  276. return true;
  277. }
  278. ////////////////////////////////////////////////////////////////
  279. //
  280. // Load_Variables
  281. //
  282. ////////////////////////////////////////////////////////////////
  283. void
  284. ComCenterGameObj::Load_Variables (ChunkLoadClass &cload)
  285. {
  286. while (cload.Open_Micro_Chunk ()) {
  287. /*switch (cload.Cur_Micro_Chunk_ID ())
  288. {
  289. default:
  290. Debug_Say (("Unrecognized Com Center Variable chunkID\n"));
  291. break;
  292. }*/
  293. cload.Close_Micro_Chunk();
  294. }
  295. return ;
  296. }
  297. ////////////////////////////////////////////////////////////////
  298. //
  299. // On_Destroyed
  300. //
  301. ////////////////////////////////////////////////////////////////
  302. void
  303. ComCenterGameObj::On_Destroyed (void)
  304. {
  305. BuildingGameObj::On_Destroyed ();
  306. //
  307. // Switch off the radar for each player on this team
  308. //
  309. if (BaseController != NULL && CombatManager::I_Am_Server ()) {
  310. BaseController->Check_Radar ();
  311. }
  312. return ;
  313. }