CnC_Remastered_Collection

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

OBJECT.H (10093B)


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