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

MasterServer.h 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 MasterServer.h
  19. */
  20. #ifndef __MASTERSERVER_H
  21. #define __MASTERSERVER_H
  22. #include <winsock2.h>
  23. #include <fstream>
  24. #include <sql.h>
  25. #include <sqlext.h>
  26. #include "Allegiance.h"
  27. #include "DataBase.h"
  28. #include "Fellowship.h"
  29. #include "CorpseCleaner.h"
  30. #include "cMonsterServer.h"
  31. #include "SimpleAI.h"
  32. #include "Status.h"
  33. class cClient;
  34. class cJobPool;
  35. class cMasterServer
  36. {
  37. friend class cClient;
  38. friend class cCommandParser;
  39. friend class cAltar;
  40. friend class cCovenant;
  41. friend class cDatabase;
  42. friend class cFellowship;
  43. friend class cHouse;
  44. friend class cMonsterServer;
  45. public:
  46. static void WriteToFile ( char *szMessage );
  47. static void Load ( );
  48. static BOOL Unload ( );
  49. static void StartThread ( );
  50. static void StopThread ( DWORD dwTimeOut );
  51. static DWORD WINAPI ServerThread ( LPVOID lpVoid );
  52. static void ParseCommand ( char *szCommand, WORD wSize, cClient *pcClient );
  53. //static void ParseCommand ( char *szCommand, WORD wSize, cClient *pcClient, cNPC *npc );
  54. static void LoadAvatar ( cClient *pcClient );
  55. static void CreateNewAvatar ( cAvatar **ppcAvatar, DWORD dwGUID );
  56. static void SendLoginData ( cClient *pcClient );
  57. static void CreateInventory ( cClient *pcClient );
  58. static void ServerMessage ( DWORD dwColor, cClient *pcClient, char *szMessage, ... );
  59. static void SendTell ( char *szMessage, cClient *pcDestination, cClient *pcOrigin );
  60. static void CALLBACK ScavengeIdleSockets ( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime );
  61. static void CALLBACK Status_Update ( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime );
  62. static BOOL DisconnectClient ( cClient *pcClient );
  63. static BOOL Corpse ( cClient *pcClient );
  64. static BOOL DisconnectAllClients( );
  65. static void LoadMonsterModels ( );
  66. static void LoadItemModels ( );
  67. static void LoadWorldModels ( );
  68. static void LoadMonsters ( );
  69. static void LoadGroundSpawns ( );
  70. static void LoadSpellModels ( );
  71. static void LoadSpells ( );
  72. static void LoadSpellComps ( );
  73. static void LoadNPCs ( );
  74. static void LoadAltars ( );
  75. static void LoadCovenants ( );
  76. static void LoadHousing ( );
  77. static void LoadHooks ( );
  78. static void LoadStorage ( );
  79. static void LoadDoors ( );
  80. static void LoadChests ( );
  81. static void LoadLifestones ( );
  82. static void LoadPortals ( );
  83. static void LoadWorldObjects ( );
  84. static void LoadWorldObjects2 ( );
  85. static void LoadNPCModels ( );
  86. //Load unique item data
  87. static void LoadItem ( cObject *pcItem );
  88. static void LoadSpawns (WORD LB);
  89. static bool SpawnMonster ( char* szMonster, cLocation pcLoc, DWORD Respawn = 0 );
  90. static bool SpawnType ( char* szMonster, cLocation pcLoc, DWORD dwModelNumber, DWORD dwExp_Value, DWORD dwHealth, DWORD dwStamina, DWORD dwMana );
  91. static bool SpawnSave ( char* szMonster, cLocation pcLoc, bool bFacing, bool bOverride, DWORD Respawn, DWORD Decay, DWORD Chase, DWORD Influence );
  92. // static bool NPC_Save ( char* szName, cLocation pcLoc, bool bFacing );
  93. static BOOL FindHeaderInFile ( FILE* fin, char* header );
  94. static void FixSpaces ( char* str );
  95. static void FixName ( char* str );
  96. static void LoadStartingLocation( );
  97. static void LoadTeleTownList ( );
  98. static void LoadAllegiances ( );
  99. static void ClearAllObjects ( );
  100. static BOOL PKLite ( cClient *pcClient, bool bState );
  101. static CStatus *cStatus;
  102. inline static void FormatIP( SOCKADDR_IN& saSockAddr, char *szStore )
  103. {
  104. wsprintf( szStore, "%u.%u.%u.%u", saSockAddr.sin_addr.S_un.S_un_b.s_b1, saSockAddr.sin_addr.S_un.S_un_b.s_b2,
  105. saSockAddr.sin_addr.S_un.S_un_b.s_b3, saSockAddr.sin_addr.S_un.S_un_b.s_b4 );
  106. }
  107. inline static void FormatIP_Port( SOCKADDR_IN& saSockAddr, char *szStore )
  108. {
  109. wsprintf( szStore, "%u.%u.%u.%u:%u", saSockAddr.sin_addr.S_un.S_un_b.s_b1, saSockAddr.sin_addr.S_un.S_un_b.s_b2,
  110. saSockAddr.sin_addr.S_un.S_un_b.s_b3, saSockAddr.sin_addr.S_un.S_un_b.s_b4, saSockAddr.sin_port );
  111. }
  112. static CorpseCleaner *m_pcCorpse;
  113. static SimpleAI *m_pcSimpleAI;
  114. static cJobPool *m_pcJobPool;
  115. static char m_szServerName[64];
  116. static DWORD m_dwNumUsers;
  117. static DWORD m_UserCount;
  118. static std::list < cEnchantment * > m_lstEnchantments;
  119. static std::vector< cTeleTownList > m_TeleTownList;
  120. static std::vector< cAllegiance * > m_AllegianceList;
  121. static std::vector< cFellowship * > m_FellowshipList;
  122. static inline DWORD NewFellowID ( ) { return ++m_dwFellowID; }
  123. //k109: Added correct starting locs
  124. //K109: Begin changes:
  125. static cLocation m_HoltburgWest;
  126. static cLocation m_HoltburgSouth;
  127. static cLocation m_ShoushiSE;
  128. static cLocation m_ShoushiWest;
  129. static cLocation m_YaraqNorth;
  130. static cLocation m_YaraqEast;
  131. //These are starting Lifestones
  132. static cLocation m_LSHoltburgWest;
  133. static cLocation m_LSHoltburgSouth;
  134. static cLocation m_LSShoushiSE;
  135. static cLocation m_LSShoushiWest;
  136. static cLocation m_LSYaraqNorth;
  137. static cLocation m_LSYaraqEast;
  138. //End changes
  139. protected:
  140. static DWORD m_dwFellowID;
  141. private:
  142. static HANDLE m_hThread;
  143. static HANDLE m_hExitEvent;
  144. static UINT_PTR m_uipTimer;
  145. static UINT_PTR m_uipStatusTimer;
  146. static DWORD m_dwThreadID;
  147. static cLocation m_StartingLoc;
  148. static cLocation m_MarketLoc;
  149. static int m_iLoadCount;
  150. static FILE* pFile;
  151. };
  152. //Inline Functions
  153. //================
  154. #endif // #ifndef __MASTERSERVER_H