powerplantgameobj.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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/powerplantgameobj.cpp $*
  25. * *
  26. * $Author:: Denzil_l $*
  27. * *
  28. * $Modtime:: 11/21/01 9:31a $*
  29. * *
  30. * $Revision:: 4 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "powerplantgameobj.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. ////////////////////////////////////////////////////////////////
  46. // Hacks
  47. ////////////////////////////////////////////////////////////////
  48. DECLARE_FORCE_LINK (PowerPlant)
  49. ////////////////////////////////////////////////////////////////
  50. // Editable and persist factories
  51. ////////////////////////////////////////////////////////////////
  52. SimplePersistFactoryClass <PowerPlantGameObjDef, CHUNKID_GAME_OBJECT_DEF_POWERPLANT> _PowerPlantGameObjDefPersistFactory;
  53. SimplePersistFactoryClass <PowerPlantGameObj, CHUNKID_GAME_OBJECT_POWERPLANT> _PowerPlantGameObjPersistFactory;
  54. DECLARE_DEFINITION_FACTORY (PowerPlantGameObjDef, CLASSID_GAME_OBJECT_DEF_POWERPLANT, "Powerplant") _PowerPlantGameObjDefDefFactory;
  55. ////////////////////////////////////////////////////////////////
  56. // Save/Load constants
  57. ////////////////////////////////////////////////////////////////
  58. enum
  59. {
  60. CHUNKID_DEF_PARENT = 0x02211153,
  61. CHUNKID_DEF_VARIABLES,
  62. MICROCHUNKID_DEF_UNUSED = 1,
  63. };
  64. enum
  65. {
  66. CHUNKID_PARENT = 0x02211154,
  67. CHUNKID_VARIABLES,
  68. MICROCHUNKID_UNUSED = 1,
  69. };
  70. ////////////////////////////////////////////////////////////////
  71. //
  72. // PowerPlantGameObjDef
  73. //
  74. ////////////////////////////////////////////////////////////////
  75. PowerPlantGameObjDef::PowerPlantGameObjDef (void)
  76. {
  77. return ;
  78. }
  79. ////////////////////////////////////////////////////////////////
  80. //
  81. // ~PowerPlantGameObjDef
  82. //
  83. ////////////////////////////////////////////////////////////////
  84. PowerPlantGameObjDef::~PowerPlantGameObjDef (void)
  85. {
  86. return ;
  87. }
  88. ////////////////////////////////////////////////////////////////
  89. //
  90. // Get_Class_ID
  91. //
  92. ////////////////////////////////////////////////////////////////
  93. uint32
  94. PowerPlantGameObjDef::Get_Class_ID (void) const
  95. {
  96. return CLASSID_GAME_OBJECT_DEF_POWERPLANT;
  97. }
  98. ////////////////////////////////////////////////////////////////
  99. //
  100. // Create
  101. //
  102. ////////////////////////////////////////////////////////////////
  103. PersistClass *
  104. PowerPlantGameObjDef::Create (void) const
  105. {
  106. PowerPlantGameObj *building = new PowerPlantGameObj;
  107. building->Init (*this);
  108. return building;
  109. }
  110. ////////////////////////////////////////////////////////////////
  111. //
  112. // Create
  113. //
  114. ////////////////////////////////////////////////////////////////
  115. bool
  116. PowerPlantGameObjDef::Save (ChunkSaveClass &csave)
  117. {
  118. csave.Begin_Chunk (CHUNKID_DEF_PARENT);
  119. BuildingGameObjDef::Save (csave);
  120. csave.End_Chunk ();
  121. csave.Begin_Chunk (CHUNKID_DEF_VARIABLES);
  122. csave.End_Chunk ();
  123. return true;
  124. }
  125. ////////////////////////////////////////////////////////////////
  126. //
  127. // Load
  128. //
  129. ////////////////////////////////////////////////////////////////
  130. bool
  131. PowerPlantGameObjDef::Load (ChunkLoadClass &cload)
  132. {
  133. while (cload.Open_Chunk ())
  134. {
  135. switch (cload.Cur_Chunk_ID ())
  136. {
  137. case CHUNKID_DEF_PARENT:
  138. BuildingGameObjDef::Load (cload);
  139. break;
  140. case CHUNKID_DEF_VARIABLES:
  141. Load_Variables (cload);
  142. break;
  143. default:
  144. Debug_Say (("Unrecognized Powerplant Def chunkID\n"));
  145. break;
  146. }
  147. cload.Close_Chunk ();
  148. }
  149. return true;
  150. }
  151. ////////////////////////////////////////////////////////////////
  152. //
  153. // Load_Variables
  154. //
  155. ////////////////////////////////////////////////////////////////
  156. void
  157. PowerPlantGameObjDef::Load_Variables (ChunkLoadClass &cload)
  158. {
  159. while (cload.Open_Micro_Chunk ()) {
  160. /*switch (cload.Cur_Micro_Chunk_ID ())
  161. {
  162. default:
  163. Debug_Say (("Unrecognized Powerplant Def Variable chunkID\n"));
  164. break;
  165. }*/
  166. cload.Close_Micro_Chunk();
  167. }
  168. return ;
  169. }
  170. ////////////////////////////////////////////////////////////////
  171. //
  172. // Get_Factory
  173. //
  174. ////////////////////////////////////////////////////////////////
  175. const PersistFactoryClass &
  176. PowerPlantGameObjDef::Get_Factory (void) const
  177. {
  178. return _PowerPlantGameObjDefPersistFactory;
  179. }
  180. ////////////////////////////////////////////////////////////////
  181. //
  182. // PowerPlantGameObj
  183. //
  184. ////////////////////////////////////////////////////////////////
  185. PowerPlantGameObj::PowerPlantGameObj (void)
  186. {
  187. return ;
  188. }
  189. ////////////////////////////////////////////////////////////////
  190. //
  191. // ~PowerPlantGameObj
  192. //
  193. ////////////////////////////////////////////////////////////////
  194. PowerPlantGameObj::~PowerPlantGameObj (void)
  195. {
  196. return ;
  197. }
  198. ////////////////////////////////////////////////////////////////
  199. //
  200. // Get_Factory
  201. //
  202. ////////////////////////////////////////////////////////////////
  203. const PersistFactoryClass &
  204. PowerPlantGameObj::Get_Factory (void) const
  205. {
  206. return _PowerPlantGameObjPersistFactory;
  207. }
  208. ////////////////////////////////////////////////////////////////
  209. //
  210. // Init
  211. //
  212. ////////////////////////////////////////////////////////////////
  213. void PowerPlantGameObj::Init( void )
  214. {
  215. Init( Get_Definition() );
  216. }
  217. ////////////////////////////////////////////////////////////////
  218. //
  219. // Init
  220. //
  221. ////////////////////////////////////////////////////////////////
  222. void
  223. PowerPlantGameObj::Init (const PowerPlantGameObjDef &definition)
  224. {
  225. BuildingGameObj::Init (definition);
  226. return ;
  227. }
  228. ////////////////////////////////////////////////////////////////
  229. //
  230. // Get_Definition
  231. //
  232. ////////////////////////////////////////////////////////////////
  233. const PowerPlantGameObjDef &
  234. PowerPlantGameObj::Get_Definition (void) const
  235. {
  236. return (const PowerPlantGameObjDef &)BaseGameObj::Get_Definition ();
  237. }
  238. ////////////////////////////////////////////////////////////////
  239. //
  240. // Save
  241. //
  242. ////////////////////////////////////////////////////////////////
  243. bool
  244. PowerPlantGameObj::Save (ChunkSaveClass &csave)
  245. {
  246. csave.Begin_Chunk (CHUNKID_PARENT);
  247. BuildingGameObj::Save (csave);
  248. csave.End_Chunk ();
  249. csave.Begin_Chunk (CHUNKID_VARIABLES);
  250. csave.End_Chunk ();
  251. return true;
  252. }
  253. ////////////////////////////////////////////////////////////////
  254. //
  255. // Load
  256. //
  257. ////////////////////////////////////////////////////////////////
  258. bool
  259. PowerPlantGameObj::Load (ChunkLoadClass &cload)
  260. {
  261. while (cload.Open_Chunk ()) {
  262. switch (cload.Cur_Chunk_ID ()) {
  263. case CHUNKID_PARENT:
  264. BuildingGameObj::Load (cload);
  265. break;
  266. case CHUNKID_VARIABLES:
  267. Load_Variables (cload);
  268. break;
  269. default:
  270. Debug_Say (("Unrecognized Powerplant chunkID\n"));
  271. break;
  272. }
  273. cload.Close_Chunk();
  274. }
  275. return true;
  276. }
  277. ////////////////////////////////////////////////////////////////
  278. //
  279. // Load_Variables
  280. //
  281. ////////////////////////////////////////////////////////////////
  282. void
  283. PowerPlantGameObj::Load_Variables (ChunkLoadClass &cload)
  284. {
  285. while (cload.Open_Micro_Chunk ()) {
  286. /*switch (cload.Cur_Micro_Chunk_ID ())
  287. {
  288. default:
  289. Debug_Say (("Unrecognized Powerplant Variable chunkID\n"));
  290. break;
  291. }*/
  292. cload.Close_Micro_Chunk();
  293. }
  294. return ;
  295. }
  296. ////////////////////////////////////////////////////////////////
  297. //
  298. // On_Destroyed
  299. //
  300. ////////////////////////////////////////////////////////////////
  301. void
  302. PowerPlantGameObj::On_Destroyed (void)
  303. {
  304. BuildingGameObj::On_Destroyed ();
  305. //
  306. // Tell the base that it better check the power state
  307. // of the base.
  308. //
  309. if (BaseController != NULL) {
  310. BaseController->Check_Base_Power ();
  311. }
  312. return ;
  313. }