DRIVE.H 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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/DRIVE.H 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 : DRIVE.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : April 14, 1994 *
  30. * *
  31. * Last Update : April 14, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef DRIVE_H
  37. #define DRIVE_H
  38. #include "foot.h"
  39. /****************************************************************************
  40. ** Movable objects are handled by this class definition. Moveable objects
  41. ** cover everything except buildings.
  42. */
  43. class DriveClass : public FootClass
  44. {
  45. public:
  46. /*
  47. ** If this unit performing harvesting action, then this flag is true. The flag
  48. ** is located here because the other bit flags here give it a free place to
  49. ** reside.
  50. */
  51. unsigned IsHarvesting:1;
  52. /*
  53. ** This flag controls whether the unit has been moebius'd into a
  54. ** different location, and whether the MoebiusCountDown timer should be
  55. ** used to take him back where he belongs.
  56. */
  57. unsigned IsMoebius:1;
  58. /*
  59. ** This controls how long a unit can exist in its alternate location
  60. ** before being pulled back by the chronosphere into its normal location.
  61. */
  62. CDTimerClass<FrameTimerClass> MoebiusCountDown;
  63. /*
  64. ** This is the coord the unit will be taken back to once its moebius
  65. ** effect wears off.
  66. */
  67. CELL MoebiusCell;
  68. /*
  69. ** Some units must have their turret locked down to face their body direction.
  70. ** When this flag is set, this condition is in effect. This flag is a more
  71. ** accurate check than examining the TrackNumber since the turret may be
  72. ** rotating into position so that a pending track may start. During this process
  73. ** the track number does not indicate anything.
  74. */
  75. unsigned IsTurretLockedDown:1;
  76. /*
  77. ** This vehicle could be processing a "short track". A short track is one that
  78. ** doesn't actually go anywhere. Kind of like turning in place.
  79. */
  80. unsigned IsOnShortTrack:1;
  81. /*---------------------------------------------------------------------
  82. ** Constructors, Destructors, and overloaded operators.
  83. */
  84. DriveClass(RTTIType rtti, int id, HousesType house);
  85. DriveClass(NoInitClass const & x) : FootClass(x), MoebiusCountDown(x) {};
  86. virtual ~DriveClass(void) {};
  87. /*---------------------------------------------------------------------
  88. ** Member function prototypes.
  89. */
  90. bool Teleport_To(CELL cell);
  91. virtual void Response_Select(void);
  92. virtual void Response_Move(void);
  93. virtual void Response_Attack(void);
  94. virtual void Scatter(COORDINATE threat, bool forced=false, bool nokidding=false);
  95. virtual bool Limbo(void);
  96. void Do_Turn(DirType dir);
  97. virtual void Overrun_Square(CELL , bool =true) {};
  98. virtual void Assign_Destination(TARGET target);
  99. virtual void Per_Cell_Process(PCPType why);
  100. virtual bool Ok_To_Move(DirType ) const;
  101. virtual void AI(void);
  102. #ifdef CHEAT_KEYS
  103. virtual void Debug_Dump(MonoClass *mono) const;
  104. #endif
  105. void Force_Track(int track, COORDINATE coord);
  106. virtual bool Stop_Driver(void);
  107. void Mark_Track(COORDINATE headto, MarkType type);
  108. /**********************************************************************
  109. ** These enumerations are used as working constants that exist only
  110. ** in the DriveClass namespace.
  111. */
  112. enum DriveClassEnum {
  113. BACKUP_INTO_REFINERY=64, // Track to backup into refinery.
  114. OUT_OF_REFINERY, // Track to leave refinery.
  115. OUT_OF_WEAPON_FACTORY // Track to leave weapons factory.
  116. };
  117. /****************************************************************************
  118. ** Smooth turning tracks are controlled by this structure and these
  119. ** processing bits.
  120. */
  121. typedef enum TrackControlType {
  122. F_=0x00, // No translation necessary?
  123. F_T=0x01, // Transpose X and Y components?
  124. F_X=0x02, // Reverse X component sign?
  125. F_Y=0x04, // Reverse Y component sign?
  126. F_D=0x08 // Two cell consumption?
  127. } TrackControlType;
  128. private:
  129. typedef struct {
  130. char Track; // Which track to use.
  131. char StartTrack; // Track when starting from stand-still.
  132. DirType Facing; // Facing when track has been completed.
  133. DriveClass::TrackControlType Flag; // List processing flag bits.
  134. } TurnTrackType;
  135. typedef struct {
  136. COORDINATE Offset; // Offset to origin coordinate.
  137. DirType Facing; // Facing (primary track).
  138. } TrackType;
  139. typedef struct {
  140. TrackType const * Track; // Pointer to track list.
  141. int Jump; // Index where track jumping is allowed.
  142. int Entry; // Entry point if jumping to this track.
  143. int Cell; // Per cell process should occur at this index.
  144. } RawTrackType;
  145. /*
  146. ** These speed values are used to accumulate movement and then
  147. ** convert them into pixel "steps" that are then translated through
  148. ** the currently running track so that the unit will move.
  149. */
  150. int SpeedAccum;
  151. /*
  152. ** This the track control logic (used for ground vehicles only). The 'Track'
  153. ** variable holds the track being followed (0 == not following track). The
  154. ** 'TrackIndex' variable holds the current index into the specified track
  155. ** (starts at 0).
  156. */
  157. int TrackNumber;
  158. int TrackIndex;
  159. /*---------------------------------------------------------------------
  160. ** Member function prototypes.
  161. */
  162. virtual void Fixup_Path(PathType *path);
  163. bool While_Moving(void);
  164. bool Start_Of_Move(void);
  165. void Lay_Track(void);
  166. COORDINATE Smooth_Turn(COORDINATE adj, DirType & dir);
  167. static TurnTrackType const TrackControl[67];
  168. static RawTrackType const RawTracks[13];
  169. static TrackType const Track13[];
  170. static TrackType const Track12[];
  171. static TrackType const Track11[];
  172. static TrackType const Track10[];
  173. static TrackType const Track9[];
  174. static TrackType const Track8[];
  175. static TrackType const Track7[];
  176. static TrackType const Track6[];
  177. static TrackType const Track5[];
  178. static TrackType const Track4[];
  179. static TrackType const Track3[];
  180. static TrackType const Track2[];
  181. static TrackType const Track1[24];
  182. };
  183. inline DriveClass::TrackControlType operator |(DriveClass::TrackControlType, DriveClass::TrackControlType);
  184. inline DriveClass::TrackControlType operator &(DriveClass::TrackControlType, DriveClass::TrackControlType);
  185. inline DriveClass::TrackControlType operator ~(DriveClass::TrackControlType);
  186. #endif