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:
291
Server/AdminTool/AdminToolLibrary/dbcomponent/RYL_GameDB.cpp
Normal file
291
Server/AdminTool/AdminToolLibrary/dbcomponent/RYL_GameDB.cpp
Normal file
@@ -0,0 +1,291 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "RYL_GameDB.h"
|
||||
#include <Log/ServerLog.h>
|
||||
#include <Network/Packet/PacketStruct/UnifiedCharPacket.h>
|
||||
|
||||
|
||||
// UID<49><44> <20>ɷ<EFBFBD><C9B7>ִ<EFBFBD> <20><><EFBFBD><EFBFBD> ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD>.
|
||||
bool CGameDB::UIDByCharacterList(unsigned long UID, unsigned int nAgentType,
|
||||
unsigned int nOldServerID, void* GetData)
|
||||
{
|
||||
char* first = reinterpret_cast<char*>(GetData);
|
||||
unsigned char* lpCount = reinterpret_cast<unsigned char*>(first);
|
||||
char* In_CharPos = static_cast<char*>(first + 1);
|
||||
|
||||
CGameDB::In_UserInfo TblUserInfo;
|
||||
CGameDB::Out_CharList* lpOut_CharList;
|
||||
|
||||
*lpCount = 0;
|
||||
ZeroMemory(&TblUserInfo, sizeof(CGameDB::In_UserInfo));
|
||||
|
||||
if (UnifiedConst::Part2Selectable == nAgentType)
|
||||
{
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT Char1, Char2, Char3, Char4, Char5 FROM UserInfo "
|
||||
"WHERE UID = %d AND OldServerGroupID = %d", UID, nOldServerID);
|
||||
}
|
||||
else
|
||||
{
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT Char1, Char2, Char3, Char4, Char5 FROM UserInfo "
|
||||
"WHERE UID = %d AND OldServerGroupID IN (%d, %d)",
|
||||
UID, UnifiedConst::ROW, UnifiedConst::Part2Unified);
|
||||
}
|
||||
|
||||
if (true == ExecuteQuery(m_szQuery))
|
||||
{
|
||||
if(this->GetData(&TblUserInfo))
|
||||
{
|
||||
char* CharCID = reinterpret_cast<char*>(&TblUserInfo);
|
||||
for(int cnt = 0; cnt < SIZE::MAX_CHAR_SLOT; cnt++)
|
||||
{
|
||||
unsigned long* CID = reinterpret_cast<unsigned long*>(CharCID + (sizeof(unsigned long) * cnt));
|
||||
|
||||
lpOut_CharList = reinterpret_cast<CGameDB::Out_CharList*>(
|
||||
In_CharPos + ((*lpCount) * sizeof(CGameDB::Out_CharList)));
|
||||
|
||||
if(*CID)
|
||||
{
|
||||
lpOut_CharList->m_UID = UID;
|
||||
lpOut_CharList->m_CID = *CID;
|
||||
CIDByCharacterName(*CID, lpOut_CharList->m_szCharName);
|
||||
*lpCount += 1;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CGameDB::UIDbyUserInfo(unsigned long dwUID, unsigned int nAgentType,
|
||||
unsigned int nOldServerID, void* GetData)
|
||||
{
|
||||
if (UnifiedConst::Part2Selectable == nAgentType)
|
||||
{
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT Char1, Char2, Char3, Char4, Char5 FROM UserInfo "
|
||||
"WHERE UID = %d AND OldServerGroupID = %d", dwUID, nOldServerID);
|
||||
}
|
||||
else
|
||||
{
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT Char1, Char2, Char3, Char4, Char5 FROM UserInfo "
|
||||
"WHERE UID = %d AND OldServerGroupID IN (%d, %d)",
|
||||
dwUID, UnifiedConst::ROW, UnifiedConst::Part2Unified);
|
||||
}
|
||||
|
||||
if (true == ExecuteQuery(m_szQuery))
|
||||
{
|
||||
if(this->GetData(GetData))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CGameDB::GetUserNation(unsigned int nAgentType, unsigned long dwUID,
|
||||
unsigned long dwCID, void* GetData)
|
||||
{
|
||||
// CID<49><44><EFBFBD><EFBFBD> OldServerGroupID<49><44> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><EFBFBD><D7B7><EFBFBD> <20>Ϸ<EFBFBD><CFB7><EFBFBD> Ŭ<><C5AC><EFBFBD>̾<EFBFBD>Ʈ<EFBFBD>ʿ<EFBFBD> <20>ַλ<D6B7><CEBB><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ɴ<EFBFBD>.
|
||||
|
||||
if (UnifiedConst::Part2Selectable == nAgentType)
|
||||
{
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT Nation FROM UserInfo "
|
||||
"WHERE UID = %d AND (Char1 = %u OR Char2 = %u OR Char3 = %u OR Char4 = %u OR Char5 = %u)",
|
||||
dwUID, dwCID, dwCID, dwCID, dwCID, dwCID);
|
||||
}
|
||||
else
|
||||
{
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT Nation FROM UserInfo "
|
||||
"WHERE UID = %d AND OldServerGroupID IN (%d, %d)",
|
||||
dwUID, UnifiedConst::ROW, UnifiedConst::Part2Unified);
|
||||
}
|
||||
|
||||
if (true == ExecuteQuery(m_szQuery))
|
||||
{
|
||||
if (this->GetData(GetData))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ERRLOG1(g_Log, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>- %s", GetErrorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
// ij<><C4B3><EFBFBD><EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD><EFBFBD><EFBFBD> <20>˻<EFBFBD>
|
||||
bool CGameDB::CNameByCharacterList(char* szCharacterName, void* GetData)
|
||||
{
|
||||
char* first = reinterpret_cast<char*>(GetData);
|
||||
unsigned char* lpCount = reinterpret_cast<unsigned char*>(first);
|
||||
|
||||
char* In_CharPos = static_cast<char*>(first + 1);
|
||||
|
||||
CGameDB::Out_CharList* lpOut_CharList = reinterpret_cast<CGameDB::Out_CharList*>(In_CharPos);
|
||||
|
||||
unsigned long dwCID;
|
||||
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT NewCID FROM TblUnifiedCharList "
|
||||
"WHERE NewCID IN (SELECT CID FROM CharInfo WHERE Name = '%s') "
|
||||
"AND (OldServerGroupID <= 15 OR OldServerGroupID IN (%d, %d, %d))",
|
||||
szCharacterName, UnifiedConst::ROW, UnifiedConst::Part2Unified, UnifiedConst::Part2Selectable);
|
||||
|
||||
if (true == ExecuteQuery(m_szQuery))
|
||||
{
|
||||
if (this->GetData(&dwCID))
|
||||
{
|
||||
*lpCount = 1;
|
||||
lpOut_CharList = reinterpret_cast<CGameDB::Out_CharList*>(In_CharPos);
|
||||
lpOut_CharList->m_CID = dwCID;
|
||||
|
||||
if(!CIDByCharacterName(dwCID, lpOut_CharList->m_szCharName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!CIDByUID(dwCID, &lpOut_CharList->m_UID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameDB::CharacterNameByCID(char* szCharacterName, void* GetData)
|
||||
{
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT CID FROM CharInfo WHERE Name = '%s'", szCharacterName);
|
||||
|
||||
if(!ExecuteQueryGetData(m_szQuery, GetData))
|
||||
{
|
||||
ERRLOG2(g_Log, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD>-%s, <20><><EFBFBD><EFBFBD>-%s", m_szQuery, GetErrorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// CID<49><44> ij<><C4B3><EFBFBD><EFBFBD> <20>˻<EFBFBD>
|
||||
bool CGameDB::CIDByCharacterList(unsigned long CID, void* GetData)
|
||||
{
|
||||
char* first = reinterpret_cast<char*>(GetData);
|
||||
unsigned char* lpCount = reinterpret_cast<unsigned char*>(first);
|
||||
char* In_CharPos = static_cast<char*>(first + 1);
|
||||
|
||||
CGameDB::Out_CharList* lpOut_CharList = reinterpret_cast<CGameDB::Out_CharList*>(In_CharPos);
|
||||
|
||||
*lpCount = 1;
|
||||
lpOut_CharList->m_CID = CID;
|
||||
|
||||
if (false == CIDByCharacterName(CID, lpOut_CharList->m_szCharName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == CIDByUID(CID, &lpOut_CharList->m_UID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// CID<49><44> UID<49>˻<EFBFBD>
|
||||
bool CGameDB::CIDByUID(unsigned long CID, void* GetData)
|
||||
{
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT UID FROM UserInfo WHERE Char1 = %d OR Char2 = %d OR Char3 = %d OR Char4 = %d OR Char5 = %d",
|
||||
CID, CID, CID, CID, CID);
|
||||
|
||||
if (true == ExecuteQuery(m_szQuery))
|
||||
{
|
||||
if (this->GetData(GetData))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
GetData = NULL;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// CID<49><44> ij<><C4B3><EFBFBD><EFBFBD> <20≯<EFBFBD> <20>˻<EFBFBD>
|
||||
bool CGameDB::CIDByCharacterName(unsigned long CID, void* GetData)
|
||||
{
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH, "SELECT Name FROM CharInfo WHERE CID = %d", CID);
|
||||
|
||||
if (true == ExecuteQuery(m_szQuery))
|
||||
{
|
||||
if(this->GetData(GetData))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
GetData = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CGameDB::ChangeName(unsigned long dwCID, char* szName)
|
||||
{
|
||||
// <20>߰輭<DFB0><E8BCAD><EFBFBD><EFBFBD> ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>û<EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>.
|
||||
/*
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"UPDATE CharInfo SET Name = '%s' WHERE CID = %d", szName, dwCID);
|
||||
|
||||
if(!ExecuteQuery(m_szQuery))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameDB::UseCharacterName(char* szName)
|
||||
{
|
||||
char result[20];
|
||||
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT Name FROM CharInfo WHERE Name = '%s'", szName);
|
||||
|
||||
if(ExecuteQuery(m_szQuery))
|
||||
{
|
||||
if(GetData(result))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned char CGameDB::GetOldServerGroupID(unsigned long dwCID)
|
||||
{
|
||||
unsigned char cOldServerGroupID = 0;
|
||||
|
||||
_snprintf(m_szQuery, MAX_QUERY_LENGTH,
|
||||
"SELECT OldServerGroupID FROM UserInfo"
|
||||
" WHERE Char1 = %u OR Char2 = %u OR Char3 = %u OR Char4 = %u OR Char5 = %u",
|
||||
dwCID, dwCID, dwCID, dwCID, dwCID);
|
||||
|
||||
if (true == ExecuteQueryGetData(m_szQuery, &cOldServerGroupID))
|
||||
{
|
||||
return cOldServerGroupID;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user