StockPile.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // StockPile.H
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 06/03/97 JMI Started.
  23. //
  24. // 06/06/97 JMI Added Add(), Union(), Intersect(), and Copy() functions.
  25. //
  26. // 06/11/97 JMI Added Zero().
  27. //
  28. // 06/12/97 JMI Added weapon values.
  29. //
  30. // 06/14/97 JMI Added m_sKevlarLayers.
  31. //
  32. // 06/15/97 JMI Added m_sBackpack, maximums, and Truncate().
  33. //
  34. // 07/15/97 JMI Added Sub().
  35. //
  36. // 07/15/97 JMI Transferred powerup index enums into CStockPile.
  37. // Also, added GetItem(). See proto for details.
  38. //
  39. // 07/16/97 JMI Moved IsEmpty() from powerup to stockpile.
  40. //
  41. // 07/19/97 JMI Added optional child GUI param to UserEdit().
  42. //
  43. // 07/23/97 JMI Added separate launcher for napalm.
  44. //
  45. // 07/30/97 JMI Added DeathWadLauncher.
  46. // Made pstockpile inputs to functions const. This caused
  47. // some silly stupidity in GetItem() calls but I just casted
  48. // it away b/c the stockpile was not being modified.
  49. //
  50. // 08/07/97 JMI Added DoubleBarrel.
  51. //
  52. // 12/08/97 JMI Added GetWeapon() that takes a CDude::WeaponType enum
  53. // to index into the stockpile.
  54. //
  55. //////////////////////////////////////////////////////////////////////////////
  56. //
  57. // This represents a character's stockpile of weapons and health.
  58. //
  59. //////////////////////////////////////////////////////////////////////////////
  60. #ifndef STOCKPILE_H
  61. #define STOCKPILE_H
  62. //////////////////////////////////////////////////////////////////////////////
  63. // C Headers -- Must be included before RSPiX.h b/c RSPiX utilizes SHMalloc.
  64. //////////////////////////////////////////////////////////////////////////////
  65. ///////////////////////////////////////////////////////////////////////////////
  66. // RSPiX Headers.
  67. ///////////////////////////////////////////////////////////////////////////////
  68. #include "RSPiX.h"
  69. //////////////////////////////////////////////////////////////////////////////
  70. // Macros.
  71. //////////////////////////////////////////////////////////////////////////////
  72. //////////////////////////////////////////////////////////////////////////////
  73. // Protos.
  74. //////////////////////////////////////////////////////////////////////////////
  75. //////////////////////////////////////////////////////////////////////////////
  76. // Typedefs.
  77. //////////////////////////////////////////////////////////////////////////////
  78. class CStockPile
  79. {
  80. ///////////////////////////////////////////////////////////////////////////
  81. // Macros.
  82. ///////////////////////////////////////////////////////////////////////////
  83. public:
  84. // Use this to enumerate the stockpile through GetItem().
  85. typedef enum
  86. {
  87. Bullets,
  88. Grenades,
  89. Cocktails,
  90. Rockets,
  91. Napalm,
  92. Shells,
  93. Fuel,
  94. #if 0
  95. ProximityMine,
  96. TimedMine,
  97. RemoteMine,
  98. BouncingBettyMine,
  99. #else
  100. Mines,
  101. #endif
  102. Health,
  103. Heatseekers,
  104. MachineGun,
  105. MissileLauncher,
  106. ShotGun,
  107. SprayCannon,
  108. FlameThrower,
  109. NapalmLauncher,
  110. DeathWadLauncher,
  111. DoubleBarrel,
  112. KevlarVest,
  113. Backpack,
  114. NumStockPileItems
  115. };
  116. ///////////////////////////////////////////////////////////////////////////
  117. // Con/Destruction.
  118. ///////////////////////////////////////////////////////////////////////////
  119. public:
  120. #if 0 // By not having a constructor, virtual funcs, and a base class we
  121. // become aggregate and can, therefore, be initialized with an initializer
  122. // list. Don't forget to Zero() this since the constructor won't!
  123. CStockPile()
  124. {
  125. Zero();
  126. }
  127. ~CStockPile()
  128. {
  129. }
  130. #endif
  131. ///////////////////////////////////////////////////////////////////////////
  132. // Methods.
  133. ///////////////////////////////////////////////////////////////////////////
  134. public:
  135. // Allow user to edit the stockpile.
  136. short UserEdit( // Returns 0 on success.
  137. RGuiItem* pgui = NULL); // In: Optional child GUI to be placed at
  138. // botom of Stockpile GUI.
  139. // Save stockpile to the specified file.
  140. short Save( // Returns 0 on success.
  141. RFile* pfile); // In: File to save to.
  142. // Load stockpile from the specified file.
  143. short Load( // Returns 0 on success.
  144. RFile* pfile, // In: File to load from.
  145. ULONG ulVersion); // In: File version to load.
  146. // Add another stockpile to this one.
  147. void Add( // Returns nothing.
  148. const CStockPile* pstockpile); // In: Stockpile to add to this one.
  149. // Subtract another stockpile from this one.
  150. void Sub( // Returns nothing.
  151. const CStockPile* pstockpile); // In: Stockpile to sub from this one.
  152. // Combine specified stockpile and this stockpile into this one
  153. // using maximum extents from either.
  154. void Union( // Returns nothing.
  155. const CStockPile* pstockpile); // In: Stockpile to combine into this one.
  156. // Combine specified stockpile and this stockpile into this one
  157. // using minimum extents from either.
  158. void Intersect( // Returns nothing.
  159. const CStockPile* pstockpile); // In: Stockpile to combine into this one.
  160. // Copy the specified stockpile over this one.
  161. void Copy( // Returns nothing.
  162. const CStockPile* pstockpile); // In: Stockpile to copy from.
  163. // Zero the stockpile.
  164. void Zero(void); // Returns nothing.
  165. // Truncate based on maximums that can be carried.
  166. // Note that this varies based on m_sBackpack.
  167. void Truncate(void); // Returns nothing.
  168. // Index by the StockPileItem you are interested in.
  169. short& GetItem( // Returns a reference to the indexed item.
  170. short sIndex); // In: The item index.
  171. // Index by the CDude::WeaponType you are interested in.
  172. short& GetWeapon( // Returns a reference to the indexed item.
  173. short sIndex); // In: The item index.
  174. // Determine if this stockpile is empty.
  175. bool IsEmpty(void); // Returns true, if the stockpile is
  176. // empty.
  177. ///////////////////////////////////////////////////////////////////////////
  178. // Querries.
  179. ///////////////////////////////////////////////////////////////////////////
  180. public:
  181. ///////////////////////////////////////////////////////////////////////////
  182. // Instantiable data.
  183. ///////////////////////////////////////////////////////////////////////////
  184. public:
  185. // *********************************************************************
  186. // *********************************************************************
  187. // PLEASE, PLEASE, PLEASE, use short type only for members of this
  188. // class!!!! Otherwise, GetItem() won't work for that item.
  189. // *********************************************************************
  190. // *********************************************************************
  191. short m_sHitPoints; // Health status.
  192. short m_sNumGrenades; // How many grenades dude has.
  193. short m_sNumFireBombs; // How many firebombs dude has.
  194. short m_sNumMissiles; // How many missiles dude has.
  195. short m_sNumNapalms; // How many napalms dude has.
  196. short m_sNumBullets; // How many bullets dude has.
  197. short m_sNumShells; // How many shotgun shells dude has.
  198. short m_sNumFuel; // How much fuel dude has.
  199. short m_sNumMines; // How many mines dude has.
  200. short m_sNumHeatseekers; // How many heatseekers dude has.
  201. short m_sMachineGun; // 0 if no machine gun, nonzero otherwise.
  202. short m_sMissileLauncher; // 0 if no missile launcher, nonzero otherwise.
  203. short m_sShotGun; // 0 if no shotgun, nonzero otherwise.
  204. short m_sSprayCannon; // 0 if no spray cannon, nonzero otherwise.
  205. short m_sFlameThrower; // 0 if no flame thrower, nonzero otherwise.
  206. short m_sNapalmLauncher; // 0 if no napalm launcher, nonzero otherwise.
  207. short m_sDeathWadLauncher; // 0 if no deathwad launcher, nonzero otherwise.
  208. short m_sDoubleBarrel; // 0 if no double barrel, nonzero otherwise.
  209. short m_sKevlarLayers; // 0 .. n layers of 'armor'.
  210. short m_sBackpack; // 0 if no backpack, nonzero otherwise.
  211. ///////////////////////////////////////////////////////////////////////////
  212. // Static data.
  213. ///////////////////////////////////////////////////////////////////////////
  214. public:
  215. static CStockPile ms_stockpileMax; // Maximum one can carry
  216. // w/o a backpack.
  217. static CStockPile ms_stockpileBackPackMax; // Maximum one can carry
  218. // with a backpack.
  219. static short ms_sEnableDeathWad; // Enable the death wad
  220. // check box.
  221. static short ms_sEnableDoubleBarrel; // Enable the double barrel
  222. // check box.
  223. };
  224. #endif // STOCKPILE_H
  225. //////////////////////////////////////////////////////////////////////////////
  226. // EOF
  227. //////////////////////////////////////////////////////////////////////////////