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:
4
Server/UserStatistics/StatServer/ReadMe.txt
Normal file
4
Server/UserStatistics/StatServer/ReadMe.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
========================================================================
|
||||
Win32 <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> : StatServer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
========================================================================
|
||||
|
||||
17
Server/UserStatistics/StatServer/StatDB_Create.sql
Normal file
17
Server/UserStatistics/StatServer/StatDB_Create.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- Execute All
|
||||
|
||||
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TblRYLUserStat]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
|
||||
drop table [dbo].[TblRYLUserStat]
|
||||
GO
|
||||
|
||||
CREATE TABLE [dbo].[TblRYLUserStat] (
|
||||
[nNation] [tinyint] NULL ,
|
||||
[nServerID] [int] NULL ,
|
||||
[nUserNum] [int] NULL ,
|
||||
[tDateTime] [smalldatetime] NULL
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE CLUSTERED INDEX [TblRYLUserStat1] ON [dbo].[TblRYLUserStat]([tDateTime] DESC , [nServerID]) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
221
Server/UserStatistics/StatServer/StatServer.cpp
Normal file
221
Server/UserStatistics/StatServer/StatServer.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
#include "stdafx.h"
|
||||
#include "resource.h"
|
||||
#include "StatServer.h"
|
||||
#include "StatServerDispatch.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
#include <Thread/Lock.h> // CNamedMutex
|
||||
#include <Log/ServerLog.h>
|
||||
#include <Utility/Debug/ExceptionReport.h> // g_CExceptionReport
|
||||
#include <Utility/Time/Pulse/Pulse.h>
|
||||
|
||||
#include <Network/Session/CreatePolicy.h>
|
||||
#include <Network/Session/Session.h>
|
||||
#include <Network/IOCP/IOCPNet.h>
|
||||
|
||||
#include <Network/Dispatch/SingleDispatchStorage.h>
|
||||
#include <Utility/ServerAppFramework/MsgProc/MsgProc.h>
|
||||
|
||||
#include <Pattern/CommandQueue.h>
|
||||
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
|
||||
#include "StatisticsDB.h"
|
||||
|
||||
|
||||
int WINAPI ExceptionUserFunc(char* szBuffer, int nBufferLen)
|
||||
{
|
||||
g_Log.Flush();
|
||||
g_SessionLog.Flush();
|
||||
|
||||
return _snprintf(szBuffer, nBufferLen, "Exception Occured. Flush all buffers.");
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
/*
|
||||
CNamedMutex Mutex("StatServer", TRUE);
|
||||
|
||||
if(GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
ERRLOG0(g_Log, "StatServer already server operating now. please shutdown and restart");
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
unsigned long dwExceptionFeatures =
|
||||
CExceptionReport::CATCH_EXCEPTION | CExceptionReport::USE_MINIDUMP | CExceptionReport::USE_REPORT;
|
||||
|
||||
CExceptionReport::GetInstance().Enable(dwExceptionFeatures);
|
||||
CExceptionReport::GetInstance().SetUserFunc(ExceptionUserFunc);
|
||||
|
||||
CStatServer& StatServer = CStatServer::GetInstance();
|
||||
|
||||
if(StatServer.Initialize(hInstance, "StatServer", lpCmdLine, IDI_STATSERVER, IDC_STATSERVER))
|
||||
{
|
||||
StatServer.ProcessMessage();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
class CStatServerProcessThread : public CProcessThread
|
||||
{
|
||||
public:
|
||||
|
||||
enum Const
|
||||
{
|
||||
PROCESS_TPP = 200, // 200ms(0.2<EFBFBD><EFBFBD>) <20><> 1ƽ.
|
||||
TPP_PER_SEC = 1000 / PROCESS_TPP,
|
||||
CONNECT_CHECK = 2 * TPP_PER_SEC, // 2<>ʸ<EFBFBD><CAB8><EFBFBD> <20><><EFBFBD><EFBFBD> üũ
|
||||
PRINT_CONSOLE = 2 * TPP_PER_SEC, // 2<>ʸ<EFBFBD><CAB8><EFBFBD> <20>ܼ<EFBFBD>â <20><><EFBFBD><EFBFBD>
|
||||
};
|
||||
|
||||
CStatServerProcessThread(CStatServer& StatServer)
|
||||
: CProcessThread(StatServer, PROCESS_TPP)
|
||||
, m_StatServer(StatServer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~CStatServerProcessThread()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
virtual void InternalRun(CPulse& Pulse)
|
||||
{
|
||||
unsigned long dwCurrentPulse = Pulse.GetCurrentPulse();
|
||||
|
||||
if(0 == (dwCurrentPulse % CONNECT_CHECK))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if(0 == (dwCurrentPulse % PRINT_CONSOLE))
|
||||
{
|
||||
m_StatServer.UpdateConsole();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Cleanup(CPulse& Pulse)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CStatServer& m_StatServer;
|
||||
};
|
||||
|
||||
|
||||
CStatServer& CStatServer::GetInstance()
|
||||
{
|
||||
static CStatServer StatServer;
|
||||
return StatServer;
|
||||
}
|
||||
|
||||
|
||||
CStatServer::CStatServer()
|
||||
: m_lpCommandQueueThread(NULL)
|
||||
, m_lpServerSessionPolicy(SessionPolicy::CreateTCPPolicy<CStatServerDispatch>())
|
||||
, m_tServerStart(0)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CStatServer::~CStatServer()
|
||||
{
|
||||
if(NULL != m_lpServerSessionPolicy)
|
||||
{
|
||||
m_lpServerSessionPolicy->Release();
|
||||
m_lpServerSessionPolicy = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool CStatServer::ApplicationSpecificInit(const TCHAR* szCmdLine)
|
||||
{
|
||||
const TCHAR* szErrorMessage = NULL;
|
||||
|
||||
if(!GetIOCPNet()->AddListener(m_lpServerSessionPolicy, NULL, CServerSetup::StatServerManageServerListen))
|
||||
{
|
||||
szErrorMessage = _T("StatServerListener add failed");
|
||||
}
|
||||
else if(!AddProcessThread(new CStatServerProcessThread(*this)))
|
||||
{
|
||||
szErrorMessage = _T("AddProcessThread failed(StatServerProcessThread)");
|
||||
}
|
||||
else if(NULL == (m_lpCommandQueueThread = new CCommandQueueThread))
|
||||
{
|
||||
szErrorMessage = _T("CCommandQueueThread create failed");
|
||||
}
|
||||
else if(!m_lpCommandQueueThread->IsValid())
|
||||
{
|
||||
szErrorMessage = _T("CCommandQueueThread is Invalid");
|
||||
}
|
||||
else if(!AddProcessThread(m_lpCommandQueueThread))
|
||||
{
|
||||
szErrorMessage = _T("AddProcessThread failed(CCommandQueueThread)");
|
||||
}
|
||||
else if(!InitializeMsgProc())
|
||||
{
|
||||
szErrorMessage = _T("Initialize message proc failed");
|
||||
}
|
||||
else if(!InitializeCommand())
|
||||
{
|
||||
szErrorMessage = _T("Initialize command failed");
|
||||
}
|
||||
else if(!CStatisticsDB::GetInstance().ConnectStatDB())
|
||||
{
|
||||
szErrorMessage = _T("Initialize StatDB failed");
|
||||
}
|
||||
|
||||
m_tServerStart = time(NULL);
|
||||
|
||||
if(NULL != szErrorMessage)
|
||||
{
|
||||
ERRLOG2(g_Log, "this:0x%p / %s", this, szErrorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CStatServer::UpdateConsole()
|
||||
{
|
||||
const int MAX_INFO = 4096;
|
||||
char szInfo[MAX_INFO];
|
||||
|
||||
time_t tCurrent = time(NULL);
|
||||
time_t tDiffTime = tCurrent - m_tServerStart;
|
||||
|
||||
time_t tDiffDay = tDiffTime / 3600 / 24;
|
||||
time_t tDiffHour = (tDiffTime / 3600) % 24;
|
||||
time_t tDiffMinute = (tDiffTime % 3600) / 60;
|
||||
|
||||
struct tm tmServerStart = *localtime(&m_tServerStart);
|
||||
struct tm tmCurrent = *localtime(&tCurrent);
|
||||
|
||||
int nLength = _snprintf(szInfo, MAX_INFO - 1,
|
||||
"[GAMA Statistics Server]\r\n\r\n"
|
||||
"Server Start Time : %04d-%02d-%02d %02d:%02d:%02d\r\n"
|
||||
"Current Server Time : %04d-%02d-%02d %02d:%02d:%02d\r\n"
|
||||
"\r\n"
|
||||
"Server Operate Time : %04d Days %02d Hours %02d Minutes",
|
||||
|
||||
tmServerStart.tm_year + 1900, tmServerStart.tm_mon + 1, tmServerStart.tm_mday,
|
||||
tmServerStart.tm_hour, tmServerStart.tm_min, tmServerStart.tm_sec,
|
||||
|
||||
tmCurrent.tm_year + 1900, tmCurrent.tm_mon + 1, tmCurrent.tm_mday,
|
||||
tmCurrent.tm_hour, tmCurrent.tm_min, tmCurrent.tm_sec,
|
||||
|
||||
tDiffDay, tDiffHour, tDiffMinute);
|
||||
|
||||
if(0 < nLength && nLength < MAX_INFO)
|
||||
{
|
||||
szInfo[nLength] = 0;
|
||||
PrintInfo(szInfo, nLength);
|
||||
}
|
||||
}
|
||||
36
Server/UserStatistics/StatServer/StatServer.h
Normal file
36
Server/UserStatistics/StatServer/StatServer.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef _STAT_SERVER_H_
|
||||
#define _STAT_SERVER_H_
|
||||
|
||||
#include <Utility/ServerAppFramework/ServerWindowFramework.h>
|
||||
|
||||
|
||||
// forward decl.
|
||||
class CSessionPolicy;
|
||||
class CCommandQueueThread;
|
||||
|
||||
|
||||
class CStatServer : public CServerWindowFramework
|
||||
{
|
||||
public:
|
||||
|
||||
static CStatServer& GetInstance();
|
||||
|
||||
void UpdateConsole();
|
||||
|
||||
private:
|
||||
|
||||
CStatServer();
|
||||
virtual ~CStatServer();
|
||||
|
||||
virtual bool ApplicationSpecificInit(const TCHAR* szCmdLine);
|
||||
|
||||
bool InitializeMsgProc();
|
||||
bool InitializeCommand();
|
||||
|
||||
CSessionPolicy* m_lpServerSessionPolicy;
|
||||
CCommandQueueThread* m_lpCommandQueueThread;
|
||||
|
||||
time_t m_tServerStart;
|
||||
};
|
||||
|
||||
#endif
|
||||
196
Server/UserStatistics/StatServer/StatServer.vcproj
Normal file
196
Server/UserStatistics/StatServer/StatServer.vcproj
Normal file
@@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="StatServer"
|
||||
ProjectGUID="{05A0302D-2E03-4CC0-B363-94DCE9D8AE58}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../Executable/$(ConfigurationName)"
|
||||
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./;../;../../RylServerProject/BaseLibrary;../../RylServerProject/RylServerLibrary"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/StatServer.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/StatServer.pdb"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../Executable/$(ConfigurationName)"
|
||||
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="./;../;../../RylServerProject/BaseLibrary;../../RylServerProject/RylServerLibrary"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/StatServer.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Resource"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
<File
|
||||
RelativePath=".\res\small.ico">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\res\StatServer.ico">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\res\StatServer.rc">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\StatisticsDB.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StatServer.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StatServerCommand.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StatServerDispatch.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StatServerMsgProcess.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\resource.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StatisticsDB.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StatServer.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StatServerDispatch.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="DB"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\StatDB_Create.sql">
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StatServerSetup.ini">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
37
Server/UserStatistics/StatServer/StatServerCommand.cpp
Normal file
37
Server/UserStatistics/StatServer/StatServerCommand.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "stdafx.h"
|
||||
#include "StatServer.h"
|
||||
#include <Log/ServerLog.h>
|
||||
#include <Utility/ServerAppFrameWork/ConsoleWindow/ConsoleCMDFactory.h>
|
||||
|
||||
|
||||
class CCMDPrintLog : public CConsoleCMDSingleton<CCMDPrintLog>
|
||||
{
|
||||
protected:
|
||||
virtual bool DoProcess()
|
||||
{
|
||||
SERLOG0(g_Log, "Flush log");
|
||||
SERLOG0(g_SessionLog, "Flush log");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
bool CStatServer::InitializeCommand()
|
||||
{
|
||||
#define INIT_COMMAND_FAILED(detail) TEXT("Command create failed - "##detail)
|
||||
|
||||
#define ADD_COMMAND(cmdstring, cmdobject, errmsg_val) \
|
||||
if(0 == (errmsg_val) && !GetCommandFactory()->AddCommand(cmdstring, new cmdobject)) { \
|
||||
(errmsg_val) = INIT_COMMAND_FAILED(cmdstring); }
|
||||
|
||||
const TCHAR* szErrorMessage = 0;
|
||||
|
||||
ADD_COMMAND("flush", CCMDPrintLog, szErrorMessage);
|
||||
|
||||
if(0 != szErrorMessage)
|
||||
{
|
||||
ERRLOG0(g_Log, szErrorMessage);
|
||||
return false;
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
99
Server/UserStatistics/StatServer/StatServerDispatch.cpp
Normal file
99
Server/UserStatistics/StatServer/StatServerDispatch.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
#include "stdafx.h"
|
||||
#include "StatServerDispatch.h"
|
||||
#include "StatisticsDB.h"
|
||||
|
||||
#include <Network/Session/Session.h>
|
||||
#include <Network/Dispatch/MultiDispatchStorage.h>
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Log/ServerLog.h>
|
||||
#include <DB/OLEDB.h>
|
||||
|
||||
|
||||
enum StatServerConst
|
||||
{
|
||||
STAT_SERVER_DEFAULT_DISPATCH_NUM = 10
|
||||
};
|
||||
|
||||
|
||||
CStatServerDispatch::CStatServerDispatch(CSession& Session)
|
||||
: CRylServerDispatch(Session, STAT_SERVER_DEFAULT_DISPATCH_NUM)
|
||||
{
|
||||
DETLOG1(g_Log, "this:0x%p/CStatServerDispatch Created", this);
|
||||
}
|
||||
|
||||
|
||||
CStatServerDispatch::~CStatServerDispatch()
|
||||
{
|
||||
DETLOG1(g_Log, "this:0x%p/CStatServerDispatch Destroyed", this);
|
||||
}
|
||||
|
||||
bool CStatServerDispatch::DispatchPacket(PktBase* lpPktBase)
|
||||
{
|
||||
switch(lpPktBase->GetCmd())
|
||||
{
|
||||
case ServerManage::CMD::UPDATE_USER_STATUS:
|
||||
UserStatUpdate(lpPktBase);
|
||||
break;
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStatServerDispatch::UserStatUpdate(PktBase* lpPktBase)
|
||||
{
|
||||
ServerManage::PktUserStat* lpPktUserStat =
|
||||
reinterpret_cast<ServerManage::PktUserStat*>(lpPktBase);
|
||||
|
||||
ServerManage::UserStatData* lpUserStatData =
|
||||
reinterpret_cast<ServerManage::UserStatData*>(lpPktUserStat + 1);
|
||||
|
||||
ServerManage::UserStatData* lpUserStatDataEnd =
|
||||
lpUserStatData + lpPktUserStat->m_usUserStatDataNum;
|
||||
|
||||
if(NULL != lpPktUserStat->m_szSendingTime)
|
||||
{
|
||||
const int QUERY_LEN = 512;
|
||||
char szQuery[QUERY_LEN];
|
||||
|
||||
OleDB* lpStatDB = CStatisticsDB::GetInstance().GetStatDB();
|
||||
if(NULL != lpStatDB)
|
||||
{
|
||||
for(; lpUserStatData != lpUserStatDataEnd; ++lpUserStatData)
|
||||
{
|
||||
if (0 != lpUserStatData->m_nUserNum)
|
||||
{
|
||||
SERVER_ID serverID;
|
||||
serverID.dwID = lpUserStatData->m_dwServerID;
|
||||
|
||||
int nLength = _snprintf(szQuery, QUERY_LEN,
|
||||
"INSERT INTO TblRYLUserStat(nNation, nGroup, nType, nZone, nCH, nUserNum, tDateTime) "
|
||||
"VALUES(%d, %d, %d, %d, %d, %d, '%s')",
|
||||
lpUserStatData->m_nNation,
|
||||
serverID.GetGroup(), serverID.GetType(), serverID.GetZone(), serverID.GetChannel(),
|
||||
lpUserStatData->m_nUserNum, lpPktUserStat->m_szSendingTime);
|
||||
|
||||
if(0 < nLength)
|
||||
{
|
||||
if(!lpStatDB->ExecuteQuery(szQuery))
|
||||
{
|
||||
ERRLOG2(g_Log, "Query Failed: %s (Err-%s)", szQuery, lpStatDB->GetErrorString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
szQuery[QUERY_LEN - 1] = 0;
|
||||
ERRLOG1(g_Log, "Make query text failed", szQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRLOG0(g_Log, "Failed Getting StatDB");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
27
Server/UserStatistics/StatServer/StatServerDispatch.h
Normal file
27
Server/UserStatistics/StatServer/StatServerDispatch.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef _STAT_SERVER_DISPATCH_H_
|
||||
#define _STAT_SERVER_DISPATCH_H_
|
||||
|
||||
#include <Network/Packet/ManagePacketCmd.h>
|
||||
#include <Network/Dispatch/RylServerDispatch.h>
|
||||
#include <Network/Dispatch/MultiDispatchStorage.h>
|
||||
|
||||
class CStatServerDispatch : public CRylServerDispatch
|
||||
{
|
||||
public:
|
||||
|
||||
static CMultiDispatch& GetDispatchTable()
|
||||
{
|
||||
static CMultiDispatch multiDispatch;
|
||||
return multiDispatch;
|
||||
}
|
||||
|
||||
CStatServerDispatch(CSession& Session);
|
||||
virtual ~CStatServerDispatch();
|
||||
|
||||
private:
|
||||
virtual bool DispatchPacket(PktBase* lpPktBase);
|
||||
|
||||
bool UserStatUpdate(PktBase* lpPktBase);
|
||||
};
|
||||
|
||||
#endif
|
||||
58
Server/UserStatistics/StatServer/StatServerMsgProcess.cpp
Normal file
58
Server/UserStatistics/StatServer/StatServerMsgProcess.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "stdafx.h"
|
||||
#include "resource.h"
|
||||
#include "StatServer.h"
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
#include <Utility/ServerAppFramework/MsgProc/MsgProc.h>
|
||||
#include <Utility/ServerAppFramework/ConsoleWindow/ConsoleWindow.h>
|
||||
|
||||
class CProcessCOMMAND : public CMsgProc
|
||||
{
|
||||
public:
|
||||
|
||||
CProcessCOMMAND(CConsoleWindow& ConsoleWindow)
|
||||
: m_ConsoleWindow(ConsoleWindow) { }
|
||||
virtual ~CProcessCOMMAND() { }
|
||||
|
||||
virtual LRESULT operator () (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
char* szCommand = 0;
|
||||
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case ID_MENU_OPENCONSOLE: m_ConsoleWindow.Initialize("Stat Server"); break;
|
||||
case ID_MENU_CLOSECONSOLE: m_ConsoleWindow.Destroy(); break;
|
||||
case ID_MENU_FLUSH: g_Log.Flush(); break;
|
||||
}
|
||||
|
||||
if(LOWORD(wParam) == IDM_EXIT)
|
||||
{
|
||||
DETLOG0(g_Log, "Terminate StatServer System Tray.");
|
||||
PostMessage(hWnd, WM_QUIT, 0, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
CConsoleWindow& m_ConsoleWindow;
|
||||
};
|
||||
|
||||
|
||||
bool CStatServer::InitializeMsgProc()
|
||||
{
|
||||
int nErrorCount = 0;
|
||||
CMsgProcessMgr* lpMsgProcessMgr = GetMsgProcessMgr();
|
||||
|
||||
if(0 != lpMsgProcessMgr)
|
||||
{
|
||||
if(GetConsoleWindow())
|
||||
{
|
||||
nErrorCount += lpMsgProcessMgr->Register(WM_COMMAND,
|
||||
new CProcessCOMMAND(*GetConsoleWindow())) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
return (0 == nErrorCount);
|
||||
}
|
||||
6
Server/UserStatistics/StatServer/StatServerSetup.ini
Normal file
6
Server/UserStatistics/StatServer/StatServerSetup.ini
Normal file
@@ -0,0 +1,6 @@
|
||||
[STAT_DB_INFO]
|
||||
|
||||
DB_IP = 61.251.229.189
|
||||
DB_NAME = GAMAUSERSTAT
|
||||
DB_ACCOUNT = STAT
|
||||
DB_PASS = !dkEkEkQnrkt@
|
||||
57
Server/UserStatistics/StatServer/StatisticsDB.cpp
Normal file
57
Server/UserStatistics/StatServer/StatisticsDB.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "stdafx.h"
|
||||
#include "StatServer.h"
|
||||
#include "StatisticsDB.h"
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
#include <DB/OLEDB.h>
|
||||
|
||||
|
||||
const TCHAR* g_szFileName = _T("./StatServerSetup.ini");
|
||||
|
||||
|
||||
CStatisticsDB& CStatisticsDB::GetInstance()
|
||||
{
|
||||
static CStatisticsDB statisticsDB;
|
||||
return statisticsDB;
|
||||
}
|
||||
|
||||
CStatisticsDB::CStatisticsDB()
|
||||
: m_lpOleDB(new (std::nothrow) OleDB)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
CStatisticsDB::~CStatisticsDB()
|
||||
{
|
||||
if(0 != m_lpOleDB)
|
||||
{
|
||||
delete m_lpOleDB;
|
||||
m_lpOleDB = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool CStatisticsDB::ConnectStatDB()
|
||||
{
|
||||
if(0 == m_lpOleDB)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const int MAX_BUFFER = 256;
|
||||
char szDBIP[MAX_BUFFER], szDBName[MAX_BUFFER], szDBAccount[MAX_BUFFER], szDBPass[MAX_BUFFER];
|
||||
|
||||
GetPrivateProfileString("STAT_DB_INFO", "DB_IP", 0, szDBIP, MAX_BUFFER, g_szFileName);
|
||||
GetPrivateProfileString("STAT_DB_INFO", "DB_NAME", 0, szDBName, MAX_BUFFER, g_szFileName);
|
||||
GetPrivateProfileString("STAT_DB_INFO", "DB_ACCOUNT", 0, szDBAccount, MAX_BUFFER, g_szFileName);
|
||||
GetPrivateProfileString("STAT_DB_INFO", "DB_PASS", 0, szDBPass, MAX_BUFFER, g_szFileName);
|
||||
|
||||
if(!m_lpOleDB->ConnectSQLServer(szDBIP, szDBName, szDBAccount, szDBPass, OleDB::ConnType_MSSQL))
|
||||
{
|
||||
ERRLOG4(g_Log, "StatDB Connection Failed: %s/%s/%s/%s", szDBIP, szDBName, szDBAccount, szDBPass);
|
||||
return false;
|
||||
}
|
||||
|
||||
INFLOG0(g_Log, "StatDB Connection Success");
|
||||
return true;
|
||||
}
|
||||
24
Server/UserStatistics/StatServer/StatisticsDB.h
Normal file
24
Server/UserStatistics/StatServer/StatisticsDB.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _STATISTICS_DATABASE_
|
||||
#define _STATISTICS_DATABASE_
|
||||
|
||||
// forward decl.
|
||||
class OleDB;
|
||||
|
||||
class CStatisticsDB
|
||||
{
|
||||
public:
|
||||
|
||||
static CStatisticsDB& GetInstance();
|
||||
|
||||
bool ConnectStatDB();
|
||||
OleDB* GetStatDB() { return m_lpOleDB; };
|
||||
|
||||
private:
|
||||
|
||||
CStatisticsDB();
|
||||
~CStatisticsDB();
|
||||
|
||||
OleDB* m_lpOleDB;
|
||||
};
|
||||
|
||||
#endif
|
||||
BIN
Server/UserStatistics/StatServer/res/StatServer.ico
Normal file
BIN
Server/UserStatistics/StatServer/res/StatServer.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
137
Server/UserStatistics/StatServer/res/StatServer.rc
Normal file
137
Server/UserStatistics/StatServer/res/StatServer.rc
Normal file
@@ -0,0 +1,137 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// <20>ѱ<EFBFBD><D1B1><EFBFBD> resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
|
||||
#pragma code_page(949)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_STATSERVER ICON "StatServer.ico"
|
||||
IDI_SMALL ICON "small.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDC_STATSERVER MENU
|
||||
BEGIN
|
||||
POPUP "Menu(&M)"
|
||||
BEGIN
|
||||
MENUITEM "Open Console(&O)", ID_MENU_OPENCONSOLE
|
||||
MENUITEM "Close Console(&C)", ID_MENU_CLOSECONSOLE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Flush(&F)", ID_MENU_FLUSH
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Shutdown(&S)", IDM_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDC_STATSERVER ACCELERATORS
|
||||
BEGIN
|
||||
"?", IDM_ABOUT, ASCII, ALT
|
||||
"/", IDM_ABOUT, ASCII, ALT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG 22, 17, 230, 75
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "<22><><EFBFBD><EFBFBD>"
|
||||
FONT 9, "System"
|
||||
BEGIN
|
||||
ICON IDI_STATSERVER,IDC_MYICON,14,9,16,16
|
||||
LTEXT "StatServer <20><><EFBFBD><EFBFBD> 1.0",IDC_STATIC,49,10,119,8,SS_NOPREFIX
|
||||
LTEXT "Copyright (C) 2004",IDC_STATIC,49,20,119,8
|
||||
DEFPUSHBUTTON "Ȯ<><C8AE>",IDOK,195,6,30,11,WS_GROUP
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""windows.h""\r\n"
|
||||
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_APP_TITLE "StatServer"
|
||||
IDC_STATSERVER "STATSERVER"
|
||||
END
|
||||
|
||||
#endif // <20>ѱ<EFBFBD><D1B1><EFBFBD> resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
BIN
Server/UserStatistics/StatServer/res/small.ico
Normal file
BIN
Server/UserStatistics/StatServer/res/small.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
30
Server/UserStatistics/StatServer/resource.h
Normal file
30
Server/UserStatistics/StatServer/resource.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by StatServer.rc
|
||||
//
|
||||
#define IDC_MYICON 2
|
||||
#define IDD_STATSERVER_DIALOG 102
|
||||
#define IDS_APP_TITLE 103
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDM_EXIT 105
|
||||
#define IDI_STATSERVER 107
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_STATSERVER 109
|
||||
#define IDR_MAINFRAME 128
|
||||
#define ID_MENU_CLOSECONSOLE 32771
|
||||
#define ID_MENU_FLUSH 32772
|
||||
#define ID_MENU_OPENCONSOLE 32773
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32774
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
8
Server/UserStatistics/StatServer/stdafx.cpp
Normal file
8
Server/UserStatistics/StatServer/stdafx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : ǥ<><C7A5> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ϸ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
// StatServer.pch<63><68> <20≯<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>˴ϴ<CBB4>.
|
||||
// stdafx.obj<62><6A><EFBFBD><EFBFBD> <20≯<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Ե˴ϴ<CBB4>.
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: <20>ʿ<EFBFBD><CABF><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴ<EFBFBD> STDAFX.H<><48><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
18
Server/UserStatistics/StatServer/stdafx.h
Normal file
18
Server/UserStatistics/StatServer/stdafx.h
Normal file
@@ -0,0 +1,18 @@
|
||||
// stdafx.h : <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ<EFBFBD>
|
||||
// ǥ<><C7A5> <20>ý<EFBFBD><C3BD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Windows <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
// Windows <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
#include <windows.h>
|
||||
// C<><43> <20><>Ÿ<EFBFBD><C5B8> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
|
||||
// TODO: <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E2BFA1> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
Reference in New Issue
Block a user