FACTORY.H 6.1 KB

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