FACTORY.H (6251B)
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\factory.h_v 2.17 16 Oct 1995 16:45:44 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 friend class DLLExportClass; // ST - 1/29/2019 11:04AM 43 44 public: 45 FactoryClass(void); 46 ~FactoryClass(void); 47 static void * operator new(size_t size); 48 static void operator delete(void *ptr); 49 50 static void Init(void); 51 52 /* 53 ** File I/O. 54 */ 55 bool Load(FileClass & file); 56 bool Save(FileClass & file); 57 void Code_Pointers(void); 58 void Decode_Pointers(void); 59 60 bool Abandon(void); 61 bool Completed(void); 62 bool Has_Changed(void); 63 bool Has_Completed(void); 64 bool Is_Building(void) const {return(Fetch_Rate() != 0);}; 65 bool Set(TechnoTypeClass const & object, HouseClass & house); 66 bool Set(int const & type, HouseClass & house); 67 bool Start(void); 68 bool Suspend(void); 69 int Completion(void); 70 TechnoClass * Get_Object(void) const; 71 int Get_Special_Item(void) const; 72 void AI(void); 73 void Set(TechnoClass & object); 74 HouseClass * Get_House(void) {return(House);}; 75 bool Is_Blocked(void) {return IsBlocked;} 76 void Set_Is_Blocked(bool set) {IsBlocked = set;} 77 78 /* 79 ** Dee-buggin' support. 80 */ 81 int Validate(void) const; 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 protected: 96 enum StepCountEnum { 97 STEP_COUNT=108 // Number of steps to break production down into. 98 }; 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_Chaged 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