CnC_Remastered_Collection

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

BBDATA.CPP (18305B)


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