| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- /*
- ** Command & Conquer Red Alert(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /* $Header: /CounterStrike/HDATA.CPP 1 3/03/97 10:24a Joe_bostic $ */
- /***********************************************************************************************
- *** 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 ***
- ***********************************************************************************************
- * *
- * Project Name : Command & Conquer *
- * *
- * File Name : HDATA.CPP *
- * *
- * Programmer : Joe L. Bostic *
- * *
- * Start Date : May 22, 1994 *
- * *
- * Last Update : September 4, 1996 [JLB] *
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * HouseTypeClass::As_Reference -- Fetches a reference to the house specified. *
- * HouseTypeClass::From_Name -- Fetch house pointer from its name. *
- * HouseTypeClass::HouseTypeClass -- Constructor for house type objects. *
- * HouseTypeClass::Init_Heap -- Allocate all heap objects for the house types. *
- * HouseTypeClass::One_Time -- One-time initialization *
- * HouseTypeClass::Read_INI -- Fetch the house control values from ini database. *
- * HouseTypeClass::Remap_Table -- Fetches the remap table for this house. *
- * HouseTypeClass::operator delete -- Returns a house type object back to the heap. *
- * HouseTypeClass::operator new -- Allocates a house type class object from special heap. *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "function.h"
- static HouseTypeClass const HouseEngland(
- HOUSE_ENGLAND,
- "England", // NAME: House name.
- TXT_ENGLAND, // FULLNAME: Translated house name.
- "ENG", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_GREEN, // Remap color ID number.
- 'E' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseGermany(
- HOUSE_GERMANY,
- "Germany", // NAME: House name.
- TXT_GERMANY, // FULLNAME: Translated house name.
- "GER", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_GREY, // Remap color ID number.
- 'G' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseFrance(
- HOUSE_FRANCE,
- "France", // NAME: House name.
- TXT_FRANCE, // FULLNAME: Translated house name.
- "FRA", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_BLUE, // Remap color ID number.
- 'F' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseUkraine(
- HOUSE_UKRAINE,
- "Ukraine", // NAME: House name.
- TXT_UKRAINE, // FULLNAME: Translated house name.
- "UKA", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_ORANGE, // Remap color ID number.
- 'K' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseUSSR(
- HOUSE_USSR,
- "USSR", // NAME: House name.
- TXT_USSR, // FULLNAME: Translated house name.
- "RED", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_RED, // Remap color ID number.
- 'U' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseGreece(
- HOUSE_GREECE,
- "Greece", // NAME: House name.
- TXT_GREECE, // FULLNAME: Translated house name.
- "GRE", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_LTBLUE, // Remap color ID number.
- 'G' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseTurkey(
- HOUSE_TURKEY,
- "Turkey", // NAME: House name.
- TXT_TURKEY, // FULLNAME: Translated house name.
- "TRK", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_BROWN, // Remap color ID number.
- 'T' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseSpain(
- HOUSE_SPAIN,
- "Spain", // NAME: House name.
- TXT_SPAIN, // FULLNAME: Translated house name.
- "SPN", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_GOLD, // Remap color ID number.
- 'S' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseGood(
- HOUSE_GOOD,
- "GoodGuy", // NAME: House name.
- TXT_GOODGUY, // FULLNAME: Translated house name.
- "GDI", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_LTBLUE, // Remap color ID number.
- 'G' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseBad(
- HOUSE_BAD,
- "BadGuy", // NAME: House name.
- TXT_BADGUY, // FULLNAME: Translated house name.
- "NOD", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_RED, // Remap color ID number.
- 'B' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseCivilian(
- HOUSE_NEUTRAL,
- "Neutral", // NAME: House name.
- TXT_CIVILIAN, // FULLNAME: Translated house name.
- "CIV", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_GOLD, // Remap color ID number.
- 'C' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseJP(
- HOUSE_JP,
- "Special", // NAME: House name.
- TXT_JP, // FULLNAME: Translated house name.
- "JP", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_GOLD, // Remap color ID number.
- 'J' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseMulti1(
- HOUSE_MULTI1,
- "Multi1", // NAME: House name.
- TXT_CIVILIAN, // FULLNAME: Translated house name.
- "MP1", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_GOLD, // Remap color ID number.
- 'M' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseMulti2(
- HOUSE_MULTI2,
- "Multi2", // NAME: House name.
- TXT_CIVILIAN, // FULLNAME: Translated house name.
- "MP2", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_LTBLUE, // Remap color ID number.
- 'M' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseMulti3(
- HOUSE_MULTI3,
- "Multi3", // NAME: House name.
- TXT_CIVILIAN, // FULLNAME: Translated house name.
- "MP3", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_RED, // Remap color ID number.
- 'M' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseMulti4(
- HOUSE_MULTI4,
- "Multi4", // NAME: House name.
- TXT_CIVILIAN, // FULLNAME: Translated house name.
- "MP4", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_GREEN, // Remap color ID number.
- 'M' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseMulti5(
- HOUSE_MULTI5,
- "Multi5", // NAME: House name.
- TXT_CIVILIAN, // FULLNAME: Translated house name.
- "MP5", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_ORANGE, // Remap color ID number.
- 'M' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseMulti6(
- HOUSE_MULTI6,
- "Multi6", // NAME: House name.
- TXT_CIVILIAN, // FULLNAME: Translated house name.
- "MP6", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_GREY, // Remap color ID number.
- 'M' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseMulti7(
- HOUSE_MULTI7,
- "Multi7", // NAME: House name.
- TXT_CIVILIAN, // FULLNAME: Translated house name.
- "MP7", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_BLUE, // Remap color ID number.
- 'M' // VOICE: Voice prefix character.
- );
- static HouseTypeClass const HouseMulti8(
- HOUSE_MULTI8,
- "Multi8", // NAME: House name.
- TXT_CIVILIAN, // FULLNAME: Translated house name.
- "MP8", // SUFFIX: House file suffix.
- 0, // LEMON: Lemon vehicle frequency.
- PCOLOR_BROWN, // Remap color ID number.
- 'M' // VOICE: Voice prefix character.
- );
- #ifdef OBSOLETE
- HouseTypeClass const * const HouseTypeClass::Pointers[HOUSE_COUNT] = {
- &HouseSpain,
- &HouseGreece,
- &HouseUSSR,
- &HouseEngland,
- &HouseUkraine,
- &HouseGermany,
- &HouseFrance,
- &HouseTurkey,
- &HouseGood,
- &HouseBad,
- &HouseCivilian,
- &HouseJP,
- &HouseMulti1,
- &HouseMulti2,
- &HouseMulti3,
- &HouseMulti4,
- &HouseMulti5,
- &HouseMulti6,
- &HouseMulti7,
- &HouseMulti8,
- };
- #endif
- /***********************************************************************************************
- * HouseTypeClass::HouseTypeClass -- Constructor for house type objects. *
- * *
- * This is the constructor for house type objects. This object holds the constant data *
- * for the house type. *
- * *
- * INPUT: see below... *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 06/21/1994 JLB : Created. *
- *=============================================================================================*/
- HouseTypeClass::HouseTypeClass(
- HousesType house,
- char const * ini,
- int fullname,
- char const * ext,
- int lemon,
- PlayerColorType remapcolor,
- char prefix) :
- AbstractTypeClass(RTTI_HOUSETYPE, house, fullname, ini),
- // RTTI(RTTI_HOUSETYPE),
- // ID(house),
- House(house),
- // IniName(ini),
- // FullName(fullname),
- Lemon(lemon),
- RemapColor(remapcolor),
- Prefix(prefix),
- FirepowerBias(1),
- GroundspeedBias(1),
- AirspeedBias(1),
- ArmorBias(1),
- ROFBias(1),
- CostBias(1),
- BuildSpeedBias(1)
- {
- strncpy(Suffix, ext, 3);
- Suffix[3] = '\0';
- }
- /***********************************************************************************************
- * HouseTypeClass::operator new -- Allocates a house type class object from special heap. *
- * *
- * This will allocate a house type object from the special heap that is used to maintain *
- * objects of this type. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns a pointer to the newly allocated house type object. *
- * *
- * WARNINGS: If there is insufficient room, this routine may return NULL. *
- * *
- * HISTORY: *
- * 09/04/1996 JLB : Created. *
- *=============================================================================================*/
- void * HouseTypeClass::operator new(size_t)
- {
- return(HouseTypes.Alloc());
- }
- /***********************************************************************************************
- * HouseTypeClass::operator delete -- Returns a house type object back to the heap. *
- * *
- * This will return the house type object specified back into the special heap that *
- * is used to maintain house type objects. *
- * *
- * INPUT: ptr -- Pointer to the house type object to delete. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/04/1996 JLB : Created. *
- *=============================================================================================*/
- void HouseTypeClass::operator delete(void * ptr)
- {
- HouseTypes.Free((HouseTypeClass *)ptr);
- }
- /***********************************************************************************************
- * HouseTypeClass::Init_Heap -- Allocate all heap objects for the house types. *
- * *
- * This will preallocate all the house types. They must be allocated in a particular order. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: This routine should be called only once at the beginning of the game. *
- * *
- * HISTORY: *
- * 09/04/1996 JLB : Created. *
- *=============================================================================================*/
- void HouseTypeClass::Init_Heap(void)
- {
- /*
- ** These house type class objects must be allocated in the exact order that they
- ** are specified in the HousesType enumeration. This is necessary because the heap
- ** allocation block index serves double duty as the type number index.
- */
- new HouseTypeClass(HouseSpain);
- new HouseTypeClass(HouseGreece);
- new HouseTypeClass(HouseUSSR);
- new HouseTypeClass(HouseEngland);
- new HouseTypeClass(HouseUkraine);
- new HouseTypeClass(HouseGermany);
- new HouseTypeClass(HouseFrance);
- new HouseTypeClass(HouseTurkey);
- new HouseTypeClass(HouseGood);
- new HouseTypeClass(HouseBad);
- new HouseTypeClass(HouseCivilian);
- new HouseTypeClass(HouseJP);
- new HouseTypeClass(HouseMulti1);
- new HouseTypeClass(HouseMulti2);
- new HouseTypeClass(HouseMulti3);
- new HouseTypeClass(HouseMulti4);
- new HouseTypeClass(HouseMulti5);
- new HouseTypeClass(HouseMulti6);
- new HouseTypeClass(HouseMulti7);
- new HouseTypeClass(HouseMulti8);
- }
- /***********************************************************************************************
- * HouseTypeClass::From_Name -- Fetch house pointer from its name. *
- * *
- * This routine will convert the ASCII house name specified into a *
- * real house number. Typically, this is used when processing a *
- * scenario INI file. *
- * *
- * INPUT: name -- ASCII name of house to process. *
- * *
- * OUTPUT: Returns with actual house number represented by the ASCII *
- * name specified. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 10/07/1992 JLB : Created. *
- * 05/21/1994 JLB : Converted to member function. *
- *=============================================================================================*/
- HousesType HouseTypeClass::From_Name(char const * name)
- {
- if (name != NULL) {
- for (HousesType house = HOUSE_FIRST; house < HOUSE_COUNT; house++) {
- if (stricmp(As_Reference(house).IniName, name) == 0) {
- // if (stricmp(Pointers[house]->IniName, name) == 0) {
- return(house);
- }
- }
- }
- return(HOUSE_NONE);
- }
- /***********************************************************************************************
- * HouseTypeClass::One_Time -- One-time initialization *
- * *
- * INPUT: none *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 05/21/1994 JLB : Converted to member function. *
- * 06/19/1996 JLB : Converted to regular heap class management. *
- *=============================================================================================*/
- void HouseTypeClass::One_Time(void)
- {
- }
- /***********************************************************************************************
- * HouseTypeClass::As_Reference -- Fetches a reference to the house specified. *
- * *
- * Use this routine to fetch a reference to the house number specified. *
- * *
- * INPUT: house -- The house number (HousesType) to look up. *
- * *
- * OUTPUT: Returns with a reference to the HouseTypeClass object that matches the house *
- * number specified. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 01/23/1995 JLB : Created. *
- *=============================================================================================*/
- HouseTypeClass & HouseTypeClass::As_Reference(HousesType house)
- {
- return(*HouseTypes.Ptr(house));
- }
- /***********************************************************************************************
- * HouseTypeClass::Remap_Table -- Fetches the remap table for this house. *
- * *
- * Use this routine to fetch the remap table assigned to this house. The remap table is *
- * what gives the house's units/buildings their distinctive color. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with a pointer to the remap table to use for this house. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 06/03/1996 JLB : Created. *
- *=============================================================================================*/
- unsigned char const * HouseTypeClass::Remap_Table(void) const
- {
- return(ColorRemaps[RemapColor].RemapTable);
- }
- /***********************************************************************************************
- * HouseTypeClass::Read_INI -- Fetch the house control values from ini database. *
- * *
- * This routine will fetch the rules controllable values for the house type from the *
- * INI database specified. *
- * *
- * INPUT: ini -- Reference to the INI database to fetch the house control values from. *
- * *
- * OUTPUT: bool; Was the house section found and processed? *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 09/04/1996 JLB : Created. *
- *=============================================================================================*/
- bool HouseTypeClass::Read_INI(CCINIClass & ini)
- {
- if (ini.Is_Present(Name())) {
- FirepowerBias = ini.Get_Fixed(Name(), "Firepower", FirepowerBias);
- GroundspeedBias = ini.Get_Fixed(Name(), "Groundspeed", GroundspeedBias);
- AirspeedBias = ini.Get_Fixed(Name(), "Airspeed", AirspeedBias);
- ArmorBias = ini.Get_Fixed(Name(), "Armor", ArmorBias);
- ROFBias = ini.Get_Fixed(Name(), "ROF", ROFBias);
- CostBias = ini.Get_Fixed(Name(), "Cost", CostBias);
- BuildSpeedBias = ini.Get_Fixed(Name(), "BuildTime", BuildSpeedBias);
- return(true);
- }
- return(false);
- }
|