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