CnC_Remastered_Collection

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

ABSTRACT.H (5687B)


      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\abstract.h_v   2.20   16 Oct 1995 16:46:30   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 int  Distance(CELL coord1, CELL coord2);
     42 COORDINATE  As_Coord(TARGET target);
     43 
     44 class AbstractTypeClass;
     45 
     46 class AbstractClass
     47 {
     48 	public:
     49 
     50 		/*
     51 		**	The coordinate location of the unit. For vehicles, this is the center
     52 		**	point. For buildings, it is the upper left corner.
     53 		*/
     54 		COORDINATE Coord;
     55 
     56 		/*
     57 		**	The actual object ram-space is located in arrays in the data segment. This flag
     58 		**	is used to indicate which objects are free to be reused and which are currently
     59 		**	in use by the game.
     60 		*/
     61 		unsigned IsActive:1;
     62 
     63 		/*
     64 		** A flag to indicate that this object was recently created. Since an object's allocation is just a matter of whether
     65 		** the IsActive flag is set, during a logic frame an object with a given ID could be 'deleted' then reallocated 
     66 		** as a different type of object in a different location. This flag lets us know that this happened. ST - 8/19/2019 5:33PM
     67 		*/
     68 		unsigned IsRecentlyCreated:1;
     69 				
     70 		/*
     71 		** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
     72 		*/
     73 		unsigned char SaveLoadPadding[8];
     74 
     75 		/*-----------------------------------------------------------------------------------
     76 		**	Constructor & destructors.
     77 		*/
     78 		AbstractClass(void) {Coord = 0L;};
     79 		virtual ~AbstractClass(void) {};
     80 
     81 		/*
     82 		**	Query functions.
     83 		*/
     84 		virtual HousesType Owner(void) const {return HOUSE_NONE;};
     85 
     86 		/*
     87 		**	Coordinate query support functions.
     88 		*/
     89 		virtual COORDINATE Center_Coord(void) const {return Coord;};
     90 		virtual COORDINATE Target_Coord(void) const {return Coord;};
     91 
     92 		/*
     93 		**	Coordinate inquiry functions. These are used for both display and
     94 		**	combat purposes.
     95 		*/
     96 		DirType Direction(AbstractClass const * object) const {return ::Direction(Center_Coord(), object->Target_Coord());};
     97 		DirType Direction(COORDINATE coord) const {return ::Direction(Center_Coord(), coord);};
     98 		DirType Direction(TARGET target) const {return ::Direction(Center_Coord(), As_Coord(target));};
     99 		DirType Direction(CELL cell) const {return ::Direction(Coord_Cell(Center_Coord()), cell);};
    100 		int Distance(TARGET target) const;
    101 		int Distance(COORDINATE coord) const {return ::Distance(Center_Coord(), coord);};
    102 		int Distance(CELL cell) const {return ::Distance(Coord_Cell(Center_Coord()), cell);};
    103 		int Distance(AbstractClass const * object) const {return ::Distance(Center_Coord(), object->Target_Coord());};
    104 
    105 		/*
    106 		**	Object entry and exit from the game system.
    107 		*/
    108 		virtual MoveType Can_Enter_Cell(CELL , FacingType = FACING_NONE) const {return MOVE_OK;};
    109 
    110 		/*
    111 		**	AI.
    112 		*/
    113 		virtual void AI(void) {};
    114 
    115 		/*
    116 		** Workaround for difference between watcom and VC destructor behavior
    117 		*/
    118 		void Delete_This(void);
    119 
    120 		/*
    121 		** Set the new recently created flag every time the active flag is set. ST - 8/19/2019 5:41PM
    122 		*/
    123 		void Set_Active(void) {IsActive = true; IsRecentlyCreated = true;}
    124 };
    125 
    126 
    127 #endif