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