ABSTRACT.CPP 13 KB

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