FACTORY.H 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /CounterStrike/FACTORY.H 1 3/03/97 10:24a Joe_bostic $ */
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : FACTORY.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 12/26/94 *
  30. * *
  31. * Last Update : December 26, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef FACTORY_H
  37. #define FACTORY_H
  38. #include "stage.h"
  39. class FactoryClass : private StageClass
  40. {
  41. public:
  42. RTTIType RTTI;
  43. int ID;
  44. FactoryClass(void);
  45. FactoryClass(NoInitClass const & x) : StageClass(x) {};
  46. ~FactoryClass(void);
  47. static void * operator new(size_t size);
  48. static void * operator new(size_t , void * ptr) {return(ptr);};
  49. static void operator delete(void *ptr);
  50. static void Init(void);
  51. /*
  52. ** File I/O.
  53. */
  54. bool Load(Straw & file);
  55. bool Save(Pipe & file) const;
  56. void Code_Pointers(void);
  57. void Decode_Pointers(void);
  58. bool Abandon(void);
  59. bool Completed(void);
  60. bool Has_Changed(void);
  61. bool Has_Completed(void);
  62. bool Is_Building(void) const {return(Fetch_Rate() != 0);};
  63. bool Set(TechnoTypeClass const & object, HouseClass & house);
  64. bool Set(int const & type, HouseClass & house);
  65. bool Start(void);
  66. bool Suspend(void);
  67. int Completion(void);
  68. TechnoClass * Get_Object(void) const;
  69. int Get_Special_Item(void) const;
  70. void AI(void);
  71. void Set(TechnoClass & object);
  72. HouseClass * Get_House(void) {return(House);};
  73. char const * Name(void) {return("Factory");}
  74. /*
  75. ** This flag is used to maintain the pool of factory class objects. If the object has
  76. ** been allocated, then this flag is true. Otherwise, the object is free to be
  77. ** allocated.
  78. */
  79. unsigned IsActive:1;
  80. enum StepCountEnum {
  81. STEP_COUNT=54 // Number of steps to break production down into.
  82. };
  83. protected:
  84. int Cost_Per_Tick(void);
  85. private:
  86. /*
  87. ** If production is temporarily suspended, then this flag will be true. A factory
  88. ** is suspended when it is first created, when production has completed, and when
  89. ** explicitly instructed to Suspend() production. Suspended production is not
  90. ** abandoned. It may be resumed with a call to Start().
  91. */
  92. unsigned IsSuspended:1;
  93. /*
  94. ** If the AI process detected that the production process has advanced far enough
  95. ** that a change in the building animation would occur, this flag will be true.
  96. ** Examination of this flag (through the Has_Changed function) allows intelligent
  97. ** updating of any production graphic.
  98. */
  99. unsigned IsDifferent:1;
  100. /*
  101. ** This records the balance due on the current production item. This value will
  102. ** be reduced as production proceeds. It will reach zero the moment production has
  103. ** finished. Using this method ensures that the total production cost will be EXACT
  104. ** regardless of the number of installment payments that are made.
  105. */
  106. int Balance;
  107. int OriginalBalance;
  108. /*
  109. ** This is the object that is being produced. It is held in a state of limbo while
  110. ** undergoing production. Since the object is created at the time production is
  111. ** started, it is always available when production completes.
  112. */
  113. TechnoClass * Object;
  114. /*
  115. ** If the factory is not producing an object and is instead producing
  116. ** a special item, then special item will be set.
  117. */
  118. int SpecialItem;
  119. /*
  120. ** The factory has to be doing production for one house or another.
  121. ** The house pointer will point to whichever house it is being done
  122. ** for.
  123. */
  124. HouseClass * House;
  125. };
  126. #endif