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:
80
GameTools/GLOBALSCRIPT/Item/ItemFactory.cpp
Normal file
80
GameTools/GLOBALSCRIPT/Item/ItemFactory.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "stdafx.h"
|
||||
#include "Item.h"
|
||||
#include "ItemMgr.h"
|
||||
#include "ItemFactory.h"
|
||||
|
||||
using namespace Item;
|
||||
|
||||
CItemFactory CItemFactory::ms_this;
|
||||
|
||||
CItemFactory::CItemFactory()
|
||||
: m_nCurrentUID(0)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
CItemFactory::~CItemFactory()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
CItem* CItemFactory::CreateItem(const ItemInfo& itemInfo)
|
||||
{
|
||||
unsigned long dwFlags = itemInfo.m_DetailData.m_dwFlags;
|
||||
|
||||
CItem* lpItem = NULL;
|
||||
|
||||
if(DetailData::EQUIP == (dwFlags & DetailData::EQUIP))
|
||||
{
|
||||
lpItem = new CEquipment(m_nCurrentUID++, itemInfo);
|
||||
}
|
||||
else if(DetailData::USE_ITEM == (dwFlags & DetailData::USE_ITEM))
|
||||
{
|
||||
lpItem = new CUseItem(m_nCurrentUID++, itemInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpItem = new CItem(m_nCurrentUID++, itemInfo);
|
||||
}
|
||||
|
||||
return lpItem;
|
||||
}
|
||||
|
||||
|
||||
CItem* CItemFactory::CreateItem(unsigned short usProtoTypeID)
|
||||
{
|
||||
const ItemInfo* lpItemInfo = CItemMgr::GetInstance().GetItemInfo(usProtoTypeID);
|
||||
|
||||
if(NULL != lpItemInfo)
|
||||
{
|
||||
return CreateItem(*lpItemInfo);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
CItem* CItemFactory::CreateItem(const char* lpSerializedItem_In, size_t& nParseLength_InOut)
|
||||
{
|
||||
const ItemData* lpItemData = reinterpret_cast<const ItemData*>(lpSerializedItem_In);
|
||||
|
||||
if(NULL != lpItemData)
|
||||
{
|
||||
CItem* lpItem = CreateItem(lpItemData->m_usProtoTypeID);
|
||||
|
||||
if(NULL != lpItem)
|
||||
{
|
||||
if(!lpItem->SerializeIn(lpSerializedItem_In, nParseLength_InOut))
|
||||
{
|
||||
delete lpItem;
|
||||
lpItem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return lpItem;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user