Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
359
Server/NFAuthTool/NFAuthServer/ServerCtrl.cpp
Normal file
359
Server/NFAuthTool/NFAuthServer/ServerCtrl.cpp
Normal file
@@ -0,0 +1,359 @@
|
||||
#include "Global.h"
|
||||
#include <Nave/NFLog.h>
|
||||
#include <Nave/NFStringUtil.h>
|
||||
#include "ServerCtrl.h"
|
||||
#include <Nave/NFIni.h>
|
||||
#include <Nave/NFTokenizer.h>
|
||||
|
||||
#include "DBComponent.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "MD5/global.h"
|
||||
#include "MD5/md5.h"
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ŀ<>ǵ<EFBFBD><C7B5><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
class CCmdHelp : public NaveServer::UICommand
|
||||
{
|
||||
public:
|
||||
virtual BOOL DoProcess(WCHAR* lpParam)
|
||||
{
|
||||
if(g_Server) g_Server->ShowCommand();
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
class CCmdClear : public NaveServer::UICommand
|
||||
{
|
||||
public:
|
||||
virtual BOOL DoProcess(WCHAR* lpParam)
|
||||
{
|
||||
NaveServer::UICmdMsgView::ClrarMsgView();
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
class CCmdClose : public NaveServer::UICommand
|
||||
{
|
||||
public:
|
||||
virtual BOOL DoProcess(WCHAR* lpParam)
|
||||
{
|
||||
if(g_Server) g_Server->EndCommand();
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
class CCmdMsg : public NaveServer::UICommand
|
||||
{
|
||||
public:
|
||||
virtual BOOL DoProcess(WCHAR* lpParam)
|
||||
{
|
||||
if(g_Server) g_Server->SendMsg(lpParam);
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
class CCmdIRC : public NaveServer::UICommand
|
||||
{
|
||||
public:
|
||||
virtual BOOL DoProcess(WCHAR* lpParam)
|
||||
{
|
||||
if(g_Server) g_Server->SendIRC(lpParam);
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
class CShutdown : public NaveServer::UICommand
|
||||
{
|
||||
public:
|
||||
virtual BOOL DoProcess(WCHAR* lpParam)
|
||||
{
|
||||
if(g_Server) g_Server->SendShutdown(lpParam);
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
class CCommand : public NaveServer::UICommand
|
||||
{
|
||||
public:
|
||||
virtual BOOL DoProcess(WCHAR* lpParam)
|
||||
{
|
||||
if(g_Server) g_Server->SendCMD(lpParam);
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ServerCtrl::ServerCtrl(void)
|
||||
{
|
||||
m_pLogin = NULL; // Client List <20><><EFBFBD><EFBFBD>
|
||||
m_uTimerID = 0;
|
||||
m_uTimerPeriod = 1;
|
||||
}
|
||||
|
||||
ServerCtrl::~ServerCtrl(void)
|
||||
{
|
||||
}
|
||||
|
||||
VOID ServerCtrl::InitializeCommand()
|
||||
{
|
||||
ADD_COMMAND(L"help", CCmdHelp, L"Show Command List.");
|
||||
ADD_COMMAND(L"clear", CCmdClear, L"Clear Display.");
|
||||
ADD_COMMAND(L"close", CCmdClose, L"Close Server.");
|
||||
ADD_COMMAND(L"msg", CCmdMsg, L"Send Message");
|
||||
ADD_COMMAND(L"irc", CCmdIRC, L"Send IRC");
|
||||
ADD_COMMAND(L"shutdown", CShutdown, L"Shutdown serverid");
|
||||
ADD_COMMAND(L"cmd", CCommand, L"Send Command");
|
||||
|
||||
}
|
||||
|
||||
VOID ServerCtrl::SendMsg(WCHAR* strParam)
|
||||
{
|
||||
NaveNet::NFPacket packet;
|
||||
|
||||
packet.SetCommand(IRC);
|
||||
packet.SetSize(sizeof(PKIRC));
|
||||
|
||||
LPPKIRC lpIRC = (LPPKIRC)packet.m_Packet;
|
||||
|
||||
strcpy(lpIRC->Key, "/SVR");
|
||||
strcpy(lpIRC->Message, Nave::ToASCII(strParam).c_str());
|
||||
|
||||
g_UManager.SendPostAll(packet);
|
||||
}
|
||||
|
||||
VOID ServerCtrl::SendIRC(WCHAR* strParam)
|
||||
{
|
||||
NaveNet::NFPacket packet;
|
||||
|
||||
packet.SetCommand(IRC);
|
||||
packet.SetSize(sizeof(PKIRC));
|
||||
|
||||
LPPKIRC lpIRC = (LPPKIRC)packet.m_Packet;
|
||||
|
||||
Nave::NFTokenizerA token(Nave::ToASCII(strParam), " ");
|
||||
std::string strCommand = token.NextToken();
|
||||
std::string strMsg = token.NextToken();
|
||||
|
||||
MD5_CTX context;
|
||||
unsigned char digest[16] ;
|
||||
memset( digest, 0, sizeof( char ) * 16 ) ;
|
||||
|
||||
int len = strlen(strCommand.c_str());
|
||||
|
||||
char strMD5[64];
|
||||
strcpy(strMD5, strCommand.c_str());
|
||||
|
||||
MD5Init(&context);
|
||||
MD5Update(&context, reinterpret_cast<unsigned char *>(strMD5), len );
|
||||
MD5Final(digest, &context);
|
||||
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
sprintf(lpIRC->Key + i * 2, "%02x", digest[i]);
|
||||
}
|
||||
|
||||
strcpy(lpIRC->Message, strMsg.c_str());
|
||||
|
||||
|
||||
g_UManager.SendPostAll(packet);
|
||||
}
|
||||
|
||||
VOID ServerCtrl::SendCMD(WCHAR* strParam)
|
||||
{
|
||||
NaveNet::NFPacket packet;
|
||||
|
||||
packet.SetCommand(CMD);
|
||||
packet.SetSize(sizeof(PKCMD));
|
||||
|
||||
LPPKCMD lpPK = (LPPKCMD)packet.m_Packet;
|
||||
|
||||
lpPK->dwCmd = Nave::ToInt(strParam);
|
||||
lpPK->dwValue = 0;
|
||||
|
||||
if(lpPK->dwCmd == SC_SHUTDOWN)
|
||||
{
|
||||
LOG_ERROR((L"Shutdown<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Command<6E><64> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>."));
|
||||
return;
|
||||
}
|
||||
|
||||
g_UManager.SendPostAll(packet);
|
||||
}
|
||||
|
||||
VOID ServerCtrl::SendShutdown(WCHAR* strParam)
|
||||
{
|
||||
NaveNet::NFPacket packet;
|
||||
|
||||
packet.SetCommand(CMD);
|
||||
packet.SetSize(sizeof(PKCMD));
|
||||
|
||||
LPPKCMD lpPK = (LPPKCMD)packet.m_Packet;
|
||||
|
||||
lpPK->dwCmd = SC_SHUTDOWN;
|
||||
lpPK->dwValue = Nave::ToInt(strParam);
|
||||
|
||||
g_UManager.SendPostAll(packet);
|
||||
}
|
||||
|
||||
VOID ServerCtrl::UpdateInfo()
|
||||
{
|
||||
WCHAR szTime[32];
|
||||
WCHAR szDate[32];
|
||||
|
||||
_tzset();
|
||||
_tstrdate( szDate );
|
||||
_tstrtime( szTime );
|
||||
|
||||
WCHAR strInfo[512];
|
||||
|
||||
_stprintf(strInfo, L"UpdateTime : %s-%s", szDate, szTime);
|
||||
|
||||
NaveServer::UICmdMsgView::UpdateInfo(strInfo);
|
||||
}
|
||||
|
||||
VOID ServerCtrl::InitObject()
|
||||
{
|
||||
Nave::NFIni ini;
|
||||
ini.Open(L"./Config.ini");
|
||||
|
||||
DWORD port,conn;
|
||||
|
||||
ini.GetValue(L"SERVER", L"PORT", &port);
|
||||
ini.GetValue(L"SERVER", L"MAXCONN", &conn);
|
||||
|
||||
// DB<44><42><EFBFBD><EFBFBD> <20>õ<EFBFBD>.
|
||||
WCHAR strIP[32];
|
||||
WCHAR strName[32];
|
||||
WCHAR strUser[32];
|
||||
WCHAR strPass[32];
|
||||
WCHAR strTable[32];
|
||||
DWORD dwLen=32;
|
||||
ini.GetValue(L"DB", L"IP", strIP, dwLen);
|
||||
dwLen=32;
|
||||
ini.GetValue(L"DB", L"NAME", strName, dwLen);
|
||||
dwLen=32;
|
||||
ini.GetValue(L"DB", L"USER", strUser, dwLen);
|
||||
dwLen=32;
|
||||
ini.GetValue(L"DB", L"PASSWORD", strPass, dwLen);
|
||||
dwLen=32;
|
||||
ini.GetValue(L"DB", L"TABLE", strTable, dwLen);
|
||||
|
||||
ini.Close();
|
||||
|
||||
g_DBTable = strTable;
|
||||
|
||||
if(!g_DBComp.Connect(strIP, strName, strUser, strPass))
|
||||
LOG_IMPORTANT((L"DB <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"));
|
||||
|
||||
m_iMaxPacket = 0;
|
||||
m_iPrevTick = timeGetTime();
|
||||
|
||||
INT Port = port;
|
||||
INT MaxConn = conn;
|
||||
Start(Port, MaxConn);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. (<28><><EFBFBD>η<EFBFBD><CEB7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(EndProcessȣ<73><C8A3><EFBFBD><EFBFBD>) ȣ<><C8A3>)
|
||||
VOID ServerCtrl::ReleaseObject()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
VOID ServerCtrl::ShowServerInfo()
|
||||
{
|
||||
// Join <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Leave<76><65><EFBFBD>Ѿ<EFBFBD><D1BE>Ѵ<EFBFBD>.
|
||||
WCHAR szDate[32],
|
||||
szTime[32];
|
||||
|
||||
|
||||
_tzset();
|
||||
_tstrdate( szDate );
|
||||
_tstrtime( szTime );
|
||||
LOG_IMPORTANT((L"------------------------------------------------"));
|
||||
LOG_IMPORTANT((L" NFAuthServer initialized at %s, %s", szDate, szTime) );
|
||||
LOG_IMPORTANT((L"------------------------------------------------"));
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Server start //
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
LOG_IMPORTANT((L"------------------------------------------------"));
|
||||
LOG_IMPORTANT((L"| SERVER START |"));
|
||||
LOG_IMPORTANT((L"------------------------------------------------"));
|
||||
|
||||
WCHAR Ip[32];
|
||||
GetLocalIP(Ip);
|
||||
LOG_IMPORTANT((L"IP(%s), Port(%d), MaxConn(%d)", Ip, m_iPort, m_iMaxConn));
|
||||
|
||||
// Nave::IOCPServer::UpdateInfo(L"<22><><EFBFBD><EFBFBD>"));
|
||||
}
|
||||
|
||||
BOOL ServerCtrl::CreateSession(SOCKET sckListener)
|
||||
{
|
||||
if(m_PacketPool.Create(m_iMaxConn,NULL,DEF_MAXPACKETSIZE, 1, 10, 32) == NULL)
|
||||
return FALSE;
|
||||
|
||||
// pClientArray(Client Controler..)
|
||||
if((m_pLogin = new GameConnection[m_iMaxConn]) == NULL)
|
||||
return FALSE; // Create MAXUSER(1000) m_pLogin
|
||||
|
||||
// Initialize pClientArray
|
||||
for(int nCnt = 0; nCnt < m_iMaxConn; nCnt++)
|
||||
{
|
||||
if(m_pLogin[nCnt].Create(nCnt,
|
||||
m_hIOCP,
|
||||
sckListener,
|
||||
&m_PacketPool,
|
||||
DEF_PACKETSIZE) == 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_UManager.Init(m_iMaxConn);
|
||||
|
||||
// Timer Setting
|
||||
timeBeginPeriod(m_uTimerPeriod);
|
||||
m_uTimerID = timeSetEvent(1000,0, (LPTIMECALLBACK)TimerProc,(DWORD)0,TIME_PERIODIC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ServerCtrl::ReleaseSession()
|
||||
{
|
||||
// Close All User Sockets
|
||||
if( m_pLogin )
|
||||
{
|
||||
for(int nCnt = 0 ; nCnt < m_iMaxConn ; nCnt++)
|
||||
{
|
||||
m_pLogin[nCnt].Disconnect();
|
||||
}
|
||||
delete [] m_pLogin;
|
||||
}
|
||||
m_pLogin = NULL;
|
||||
|
||||
// [03] Ÿ<≯<EFBFBD> <20><><EFBFBD>̱<EFBFBD>
|
||||
timeKillEvent(m_uTimerID);
|
||||
timeEndPeriod(m_uTimerPeriod);
|
||||
|
||||
// [01] Shutdown the Packet Pool
|
||||
m_PacketPool.Release();
|
||||
LOG_IMPORTANT((L"shutdown packet pool.." ));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Process Update...
|
||||
VOID ServerCtrl::Update()
|
||||
{
|
||||
NaveServer::NFServerCtrl::Update();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// [1]DESCRIPTION : Ÿ<≯<EFBFBD> <20>Լ<EFBFBD> //
|
||||
// [2]PARAMETER : dwUser - <20><><EFBFBD><EFBFBD> <20><>ü<EFBFBD><C3BC> <20>ѱ<EFBFBD><D1B1><EFBFBD> <20><><EFBFBD><EFBFBD> //
|
||||
// [3]RETURN : void //
|
||||
// [4]DATE : 2000<30><30> 11<31><31> 21<32><31> //
|
||||
//////////////////////////////////////////////////////////////////
|
||||
void ServerCtrl::TimerProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
|
||||
{
|
||||
UpdateInfomation();
|
||||
}
|
||||
Reference in New Issue
Block a user