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