Files
Client/Server/DBProcess/RylDBLibrary/RylDBStoreCommand.cpp
LGram16 dd97ddec92 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>
2025-11-29 20:17:20 +09:00

155 lines
4.3 KiB
C++

#include <Log/ServerLog.h>
#include "RylDBStoreCommand.h"
namespace RylDBCommand
{
#define BOUNDED_SUBTRACT(data, minusval, minbound) if ((data) < (minusval) + (minbound)) { (data) = (minbound); } else { (data) -= (minusval); }
void CUnifiedStore1::Init(void)
{
m_UID = 0;
m_Flag = 0;
m_Gold = 0;
memset(m_Store, 0, sizeof(STORE));
memset(m_Password, 0, sizeof(char) * STORE_INFO::MAX_PASS_LEN * 2);
m_OldServerGroupID = 0;
m_bAdjustedSize = false;
m_StoreLength = 0;
m_PasswordLength = 0;
m_UIDStatus = DBSTATUS_S_OK;
m_OldServerGroupIDStatus = DBSTATUS_S_OK;
m_PasswordStatus = DBSTATUS_S_OK;
m_FlagStatus = DBSTATUS_S_OK;
m_GoldStatus = DBSTATUS_S_OK;
m_StoreStatus = DBSTATUS_S_OK;
}
void CUnifiedStore1::AdjustSize(bool bRestore)
{
if (bRestore && m_bAdjustedSize)
{
reinterpret_cast<STORE&>(m_Store).dwSize += sizeof(unsigned long);
m_bAdjustedSize = false;
}
else if (!bRestore && !m_bAdjustedSize)
{
BOUNDED_SUBTRACT(reinterpret_cast<STORE&>(m_Store).dwSize, sizeof(unsigned long), 0);
m_bAdjustedSize = true;
}
}
void CUnifiedStore1::LogError(DBErrorType eErrorType, HRESULT hr)
{
switch(eErrorType)
{
case DBERR_CONVERT_FAILED:
ERRLOG1(g_Log, "UID:%10u / UnifiedStore1 데이터 처리 실패", GetUID());
break;
case DBERR_SETDATA_FAILED:
ERRLOG3(g_Log, "UID:%10u / hr:0x%08x / UnifiedStore1 SetData 실패 : DBStatus:%s",
GetUID(), hr, GetDBStatus());
break;
case DBERR_UPDATE_FAILED:
ERRLOG3(g_Log, "UID:%10u / hr:0x%08x / UnifiedStore1 Update 실패 : DBStatus:%s",
GetUID(), hr, GetDBStatus());
break;
}
}
bool CUnifiedStore1::operator == (const CUnifiedStore1& rhs) const
{
return
m_UID == rhs.m_UID &&
m_Flag == rhs.m_Flag &&
m_Gold == rhs.m_Gold &&
m_OldServerGroupID == rhs.m_OldServerGroupID &&
0 == memcmp(m_Store, rhs.m_Store, sizeof(STORE)) &&
0 == memcmp(m_Password, rhs.m_Password, sizeof(char) * STORE_INFO::MAX_PASS_LEN * 2);
}
CString CUnifiedStore1::GetDBStatus()
{
CString dbStatus;
m_Password[STORE_INFO::MAX_PASS_LEN - 1] = 0;
dbStatus.Format("UID:%10u(0x%08x) OldServerGroupID:%3d(0x%08x) Password:%s(0x%08x) "
"Flag:0x%08x(0x%08x) Gold:%10u(0x%08x) StoreLen:%4u(0x%08x)",
m_UID, m_UIDStatus, m_OldServerGroupID, m_OldServerGroupIDStatus,
m_Password, m_PasswordStatus, m_Flag, m_FlagStatus,
m_Gold, m_GoldStatus, GetStore().dwSize, m_StoreStatus);
return dbStatus;
}
void CUnifiedStore2::Init(void)
{
m_UID = 0;
memset(m_Store, 0, sizeof(STORE));
m_OldServerGroupID = 0;
m_bAdjustedSize = false;
m_StoreLength = 0;
m_UIDStatus = DBSTATUS_S_OK;
m_StoreStatus = DBSTATUS_S_OK;
m_OldServerGroupIDStatus = DBSTATUS_S_OK;
}
void CUnifiedStore2::AdjustSize(bool bRestore)
{
if (bRestore && m_bAdjustedSize)
{
reinterpret_cast<STORE&>(m_Store).dwSize += sizeof(unsigned long);
m_bAdjustedSize = false;
}
else if (!bRestore && !m_bAdjustedSize)
{
BOUNDED_SUBTRACT(reinterpret_cast<STORE&>(m_Store).dwSize, sizeof(unsigned long), 0);
m_bAdjustedSize = true;
}
}
void CUnifiedStore2::LogError(DBErrorType eErrorType, HRESULT hr)
{
switch(eErrorType)
{
case DBERR_CONVERT_FAILED:
ERRLOG1(g_Log, "UID:%10u / UnifiedStore2 데이터 처리 실패", GetUID());
break;
case DBERR_SETDATA_FAILED:
ERRLOG3(g_Log, "UID:%10u / hr:0x%08x / UnifiedStore2 SetData 실패 : DBStatus:%s",
GetUID(), hr, GetDBStatus());
break;
case DBERR_UPDATE_FAILED:
ERRLOG3(g_Log, "UID:%10u / hr:0x%08x / UnifiedStore2 Update 실패 : DBStatus:%s",
GetUID(), hr, GetDBStatus());
break;
}
}
bool CUnifiedStore2::operator == (const CUnifiedStore2& rhs) const
{
return
m_UID == rhs.m_UID &&
m_OldServerGroupID == rhs.m_OldServerGroupID &&
0 == memcmp(m_Store, rhs.m_Store, sizeof(STORE));
}
CString CUnifiedStore2::GetDBStatus()
{
CString dbStatus;
dbStatus.Format("UID:%10u(0x%08x) OldServerGroupID:%3d(0x%08x) StoreLen:%4u(0x%08x)",
m_UID, m_UIDStatus, m_OldServerGroupID, m_OldServerGroupIDStatus, GetStore().dwSize, m_StoreStatus);
return dbStatus;
}
}