CnC_Remastered_Collection

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

VDATA.CPP (41463B)


      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/VDATA.CPP 1     3/03/97 10:26a 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 : VDATA.CPP                                                    *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 03/13/96                                                     *
     28  *                                                                                             *
     29  *                  Last Update : July 9, 1996 [JLB]                                           *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  *   VesselTypeClass::As_Reference -- Converts a vessel type into a VesselTypeClass reference. *
     34  *   VesselTypeClass::Create_And_Place -- Creates a vessel and places it at location.          *
     35  *   VesselTypeClass::Create_One_Of -- Creates a vessel object that matches this vessel type.  *
     36  *   VesselTypeClass::Dimensions -- Fetches the pixel width and height of this vessel type.    *
     37  *   VesselTypeClass::Display -- Displays a generic representation of this vessel type.        *
     38  *   VesselTypeClass::From_Name -- Converts a name into a vessel type.                         *
     39  *   VesselTypeClass::Init_Heap -- Initialize the vessel heap.                                 *
     40  *   VesselTypeClass::One_Time -- Performs one time initialization for vessel types.           *
     41  *   VesselTypeClass::Overlap_List -- Figures the overlap list for the vessel type.            *
     42  *   VesselTypeClass::Prep_For_Add -- Adds vessel types to the scenario editor object list.    *
     43  *   VesselTypeClass::Turret_Adjust -- Adjust turret offset according to facing specified.     *
     44  *   VesselTypeClass::VesselTypeClass -- Constructor for naval vessel types.                   *
     45  *   VesselTypeClass::Who_Can_Build_Me -- Fetches pointer to available factory for this vessel.*
     46  *   VesselTypeClass::operator delete -- Returns a vessel type object back to the memory pool. *
     47  *   VesselTypeClass::operator new -- Allocate a vessel type object from the special memory poo*
     48  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     49 
     50 
     51 #include "function.h"
     52 
     53 
     54 // Submarine
     55 static VesselTypeClass const VesselSubmarine(
     56 	VESSEL_SS,
     57 	TXT_SS,					// NAME:			Text name of this unit type.
     58 	"SS",						// NAME:			Text name of this unit type.
     59 	ANIM_FBALL1,			// EXPLOSION:	Type of explosion when destroyed.
     60 	0x0000,					//	Vertical offset.
     61 	0x0000,					// Primary weapon offset along turret centerline.
     62 	0x0000,					// Primary weapon lateral offset along turret centerline.
     63 	0x0000,					// Secondary weapon offset along turret centerline.
     64 	0x0000,					// Secondary weapon lateral offset along turret centerling.
     65 		false,				// Only has eight facings?
     66 		true,					// Always use the given name for the vehicle?
     67 		false,				// Is it equipped with a combat turret?
     68 	8,							// Rotation stages.
     69 	14							// Turret center offset along body centerline.
     70 );
     71 
     72 // Destroyer
     73 static VesselTypeClass const VesselDestroyer(
     74 	VESSEL_DD,
     75 	TXT_DD,					// NAME:			Text name of this unit type.
     76 	"DD",						// NAME:			Text name of this unit type.
     77 	ANIM_FBALL1,			// EXPLOSION:	Type of explosion when destroyed.
     78 	0x0000,					//	Vertical offset.
     79 	0x0000,					// Primary weapon offset along turret centerline.
     80 	0x0000,					// Primary weapon lateral offset along turret centerline.
     81 	0x0000,					// Secondary weapon offset along turret centerline.
     82 	0x0000,					// Secondary weapon lateral offset along turret centerling.
     83 		false,				// Only has eight facings?
     84 		true,					// Always use the given name for the vehicle?
     85 		true,					// Is it equipped with a combat turret?
     86 	8,							// Rotation stages.
     87 	14							// Turret center offset along body centerline.
     88 );
     89 
     90 // Cruiser
     91 static VesselTypeClass const VesselCruiser(
     92 	VESSEL_CA,
     93 	TXT_CA,					// NAME:			Text name of this unit type.
     94 	"CA",						// NAME:			Text name of this unit type.
     95 	ANIM_FBALL1,			// EXPLOSION:	Type of explosion when destroyed.
     96 	0x0000,					//	Vertical offset.
     97 	0x0000,					// Primary weapon offset along turret centerline.
     98 	0x0000,					// Primary weapon lateral offset along turret centerline.
     99 	0x0000,					// Secondary weapon offset along turret centerline.
    100 	0x0000,					// Secondary weapon lateral offset along turret centerling.
    101 		false,				// Only has eight facings?
    102 		true,					// Always use the given name for the vehicle?
    103 		true,					// Is it equipped with a combat turret?
    104 	8,							// Rotation stages.
    105 	14							// Turret center offset along body centerline.
    106 );
    107 
    108 // Transport
    109 static VesselTypeClass const VesselTransport(
    110 	VESSEL_TRANSPORT,
    111 	TXT_TRANSPORT,			// NAME:			Text name of this unit type.
    112 	"LST",					// NAME:			Text name of this unit type.
    113 	ANIM_FBALL1,			// EXPLOSION:	Type of explosion when destroyed.
    114 	0x0000,					//	Vertical offset.
    115 	0x0000,					// Primary weapon offset along turret centerline.
    116 	0x0000,					// Primary weapon lateral offset along turret centerline.
    117 	0x0000,					// Secondary weapon offset along turret centerline.
    118 	0x0000,					// Secondary weapon lateral offset along turret centerling.
    119 		false,				// Only has eight facings?
    120 		true,					// Always use the given name for the vehicle?
    121 		false,				// Is it equipped with a combat turret?
    122 	0,							// Rotation stages.
    123 	0							// Turret center offset along body centerline.
    124 );
    125 
    126 // Gun Boat
    127 static VesselTypeClass const VesselPTBoat(
    128 	VESSEL_PT,
    129 	TXT_PT,					// NAME:			Text name of this unit type.
    130 	"PT",						// NAME:			Text name of this unit type.
    131 	ANIM_FBALL1,			// EXPLOSION:	Type of explosion when destroyed.
    132 	0x0000,					//	Vertical offset.
    133 	0x0000,					// Primary weapon offset along turret centerline.
    134 	0x0000,					// Primary weapon lateral offset along turret centerline.
    135 	0x0000,					// Secondary weapon offset along turret centerline.
    136 	0x0000,					// Secondary weapon lateral offset along turret centerling.
    137 		false,				// Only has eight facings?
    138 		true,					// Always use the given name for the vehicle?
    139 		true,					// Is it equipped with a combat turret?
    140 	8,							// Rotation stages.
    141 	14							// Turret center offset along body centerline.
    142 );
    143 
    144 
    145 #ifdef FIXIT_CSII	//	checked - ajw 9/28/98
    146 // Missile Submarine
    147 static VesselTypeClass const VesselMissileSubmarine(
    148 	VESSEL_MISSILESUB,
    149 	TXT_MISSILESUB,		// NAME:			Text name of this unit type.
    150 	"MSUB",					// NAME:			Text name of this unit type.
    151 	ANIM_FBALL1,			// EXPLOSION:	Type of explosion when destroyed.
    152 	0x0000,					//	Vertical offset.
    153 	0x0000,					// Primary weapon offset along turret centerline.
    154 	0x0000,					// Primary weapon lateral offset along turret centerline.
    155 	0x0000,					// Secondary weapon offset along turret centerline.
    156 	0x0000,					// Secondary weapon lateral offset along turret centerling.
    157 		false,				// Only has eight facings?
    158 		true,					// Always use the given name for the vehicle?
    159 		false,				// Is it equipped with a combat turret?
    160 	8,							// Rotation stages.
    161 	14							// Turret center offset along body centerline.
    162 );
    163 #endif
    164 
    165 #ifdef FIXIT_CARRIER	//	checked - ajw 9/28/98
    166 // Transport
    167 static VesselTypeClass const VesselCarrier(
    168 	VESSEL_CARRIER,
    169 	TXT_CARRIER,			// NAME:			Text name of this unit type.
    170 	"CARR",					// NAME:			Text name of this unit type.
    171 	ANIM_FBALL1,			// EXPLOSION:	Type of explosion when destroyed.
    172 	0x0000,					//	Vertical offset.
    173 	0x0000,					// Primary weapon offset along turret centerline.
    174 	0x0000,					// Primary weapon lateral offset along turret centerline.
    175 	0x0000,					// Secondary weapon offset along turret centerline.
    176 	0x0000,					// Secondary weapon lateral offset along turret centerling.
    177 		false,				// Only has eight facings?
    178 		true,					// Always use the given name for the vehicle?
    179 		false,				// Is it equipped with a combat turret?
    180 	0,							// Rotation stages.
    181 	0							// Turret center offset along body centerline.
    182 );
    183 #endif
    184 
    185 /***********************************************************************************************
    186  * VesselTypeClass::VesselTypeClass -- Constructor for unit types.                             *
    187  *                                                                                             *
    188  *    This is the constructor for the vessel static data. Each vessels is assign a specific    *
    189  *    variation. This class elaborates what the variation actually is.                         *
    190  *                                                                                             *
    191  * INPUT:   bla bla bla... see below                                                           *
    192  *                                                                                             *
    193  * OUTPUT:  none                                                                               *
    194  *                                                                                             *
    195  * WARNINGS:   none                                                                            *
    196  *                                                                                             *
    197  * HISTORY:                                                                                    *
    198  *   03/14/1996 JLB : Created                                                                  *
    199  *=============================================================================================*/
    200 VesselTypeClass::VesselTypeClass(
    201 				VesselType type,
    202 				int name,
    203 				char const * ininame,
    204 				AnimType exp,
    205 				int verticaloffset,
    206 				int primaryoffset,
    207 				int primarylateral,
    208 				int secondaryoffset,
    209 				int secondarylateral,
    210 				bool is_eight,
    211 				bool is_nominal,
    212 				bool is_turret_equipped,
    213 				int rotation,
    214 				int toffset
    215 				) :
    216 					TechnoTypeClass(
    217 										RTTI_VESSELTYPE,
    218 										int(type),
    219 										name,
    220 										ininame,
    221 										REMAP_NORMAL,
    222 										verticaloffset,
    223 										primaryoffset,
    224 										primarylateral,
    225 										secondaryoffset,
    226 										secondarylateral,
    227 										is_nominal,
    228 										false,
    229 										true,
    230 										true,
    231 										false,
    232 										false,
    233 										false,
    234 										is_turret_equipped,
    235 										true,
    236 										true,
    237 										rotation,
    238 										SPEED_FLOAT
    239 										),
    240 	IsPieceOfEight(is_eight),
    241 	Type(type),
    242 	TurretOffset(toffset),
    243 	Mission(MISSION_GUARD),
    244 	Explosion(exp),
    245 	MaxSize(0)
    246 {
    247 	/*
    248 	**	Forced vessel overrides from the default.
    249 	*/
    250 	IsCrew = false;
    251 	Speed = SPEED_FLOAT;
    252 	IsScanner = true;
    253 }
    254 
    255 
    256 /***********************************************************************************************
    257  * VesselTypeClass::operator new -- Allocate a vessel type object from the special memory pool *
    258  *                                                                                             *
    259  *    This will allocate a vessel type class object from the memory pool.                      *
    260  *                                                                                             *
    261  * INPUT:   none                                                                               *
    262  *                                                                                             *
    263  * OUTPUT:  Returns with a pointer to the allocated vessel type class object. If memory in the *
    264  *          special heap has been exhaused, then NULL will be returned.                        *
    265  *                                                                                             *
    266  * WARNINGS:   none                                                                            *
    267  *                                                                                             *
    268  * HISTORY:                                                                                    *
    269  *   07/09/1996 JLB : Created.                                                                 *
    270  *=============================================================================================*/
    271 void * VesselTypeClass::operator new(size_t)
    272 {
    273 	return(VesselTypes.Alloc());
    274 }
    275 
    276 
    277 /***********************************************************************************************
    278  * VesselTypeClass::operator delete -- Returns a vessel type object back to the memory pool.   *
    279  *                                                                                             *
    280  *    This will return a previously allocated vessel object back to the special pool from      *
    281  *    whence it was originally allocated.                                                      *
    282  *                                                                                             *
    283  * INPUT:   pointer  -- Pointer to the vessel type object to return to the pool.               *
    284  *                                                                                             *
    285  * OUTPUT:  none                                                                               *
    286  *                                                                                             *
    287  * WARNINGS:   none                                                                            *
    288  *                                                                                             *
    289  * HISTORY:                                                                                    *
    290  *   07/09/1996 JLB : Created.                                                                 *
    291  *=============================================================================================*/
    292 void VesselTypeClass::operator delete(void * pointer)
    293 {
    294 	VesselTypes.Free((VesselTypeClass *)pointer);
    295 }
    296 
    297 
    298 /***********************************************************************************************
    299  * VesselTypeClass::Init_Heap -- Initialize the vessel heap.                                   *
    300  *                                                                                             *
    301  *    This will pre-allocate all the vessel types required.                                    *
    302  *                                                                                             *
    303  * INPUT:   none                                                                               *
    304  *                                                                                             *
    305  * OUTPUT:  none                                                                               *
    306  *                                                                                             *
    307  * WARNINGS:   Only call this routine once and do so before processing the rules.ini file.     *
    308  *                                                                                             *
    309  * HISTORY:                                                                                    *
    310  *   07/09/1996 JLB : Created.                                                                 *
    311  *=============================================================================================*/
    312 void VesselTypeClass::Init_Heap(void)
    313 {
    314 	/*
    315 	**	These vessel type class objects must be allocated in the exact order that they
    316 	**	are specified in the VesselType enumeration. This is necessary because the heap
    317 	**	allocation block index serves double duty as the type number index.
    318 	*/
    319 	new VesselTypeClass(VesselSubmarine);				//	VESSEL_SS
    320 	new VesselTypeClass(VesselDestroyer);				//	VESSEL_DD
    321 	new VesselTypeClass(VesselCruiser);					// VESSEL_CA
    322 	new VesselTypeClass(VesselTransport);				// VESSEL_TRANSPORT
    323 	new VesselTypeClass(VesselPTBoat);					// VESSEL_PT
    324 #ifdef FIXIT_CSII	//	checked - ajw 9/28/98
    325 	new VesselTypeClass(VesselMissileSubmarine);		// VESSEL_MISSILESUB
    326 #endif
    327 #ifdef FIXIT_CARRIER	//	checked - ajw 9/28/98
    328 	new VesselTypeClass(VesselCarrier);					// VESSEL_CARRIER
    329 #endif
    330 }
    331 
    332 
    333 /***********************************************************************************************
    334  * VesselTypeClass::As_Reference -- Converts a vessel type into a VesselTypeClass reference.   *
    335  *                                                                                             *
    336  *    This routine will fetch a reference to the vessel type that corresponds to the vessel    *
    337  *    type specified.                                                                          *
    338  *                                                                                             *
    339  * INPUT:   type  -- The vessel type number to convert.                                        *
    340  *                                                                                             *
    341  * OUTPUT:  Returns with a reference to the vessel type class that corresponds to the vessel   *
    342  *          type specified.                                                                    *
    343  *                                                                                             *
    344  * WARNINGS:   none                                                                            *
    345  *                                                                                             *
    346  * HISTORY:                                                                                    *
    347  *   03/20/1996 JLB : Created.                                                                 *
    348  *=============================================================================================*/
    349 VesselTypeClass & VesselTypeClass::As_Reference(VesselType type)
    350 {
    351 	return(*VesselTypes.Ptr(type));
    352 }
    353 
    354 
    355 #ifdef NEVER
    356 /***********************************************************************************************
    357  * VesselTypeClass::Who_Can_Build_Me -- Fetches pointer to available factory for this vessel.  *
    358  *                                                                                             *
    359  *    Use this routine to fetch a pointer to the vessel factory that can build this vessel     *
    360  *    type.                                                                                    *
    361  *                                                                                             *
    362  * INPUT:   intheory -- If true, then this indicates that if the factory is currently          *
    363  *                      busy doing other things, this won't make in ineligible for searching. *
    364  *                      Typical use of this is by the sidebar logic which needs only to know   *
    365  *                      if theoretical production is allowed.                                  *
    366  *                                                                                             *
    367  *          legal    -- If true, then the buildings are checked for specific legality when     *
    368  *                      being scanned. For building placement, this is usually false, for      *
    369  *                      sidebar button adding, this is usually true.                           *
    370  *                                                                                             *
    371  *          house    -- The owner of the unit to be produced. This has an effect of legality.  *
    372  *                                                                                             *
    373  * OUTPUT:  Returns with a pointer to the factory (building) that can produce this vessel type.*
    374  *                                                                                             *
    375  * WARNINGS:   none                                                                            *
    376  *                                                                                             *
    377  * HISTORY:                                                                                    *
    378  *   03/20/1996 JLB : Created.                                                                 *
    379  *=============================================================================================*/
    380 BuildingClass * VesselTypeClass::Who_Can_Build_Me(bool intheory, bool legal, HousesType house) const
    381 {
    382 	BuildingClass * anybuilding = NULL;
    383 
    384 	for (int index = 0; index < Buildings.Count(); index++) {
    385 		BuildingClass * building = Buildings.Ptr(index);
    386 		assert(building != NULL);
    387 
    388 		if (	!building->IsInLimbo &&
    389 				building->House->Class->House == house &&
    390 				building->Class->ToBuild == RTTI_VESSELTYPE &&
    391 				building->Mission != MISSION_DECONSTRUCTION &&
    392 				((1L << building->ActLike) & Ownable) &&
    393 				(!legal || building->House->Can_Build(Type, building->ActLike)) &&
    394 				(intheory || !building->In_Radio_Contact())) {
    395 
    396 			if (building->IsLeader) return(building);
    397 			anybuilding = building;
    398 		}
    399 	}
    400 	return(anybuilding);
    401 }
    402 #endif
    403 
    404 
    405 /***********************************************************************************************
    406  * VesselTypeClass::Display -- Displays a generic representation of this vessel type.          *
    407  *                                                                                             *
    408  *    This routine is used by the scenario editor to display a representation of this          *
    409  *    vessel type in the object placement dialog.                                              *
    410  *                                                                                             *
    411  * INPUT:   x,y      -- Pixel coordinate to render the center of this vessel type to.          *
    412  *                                                                                             *
    413  *          window   -- The window to clip the shape to. The pixel coordinates are relative    *
    414  *                      to this window.                                                        *
    415  *                                                                                             *
    416  *          house    -- The owner of the vessel. This is used to give the vessel its color.    *
    417  *                                                                                             *
    418  * OUTPUT:  none                                                                               *
    419  *                                                                                             *
    420  * WARNINGS:   none                                                                            *
    421  *                                                                                             *
    422  * HISTORY:                                                                                    *
    423  *   03/20/1996 JLB : Created.                                                                 *
    424  *=============================================================================================*/
    425 #ifdef SCENARIO_EDITOR
    426 void VesselTypeClass::Display(int x, int y, WindowNumberType window, HousesType ) const
    427 {
    428 	int shape = 0;
    429 	void const * ptr = Get_Cameo_Data();
    430 	if (ptr == NULL) {
    431 		ptr = Get_Image_Data();
    432 		shape = Rotation/6;
    433 	}
    434 	CC_Draw_Shape(ptr, shape, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL);
    435 }
    436 
    437 
    438 /***********************************************************************************************
    439  * VesselTypeClass::Prep_For_Add -- Adds vessel types to the scenario editor object list.      *
    440  *                                                                                             *
    441  *    This routine is called when the scenario editor needs to obtain a list of the            *
    442  *    vessel object that can be placed down. It will submit all the vessel types that can      *
    443  *    be placed down.                                                                          *
    444  *                                                                                             *
    445  * INPUT:   none                                                                               *
    446  *                                                                                             *
    447  * OUTPUT:  none                                                                               *
    448  *                                                                                             *
    449  * WARNINGS:   none                                                                            *
    450  *                                                                                             *
    451  * HISTORY:                                                                                    *
    452  *   03/20/1996 JLB : Created.                                                                 *
    453  *=============================================================================================*/
    454 void VesselTypeClass::Prep_For_Add(void)
    455 {
    456 	for (VesselType index = VESSEL_FIRST; index < VESSEL_COUNT; index++) {
    457 		if (As_Reference(index).Get_Image_Data() != NULL) {
    458 			Map.Add_To_List(&As_Reference(index));
    459 		}
    460 	}
    461 }
    462 #endif	//SCENARIO_EDITOR
    463 
    464 
    465 /***********************************************************************************************
    466  * VesselTypeClass::Create_One_Of -- Creates a vessel object that matches this vessel type.    *
    467  *                                                                                             *
    468  *    This routine is called when the type of vessel is known (by way of a VesselTypeClass)    *
    469  *    and a corresponding vessel object needs to be created.                                   *
    470  *                                                                                             *
    471  * INPUT:   house -- Pointer to the owner that this vessel will be assigned to.                *
    472  *                                                                                             *
    473  * OUTPUT:  Returns with a pointer to the vessel object created. If no vessel could be         *
    474  *          created, then NULL is returned.                                                    *
    475  *                                                                                             *
    476  * WARNINGS:   The vessel is created in a limbo state. It must first be placed down upon       *
    477  *             the map before it starts to function.                                           *
    478  *                                                                                             *
    479  * HISTORY:                                                                                    *
    480  *   03/20/1996 JLB : Created.                                                                 *
    481  *=============================================================================================*/
    482 ObjectClass * VesselTypeClass::Create_One_Of(HouseClass * house) const
    483 {
    484 	return(new VesselClass(Type, house->Class->House));
    485 }
    486 
    487 
    488 /***********************************************************************************************
    489  * VesselTypeClass::Create_And_Place -- Creates a vessel and places it at location.            *
    490  *                                                                                             *
    491  *    This routine is used to create a vessel and then place it down upon the                  *
    492  *    map.                                                                                     *
    493  *                                                                                             *
    494  * INPUT:   cell  -- The location to place this vessel down upon.                              *
    495  *                                                                                             *
    496  *          house -- The house to assign this vessel's ownership to.                           *
    497  *                                                                                             *
    498  * OUTPUT:  bool; Was the vessel successfully created and placed down upon the map?            *
    499  *                                                                                             *
    500  * WARNINGS:   none                                                                            *
    501  *                                                                                             *
    502  * HISTORY:                                                                                    *
    503  *   03/20/1996 JLB : Created.                                                                 *
    504  *=============================================================================================*/
    505 bool VesselTypeClass::Create_And_Place(CELL cell, HousesType house) const
    506 {
    507 	VesselClass * unit = new VesselClass(Type, house);
    508 	if (unit != NULL) {
    509 		return(unit->Unlimbo(Cell_Coord(cell), Random_Pick(DIR_N, DIR_MAX)));
    510 	}
    511 	delete unit;
    512 	return(false);
    513 }
    514 
    515 
    516 /***********************************************************************************************
    517  * VesselTypeClass::Dimensions -- Fetches the pixel width and height of this vessel type.      *
    518  *                                                                                             *
    519  *    This routine is used to fetch the width and height of this vessel type. These dimensions *
    520  *    are not specific to any particular facing. Rather, they are only for the generic vessel  *
    521  *    size.                                                                                    *
    522  *                                                                                             *
    523  * INPUT:   width, height  -- Reference to the integers that are to be initialized with the    *
    524  *                            pixel width and height of this vessel type.                      *
    525  *                                                                                             *
    526  * OUTPUT:  none                                                                               *
    527  *                                                                                             *
    528  * WARNINGS:   none                                                                            *
    529  *                                                                                             *
    530  * HISTORY:                                                                                    *
    531  *   03/20/1996 JLB : Created.                                                                 *
    532  *=============================================================================================*/
    533 void VesselTypeClass::Dimensions(int & width, int & height) const
    534 {
    535 	width = 48;
    536 	height = 48;
    537 }
    538 
    539 
    540 /***********************************************************************************************
    541  * VesselTypeClass::One_Time -- Performs one time initialization for vessel types.             *
    542  *                                                                                             *
    543  *    This routine will load in the vessel shape data. It should be called only once at the    *
    544  *    beginning of the game.                                                                   *
    545  *                                                                                             *
    546  * INPUT:   none                                                                               *
    547  *                                                                                             *
    548  * OUTPUT:  none                                                                               *
    549  *                                                                                             *
    550  * WARNINGS:   Only call this once.                                                            *
    551  *                                                                                             *
    552  * HISTORY:                                                                                    *
    553  *   03/20/1996 JLB : Created.                                                                 *
    554  *=============================================================================================*/
    555 void VesselTypeClass::One_Time(void)
    556 {
    557 	for (VesselType index = VESSEL_FIRST; index < VESSEL_COUNT; index++) {
    558 		char	fullname[_MAX_FNAME+_MAX_EXT];
    559 		char	buffer[_MAX_FNAME];
    560 		VesselTypeClass const & uclass = As_Reference(index);
    561 #ifdef FIXIT_CARRIER	//	checked - ajw 9/28/98
    562 		if (uclass.Level != -1 || index==VESSEL_CARRIER) {
    563 #else
    564 		if (uclass.Level != -1) {
    565 #endif
    566 //		if (uclass.IsBuildable) {
    567 
    568 			/*
    569 			**	Fetch the supporting data files for the unit.
    570 			*/
    571 			sprintf(buffer, "%sICON", uclass.Graphic_Name());
    572 			_makepath(fullname, NULL, NULL, buffer, ".SHP");
    573 			((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname);
    574 		}
    575 
    576 		/*
    577 		**	Fetch a pointer to the unit's shape data.
    578 		*/
    579 		_makepath(fullname, NULL, NULL, uclass.Graphic_Name(), ".SHP");
    580 		((void const *&)uclass.ImageData) = MFCD::Retrieve(fullname);
    581 
    582 		((int &)uclass.MaxSize) = 26;
    583 	}
    584 }
    585 
    586 
    587 /***********************************************************************************************
    588  * VesselTypeClass::Turret_Adjust -- Adjust turret offset according to facing specified.       *
    589  *                                                                                             *
    590  *    This routine will determine the pixel adjustment necessary for a turret. The direction   *
    591  *    specified is what the vessel body is facing.                                             *
    592  *                                                                                             *
    593  * INPUT:   dir   -- The presumed direction of the body facing for the vessel.                 *
    594  *                                                                                             *
    595  *          x,y   -- The center pixel position for the vessel. These values should be          *
    596  *                   adjusted (they are references) to match the adjusted offset for the       *
    597  *                   turret.                                                                   *
    598  *                                                                                             *
    599  * OUTPUT:  none                                                                               *
    600  *                                                                                             *
    601  * WARNINGS:   none                                                                            *
    602  *                                                                                             *
    603  * HISTORY:                                                                                    *
    604  *   03/20/1996 JLB : Created.                                                                 *
    605  *=============================================================================================*/
    606 void VesselTypeClass::Turret_Adjust(DirType dir, int & x, int & y) const
    607 {
    608 	short xx = x;
    609 	short yy = y;
    610 
    611 	switch (Type) {
    612 		case VESSEL_CA:
    613 			Normal_Move_Point(xx, yy, dir, 22);
    614 			x = xx;
    615 			y = yy-4;
    616 			break;
    617 
    618 		case VESSEL_PT:
    619 			Normal_Move_Point(xx, yy, dir, 14);
    620 			x = xx;
    621 			y = yy+1;
    622 			break;
    623 
    624 		case VESSEL_DD:
    625 			Normal_Move_Point(xx, yy, dir+DIR_S, 8);
    626 			x = xx;
    627 			y = yy-4;
    628 			break;
    629 	}
    630 }
    631 
    632 
    633 /***********************************************************************************************
    634  * VesselTypeClass::Overlap_List -- Figures the overlap list for the vessel type.              *
    635  *                                                                                             *
    636  *    This routine will return the overlap list for a vessel that is sitting still in the      *
    637  *    center of a cell.                                                                        *
    638  *                                                                                             *
    639  * INPUT:   none                                                                               *
    640  *                                                                                             *
    641  * OUTPUT:  Returns with a pointer to the overlap list that this vessel would use.             *
    642  *                                                                                             *
    643  * WARNINGS:   none                                                                            *
    644  *                                                                                             *
    645  * HISTORY:                                                                                    *
    646  *   03/20/1996 JLB : Created.                                                                 *
    647  *=============================================================================================*/
    648 short const * VesselTypeClass::Overlap_List(void) const
    649 {
    650 	static short const _ship[] = {-3, -2, -1, 1, 2, 3,
    651 		-MAP_CELL_W, -(MAP_CELL_W+1), -(MAP_CELL_W-1), -(MAP_CELL_W+2), -(MAP_CELL_W-2),
    652 		+MAP_CELL_W, +(MAP_CELL_W+1), +(MAP_CELL_W-1), +(MAP_CELL_W+2), +(MAP_CELL_W-2),
    653 		REFRESH_EOL};
    654 //	static short const _ship[] = {-1, 1,
    655 //		-MAP_CELL_W, -(MAP_CELL_W+1), -(MAP_CELL_W-1),
    656 //		+MAP_CELL_W, +(MAP_CELL_W+1), +(MAP_CELL_W-1),
    657 //		REFRESH_EOL};
    658 
    659 	return(&_ship[0]);
    660 }
    661 
    662 
    663 /***********************************************************************************************
    664  * VesselTypeClass::From_Name -- Converts a name into a vessel type.                           *
    665  *                                                                                             *
    666  *    Use this routine to convert an ASCII version of a vessel type into the corresponding     *
    667  *    VesselType id value. Typical use of this would be to parse the INI file.                 *
    668  *                                                                                             *
    669  * INPUT:   name  -- Pointer to the ASCII name to be converted into a vessel type.             *
    670  *                                                                                             *
    671  * OUTPUT:  Returns with the vessel type number that matches the string specified.             *
    672  *                                                                                             *
    673  * WARNINGS:   none                                                                            *
    674  *                                                                                             *
    675  * HISTORY:                                                                                    *
    676  *   03/20/1996 JLB : Created.                                                                 *
    677  *=============================================================================================*/
    678 VesselType VesselTypeClass::From_Name(char const * name)
    679 {
    680 	if (name != NULL) {
    681 		for (VesselType classid = VESSEL_FIRST; classid < VESSEL_COUNT; classid++) {
    682 			if (stricmp(As_Reference(classid).IniName, name) == 0) {
    683 				return(classid);
    684 			}
    685 		}
    686 	}
    687 	return(VESSEL_NONE);
    688 }
    689 
    690 
    691 /***********************************************************************************************
    692  * VesselTypeClass::Max_Pips -- Fetches the maximum pips allowed for this vessel.              *
    693  *                                                                                             *
    694  *    This routine will determine the number of pips (maximum) allowed for this unit type.     *
    695  *    Typically, this is the number of passengers allowed.												  *
    696  *                                                                                             *
    697  * INPUT:   none                                                                               *
    698  *                                                                                             *
    699  * OUTPUT:  Returns with the maximum number of pips allowed for this vessel type.              *
    700  *                                                                                             *
    701  * WARNINGS:   none                                                                            *
    702  *                                                                                             *
    703  * HISTORY:                                                                                    *
    704  *   06/01/1996 BWG : Created.                                                                 *
    705  *=============================================================================================*/
    706 int VesselTypeClass::Max_Pips(void) const
    707 {
    708 	return(Max_Passengers());
    709 }