BBDATA.CPP 18 KB

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