CnC_Remastered_Collection

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

ABSTRACT.CPP (13907B)


      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/ABSTRACT.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 : ABSTRACT.CPP                                                 *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 01/26/95                                                     *
     28  *                                                                                             *
     29  *                  Last Update : July 10, 1996 [JLB]                                          *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  *   AbstractClass::Debug_Dump -- Display debug information to mono screen.                    *
     34  *   AbstractClass::Distance -- Determines distance to target.                                 *
     35  *   AbstractTypeClass::AbstractTypeClass -- Constructor for abstract type objects.            *
     36  *   AbstractTypeClass::Coord_Fixup -- Performs custom adjustments to location coordinate.     *
     37  *   AbstractTypeClass::Full_Name -- Returns the full name (number) of this object type.       *
     38  *   AbstractTypeClass::Get_Ownable -- Fetch the ownable bits for this object.                 *
     39  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     40 
     41 #include	"function.h"
     42 
     43 
     44 /***********************************************************************************************
     45  * AbstractClass::Debug_Dump -- Display debug information to mono screen.                      *
     46  *                                                                                             *
     47  *    This debug only routine will display various information about this abstract class       *
     48  *    object to the monochrome screen specified.                                               *
     49  *                                                                                             *
     50  * INPUT:   mono  -- Pointer to the monochrome screen to display the debug information to.     *
     51  *                                                                                             *
     52  * OUTPUT:  none                                                                               *
     53  *                                                                                             *
     54  * WARNINGS:   none                                                                            *
     55  *                                                                                             *
     56  * HISTORY:                                                                                    *
     57  *   07/10/1996 JLB : Created.                                                                 *
     58  *=============================================================================================*/
     59 #ifdef CHEAT_KEYS
     60 void AbstractClass::Debug_Dump(MonoClass * mono) const
     61 {
     62 	assert(IsActive);
     63 
     64 	mono->Set_Cursor(11, 5);mono->Printf("%08X", As_Target());
     65 	mono->Set_Cursor(20, 1);mono->Printf("%08X", Coord);
     66 	mono->Set_Cursor(29, 1);mono->Printf("%3d", Height);
     67 	if (Owner() != HOUSE_NONE) {
     68 		mono->Set_Cursor(1, 3);
     69 		mono->Printf("%-18s", Text_String(HouseTypeClass::As_Reference(Owner()).FullName));
     70 	}
     71 }
     72 #endif
     73 
     74 
     75 /***********************************************************************************************
     76  * AbstractClass::Distance -- Determines distance to target.                                   *
     77  *                                                                                             *
     78  *    This will determine the distance (direct line) to the target. The distance is in         *
     79  *    'leptons'. This routine is typically used for weapon range checks.                       *
     80  *                                                                                             *
     81  * INPUT:   target   -- The target to determine range to.                                      *
     82  *                                                                                             *
     83  * OUTPUT:  Returns with the range to the specified target (in leptons).                       *
     84  *                                                                                             *
     85  * WARNINGS:   none                                                                            *
     86  *                                                                                             *
     87  * HISTORY:                                                                                    *
     88  *   08/17/1994 JLB : Created.                                                                 *
     89  *=============================================================================================*/
     90 int AbstractClass::Distance(TARGET target) const
     91 {
     92 	/*
     93 	**	Should subtract a fudge-factor distance for building targets.
     94 	*/
     95 	BuildingClass * obj = As_Building(target);
     96 	int dist = Distance(As_Coord(target));
     97 
     98 	/*
     99 	** If the object is a building the adjust it by the average radius
    100 	** of the object.
    101 	*/
    102 	if (obj && obj->IsActive) {
    103 		dist -= ((obj->Class->Width() + obj->Class->Height()) * (0x100 / 4));
    104 		if (dist < 0) dist = 0;
    105 	}
    106 
    107 	/*
    108 	** Return the distance to the target
    109 	*/
    110 	return(dist);
    111 }
    112 
    113 
    114 /***********************************************************************************************
    115  * AbstractTypeClass::AbstractTypeClass -- Constructor for abstract type objects.              *
    116  *                                                                                             *
    117  *    This is the constructor for AbstractTypeClass objects. It initializes the INI name and   *
    118  *    the text name for this object type.                                                      *
    119  *                                                                                             *
    120  * INPUT:   name  -- Text number for the full name of the object.                              *
    121  *                                                                                             *
    122  *          ini   -- The ini name for this object type.                                        *
    123  *                                                                                             *
    124  * OUTPUT:  none                                                                               *
    125  *                                                                                             *
    126  * WARNINGS:   none                                                                            *
    127  *                                                                                             *
    128  * HISTORY:                                                                                    *
    129  *   05/22/1995 JLB : Created.                                                                 *
    130  *=============================================================================================*/
    131 AbstractTypeClass::AbstractTypeClass(RTTIType rtti, int id, int name, char const * ini) :
    132 	RTTI(rtti),
    133 	ID(id),
    134 	FullName(name)
    135 {
    136 	strncpy((char *)IniName, ini, sizeof(IniName));
    137 	((char &)IniName[sizeof(IniName)-1]) = '\0';
    138 }
    139 
    140 
    141 /***********************************************************************************************
    142  * AbstractTypeClass::Coord_Fixup -- Performs custom adjustments to location coordinate.       *
    143  *                                                                                             *
    144  *    This routine is called when the placement coordinate should be fixed up according        *
    145  *    to any special rules specific to this object type. At this level, no transformation      *
    146  *    occurs. Derived classes will transform the coordinate as necessary.                      *
    147  *                                                                                             *
    148  * INPUT:   coord -- The proposed coordinate that this object type will be placed down at.     *
    149  *                                                                                             *
    150  * OUTPUT:  Returns with the adjusted coordinate that the object should be placed down at.     *
    151  *                                                                                             *
    152  * WARNINGS:   none                                                                            *
    153  *                                                                                             *
    154  * HISTORY:                                                                                    *
    155  *   09/21/1995 JLB : Created.                                                                 *
    156  *=============================================================================================*/
    157 COORDINATE AbstractTypeClass::Coord_Fixup(COORDINATE coord) const
    158 {
    159 	return(coord);
    160 }
    161 
    162 
    163 /***********************************************************************************************
    164  * AbstractTypeClass::Full_Name -- Returns the full name (number) of this object type.         *
    165  *                                                                                             *
    166  *    This routine is used to fetch the full name of this object type. The name value          *
    167  *    returned is actually the index number into the text array.                               *
    168  *                                                                                             *
    169  * INPUT:   none                                                                               *
    170  *                                                                                             *
    171  * OUTPUT:  Returns with the full name index number for this object type.                      *
    172  *                                                                                             *
    173  * WARNINGS:   none                                                                            *
    174  *                                                                                             *
    175  * HISTORY:                                                                                    *
    176  *   09/21/1995 JLB : Created.                                                                 *
    177  *=============================================================================================*/
    178 int AbstractTypeClass::Full_Name(void) const
    179 {
    180 #ifdef FIXIT_NAME_OVERRIDE
    181 	for (int index = 0; index < ARRAY_SIZE(NameOverride); index++) {
    182 		if (NameIDOverride[index] == ((RTTI+1) * 100) + ID)  {
    183 			return(-(index+1));
    184 		}
    185 	}
    186 #endif
    187 	return(FullName);
    188 }
    189 
    190 
    191 /***********************************************************************************************
    192  * AbstractTypeClass::Get_Ownable -- Fetch the ownable bits for this object.                   *
    193  *                                                                                             *
    194  *    This returns a bit flag that indicates which houses are allowed to own this object       *
    195  *    type. At this level, all houses have ownership rights. This routine will be overridden   *
    196  *    by object types that restrict ownership.                                                 *
    197  *                                                                                             *
    198  * INPUT:   none                                                                               *
    199  *                                                                                             *
    200  * OUTPUT:  Returns with a bit flag indicating which houses have ownership rights.             *
    201  *                                                                                             *
    202  * WARNINGS:   none                                                                            *
    203  *                                                                                             *
    204  * HISTORY:                                                                                    *
    205  *   09/21/1995 JLB : Created.                                                                 *
    206  *=============================================================================================*/
    207 int AbstractTypeClass::Get_Ownable(void) const
    208 {
    209 	return(HOUSEF_ALLIES | HOUSEF_SOVIET | HOUSEF_OTHERS);
    210 }
    211 
    212 
    213