HDATA.CPP 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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/HDATA.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 : HDATA.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : May 22, 1994 *
  30. * *
  31. * Last Update : September 4, 1996 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * HouseTypeClass::As_Reference -- Fetches a reference to the house specified. *
  36. * HouseTypeClass::From_Name -- Fetch house pointer from its name. *
  37. * HouseTypeClass::HouseTypeClass -- Constructor for house type objects. *
  38. * HouseTypeClass::Init_Heap -- Allocate all heap objects for the house types. *
  39. * HouseTypeClass::One_Time -- One-time initialization *
  40. * HouseTypeClass::Read_INI -- Fetch the house control values from ini database. *
  41. * HouseTypeClass::Remap_Table -- Fetches the remap table for this house. *
  42. * HouseTypeClass::operator delete -- Returns a house type object back to the heap. *
  43. * HouseTypeClass::operator new -- Allocates a house type class object from special heap. *
  44. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  45. #include "function.h"
  46. static HouseTypeClass const HouseEngland(
  47. HOUSE_ENGLAND,
  48. "England", // NAME: House name.
  49. TXT_ENGLAND, // FULLNAME: Translated house name.
  50. "ENG", // SUFFIX: House file suffix.
  51. 0, // LEMON: Lemon vehicle frequency.
  52. PCOLOR_GREEN, // Remap color ID number.
  53. 'E' // VOICE: Voice prefix character.
  54. );
  55. static HouseTypeClass const HouseGermany(
  56. HOUSE_GERMANY,
  57. "Germany", // NAME: House name.
  58. TXT_GERMANY, // FULLNAME: Translated house name.
  59. "GER", // SUFFIX: House file suffix.
  60. 0, // LEMON: Lemon vehicle frequency.
  61. PCOLOR_GREY, // Remap color ID number.
  62. 'G' // VOICE: Voice prefix character.
  63. );
  64. static HouseTypeClass const HouseFrance(
  65. HOUSE_FRANCE,
  66. "France", // NAME: House name.
  67. TXT_FRANCE, // FULLNAME: Translated house name.
  68. "FRA", // SUFFIX: House file suffix.
  69. 0, // LEMON: Lemon vehicle frequency.
  70. PCOLOR_BLUE, // Remap color ID number.
  71. 'F' // VOICE: Voice prefix character.
  72. );
  73. static HouseTypeClass const HouseUkraine(
  74. HOUSE_UKRAINE,
  75. "Ukraine", // NAME: House name.
  76. TXT_UKRAINE, // FULLNAME: Translated house name.
  77. "UKA", // SUFFIX: House file suffix.
  78. 0, // LEMON: Lemon vehicle frequency.
  79. PCOLOR_ORANGE, // Remap color ID number.
  80. 'K' // VOICE: Voice prefix character.
  81. );
  82. static HouseTypeClass const HouseUSSR(
  83. HOUSE_USSR,
  84. "USSR", // NAME: House name.
  85. TXT_USSR, // FULLNAME: Translated house name.
  86. "RED", // SUFFIX: House file suffix.
  87. 0, // LEMON: Lemon vehicle frequency.
  88. PCOLOR_RED, // Remap color ID number.
  89. 'U' // VOICE: Voice prefix character.
  90. );
  91. static HouseTypeClass const HouseGreece(
  92. HOUSE_GREECE,
  93. "Greece", // NAME: House name.
  94. TXT_GREECE, // FULLNAME: Translated house name.
  95. "GRE", // SUFFIX: House file suffix.
  96. 0, // LEMON: Lemon vehicle frequency.
  97. PCOLOR_LTBLUE, // Remap color ID number.
  98. 'G' // VOICE: Voice prefix character.
  99. );
  100. static HouseTypeClass const HouseTurkey(
  101. HOUSE_TURKEY,
  102. "Turkey", // NAME: House name.
  103. TXT_TURKEY, // FULLNAME: Translated house name.
  104. "TRK", // SUFFIX: House file suffix.
  105. 0, // LEMON: Lemon vehicle frequency.
  106. PCOLOR_BROWN, // Remap color ID number.
  107. 'T' // VOICE: Voice prefix character.
  108. );
  109. static HouseTypeClass const HouseSpain(
  110. HOUSE_SPAIN,
  111. "Spain", // NAME: House name.
  112. TXT_SPAIN, // FULLNAME: Translated house name.
  113. "SPN", // SUFFIX: House file suffix.
  114. 0, // LEMON: Lemon vehicle frequency.
  115. PCOLOR_GOLD, // Remap color ID number.
  116. 'S' // VOICE: Voice prefix character.
  117. );
  118. static HouseTypeClass const HouseGood(
  119. HOUSE_GOOD,
  120. "GoodGuy", // NAME: House name.
  121. TXT_GOODGUY, // FULLNAME: Translated house name.
  122. "GDI", // SUFFIX: House file suffix.
  123. 0, // LEMON: Lemon vehicle frequency.
  124. PCOLOR_LTBLUE, // Remap color ID number.
  125. 'G' // VOICE: Voice prefix character.
  126. );
  127. static HouseTypeClass const HouseBad(
  128. HOUSE_BAD,
  129. "BadGuy", // NAME: House name.
  130. TXT_BADGUY, // FULLNAME: Translated house name.
  131. "NOD", // SUFFIX: House file suffix.
  132. 0, // LEMON: Lemon vehicle frequency.
  133. PCOLOR_RED, // Remap color ID number.
  134. 'B' // VOICE: Voice prefix character.
  135. );
  136. static HouseTypeClass const HouseCivilian(
  137. HOUSE_NEUTRAL,
  138. "Neutral", // NAME: House name.
  139. TXT_CIVILIAN, // FULLNAME: Translated house name.
  140. "CIV", // SUFFIX: House file suffix.
  141. 0, // LEMON: Lemon vehicle frequency.
  142. PCOLOR_GOLD, // Remap color ID number.
  143. 'C' // VOICE: Voice prefix character.
  144. );
  145. static HouseTypeClass const HouseJP(
  146. HOUSE_JP,
  147. "Special", // NAME: House name.
  148. TXT_JP, // FULLNAME: Translated house name.
  149. "JP", // SUFFIX: House file suffix.
  150. 0, // LEMON: Lemon vehicle frequency.
  151. PCOLOR_GOLD, // Remap color ID number.
  152. 'J' // VOICE: Voice prefix character.
  153. );
  154. static HouseTypeClass const HouseMulti1(
  155. HOUSE_MULTI1,
  156. "Multi1", // NAME: House name.
  157. TXT_CIVILIAN, // FULLNAME: Translated house name.
  158. "MP1", // SUFFIX: House file suffix.
  159. 0, // LEMON: Lemon vehicle frequency.
  160. PCOLOR_GOLD, // Remap color ID number.
  161. 'M' // VOICE: Voice prefix character.
  162. );
  163. static HouseTypeClass const HouseMulti2(
  164. HOUSE_MULTI2,
  165. "Multi2", // NAME: House name.
  166. TXT_CIVILIAN, // FULLNAME: Translated house name.
  167. "MP2", // SUFFIX: House file suffix.
  168. 0, // LEMON: Lemon vehicle frequency.
  169. PCOLOR_LTBLUE, // Remap color ID number.
  170. 'M' // VOICE: Voice prefix character.
  171. );
  172. static HouseTypeClass const HouseMulti3(
  173. HOUSE_MULTI3,
  174. "Multi3", // NAME: House name.
  175. TXT_CIVILIAN, // FULLNAME: Translated house name.
  176. "MP3", // SUFFIX: House file suffix.
  177. 0, // LEMON: Lemon vehicle frequency.
  178. PCOLOR_RED, // Remap color ID number.
  179. 'M' // VOICE: Voice prefix character.
  180. );
  181. static HouseTypeClass const HouseMulti4(
  182. HOUSE_MULTI4,
  183. "Multi4", // NAME: House name.
  184. TXT_CIVILIAN, // FULLNAME: Translated house name.
  185. "MP4", // SUFFIX: House file suffix.
  186. 0, // LEMON: Lemon vehicle frequency.
  187. PCOLOR_GREEN, // Remap color ID number.
  188. 'M' // VOICE: Voice prefix character.
  189. );
  190. static HouseTypeClass const HouseMulti5(
  191. HOUSE_MULTI5,
  192. "Multi5", // NAME: House name.
  193. TXT_CIVILIAN, // FULLNAME: Translated house name.
  194. "MP5", // SUFFIX: House file suffix.
  195. 0, // LEMON: Lemon vehicle frequency.
  196. PCOLOR_ORANGE, // Remap color ID number.
  197. 'M' // VOICE: Voice prefix character.
  198. );
  199. static HouseTypeClass const HouseMulti6(
  200. HOUSE_MULTI6,
  201. "Multi6", // NAME: House name.
  202. TXT_CIVILIAN, // FULLNAME: Translated house name.
  203. "MP6", // SUFFIX: House file suffix.
  204. 0, // LEMON: Lemon vehicle frequency.
  205. PCOLOR_GREY, // Remap color ID number.
  206. 'M' // VOICE: Voice prefix character.
  207. );
  208. static HouseTypeClass const HouseMulti7(
  209. HOUSE_MULTI7,
  210. "Multi7", // NAME: House name.
  211. TXT_CIVILIAN, // FULLNAME: Translated house name.
  212. "MP7", // SUFFIX: House file suffix.
  213. 0, // LEMON: Lemon vehicle frequency.
  214. PCOLOR_BLUE, // Remap color ID number.
  215. 'M' // VOICE: Voice prefix character.
  216. );
  217. static HouseTypeClass const HouseMulti8(
  218. HOUSE_MULTI8,
  219. "Multi8", // NAME: House name.
  220. TXT_CIVILIAN, // FULLNAME: Translated house name.
  221. "MP8", // SUFFIX: House file suffix.
  222. 0, // LEMON: Lemon vehicle frequency.
  223. PCOLOR_BROWN, // Remap color ID number.
  224. 'M' // VOICE: Voice prefix character.
  225. );
  226. #ifdef OBSOLETE
  227. HouseTypeClass const * const HouseTypeClass::Pointers[HOUSE_COUNT] = {
  228. &HouseSpain,
  229. &HouseGreece,
  230. &HouseUSSR,
  231. &HouseEngland,
  232. &HouseUkraine,
  233. &HouseGermany,
  234. &HouseFrance,
  235. &HouseTurkey,
  236. &HouseGood,
  237. &HouseBad,
  238. &HouseCivilian,
  239. &HouseJP,
  240. &HouseMulti1,
  241. &HouseMulti2,
  242. &HouseMulti3,
  243. &HouseMulti4,
  244. &HouseMulti5,
  245. &HouseMulti6,
  246. &HouseMulti7,
  247. &HouseMulti8,
  248. };
  249. #endif
  250. /***********************************************************************************************
  251. * HouseTypeClass::HouseTypeClass -- Constructor for house type objects. *
  252. * *
  253. * This is the constructor for house type objects. This object holds the constant data *
  254. * for the house type. *
  255. * *
  256. * INPUT: see below... *
  257. * *
  258. * OUTPUT: none *
  259. * *
  260. * WARNINGS: none *
  261. * *
  262. * HISTORY: *
  263. * 06/21/1994 JLB : Created. *
  264. *=============================================================================================*/
  265. HouseTypeClass::HouseTypeClass(
  266. HousesType house,
  267. char const * ini,
  268. int fullname,
  269. char const * ext,
  270. int lemon,
  271. PlayerColorType remapcolor,
  272. char prefix) :
  273. AbstractTypeClass(RTTI_HOUSETYPE, house, fullname, ini),
  274. // RTTI(RTTI_HOUSETYPE),
  275. // ID(house),
  276. House(house),
  277. // IniName(ini),
  278. // FullName(fullname),
  279. Lemon(lemon),
  280. RemapColor(remapcolor),
  281. Prefix(prefix),
  282. FirepowerBias(1),
  283. GroundspeedBias(1),
  284. AirspeedBias(1),
  285. ArmorBias(1),
  286. ROFBias(1),
  287. CostBias(1),
  288. BuildSpeedBias(1)
  289. {
  290. strncpy(Suffix, ext, 3);
  291. Suffix[3] = '\0';
  292. }
  293. /***********************************************************************************************
  294. * HouseTypeClass::operator new -- Allocates a house type class object from special heap. *
  295. * *
  296. * This will allocate a house type object from the special heap that is used to maintain *
  297. * objects of this type. *
  298. * *
  299. * INPUT: none *
  300. * *
  301. * OUTPUT: Returns a pointer to the newly allocated house type object. *
  302. * *
  303. * WARNINGS: If there is insufficient room, this routine may return NULL. *
  304. * *
  305. * HISTORY: *
  306. * 09/04/1996 JLB : Created. *
  307. *=============================================================================================*/
  308. void * HouseTypeClass::operator new(size_t)
  309. {
  310. return(HouseTypes.Alloc());
  311. }
  312. /***********************************************************************************************
  313. * HouseTypeClass::operator delete -- Returns a house type object back to the heap. *
  314. * *
  315. * This will return the house type object specified back into the special heap that *
  316. * is used to maintain house type objects. *
  317. * *
  318. * INPUT: ptr -- Pointer to the house type object to delete. *
  319. * *
  320. * OUTPUT: none *
  321. * *
  322. * WARNINGS: none *
  323. * *
  324. * HISTORY: *
  325. * 09/04/1996 JLB : Created. *
  326. *=============================================================================================*/
  327. void HouseTypeClass::operator delete(void * ptr)
  328. {
  329. HouseTypes.Free((HouseTypeClass *)ptr);
  330. }
  331. /***********************************************************************************************
  332. * HouseTypeClass::Init_Heap -- Allocate all heap objects for the house types. *
  333. * *
  334. * This will preallocate all the house types. They must be allocated in a particular order. *
  335. * *
  336. * INPUT: none *
  337. * *
  338. * OUTPUT: none *
  339. * *
  340. * WARNINGS: This routine should be called only once at the beginning of the game. *
  341. * *
  342. * HISTORY: *
  343. * 09/04/1996 JLB : Created. *
  344. *=============================================================================================*/
  345. void HouseTypeClass::Init_Heap(void)
  346. {
  347. /*
  348. ** These house type class objects must be allocated in the exact order that they
  349. ** are specified in the HousesType enumeration. This is necessary because the heap
  350. ** allocation block index serves double duty as the type number index.
  351. */
  352. new HouseTypeClass(HouseSpain);
  353. new HouseTypeClass(HouseGreece);
  354. new HouseTypeClass(HouseUSSR);
  355. new HouseTypeClass(HouseEngland);
  356. new HouseTypeClass(HouseUkraine);
  357. new HouseTypeClass(HouseGermany);
  358. new HouseTypeClass(HouseFrance);
  359. new HouseTypeClass(HouseTurkey);
  360. new HouseTypeClass(HouseGood);
  361. new HouseTypeClass(HouseBad);
  362. new HouseTypeClass(HouseCivilian);
  363. new HouseTypeClass(HouseJP);
  364. new HouseTypeClass(HouseMulti1);
  365. new HouseTypeClass(HouseMulti2);
  366. new HouseTypeClass(HouseMulti3);
  367. new HouseTypeClass(HouseMulti4);
  368. new HouseTypeClass(HouseMulti5);
  369. new HouseTypeClass(HouseMulti6);
  370. new HouseTypeClass(HouseMulti7);
  371. new HouseTypeClass(HouseMulti8);
  372. }
  373. /***********************************************************************************************
  374. * HouseTypeClass::From_Name -- Fetch house pointer from its name. *
  375. * *
  376. * This routine will convert the ASCII house name specified into a *
  377. * real house number. Typically, this is used when processing a *
  378. * scenario INI file. *
  379. * *
  380. * INPUT: name -- ASCII name of house to process. *
  381. * *
  382. * OUTPUT: Returns with actual house number represented by the ASCII *
  383. * name specified. *
  384. * *
  385. * WARNINGS: none *
  386. * *
  387. * HISTORY: *
  388. * 10/07/1992 JLB : Created. *
  389. * 05/21/1994 JLB : Converted to member function. *
  390. *=============================================================================================*/
  391. HousesType HouseTypeClass::From_Name(char const * name)
  392. {
  393. if (name != NULL) {
  394. for (HousesType house = HOUSE_FIRST; house < HOUSE_COUNT; house++) {
  395. if (stricmp(As_Reference(house).IniName, name) == 0) {
  396. // if (stricmp(Pointers[house]->IniName, name) == 0) {
  397. return(house);
  398. }
  399. }
  400. }
  401. return(HOUSE_NONE);
  402. }
  403. /***********************************************************************************************
  404. * HouseTypeClass::One_Time -- One-time initialization *
  405. * *
  406. * INPUT: none *
  407. * *
  408. * OUTPUT: none *
  409. * *
  410. * WARNINGS: none *
  411. * *
  412. * HISTORY: *
  413. * 05/21/1994 JLB : Converted to member function. *
  414. * 06/19/1996 JLB : Converted to regular heap class management. *
  415. *=============================================================================================*/
  416. void HouseTypeClass::One_Time(void)
  417. {
  418. }
  419. /***********************************************************************************************
  420. * HouseTypeClass::As_Reference -- Fetches a reference to the house specified. *
  421. * *
  422. * Use this routine to fetch a reference to the house number specified. *
  423. * *
  424. * INPUT: house -- The house number (HousesType) to look up. *
  425. * *
  426. * OUTPUT: Returns with a reference to the HouseTypeClass object that matches the house *
  427. * number specified. *
  428. * *
  429. * WARNINGS: none *
  430. * *
  431. * HISTORY: *
  432. * 01/23/1995 JLB : Created. *
  433. *=============================================================================================*/
  434. HouseTypeClass & HouseTypeClass::As_Reference(HousesType house)
  435. {
  436. return(*HouseTypes.Ptr(house));
  437. }
  438. /***********************************************************************************************
  439. * HouseTypeClass::Remap_Table -- Fetches the remap table for this house. *
  440. * *
  441. * Use this routine to fetch the remap table assigned to this house. The remap table is *
  442. * what gives the house's units/buildings their distinctive color. *
  443. * *
  444. * INPUT: none *
  445. * *
  446. * OUTPUT: Returns with a pointer to the remap table to use for this house. *
  447. * *
  448. * WARNINGS: none *
  449. * *
  450. * HISTORY: *
  451. * 06/03/1996 JLB : Created. *
  452. *=============================================================================================*/
  453. unsigned char const * HouseTypeClass::Remap_Table(void) const
  454. {
  455. return(ColorRemaps[RemapColor].RemapTable);
  456. }
  457. /***********************************************************************************************
  458. * HouseTypeClass::Read_INI -- Fetch the house control values from ini database. *
  459. * *
  460. * This routine will fetch the rules controllable values for the house type from the *
  461. * INI database specified. *
  462. * *
  463. * INPUT: ini -- Reference to the INI database to fetch the house control values from. *
  464. * *
  465. * OUTPUT: bool; Was the house section found and processed? *
  466. * *
  467. * WARNINGS: none *
  468. * *
  469. * HISTORY: *
  470. * 09/04/1996 JLB : Created. *
  471. *=============================================================================================*/
  472. bool HouseTypeClass::Read_INI(CCINIClass & ini)
  473. {
  474. if (ini.Is_Present(Name())) {
  475. FirepowerBias = ini.Get_Fixed(Name(), "Firepower", FirepowerBias);
  476. GroundspeedBias = ini.Get_Fixed(Name(), "Groundspeed", GroundspeedBias);
  477. AirspeedBias = ini.Get_Fixed(Name(), "Airspeed", AirspeedBias);
  478. ArmorBias = ini.Get_Fixed(Name(), "Armor", ArmorBias);
  479. ROFBias = ini.Get_Fixed(Name(), "ROF", ROFBias);
  480. CostBias = ini.Get_Fixed(Name(), "Cost", CostBias);
  481. BuildSpeedBias = ini.Get_Fixed(Name(), "BuildTime", BuildSpeedBias);
  482. return(true);
  483. }
  484. return(false);
  485. }