ABSTRACT.CPP 14 KB

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