CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

DRIVE.H (8967B)


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