CnC_Remastered_Collection

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

OBJECT.H (11043B)


      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/OBJECT.H 1     3/03/97 10:25a 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 : OBJECT.H                                                     *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : April 29, 1994                                               *
     28  *                                                                                             *
     29  *                  Last Update : April 29, 1994   [JLB]                                       *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef OBJECT_H
     36 #define OBJECT_H
     37 
     38 #include	"abstract.h"
     39 
     40 class ObjectClass;
     41 class TechnoClass;
     42 class ObjectTypeClass;
     43 class HouseClass;
     44 class BuildingClass;
     45 class RadioClass;
     46 class TriggerClass;
     47 
     48 
     49 /**********************************************************************
     50 **	Every game object (that can exist on the map) is ultimately derived from this object
     51 **	class. It holds the common information between all objects. This is primarily the
     52 **	object unique ID number and its location in the world. All common operations between
     53 **	game objects are represented by virtual functions in this class.
     54 */
     55 class ObjectClass : public AbstractClass
     56 {
     57 	public:
     58 		/*
     59 		**	The object can be in one of two states -- placed down on the map, or not. If the
     60 		**	object is placed down on the map, then this flag will be true.
     61 		*/
     62 		unsigned IsDown:1;
     63 
     64 		/*
     65 		**	This is a support flag that is only used while building a list of objects to
     66 		**	be damaged by a proximity affect (explosion). When this flag is set, this object
     67 		**	will not be added to the list of units to damage. When damage is applied to the
     68 		**	object, this flag is cleared again. This process ensures that an object is never
     69 		**	subject to "double jeopardy".
     70 		*/
     71 		unsigned IsToDamage:1;
     72 
     73 		/*
     74 		**	Is this object flagged to be displayed during the next rendering process?  This
     75 		**	flag could be set by many different circumstances. It is automatically cleared
     76 		**	when the object is rerendered.
     77 		*/
     78 		unsigned IsToDisplay:1;
     79 
     80 		/*
     81 		**	An object in the game may be valid yet held in a state of "limbo". Units are in such
     82 		**	a state if they are being transported or are otherwise "inside" another unit. They can
     83 		**	also be in limbo if they have been created but are being held until the proper time
     84 		**	for delivery.
     85 		*/
     86 		unsigned IsInLimbo:1;
     87 
     88 		/*
     89 		**	When an object is "selected" it is given a floating bar graph or other graphic imagery
     90 		**	to display this fact. When the player performs I/O, the actions may have a direct
     91 		**	bearing on the actions of the currently selected object. For quick checking purposes,
     92 		**	if this object is the one that is "selected", this flag will be true.
     93 		*/
     94 		unsigned IsSelected:1;
     95 
     96 		//Added a mask instead of bool for selecting players. This is because we must now support multiplayer.
     97 		// - 6/26/2019
     98 		// Needs more than 16 bits since RA has more than 16 factions. ST - 8/14/2019 12:15PM
     99 		unsigned int IsSelectedMask;
    100 
    101 		/*
    102 		**	If an animation is attached to this object, then this flag will be true.
    103 		*/
    104 		unsigned IsAnimAttached:1;
    105 
    106 		/*
    107 		**	If this object should process falling logic, then this flag will be true. Such
    108 		**	objects might be ballistic projectiles, grenades, or parachuters.
    109 		*/
    110 		unsigned IsFalling:1;
    111 		int Riser;
    112 
    113 		/*
    114 		**	Several objects could exist in the same cell list. This is a pointer to the
    115 		**	next object in the cell list. The objects in this list are not in any
    116 		**	significant order.
    117 		*/
    118 		SmartPtr<ObjectClass> Next;
    119 
    120 		/*
    121 		** Every object can be assigned a trigger; the same trigger can be assigned
    122 		** to multiple objects.
    123 		*/
    124 		CCPtr<TriggerClass> Trigger;
    125 
    126 		/*
    127 		**	This is the current strength of this object.
    128 		*/
    129 		short Strength;
    130 
    131 		/*
    132 		** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
    133 		*/
    134 		unsigned char SaveLoadPadding[16];
    135 
    136 		/*-----------------------------------------------------------------------------------
    137 		**	Constructor & destructors.
    138 		*/
    139 		ObjectClass(RTTIType rtti, int id);
    140 		ObjectClass(NoInitClass const & x) : AbstractClass(x), Next(x), Trigger(x) {};
    141 		virtual ~ObjectClass(void) {Next = 0;};
    142 		int operator < (ObjectClass const & object) const {return Sort_Y() < object.Sort_Y();};
    143 		int operator > (ObjectClass const & object) const {return Sort_Y() > object.Sort_Y();};
    144 
    145 		/*
    146 		**	Object selection control.
    147 		*/
    148 		static void Init(void);
    149 
    150 		/*
    151 		**	Query functions.
    152 		*/
    153 		virtual bool Is_Players_Army(void) const {return(false);}
    154 		virtual void const * Get_Image_Data(void) const;
    155 		virtual ActionType What_Action(ObjectClass const *) const;
    156 		virtual ActionType What_Action(CELL) const;
    157 		virtual LayerType In_Which_Layer(void) const;
    158 		bool Is_Infantry(void) const {return(RTTI == RTTI_INFANTRY);};
    159 		bool Is_Foot(void) const {return(RTTI == RTTI_INFANTRY || RTTI == RTTI_UNIT || RTTI == RTTI_VESSEL || RTTI == RTTI_AIRCRAFT);};
    160 		bool Is_Techno(void) const {return(RTTI == RTTI_BUILDING || RTTI == RTTI_UNIT || RTTI == RTTI_INFANTRY || RTTI == RTTI_VESSEL || RTTI == RTTI_AIRCRAFT);};
    161 		virtual int Get_Ownable(void) const;
    162 		virtual ObjectTypeClass const & Class_Of(void) const = 0;
    163 		virtual char const * Name(void) const;
    164 		virtual int Full_Name(void) const;
    165 		virtual bool Can_Repair(void) const;
    166 		virtual bool Can_Demolish(void) const;
    167 		virtual bool Can_Demolish_Unit(void) const;
    168 		virtual bool Can_Capture(void) const;
    169 		virtual bool Can_Player_Fire(void) const;
    170 		virtual bool Can_Player_Move(void) const;
    171 
    172 		/*
    173 		**	Coordinate inquiry functions. These are used for both display and
    174 		**	combat purposes.
    175 		*/
    176 		virtual COORDINATE Docking_Coord(void) const;
    177 		virtual COORDINATE Target_Coord(void) const;
    178 		virtual COORDINATE Center_Coord(void) const;
    179 		virtual COORDINATE Render_Coord(void) const;
    180 		virtual COORDINATE Sort_Y(void) const;
    181 		virtual FireDataType Fire_Data(int which) const;
    182 		virtual COORDINATE Fire_Coord(int which) const;
    183 		virtual COORDINATE Exit_Coord(void) const;
    184 
    185 		/*
    186 		**	Object entry and exit from the game system.
    187 		*/
    188 		virtual bool Limbo(void);
    189 		virtual bool Unlimbo(COORDINATE , DirType facing = DIR_N);
    190 		virtual void Detach(TARGET target, bool all=true);
    191 		virtual void Detach_All(bool all=true);
    192 		virtual void Record_The_Kill(TechnoClass * );
    193 		virtual bool Paradrop(COORDINATE coord);
    194 		bool Attach_Trigger(TriggerClass * trigger);
    195 
    196 		/*
    197 		**	Display and rendering support functionality. Supports imagery and how
    198 		**	object interacts with the map and thus indirectly controls rendering.
    199 		*/
    200 		virtual void Do_Shimmer(void);
    201 		virtual int Exit_Object(TechnoClass *);
    202 		virtual bool Render(bool forced) const;
    203 		virtual short const * Occupy_List(bool placement=false) const;
    204 		virtual short const * Overlap_List(bool redraw=false) const;
    205 		virtual fixed Health_Ratio(void) const;
    206 		virtual void Draw_It(int x, int y, WindowNumberType ) const = 0;
    207 		virtual void Hidden(void);
    208 		virtual void Look(bool incremental=false);
    209 		virtual bool Mark(MarkType=MARK_CHANGE);
    210 
    211 	private:
    212 		virtual void Mark_For_Redraw(void);
    213 
    214 	public:
    215 
    216 		/*
    217 		**	User I/O.
    218 		*/
    219 		virtual void Active_Click_With(ActionType , ObjectClass *);
    220 		virtual void Active_Click_With(ActionType , CELL );
    221 		virtual void Clicked_As_Target(HousesType house, int = 7); // 2019/09/20 JAS - Added record of who clicked on the object
    222 		virtual bool Select(bool allow_mixed = false);
    223 		virtual void Unselect(void);
    224 
    225 		//These selection functions were added to handle the fact that we now need to support 
    226 		//client-server multiplayer. - JAS 6/26/2019
    227 		virtual void Unselect_All_Players(void);
    228 		virtual void Unselect_All_Players_Except_Owner(void);
    229 		virtual bool Is_Selected_By_Player(HouseClass *player = NULL) const;
    230 		virtual void Set_Selected_By_Player(HouseClass *player = NULL);
    231 		virtual void Set_Unselected_By_Player(HouseClass *player = NULL);
    232 
    233 		/*
    234 		**	Combat related.
    235 		*/
    236 		virtual bool In_Range(COORDINATE , int=0) const;
    237 		virtual int Weapon_Range(int =0) const;
    238 		virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false);
    239 		virtual void Scatter(COORDINATE , bool forced=false, bool nokidding=false);
    240 		virtual bool Catch_Fire(void);
    241 		virtual void Fire_Out(void);
    242 		virtual int Value(void) const;
    243 		virtual MissionType Get_Mission(void) const;
    244 
    245 		/*
    246 		**	AI.
    247 		*/
    248 		virtual void Per_Cell_Process(PCPType) {}
    249 		virtual BuildingClass * Who_Can_Build_Me(bool intheory, bool legal) const;
    250 		virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
    251 		virtual bool Revealed(HouseClass * house);
    252 		virtual void Repair(int );
    253 		virtual void Sell_Back(int );
    254 		virtual void AI(void);
    255 
    256 		/*
    257 		**	File I/O.
    258 		*/
    259 		virtual void Code_Pointers(void);
    260 		virtual void Decode_Pointers(void);
    261 
    262 		/*
    263 		**	Scenario and debug support.
    264 		*/
    265 		#ifdef CHEAT_KEYS
    266 		virtual void Debug_Dump(MonoClass *mono) const;
    267 		#endif
    268 		virtual void Move(FacingType);
    269 
    270 		enum {FLIGHT_LEVEL=256};
    271 
    272 };
    273 
    274 #endif