⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ousterspendent.cpp

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//////////////////////////////////////////////////////////////////////////////// Filename    : OustersPendent.cpp// Written By  : Elca// Description : //////////////////////////////////////////////////////////////////////////////#include "OustersPendent.h"#include "DB.h"#include "Slayer.h"#include "Vampire.h"#include "Ousters.h"#include "Belt.h"#include "Motorcycle.h"#include "ItemInfoManager.h"#include "Stash.h"#include "ItemUtil.h"// global variable declarationOustersPendentInfoManager* g_pOustersPendentInfoManager = NULL;ItemID_t OustersPendent::m_ItemIDRegistry = 0;Mutex    OustersPendent::m_Mutex;//--------------------------------------------------------------------------------// constructor//--------------------------------------------------------------------------------OustersPendent::OustersPendent()	throw()//: m_ItemType(0), m_Durability(0){	setItemType(0);	setDurability(0);	m_EnchantLevel = 0;}OustersPendent::OustersPendent(ItemType_t itemType, const list<OptionType_t>& optionType)	throw()//: m_ItemType(itemType), m_OptionType(optionType), m_Durability(0){	setItemType(itemType);	setOptionType(optionType);	m_EnchantLevel = 0;	setDurability(computeMaxDurability(this));	if (!g_pItemInfoManager->isPossibleItem(getItemClass(), getItemType(), getOptionTypeList()))	{		filelog("itembug.log", "OustersPendent::OustersPendent() : Invalid item type or option type");		throw ("OustersPendent::OustersPendent() : Invalid item type or optionType");	}}//--------------------------------------------------------------------------------// create item//--------------------------------------------------------------------------------void OustersPendent::create(const string & ownerID, Storage storage, StorageID_t storageID, BYTE x, BYTE y, ItemID_t itemID) 	throw(Error){	__BEGIN_TRY	Statement* pStmt;	if (itemID==0)	{		__ENTER_CRITICAL_SECTION(m_Mutex)		m_ItemIDRegistry += g_pItemInfoManager->getItemIDSuccessor();		m_ItemID = m_ItemIDRegistry;		__LEAVE_CRITICAL_SECTION(m_Mutex)	}	else	{		m_ItemID = itemID;	}		BEGIN_DB 	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();		StringStream sql;		string optionField;		setOptionTypeToField( getOptionTypeList(), optionField );		sql << "INSERT INTO OustersPendentObject "			<< "(ItemID,  ObjectID, ItemType, OwnerID, Storage, StorageID ,"			<< " X, Y, OptionType, Durability, Grade, ItemFlag)"			<< " VALUES(" 			<< m_ItemID << ", "			<< m_ObjectID << ", " << getItemType() << ", '" << ownerID << "', " <<(int)storage << ", " << storageID << ", " 			<<(int)x << ", " <<(int)y << ", '" << optionField.c_str() << "', " << getDurability() << ", " << getGrade() << ", " << (int)m_CreateType << ")";		pStmt->executeQuery(sql.toString());		SAFE_DELETE(pStmt);	}	END_DB(pStmt)	__END_CATCH}//--------------------------------------------------------------------------------// save item//--------------------------------------------------------------------------------void OustersPendent::tinysave(const char* field) const	throw(Error){	__BEGIN_TRY	Statement* pStmt = NULL;	BEGIN_DB	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();		pStmt->executeQuery( "UPDATE OustersPendentObject SET %s WHERE ItemID=%ld",								field, m_ItemID);		SAFE_DELETE(pStmt);	}	END_DB(pStmt)		__END_CATCH}//--------------------------------------------------------------------------------// save item//--------------------------------------------------------------------------------void OustersPendent::save(const string & ownerID, Storage storage, StorageID_t storageID, BYTE x, BYTE y) 	throw(Error){	__BEGIN_TRY	Statement* pStmt;	BEGIN_DB 	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();		/*		StringStream sql;		sql << "UPDATE OustersPendentObject SET "			<< "ObjectID = " << m_ObjectID			<< ",ItemType = " << m_ItemType			<< ",OwnerID = '" << ownerID << "'"			<< ",Storage = " <<(int)storage			<< ",StorageID = " << storageID			<< ",X = " <<(int)x			<< ",Y = " <<(int)y			<< ",OptionType = " <<(int)m_OptionType			<< ",Durability = " << m_Durability			<< ",EnchantLevel = " <<(int)m_EnchantLevel			<< " WHERE ItemID = " << m_ItemID;		pStmt->executeQuery(sql.toString());		*/		string optionField;		setOptionTypeToField( getOptionTypeList(), optionField );		pStmt->executeQuery( "UPDATE OustersPendentObject SET ObjectID=%ld, ItemType=%d, OwnerID='%s', Storage=%d, StorageID=%ld, X=%d, Y=%d, OptionType='%s', Durability=%d, Grade=%d, EnchantLevel=%d WHERE ItemID=%ld",								m_ObjectID, getItemType(), ownerID.c_str(), (int)storage, storageID, (int)x, (int)y, optionField.c_str(), getDurability(), getGrade(), (int)m_EnchantLevel, m_ItemID );		SAFE_DELETE(pStmt);	}	END_DB(pStmt)		__END_CATCH}//--------------------------------------------------------------------------------// get debug string//--------------------------------------------------------------------------------string OustersPendent::toString() const 	throw(){	StringStream msg;	msg << "OustersPendent("		<< "ItemID:"        << m_ItemID		<< ",ItemType:"     <<(int)getItemType()		<< ",OptionType:"   <<getOptionTypeToString(getOptionTypeList()).c_str()		<< ",Durability:"   <<(int)getDurability()		<< ",EnchantLevel:" <<(int)m_EnchantLevel		<< ")";	return msg.toString();}/*//--------------------------------------------------------------------------------// get width//--------------------------------------------------------------------------------VolumeWidth_t OustersPendent::getVolumeWidth() const 	throw(Error){	__BEGIN_TRY	return g_pOustersPendentInfoManager->getItemInfo(m_ItemType)->getVolumeWidth();	__END_CATCH}	//--------------------------------------------------------------------------------// get height//--------------------------------------------------------------------------------VolumeHeight_t OustersPendent::getVolumeHeight() const 	throw(Error){	__BEGIN_TRY	return g_pOustersPendentInfoManager->getItemInfo(m_ItemType)->getVolumeHeight();	__END_CATCH}	//--------------------------------------------------------------------------------// get weight//--------------------------------------------------------------------------------Weight_t OustersPendent::getWeight() const 	throw(Error){	__BEGIN_TRY	return g_pOustersPendentInfoManager->getItemInfo(m_ItemType)->getWeight();	__END_CATCH}//--------------------------------------------------------------------------------// get/set armor's Defense Bonus//--------------------------------------------------------------------------------Defense_t OustersPendent::getDefenseBonus() const 	throw(Error){	__BEGIN_TRY	return g_pOustersPendentInfoManager->getItemInfo(m_ItemType)->getDefenseBonus();	__END_CATCH}Protection_t OustersPendent::getProtectionBonus() const	throw(Error){	__BEGIN_TRY	return g_pOustersPendentInfoManager->getItemInfo(m_ItemType)->getProtectionBonus();		__END_CATCH}*///--------------------------------------------------------------------------------// get debug string//--------------------------------------------------------------------------------string OustersPendentInfo::toString() const 	throw(){	StringStream msg;	msg << "OustersPendentInfo("		<< "ItemType:" << m_ItemType		<< ",Name:" << m_Name		<< ",EName:" << m_EName		<< ",Price:" << m_Price		<< ",VolumeType:" << Volume2String[m_VolumeType]		<< ",Weight:" << m_Weight		<< ",Description:" << m_Description		<< ",Durability:" << m_Durability		<< ",DefenseBonus:" << m_DefenseBonus		<< ")";	return msg.toString();}//--------------------------------------------------------------------------------// load from DB//--------------------------------------------------------------------------------void OustersPendentInfoManager::load() 	throw(Error){	__BEGIN_TRY	Statement* pStmt;	BEGIN_DB 	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();        Result* pResult = pStmt->executeQuery("SELECT MAX(ItemType) FROM OustersPendentInfo");        pResult->next();        m_InfoCount = pResult->getInt(1);        m_pItemInfos = new ItemInfo*[m_InfoCount+1];        for (uint i = 0 ; i <= m_InfoCount ; i ++)            m_pItemInfos[i] = NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -