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:
2025-11-29 20:17:20 +09:00
parent 5d3cd64a25
commit dd97ddec92
11602 changed files with 1446576 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
#include <Log/ServerLog.h>
#include <Utility/Setup/ServerSetup.h>
#include "DBComponent.h"
#include "AdminDBComponent.h"
bool DBComponent::AdminDB::StartCharChatBan(CDBComponent& DBComponent, unsigned long dwAdminCID,
unsigned long dwTargetCID, unsigned long dwMinutes)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
SYSTEMTIME localTime;
GetLocalTime(&localTime);
char strStartTime[MAX_PATH] = "";
char strEndTime[MAX_PATH] = "";
sprintf(strStartTime, "cast('%d-%d-%d %d:%d:%d' as smalldatetime)",
localTime.wYear, localTime.wMonth, localTime.wDay, localTime.wHour, localTime.wMinute, localTime.wSecond);
sprintf(strEndTime, "cast('2010-12-31 00:00:00' as smalldatetime)");
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(),
"INSERT INTO TblChatBanList(CID, ServerGroupID, RemainTime, AdminCID, StartTime, EndTime) VALUES(%d, %d, %d, %d, %s, %s)",
dwTargetCID, CServerSetup::GetInstance().GetServerGroup(), dwMinutes, dwAdminCID, strStartTime, strEndTime);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "채팅 금지 캐릭터 추가 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::AdminDB::GetCharChatBan(CDBComponent& DBComponent, unsigned long dwCID, unsigned long& dwMinutes)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(),
"SELECT RemainTime FROM TblChatBanList WHERE CID=%d AND RemainTime>0", dwCID);
if (!DBComponent.ExecuteQueryGetData(DBComponent.GetQueryBuffer(), (void*)&dwMinutes))
{
dwMinutes = 0;
return true;
}
return true;
}
bool DBComponent::AdminDB::EndCharChatBan(CDBComponent& DBComponent, unsigned long dwCID)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
SYSTEMTIME localTime;
GetLocalTime(&localTime);
char strEndTime[MAX_PATH] = "";
sprintf(strEndTime, "cast('%d-%d-%d %d:%d:%d' as smalldatetime)",
localTime.wYear, localTime.wMonth, localTime.wDay, localTime.wHour, localTime.wMinute, localTime.wSecond);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(),
"UPDATE TblChatBanList SET RemainTime=0, EndTime=%s WHERE CID=%d AND RemainTime>0", strEndTime, dwCID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "캐릭터 채팅 금지 종료 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::AdminDB::UpdateCharChatBanTime(CDBComponent& DBComponent, unsigned long dwCID, unsigned long dwMinutes)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(),
"UPDATE TblChatBanList SET RemainTime=%d WHERE CID=%d AND RemainTime>0", dwMinutes, dwCID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "채팅 금지 시간 업데이트 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}

View File

@@ -0,0 +1,18 @@
#ifndef _RYL_ADMIN_DB_COMPONENT_H_
#define _RYL_ADMIN_DB_COMPONENT_H_
// forward decl.
class CDBComponent;
namespace DBComponent
{
namespace AdminDB
{
bool StartCharChatBan(CDBComponent& DBComponent, unsigned long dwAdminCID, unsigned long dwTargetCID, unsigned long dwMinutes);
bool GetCharChatBan(CDBComponent& DBComponent, unsigned long dwCID, unsigned long& dwMinutes);
bool EndCharChatBan(CDBComponent& DBComponent, unsigned long dwCID);
bool UpdateCharChatBanTime(CDBComponent& DBComponent, unsigned long dwCID, unsigned long dwMinutes);
};
};
#endif

View File

@@ -0,0 +1,535 @@
#include "stdafx.h"
#include "DBComponent.h"
#include "AuthDBComponent.h"
#include <Utility/Math/Math.h>
#include <Utility/Debug/PerformanceCheck.h>
#include <Log/ServerLog.h>
#pragma pack(1)
struct HanLoginData
{
enum
{
ID_LEN = 16,
PASS_LEN = 32
};
char m_szAccount[ID_LEN];
char m_szPassword[PASS_LEN];
HAN_UID m_nUID;
};
struct GamaLoginData
{
enum
{
ID_LEN = 16,
PASS_LEN = 32
};
char m_szAccount[ID_LEN];
char m_szPassword[PASS_LEN];
unsigned long m_dwUID;
};
struct PCCheckAgreement
{
enum
{
// edith 2008.03.17 ID,PASS 길이조정
ID_LEN = 24,
};
char m_szAccount[ID_LEN];
unsigned long m_dwRet;
};
struct GamaGetAccountByUID
{
enum
{
ID_LEN = 20
};
unsigned long m_dwUID;
char m_szAccount[ID_LEN];
};
struct GamaGetUIDByAccount
{
enum
{
ID_LEN = 12
};
char m_szAccount[ID_LEN];
unsigned long m_dwUID;
};
#pragma pack()
class CAuthorizeParam
{
public:
static CAuthorizeParam& GetInstance();
OleDB::PARAM_INFO m_HanAuthParam; // 한게임 인증 파라미터 정보
OleDB::PARAM_INFO m_HanUpdateParam; // 업데이트 한
OleDB::PARAM_INFO m_HanRegParam;
OleDB::PARAM_INFO m_HanAuthCheckParam; // 이관 신청 여부 확인 정보.
OleDB::PARAM_INFO m_GamaAuthParam; // 인증 파라미터
OleDB::PARAM_INFO m_GamaGetAccountByUID; // UID로 계정명 얻기
OleDB::PARAM_INFO m_GamaGetUIDByAccount; // 계정명으로 UID얻기
private:
CAuthorizeParam();
};
CAuthorizeParam& CAuthorizeParam::GetInstance()
{
static CAuthorizeParam authParam;
return authParam;
}
CAuthorizeParam::CAuthorizeParam()
{
// 한게임 인증 파라미터
memset(&m_HanAuthParam, 0, sizeof(OleDB::PARAM_INFO));
m_HanAuthParam.ColNum = 3;
m_HanAuthParam.ColSize[0] = sizeof(char) * 16;
m_HanAuthParam.ColType[0] = DBTYPE_STR;
m_HanAuthParam.eParamIO[0] = DBPARAMIO_INPUT;
m_HanAuthParam.ColSize[1] = sizeof(char) * 32;
m_HanAuthParam.ColType[1] = DBTYPE_STR;
m_HanAuthParam.eParamIO[1] = DBPARAMIO_INPUT;
m_HanAuthParam.ColSize[2] = sizeof(INT64);
m_HanAuthParam.ColType[2] = DBTYPE_I8;
m_HanAuthParam.eParamIO[2] = DBPARAMIO_OUTPUT;
// 한게임 등록 파라미터
memset(&m_HanRegParam, 0, sizeof(OleDB::PARAM_INFO));
m_HanRegParam.ColNum = 2;
m_HanRegParam.ColSize[0] = sizeof(char) * 16;
m_HanRegParam.ColType[0] = DBTYPE_STR;
m_HanRegParam.eParamIO[0] = DBPARAMIO_INPUT;
m_HanRegParam.ColSize[1] = sizeof(char) * 3;
m_HanRegParam.ColType[1] = DBTYPE_STR;
m_HanRegParam.eParamIO[1] = DBPARAMIO_INPUT;
// 한게임 계정이전 파라미터
memset(&m_HanAuthCheckParam, 0, sizeof(OleDB::PARAM_INFO));
m_HanAuthCheckParam.ColNum = 2;
m_HanAuthCheckParam.ColSize[0] = sizeof(char) * 16;
m_HanAuthCheckParam.ColType[0] = DBTYPE_STR;
m_HanAuthCheckParam.eParamIO[0] = DBPARAMIO_INPUT;
m_HanAuthCheckParam.ColSize[1] = sizeof(unsigned long);
m_HanAuthCheckParam.ColType[1] = DBTYPE_I4;
m_HanAuthCheckParam.eParamIO[1] = DBPARAMIO_OUTPUT;
// 가마 인증 파라미터
memset(&m_GamaAuthParam, 0, sizeof(OleDB::PARAM_INFO));
m_GamaAuthParam.ColNum = 3;
m_GamaAuthParam.ColSize[0] = sizeof(char) * GamaLoginData::ID_LEN;
m_GamaAuthParam.ColType[0] = DBTYPE_STR;
m_GamaAuthParam.eParamIO[0] = DBPARAMIO_INPUT;
m_GamaAuthParam.ColSize[1] = sizeof(char) * GamaLoginData::PASS_LEN;
m_GamaAuthParam.ColType[1] = DBTYPE_STR;
m_GamaAuthParam.eParamIO[1] = DBPARAMIO_INPUT;
m_GamaAuthParam.ColSize[2] = sizeof(unsigned long);
m_GamaAuthParam.ColType[2] = DBTYPE_I4;
m_GamaAuthParam.eParamIO[2] = DBPARAMIO_OUTPUT;
// UID로 계정명 얻기
memset(&m_GamaGetAccountByUID, 0, sizeof(OleDB::PARAM_INFO));
m_GamaGetAccountByUID.ColNum = 2;
m_GamaGetAccountByUID.ColSize[0] = sizeof(unsigned long);
m_GamaGetAccountByUID.ColType[0] = DBTYPE_I4;
m_GamaGetAccountByUID.eParamIO[0] = DBPARAMIO_INPUT;
m_GamaGetAccountByUID.ColSize[1] = sizeof(char) * GamaGetAccountByUID::ID_LEN;
m_GamaGetAccountByUID.ColType[1] = DBTYPE_STR;
m_GamaGetAccountByUID.eParamIO[1] = DBPARAMIO_OUTPUT;
// 계정명으로 UID얻기
memset(&m_GamaGetUIDByAccount, 0, sizeof(OleDB::PARAM_INFO));
m_GamaGetUIDByAccount.ColNum = 2;
m_GamaGetUIDByAccount.ColSize[0] = sizeof(char) * GamaGetUIDByAccount::ID_LEN;
m_GamaGetUIDByAccount.ColType[0] = DBTYPE_STR;
m_GamaGetUIDByAccount.eParamIO[0] = DBPARAMIO_INPUT;
m_GamaGetUIDByAccount.ColSize[1] = sizeof(unsigned long);
m_GamaGetUIDByAccount.ColType[1] = DBTYPE_I4;
m_GamaGetUIDByAccount.eParamIO[1] = DBPARAMIO_OUTPUT;
}
//Interface/////////////////////////////////////////////////////////////////////////////////////
//
// 일본 인증
//
// Parameter :
//
// Do :
//
// Return :
//
///////////////////////////////////////////////////////////////////////////////////////////////
bool DBComponent::AuthDB::LoginAuthJapan(CDBComponent& DBComponent, const char *Account_In,
const char *Password_In, const char *szAddress, AUTH* lpAuthUser_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "LoginUserStatus '%s', '%s', '%s'",
Account_In, Password_In, szAddress);
if (DBComponent.ExecuteQueryGetData(Query, (void *)lpAuthUser_Out)) {
return true;
}
return false;
}
//Interface/////////////////////////////////////////////////////////////////////////////////////
//
// 요시랜드 인증
//
// Parameter :
//
// Do :
//
// Return :
//
///////////////////////////////////////////////////////////////////////////////////////////////
bool DBComponent::AuthDB::LoginAuthMyth(CDBComponent& DBComponent,
const char *Account_In, const char *Password_In,
const char *szAddress, AUTH* lpAuthUser_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.spLoginAuthMyth '%s', '%s', '%s'",
Account_In, Password_In, szAddress);
if (DBComponent.ExecuteQueryGetData(Query, (void *)lpAuthUser_Out)) {
return true;
}
return false;
}
bool DBComponent::AuthDB::GetPCCheckAgreement(CDBComponent& DBComponent, const char* szAccount_In, unsigned long* dwNumber_Out)
{
PCCheckAgreement pcCheckAgreement;
memset(&pcCheckAgreement, 0, sizeof(PCCheckAgreement));
strncpy(pcCheckAgreement.m_szAccount, szAccount_In, PCCheckAgreement::ID_LEN);
if(DBComponent.ExecuteQueryWithParams("{call PC_CHECK_AGREEMENT(?, ?)}", reinterpret_cast<char*>(&pcCheckAgreement), CAuthorizeParam::GetInstance().m_HanAuthCheckParam))
{
*dwNumber_Out = pcCheckAgreement.m_dwRet;
return true;
}
return false;
}
//Interface/////////////////////////////////////////////////////////////////////////////////////
//
// 한게임 인증
//
// Parameter :
//
// Do :
//
// Return :
//
///////////////////////////////////////////////////////////////////////////////////////////////
bool DBComponent::AuthDB::LoginAuthHan(CDBComponent& DBComponent,
const char* szAccount, const char* szPassword, HAN_UID& hanUID)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
HanLoginData loginData;
memset(&loginData, 0, sizeof(HanLoginData));
strncpy(loginData.m_szAccount, szAccount, HanLoginData::ID_LEN);
strncpy(loginData.m_szPassword, szPassword, HanLoginData::PASS_LEN);
if( DBComponent.ExecuteQueryWithParams("{call pc_ryl_login(?, ?, ?)}",
reinterpret_cast<char*>(&loginData), CAuthorizeParam::GetInstance().m_HanAuthParam))
{
hanUID = loginData.m_nUID;
return true;
}
return false;
}
//Interface/////////////////////////////////////////////////////////////////////////////////////
//
// 릴 게임 등록
//
// Parameter :
//
// Do :
//
// Return :
//
///////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _REG_HAN
{
char Name[16];
char Reg[3];
}REG_HAN, *LPREG_HAN;
bool DBComponent::AuthDB::RegRylGameHan(CDBComponent& DBComponent, char *Account_In, char *Mail_In)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
char Query[CDBComponent::QUERY_BUFFER_LEN];
REG_HAN Reg = {0,};
strcpy(Reg.Name, Account_In);
strcpy(Reg.Reg, Mail_In);
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "{call pc_ryl_login2(?, ?)}");
if( DBComponent.ExecuteQueryWithParams(Query, (char *)&Reg, CAuthorizeParam::GetInstance().m_HanRegParam))
{
return true;
}
return false;
}
bool DBComponent::AuthDB::GetAccountByUID(CDBComponent& DBComponent, unsigned long UID_In, char *Account_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
sprintf(Query, "select FC_GETMEMBERID_BYUID(%d) from dual", UID_In);
if(DBComponent.ExecuteQueryGetData(Query, Account_Out))
return true;
return false;
}
bool DBComponent::AuthDB::GetUIDByAccount(CDBComponent& DBComponent, char *Account_In, char *UID_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
sprintf(Query, "select FC_GETUID_BYMEMBERID('%s') from dual", Account_In);
if(DBComponent.ExecuteQueryGetData(Query, UID_Out))
return true;
return false;
}
bool DBComponent::AuthDB::GetMythAccountByUID(CDBComponent& DBComponent, unsigned long UID_In, char *Account_Out)
{
char szQuery[CDBComponent::QUERY_BUFFER_LEN];
char szResults[CDBComponent::QUERY_BUFFER_LEN];
memset(szResults, 0, sizeof(szResults));
if (0 < _snprintf(szQuery, CDBComponent::QUERY_BUFFER_LEN - 1,
"dbo.sp_SearchUserAccount %d, NULL", UID_In) &&
DBComponent.ExecuteQueryGetData(szQuery, szResults))
{
memcpy(Account_Out, szResults + sizeof(unsigned long),
sizeof(char) * HanLoginData::ID_LEN);
return true;
}
return false;
}
bool DBComponent::AuthDB::GetMythUIDByAccount(CDBComponent& DBComponent, const char *Account_In, unsigned long *UID_Out)
{
char szQuery[CDBComponent::QUERY_BUFFER_LEN];
char szResults[CDBComponent::QUERY_BUFFER_LEN];
memset(szResults, 0, sizeof(szResults));
if (0 < _snprintf(szQuery, CDBComponent::QUERY_BUFFER_LEN - 1,
"dbo.sp_SearchUserAccount NULL, '%s'", Account_In) &&
DBComponent.ExecuteQueryGetData(szQuery, szResults))
{
memcpy(UID_Out, szResults, sizeof(unsigned long));
return true;
}
return false;
}
//Interface/////////////////////////////////////////////////////////////////////////////////////
//
// 블럭된 계정인지 확인
//
// Parameter :
//
// Do :
//
// Return :
//
///////////////////////////////////////////////////////////////////////////////////////////////
bool DBComponent::AuthDB::CheckBlockedUser(CDBComponent& DBComponent, unsigned long UID_In,
unsigned char cServerID, LPRE_CMS_CheckUserBlock lpData_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
if(0 < _snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckRestraintChar '%d', '%d'", cServerID, UID_In))
{
if(DBComponent.ExecuteQueryGetData(Query, lpData_Out))
{
return true;
}
}
return false;
}
bool DBComponent::AuthDB::LoginBattleAuthHan(CDBComponent& DBComponent,
const char* szAccount, const char* szPassword, HAN_UID& hanUID)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
HanLoginData loginData;
memset(&loginData, 0, sizeof(HanLoginData));
strncpy(loginData.m_szAccount, szAccount, HanLoginData::ID_LEN);
strncpy(loginData.m_szPassword, szPassword, HanLoginData::PASS_LEN);
if (DBComponent.ExecuteQueryWithParams("{call pc_rylbl_login(?, ?, ?)}",
reinterpret_cast<char*>(&loginData), CAuthorizeParam::GetInstance().m_HanAuthParam))
{
hanUID = loginData.m_nUID;
return true;
}
return false;
}
bool DBComponent::AuthDB::RegBattleRylGameHan(CDBComponent& DBComponent, char* szAccount_In, char* szMail_In)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
REG_HAN Reg = {0,};
strncpy(Reg.Name, szAccount_In, 16);
strncpy(Reg.Reg, szMail_In, 3);
return DBComponent.ExecuteQueryWithParams("{call pc_rylbl_login2(?, ?)}", (char *)&Reg,
CAuthorizeParam::GetInstance().m_HanRegParam);
}
bool DBComponent::AuthDB::GetBattleAccountByUID(CDBComponent& DBComponent, unsigned long UID_In, char *Account_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
sprintf(Query, "select FC_RYLBL_GETMEMBERID_BYUID(%d) from dual", UID_In);
return DBComponent.ExecuteQueryGetData(Query, Account_Out);
}
bool DBComponent::AuthDB::GetBattleUIDByAccount(CDBComponent& DBComponent, char *Account_In, char *UID_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
sprintf(Query, "select FC_RYLBL_GETUID_BYMEMBERID('%s') from dual", Account_In);
return DBComponent.ExecuteQueryGetData(Query, UID_Out);
}
bool DBComponent::AuthDB::GetUIDFromBattleUID(CDBComponent& DBComponent, unsigned long dwBattleUID, unsigned long* lpUID)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
sprintf(Query, "USPGetUID %d", dwBattleUID);
return DBComponent.ExecuteQueryGetData(Query, lpUID);
}
bool DBComponent::AuthDB::GetBattleUIDFromUID(CDBComponent& DBComponent, unsigned long dwUID, unsigned long* lpBattleUID)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
sprintf(Query, "USPGetUIDBattle %d", dwUID);
return DBComponent.ExecuteQueryGetData(Query, lpBattleUID);
}
// 가마 독자 서비스 관련 인증
bool DBComponent::AuthDB::LoginAuthGama(CDBComponent& DBComponent,
const char* szAccount, const char* szPassword, unsigned long& dwUID)
{
GamaLoginData gamaLoginData;
memset(&gamaLoginData, 0, sizeof(gamaLoginData));
strncpy(gamaLoginData.m_szAccount, szAccount, GamaLoginData::ID_LEN);
strncpy(gamaLoginData.m_szPassword, szPassword, GamaLoginData::PASS_LEN);
if (DBComponent.ExecuteQueryWithParams("Client_RYL_Login ?, ?, ? OUTPUT",
reinterpret_cast<char*>(&gamaLoginData), CAuthorizeParam::GetInstance().m_GamaAuthParam))
{
dwUID = gamaLoginData.m_dwUID;
return true;
}
ERRLOG1(g_Log, "DB에러 : 로그인 프로시저 호출 실패. %s", DBComponent.GetErrorString());
return false;
}
bool DBComponent::AuthDB::GetGamaAccountByUID(CDBComponent& DBComponent,
unsigned long dwUID, char* szAccount_Out, int nAccountBufferLen)
{
GamaGetAccountByUID gamaGetAccountByUID;
memset(&gamaGetAccountByUID, 0, sizeof(gamaGetAccountByUID));
gamaGetAccountByUID.m_dwUID = dwUID;
if (DBComponent.ExecuteQueryWithParams("Client_RYL_GETMIDBYUID ?, ? OUTPUT",
reinterpret_cast<char*>(&gamaGetAccountByUID), CAuthorizeParam::GetInstance().m_GamaGetAccountByUID))
{
_snprintf(szAccount_Out, nAccountBufferLen, gamaGetAccountByUID.m_szAccount);
szAccount_Out[nAccountBufferLen - 1] = 0;
return true;
}
ERRLOG1(g_Log, "DB에러 : UID로 계정명 얻어오는 프로시저 호출 실패. %s", DBComponent.GetErrorString());
return false;
}
bool DBComponent::AuthDB::GetGamaUIDByAccount(CDBComponent& DBComponent,
const char* szAccount, unsigned long& dwUID)
{
GamaGetUIDByAccount gamaGetUIDByAccount;
memset(&gamaGetUIDByAccount, 0, sizeof(gamaGetUIDByAccount));
strncpy(gamaGetUIDByAccount.m_szAccount, szAccount, GamaGetUIDByAccount::ID_LEN);
if (DBComponent.ExecuteQueryWithParams("Client_RYL_GETUIDBYMID ?, ? OUTPUT",
reinterpret_cast<char*>(&gamaGetUIDByAccount), CAuthorizeParam::GetInstance().m_GamaGetUIDByAccount))
{
dwUID = gamaGetUIDByAccount.m_dwUID;
return true;
}
ERRLOG1(g_Log, "DB에러 : 계정명으로 UID 얻어오는 프로시저 호출 실패. %s", DBComponent.GetErrorString());
return false;
}

View File

@@ -0,0 +1,57 @@
#ifndef _RYL_AUTH_DB_COMPONENT_H_
#define _RYL_AUTH_DB_COMPONENT_H_
// forward decl.
class CDBComponent;
namespace DBComponent
{
namespace AuthDB
{
// ---------------------------------------------------------------------------------
// 인증 관련
/*
unsigned long GetID(HAN_UID Auth_In);
*/
bool LoginAuthMyth(CDBComponent& DBComponent, const char *Account_In,
const char *Password_In, const char *szAddress, AUTH* lpAuthUser_Out);
// 일본 인증
bool LoginAuthJapan(CDBComponent& DBComponent, const char *Account_In,
const char *Password_In, const char *szAddress, AUTH* lpAuthUser_Out);
bool LoginAuthHan(CDBComponent& DBComponent, const char* szAccount, const char* szPassword, HAN_UID& hanUID);
bool RegRylGameHan(CDBComponent& DBComponent, char *Account_In, char *Mail_In);
bool GetAccountByUID(CDBComponent& DBComponent, unsigned long UID_In, char *Account_Out);
bool GetUIDByAccount(CDBComponent& DBComponent, char *Account_In, char *UID_Out);
bool GetMythAccountByUID(CDBComponent& DBComponent, unsigned long UID_In, char *Account_Out);
bool GetMythUIDByAccount(CDBComponent& DBComponent, const char *Account_In, unsigned long *UID_Out);
bool CheckBlockedUser(CDBComponent& DBComponent, unsigned long UID_In, unsigned char cServerID, LPRE_CMS_CheckUserBlock lpData_Out);
// 배틀로한 인증 관련
bool LoginBattleAuthHan(CDBComponent& DBComponent, const char* szAccount, const char* szPassword, HAN_UID& hanUID);
bool RegBattleRylGameHan(CDBComponent& DBComponent, char* szAccount_In, char* szMail_In);
bool GetBattleAccountByUID(CDBComponent& DBComponent, unsigned long UID_In, char *Account_Out);
bool GetBattleUIDByAccount(CDBComponent& DBComponent, char *Account_In, char *UID_Out);
// 배틀로한은 기존 게임과 UID가 다르다. 그래서 기존 게임 UID로 배틀로한 UID를 얻어내거나
// 배틀로한 UID로 기존 게임 UID를 얻어낼 필요가 있다.
bool GetUIDFromBattleUID(CDBComponent& DBComponent, unsigned long dwBattleUID, unsigned long* lpUID);
bool GetBattleUIDFromUID(CDBComponent& DBComponent, unsigned long dwUID, unsigned long* lpBattleUID);
// 이관 신청 여부 확인.
bool GetPCCheckAgreement(CDBComponent& DBComponent, const char* szAccount_In, unsigned long* dwNumber_Out);
// 가마 독자 서비스 관련 인증
bool LoginAuthGama(CDBComponent& DBComponent, const char* szAccount, const char* szPassword, unsigned long& dwUID);
bool GetGamaAccountByUID(CDBComponent& DBComponent, unsigned long dwUID, char* szAccount_Out, int nAccountBufferLen);
bool GetGamaUIDByAccount(CDBComponent& DBComponent, const char* szAccount, unsigned long& dwUID);
};
};
#endif

View File

@@ -0,0 +1,304 @@
#include "stdafx.h"
#include "DBComponent.h"
#include "BillingDBComponent.h"
#include <Utility/Math/Math.h>
#include <Utility/Debug/PerformanceCheck.h>
#include <Log/ServerLog.h>
bool DBComponent::BillingDB::InitUserList(CDBComponent& DBComponent)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "DELETE FROM TblCurrentUser");
if (DBComponent.ExecuteQuery(Query)) {
return true;
}
return false;
}
// --------------------------------------------------------------------------------------------
// 빌링 관련 (ROW 빌링)
//
// USPCheckUser_Login [ public ]
// - 빌링 로그인
//
// Parameter :
//
// Return :
// 생성 성공 시 true, 실패시 false
//
///////////////////////////////////////////////////////////////////////////////////////////////
bool DBComponent::BillingDB::USPCheckUser_Login(CDBComponent& DBComponent, char *Account, unsigned long UserID,
char Check, char *ClientIP, char Group,
RE_USPCheckBilling_Login* lpData_Out){
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckUser_Login '%s', %d, %d, '%s', %d",
Account, UserID, Check, ClientIP, Group);
if (DBComponent.ExecuteQueryGetData(Query, (void *)lpData_Out)) {
return true;
}
return false;
}
bool DBComponent::BillingDB::USPCheckUser_CharIDLogin(CDBComponent& DBComponent, char *Account,
unsigned long UserID,
char Check, char *ClientIP, char Group,
RE_USPCheckBilling_Login* lpData_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckUser_CharIDLogin '%s', %d, %d, '%s', %d",
Account, UserID, Check, ClientIP, Group);
if (DBComponent.ExecuteQueryGetData(Query, (void *)lpData_Out)) {
return true;
}
return false;
}
bool DBComponent::BillingDB::USPCheckUser_LogOut(CDBComponent& DBComponent,
char *Account, unsigned long* Return_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckUser_LogOut '%s'", Account);
if (DBComponent.ExecuteQueryGetData(Query, (void *)Return_Out)) {
return true;
}
return false;
}
// --------------------------------------------------------------------------------------------
// 빌링 관련 (기존 빌링)
//
// USPCheckBilling_Login [ public ]
// - 빌링 로그인
//
// Parameter :
//
// Return :
// 생성 성공 시 true, 실패시 false
//
///////////////////////////////////////////////////////////////////////////////////////////////
bool DBComponent::BillingDB::USPCheckBilling_Login(CDBComponent& DBComponent, char *Account, unsigned long UserID,
char Check, char *ClientIP, char Group,
RE_USPCheckBilling_Login* lpData_Out){
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckBilling_Login '%s', %d, %d, '%s', %d",
Account, UserID, Check, ClientIP, Group);
if (DBComponent.ExecuteQueryGetData(Query, (void *)lpData_Out)) {
return true;
}
return false;
}
bool DBComponent::BillingDB::USPCheckBilling_CharIDLogin(CDBComponent& DBComponent, char *Account,
unsigned long UserID,
char Check, char *ClientIP, char Group,
RE_USPCheckBilling_Login* lpData_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckBilling_CharIDLogin '%s', %d, %d, '%s', %d",
Account, UserID, Check, ClientIP, Group);
if (DBComponent.ExecuteQueryGetData(Query, (void *)lpData_Out)) {
return true;
}
return false;
}
bool DBComponent::BillingDB::USPCheckBilling_LogOut(CDBComponent& DBComponent,
char *Account, unsigned long* Return_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckBilling_LogOut '%s'", Account);
if (DBComponent.ExecuteQueryGetData(Query, (void *)Return_Out)) {
return true;
}
return false;
}
bool DBComponent::BillingDB::USPServer_Start(CDBComponent& DBComponent, char Group, unsigned long* Return_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPServer_Start %d", Group);
if (DBComponent.ExecuteQueryGetData(Query, (void *)Return_Out)) {
return true;
}
return false;
}
bool DBComponent::BillingDB::USPServer_End(CDBComponent& DBComponent, char Group, unsigned long* Return_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPServer_End %d", Group);
if (DBComponent.ExecuteQueryGetData(Query, (void *)Return_Out)) {
return true;
}
return false;
}
bool DBComponent::BillingDB::USPDisConnectLogOut(CDBComponent& DBComponent, char Group, unsigned long* Return_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPDisConnectLogOut %d", Group);
if (DBComponent.ExecuteQueryGetData(Query, (void *)Return_Out)) {
return true;
}
return false;
}
bool DBComponent::BillingDB::USPGRoomCurrent_DisConn(CDBComponent& DBComponent, char *Account)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPGRoomCurrent_DisConn '%s'", Account);
if (DBComponent.ExecuteQuery(Query)) {
return true;
}
return false;
}
// --------------------------------------------------------------------------------------------
// 빌링 관련 (통합 빌링)
bool DBComponent::BillingDB::USPCheckBilling_Login_Post(CDBComponent& DBComponent, char *Account,
unsigned long UserID, char Check,
char *ClientIP, char Group, RE_USPCheckBilling_Login* lpData_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckBilling_Login_Post '%s', %d, %d, '%s', %d",
Account, UserID, Check, ClientIP, Group);
if (DBComponent.ExecuteQueryGetData(Query, (void *)lpData_Out)) {
return true;
}
return false;
}
bool DBComponent::BillingDB::USPCheckBilling_CharIDLogin_Post(CDBComponent& DBComponent, char *Account,
unsigned long UserID, char Check,
char *ClientIP, char Group, RE_USPCheckBilling_Login* lpData_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckBilling_CharIDLogin_Post '%s', %d, %d, '%s', %d",
Account, UserID, Check, ClientIP, Group);
return DBComponent.ExecuteQueryGetData(Query, (void *)lpData_Out);
}
bool DBComponent::BillingDB::USPCheckBilling_LogOut_Post(CDBComponent& DBComponent, char *Account, unsigned long* Return_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPCheckBilling_LogOut_Post '%s'", Account);
return DBComponent.ExecuteQueryGetData(Query, (void *)Return_Out);
}
bool DBComponent::BillingDB::USPDisConnectLogOut_Post(CDBComponent& DBComponent, char Group)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPDisConnectLogOut %d", Group);
return DBComponent.ExecuteQuery(Query);
}
bool DBComponent::BillingDB::USPCheckTimeoutUser(CDBComponent& DBComponent)
{
return DBComponent.ExecuteQuery("dbo.USPCheckTimeOutUser");
}
bool DBComponent::BillingDB::USPCheckBilling_InsertCurrentUser_Post(CDBComponent& DBComponent, int nTableType,
char* Account, unsigned long UserID,
char *ClientIP, char Group, char cBillingType,
char cCheck, unsigned long* Return_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN,
"dbo.USPCheckBilling_InsertCurrentUser_Post %d, '%s', %u, '%s', %d, '%c', %d",
nTableType, Account, UserID, ClientIP, Group, cBillingType, cCheck);
return DBComponent.ExecuteQueryGetData(Query, Return_Out);
}
//Interface/////////////////////////////////////////////////////////////////////////////////////
//
// 요시랜드 인증 ( 포인트 처리 )
//
// Parameter :
//
// Do :
//
// Return :
//
///////////////////////////////////////////////////////////////////////////////////////////////
bool DBComponent::BillingDB::PayAuthMyth(CDBComponent& DBComponent,
const char *Account_In, const char* szAddress, PAY_AUTH* lpPayAuth_Out)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.spPayAuthMyth '%s', '%s'",
Account_In, szAddress);
if (DBComponent.ExecuteQueryGetData(Query, (void *)lpPayAuth_Out)) {
return true;
}
return false;
}
// 일본 인증 (오픈베타용)
bool DBComponent::BillingDB::USPJapanUserLoginToZone(CDBComponent& DBComponent, char *Account,
unsigned long UserID,char Check, char *ClientIP,
char Group, unsigned long* dwReturnedFlag)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPJapanUserLoginToZone '%s', %d, %d, '%s', %d",
Account, UserID, Check, ClientIP, Group);
return DBComponent.ExecuteQueryGetData(Query, (void*)dwReturnedFlag);
}
bool DBComponent::BillingDB::USPJapanUserLoginToAuth(CDBComponent& DBComponent, char *Account,
unsigned long UserID, char Check, char *ClientIP,
char Group, unsigned long* dwReturnedFlag)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPJapanUserLoginToAuth '%s', %d, %d, '%s', %d",
Account, UserID, Check, ClientIP, Group);
return DBComponent.ExecuteQueryGetData(Query, (void*)dwReturnedFlag);
}
bool DBComponent::BillingDB::USPJapanUserLogOut(CDBComponent& DBComponent, char *Account,
unsigned long* dwReturnedFlag)
{
char Query[CDBComponent::QUERY_BUFFER_LEN];
_snprintf(Query, CDBComponent::QUERY_BUFFER_LEN, "dbo.USPJapanUserLogOut '%s'", Account);
return DBComponent.ExecuteQueryGetData(Query, (void*)dwReturnedFlag);
}

View File

@@ -0,0 +1,76 @@
#ifndef _RYL_BILLING_DB_COMPONENTS_H_
#define _RYL_BILLING_DB_COMPONENTS_H_
#include <DB/DBDefine.h>
// forward decl;
class CDBComponent;
namespace DBComponent
{
namespace BillingDB
{
bool InitUserList(CDBComponent& DBComponent);
// ---------------------------------------------------------------------------------
// 기존 빌링
bool USPCheckUser_Login(CDBComponent& DBComponent, char *Account, unsigned long UserID,
char Check, char *ClientIP, char Group, RE_USPCheckBilling_Login* lpData_Out);
bool USPCheckUser_CharIDLogin(CDBComponent& DBComponent, char *Account, unsigned long UserID,
char Check, char *ClientIP, char Group, RE_USPCheckBilling_Login* lpData_Out);
bool USPCheckUser_LogOut(CDBComponent& DBComponent, char *Account, unsigned long* Return_Out);
// ---------------------------------------------------------------------------------
// 기존 빌링
bool USPCheckBilling_Login(CDBComponent& DBComponent, char *Account, unsigned long UserID,
char Check, char *ClientIP, char Group, RE_USPCheckBilling_Login* lpData_Out);
bool USPCheckBilling_CharIDLogin(CDBComponent& DBComponent, char *Account, unsigned long UserID,
char Check, char *ClientIP, char Group, RE_USPCheckBilling_Login* lpData_Out);
bool USPCheckBilling_LogOut(CDBComponent& DBComponent, char *Account, unsigned long* Return_Out);
bool USPServer_Start(CDBComponent& DBComponent, char Group, unsigned long* Return_Out);
bool USPServer_End(CDBComponent& DBComponent, char Group, unsigned long* Return_Out);
bool USPDisConnectLogOut(CDBComponent& DBComponent, char Group, unsigned long* Return_Out);
bool USPGRoomCurrent_DisConn(CDBComponent& DBComponent, char *Account);
// ---------------------------------------------------------------------------------
// 통합빌링
bool USPCheckBilling_Login_Post(CDBComponent& DBComponent, char *Account, unsigned long UserID,
char Check, char *ClientIP, char Group, RE_USPCheckBilling_Login* lpData_Out);
bool USPCheckBilling_CharIDLogin_Post(CDBComponent& DBComponent, char *Account, unsigned long UserID, char Check,
char *ClientIP, char Group, RE_USPCheckBilling_Login* lpData_Out);
bool USPCheckBilling_LogOut_Post(CDBComponent& DBComponent, char *Account, unsigned long* Return_Out);
bool USPCheckBilling_InsertCurrentUser_Post(CDBComponent& DBComponent, int nTableType, char* Account, unsigned long UserID,
char *ClientIP, char Group, char cBillingType, char cCheck, unsigned long* Return_Out);
// 다음 두 쿼리는, 실행한 후 데이터를 얻어와서 처리할 필요가 있음.
bool USPDisConnectLogOut_Post(CDBComponent& DBComponent, char Group);
bool USPCheckTimeoutUser(CDBComponent& DBComponent);
// ---------------------------------------------------------------------------------
// 대만빌링
bool PayAuthMyth(CDBComponent& DBComponent,
const char *Account_In, const char* szAddress, PAY_AUTH* lpPayAuth_Out);
// ---------------------------------------------------------------------------------
// 일본 오픈베타
bool USPJapanUserLoginToZone(CDBComponent& DBComponent, char *Account, unsigned long UserID,
char Check, char *ClientIP, char Group, unsigned long* dwReturnedFlag);
bool USPJapanUserLoginToAuth(CDBComponent& DBComponent, char *Account, unsigned long UserID,
char Check, char *ClientIP, char Group, unsigned long* dwReturnedFlag);
bool USPJapanUserLogOut(CDBComponent& DBComponent, char *Account, unsigned long* dwReturnedFlag);
};
};
#endif

View File

@@ -0,0 +1,99 @@
///////////////////////////////////////////////////////////////////////////////////////////////
//
// CDBComponent
//
//////////////////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <Log/ServerLog.h>
#include <Utility/Setup/ServerSetup.h>
#include <Utility/Math/Math.h>
#include <Utility/Debug/PerformanceCheck.h>
#include "DBComponent.h"
CDBSingleObject& CDBSingleObject::GetInstance()
{
static CDBSingleObject dbSingleObject;
return dbSingleObject;
}
CDBComponent::CDBComponent(void)
{
}
CDBComponent::~CDBComponent()
{
}
bool CDBComponent::Connect(DBClass DBClass_In)
{
CServerSetup& serverSetup = CServerSetup::GetInstance();
CServerSetup::DBInfo* lpDBInfo = 0;
switch (DBClass_In)
{
case Class_AuthDB: lpDBInfo = &serverSetup.GetAuthDBInfo(); break;
case Class_GameDB: lpDBInfo = &serverSetup.GetGameDBInfo(); break;
case Class_KeeperDB: lpDBInfo = &serverSetup.GetKeeperDBInfo(); break;
case Class_AdminDB: lpDBInfo = &serverSetup.GetAdminToolDBInfo(); break;
}
if (0 == lpDBInfo)
{
ERRLOG0(g_Log, "DB Connect failed : Unknown dbType");
}
else if (!ConnectSQLServer(lpDBInfo->m_szDBAddr, lpDBInfo->m_szDBName,
lpDBInfo->m_szDBUser, lpDBInfo->m_szDBPass, lpDBInfo->m_ConnType))
{
ERRLOG1(g_Log, "DB Connect failed : %s", GetErrorString());
}
else
{
return true;
}
return false;
}
bool CDBComponent::Connect(const TCHAR* szDBServerName, const TCHAR* szDBName,
const TCHAR* szDBAccount, const TCHAR* szDBPass,
OleDB::ConnType connType)
{
// DETLOG1(g_Log, "DB에 로그인합니다 : DB : %s", szDBName);
// DETLOG4(g_Log, "DB에 로그인합니다 : %s, DB : %s, Account : %s, Password : %s",
// szDBServerName, szDBName, szDBAccount, szDBPass);
if (!ConnectSQLServer(szDBServerName, szDBName, szDBAccount, szDBPass, connType))
{
ERRLOG1(g_Log, "DB Connect failed : %s", GetErrorString());
return false;
}
return true;
}
bool CDBComponent::Select(const TCHAR *Query_In, void** lpLoginTable_Out,
int Size_In, int StartNum_In, int RowNum_In, int *GetRowNum_Out)
{
if (StartNum_In == 0 && !ExecuteQuery(Query_In))
{
ERRLOG1(g_Log, "Execute DB Query failed : %s", GetErrorString());
}
else if (!GetData((void **)lpLoginTable_Out, Size_In, RowNum_In, GetRowNum_Out))
{
ERRLOG1(g_Log, "Get DBdata failed : %s", GetErrorString());
}
else
{
return true;
}
return false;
}

View File

@@ -0,0 +1,79 @@
///////////////////////////////////////////////////////////////////////////////////////////////
//
// CDB Component
//
//////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _CDBComponent
#define _CDBComponent
#include <DB/OLEDB.h>
#include "DBDefine.h"
//#define _CHECK_DBOBJECT_PERFORMANCE
#ifdef _CHECK_DBOBJECT_PERFORMANCE
#define DBOBJECT_PERFORMANCE_CHECK(x) x
#else
#define DBOBJECT_PERFORMANCE_CHECK(x) (void*)0
#endif
//////////////////////////////////////////////////////////////////////////////////////////////
//
// DB Componet
//
///////////////////////////////////////////////////////////////////////////////////////////////
class CDBComponent : public OleDB
{
public:
enum DBClass
{
Class_AuthDB = 1,
Class_GameDB = 2,
Class_KeeperDB = 3,
Class_AdminDB = 4
};
enum
{
MAX_QUERY_LENGTH = 32768,
QUERY_BUFFER_LEN = 1024
};
CDBComponent();
virtual ~CDBComponent();
bool Connect(DBClass DBClass_In);
bool Connect(const TCHAR* szDBServerName, const TCHAR* szDBName,
const TCHAR* szDBAccount, const TCHAR* szDBPass,
OleDB::ConnType connType = OleDB::ConnType_MSSQL);
// Åø °ü·Ã
bool Select(const TCHAR *Query_In, void** lpLoginTable_Out, int Size_In,
int StartNum_In, int RowNum_In, int *GetRowNum_Out);
TCHAR* GetQueryBuffer() { return m_Query; }
const int GetQueryBufferLen() { return MAX_QUERY_LENGTH; }
private:
TCHAR m_Query[MAX_QUERY_LENGTH];
};
//////////////////////////////////////////////////////////////////////////////////////////////
//
// DB Object Singleon
//
///////////////////////////////////////////////////////////////////////////////////////////////
class CDBSingleObject : public CDBComponent
{
public:
CDBSingleObject(void) { }
virtual ~CDBSingleObject(void) { }
static CDBSingleObject& GetInstance();
};
#endif

View File

@@ -0,0 +1,884 @@
///////////////////////////////////////////////////////////////////////////////////////////////
//
// DB Struct Define
//
//////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _DBDefine
#define _DBDefine
#include <algorithm>
#pragma pack(1) // 1byte order로 패킹
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 캐릭터 정보 DB Table
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct CHAR_INFOST
{
enum
{
// edith 2008.03.17 ID,PASS 길이조정
MAX_ACCOUNT_LEN = 24,
MAX_NAME_LEN = 16
};
unsigned long CID;
char Name[MAX_NAME_LEN]; // 캐릭터 이름
char Sex; // 캐릭터 성
char Hair; // 캐릭터 머리 모양
char Face; // 캐릭터 얼굴 모양
char Race; // 캐릭터 종족
unsigned short Class; // 캐릭터 클래스
unsigned long Fame; // 명성
unsigned long Mileage; // 마일리지
unsigned long GID; // 캐릭터 길드
unsigned long PID; // 캐릭터 파티
char Level; // 캐릭터 레벨
unsigned long Gold; // 돈
unsigned short IP; // 증가 포인트
unsigned short STR; // 캐릭터 STR
unsigned short DEX; // 캐릭터 DEX
unsigned short CON; // 캐릭터 CON
unsigned short INT; // 캐릭터 INT
unsigned short WIS; // 캐릭터 WIS
short HP; // 캐릭터 HP
short MP; // 캐릭터 MP
__int64 Exp; // 캐릭터 경험점
char Chance; // 캐릭터 찬스
};
typedef CHAR_INFOST* LPCHAR_INFOST;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 시간
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct TIME
{
unsigned short Year; // 연도
unsigned short Month; // 달
unsigned short Day; // 날짜
unsigned short Hour; // 시간
unsigned short Minute; // 분
unsigned short Second; // 초
unsigned long MSecond; // 밀리초
};
typedef TIME* LPTIME;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 요시랜드 인증
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct AUTH
{
unsigned long Errcode; // 에러 코드
unsigned long UID; // 유저 아이디
union COMMENT
{
unsigned long Point; // 포인트 양
TIME Time; // 시간
} Comment;
unsigned long Dumy[4]; // 규격에 맞지 않은 사이즈의 데이터 대비
};
struct PAY_AUTH
{
// edith 2008.05.29 어카운트 길이가 20->40으로 바꼈다.
enum { AccountLen = 40 };
unsigned long Errcode; // 에러 코드
char Account[AccountLen]; // 계정 이름
unsigned long UID; // 유저 아이디
unsigned long Time; // 시간 (분)
int WarningCode; // 0 : 대만 경고보냄 / 1 : 중국 경고없음 / 2 : 중국 경고보냄
};
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 한게임 인증
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _HAN_UID
{
unsigned long hUID; // 유저 아이디
unsigned long lUID; // 유저 아이디
}HAN_UID, *LPHAN_UID;
typedef struct _HAN_AUTH
{
unsigned char Num; // 자리수
unsigned short Extra; // 뭐하는 건지 모름
unsigned long UID; // 유저 아이디
unsigned char Dump; // 빈공간
}HAN_AUTH, *LPHAN_AUTH;
typedef union _HAN_CONVERT
{
unsigned _int64 iValue; // 64 Bit 값
HAN_AUTH sValue; // 구조체
}HAN_CONVERT, *LPHAN_CONVERT;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 위치
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct POS
{
float fPointX; // Point X 좌표
float fPointY; // Point Y 좌표
float fPointZ; // Point Z 좌표
};
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 스킬 슬롯 // modified 2002/10/3 11:20 by sparrowhawk
//
//////////////////////////////////////////////////////////////////////////////////////////////
union SKILLSLOT
{
struct
{
unsigned short wSkill; // 스킬 아이디
char cLockCount; // 스킬 락 카운트 ( 0~4 )
char cSkillLevel; // 스킬 레벨 ( -127 ~ 128 )
}SKILLINFO;
unsigned long dwSkillSlot;
SKILLSLOT() : dwSkillSlot(0) { }
SKILLSLOT(unsigned short skill, char lockcount, char skillLevel)
{ SKILLINFO.wSkill = skill; SKILLINFO.cLockCount = lockcount; SKILLINFO.cSkillLevel = skillLevel; }
};
typedef SKILLSLOT* LPSKILLSLOT;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 스킬
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct SKILL
{
enum Const
{
MAX_SKILL_LEVEL = 6,
MAX_SLOT_NUM = 40
};
unsigned short wSkillNum; // 스킬 수 (TODO : 사용하지 않습니다.)
unsigned short wSlotNum; // 슬롯 수
SKILLSLOT SSlot[MAX_SLOT_NUM]; // 스킬
SKILL() : wSkillNum(0), wSlotNum(0)
{
std::fill_n(&SSlot[0], int(MAX_SLOT_NUM), SKILLSLOT());
}
SKILL(unsigned short usSkillNum, unsigned short usSlotNum)
: wSkillNum(usSkillNum), wSlotNum(usSlotNum)
{
std::fill_n(&SSlot[0], int(MAX_SLOT_NUM), SKILLSLOT());
}
unsigned short GetSkillNum(void)
{
unsigned short wCount = 0;
for (int Index = 0; Index < wSlotNum; ++Index)
{
// 스킬아이디가 0x8000 보다 작으면 소설모션, 어빌리티 이다.
if(SSlot[Index].SKILLINFO.wSkill < 0x8000)
continue;
wCount += (SSlot[Index].SKILLINFO.cLockCount * MAX_SKILL_LEVEL +
SSlot[Index].SKILLINFO.cSkillLevel);
}
return wCount;
}
unsigned short GetAbilityNum(void)
{
unsigned short wCount = 0;
for (int Index = 0; Index < wSlotNum; ++Index)
{
if(SSlot[Index].SKILLINFO.wSkill >= 0x2000)
continue;
wCount += SSlot[Index].SKILLINFO.cLockCount;
}
return wCount;
}
};
typedef SKILL* LPSKILL;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 타이틀
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _TITLE
{
__int64 dlTitle; // 타이틀 아이디
unsigned short wScore; // 타이틀 점수
}TITLE, *LPTITLE;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 장비
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _EQUIP
{
enum { MAX_EQUIP_SIZE = 1436 }; // + 4 = 1440
unsigned long dwSize;
char Data[MAX_EQUIP_SIZE];
} EQUIP, *LPEQUIP;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 인벤
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _INVEN
{
enum { MAX_INVEN_SIZE = 5116 }; // + 4 = 5120
unsigned long dwSize;
char Data[MAX_INVEN_SIZE];
} INVEN, *LPINVEN;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Extra
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _EXTRA
{
enum { MAX_EXTRA_SIZE = 508 }; // + 4 = 512
unsigned long dwSize;
char Data[MAX_EXTRA_SIZE];
} EXTRA, *LPEXTRA;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Exchange
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _EXCHANGE
{
enum { MAX_EXCHANGE_SIZE = 1280 }; // + 4 = 1284
unsigned long dwSize;
char Data[MAX_EXCHANGE_SIZE];
} EXCHANGE, *LPEXCHANGE;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 임시 인벤토리
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct TEMPINVEN
{
enum { MAX_TEMPINVEN_SIZE = 1436 }; // + 4 = 1440
unsigned long dwSize;
char Data[MAX_TEMPINVEN_SIZE];
};
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 창고
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _STORE
{
enum { MAX_STORE_SIZE = 7296 }; // + 4 = 7300
unsigned long dwSize;
char Data[MAX_STORE_SIZE];
} STORE, *LPSTORE;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 퀵 슬롯
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct QUICKSLOT {
enum Type { NONE = 0, SKILL = 1, ITEM = 2 };
char nType;
char nSkillLockCount;
char nSkillLevel;
unsigned short wID; // Skill_ID 또는 아이템 ProtoType ID
QUICKSLOT() : nType(NONE), nSkillLockCount(0), nSkillLevel(0), wID(0) { }
QUICKSLOT(char type, char lockCount, char skillLevel, unsigned short wid)
: nType(type), nSkillLockCount(lockCount), nSkillLevel(skillLevel), wID(wid) { }
};
typedef QUICKSLOT* LPQUICKSLOT;
struct QUICK
{
enum { MAX_QUICK_NUM = 20 };
QUICKSLOT Slots[MAX_QUICK_NUM];
QUICK()
{
std::fill_n(&Slots[0], int(MAX_QUICK_NUM), QUICKSLOT());
}
};
typedef QUICK *LPQUICK;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 캐릭터 생성 구조체
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct CHAR_CREATE
{
enum RaceType
{
HUMAN = 0,
AKHAN = 1
};
char Name[CHAR_INFOST::MAX_NAME_LEN]; // 캐릭터 이름
char Sex; // 캐릭터 성
char Hair; // 캐릭터 머리 모양
char Face; // 캐릭터 얼굴 모양
char Race; // 캐릭터 종족
unsigned short Class; // 캐릭터 클래스
unsigned short Equip[15]; // 장비
unsigned short STR; // 캐릭터 STR
unsigned short DEX; // 캐릭터 DEX
unsigned short CON; // 캐릭터 CON
unsigned short INT; // 캐릭터 INT
unsigned short WIS; // 캐릭터 WIS
};
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 캐릭터 모양 구조체
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct CHAR_VIEW
{
enum RaceType
{
HUMAN = 0,
AKHAN = 1
};
unsigned long CID;
char Name[CHAR_INFOST::MAX_NAME_LEN]; // 캐릭터 이름
char Sex; // 캐릭터 성
char Hair; // 캐릭터 머리 모양
char Face; // 캐릭터 얼굴 모양
char Race; // 캐릭터 종족
unsigned short Class; // 캐릭터 클래스
unsigned long Fame; // 명성
unsigned long Mileage; // 마일리지
unsigned long GID; // 캐릭터 길드
unsigned long PID; // 캐릭터 파티
char Level; // 캐릭터 레벨
unsigned short Equip[15]; // 장비(겉보기)
};
// DB 에 저장하지는 않지만 CHAR_VIEW 에 관련된 추가 정보이다.
// 길드 및 국적 정보
struct sGuildData
{
unsigned char m_cNation;
char m_szName[CHAR_INFOST::MAX_NAME_LEN];
};
typedef struct _PREMIUMSERVICE
{
long lPremiumTime;
int iPremiumType;
} PREMIUMSERVICE, *LPPREMIUMSERVICE;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 캐릭터 정보 DB Table
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct USER_INFO
{
enum
{
MAX_CHAR_NUM = 5
};
unsigned long CharID[MAX_CHAR_NUM]; // 캐릭터
// WORK_LIST 2.1 계정 국적 추가
unsigned char Nation; // 계정 국적
// 서버통합 - by sphawk
unsigned char OldServerGroupID; // 통합전 서버그룹ID (0이면 현재 서버군의 정보임을 나타냄)
unsigned char FirstLogin;
bool HasCharacter(unsigned long dwCID) const
{
for(int nCount = 0; nCount < MAX_CHAR_NUM; ++nCount)
{
if(CharID[nCount] == dwCID) { return true; }
}
return false;
}
unsigned char GetCharacterNum() const
{
unsigned char cSelectedCharacter = 0;
for(int nCount = 0; nCount < MAX_CHAR_NUM; ++nCount)
{
if(0 != CharID[nCount]) { ++cSelectedCharacter; }
}
return cSelectedCharacter;
}
};
typedef USER_INFO *LPUSER_INFO;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 캐릭터 추가 정보
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _CHAR_INFOEX
{
unsigned long Total; // 총 이용 시간(분)
unsigned long ServerID; // 존
unsigned char cNameChangeCount; // 이름 바꿀 수 있는 횟수
unsigned char cAdminFlag; // Admin 모델 정보.
unsigned char GuildWarFlag; // 길드 전쟁 참여 플래그
unsigned char RealmWarFlag; // 국가 전쟁 참여 플래그
unsigned char RealmPoint; // 국가 전쟁 공헌훈장 포인트.
unsigned char RealmCheckPoint; // 국가 전쟁 중에 로그아웃해서 포인트를 얻었을 경우.
unsigned char RealmMinute; // 국가 전쟁 플레이 타임 기록.
TIME LoggoutTime; // 로그아웃된 시간.
} CHAR_INFOEX, *LPCHAR_INFOEX;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 캐릭터 위치 정보 DB Table
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _CHAR_POS
{
POS LastPoint; // 마지막 위치
POS SavePoint; // 세이브 위치
} CHAR_POS, *LPCHAR_POS;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 파티 정보 DB Table
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _PARTY_INFO
{
enum { MAX_MEM = 10 };
unsigned long MemberCID[MAX_MEM]; // 멤버 CID
char Name[MAX_MEM][CHAR_INFOST::MAX_NAME_LEN]; // 멤버 이름
} PARTY_INFO, *LPPARTY_INFO;
typedef struct _PARTY_USER_INFO
{
enum { MAX_MEM = 10 };
unsigned short m_wClass[MAX_MEM]; // 멤버 클래스
char m_cLevel[MAX_MEM]; // 멤버 레벨
unsigned long m_dwGID[MAX_MEM]; // 멥버 길드 아이드
} PARTY_USER_INFO, *LPPARTY_USER_INFO;
typedef struct _PARTY_DB_INFO // 디비에서 얻어올때 사용.
{
PARTY_INFO PartyInfo;
PARTY_USER_INFO PartyUserInfo;
} PARTY_DB_INFO, *LPPARTY_DB_INFO;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 파티
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct PARTY
{
enum { MAX_MEM = 10 };
unsigned long m_dwPartyID;
unsigned long m_dwLeaderID;
unsigned char m_cMemberNum;
char Name[MAX_MEM][CHAR_INFOST::MAX_NAME_LEN];
unsigned long MemberCID[MAX_MEM];
unsigned long ServerID[MAX_MEM];
unsigned short m_wClass[MAX_MEM]; // 멤버 클래스
char m_cLevel[MAX_MEM]; // 멤버 레벨
unsigned long m_dwGID[MAX_MEM]; // 멤버 길드 아이드
PARTY() : m_dwPartyID(0), m_dwLeaderID(0), m_cMemberNum(0)
{
std::fill_n(&MemberCID[0], int(MAX_MEM), 0);
std::fill_n(&ServerID[0], int(MAX_MEM), 0);
std::fill_n(&m_wClass[0], int(MAX_MEM), 0);
std::fill_n(&m_cLevel[0], int(MAX_MEM), 0);
std::fill_n(&m_dwGID[0], int(MAX_MEM), 0);
}
};
struct PARTY_USERINFO
{
unsigned long m_dwGID[PARTY::MAX_MEM];
};
// 파티 정보(길드정보 추가) //
struct PARTY_EX : public PARTY
{
bool m_bAutoRouting[PARTY::MAX_MEM];
POS m_Position[PARTY::MAX_MEM];
PARTY_EX()
{
InitMemberAutoRouting();
InitMemberPos();
}
PARTY_EX(const PARTY& party)
{
m_dwPartyID = party.m_dwPartyID;
m_dwLeaderID = party.m_dwLeaderID;
m_cMemberNum = party.m_cMemberNum;
for (int nIndex = 0; nIndex < PARTY::MAX_MEM; ++nIndex)
{
::memcpy(Name[nIndex], party.Name[nIndex], CHAR_INFOST::MAX_NAME_LEN);
MemberCID[nIndex] = party.MemberCID[nIndex];
ServerID[nIndex] = party.ServerID[nIndex];
m_wClass[nIndex] = party.m_wClass[nIndex];
m_cLevel[nIndex] = party.m_cLevel[nIndex];
m_dwGID[nIndex] = party.m_dwGID[nIndex];
}
InitMemberAutoRouting();
InitMemberPos();
}
inline void InitMemberAutoRouting()
{
std::fill_n(&m_bAutoRouting[0], int(PARTY::MAX_MEM), false);
}
inline void InitMemberPos()
{
for (int i = 0; i < PARTY::MAX_MEM; ++i)
{
m_Position[i].fPointX = 0.0f;
m_Position[i].fPointY = 0.0f;
m_Position[i].fPointZ = 0.0f;
}
}
};
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 창고
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _STORE_INFO
{
enum { MAX_PASS_LEN = 5 };
char Password[MAX_PASS_LEN]; // 패스워드
unsigned long Flag; // 플래그
unsigned long Gold; // 플래그
} STORE_INFO, *LPSTORE_INFO;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 운영자
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _ADMIN
{
enum { MAX_IP_LEN = 16 };
unsigned long UID;
unsigned short Level;
char IP_S[MAX_IP_LEN];
char IP_E[MAX_IP_LEN];
} ADMIN, *LPADMIN;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 프랜드
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _FRIEND
{
enum
{
MAX_FRIEND_SIZE = 2400, // + 4 = 2404
MAX_FRIENDINFO_SIZE = 700, // + 4 = 704 (캐릭터 정보 추가.)
};
unsigned long dwSize;
char Data[MAX_FRIEND_SIZE];
unsigned long dwInfoSize; //
char Info[MAX_FRIENDINFO_SIZE];
} FRIEND, *LPFRIEND;
typedef struct _BAN
{
enum
{
MAX_BAN_SIZE = 2000, // + 4 = 2004
MAX_BANINFO_SIZE = 700, // + 4 = 704 (캐릭터 정보 추가.)
};
unsigned long dwSize;
char Data[MAX_BAN_SIZE];
unsigned long dwInfoSize;
char Info[MAX_BANINFO_SIZE];
} BAN, *LPBAN;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 과금 관련
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _RE_USPCheckBilling_Login
{
unsigned long Flag; // Success(=0)
char strBillingType[2]; // D, T(N: 무료계정)
int PlayTime; // 현재 남은 시간 (일, 분)
unsigned long intCRMIndex1; // 피시방 고유아이디
} RE_USPCheckBilling_Login, *LPRE_USPCheckBilling_Login;
typedef struct _RE_USPGRoomCurrent_DisConn
{
enum { ClientIDLen = 20 };
unsigned char ClientID[ClientIDLen]; // 계정
unsigned long UID; // 유저 아이디
char ServerID; // 서버 아이디
}RE_USPGRoomCurrent_DisConn, *LPRE_USPGRoomCurrent_DisConn;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 계정 블록 관련
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _RE_CMS_CheckUserBlock
{
unsigned char m_cFlags; // 0 : 블럭 안함, 1 : 계정 블럭, 2 : 캐릭터 블럭
char m_szCharName[20][USER_INFO::MAX_CHAR_NUM]; // 블럭된 캐릭터 이름
} RE_CMS_CheckUserBlock, *LPRE_CMS_CheckUserBlock;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 퀘스트
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _QUEST
{
enum { MAX_QUEST_SIZE = 260 }; // + 4 = 264
unsigned long dwSize;
char Data[MAX_QUEST_SIZE];
} QUEST, *LPQUEST;
typedef struct _HISTORY
{
enum { MAX_HISTORY_SIZE = 400 }; // + 4 = 404
unsigned long dwSize;
char Data[MAX_HISTORY_SIZE];
} HISTORY, *LPHISTORY;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 설정
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _CONFIG
{
enum { MAX_CONFIG_SIZE = 46 }; // + 4 = 50
unsigned long dwSize;
char Data[MAX_CONFIG_SIZE];
} CONFIG, *LPCONFIG;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 특수 소설모션
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _SOCIALEX
{
enum { MAX_SOCIAL_SIZE = 20 }; // + 4 = 24
unsigned long dwSize;
char Data[MAX_SOCIAL_SIZE];
} SOCIALEX, *LPSOCIALEX;
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 이벤트 아이템
//
//////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _EVENTITEM
{
enum { MAX_ITEM_NAME = 32 };
unsigned long nItemIndex;
char strItemName[MAX_ITEM_NAME];
unsigned long nItemAmount;
TIME UpdateTime;
} EVENTITEM, *LPEVENTITEM;
// 서버통합 - 캐릭터 생성을 파라미터로 DB에 호출.
struct CHAR_CREATE_DB
{
unsigned long dwUID;
unsigned long dwSlotPos;
char szName[CHAR_INFOST::MAX_NAME_LEN];
unsigned char cSex;
unsigned char cHair;
unsigned char cFace;
unsigned char cRace;
short sClass;
unsigned long dwGold;
short sSTR;
short sDEX;
short sCON;
short sINT;
short sWIS;
float fPointX;
float fPointY;
float fPointZ;
unsigned short Equip[15];
SKILL skill;
unsigned char cServerGroupID;
int dwCID_Out;
};
// 서버통합 - 통합된 캐릭터 정보를 얻어온다.
struct UnifiedCharData
{
char szName[16];
char szBeforeCharName[20];
unsigned long dwNewCID;
unsigned long dwBeforeCID;
short sClass;
unsigned char cLevel;
unsigned char cOldServerGroupID;
};
struct UnifiedStoreInfo
{
unsigned char cOldServerGroupID; // 구 서버그룹
char Password[STORE_INFO::MAX_PASS_LEN]; // 패스워드
unsigned long Flag; // 플래그
unsigned long Gold; // 금액
};
struct KeyInfo
{
enum Const
{
MAX_KEY_INFO = 34
};
unsigned char m_cUsed;
unsigned long m_dwKeyInfo[MAX_KEY_INFO];
};
///////////////////////////////////////////////////////////////////////////////////////////////
//
// 스펠
//
//////////////////////////////////////////////////////////////////////////////////////////////
struct SPELLINSTANCE {
unsigned long dwDurationSec;
unsigned short wSpellID;
unsigned short wEnchantLevel;
unsigned char cSpellType;
SPELLINSTANCE() : dwDurationSec(0), wSpellID(0), wEnchantLevel(0), cSpellType(0) { }
SPELLINSTANCE(unsigned long dwDurationSec, unsigned short wSpellID, unsigned short wEnchantLevel, unsigned char cSpellType)
: dwDurationSec(dwDurationSec), wSpellID(wSpellID), wEnchantLevel(wEnchantLevel), cSpellType(cSpellType) { }
};
typedef SPELLINSTANCE* LPSPELLINSTANCE;
struct SPELL
{
enum { MAX_SPELL_NUM = 30 };
SPELLINSTANCE Spells[MAX_SPELL_NUM];
SPELL()
{
std::fill_n(&Spells[0], int(MAX_SPELL_NUM), SPELLINSTANCE());
}
};
typedef SPELL* LPSPELL;
#pragma pack()
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,172 @@
#ifndef _RYL_GAME_DB_COMPONENT_H_
#define _RYL_GAME_DB_COMPONENT_H_
// forward decl.
class CDBComponent;
namespace DBComponent
{
namespace GameDB
{
// 게임 관련
bool InsertAdmin(CDBComponent& DBComponent, unsigned long UserID_In);
bool DeleteAdmin(CDBComponent& DBComponent, unsigned long UserID_In);
bool IsAdmin(CDBComponent& DBComponent, unsigned long UserID_In);
bool InsertUser(CDBComponent& DBComponent, unsigned long UserID_In, unsigned char cOldServerGroupID, bool bSupressLog = false);
bool UpdateUser(CDBComponent& DBComponent, unsigned long dwUID, USER_INFO* lpUserInfo);
bool UpdateUserFirstLogin(CDBComponent& DBComponent, unsigned long dwUID, unsigned char cFirstLoginType);
bool UpdateCharZone(CDBComponent& DBComponent, unsigned long UserID_In, unsigned long Zone_In);
// WORK_LIST 2.1 계정 국적 추가
bool UpdateAccountNation(CDBComponent& DBComponent, unsigned long UserID_In,
unsigned char AccountNation_In, unsigned char cOldServerGroupID);
bool GetUserInfo(CDBComponent& DBComponent, unsigned long UserID_In, USER_INFO& UserInfo_Out, unsigned char cOldServerGroupID, bool bSupressLog = false);
bool GetCharView(CDBComponent& DBComponent, unsigned long CharID_In, CHAR_VIEW* lpCharLogin_Out);
bool GetCharInfoEx(CDBComponent& DBComponent, unsigned long CharID_In, CHAR_INFOEX* lpCharInfoEx_Out);
bool UpdateCharInfoEx(CDBComponent& DBComponent, unsigned long CharID_In, CHAR_INFOEX* lpCharInfoEx_In);
bool InsertItemUID(CDBComponent& DBComponent, unsigned long ServerID_In, DWORD64 dwItemUID);
bool GetItemUID(CDBComponent& DBComponent, unsigned long ServerID_In, DWORD64 *lpItemID_Out, bool bSupressLog = false);
bool SetItemUID(CDBComponent& DBComponent, unsigned long ServerID_In, DWORD64 ItemID_In);
bool InsertEventItem(CDBComponent& DBComponent, unsigned short wItemID, unsigned short wMaxNum, const tm& StartTime, const tm& EndTime);
bool UpdateEventItem(CDBComponent& DBComponent, unsigned short wItemID, unsigned short wMaxNum, const tm& StartTime, const tm& EndTime);
bool UpdateEventItem(CDBComponent& DBComponent, unsigned short wItemID, unsigned short wNowNum);
bool DeleteEventItem(CDBComponent& DBComponent, unsigned short wItemID);
// 창고관련
bool GetUnifiedItemStore1(CDBComponent& DBComponent, unsigned long UserID_In, unsigned char cOldServerGroupID, LPSTORE lpStore_Out);
bool GetUnifiedItemStore2(CDBComponent& DBComponent, unsigned long UserID_In, unsigned char cOldServerGroupID, LPSTORE lpStore_Out);
bool UpdateUnifiedItemStore1(CDBComponent& DBComponent, unsigned long UserID_In, unsigned char cOldServerGroupID, LPSTORE lpStore_In);
bool UpdateUnifiedItemStore2(CDBComponent& DBComponent, unsigned long UserID_In, unsigned char cOldServerGroupID, LPSTORE lpStore_In);
bool GetUnifiedItemStoreInfo(CDBComponent& DBComponent, unsigned long UserID_In, unsigned char cOldServerGroupID, STORE_INFO* lpStoreInfo, bool bSupressLog = false);
bool GetUnifiedItemStoreInfo(CDBComponent& DBComponent, unsigned long UserID_In, UnifiedStoreInfo* lpUnifiedStoreInfo_Out, int& nStoreNum_InOut);
bool SetUnifiedItemStoreInfo(CDBComponent& DBComponent, unsigned long UserID_In, unsigned char cOldServerGroupID, LPSTORE_INFO lpStoreInfo_In);
// cOldServerGroupID의 창고 데이터를 cChangedServerGroupID로 덮어 씌우고,
// cOldServerGroupID의 창고 데이터를 NULL로 만든다.
bool ChangeUnifiedItemStoreGroup(CDBComponent& DBComponent, unsigned long dwUID,
unsigned char cOldServerGroupID, unsigned char cChangedServerGroupID);
bool DeleteUnifiedStore(CDBComponent& DBComponent, unsigned long dwUID, unsigned char cOldStoreServerGroup);
// 통합서버관련
bool GetUnifiedCharList(CDBComponent& DBComponent, unsigned long dwUID, UnifiedCharData* lpUnifiedCharData, int& nUnifiedCharData_InOut);
bool UpdateUnifiedCharServerGroupID(CDBComponent& DBComponent, unsigned long dwUID, unsigned long dwCID, unsigned char cOldServerGroupID);
// 친구/거부 관련
bool GetFriend(CDBComponent& DBComponent, unsigned long CharID_In, FRIEND* lpFriend_Out);
bool GetBan(CDBComponent& DBComponent, unsigned long CharID_In, BAN* lpBan_Out);
bool UpdateFriend(CDBComponent& DBComponent, unsigned long CharID_In, FRIEND* lpFriend_In);
bool UpdateBan(CDBComponent& DBComponent, unsigned long CharID_In, BAN* lpBan_Out);
// 퀘스트 관련
bool GetQuest(CDBComponent& DBComponent, unsigned long CharID_In, LPQUEST lpQuest_Out);
bool GetHistory(CDBComponent& DBComponent, unsigned long CharID_In, LPHISTORY lpHistory_Out);
bool UpdateQuest(CDBComponent& DBComponent, unsigned long CharID_In, LPQUEST lpQuest_In);
bool UpdateHistory(CDBComponent& DBComponent, unsigned long CharID_In, LPHISTORY lpHistory_In);
// 캐릭터 생성
bool InsertChar(CDBComponent& DBComponent, unsigned long dwUID, unsigned long dwSlot,
CHAR_CREATE& char_In, unsigned long dwGold, POS& pos, SKILL& skill,
unsigned char cOldServerGroupID, unsigned long& dwCID_Out);
// 캐릭터 이름 변경
// dwResult : 0 - 캐릭터 이름 변경 성공
// dwResult : 1 - 캐릭터 이름 변경 실패 (겹치는 이름 있음)
bool ChangeCharName(CDBComponent& DBComponent, unsigned long dwCID,
const char* szCharName, unsigned long& dwResult);
// 캐릭터 삭제
bool DeleteChar(CDBComponent& DBComponent, unsigned long dwUID, unsigned long dwCID,
unsigned char cSlot, unsigned char cCurrentServerGroupID, unsigned char cOldServerGroupID);
bool DeleteCharBattleServer(CDBComponent& DBComponent, unsigned long dwUID, unsigned long dwCID,
unsigned char cSlot, unsigned char cCurrentServerGroupID, unsigned char cOldServerGroupID);
// 설정 관련
bool GetConfig(CDBComponent& DBComponent, unsigned long CharID_In, LPCONFIG lpConfig_Out);
bool UpdateConfig(CDBComponent& DBComponent, unsigned long CharID_In, LPCONFIG lpConfig_In);
// 게임타임 관련
bool GetPlayTime(CDBComponent& DBComponent, unsigned long UserID_In, unsigned int* PlayTime_Out);
bool UpdatePlayTime(CDBComponent& DBComponent, unsigned long UserID_In, int Flag_In);
// 프리미엄 타임 관련
bool GetPremiumService(CDBComponent& DBComponent, unsigned long UserID_In, PREMIUMSERVICE& Premium_Out);
bool UpdatePremiumService(CDBComponent& DBComponent, unsigned long UserID_In, int Flag_In);
bool AddPremiumService(CDBComponent& DBComponent, unsigned long UserID_In, int ServiceType_In, int AddDay_In);
// 엑스트라 이벤트 관련
bool UpdateExtraEvent(CDBComponent& DBComponent, unsigned long UserID_In, unsigned long EventType_In, unsigned long EventNum_In, unsigned long EventValue_In, unsigned int* Result_Out);
bool GetEquip(CDBComponent& DBComponent, unsigned long CharID_In, EQUIP* lpEquip_Out);
bool GetInven(CDBComponent& DBComponent, unsigned long CharID_In, INVEN* lpInven_Out);
bool GetQuick(CDBComponent& DBComponent, unsigned long CharID_In, QUICK* lpQuick_Out);
bool GetExtra(CDBComponent& DBComponent, unsigned long CharID_In, EXTRA* lpExtra_Out);
bool GetExchange(CDBComponent& DBComponent, unsigned long CharID_In, EXCHANGE* lpExchange_Out);
bool GetTempInven(CDBComponent& DBComponent, unsigned long CharID_In, TEMPINVEN* lpTempInven_Out);
bool UpdateEquip(CDBComponent& DBComponent, unsigned long CharID_In, EQUIP* lpEquip_In);
bool UpdateInven(CDBComponent& DBComponent, unsigned long CharID_In, INVEN* lpInven_In);
bool UpdateQuick(CDBComponent& DBComponent, unsigned long CharID_In, QUICK* lpQuick_In);
bool UpdateExtra(CDBComponent& DBComponent, unsigned long CharID_In, EXTRA* lpExtra_In);
bool UpdateExchange(CDBComponent& DBComponent, unsigned long CharID_In, EXCHANGE* lpExchange_In);
bool UpdateTempInven(CDBComponent& DBComponent, unsigned long CharID_In, TEMPINVEN* lpTempInven_In);
bool GetCharInfo(CDBComponent& DBComponent, unsigned long CharID_In, LPCHAR_INFOST lpCharInfo_In, unsigned short* EquiView_In, const int nEquipView);
bool GetCharPos(CDBComponent& DBComponent, unsigned long CharID_In, LPCHAR_POS lpCharPos_Out);
bool GetCharSkill(CDBComponent& DBComponent, unsigned long CharID_In, LPSKILL lpSkill_Out);
bool UpdateCharInfo(CDBComponent& DBComponent, unsigned long CharID_In, LPCHAR_INFOST lpCharInfo_In, unsigned short *EquipData_In, const int nEquipView);
bool UpdateCharPos(CDBComponent& DBComponent, unsigned long CharID_In, LPCHAR_POS lpCharPos_In);
bool UpdateCharSkill(CDBComponent& DBComponent, unsigned long CharID_In, LPSKILL lpSkill_In);
bool UpdateCharParty(CDBComponent& DBComponent, unsigned long CharID_In, unsigned long PartyID_In);
bool UpdateCharEquip(CDBComponent& DBComponent, unsigned long CharID_In, unsigned short *lpEquip_In);
// 파티 관련
bool InsertParty(CDBComponent& DBComponent, LPPARTY_DB_INFO lpParty_Info_In, unsigned long *PartyID_Out);
bool DeleteParty(CDBComponent& DBComponent, LPPARTY_DB_INFO lpParty_Info_In, unsigned long PartyID_In);
bool GetPartyInfo(CDBComponent& DBComponent, unsigned long PartyID_In, LPPARTY_DB_INFO lpPartyInfo_Out);
bool UpdatePartyInfo(CDBComponent& DBComponent, unsigned long PartyID_In, LPPARTY_DB_INFO lpPartyInfo_In);
bool InsertPartyMember(CDBComponent& DBComponent, unsigned long PartyID_In, LPPARTY_DB_INFO lpPartyInfo_In, unsigned long CharID_In);
bool DeletePartyMember(CDBComponent& DBComponent, unsigned long PartyID_In, LPPARTY_DB_INFO lpPartyInfo_In, unsigned long CharID_In);
// 로그 관련
bool InsertItemDuplicatedLog(CDBComponent& DBComponent, unsigned __int64 dwItemSerial,
const char* szName, unsigned long dwUID, unsigned long dwCID, unsigned long dwQty);
// 핵로그를 남긴다
bool InsertHackLog(CDBComponent& DBComponent, unsigned long dwUID, unsigned long dwCID, const char* szName);
// 전쟁 플래그 관련
bool UpdateGuildWarFlag(CDBComponent& DBComponent, unsigned long dwCID, unsigned char cFlag);
bool UpdateRealmWarFlag(CDBComponent& DBComponent, unsigned long dwCID, unsigned char cFlag);
// 운영자 캐릭터 명령어 로그 관련.
bool InsertAdminCommandLog(CDBComponent& DBComponent, unsigned long dwServerGroupID, unsigned long dwAdminCID, unsigned long dwCID, char* szCommand);
// bool GetKeyInfo(CDBComponent& DBComponent, KeyInfo* pKeyInfo, unsigned long dwUID);
// bool UpdateKeyInfo(CDBComponent& DBComponent, KeyInfo* pKeyInfo, unsigned long dwUID);
// 스펠 관련
bool GetSpell(CDBComponent& DBComponent, unsigned long CharID_In, SPELL* lpSpell_Out);
bool UpdateSpell(CDBComponent& DBComponent, unsigned long CharID_In, SPELL* lpSpell_In);
}
}
#endif

View File

@@ -0,0 +1,433 @@
#include "stdafx.h"
#include "DBComponent.h"
#include "GuildDBComponent.h"
#include <Utility/Math/Math.h>
#include <Utility/Debug/PerformanceCheck.h>
#include <Utility/Setup/ServerSetup.h>
#include <Log/ServerLog.h>
bool DBComponent::GuildDB::InsertGuildInfo(CDBComponent& DBComponent, char* szGuildName,
unsigned char cNation, char* szRight, unsigned short wSize,
unsigned long *dwGID, unsigned short *wError)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
unsigned long dwResult[2];
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(),
"dbo.USPGuildCreate '%s', '%d', '0', '0', 0x", szGuildName, cNation);
char* lpDest = DBComponent.GetQueryBuffer() + strlen(DBComponent.GetQueryBuffer());
// Query 뒷부분을 완성해준다. (권한 부분)
char* lpPos = szRight;
for (int nIndex = 0; nIndex < wSize; ++nIndex, ++lpPos, lpDest += 2)
{
Math::Convert::Hex08ToStr(lpDest, *lpPos);
}
size_t nLen = strlen(DBComponent.GetQueryBuffer());
lpDest = DBComponent.GetQueryBuffer() + strlen(DBComponent.GetQueryBuffer());
_snprintf(lpDest, DBComponent.GetQueryBufferLen() - nLen, ", %d",
CServerSetup::GetInstance().GetAgentServerType());
if (!DBComponent.ExecuteQueryGetData(DBComponent.GetQueryBuffer(), (void *)dwResult))
{
SERLOG2(g_Log, "길드 생성 실패 : %s : Query:%s", DBComponent.GetErrorString(), DBComponent.GetQueryBuffer());
return false;
}
*wError = static_cast<unsigned short>(dwResult[0]);
*dwGID = dwResult[1];
return true;
}
bool DBComponent::GuildDB::InsertGuildMember(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwCID, unsigned char cTitle, unsigned char cRank)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
unsigned long dwResult = 0;
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "dbo.USPGuildMemberInsert '%d', '%d', '%d', '%d'",
dwGID, dwCID, cTitle, cRank);
if (false == DBComponent.ExecuteQueryGetData(DBComponent.GetQueryBuffer(), (void *)&dwResult))
{
SERLOG2(g_Log, "길드 멤버 추가 실패 : %s : Query:%s", DBComponent.GetErrorString(), DBComponent.GetQueryBuffer());
return false;
}
if (0 != dwResult)
{
// CharInfo에 업데이트를 실패한 경우 (존재하지 않는 CID를 보냈다던지...)
return false;
}
return true;
}
bool DBComponent::GuildDB::InsertGuildRelation(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelationType)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "INSERT INTO TblGuildRelation(nGuildID, nTargetGuildID, tnRelation) VALUES(%d, %d, %d)",
dwGID, dwTargetGID, cRelationType);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 관계 추가 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::DeleteGuildInfo(CDBComponent& DBComponent, unsigned long dwGID)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "dbo.USPGuildDelete %d", dwGID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 삭제 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::DeleteGuildMember(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwCID, unsigned char cRank)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
unsigned long dwResult = 0;
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "dbo.USPGuildMemberOut %d, %d, %d",
dwGID, dwCID, cRank);
if (false == DBComponent.ExecuteQueryGetData(DBComponent.GetQueryBuffer(), (void *)&dwResult))
{
SERLOG1(g_Log, "길드 멤버 삭제 실패 : %s", DBComponent.GetErrorString());
return false;
}
if (0 != dwResult)
{
// CharInfo에 업데이트를 실패한 경우 (존재하지 않는 CID를 보냈다던지...)
return false;
}
return true;
}
bool DBComponent::GuildDB::DeleteGuildRelation(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwTargetGID)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "DELETE TblGuildRelation WHERE nGuildID=%d AND nTargetGuildID=%d", dwGID, dwTargetGID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 관계 삭제 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::DeleteGuildRelation(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelation)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "DELETE TblGuildRelation WHERE nGuildID=%d AND nTargetGuildID=%d AND tnRelation=%d", dwGID, dwTargetGID, cRelation);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 관계 삭제 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::DeleteGuildRelation(CDBComponent& DBComponent, unsigned long dwGID)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "DELETE TblGuildRelation WHERE nGuildID=%d OR nTargetGuildID=%d", dwGID, dwGID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 관계 삭제 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateMemberTitle(CDBComponent& DBComponent, unsigned long dwCID, unsigned char cTitle, SYSTEMTIME UpdateTime)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
char strTime[MAX_PATH] = "";
if (0 == UpdateTime.wYear)
{
// 년도가 0인 경우는 체크하지 않겠다는 의미이므로 DB에는 먼 미래로 기록해둔다.
sprintf(strTime, "cast('2010-12-31 00:00:00' as smalldatetime)");
}
else
{
sprintf(strTime, "cast('%d-%d-%d %d:%d:%d' as smalldatetime)", UpdateTime.wYear, UpdateTime.wMonth, UpdateTime.wDay,
UpdateTime.wHour, UpdateTime.wMinute, UpdateTime.wSecond, UpdateTime.wMilliseconds);
}
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "UPDATE TblGuildMember SET nPosition=%d, tLeaveGuildTime=%s WHERE nCID=%d",
cTitle, strTime, dwCID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드원 직위 변경 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateMemberRank(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwCID, unsigned char cBeforeRank, unsigned char cAfterRank)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "dbo.USPGuildChangePos %d, %d, %d, %d",
dwGID, dwCID, cBeforeRank, cAfterRank);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드원 직위 변경 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateGuildRelation(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelationType)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "UPDATE TblGuildRelation SET tnRelation=%d WHERE nGuildID=%d AND nTargetGuildID=%d",
cRelationType, dwGID, dwTargetGID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 관계 업데이트 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateGuildTime(CDBComponent& DBComponent, unsigned long dwGID, unsigned char cType, SYSTEMTIME UpdateTime)
{
// 상수들은 Community/Guild/GuildConstants.h 파일을 참고
// TODO : 현재 GameLibrary 프로젝트와 ServerLibrary 프로젝트의 종속성이 애매해서... 추후 정리가 필요.
char strTime[MAX_PATH] = "";
if (0 == UpdateTime.wYear)
{
// 년도가 0인 경우는 체크하지 않겠다는 의미이므로 DB에는 먼 미래로 기록해둔다.
sprintf(strTime, "cast('2010-12-31 00:00:00' as smalldatetime)");
}
else
{
sprintf(strTime, "cast('%d-%d-%d %d:%d:%d' as smalldatetime)", UpdateTime.wYear, UpdateTime.wMonth, UpdateTime.wDay,
UpdateTime.wHour, UpdateTime.wMinute, UpdateTime.wSecond, UpdateTime.wMilliseconds);
}
char strColumn[MAX_PATH] = "";
switch (cType)
{
case 0:
sprintf(strColumn, "tLastLogout");
break;
case 1:
sprintf(strColumn, "tCheckMember");
break;
case 2:
sprintf(strColumn, "tGMLastLogout");
break;
}
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "UPDATE TblGuildInfo SET %s=%s WHERE nGuildID=%d",
strColumn, strTime, dwGID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG2(g_Log, "길드 시간 변경 실패: %s - Query : %s", DBComponent.GetErrorString(), DBComponent.GetQueryBuffer());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateGuildLevel(CDBComponent& DBComponent, unsigned long dwGID, unsigned char cLevel, unsigned long dwGold)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "UPDATE TblGuildInfo SET nGuildGold=%d, tnGuildLevel=%d WHERE nGuildID=%d",
dwGold, cLevel, dwGID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 레벨 변경 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateGuildInclination(CDBComponent& DBComponent, unsigned long dwGID, unsigned char cInclination)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "UPDATE TblGuildInfo SET tnNationType=%d, tChangeState=GetDate() WHERE nGuildID=%d",
cInclination, dwGID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 성향 변경 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateGuildRight(CDBComponent& DBComponent, unsigned long dwGID, char* szRight, unsigned short wSize)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(),
"UPDATE TblGuildInfo SET bRight=0x");
char* lpDest = DBComponent.GetQueryBuffer() + strlen(DBComponent.GetQueryBuffer());
char* lpPos = szRight;
for (int nIndex = 0; nIndex < wSize; ++nIndex, ++lpPos, lpDest += 2)
{
Math::Convert::Hex08ToStr(lpDest, *lpPos);
}
const int MAX_FOOTER = 512;
char szFooter[MAX_FOOTER];
sprintf(szFooter, " WHERE nGuildID=%d", dwGID);
strcat(DBComponent.GetQueryBuffer(), szFooter);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 권한 변경 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateGuildMark(CDBComponent& DBComponent, unsigned long dwGID, char* szMark, unsigned short wSize, unsigned long dwGold)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "UPDATE TblGuildInfo SET nGuildGold=%d, bGuildMark=0x", dwGold);
char* lpDest = DBComponent.GetQueryBuffer() + strlen(DBComponent.GetQueryBuffer());
char* lpPos = szMark;
for (int nIndex = 0; nIndex < wSize; ++nIndex, ++lpPos, lpDest += 2)
{
Math::Convert::Hex08ToStr(lpDest, *lpPos);
}
const int MAX_FOOTER = 512;
char szFooter[MAX_FOOTER];
sprintf(szFooter, " WHERE nGuildID=%d", dwGID);
strcat(DBComponent.GetQueryBuffer(), szFooter);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 마크 변경 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateGuildMemberTactics(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwCID, unsigned char cTactics)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(),
"Update TblGuildMember Set Tactics = %d where nGuildID = %d And nCID = %d",cTactics, dwGID, dwCID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "용병 플레그 세팅 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateGuildGold(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwGold)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "UPDATE TblGuildInfo SET nGuildGold=%d WHERE nGuildID=%d",
dwGold, dwGID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 금고 업데이트 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::UpdateGuildFame(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwFame)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "UPDATE TblGuildInfo SET nGuildFame=%d WHERE nGuildID=%d",
dwFame, dwGID);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 명성 업데이트 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}
bool DBComponent::GuildDB::ReleaseGold(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwGold)
{
DBOBJECT_PERFORMANCE_CHECK(FunctionTimingCheck);
_snprintf(DBComponent.GetQueryBuffer(), DBComponent.GetQueryBufferLen(), "dbo.USPGuildGiveMemberGold %d, %d",
dwGID, dwGold);
if (false == DBComponent.ExecuteQuery(DBComponent.GetQueryBuffer()))
{
SERLOG1(g_Log, "길드 금고 방출 실패 : %s", DBComponent.GetErrorString());
return false;
}
return true;
}

View File

@@ -0,0 +1,38 @@
#ifndef _RYL_GUILD_DB_COMPONENT_H_
#define _RYL_GUILD_DB_COMPONENT_H_
// forward decl.
class CDBComponent;
namespace DBComponent
{
namespace GuildDB
{
// --------------------------------------------------------------------------------------------
// 길드 관련 - GuildDBComponent.cpp --------------------------------------------------------------
bool InsertGuildInfo(CDBComponent& DBComponent, char* szGuildName, unsigned char cNation, char* szRight, unsigned short wSize, unsigned long *dwGID, unsigned short *wError);
bool InsertGuildMember(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwCID, unsigned char cTitle, unsigned char cRank);
bool InsertGuildRelation(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelationType);
bool DeleteGuildInfo(CDBComponent& DBComponent, unsigned long dwGID);
bool DeleteGuildMember(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwCID, unsigned char cRank);
bool DeleteGuildRelation(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwTargetGID); // 두 길드 간의 관계를 삭제
bool DeleteGuildRelation(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelation); // 두 길드 간의 관계를 삭제
bool DeleteGuildRelation(CDBComponent& DBComponent, unsigned long dwGID); // 해당 길드와 관계가 있는 모든 길드 관계를 삭제
bool UpdateMemberTitle(CDBComponent& DBComponent, unsigned long dwCID, unsigned char cTitle, SYSTEMTIME UpdateTime);
bool UpdateMemberRank(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwCID, unsigned char cBeforeRank, unsigned char cAfterRank);
bool UpdateGuildRelation(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwTargetGID, unsigned char cRelationType);
bool UpdateGuildTime(CDBComponent& DBComponent, unsigned long dwGID, unsigned char cType, SYSTEMTIME UpdateTime);
bool UpdateGuildLevel(CDBComponent& DBComponent, unsigned long dwGID, unsigned char cLevel, unsigned long dwGold);
bool UpdateGuildInclination(CDBComponent& DBComponent, unsigned long dwGID, unsigned char cInclination);
bool UpdateGuildRight(CDBComponent& DBComponent, unsigned long dwGID, char* szRight, unsigned short wSize);
bool UpdateGuildMark(CDBComponent& DBComponent, unsigned long dwGID, char* szMark, unsigned short wSize, unsigned long dwGold);
bool UpdateGuildGold(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwGold);
bool UpdateGuildFame(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwFame);
bool ReleaseGold(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwGold);
bool UpdateGuildMemberTactics(CDBComponent& DBComponent, unsigned long dwGID, unsigned long dwCID, unsigned char cTactics);
}
}
#endif