DRIVE.H 8.4 KB

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