BBDATA.CPP 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/BBDATA.CPP 1 3/03/97 10:24a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : BBDATA.CPP *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : May 23, 1994 *
  26. * *
  27. * Last Update : July 19, 1996 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * BulletTypeClass::As_Reference -- Returns with a reference to the bullet type object specif*
  32. * BulletTypeClass::BulletTypeClass -- Constructor for bullet type objects. *
  33. * BulletTypeClass::Init_Heap -- Initialize the heap objects for the bullet type. *
  34. * BulletTypeClass::Load_Shapes -- Load shape data for bullet types. *
  35. * BulletTypeClass::One_Time -- Performs the one time processing for bullets. *
  36. * BulletTypeClass::Read_INI -- Fetch the bullet type data from the INI database. *
  37. * BulletTypeClass::operator delete -- Deletes a bullet type object from the special heap. *
  38. * BulletTypeClass::operator new -- Allocates a bullet type object from the special heap. *
  39. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  40. #include "function.h"
  41. /***********************************************************************************************
  42. * BulletTypeClass::BulletTypeClass -- Constructor for bullet type objects. *
  43. * *
  44. * This is basically a constructor for static type objects used by bullets. All bullets *
  45. * are of a type constructed by this routine at game initialization time. *
  46. * *
  47. * INPUT: see below... *
  48. * *
  49. * OUTPUT: none *
  50. * *
  51. * WARNINGS: none *
  52. * *
  53. * HISTORY: *
  54. * 10/17/1994 JLB : Created. *
  55. * 07/17/1996 JLB : Uses correct default values. *
  56. *=============================================================================================*/
  57. BulletTypeClass::BulletTypeClass(char const * name) :
  58. ObjectTypeClass( RTTI_BULLETTYPE,
  59. BulletTypes.ID(this),
  60. true,
  61. true,
  62. false,
  63. false,
  64. true,
  65. true,
  66. false,
  67. TXT_NONE,
  68. name
  69. ),
  70. IsHigh(false),
  71. IsShadow(true),
  72. IsArcing(false),
  73. IsDropping(false),
  74. IsInvisible(false),
  75. IsProximityArmed(false),
  76. IsFlameEquipped(false),
  77. IsFueled(false),
  78. IsFaceless(true),
  79. IsInaccurate(false),
  80. IsTranslucent(false),
  81. IsAntiAircraft(false),
  82. IsAntiGround(true),
  83. IsAntiSub(false),
  84. IsDegenerate(false),
  85. IsSubSurface(false),
  86. IsParachuted(false),
  87. IsGigundo(false),
  88. Type(BulletType(ID)),
  89. ROT(0),
  90. Arming(0),
  91. Tumble(0)
  92. {
  93. }
  94. /***********************************************************************************************
  95. * BulletTypeClass::operator new -- Allocates a bullet type object from the special heap. *
  96. * *
  97. * This allocates a bullet type object from a special heap that is used just for *
  98. * objects of this type. *
  99. * *
  100. * INPUT: none *
  101. * *
  102. * OUTPUT: Returns with a pointer to an allocated block or NULL if the allocation could not *
  103. * occur. *
  104. * *
  105. * WARNINGS: none *
  106. * *
  107. * HISTORY: *
  108. * 07/06/1996 JLB : Created. *
  109. *=============================================================================================*/
  110. void * BulletTypeClass::operator new(size_t)
  111. {
  112. return(BulletTypes.Alloc());
  113. }
  114. /***********************************************************************************************
  115. * BulletTypeClass::operator delete -- Deletes a bullet type object from the special heap. *
  116. * *
  117. * This is the counterpart to the operator new function for bullet type objects. It will *
  118. * return the bullet type object back to the special heap used for bullet type object *
  119. * allocation. *
  120. * *
  121. * INPUT: ptr -- Pointer to the bullet type object to free. *
  122. * *
  123. * OUTPUT: none *
  124. * *
  125. * WARNINGS: none *
  126. * *
  127. * HISTORY: *
  128. * 07/06/1996 JLB : Created. *
  129. *=============================================================================================*/
  130. void BulletTypeClass::operator delete(void * ptr)
  131. {
  132. BulletTypes.Free((BulletTypeClass *)ptr);
  133. }
  134. /***********************************************************************************************
  135. * BulletTypeClass::Init_Heap -- Initialize the heap objects for the bullet type. *
  136. * *
  137. * This performs any necessary initialization for the bullet types. *
  138. * *
  139. * INPUT: none *
  140. * *
  141. * OUTPUT: none *
  142. * *
  143. * WARNINGS: none *
  144. * *
  145. * HISTORY: *
  146. * 07/06/1996 JLB : Created. *
  147. *=============================================================================================*/
  148. void BulletTypeClass::Init_Heap(void)
  149. {
  150. /*
  151. ** These bullet type class objects must be allocated in the exact order that they
  152. ** are specified in the BulletType enumeration. This is necessary because the heap
  153. ** allocation block index serves double duty as the type number index.
  154. */
  155. new BulletTypeClass("Invisible"); // BULLET_INVISIBLE
  156. new BulletTypeClass("Cannon"); // BULLET_CANNON
  157. new BulletTypeClass("Ack"); // BULLET_ACK
  158. new BulletTypeClass("Torpedo"); // BULLET_TORPEDO
  159. new BulletTypeClass("FROG"); // BULLET_FROG
  160. new BulletTypeClass("HeatSeeker"); // BULLET_HEAT_SEEKER
  161. new BulletTypeClass("LaserGuided"); // BULLET_LASER_GUIDED
  162. new BulletTypeClass("Lobbed"); // BULLET_LOBBED
  163. new BulletTypeClass("Bomblet"); // BULLET_BOMBLET
  164. new BulletTypeClass("Ballistic"); // BULLET_BALLISTIC
  165. new BulletTypeClass("Parachute"); // BULLET_PARACHUTE
  166. new BulletTypeClass("Fireball"); // BULLET_FIREBALL
  167. new BulletTypeClass("LeapDog"); // BULLET_DOG
  168. new BulletTypeClass("Catapult"); // BULLET_CATAPULT
  169. new BulletTypeClass("AAMissile"); // BULLET_AAMISSILE
  170. new BulletTypeClass("GPSSatellite");// BULLET_GPS_SATELLITE
  171. new BulletTypeClass("NukeUp"); // BULLET_NUKE_UP
  172. new BulletTypeClass("NukeDown"); // BULLET_NUKE_DOWN
  173. }
  174. /***********************************************************************************************
  175. * BulletTypeClass::One_Time -- Performs the one time processing for bullets. *
  176. * *
  177. * This routine is used to perform any one time processing for the bullet type class. It *
  178. * handles loading of the shape files. *
  179. * *
  180. * INPUT: none *
  181. * *
  182. * OUTPUT: none *
  183. * *
  184. * WARNINGS: This routine must be called before any rendering of bullets occurs and should *
  185. * only be called once. *
  186. * *
  187. * HISTORY: *
  188. * 05/28/1994 JLB : Created. *
  189. *=============================================================================================*/
  190. void BulletTypeClass::One_Time(void)
  191. {
  192. /*
  193. ** Load the bullet shapes.
  194. */
  195. for (int index = BULLET_FIRST; index < BULLET_COUNT; index++) {
  196. BulletTypeClass const & bullet = As_Reference((BulletType)index);
  197. char fullname[_MAX_FNAME+_MAX_EXT];
  198. if (!bullet.IsInvisible) {
  199. _makepath(fullname, NULL, NULL, bullet.GraphicName, ".SHP");
  200. #ifdef NDEBUG
  201. ((void const *&)bullet.ImageData) = MFCD::Retrieve(fullname);
  202. #else
  203. RawFileClass file(fullname);
  204. if (file.Is_Available()) {
  205. ((void const *&)bullet.ImageData) = Load_Alloc_Data(file);
  206. } else {
  207. ((void const *&)bullet.ImageData) = MFCD::Retrieve(fullname);
  208. }
  209. #endif
  210. }
  211. }
  212. }
  213. /***********************************************************************************************
  214. * BulletTypeClass::As_Reference -- Returns with a reference to the bullet type object specifi *
  215. * *
  216. * Given a bullet type identifier, this routine will return a reference to the bullet type *
  217. * object it refers to. *
  218. * *
  219. * INPUT: type -- The bullet type identifier to convert to a reference. *
  220. * *
  221. * OUTPUT: Returns with a reference to the bullet type object. *
  222. * *
  223. * WARNINGS: Make sure that the type parameter specified is a valid bullet type. If not, *
  224. * then the results are undefined. *
  225. * *
  226. * HISTORY: *
  227. * 07/06/1996 JLB : Created. *
  228. *=============================================================================================*/
  229. BulletTypeClass & BulletTypeClass::As_Reference(BulletType type)
  230. {
  231. return(*BulletTypes.Ptr(type));
  232. }
  233. /***********************************************************************************************
  234. * BulletTypeClass::Read_INI -- Fetch the bullet type data from the INI database. *
  235. * *
  236. * Use this routine to fetch override information about this bullet type class object *
  237. * from the INI database specified. *
  238. * *
  239. * INPUT: ini -- Reference to the INI database to examine. *
  240. * *
  241. * OUTPUT: bool; Was the section for this bullet found and the data extracted? *
  242. * *
  243. * WARNINGS: none *
  244. * *
  245. * HISTORY: *
  246. * 07/19/1996 JLB : Created. *
  247. *=============================================================================================*/
  248. bool BulletTypeClass::Read_INI(CCINIClass & ini)
  249. {
  250. if (ini.Is_Present(Name())) {
  251. Arming = ini.Get_Int(Name(), "Arm", Arming);
  252. ROT = ini.Get_Int(Name(), "ROT", ROT);
  253. Tumble = ini.Get_Int(Name(), "Frames", Tumble);
  254. IsHigh = ini.Get_Bool(Name(), "High", IsHigh);
  255. IsShadow = ini.Get_Bool(Name(), "Shadow", IsShadow);
  256. IsArcing = ini.Get_Bool(Name(), "Arcing", IsArcing);
  257. IsDropping = ini.Get_Bool(Name(), "Dropping", IsDropping);
  258. IsInvisible = ini.Get_Bool(Name(), "Inviso", IsInvisible);
  259. IsProximityArmed = ini.Get_Bool(Name(), "Proximity", IsProximityArmed);
  260. IsFlameEquipped = ini.Get_Bool(Name(), "Animates", IsFlameEquipped);
  261. IsFueled = ini.Get_Bool(Name(), "Ranged", IsFueled);
  262. IsInaccurate = ini.Get_Bool(Name(), "Inaccuate", IsInaccurate);
  263. IsAntiAircraft = ini.Get_Bool(Name(), "AA", IsAntiAircraft);
  264. IsAntiGround = ini.Get_Bool(Name(), "AG", IsAntiGround);
  265. IsAntiSub = ini.Get_Bool(Name(), "ASW", IsAntiSub);
  266. IsDegenerate = ini.Get_Bool(Name(), "Degenerates", IsDegenerate);
  267. IsSubSurface = ini.Get_Bool(Name(), "UnderWater", IsSubSurface);
  268. IsParachuted = ini.Get_Bool(Name(), "Parachuted", IsParachuted);
  269. IsFaceless = !ini.Get_Bool(Name(), "Rotates", !IsFaceless);
  270. IsTranslucent = ini.Get_Bool(Name(), "Translucent", IsTranslucent);
  271. IsGigundo = ini.Get_Bool(Name(), "Gigundo", IsGigundo);
  272. ini.Get_String(Name(), "Image", GraphicName, GraphicName, sizeof(GraphicName));
  273. return(true);
  274. }
  275. return(false);
  276. }