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>
99 lines
2.4 KiB
C++
99 lines
2.4 KiB
C++
#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;
|
|
} |