DRIVE.H 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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: F:\projects\c&c\vcs\code\drive.h_v 2.19 16 Oct 1995 16:47:44 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. ** This points to the static control data that gives 'this' unit its characteristics.
  44. */
  45. UnitTypeClass const * const Class;
  46. /*
  47. ** Simulated sub-pixel offset to find out where the object would be if it could make a sub-pixel move. Only used by
  48. ** GlyphX client for more accurate positioning.
  49. **
  50. ** ST - 4/30/2019 8:05AM
  51. */
  52. short SimLeptonX;
  53. short SimLeptonY;
  54. /*
  55. ** This records the number of "loads" of Tiberium the unit is carrying. Only
  56. ** harvesters use this field.
  57. */
  58. unsigned char Tiberium;
  59. /*
  60. ** If this unit performing harvesting action, then this flag is true. The flag
  61. ** is located here because the other bit flags here give it a free place to
  62. ** reside.
  63. */
  64. unsigned IsHarvesting:1;
  65. /*
  66. ** This flags when a transport vehicle could not unload at its designated location
  67. ** and is heading off the map to try again later. When this flag is true, the
  68. ** transport unit is allowed to disappear when it reaches the edge of the map.
  69. */
  70. unsigned IsReturning:1;
  71. /*
  72. ** Some units must have their turret locked down to face their body direction.
  73. ** When this flag is set, this condition is in effect. This flag is a more
  74. ** accurate check than examining the TrackNumber since the turret may be
  75. ** rotating into position so that a pending track may start. During this process
  76. ** the track number does not indicate anything.
  77. */
  78. unsigned IsTurretLockedDown:1;
  79. /*
  80. ** This vehicle could be processing a "short track". A short track is one that
  81. ** doesn't actually go anywhere. Kind of like turning in place.
  82. */
  83. unsigned IsOnShortTrack:1;
  84. /*---------------------------------------------------------------------
  85. ** Constructors, Destructors, and overloaded operators.
  86. */
  87. DriveClass(void);
  88. DriveClass(UnitType classid, HousesType house);
  89. virtual ~DriveClass(void) {};
  90. operator UnitType(void) const {return Class->Type;};
  91. /*---------------------------------------------------------------------
  92. ** Member function prototypes.
  93. */
  94. virtual int Offload_Tiberium_Bail(void);
  95. void Do_Turn(DirType dir);
  96. virtual void Approach_Target(void);
  97. virtual ObjectTypeClass const & Class_Of(void) const;
  98. virtual void Overrun_Square(CELL cell, bool threaten=true);
  99. virtual void Assign_Destination(TARGET target);
  100. virtual void Per_Cell_Process(bool center);
  101. virtual bool Ok_To_Move(DirType ) const;
  102. virtual void AI(void);
  103. #ifdef CHEAT_KEYS
  104. virtual void Debug_Dump(MonoClass *mono) const;
  105. #endif
  106. void Force_Track(int track, COORDINATE coord);
  107. virtual int Tiberium_Load(void) const;
  108. void Exit_Map(void);
  109. void Mark_Track(COORDINATE headto, MarkType type);
  110. /*
  111. ** File I/O.
  112. */
  113. virtual void Code_Pointers(void);
  114. virtual void Decode_Pointers(void);
  115. /**********************************************************************
  116. ** These enumerations are used as working constants that exist only
  117. ** in the DriveClass namespace.
  118. */
  119. enum DriveClassEnum {
  120. BACKUP_INTO_REFINERY=64, // Track to backup into refinery.
  121. OUT_OF_REFINERY, // Track to leave refinery.
  122. OUT_OF_WEAPON_FACTORY // Track to leave weapons factory.
  123. };
  124. private:
  125. /****************************************************************************
  126. ** Smooth turning tracks are controlled by this structure and these
  127. ** processing bits.
  128. */
  129. typedef enum TrackControlType : unsigned char {
  130. F_=0x00, // No translation necessary?
  131. F_T=0x01, // Transpose X and Y components?
  132. F_X=0x02, // Reverse X component sign?
  133. F_Y=0x04, // Reverse Y component sign?
  134. F_D=0x08 // Two cell consumption?
  135. } TrackControlType;
  136. //#define F_S 0x10 // Is this a 90 degree turn?
  137. typedef struct {
  138. char Track; // Which track to use.
  139. char StartTrack; // Track when starting from stand-still.
  140. DirType Facing; // Facing when track has been completed.
  141. DriveClass::TrackControlType Flag; // List processing flag bits.
  142. } TurnTrackType;
  143. typedef struct {
  144. COORDINATE Offset; // Offset to origin coordinate.
  145. DirType Facing; // Facing (primary track).
  146. } TrackType;
  147. typedef struct {
  148. DriveClass::TrackType const * Track; // Pointer to track list.
  149. int Jump; // Index where track jumping is allowed.
  150. int Entry; // Entry point if jumping to this track.
  151. int Cell; // Per cell process should occur at this index.
  152. } RawTrackType;
  153. /*
  154. ** These speed values are used to accumulate movement and then
  155. ** convert them into pixel "steps" that are then translated through
  156. ** the currently running track so that the unit will move.
  157. */
  158. unsigned char SpeedAccum;
  159. /*
  160. ** This the track control logic (used for ground vehicles only). The 'Track'
  161. ** variable holds the track being followed (0 == not following track). The
  162. ** 'TrackIndex' variable holds the current index into the specified track
  163. ** (starts at 0).
  164. */
  165. char TrackNumber;
  166. char TrackIndex;
  167. /*---------------------------------------------------------------------
  168. ** Member function prototypes.
  169. */
  170. virtual void Fixup_Path(PathType *path);
  171. bool While_Moving(void);
  172. bool Start_Of_Move(void);
  173. void Lay_Track(void);
  174. COORDINATE Smooth_Turn(COORDINATE adj, DirType *dir);
  175. static TurnTrackType const TrackControl[67];
  176. static RawTrackType const RawTracks[13];
  177. static TrackType const Track13[];
  178. static TrackType const Track12[];
  179. static TrackType const Track11[];
  180. static TrackType const Track10[];
  181. static TrackType const Track9[];
  182. static TrackType const Track8[];
  183. static TrackType const Track7[];
  184. static TrackType const Track6[];
  185. static TrackType const Track5[];
  186. static TrackType const Track4[];
  187. static TrackType const Track3[];
  188. static TrackType const Track2[];
  189. static TrackType const Track1[24];
  190. };
  191. //PG_TO_FIX
  192. //inline DriveClass::TrackControlType operator |(DriveClass::TrackControlType, DriveClass::TrackControlType);
  193. //inline DriveClass::TrackControlType operator &(DriveClass::TrackControlType, DriveClass::TrackControlType);
  194. //inline DriveClass::TrackControlType operator ~(DriveClass::TrackControlType);
  195. #endif