ABSTRACT.CPP 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. ** Command & Conquer(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: F:\projects\c&c\vcs\code\abstract.cpv 2.20 16 Oct 1995 16:49:04 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 : May 22, 1995 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * AbstractClass::Distance -- Determines distance to target. *
  36. * AbstractTypeClass::AbstractTypeClass -- Constructor for abstract type objects. *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #include "function.h"
  39. /***********************************************************************************************
  40. * AbstractClass::Distance -- Determines distance to target. *
  41. * *
  42. * This will determine the distance (direct line) to the target. The distance is in *
  43. * 'leptons'. This routine is typically used for weapon range checks. *
  44. * *
  45. * INPUT: target -- The target to determine range to. *
  46. * *
  47. * OUTPUT: Returns with the range to the specified target (in leptons). *
  48. * *
  49. * WARNINGS: none *
  50. * *
  51. * HISTORY: *
  52. * 08/17/1994 JLB : Created. *
  53. *=============================================================================================*/
  54. int AbstractClass::Distance(TARGET target) const
  55. {
  56. /*
  57. ** Should subtract a fudge-factor distance for building targets.
  58. */
  59. BuildingClass *obj = As_Building(target);
  60. int dist = Distance(As_Coord(target));
  61. /*
  62. ** If the object is a building the adjust it by the average radius
  63. ** of the object.
  64. */
  65. if (obj) {
  66. dist -= ((obj->Class->Width() + obj->Class->Height()) * (0x100 / 4));
  67. if (dist < 0) dist = 0;
  68. }
  69. /*
  70. ** Return the distance to the target
  71. */
  72. return(dist);
  73. }
  74. /***********************************************************************************************
  75. * AbstractTypeClass::AbstractTypeClass -- Constructor for abstract type objects. *
  76. * *
  77. * This is the constructor for AbstractTypeClass objects. It initializes the INI name and *
  78. * the text name for this object type. *
  79. * *
  80. * INPUT: name -- Text number for the full name of the object. *
  81. * *
  82. * ini -- The ini name for this object type. *
  83. * *
  84. * OUTPUT: none *
  85. * *
  86. * WARNINGS: none *
  87. * *
  88. * HISTORY: *
  89. * 05/22/1995 JLB : Created. *
  90. *=============================================================================================*/
  91. AbstractTypeClass::AbstractTypeClass(int name, char const * ini)
  92. {
  93. Name = name;
  94. strncpy((char *)IniName, ini, sizeof(IniName));
  95. ((char &)IniName[sizeof(IniName)-1]) = '\0';
  96. }
  97. RTTIType AbstractTypeClass::What_Am_I(void) const {return RTTI_ABSTRACTTYPE;};
  98. COORDINATE AbstractTypeClass::Coord_Fixup(COORDINATE coord) const {return coord;}
  99. int AbstractTypeClass::Full_Name(void) const {return Name;};
  100. unsigned short AbstractTypeClass::Get_Ownable(void) const {return 0xffff;};