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>
171 lines
5.4 KiB
C++
171 lines
5.4 KiB
C++
// RebalanceConverter.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "Rebalance.h"
|
|
#include <RylDBLibrary/RylDBLibrary.h>
|
|
#include <Item/RebalanceConvert/RebalanceItem.h>
|
|
|
|
#include <Item/ItemMgr.h>
|
|
#include <Skill/SkillMgr.h>
|
|
#include <Item/RebalanceConvert/OldItemMgr.h>
|
|
|
|
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
|
#include <Utility/Setup/ServerSetup.h>
|
|
#include <Log/ServerLog.h>
|
|
|
|
void PrintUsage()
|
|
{
|
|
printf("usage : RebalanceConverter DBAddress DBName DBAccount DBPassword "
|
|
"ServerGroupNum(0~9) RenumberingUID(0/1)\n");
|
|
}
|
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|
|
{
|
|
if(7 != argc)
|
|
{
|
|
PrintUsage();
|
|
return -1;
|
|
}
|
|
|
|
if(!Item::CItemMgr::GetInstance().LoadItemProtoType("./NewItemScript.txt"))
|
|
{
|
|
printf("NewItemScript.txt load failed\n");
|
|
return -1;
|
|
}
|
|
else if(!OldItem::CItemMgr::GetInstance().LoadItemProtoType("./OldItemScript.txt"))
|
|
{
|
|
printf("OldItemScript.txt load failed\n");
|
|
return -1;
|
|
}
|
|
|
|
using namespace RebalanceLib;
|
|
|
|
CoInitialize(0);
|
|
|
|
int nServerGroup = atoi(argv[5]);
|
|
bool bRenumberingUID = (1 == atoi(argv[6]));
|
|
|
|
SERVER_ID serverID;
|
|
|
|
serverID.sID.Type = CServerSetup::AuthServer;
|
|
serverID.sID.Group = nServerGroup;
|
|
serverID.sID.Channel = 0;
|
|
serverID.sID.ID = 0;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
ATL::CDataSource dataSource;
|
|
ATL::CSession Session;
|
|
|
|
CDBItemSerialMgr dbItemSerialMgr;
|
|
|
|
#define LOG_CONVERT0(str) { ERRLOG0(g_Log, (str)); printf(str "\n"); }
|
|
#define LOG_CONVERT1(str, arg1) { ERRLOG1(g_Log, (str), (arg1)); printf(str "\n", (arg1)); }
|
|
#define LOG_CONVERT2(str, arg1, arg2) { ERRLOG2(g_Log, (str), (arg1), (arg2)); printf(str "\n", (arg1), (arg2)); }
|
|
|
|
if(FAILED(hr = CRylDBProcess::ConnectDB(dataSource, argv[1], argv[2], argv[3], argv[4])))
|
|
{
|
|
LOG_CONVERT1("Connect DB failed : hr:0x%08X", hr);
|
|
}
|
|
else if(FAILED(hr = Session.Open(dataSource)))
|
|
{
|
|
LOG_CONVERT1("Open session failed : hr:0x%08X", hr);
|
|
}
|
|
else if(FAILED(hr = dbItemSerialMgr.ClearAllSerialDB(Session)))
|
|
{
|
|
LOG_CONVERT1("Clear itemSerial failed : hr:0x%08X", hr);
|
|
}
|
|
else if(FAILED(hr = dbItemSerialMgr.LoadItemSerialDB(Session, serverID.dwID)))
|
|
{
|
|
LOG_CONVERT1("Insert itemSerial failed : hr:0x%08X", hr);
|
|
}
|
|
else
|
|
{
|
|
CRylDBProcess rylDBProcess(Session);
|
|
CConsoleCounter consoleCounter(1000);
|
|
|
|
SkillDataMap UIDSkillDataMap;
|
|
SkillDataMap CIDSkillDataMap;
|
|
|
|
CDBReadSkill readDBSkill(CIDSkillDataMap, true);
|
|
|
|
CDBItemConvert convertDBItem(dbItemSerialMgr,
|
|
Item::CItemMgr::GetInstance(), OldItem::CItemMgr::GetInstance(),
|
|
&UIDSkillDataMap, &CIDSkillDataMap, true, bRenumberingUID);
|
|
|
|
// 스킬 읽기
|
|
if(FAILED(hr = rylDBProcess.CharSkill(readDBSkill, consoleCounter)))
|
|
{
|
|
LOG_CONVERT1("Skill process failed : hr:0x%08X", hr);
|
|
}
|
|
// CharItem컨버트
|
|
else if(FAILED(hr = rylDBProcess.CharItem(convertDBItem, consoleCounter)))
|
|
{
|
|
LOG_CONVERT1("CharItem process failed : hr:0x%08X", hr);
|
|
}
|
|
// CharItemEx컨버트
|
|
else if(FAILED(hr = rylDBProcess.CharItemEx(convertDBItem, consoleCounter)))
|
|
{
|
|
LOG_CONVERT1("CharItemEx process failed : hr:0x%08X", hr);
|
|
}
|
|
// 통합서버 창고 컨버트
|
|
else if(FAILED(hr = rylDBProcess.UnifiedStore1(convertDBItem, consoleCounter)))
|
|
{
|
|
LOG_CONVERT1("UnifiedStore1 process failed : hr:0x%08X", hr);
|
|
}
|
|
else if(FAILED(hr = rylDBProcess.UnifiedStore2(convertDBItem, consoleCounter)))
|
|
{
|
|
LOG_CONVERT1("UnifiedStore2 process failed : hr:0x%08X", hr);
|
|
}
|
|
else
|
|
{
|
|
GoldDataMap UIDGoldDataMap;
|
|
GoldDataMap CIDGoldDataMap;
|
|
|
|
CDBItemConvert::ChangeSkillBookToGold(UIDSkillDataMap, UIDGoldDataMap);
|
|
CDBItemConvert::ChangeSkillBookToGold(CIDSkillDataMap, CIDGoldDataMap);
|
|
|
|
CDBAddUnifiedStoreGold addUnifiedStoreGold(UIDGoldDataMap);
|
|
CDBAddCharGold addCharGold(CIDGoldDataMap);
|
|
|
|
if(FAILED(hr = rylDBProcess.UnifiedStore1(addUnifiedStoreGold, consoleCounter)))
|
|
{
|
|
LOG_CONVERT1("Add store gold process failed : hr:0x%08X", hr);
|
|
}
|
|
else if(FAILED(hr = rylDBProcess.CharInfo(addCharGold, consoleCounter)))
|
|
{
|
|
LOG_CONVERT1("Add character gold process failed : hr:0x%08X", hr);
|
|
}
|
|
|
|
// 남은 스킬북 양을 확인.
|
|
LogRemainSkillBook(UIDSkillDataMap, "UIDBook");
|
|
LogRemainSkillBook(CIDSkillDataMap, "CIDBook");
|
|
|
|
// 남은 돈 양을 확인.
|
|
LogRemainGold(UIDGoldDataMap, "UIDGold");
|
|
LogRemainGold(CIDGoldDataMap, "CIDGold");
|
|
|
|
// 최종 아이템 시리얼 저장.
|
|
if(FAILED(hr = dbItemSerialMgr.SaveItemSerialDB(Session, serverID.dwID)))
|
|
{
|
|
LOG_CONVERT1("ItemSerial save failed : hr:0x%08X", hr);
|
|
}
|
|
|
|
// 아이템 등급 출력
|
|
CItemGrade::GetInstance().WriteGradeNum();
|
|
INFLOG2(g_Log, "MaxUID : (0x%08X / %016I64X)",
|
|
serverID.dwID, dbItemSerialMgr.GetItemSerial());
|
|
}
|
|
}
|
|
|
|
INFLOG0(g_Log, "Convert Complete");
|
|
|
|
Session.Close();
|
|
dataSource.Close();
|
|
|
|
CoUninitialize();
|
|
return 0;
|
|
}
|
|
|