CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

HDATA.CPP (15998B)


      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:   F:\projects\c&c\vcs\code\hdata.cpv   2.17   16 Oct 1995 16:48:18   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 : January 23, 1995 [JLB]                                       *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  *   HouseTypeClass::From_Name -- Fetch house pointer from its name.                           *
     34  *   HouseTypeClass::As_Reference -- Fetches a reference to the house specified.               * 
     35  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     36 
     37 #include	"function.h"
     38 
     39 /*
     40 **	These are the colors used to identify the various owners.
     41 */
     42 const int COLOR_GOOD = 180;  // GOLD
     43 const int COLOR_BRIGHT_GOOD = 176;  // GOLD
     44 const int COLOR_BAD = 123;	//RED;
     45 const int COLOR_BRIGHT_BAD = 127;	//RED;
     46 const int COLOR_NEUTRAL = 205;	//WHITE;
     47 const int COLOR_BRIGHT_NEUTRAL = 202;	//WHITE;
     48 
     49 
     50 static HouseTypeClass const HouseGood(
     51 	HOUSE_GOOD,
     52 	"GoodGuy",					//	NAME:			House name.
     53 	TXT_GDI,						// FULLNAME:	Translated house name.
     54 	"GDI",						// SUFFIX:		House file suffix.
     55 	0,								// LEMON:		Lemon vehicle frequency.
     56 	COLOR_GOOD,					// COLOR:		Dark Radar map color.
     57 	COLOR_BRIGHT_GOOD,		// COLOR:		Bright Radar map color.
     58 	REMAP_GOLD,				// Remap color ID number.
     59 	RemapGold,				// Default remap table.
     60 	'G'							// VOICE:		Voice prefix character.
     61 );
     62 
     63 static HouseTypeClass const HouseBad(
     64 	HOUSE_BAD,
     65 	"BadGuy",					//	NAME:			House name.
     66 	TXT_NOD,						// FULLNAME:	Translated house name.
     67 	"NOD",						// SUFFIX:		House file suffix.
     68 	0,								// LEMON:		Lemon vehicle frequency.
     69 	COLOR_BAD,					// COLOR:		Dark Radar map color.
     70 	COLOR_BRIGHT_BAD,			// COLOR:		Bright Radar map color.
     71 	REMAP_LTBLUE,				// Remap color ID number.
     72 	RemapLtBlue,				// Default remap table.
     73 	'B'							// VOICE:		Voice prefix character.
     74 );
     75 
     76 static HouseTypeClass const HouseCivilian(
     77 	HOUSE_NEUTRAL,
     78 	"Neutral",					//	NAME:			House name.
     79 	TXT_CIVILIAN,				// FULLNAME:	Translated house name.
     80 	"CIV",						// SUFFIX:		House file suffix.
     81 	0,								// LEMON:		Lemon vehicle frequency.
     82 	COLOR_NEUTRAL,				// COLOR:		Dark Radar map color.
     83 	COLOR_BRIGHT_NEUTRAL,	// COLOR:		Bright Radar map color.
     84 	REMAP_GOLD,				// Remap color ID number.
     85 	RemapNone,					// Default remap table.
     86 	'C'							// VOICE:		Voice prefix character.
     87 );
     88 
     89 static HouseTypeClass const HouseJP(
     90 	HOUSE_JP,
     91 	"Special",					//	NAME:			House name.
     92 	TXT_JP,						// FULLNAME:	Translated house name.
     93 	"JP",							// SUFFIX:		House file suffix.
     94 	0,								// LEMON:		Lemon vehicle frequency.
     95 	COLOR_NEUTRAL,				// COLOR:		Dark Radar map color.
     96 	COLOR_BRIGHT_NEUTRAL,	// COLOR:		Bright Radar map color.
     97 	REMAP_GOLD,				// Remap color ID number.
     98 	RemapNone,					// Default remap table.
     99 	'J'							// VOICE:		Voice prefix character.
    100 );
    101 
    102 static HouseTypeClass const HouseMulti1(
    103 	HOUSE_MULTI1,
    104 	"Multi1",					//	NAME:			House name.
    105 	TXT_CIVILIAN,				// FULLNAME:	Translated house name.
    106 	"MP1",						// SUFFIX:		House file suffix.
    107 	0,								// LEMON:		Lemon vehicle frequency.
    108 	COLOR_NEUTRAL,				// COLOR:		Radar map color.
    109 	COLOR_BRIGHT_NEUTRAL,	// COLOR:		Bright Radar map color.
    110 	REMAP_LTBLUE,					// Remap color ID number.
    111 	RemapLtBlue,			// Default remap table.
    112 	'M'							// VOICE:		Voice prefix character.
    113 );
    114 
    115 static HouseTypeClass const HouseMulti2(
    116 	HOUSE_MULTI2,
    117 	"Multi2",					//	NAME:			House name.
    118 	TXT_CIVILIAN,				// FULLNAME:	Translated house name.
    119 	"MP2",						// SUFFIX:		House file suffix.
    120 	0,								// LEMON:		Lemon vehicle frequency.
    121 	COLOR_NEUTRAL,				// COLOR:		Radar map color.
    122 	COLOR_BRIGHT_NEUTRAL,	// COLOR:		Bright Radar map color.
    123 	REMAP_ORANGE,				// Remap color ID number.
    124 	RemapOrange,				// Default remap table.
    125 	'M'							// VOICE:		Voice prefix character.
    126 );
    127 
    128 static HouseTypeClass const HouseMulti3(
    129 	HOUSE_MULTI3,
    130 	"Multi3",					//	NAME:			House name.
    131 	TXT_CIVILIAN,				// FULLNAME:	Translated house name.
    132 	"MP3",						// SUFFIX:		House file suffix.
    133 	0,								// LEMON:		Lemon vehicle frequency.
    134 	COLOR_NEUTRAL,				// COLOR:		Radar map color.
    135 	COLOR_BRIGHT_NEUTRAL,	// COLOR:		Bright Radar map color.
    136 	REMAP_GREEN,				// Remap color ID number.
    137 	RemapGreen,					// Default remap table.
    138 	'M'							// VOICE:		Voice prefix character.
    139 );
    140 
    141 static HouseTypeClass const HouseMulti4(
    142 	HOUSE_MULTI4,
    143 	"Multi4",					//	NAME:			House name.
    144 	TXT_CIVILIAN,				// FULLNAME:	Translated house name.
    145 	"MP4",						// SUFFIX:		House file suffix.
    146 	0,								// LEMON:		Lemon vehicle frequency.
    147 	COLOR_NEUTRAL,				// COLOR:		Radar map color.
    148 	COLOR_BRIGHT_NEUTRAL,	// COLOR:		Bright Radar map color.
    149 	REMAP_BLUE,					// Remap color ID number.
    150 	RemapBlue,					// Default remap table.
    151 	'M'							// VOICE:		Voice prefix character.
    152 );
    153 
    154 static HouseTypeClass const HouseMulti5(
    155 	HOUSE_MULTI5,
    156 	"Multi5",					//	NAME:			House name.
    157 	TXT_CIVILIAN,				// FULLNAME:	Translated house name.
    158 	"MP5",						// SUFFIX:		House file suffix.
    159 	0,								// LEMON:		Lemon vehicle frequency.
    160 	COLOR_NEUTRAL,				// COLOR:		Radar map color.
    161 	COLOR_BRIGHT_NEUTRAL,	// COLOR:		Bright Radar map color.
    162 	REMAP_GOLD,				// Remap color ID number.
    163 	RemapGold,				// Default remap table.
    164 	'M'							// VOICE:		Voice prefix character.
    165 );
    166 
    167 static HouseTypeClass const HouseMulti6(
    168 	HOUSE_MULTI6,
    169 	"Multi6",					//	NAME:			House name.
    170 	TXT_CIVILIAN,				// FULLNAME:	Translated house name.
    171 	"MP6",						// SUFFIX:		House file suffix.
    172 	0,								// LEMON:		Lemon vehicle frequency.
    173 	COLOR_NEUTRAL,				// COLOR:		Radar map color.
    174 	COLOR_BRIGHT_NEUTRAL,	// COLOR:		Bright Radar map color.
    175 	REMAP_RED,					// Remap color ID number.
    176 	RemapRed,					// Default remap table.
    177 	'M'							// VOICE:		Voice prefix character.
    178 );
    179 
    180 HouseTypeClass const * const HouseTypeClass::Pointers[HOUSE_COUNT] = {
    181 	&HouseGood,
    182 	&HouseBad,
    183 	&HouseCivilian,
    184 	&HouseJP,
    185 	&HouseMulti1,
    186 	&HouseMulti2,
    187 	&HouseMulti3,
    188 	&HouseMulti4,
    189 	&HouseMulti5,
    190 	&HouseMulti6,
    191 };
    192 
    193 
    194 /***********************************************************************************************
    195  * HouseTypeClass::HouseTypeClass -- Constructor for house type objects.                       *
    196  *                                                                                             *
    197  *    This is the constructor for house type objects. This object holds the constant data      *
    198  *    for the house type.                                                                      *
    199  *                                                                                             *
    200  * INPUT:   house    -- The ID number for this house type.                                     *
    201  *          ini      -- The INI name of this house.                                            *
    202  *          fullname -- The text number representing the complete name of the house.           *
    203  *          ext      -- The filename extension used when loading data files.                   *
    204  *          lemon    -- The percentage for objects of this ownership to be lemon.              *
    205  *          remapc   -- The remap color number to use.                                         *
    206  *          color    -- The radar color to use for this "house".                               *
    207  *          prefix   -- A unique prefix letter used when building custom filenames.            *
    208  *                                                                                             *
    209  * OUTPUT:  none                                                                               *
    210  *                                                                                             *
    211  * WARNINGS:   none                                                                            *
    212  *                                                                                             *
    213  * HISTORY:                                                                                    *
    214  *   06/21/1994 JLB : Created.                                                                 *
    215  *=============================================================================================*/
    216 HouseTypeClass::HouseTypeClass(HousesType house, 
    217 				char const * ini, 
    218 				int fullname, 
    219 				char const * ext, 
    220 				int lemon, 
    221 				int color, 
    222 				int bright_color, 
    223 				PlayerColorType remapcolor,
    224 				unsigned char const * remap, 
    225 				char prefix)
    226 {
    227 	RemapTable = remap;
    228 	RemapColor = remapcolor;
    229 	House = house;
    230 	IniName = ini;
    231 	FullName = fullname;
    232 	strncpy(Suffix, ext, 3);
    233 	Suffix[3] = '\0';
    234 	Lemon = lemon;
    235 	Color = color;
    236 	BrightColor = bright_color;
    237 	Prefix = prefix;
    238 	FirepowerBias = 1;
    239 	GroundspeedBias = 1;
    240 	AirspeedBias = 1;
    241 	ArmorBias = 1;
    242 	ROFBias = 1;
    243 	CostBias = 1;
    244 	BuildSpeedBias = 1;
    245 }
    246 
    247 
    248 /***********************************************************************************************
    249  * HouseTypeClass::From_Name -- Fetch house pointer from its name.                             *
    250  *                                                                                             *
    251  *    This routine will convert the ASCII house name specified into a                          *
    252  *    real house number. Typically, this is used when processing a                             *
    253  *    scenario INI file.                                                                       *
    254  *                                                                                             *
    255  * INPUT:   name  -- ASCII name of house to process.                                           *
    256  *                                                                                             *
    257  * OUTPUT:  Returns with actual house number represented by the ASCII                          *
    258  *          name specified.                                                                    *
    259  *                                                                                             *
    260  * WARNINGS:   none                                                                            *
    261  *                                                                                             *
    262  * HISTORY:                                                                                    *
    263  *   10/07/1992 JLB : Created.                                                                 *
    264  *   05/21/1994 JLB : Converted to member function.                                            *
    265  *=============================================================================================*/
    266 HousesType HouseTypeClass::From_Name(char const *name)
    267 {
    268 	if (name) {
    269 		for (HousesType house = HOUSE_FIRST; house < HOUSE_COUNT; house++) {
    270 			if (stricmp(Pointers[house]->IniName, name) == 0) {
    271 				return(house);
    272 			}
    273 		}
    274 	}
    275 	return(HOUSE_NONE);
    276 }
    277 
    278 
    279 /***********************************************************************************************
    280  * HouseTypeClass::One_Time -- One-time initialization                                         *
    281  *                                                                                             *
    282  * INPUT:   none                                                                               *
    283  *                                                                                             *
    284  * OUTPUT:  none                                                                               *
    285  *                                                                                             *
    286  * WARNINGS:   none                                                                            *
    287  *                                                                                             *
    288  * HISTORY:                                                                                    *
    289  *   05/21/1994 JLB : Converted to member function.                                            *
    290  *=============================================================================================*/
    291 void HouseTypeClass::One_Time(void)
    292 {
    293 	/*
    294 	** Change the radar color for special units; otherwise, they'll be the same
    295 	** color as the player!
    296 	*/
    297 	//if (Special.IsJurassic && AreThingiesEnabled) {			// Assume funpark mode might be required. ST - 10/14/2019 11:53AM
    298 		((unsigned char &)HouseJP.Color) = (unsigned char)COLOR_BAD;
    299 		((unsigned char &)HouseJP.BrightColor) = (unsigned char)COLOR_BRIGHT_BAD;
    300 	//}
    301 }
    302 
    303 
    304 /*********************************************************************************************** 
    305  * HouseTypeClass::As_Reference -- Fetches a reference to the house specified.                 * 
    306  *                                                                                             * 
    307  *    Use this routine to fetch a reference to the house number specified.                     * 
    308  *                                                                                             * 
    309  * INPUT:   house -- The house number (HousesType) to look up.                                 * 
    310  *                                                                                             * 
    311  * OUTPUT:  Returns with a reference to the HouseTypeClass object that matches the house       * 
    312  *          number specified.                                                                  * 
    313  *                                                                                             * 
    314  * WARNINGS:   none                                                                            * 
    315  *                                                                                             * 
    316  * HISTORY:                                                                                    * 
    317  *   01/23/1995 JLB : Created.                                                                 * 
    318  *=============================================================================================*/
    319 HouseTypeClass const & HouseTypeClass::As_Reference(HousesType house) 
    320 {
    321 	return(*Pointers[house]);
    322 }