CnC_Remastered_Collection

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

ABSTRACT.H (6079B)


      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/ABSTRACT.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 : ABSTRACT.H                                                   *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 01/26/95                                                     *
     28  *                                                                                             *
     29  *                  Last Update : January 26, 1995 [JLB]                                       *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef ABSTRACT_H
     36 #define ABSTRACT_H
     37 
     38 DirType Direction(CELL cell1, CELL cell2);
     39 DirType Direction(COORDINATE coord1, COORDINATE coord2);
     40 int Distance(COORDINATE coord1, COORDINATE coord2);
     41 COORDINATE As_Coord(TARGET target);
     42 
     43 class AbstractTypeClass;
     44 
     45 /*
     46 **	This class is the base class for all game objects that have an existence on the
     47 **	battlefield.
     48 */
     49 class AbstractClass
     50 {
     51 	public:
     52 
     53 		/*
     54 		**	This specifies the type of object and the unique ID number
     55 		**	associated with it. The ID number happens to match the index into
     56 		**	the object heap appropriate for this object type.
     57 		*/
     58 		RTTIType RTTI;
     59 		int ID;
     60 
     61 		/*
     62 		**	The coordinate location of the unit. For vehicles, this is the center
     63 		**	point. For buildings, it is the upper left corner.
     64 		*/
     65 		COORDINATE Coord;
     66 
     67 		/*
     68 		**	This is the height of the object above ground (expressed in leptons).
     69 		*/
     70 		int Height;
     71 
     72 		/*
     73 		**	The actual object ram-space is located in arrays in the data segment. This flag
     74 		**	is used to indicate which objects are free to be reused and which are currently
     75 		**	in use by the game.
     76 		*/
     77 		unsigned IsActive:1;
     78 
     79 		/*
     80 		** A flag to indicate that this object was recently created. Since an object's allocation is just a matter of whether
     81 		** the IsActive flag is set, during a logic frame an object with a given ID could be 'deleted' then reallocated 
     82 		** as a different type of object in a different location. This flag lets us know that this happened. ST - 8/19/2019 5:33PM
     83 		*/
     84 		unsigned IsRecentlyCreated:1;
     85 
     86 		/*-----------------------------------------------------------------------------------
     87 		**	Constructor & destructors.
     88 		*/
     89 		AbstractClass(RTTIType rtti, int id) : RTTI(rtti), ID(id), Coord(0xFFFFFFFFL), Height(0) {};
     90 		AbstractClass(NoInitClass const & x) {x();};
     91 		virtual ~AbstractClass(void) {};
     92 
     93 		/*
     94 		**	Query functions.
     95 		*/
     96 		virtual char const * Name(void) const {return("");}
     97 		virtual HousesType Owner(void) const {return HOUSE_NONE;};
     98 		TARGET As_Target(void) const {return(Build_Target(RTTI, ID));};
     99 		RTTIType What_Am_I(void) const {return(RTTI);};
    100 
    101 		/*
    102 		**	Scenario and debug support.
    103 		*/
    104 		#ifdef CHEAT_KEYS
    105 		virtual void Debug_Dump(MonoClass * mono) const;
    106 		#endif
    107 
    108 		/*
    109 		**	Coordinate query support functions.
    110 		*/
    111 		virtual COORDINATE Center_Coord(void) const {return Coord;};
    112 		virtual COORDINATE Target_Coord(void) const {return Coord;};
    113 
    114 		/*
    115 		**	Coordinate inquiry functions. These are used for both display and
    116 		**	combat purposes.
    117 		*/
    118 		DirType Direction(AbstractClass const * object) const {return ::Direction(Center_Coord(), object->Target_Coord());};
    119 		DirType Direction(COORDINATE coord) const {return ::Direction(Center_Coord(), coord);};
    120 		DirType Direction(TARGET target) const {return ::Direction(Center_Coord(), As_Coord(target));};
    121 		DirType Direction(CELL cell) const {return ::Direction(Coord_Cell(Center_Coord()), cell);};
    122 		int Distance(TARGET target) const;
    123 		int Distance(COORDINATE coord) const {return ::Distance(Center_Coord(), coord);};
    124 		int Distance(AbstractClass const * object) const {return ::Distance(Center_Coord(), object->Target_Coord());};
    125 
    126 		/*
    127 		**	Object entry and exit from the game system.
    128 		*/
    129 		virtual MoveType Can_Enter_Cell(CELL , FacingType = FACING_NONE) const {return MOVE_OK;};
    130 
    131 		/*
    132 		**	AI.
    133 		*/
    134 		virtual void AI(void) {};
    135 
    136 		/*
    137 		** Set the new recently created flag every time the active flag is set. ST - 8/19/2019 5:41PM
    138 		*/
    139 		void Set_Active(void) {IsActive = true; IsRecentlyCreated = true;}
    140 
    141 };
    142 
    143 
    144 #endif