CnC_Remastered_Collection

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

TEAM.H (8828B)


      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\team.h_v   2.16   16 Oct 1995 16:48:04   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 : TEAM.H                                                       *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 12/11/94                                                     *
     28  *                                                                                             *
     29  *                  Last Update : December 11, 1994 [JLB]                                      *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef TEAM_H
     36 #define TEAM_H
     37 
     38 #include	<wwfile.h>
     39 #include	"teamtype.h"
     40 #include	"abstract.h"
     41 
     42 /*
     43 ** Units are only allowed to stray a certain distance away from their
     44 ** team.  When they exceed this distance, some sort of fixup must be
     45 ** done.
     46 */
     47 #define STRAY_DISTANCE		2
     48 
     49 class TeamClass : public AbstractClass
     50 {
     51 #ifdef USE_RA_AI
     52 	friend class HouseClass;		       // Needed for RA AI moved into C&C. ST - 7/24/2019 2:44PM
     53 #endif // USE_RA_AI
     54 
     55 	public:
     56 		/*
     57 		**	This specifies the type of team this is.
     58 		*/
     59 		TeamTypeClass const * const Class;
     60 
     61 		/*
     62 		**	This specifies the owner of this team.
     63 		*/
     64 		HouseClass * const House;
     65 
     66 		/*
     67 		**	This flag forces the team into active state regardless of whether it
     68 		**	is understrength or not.
     69 		*/
     70 		unsigned IsForcedActive:1;
     71 
     72 		/*
     73 		**	This flag is set to true when the team initiates into active mode. The
     74 		**	flag is never cleared. By examining this flag, it is possible to determine
     75 		**	if the team has ever launched into active mode.
     76 		*/
     77 		unsigned IsHasBeen:1;
     78 
     79 		/*
     80 		**	If the team is full strength, then this flag is true. A full strength
     81 		**	team will not try to recruit members.
     82 		*/
     83 		unsigned IsFullStrength:1;
     84 
     85 		/*
     86 		**	A team that is below half strength has this flag true. It means that the
     87 		**	the team should hide back at the owner's base and try to recruit
     88 		**	members.
     89 		*/
     90 		unsigned IsUnderStrength:1;
     91 
     92 		/*
     93 		**	If a team is not understrength but is not yet full strength, then
     94 		**	the team is regrouping.  If this flag is set and the team becomes
     95 		**	full strength, the all members of the team will become initiated
     96 		** and this flag will be reset.
     97 		*/
     98 		unsigned IsReforming:1;
     99 
    100 		/*
    101 		** This bit should be set if a team is determined to have lagging
    102 		** units in its formation.
    103 		*/
    104 		unsigned IsLagging:1;
    105 
    106 	private:
    107 		/*
    108 		**	If a team member was removed or added, then this flag will be set to true. The
    109 		**	team system uses this flag to tell whether it should recalculate the team
    110 		**	under strength or full strength flags. This process does not need to occur
    111 		**	EVERY time a unit added or deleted from a team, just every so often if the
    112 		**	team has been changed.
    113 		*/
    114 		unsigned IsAltered:1;
    115 
    116 		/*
    117 		**	If the team is working on it's primary mission (it is past the build up stage)
    118 		**	then this flag will be true. The transition between "moving" and "stationary"
    119 		**	stages usually requires some action on the team's part.
    120 		*/
    121 		unsigned IsMoving:1;
    122 
    123 		/*
    124 		**	When the team determines that the next mission should be advanced to, it will
    125 		**	set this flag to true. Mission advance will either change the behavior of the
    126 		**	team or cause it to disband.
    127 		*/
    128 		unsigned IsNextMission:1;
    129 		/*
    130 		** Records whether the team is suspended from production.
    131 		*/
    132 		unsigned Suspended:1;
    133 
    134 	public:
    135 		/*
    136 		**	A team will have a center point. This is the point used to determine if
    137 		**	any member of the team is "too far" from the team and must return. This
    138 		**	center point is usually calculated as the average position of all the
    139 		**	team members.
    140 		*/
    141 		CELL Center;
    142 		CELL ObjectiveCenter;
    143 
    144 		/*
    145 		**	This is the target of the team. Typically, it is a unit or structure, but
    146 		**	for the case of teams with a movement mission, it might represent a
    147 		**	destination cell.
    148 		*/
    149 		TARGET MissionTarget;
    150 		TARGET Target;
    151 
    152 		/*
    153 		**	This is the total number of members in this team.
    154 		*/
    155 		int Total;
    156 
    157 		/*
    158 		**	This is the teams combined risk value
    159 		*/
    160 		int Risk;
    161 		/*
    162 		** This is the amount of time the team is suspended for.
    163 		*/
    164 		TCountDownTimerClass SuspendTimer;
    165 
    166 		//------------------------------------------------------------
    167 		TeamClass(void) : Class(0), House(0) {IsActive=false;Member=0;IsAltered=true;};
    168 		TeamClass(TeamTypeClass const * team, HouseClass * owner);
    169 		virtual ~TeamClass(void);
    170 		virtual RTTIType What_Am_I(void) const {return RTTI_TEAM;};
    171 		static void operator delete(void *ptr);
    172 		static void * operator new(size_t size);
    173 		static void Init(void);
    174 		static void Suspend_Teams(int priority);
    175 
    176 		TARGET As_Target(void) const;
    177 
    178 		/*
    179 		**	File I/O.
    180 		*/
    181 		bool  Load(FileClass & file);
    182 		bool  Save(FileClass & file);
    183 		void  Code_Pointers(void);
    184 		void  Decode_Pointers(void);
    185 
    186 		void  Force_Active(void) {IsForcedActive = true;IsUnderStrength=false;};
    187 		bool  Remove(FootClass *, int typeindex=-1);
    188 		void  Detach(TARGET target, bool all);
    189 		void  AI(void);
    190 		void  Took_Damage(FootClass * obj, ResultType result, TechnoClass * source);
    191 		bool  Add(FootClass *, int typeindex=-1);
    192 		void  Assign_Mission_Target(TARGET new_target);
    193 
    194 		/*
    195 		**	Dee-buggin' support.
    196 		*/
    197 		int Validate(void) const;
    198 
    199 		/*
    200 		**	This is a record of the current number of active teams of each
    201 		**	type. It can range from zero to MaxAllowed.
    202 		*/
    203 		static unsigned char Number[TEAMTYPE_MAX];
    204 
    205 	private:
    206 
    207 		/*
    208 		**	The current mission index into the mission list is recorded here.
    209 		*/
    210 		int CurrentMission;
    211 
    212 		/*
    213 		**	Some missions will time out. This is the timer that keeps track of the
    214 		**	time to transition between missions.
    215 		*/
    216 		TCountDownTimerClass TimeOut;
    217 
    218 		void  Coordinate_Unload(void);
    219 		bool  Coordinate_Regroup(void);
    220 		void  Coordinate_Attack(void);
    221 		void  Coordinate_Move(void);
    222 		void  Coordinate_Conscript(FootClass * unit);
    223 //		void Control(FootClass *, bool initial=false);
    224 		void  Calc_Center(CELL &center, CELL &obj_center) const;
    225 		int  Recruit(int typeindex);
    226 		bool  Is_A_Member(void const * who) const;
    227 		bool  Lagging_Units(void);
    228 
    229 		/*
    230 		**	Points to the first member in the list of members for this team.
    231 		*/
    232 		FootClass * Member;
    233 
    234 		unsigned char Quantity[TeamTypeClass::MAX_TEAM_CLASSCOUNT];
    235 
    236 		/*
    237 		** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
    238 		*/
    239 		unsigned char SaveLoadPadding[32];
    240 
    241 		/*
    242 		**	This records the success of each team type. As the team carries out its
    243 		**	mission, it increments this counter if it considers the mission
    244 		**	to have been successfully completed. Teams with greater success
    245 		**	will be created more than the others.
    246 		*/
    247 		static unsigned char Success[TEAMTYPE_MAX];
    248 
    249 		/*
    250 		** This contains the value of the Virtual Function Table Pointer
    251 		*/
    252 		static void * VTable;
    253 };
    254 
    255 #endif