BUILDING.H (12865B)
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/BUILDING.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 : BUILDING.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : April 14, 1994 * 28 * * 29 * Last Update : April 14, 1994 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 #ifndef BUILDING_H 36 #define BUILDING_H 37 38 #include "radio.h" 39 #include "cargo.h" 40 #include "mission.h" 41 #include "bullet.h" 42 #include "target.h" 43 #include "factory.h" 44 #include "techno.h" 45 46 #define MAX_DOOR_STAGE 18 // # of frames of door opening on weapons factory 47 #define DOOR_OPEN_STAGE 9 // frame on which the door is entirely open 48 #define MAX_REPAIR_ANIM_STAGE 5 // # of stages of anim for repair center cycling 49 50 /**************************************************************************** 51 ** For each instance of a building in the game, there is one of 52 ** these structures. This structure holds information that is specific 53 ** and dynamic for a particular building. 54 */ 55 class BuildingClass : public TechnoClass 56 { 57 public: 58 59 /* 60 ** This points to the control data that gives this building its characteristics. 61 */ 62 CCPtr<BuildingTypeClass> Class; 63 64 /* 65 ** If this building is in the process of producing something, then this 66 ** will point to the factory manager. 67 */ 68 CCPtr<FactoryClass> Factory; 69 70 /* 71 ** This is the house that originally owned this factory. Objects buildable 72 ** by this house type will be produced from this factory regardless of who 73 ** the current owner is. 74 */ 75 HousesType ActLike; 76 77 /* 78 ** This building should be rebuilt if it is destroyed. This is in spite 79 ** of the condition of the prebuilt base list. 80 */ 81 unsigned IsToRebuild:1; 82 83 /* 84 ** Is the building allowed to repair itself? 85 */ 86 unsigned IsToRepair:1; 87 88 /* 89 ** If the computer owns this building, then it is allowed to sell it if 90 ** the situation warrants it. In the other case, it cannot sell the 91 ** building regardless of conditions. 92 */ 93 unsigned IsAllowedToSell:1; 94 95 /* 96 ** If the building is at a good point to change orders, then this 97 ** flag will be set to true. 98 */ 99 unsigned IsReadyToCommence:1; 100 101 /* 102 ** If this building is currently spending money to repair itself, then 103 ** this flag is true. It will automatically be set to false when the building 104 ** has reached full strength, when money is exhausted, or if the player 105 ** specifically stops the repair process. 106 */ 107 unsigned IsRepairing:1; 108 109 /* 110 ** If repair is currently in progress and this flag is true, then a wrench graphic 111 ** will be overlaid on the building to give visual feedback for the repair process. 112 */ 113 unsigned IsWrenchVisible:1; 114 115 /* 116 ** This flag is set when a commando has raided the building and planted 117 ** plastic explosives. When the CommandoCountDown timer expires, the 118 ** building takes massive damage. 119 */ 120 unsigned IsGoingToBlow:1; 121 122 /* 123 ** If this building was destroyed by some method that would prevent 124 ** survivors, then this flag will be true. 125 */ 126 unsigned IsSurvivorless:1; 127 128 /* 129 ** These state control variables are used by the obelisk for the charging 130 ** animation. 131 */ 132 unsigned IsCharging:1; 133 unsigned IsCharged:1; 134 135 /* 136 ** A building that has been captured will not contain the full compliment 137 ** of crew. This is true even if it subsequently gets captured back. 138 */ 139 unsigned IsCaptured:1; 140 141 /* 142 ** Used by the gap generator to decide if it should jam or unjam 143 */ 144 unsigned IsJamming:1; 145 146 /* 147 ** Used by radar facilities to know if they're being jammed by a mobile 148 ** radar jammer 149 */ 150 unsigned IsJammed:1; 151 152 /* 153 ** Used only by advanced tech center, this keeps track of whether the 154 ** GPS satellite has been fired or not. 155 */ 156 unsigned HasFired:1; 157 158 /* 159 ** If Grand_Opening was already called for this building, then this 160 ** flag will be true. By utilizing this flag, multiple inadvertant 161 ** calls to Grand_Opening won't cause problems. 162 */ 163 unsigned HasOpened:1; 164 165 /* 166 ** Special countdown to destruction value. If the building is destroyed, 167 ** it won't actually be removed from the map until this value reaches 168 ** zero. This delay is for cosmetic reasons. 169 */ 170 CDTimerClass<FrameTimerClass> CountDown; 171 172 /* 173 ** This is the current animation processing state that the building is 174 ** in. 175 */ 176 BStateType BState; 177 BStateType QueueBState; 178 179 /* 180 ** For multiplayer games, this keeps track of the last house to damage 181 ** this building, so if it burns to death or otherwise gradually dies, 182 ** proper credit can be given for the kill. 183 */ 184 HousesType WhoLastHurtMe; 185 186 /* 187 ** This is the saboteur responsible for this building's destruction. 188 */ 189 TARGET WhomToRepay; 190 191 /* 192 ** This is a record of the last strength of the building. Every so often, 193 ** it will compare this strength to the current strength. If there is a 194 ** discrepancy, then the owner power is adjusted accordingly. 195 */ 196 int LastStrength; 197 198 /* 199 ** This is a target id of an animation we're keeping track of. Examples 200 ** of this usage are the advanced tech center, which needs to know 201 ** when the sputdoor animation has reached a certain stage. 202 */ 203 TARGET AnimToTrack; 204 205 /* 206 ** This is the countdown timer that regulates placement retry logic 207 ** for factory type buildings. 208 */ 209 CDTimerClass<FrameTimerClass> PlacementDelay; 210 211 /*--------------------------------------------------------------------- 212 ** Constructors, Destructors, and overloaded operators. 213 */ 214 static void * operator new(size_t size); 215 static void * operator new(size_t , void * ptr) {return(ptr);}; 216 static void operator delete(void *ptr); 217 BuildingClass(StructType type, HousesType house); 218 #ifdef FIXIT_MULTI_SAVE 219 BuildingClass(NoInitClass const & x) : TechnoClass(x), Class(x), Factory(x), CountDown(x), PlacementDelay(x) {}; 220 #else 221 BuildingClass(NoInitClass const & x) : TechnoClass(x), Class(x), CountDown(x), PlacementDelay(x) {}; 222 #endif 223 virtual ~BuildingClass(void); 224 operator StructType(void) const {return Class->Type;}; 225 226 /*--------------------------------------------------------------------- 227 ** Member function prototypes. 228 */ 229 static void Init(void); 230 231 TARGET Target_Scan(void); 232 BuildingTypeClass::AnimControlType const * Fetch_Anim_Control(void) {return (&Class->Anims[BState]);}; 233 234 /* 235 ** Query functions. 236 */ 237 virtual int Value(void) const; 238 virtual void const * Get_Image_Data(void) const; 239 virtual int How_Many_Survivors(void) const; 240 virtual DirType Turret_Facing(void) const; 241 virtual CELL Find_Exit_Cell(TechnoClass const * techno) const; 242 virtual InfantryType Crew_Type(void) const; 243 virtual int Pip_Count(void) const; 244 virtual bool Can_Player_Move(void) const; 245 virtual ActionType What_Action(ObjectClass const * target) const; 246 virtual ActionType What_Action(CELL cell) const; 247 virtual bool Can_Demolish(void) const; 248 virtual bool Can_Demolish_Unit(void) const; 249 virtual bool Can_Capture(void) const; 250 virtual ObjectTypeClass const & Class_Of(void) const {return *Class;}; 251 virtual DirType Fire_Direction(void) const; 252 virtual short const * Overlap_List(bool redraw=false) const; 253 int Shape_Number(void) const; 254 int Power_Output(void) const; 255 CELL Check_Point(CheckPointType cp) const; 256 257 /* 258 ** Coordinate inquiry functions. These are used for both display and 259 ** combat purposes. 260 */ 261 virtual COORDINATE Target_Coord(void) const; 262 virtual COORDINATE Docking_Coord(void) const; 263 virtual COORDINATE Center_Coord(void) const; 264 virtual COORDINATE Sort_Y(void) const; 265 virtual COORDINATE Exit_Coord(void) const; 266 267 /* 268 ** Object entry and exit from the game system. 269 */ 270 virtual void Detach(TARGET target, bool all); 271 virtual void Detach_All(bool all=true); 272 virtual void Grand_Opening(bool captured = false); 273 virtual void Update_Buildables(void); 274 virtual MoveType Can_Enter_Cell(CELL cell, FacingType = FACING_NONE) const; 275 virtual bool Unlimbo(COORDINATE , DirType dir = DIR_N); 276 virtual bool Limbo(void); 277 278 /* 279 ** Display and rendering support functionality. Supports imagery and how 280 ** object interacts with the map and thus indirectly controls rendering. 281 */ 282 virtual void const * Remap_Table(void); 283 virtual int Exit_Object(TechnoClass * base); 284 virtual void Draw_It(int x, int y, WindowNumberType window) const; 285 virtual bool Mark(MarkType mark=MARK_CHANGE); 286 virtual void Fire_Out(void); 287 void Begin_Mode(BStateType bstate); 288 289 /* 290 ** User I/O. 291 */ 292 virtual void Active_Click_With(ActionType action, ObjectClass * object); 293 virtual void Active_Click_With(ActionType action, CELL cell); 294 295 /* 296 ** Combat related. 297 */ 298 virtual void Death_Announcement(TechnoClass const * source=0) const; 299 virtual FireErrorType Can_Fire(TARGET, int which) const; 300 virtual TARGET Greatest_Threat(ThreatType threat) const; 301 virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false); 302 virtual bool Captured(HouseClass * newowner); 303 void Update_Radar_Spied(void); 304 305 /* 306 ** AI. 307 */ 308 void Charging_AI(void); 309 void Rotation_AI(void); 310 void Factory_AI(void); 311 void Repair_AI(void); 312 void Animation_AI(void); 313 virtual bool Revealed(HouseClass * house); 314 virtual void Repair(int control); 315 virtual void Sell_Back(int control); 316 virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param); 317 virtual void AI(void); 318 virtual void Assign_Target(TARGET target); 319 virtual bool Toggle_Primary(void); 320 bool Flush_For_Placement(TechnoClass * techno, CELL cell); 321 322 virtual int Mission_Unload(void); 323 virtual int Mission_Repair(void); 324 virtual int Mission_Attack(void); 325 virtual int Mission_Harvest(void); 326 virtual int Mission_Guard(void); 327 virtual int Mission_Construction(void); 328 virtual int Mission_Deconstruction(void); 329 virtual int Mission_Missile(void); 330 virtual void Enter_Idle_Mode(bool initial=false); 331 void Remove_Gap_Effect(void); 332 333 /* 334 ** Scenario and debug support. 335 */ 336 #ifdef CHEAT_KEYS 337 virtual void Debug_Dump(MonoClass *mono) const; 338 #endif 339 340 /* 341 ** File I/O. 342 */ 343 static void Read_INI(CCINIClass & ini); 344 static void Write_INI(CCINIClass & ini); 345 static char *INI_Name(void) {return "STRUCTURES";}; 346 bool Load(Straw & file); 347 bool Save(Pipe & file) const; 348 349 virtual unsigned Spied_By() const; 350 351 private: 352 void Drop_Debris(TARGET source = TARGET_NONE); 353 354 /* 355 ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load 356 */ 357 unsigned char SaveLoadPadding[32]; 358 359 static COORDINATE const CenterOffset[BSIZE_COUNT]; 360 }; 361 362 #endif