- Main Page
- Classes
- Files

- File List
- File Members

# E:/uas2/Server/MasterServer.h

Go to the documentation of this file.

    00001 /*
    00002 * This file is part of UAS2.
    00003 *
    00004 * UAS2 is free software; you can redistribute it and/or modify
    00005 * it under the terms of the GNU General Public License as published by
    00006 * the Free Software Foundation; either version 2 of the License, or
    00007 * (at your option) any later version.
    00008 *
    00009 * UAS2 is distributed in the hope that it will be useful,
    00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012 * GNU General Public License for more details.
    00013
    00014 * You should have received a copy of the GNU General Public License
    00015 * along with UASv1; if not, write to the Free Software
    00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00017 */
    00018
    00023 #ifndef __MASTERSERVER_H
    00024 #define __MASTERSERVER_H
    00025
    00026 #include <winsock2.h>
    00027 #include <fstream>
    00028 #include <sql.h>
    00029 #include <sqlext.h>
    00030 #include "Allegiance.h"
    00031 #include "DataBase.h"
    00032 #include "Fellowship.h"
    00033 #include "CorpseCleaner.h"
    00034 #include "cMonsterServer.h"
    00035 #include "SimpleAI.h"
    00036 #include "Status.h"
    00037
    00038 class cClient;
    00039 class cJobPool;
    00040
    00041 class cMasterServer
    00042 {
    00043         friend class cClient;
    00044         friend class cCommandParser;
    00045         friend class cAltar;
    00046         friend class cCovenant;
    00047         friend class cDatabase;
    00048         friend class cFellowship;
    00049         friend class cHouse;
    00050         friend class cMonsterServer;
    00051
    00052 public:
    00053         static void                             WriteToFile                     ( char *szMessage );
    00054         static void                             Load                            ( );
    00055         static BOOL                             Unload                          ( );
    00056
    00057         static void                             StartThread                     ( );
    00058         static void                             StopThread                      ( DWORD dwTimeOut );
    00059         static DWORD WINAPI             ServerThread            ( LPVOID lpVoid );
    00060
    00061         static void                             ParseCommand            ( char *szCommand, WORD wSize, cClient *pcClient );
    00062         //static void                           ParseCommand            ( char *szCommand, WORD wSize, cClient *pcClient, cNPC *npc );
    00063         static void                             LoadAvatar                      ( cClient *pcClient );
    00064     static void                         CreateNewAvatar         ( cAvatar **ppcAvatar, DWORD dwGUID );
    00065         static void                             SendLoginData           ( cClient *pcClient );
    00066         static void                             CreateInventory         ( cClient *pcClient );
    00067         static void                             ServerMessage           ( DWORD dwColor, cClient *pcClient, char *szMessage, ... );
    00068         static void                             SendTell                        ( char *szMessage, cClient *pcDestination, cClient *pcOrigin );
    00069
    00070         static void CALLBACK    ScavengeIdleSockets     ( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime );
    00071         static void CALLBACK    Status_Update           ( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime );
    00072         static BOOL                             DisconnectClient        ( cClient *pcClient );
    00073         static BOOL                             Corpse                          ( cClient *pcClient );
    00074         static BOOL                             DisconnectAllClients( );
    00075         static void                             LoadMonsterModels       ( );
    00076         static void                             LoadItemModels          ( );
    00077         static void                             LoadWorldModels         ( );
    00078         static void                             LoadMonsters            ( );
    00079         static void                             LoadGroundSpawns        ( );
    00080         static void                             LoadSpellModels         ( );
    00081         static void                             LoadSpells                      ( );
    00082         static void                             LoadSpellComps          ( );
    00083         static void                             LoadNPCs                        ( );
    00084         static void                             LoadAltars                      ( );
    00085         static void                             LoadCovenants           ( );
    00086         static void                             LoadHousing                     ( );
    00087         static void                             LoadHooks                       ( );
    00088         static void                             LoadStorage                     ( );
    00089         static void                             LoadDoors                       ( );
    00090         static void                             LoadChests                      ( );
    00091         static void                             LoadLifestones          ( );
    00092         static void                             LoadPortals                     ( );
    00093         static void                             LoadWorldObjects        ( );
    00094         static void                             LoadWorldObjects2       ( );
    00095         static void                             LoadNPCModels           ( );
    00096         //Load unique item data
    00097         static void                             LoadItem                        ( cObject *pcItem );
    00098
    00099         static void                             LoadSpawns                      (WORD LB);
    00100
    00101         static bool                             SpawnMonster            ( char* szMonster, cLocation pcLoc, DWORD Respawn = 0 );
    00102         static bool                             SpawnType                       ( char* szMonster, cLocation pcLoc, DWORD dwModelNumber, DWORD dwExp_Value, DWORD dwHealth, DWORD dwStamina, DWORD dwMana );
    00103         static bool                             SpawnSave                       ( char* szMonster, cLocation pcLoc, bool bFacing, bool bOverride, DWORD Respawn, DWORD Decay, DWORD Chase, DWORD Influence );
    00104 //      static bool                             NPC_Save                        ( char* szName, cLocation pcLoc, bool bFacing );
    00105
    00106         static BOOL                             FindHeaderInFile        ( FILE* fin, char* header );
    00107         static void                             FixSpaces                       ( char* str );
    00108         static void                             FixName                         ( char* str );
    00109
    00110         static void                             LoadStartingLocation( );
    00111         static void                             LoadTeleTownList        ( );
    00112         static void                             LoadAllegiances         ( );
    00113
    00114         static void                             ClearAllObjects         ( );
    00115         static BOOL                             PKLite                          ( cClient *pcClient, bool bState );
    00116         static CStatus                  *cStatus;
    00117
    00118         inline static void FormatIP( SOCKADDR_IN& saSockAddr, char *szStore )
    00119         {
    00120                 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,
    00121                         saSockAddr.sin_addr.S_un.S_un_b.s_b3, saSockAddr.sin_addr.S_un.S_un_b.s_b4 );
    00122         }
    00123
    00124         inline static void FormatIP_Port( SOCKADDR_IN& saSockAddr, char *szStore )
    00125         {
    00126                 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,
    00127                         saSockAddr.sin_addr.S_un.S_un_b.s_b3, saSockAddr.sin_addr.S_un.S_un_b.s_b4, saSockAddr.sin_port );
    00128         }
    00129         static CorpseCleaner *m_pcCorpse;
    00130         static SimpleAI          *m_pcSimpleAI;
    00131         static cJobPool          *m_pcJobPool;
    00132         static char                     m_szServerName[64];
    00133         static DWORD            m_dwNumUsers;
    00134         static DWORD            m_UserCount;
    00135         static std::list < cEnchantment * >     m_lstEnchantments;
    00136         static std::vector< cTeleTownList >     m_TeleTownList;
    00137         static std::vector< cAllegiance * >     m_AllegianceList;
    00138         static std::vector< cFellowship * >     m_FellowshipList;
    00139
    00140         static inline DWORD     NewFellowID     ( )     { return ++m_dwFellowID; }
    00141
    00142
    00143         //k109:  Added correct starting locs
    00144
    00145         //K109: Begin changes:
    00146         static cLocation        m_HoltburgWest;
    00147         static cLocation        m_HoltburgSouth;
    00148         static cLocation        m_ShoushiSE;
    00149         static cLocation        m_ShoushiWest;
    00150         static cLocation        m_YaraqNorth;
    00151         static cLocation        m_YaraqEast;
    00152
    00153         //These are starting Lifestones
    00154         static cLocation        m_LSHoltburgWest;
    00155         static cLocation        m_LSHoltburgSouth;
    00156         static cLocation        m_LSShoushiSE;
    00157         static cLocation        m_LSShoushiWest;
    00158         static cLocation        m_LSYaraqNorth;
    00159         static cLocation        m_LSYaraqEast;
    00160         //End changes
    00161
    00162 protected:
    00163         static DWORD            m_dwFellowID;
    00164
    00165 private:
    00166         static HANDLE           m_hThread;
    00167         static HANDLE           m_hExitEvent;
    00168         static UINT_PTR         m_uipTimer;
    00169         static UINT_PTR         m_uipStatusTimer;
    00170         static DWORD            m_dwThreadID;
    00171
    00172         static cLocation        m_StartingLoc;
    00173         static cLocation    m_MarketLoc;
    00174
    00175         static int                      m_iLoadCount;
    00176         static FILE*            pFile;
    00177
    00178 };
    00179
    00180 //Inline Functions
    00181 //================
    00182
    00183 #endif  // #ifndef __MASTERSERVER_H