Clone of UAS2 @ https://github.com/drudgedance/uas2

cItemModels.h 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /*
  2. * This file is part of UAS2.
  3. *
  4. * UAS2 is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * UAS2 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. * You should have received a copy of the GNU General Public License
  14. * along with UASv1; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. /**
  18. * @file cItemModels.h
  19. */
  20. #define ITEM_MODEL_TABLE_SIZE 4000
  21. #if _MSC_VER > 1000
  22. #pragma once
  23. #endif // _MSC_VER > 1000
  24. #include <winsock2.h>
  25. #include "shared.h"
  26. class cItemModels
  27. {
  28. friend class cMasterServer;
  29. friend class cObject;
  30. friend class cWeapon;
  31. public:
  32. cItemModels( DWORD dwModelID, BOOL fAddToHash = TRUE )
  33. : m_dwModelID( dwModelID ),
  34. m_pcPrev ( NULL ),
  35. m_pcNext ( NULL )
  36. {
  37. if( fAddToHash )
  38. Hash_Add( this );
  39. }
  40. virtual ~cItemModels()
  41. {
  42. if ( m_pcPrev ) m_pcPrev->m_pcNext = m_pcNext;
  43. else m_lpcHashTable[m_dwModelID] = m_pcNext;
  44. if ( m_pcNext ) m_pcNext->m_pcPrev = m_pcPrev;
  45. }
  46. static inline void Hash_Load( )
  47. {
  48. ZeroMemory( m_lpcHashTable, sizeof( m_lpcHashTable ) );
  49. }
  50. static inline cItemModels *Hash_New( DWORD& dwModelID )
  51. {
  52. cItemModels *pcModel = Hash_Find( dwModelID );
  53. if ( pcModel )
  54. return pcModel;
  55. return new cItemModels( dwModelID ) ;
  56. }
  57. static void Hash_Erase ( );
  58. static void Hash_Remove ( cItemModels *pcModel );
  59. static cItemModels *FindModel ( DWORD dwModelID );
  60. bool m_clothingModelLoaded;
  61. std::string m_strName;
  62. std::string m_strDescription;
  63. DWORD m_PortalLinker;
  64. DWORD m_dwModelID;
  65. // Model vectors
  66. BYTE m_bPaletteChange;
  67. DWORD m_wPaletteVector;
  68. sPaletteChange m_vectorPal[255];
  69. BYTE m_bTextureChange;
  70. DWORD m_wTextureVector;
  71. sTextureChange m_vectorTex[255];
  72. BYTE m_bModelChange;
  73. DWORD m_wModelVector;
  74. sModelChange m_vectorMod[255];
  75. // Model clothing vectors
  76. BYTE m_bWearPaletteChange;
  77. DWORD m_wWearPaletteVector;
  78. sPaletteChange m_WearVectorPal[255];
  79. BYTE m_bWearTextureChange;
  80. DWORD m_wWearTextureVector;
  81. sTextureChange m_WearVectorTex[255];
  82. BYTE m_bWearModelChange;
  83. DWORD m_wWearModelVector;
  84. sModelChange m_WearVectorMod[255];
  85. WORD m_wPortalMode;
  86. WORD m_wUnknown_1;
  87. DWORD m_dwUnknownCount;
  88. DWORD m_dwUnknownDword;
  89. DWORD m_dwUnknown;
  90. WORD m_wSeagreen8;
  91. WORD m_wSeagreen10;
  92. WORD m_wModel;
  93. WORD m_wIcon;
  94. WORD m_wSoundSet;
  95. DWORD m_dwModelNumber;
  96. DWORD m_dwObjectFlags1;
  97. DWORD m_dwObjectFlags2;
  98. DWORD m_dwFlags1;
  99. DWORD m_dwFlags2;
  100. WORD m_wUnknown1;
  101. DWORD m_dwUnknown_Blue;
  102. float m_flScale;
  103. DWORD m_dwUnknown_LightGrey;
  104. DWORD m_dwTrio1[3];
  105. DWORD m_dwTrio2[3];
  106. DWORD m_dwTrio3[3];
  107. DWORD m_dwMedGrey;
  108. DWORD m_dwBlueGrey;
  109. DWORD m_dwUnknown_v2;
  110. DWORD m_dwUnknown_v6;
  111. //Item specific values
  112. DWORD m_dwValue;
  113. DWORD m_dwUseableOn;
  114. float m_fApproachDistance;
  115. DWORD m_dwIconHighlight;
  116. WORD m_wAmmoType;
  117. BYTE m_bWieldType;
  118. WORD m_wUses;
  119. WORD m_wUseLimit;
  120. WORD m_wStack;
  121. WORD m_wStackLimit;
  122. DWORD m_dwContainerID;
  123. DWORD m_dwVitalID;
  124. DWORD m_dwEquipPossible;
  125. DWORD m_dwEquipActual;
  126. DWORD m_dwCoverage;
  127. float m_fWorkmanship;
  128. WORD m_wBurden;
  129. DWORD m_dwSpellID;
  130. //For scrolls
  131. WORD m_wSpellID;
  132. DWORD m_dwOwner;
  133. WORD m_wHooks;
  134. DWORD m_dwMaterialType;
  135. DWORD m_dwQuestItemID;
  136. UINT m_vital_affect;
  137. int m_ItemType;
  138. //Armor
  139. DWORD m_dwArmor_Level;
  140. float m_fProt_Slashing;
  141. float m_fProt_Piercing;
  142. float m_fProt_Bludgeon;
  143. float m_fProt_Fire;
  144. float m_fProt_Cold;
  145. float m_fProt_Acid;
  146. float m_fProt_Electric;
  147. //Weapons
  148. DWORD m_dwWeaponDamage;
  149. DWORD m_dwWeaponSpeed;
  150. DWORD m_dwWeaponSkill;
  151. DWORD m_dwDamageType;
  152. double m_dWeaponVariance;
  153. double m_dWeaponModifier;
  154. double m_dWeaponPower;
  155. double m_dWeaponAttack;
  156. int m_isContainer;
  157. int m_isClothing;
  158. int m_isUAWeapon;
  159. //Books
  160. DWORD m_ContentPages;
  161. DWORD m_UsedPages;
  162. DWORD m_TotalPages;
  163. std::string m_Author;
  164. std::string m_Title;
  165. std::string m_Comment;
  166. std::string m_CommentAuthor;
  167. typedef struct Pages
  168. {
  169. std::string textPages;
  170. };
  171. Pages m_Pages[50];
  172. /*
  173. std::string m_Page1;
  174. std::string m_Page2;
  175. std::string m_Page3;
  176. std::string m_Page4;
  177. std::string m_Page5;
  178. std::string m_Page6;
  179. std::string m_Page7;
  180. std::string m_Page8;
  181. std::string m_Page9;
  182. */
  183. // Animation Arrays
  184. cItemModels *m_pcNext;
  185. cItemModels *m_pcPrev;
  186. std::list< cItemModels * > m_lstModels;
  187. private:
  188. static cItemModels *m_lpcHashTable[ITEM_MODEL_TABLE_SIZE];
  189. static inline Hash_Add( cItemModels *pcItemModels )
  190. {
  191. const DWORD dwModelID = pcItemModels->m_dwModelID;
  192. if ( !m_lpcHashTable[dwModelID] )
  193. m_lpcHashTable[dwModelID] = pcItemModels;
  194. else
  195. {
  196. pcItemModels->m_pcNext = m_lpcHashTable[dwModelID];
  197. m_lpcHashTable[dwModelID]->m_pcPrev = pcItemModels;
  198. m_lpcHashTable[dwModelID] = pcItemModels;
  199. }
  200. }
  201. static inline cItemModels *Hash_Find( DWORD& dwModelID )
  202. {
  203. const DWORD dwModel = dwModelID;
  204. cItemModels *pcItemModels = m_lpcHashTable[dwModel];
  205. while ( pcItemModels )
  206. {
  207. if ( pcItemModels->CompareModel( dwModelID ) ) return pcItemModels;
  208. else
  209. pcItemModels = pcItemModels->m_pcNext;
  210. }
  211. return NULL;
  212. }
  213. inline BOOL CompareModel( DWORD& dwModelID )
  214. {
  215. if ( dwModelID == m_dwModelID )
  216. return true;
  217. else
  218. return false;
  219. }
  220. };