00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00023 #ifndef __CHARACTERSERVER_H
00024 #define __CHARACTERSERVER_H
00025
00026 #include "uas.h"
00027
00028 class cCharacterServer
00029 {
00030 friend class cMasterServer;
00031
00032 public:
00033 static DWORD m_dwClientCount;
00034 static DWORD ReturnPadOffset( DWORD dwLength );
00035 static void Initialize( short nPort, WORD wLogicalID, DWORD dwSendCRCSeed, DWORD dwRecvCRCSeed )
00036 {
00037 UpdateConsole( "\r\n Starting Character Server ... " );
00038
00039 SOCKADDR_IN saSockAddr;
00040 saSockAddr.sin_family = AF_INET;
00041 saSockAddr.sin_port = htons( nPort );
00042 saSockAddr.sin_addr.s_addr = INADDR_ANY;
00043
00044 m_wLogicalID = wLogicalID;
00045 m_dwSendCRCSeed = dwSendCRCSeed;
00046 m_dwRecvCRCSeed = dwRecvCRCSeed;
00047
00048 m_Socket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
00049 if ( !m_Socket )
00050 {
00051 UpdateConsole( "socket( ) failed!\r\n" );
00052 return ;
00053 }
00054
00055 if ( bind( m_Socket, (struct sockaddr *)&saSockAddr, sizeof( SOCKADDR_IN ) ) )
00056 {
00057 UpdateConsole( "bind( ) failed!\r\n" );
00058 return ;
00059 }
00060
00061 UpdateConsole( "success.\r\n" );
00062 }
00063
00064 static void Halt( )
00065 {
00066 closesocket( m_Socket );
00067 UpdateConsole( " Character Server: closing socket ...\r\n" );
00068 }
00069
00070 protected:
00071 static DWORD m_dwSendCRCSeed;
00072 static DWORD m_dwRecvCRCSeed;
00073 static WORD m_wLogicalID;
00074 static SOCKET m_Socket;
00075 };
00076
00077 #endif // #ifndef __CHARACTERSERVER_H