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:
568
Server/DBProcess/ConvertTwoNationQuest/ConvertTwoNationQuest.cpp
Normal file
568
Server/DBProcess/ConvertTwoNationQuest/ConvertTwoNationQuest.cpp
Normal file
@@ -0,0 +1,568 @@
|
||||
// ConvertTwoNationQuest.cpp : <20>ܼ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <Item/ItemMgr.h>
|
||||
#include <Item/Item.h>
|
||||
#include <Item/Container/ContainerConstant.h>
|
||||
#include <Item/RebalanceConvert/ContainerChecker.h>
|
||||
|
||||
#include <RylDBLibrary/RylDBLibrary.h>
|
||||
#include <RylDBLibrary/RylDBStoreCommand.h>
|
||||
#include <RylDBLibrary/RylDBCharCommand.h>
|
||||
|
||||
#include <Log/ServerLog.h>
|
||||
|
||||
#include <Network/Packet/PacketStruct/ServerInfo.h>
|
||||
#include <Network/Packet/PacketStruct/CharQuestPacket.h>
|
||||
|
||||
#include <Utility/TokenlizedFile.h>
|
||||
#include <Utility/Setup/ServerSetup.h>
|
||||
#include <Utility/math/Math.h>
|
||||
|
||||
#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)); }
|
||||
|
||||
class CDBConvertTwoNationQuest : public IDBCharItemProcess, public IDBCharQuestProcess
|
||||
{
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
INSERT_ITEM_ID = 10329
|
||||
};
|
||||
|
||||
struct ConvertID
|
||||
{
|
||||
unsigned short m_wQuestID;
|
||||
unsigned short m_wChangeQuestID;
|
||||
unsigned char m_cType;
|
||||
|
||||
enum
|
||||
{
|
||||
type_remove_quest = 0,
|
||||
type_change_quest = 1
|
||||
};
|
||||
|
||||
ConvertID() : m_wQuestID(0), m_wChangeQuestID(0) {}
|
||||
};
|
||||
|
||||
|
||||
struct ParseData
|
||||
{
|
||||
typedef bool(*ParseFunc) (ConvertID& convertID, const char* szValue);
|
||||
|
||||
const char* m_szColumnName;
|
||||
ParseFunc m_fnParseFunc;
|
||||
|
||||
ParseData(const char* szColumnName, ParseFunc fnParseFunc)
|
||||
: m_szColumnName(szColumnName), m_fnParseFunc(fnParseFunc) { }
|
||||
};
|
||||
|
||||
typedef std::vector<ParseData> ParseDataArray;
|
||||
typedef std::map<unsigned short, ConvertID*> ConvertMap;
|
||||
typedef std::map<unsigned long, unsigned long> UID;
|
||||
|
||||
public:
|
||||
|
||||
CDBConvertTwoNationQuest(ATL::CSession& session) : m_Session(session) { }
|
||||
|
||||
virtual ConvertResult operator() (RylDBCommand::CCharItem& charItem_InOut);
|
||||
virtual ConvertResult operator() (RylDBCommand::CCharQuest& charQuest_InOut);
|
||||
|
||||
bool Initialize(int nServerGroup);
|
||||
bool Release();
|
||||
|
||||
private:
|
||||
|
||||
UID m_cUID;
|
||||
|
||||
ConvertMap m_cConvertMap;
|
||||
ConvertMap m_cChangeMap;
|
||||
|
||||
CDBItemSerialMgr m_cDBItemSerialMgr;
|
||||
|
||||
ATL::CSession& m_Session;
|
||||
};
|
||||
|
||||
class CParseDelimitedData
|
||||
{
|
||||
public:
|
||||
|
||||
CParseDelimitedData(CTokenlizedFile& TokenlizedFile) : m_TokenlizedFile(TokenlizedFile) { }
|
||||
|
||||
bool operator() (CDBConvertTwoNationQuest::ParseDataArray& ParserArray, CDBConvertTwoNationQuest::ConvertID& convertID)
|
||||
{
|
||||
for (CDBConvertTwoNationQuest::ParseDataArray::iterator itr = ParserArray.begin(); itr != ParserArray.end(); ++itr)
|
||||
{
|
||||
const char* szValue = m_TokenlizedFile.GetStringValue(itr->m_szColumnName);
|
||||
|
||||
if (NULL == szValue)
|
||||
{
|
||||
ERRLOG2(g_Log, "Data Load Fail Line:%d, ColumnName:%s",
|
||||
m_TokenlizedFile.GetCurrentLine(), itr->m_szColumnName);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == itr->m_fnParseFunc(convertID, szValue))
|
||||
{
|
||||
ERRLOG2(g_Log, "Data Fail Line:%d, ColumnName:%s",
|
||||
m_TokenlizedFile.GetCurrentLine(), itr->m_szColumnName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
CTokenlizedFile& m_TokenlizedFile;
|
||||
};
|
||||
|
||||
bool ReadType(CDBConvertTwoNationQuest::ConvertID& convertID, const char* szValue)
|
||||
{
|
||||
convertID.m_cType = static_cast<unsigned char>(atoi(szValue));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool ReadBefore(CDBConvertTwoNationQuest::ConvertID& convertID, const char* szValue)
|
||||
{
|
||||
convertID.m_wQuestID = Math::Convert::StrToHex16(szValue);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool ReadAfter(CDBConvertTwoNationQuest::ConvertID& convertID, const char* szValue)
|
||||
{
|
||||
convertID.m_wChangeQuestID = Math::Convert::StrToHex16(szValue);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void PrintUsage()
|
||||
{
|
||||
printf("ConvertAccessory DBAddress DBName DBAccount DBPassword ServerGroupNum(0~9)");
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
if(6 != argc)
|
||||
{
|
||||
PrintUsage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
CoInitialize(0);
|
||||
|
||||
int nServerGroup = atoi(argv[5]);
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
ATL::CDataSource dataSource;
|
||||
ATL::CSession Session;
|
||||
|
||||
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 = Session.StartTransaction()))
|
||||
{
|
||||
LOG_CONVERT1("Start transaction failed : hr:0x%08x", hr);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
CRylDBProcess dbProcess(Session);
|
||||
CConsoleCounter consoleCounter(1000);
|
||||
CDBConvertTwoNationQuest quest(Session);
|
||||
|
||||
if(!quest.Initialize(nServerGroup))
|
||||
{
|
||||
LOG_CONVERT0("Initialize failed");
|
||||
}
|
||||
else if (FAILED(hr = dbProcess.CharQuest(quest, consoleCounter)))
|
||||
{
|
||||
LOG_CONVERT1("CharQuest process failed : hr:0x%08X", hr);
|
||||
}
|
||||
else if(FAILED(hr = dbProcess.CharItem(quest, consoleCounter)))
|
||||
{
|
||||
LOG_CONVERT1("CharItem process failed : hr:0x%08x", hr);
|
||||
}
|
||||
|
||||
quest.Release();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
LOG_CONVERT0("Exception occured! rollback transaction now!");
|
||||
LOG_CONVERT2("Rollback transaction %s! : hr:0x%08x",
|
||||
FAILED(hr = Session.Abort()) ? "failed" : "succeeded", hr);
|
||||
}
|
||||
|
||||
LOG_CONVERT0("Commit transaction now!");
|
||||
LOG_CONVERT2("Commit transaction %s! : hr:0x%08x",
|
||||
FAILED(hr = Session.Commit()) ? "failed" : "succeeded", hr);
|
||||
}
|
||||
|
||||
Session.Close();
|
||||
dataSource.Close();
|
||||
|
||||
CoUninitialize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CDBConvertTwoNationQuest::Initialize(int nServerGroup)
|
||||
{
|
||||
const char* szFileName = "ConvertQuest.txt";
|
||||
|
||||
CTokenlizedFile TokenlizedFile;
|
||||
|
||||
if(!TokenlizedFile.Open(szFileName))
|
||||
{
|
||||
LOG_CONVERT0("ConverScript <20>ε<EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == TokenlizedFile.ReadColumn())
|
||||
{
|
||||
LOG_CONVERT0("ConverScript <20>÷<EFBFBD> <20>ε<EFBFBD> <20><><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
ParseDataArray parseDataArray;
|
||||
|
||||
parseDataArray.reserve(3);
|
||||
parseDataArray.push_back(ParseData("Type", ReadType));
|
||||
parseDataArray.push_back(ParseData("Before", ReadBefore));
|
||||
parseDataArray.push_back(ParseData("After", ReadAfter));
|
||||
|
||||
m_cConvertMap.clear();
|
||||
m_cChangeMap.clear();
|
||||
|
||||
ConvertID convertID;
|
||||
ConvertID* pConverID;
|
||||
|
||||
CParseDelimitedData ParseData(TokenlizedFile);
|
||||
|
||||
while (TokenlizedFile.ReadLine())
|
||||
{
|
||||
if (false == ParseData(parseDataArray, convertID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pConverID = new ConvertID;
|
||||
memcpy(pConverID, &convertID, sizeof(ConvertID));
|
||||
|
||||
bool bInsert = false;
|
||||
|
||||
if(pConverID->m_cType==ConvertID::type_remove_quest)
|
||||
{
|
||||
bInsert = m_cConvertMap.insert(std::make_pair(pConverID->m_wQuestID, pConverID)).second;
|
||||
}
|
||||
else if(pConverID->m_cType==ConvertID::type_change_quest)
|
||||
{
|
||||
bInsert = m_cChangeMap.insert(std::make_pair(pConverID->m_wQuestID, pConverID)).second;
|
||||
}
|
||||
|
||||
if(!bInsert)
|
||||
{
|
||||
LOG_CONVERT0("ConverMap Insert Fail");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SERVER_ID serverID;
|
||||
|
||||
serverID.sID.Type = CServerSetup::AuthServer;
|
||||
serverID.sID.Group = nServerGroup;
|
||||
serverID.sID.Channel = 0;
|
||||
serverID.sID.ID = 0;
|
||||
|
||||
HRESULT hr = m_cDBItemSerialMgr.LoadItemSerialDB(m_Session, serverID.dwID);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
LOG_CONVERT1("itemSerial failed : hr:0x%08X", hr);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9>Ʈ <20>ε<EFBFBD>
|
||||
if(!Item::CItemMgr::GetInstance().LoadItemProtoType("ItemScript.txt"))
|
||||
{
|
||||
LOG_CONVERT0("ItemScript Load Failed");
|
||||
}
|
||||
|
||||
m_cUID.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDBConvertTwoNationQuest::Release()
|
||||
{
|
||||
ConvertMap::iterator begin = m_cConvertMap.begin();
|
||||
ConvertMap::iterator end = m_cConvertMap.end();
|
||||
|
||||
for(ConvertMap::iterator itr = begin; itr!=end; itr++)
|
||||
{
|
||||
if(itr->second)
|
||||
{
|
||||
delete itr->second;
|
||||
}
|
||||
}
|
||||
|
||||
begin = m_cChangeMap.begin();
|
||||
end = m_cChangeMap.end();
|
||||
|
||||
for(ConvertMap::iterator itr = begin; itr!=end; itr++)
|
||||
{
|
||||
if(itr->second)
|
||||
{
|
||||
delete itr->second;
|
||||
}
|
||||
}
|
||||
|
||||
m_cChangeMap.clear();
|
||||
m_cConvertMap.clear();
|
||||
m_cUID.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ConvertResult CDBConvertTwoNationQuest::operator() (RylDBCommand::CCharQuest& charQuest_InOut)
|
||||
{
|
||||
unsigned long dwCID = charQuest_InOut.GetCID();
|
||||
unsigned long dwCount = 0;
|
||||
bool bQuestCheck = false;
|
||||
bool bCompleteCheck = false;
|
||||
const QUEST& quest_In = charQuest_InOut.GetQuest();
|
||||
const HISTORY history_In = charQuest_InOut.GetHistory();
|
||||
|
||||
if(dwCID==104)
|
||||
{
|
||||
// 0xf134 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD>̻<EFBFBD>) or <20>Ϸ<EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD> PC üũ
|
||||
if (0 < quest_In.dwSize)
|
||||
{
|
||||
QUEST quest_Out;
|
||||
memset(&quest_Out, 0, sizeof(QUEST));
|
||||
|
||||
const PktQuestDB::ExecutingQuest* lpExecutingQuestPos =
|
||||
reinterpret_cast<const PktQuestDB::ExecutingQuest*>(quest_In.Data);
|
||||
|
||||
const PktQuestDB::ExecutingQuest* lpExecutingQuestEnd =
|
||||
reinterpret_cast<const PktQuestDB::ExecutingQuest*>(quest_In.Data + quest_In.dwSize);
|
||||
|
||||
for(; lpExecutingQuestPos < lpExecutingQuestEnd; ++lpExecutingQuestPos)
|
||||
{
|
||||
if(lpExecutingQuestPos->m_wQuestID==0xf134 && lpExecutingQuestPos->m_cPhase>=3)
|
||||
{
|
||||
bQuestCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < history_In.dwSize && !bQuestCheck)
|
||||
{
|
||||
HISTORY history_Out;
|
||||
memset(&history_Out, 0, sizeof(HISTORY));
|
||||
|
||||
const unsigned short* lpHistoryPos = reinterpret_cast<const unsigned short*>(history_In.Data);
|
||||
const unsigned short* lpHistoryEnd = reinterpret_cast<const unsigned short*>(history_In.Data + history_In.dwSize);
|
||||
|
||||
for(; lpHistoryPos < lpHistoryEnd; ++lpHistoryPos)
|
||||
{
|
||||
if(*lpHistoryPos==0xf134)
|
||||
{
|
||||
bQuestCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 0xf090 or 0xf096 <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD>̻<EFBFBD>) or <20>Ϸ<EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>Ͽ<EFBFBD> <20>ִ<EFBFBD> PC üũ.
|
||||
if (0 < quest_In.dwSize && bQuestCheck)
|
||||
{
|
||||
QUEST quest_Out;
|
||||
memset(&quest_Out, 0, sizeof(QUEST));
|
||||
|
||||
const PktQuestDB::ExecutingQuest* lpExecutingQuestPos =
|
||||
reinterpret_cast<const PktQuestDB::ExecutingQuest*>(quest_In.Data);
|
||||
|
||||
const PktQuestDB::ExecutingQuest* lpExecutingQuestEnd =
|
||||
reinterpret_cast<const PktQuestDB::ExecutingQuest*>(quest_In.Data + quest_In.dwSize);
|
||||
|
||||
for(; lpExecutingQuestPos < lpExecutingQuestEnd; ++lpExecutingQuestPos)
|
||||
{
|
||||
if(lpExecutingQuestPos->m_wQuestID==0xf090 && lpExecutingQuestPos->m_cPhase>=3)
|
||||
{
|
||||
bQuestCheck = true;
|
||||
break;
|
||||
}
|
||||
else if(lpExecutingQuestPos->m_wQuestID==0xf096 && lpExecutingQuestPos->m_cPhase>=3)
|
||||
{
|
||||
bCompleteCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < history_In.dwSize && !bCompleteCheck)
|
||||
{
|
||||
HISTORY history_Out;
|
||||
memset(&history_Out, 0, sizeof(HISTORY));
|
||||
|
||||
const unsigned short* lpHistoryPos = reinterpret_cast<const unsigned short*>(history_In.Data);
|
||||
const unsigned short* lpHistoryEnd = reinterpret_cast<const unsigned short*>(history_In.Data + history_In.dwSize);
|
||||
|
||||
for(; lpHistoryPos < lpHistoryEnd; ++lpHistoryPos)
|
||||
{
|
||||
if(*lpHistoryPos!=0xf090 && *lpHistoryPos!=0xf096)
|
||||
{
|
||||
bQuestCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>Ͽ<EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
if (0 < quest_In.dwSize)
|
||||
{
|
||||
QUEST quest_Out;
|
||||
memset(&quest_Out, 0, sizeof(QUEST));
|
||||
|
||||
const PktQuestDB::ExecutingQuest* lpExecutingQuestPos =
|
||||
reinterpret_cast<const PktQuestDB::ExecutingQuest*>(quest_In.Data);
|
||||
|
||||
const PktQuestDB::ExecutingQuest* lpExecutingQuestEnd =
|
||||
reinterpret_cast<const PktQuestDB::ExecutingQuest*>(quest_In.Data + quest_In.dwSize);
|
||||
|
||||
PktQuestDB::ExecutingQuest* lpDst = reinterpret_cast<PktQuestDB::ExecutingQuest*>(quest_Out.Data);
|
||||
|
||||
for(dwCount = 0; lpExecutingQuestPos < lpExecutingQuestEnd; ++lpExecutingQuestPos)
|
||||
{
|
||||
ConvertMap::iterator find = m_cConvertMap.find(lpExecutingQuestPos->m_wQuestID);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD>°<C2B0> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>..
|
||||
if(find==m_cConvertMap.end())
|
||||
{
|
||||
*lpDst = *lpExecutingQuestPos;
|
||||
lpDst++;
|
||||
dwCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (dwCount)
|
||||
{
|
||||
quest_Out.dwSize = static_cast<unsigned long>(
|
||||
reinterpret_cast<char*>(lpDst) - quest_Out.Data);
|
||||
|
||||
charQuest_InOut.SetQuest(quest_Out);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < history_In.dwSize)
|
||||
{
|
||||
HISTORY quest;
|
||||
memcpy(&quest, &history_In, sizeof(HISTORY));
|
||||
|
||||
unsigned short* lpHistoryPos = reinterpret_cast<unsigned short*>(quest.Data);
|
||||
unsigned short* lpHistoryEnd = reinterpret_cast<unsigned short*>(quest.Data + history_In.dwSize);
|
||||
|
||||
for(dwCount = 0; lpHistoryPos < lpHistoryEnd; ++lpHistoryPos)
|
||||
{
|
||||
ConvertMap::iterator find = m_cConvertMap.find(*lpHistoryPos);
|
||||
|
||||
if(find!=m_cChangeMap.end())
|
||||
{
|
||||
*lpHistoryPos = find->second->m_wChangeQuestID;
|
||||
dwCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (dwCount)
|
||||
{
|
||||
charQuest_InOut.SetHistory(quest);
|
||||
}
|
||||
}
|
||||
|
||||
if(bQuestCheck)
|
||||
{
|
||||
bool bInsert = m_cUID.insert(std::make_pair(dwCID, dwCID)).second;
|
||||
|
||||
if(!bInsert)
|
||||
{
|
||||
LOG_CONVERT1("UID Insert Fail : %u", dwCID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CONVERT_SUCCEEDED;
|
||||
}
|
||||
|
||||
ConvertResult CDBConvertTwoNationQuest::operator()(RylDBCommand::CCharItem& charItem_InOut)
|
||||
{
|
||||
// 10329 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
|
||||
unsigned long dwCID = charItem_InOut.GetCID();
|
||||
|
||||
UID::iterator find = m_cUID.find(dwCID);
|
||||
|
||||
if(find!=m_cUID.end())
|
||||
{
|
||||
const INVEN& inven_In = charItem_InOut.GetInven();
|
||||
|
||||
INVEN inven_Out;
|
||||
memset(&inven_Out, 0, sizeof(INVEN));
|
||||
|
||||
const Item::ItemInfo* pItemInfo = Item::CItemMgr::GetInstance().GetItemInfo(INSERT_ITEM_ID);
|
||||
|
||||
if(pItemInfo)
|
||||
{
|
||||
RebalanceLib::CItemArrayChecker<
|
||||
ContainerConstant::INVENTORY_WIDTH,
|
||||
ContainerConstant::INVENTORY_HEIGHT,
|
||||
ContainerConstant::MAX_INVENTORY_TAB> Inven_checker(TakeType::TS_INVEN);
|
||||
|
||||
Item::ItemPos emptyPos;
|
||||
|
||||
if(inven_Out.dwSize + sizeof(Item::ItemData) <= INVEN::MAX_INVEN_SIZE)
|
||||
{
|
||||
if(Inven_checker.FindQuestEmptyPos(emptyPos, pItemInfo->m_DetailData.m_cXSize, pItemInfo->m_DetailData.m_cYSize))
|
||||
{
|
||||
Item::ItemData* lpItemData = reinterpret_cast<Item::ItemData*>(inven_Out.Data + inven_Out.dwSize);
|
||||
|
||||
lpItemData->m_dwUID = m_cDBItemSerialMgr.GetNewItemSerial();
|
||||
lpItemData->m_usProtoTypeID = pItemInfo->m_usProtoTypeID;
|
||||
lpItemData->m_ItemPos = emptyPos;
|
||||
lpItemData->m_cItemSize = sizeof(Item::ItemData);
|
||||
lpItemData->m_cNumOrDurability = 1;
|
||||
|
||||
inven_Out.dwSize += sizeof(Item::ItemData);
|
||||
|
||||
charItem_InOut.SetInven(inven_Out);
|
||||
|
||||
goto go_return;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_CONVERT1("Empty Pos : %u", dwCID);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_CONVERT1("ItemManager Load Failed : %u", dwCID);
|
||||
}
|
||||
}
|
||||
|
||||
go_return:
|
||||
|
||||
return CONVERT_SUCCEEDED;
|
||||
}
|
||||
Reference in New Issue
Block a user