CnC_Remastered_Collection

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

FACTORY.H (6280B)


      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/FACTORY.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 : FACTORY.H                                                    *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 12/26/94                                                     *
     28  *                                                                                             *
     29  *                  Last Update : December 26, 1994 [JLB]                                      *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef FACTORY_H
     36 #define FACTORY_H
     37 
     38 #include	"stage.h"
     39 
     40 class FactoryClass : private StageClass
     41 {
     42 	public:
     43 		RTTIType RTTI;
     44 		int ID;
     45 
     46 
     47 		FactoryClass(void);
     48 		FactoryClass(NoInitClass const & x) : StageClass(x) {};
     49 		~FactoryClass(void);
     50 		static void * operator new(size_t size);
     51 		static void * operator new(size_t , void * ptr) {return(ptr);};
     52 		static void operator delete(void *ptr);
     53 
     54 		static void Init(void);
     55 
     56 		/*
     57 		**	File I/O.
     58 		*/
     59 		bool Load(Straw & file);
     60 		bool Save(Pipe & file) const;
     61 		void Code_Pointers(void);
     62 		void Decode_Pointers(void);
     63 
     64 		bool Abandon(void);
     65 		bool Completed(void);
     66 		bool Has_Changed(void);
     67 		bool Has_Completed(void);
     68 		bool Is_Building(void) const {return(Fetch_Rate() != 0);};
     69 		bool Set(TechnoTypeClass const & object, HouseClass & house);
     70 		bool Set(int const & type, HouseClass & house);
     71 		bool Start(void);
     72 		bool Suspend(void);
     73 		int Completion(void);
     74 		TechnoClass * Get_Object(void) const;
     75 		int Get_Special_Item(void) const;
     76 		void AI(void);
     77 		void Set(TechnoClass & object);
     78 		HouseClass * Get_House(void) {return(House);};
     79 		char const * Name(void) {return("Factory");}
     80 		bool Is_Blocked(void) {return IsBlocked;}
     81 		void Set_Is_Blocked(bool set) {IsBlocked = set;}
     82 
     83 		/*
     84 		** Added for debugging / testing. ST - 8/23/2019 3:52PM
     85 		*/
     86 		void Force_Complete(void);
     87 
     88 		/*
     89 		**	This flag is used to maintain the pool of factory class objects. If the object has
     90 		**	been allocated, then this flag is true. Otherwise, the object is free to be
     91 		**	allocated.
     92 		*/
     93 		unsigned IsActive:1;
     94 
     95 		enum StepCountEnum {
     96 			STEP_COUNT=54			// Number of steps to break production down into.
     97 		};
     98 	protected:
     99 
    100 		int Cost_Per_Tick(void);
    101 
    102 	private:
    103 
    104 		/*
    105 		**	If production is temporarily suspended, then this flag will be true. A factory
    106 		**	is suspended when it is first created, when production has completed, and when
    107 		**	explicitly instructed to Suspend() production. Suspended production is not
    108 		**	abandoned. It may be resumed with a call to Start().
    109 		*/
    110 		unsigned IsSuspended:1;
    111 
    112 		/*
    113 		**	If the AI process detected that the production process has advanced far enough
    114 		**	that a change in the building animation would occur, this flag will be true.
    115 		**	Examination of this flag (through the Has_Changed function) allows intelligent
    116 		**	updating of any production graphic.
    117 		*/
    118 		unsigned IsDifferent:1;
    119 
    120 		/*
    121 		** The exit from the factory is blocked by something, which means a unit is prevented from exiting after construction
    122 		** has completed. ST - 2/25/2020 11:29AM
    123 		*/
    124 		unsigned IsBlocked:1;
    125 
    126 		/*
    127 		**	This records the balance due on the current production item. This value will
    128 		**	be reduced as production proceeds. It will reach zero the moment production has
    129 		**	finished. Using this method ensures that the total production cost will be EXACT
    130 		**	regardless of the number of installment payments that are made.
    131 		*/
    132 		int Balance;
    133 		int OriginalBalance;
    134 
    135 		/*
    136 		**	This is the object that is being produced. It is held in a state of limbo while
    137 		**	undergoing production. Since the object is created at the time production is
    138 		**	started, it is always available when production completes.
    139 		*/
    140 		TechnoClass * Object;
    141 
    142 		/*
    143 		**	If the factory is not producing an object and is instead producing
    144 		** a special item, then special item will be set.
    145 		*/
    146 		int SpecialItem;
    147 
    148 		/*
    149 		** The factory has to be doing production for one house or another.
    150 		** The house pointer will point to whichever house it is being done
    151 		** for.
    152 		*/
    153 		HouseClass  * House;
    154 
    155 		/*
    156 		** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
    157 		*/
    158 		unsigned char SaveLoadPadding[32];
    159 };
    160 
    161 #endif