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

Shared.h 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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 Shared.h
  19. * Defines shared structures and variables.
  20. */
  21. #ifndef __SHARED_H
  22. #define __SHARED_H
  23. #pragma once
  24. #include <winsock2.h>
  25. #include <time.h>
  26. #include <list>
  27. #include <math.h>
  28. #define WM_CLEAROBJECTS WM_APP+1
  29. #define MAX_PACKET_SIZE 0x1E4
  30. #define MAX_FRAGMENT_SIZE 0x1D0
  31. #define MAX_DATA_SIZE 0x1C0
  32. #define MAX_CORPSES 1000
  33. #define MAX_MONSTERS 5000
  34. #define MAX_PETS 5000
  35. #define DELAY 120
  36. #define CORPSE_DELAY 60
  37. #define ACTION_DELAY 1
  38. #define TICKS_PER_SEC 10
  39. #define MAX_LEVEL 126
  40. //Allegiance
  41. #define OLD_PASSUP true // XP share based upon number of fellows (vassal factor)
  42. #define PASSED_XP_MULT 1 // XP passup multiplier
  43. #define RECEIVED_XP_MULT 1 // XP reception multiplier
  44. #define MAX_VASSALS 12 // maximum number of vassals
  45. #define MAX_RANK 10 // maximum rank
  46. //Fellowship
  47. #define OLD_PASSTHROUGH true // XP share based upon number of fellows (fellow factor)
  48. #define SHARED_XP_MULT 1 // XP sharing multiplier
  49. #define OLD_FELLOW_RANGE true // maximum distance for 100% XP share
  50. #define FELLOW_RANGE_MULT 1 // XP share distance multiplier
  51. #define MAX_FELLOW_SIZE 9 // maximum number of fellows
  52. #ifdef _DEBUG
  53. #define SAFEDELETE( p ) \
  54. { \
  55. try { \
  56. delete (p); \
  57. (p) = NULL; \
  58. } \
  59. catch ( ... ) { \
  60. UpdateConsole( "\r\n Bad deletion attempt detected at %s %lu!!\r\n", __FILE__, __LINE__ ); \
  61. } \
  62. }
  63. #else
  64. #define SAFEDELETE( p ) \
  65. { \
  66. delete (p); \
  67. (p) = NULL; \
  68. }
  69. #endif
  70. #ifdef _DEBUG
  71. #define SAFEDELETE_ARRAY( a ) \
  72. { \
  73. try { \
  74. delete[] (a); \
  75. (a) = NULL; \
  76. } \
  77. catch ( ... ) { \
  78. UpdateConsole( "\r\n Bad array deletion attempt detected at %s %lu!!\r\n", __FILE__, __LINE__ ); \
  79. } \
  80. }
  81. #else
  82. #define SAFEDELETE_ARRAY( a ) \
  83. { \
  84. delete[] (a); \
  85. (a) = NULL; \
  86. }
  87. #endif
  88. #define CHECKRETURN(ExitOnError, hType, hName, ReturnOnError) \
  89. if (!(retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO || retcode == SQL_NO_DATA)) \
  90. { \
  91. UpdateConsole( " <SQL> %s: Error on line %lu: ", __FILE__, __LINE__ );\
  92. cDatabase::GetError(hType, &hName); \
  93. if (ExitOnError) \
  94. { \
  95. UpdateConsole(" <SQL> Function has been aborted.\r\n"); \
  96. /*return ReturnOnError; */ \
  97. } \
  98. else \
  99. UpdateConsole(" <SQL> Function has been continued normally.\r\n"); \
  100. }
  101. class cClient;
  102. typedef std::list< cClient * >::iterator iterClient_lst;
  103. class cObject;
  104. typedef std::list< cObject * >::iterator iterObject_lst;
  105. class cModels;
  106. typedef std::list< cModels * >::iterator iterModel_lst;
  107. class cMagicModels;
  108. typedef std::list< cMagicModels * >::iterator iterMagicModel_lst;
  109. class cEnchantment;
  110. typedef std::list< cEnchantment * >::iterator iterEnchantment_lst;
  111. class cNPC;
  112. typedef std::list< cNPC * >::iterator iterNPCs_lst;
  113. #pragma pack( push, 1 )
  114. typedef struct
  115. {
  116. DWORD m_dwSequence; //! 0x00 - 0x03
  117. DWORD m_dwFlags; //! 0x04 - 0x07
  118. DWORD m_dwCRC; //! 0x08 - 0x0B
  119. WORD m_wLogicalID; //! 0x0C - 0x0D
  120. WORD m_wTime; //! 0x0E - 0x0F
  121. WORD m_wTotalSize; //! 0x10 - 0x11
  122. WORD m_wTable; //! 0x12 - 0x13
  123. } cTransportHeader;
  124. typedef struct
  125. {
  126. DWORD m_dwSequence; //! Sequence/ID - Identifier used to match fragmented messages together.
  127. DWORD m_dwObjectID; //! Flags - Bitmask with an unknown purpose. Always 0x80000000?
  128. WORD m_wFragmentCount; //! Count - The number of fragments required to complete this message.
  129. WORD m_wFragmentLength; //! Size - Number of bytes in this fragment, including the fragment header.
  130. WORD m_wFragmentIndex; //! Index - Fragment index. Used to order the message data from the fragment.
  131. WORD m_wFragmentGroup; //! Group - Message group identifier. Message groups signify the message types.
  132. } cFragmentHeader;
  133. #pragma pack( pop )
  134. #pragma pack( push, 1 )
  135. typedef struct cLocation
  136. {
  137. //std::string Name;
  138. DWORD m_dwLandBlock; //! landblock location
  139. float m_flX; //! cartesian position (relative to landblock)
  140. float m_flY; //! cartesian position (relative to landblock)
  141. float m_flZ; //! cartesian position (relative to landblock)
  142. float m_flA; //! quaternion orientation
  143. float m_flB; //! quaternion orientation
  144. float m_flC; //! quaternion orientation
  145. float m_flW; //! quaternion orientation
  146. cLocation( )
  147. {
  148. m_dwLandBlock = 0x00;
  149. m_flA = 0.624711f;
  150. m_flB = 0.000000f;
  151. m_flC = 0.000000f;
  152. m_flW = 0.000000f;
  153. }
  154. } cLocation;
  155. #pragma pack( pop )
  156. #pragma pack( push, 1 )
  157. typedef struct cVelocity
  158. {
  159. float m_dx, m_dy, m_dz;
  160. cVelocity( )
  161. {
  162. m_dx = 0.0f;
  163. m_dy = 0.0f;
  164. m_dz = 0.0f;
  165. }
  166. } cVelocity;
  167. #pragma pack( pop )
  168. typedef struct{
  169. BYTE bLow;
  170. BYTE bOO;
  171. BYTE bLo;
  172. BYTE bHi;
  173. } lb;
  174. #pragma pack( push,1)
  175. typedef struct sPaletteChange
  176. {
  177. WORD m_wNewPalette;
  178. BYTE m_ucOffset;
  179. BYTE m_ucLength;
  180. sPaletteChange()
  181. {
  182. m_wNewPalette = 0x0; //! Palette (0x04000000 file)
  183. m_ucOffset = 0x0; //! Offset from beginning of palette
  184. m_ucLength = 0x0; //! Number of palette entries to copy
  185. }
  186. } sPaletteChange;
  187. #pragma pack( pop)
  188. #pragma pack( push,1)
  189. typedef struct sTextureChange
  190. {
  191. BYTE m_bModelIndex;
  192. WORD m_wOldTexture;
  193. WORD m_wNewTexture;
  194. sTextureChange()
  195. {
  196. m_bModelIndex = 0x0; //! Index of body part affected
  197. m_wOldTexture = 0x0; //! Texture mask (0x05000000 file)
  198. m_wNewTexture = 0x0; //! Texture (0x05000000 file)
  199. }
  200. } sTextureChange;
  201. #pragma pack( pop)
  202. #pragma pack( push,1)
  203. typedef struct sModelChange
  204. {
  205. BYTE m_bModelIndex;
  206. WORD m_wNewModel;
  207. sModelChange()
  208. {
  209. m_bModelIndex = 0x0; //! Index of body part affected
  210. m_wNewModel = 0x0; //! Model (0x02000000 file)
  211. }
  212. } sModelChange;
  213. #pragma pack( pop)
  214. #pragma pack( push, 1 )
  215. typedef struct cMonStats
  216. {
  217. DWORD m_dwLevel;
  218. DWORD m_dwStr;
  219. DWORD m_dwEnd;
  220. DWORD m_dwQuick;
  221. DWORD m_dwCoord;
  222. DWORD m_dwFocus;
  223. DWORD m_dwSelf;
  224. DWORD m_dwSpecies;
  225. cMonStats( )
  226. {
  227. m_dwLevel = 0x1;
  228. m_dwStr = 0x0;
  229. m_dwEnd = 0x0;
  230. m_dwQuick = 0x0;
  231. m_dwCoord = 0x0;
  232. m_dwFocus = 0x0;
  233. m_dwSelf = 0x0;
  234. m_dwSpecies = 0x0;
  235. }
  236. } cMonStats;
  237. #pragma pack( pop )
  238. enum eColors
  239. {
  240. ColorGreen = 1,
  241. ColorWhite = 2,
  242. ColorYellow = 3,
  243. ColorBrown = 4,
  244. ColorMagenta = 5,
  245. ColorRed = 6,
  246. ColorGreen2 = 7,
  247. ColorPink = 8,
  248. ColorLightPink = 9,
  249. ColorYellow2 = 10,
  250. ColorBrown2 = 11,
  251. ColorGrey = 12,
  252. ColorCyan = 13,
  253. ColorAquamarine = 14,
  254. ColorRed2 = 15,
  255. ColorGreen3 = 16,
  256. ColorBlue = 17,
  257. ColorGreen4 = 18
  258. };
  259. struct cAvatarList
  260. {
  261. DWORD m_dwGUID; //! Avatar GUID
  262. DWORD m_dwOwnerID; //! Account ID
  263. std::string m_strName; //! Avatar Name
  264. };
  265. enum eAccessLevels
  266. {
  267. eDeveloper = 0,
  268. eAdmin = 1,
  269. eSentinel = 2,
  270. eAdvocate = 3,
  271. eStaff = 4,
  272. eUeber = 5,
  273. eVIP = 6,
  274. eNormal = 7
  275. };
  276. struct ConfirmPanel
  277. {
  278. DWORD m_dwSequence;
  279. DWORD m_dwType;
  280. std::string m_szText;
  281. DWORD m_dwSenderGUID;
  282. DWORD m_dwReceiptGUID;
  283. };
  284. struct cTeleTownList
  285. {
  286. std::string m_teleString; //! String representing the town name
  287. DWORD m_dwLandblock;
  288. FLOAT m_flPosX;
  289. FLOAT m_flPosY;
  290. FLOAT m_flPosZ;
  291. FLOAT m_flOrientW;
  292. FLOAT m_flOrientX;
  293. FLOAT m_flOrientY;
  294. FLOAT m_flOrientZ;
  295. };
  296. struct cDungeonList
  297. {
  298. INT m_intID;
  299. std::string m_strName;
  300. DWORD m_dwLandblock;
  301. FLOAT m_flLocX;
  302. FLOAT m_flLocY;
  303. FLOAT m_flLocZ;
  304. FLOAT m_flHeading;
  305. };
  306. typedef struct cAnimates
  307. {
  308. WORD m_wStance[10];
  309. WORD m_wAttack[10];
  310. WORD m_wIdle[10];
  311. WORD m_wReact[10];
  312. WORD m_wDeath;
  313. WORD m_wStand;
  314. cAnimates( )
  315. {
  316. for (int i = 0; i < 10; i++)
  317. {
  318. m_wStance[i] = 0x0000;
  319. m_wAttack[i] = 0x0000;
  320. m_wIdle[i] = 0x0000;
  321. m_wReact[i] = 0x0000;
  322. }
  323. m_wDeath = 0x0011;
  324. m_wStand = 0x0001;
  325. }
  326. } cAnimates;
  327. ////////////////////////////////////////////////////////
  328. // Define the Various Spell Structures
  329. ////////////////////////////////////////////////////////
  330. typedef struct cSpellBook
  331. {
  332. DWORD dwSpell_ID; //! Max 100 spells in the spellbook
  333. float flCharge; //! spell charge value
  334. DWORD dwUnknownA; //! 0 - so far
  335. DWORD dwUnknownB; //! 0 - so far
  336. WORD wSpellType; //! 0 - War, 1 - Life, 2 - Creature, 4 - Item
  337. cSpellBook()
  338. {
  339. dwSpell_ID = 0;
  340. flCharge = 1.0f;
  341. dwUnknownA = 0;
  342. dwUnknownB = 0;
  343. wSpellType = 0;
  344. }
  345. } cSpellBook;
  346. typedef struct cSpellTab
  347. {
  348. DWORD dwTabCount;
  349. DWORD dwSpell_ID[40]; //! max 40 spells per tab
  350. cSpellTab()
  351. {
  352. dwTabCount = 0;
  353. for(int i = 0;i < 41;i++)
  354. {
  355. dwSpell_ID[i] = 0;
  356. }
  357. }
  358. } cSpellTab;
  359. // cs_CastMagic (Packet F7B1:004A - Group ??)
  360. // - Cast Magic Spell
  361. typedef struct cs_CastMagic
  362. {
  363. DWORD dwWorldEvent;
  364. DWORD dwSequence;
  365. DWORD dwGameEvent; //! should be 0x004A
  366. float flHeading;
  367. DWORD dwSpellID;
  368. } cs_CastMagic;
  369. ////////////////////////////////////////////////////////
  370. // Define the Inventory Sturcture
  371. ////////////////////////////////////////////////////////
  372. typedef struct vInventory
  373. {
  374. DWORD dwObjectGUID; //! Item GUID
  375. DWORD dwIsContainer; //! Is Container (0 = No, 1 = Yes)
  376. DWORD fEquipped; //! Is Equipped (0 = No, 1 = Yes in hand, 2 = Yes as clothing)
  377. DWORD dwItemModelNumber; //! Item's model number
  378. std::string strName; //! Item Name
  379. vInventory()
  380. {
  381. dwObjectGUID = 0;
  382. dwIsContainer = 0;
  383. fEquipped = 0;
  384. dwItemModelNumber = 0;
  385. strName = " ";
  386. }
  387. } vInventory;
  388. #pragma pack( push,1)
  389. typedef struct sMonsters
  390. {
  391. DWORD m_dwGUID; //! Monster GUID
  392. DWORD m_dwLastAttacker; //! Last attacker's GUID
  393. time_t m_TimeNextAction; //! Time to next action
  394. DWORD m_dwEvent;
  395. sMonsters()
  396. {
  397. m_dwGUID = 0x0L;
  398. m_dwLastAttacker = 0x0L;
  399. time(&m_TimeNextAction + 30);
  400. m_dwEvent = 0x0L;
  401. }
  402. } sMonsters;
  403. #pragma pack( pop)
  404. #define Race 3
  405. #define Gender 2
  406. #define TexType 3
  407. #define TexIndex 45
  408. extern short g_nCharPort;
  409. extern short g_nWorldPort;
  410. extern HWND g_hWndMain;
  411. extern char g_szLocalIP[16];
  412. extern WORD g_wAvatarTexturesList[Race][Gender][TexType][TexIndex];
  413. extern WORD g_wAvatarTexturesBaldList[Race][Gender][TexIndex];
  414. void UpdateConsole( const char *szBuff );
  415. long UpdateConsole( char *szBuff, long nErr );
  416. void UpdateConsole( char *szMessage, ... );
  417. #endif // #ifndef __SHARED_H