DRIVE.H 8.4 KB

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