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

📄 pupa.cpp

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		{			m_MPAmount       =(int)amount;			m_MPDelay        =(int)delay;			m_MPRecoveryUnit =(int)unit;		}	}	__END_CATCH}//--------------------------------------------------------------------------------// get debug string//--------------------------------------------------------------------------------string PupaInfo::toString() const 	throw(){	StringStream msg;	msg << "PupaInfo("		<< "ItemType:"     <<(int)m_ItemType		<< ",Name:"        << m_Name		<< ",EName:"       << m_EName		<< ",Price:"       <<(int)m_Price		<< ",VolumeType:"  << Volume2String[m_VolumeType]		<< ",Weight:"      <<(int)m_Weight		<< ",Description:" << m_Description		<< ",HPAmount:"    <<(int)m_HPAmount		<< ",MPAmount:"    <<(int)m_MPAmount		<< ")";	return msg.toString();}//--------------------------------------------------------------------------------// load from DB//--------------------------------------------------------------------------------void PupaInfoManager::load() 	throw(Error){	__BEGIN_TRY	Statement* pStmt;	BEGIN_DB 	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();        Result* pResult = pStmt->executeQuery("SELECT MAX(ItemType) FROM PupaInfo");        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;        pResult = pStmt->executeQuery(			"SELECT ItemType, Name, EName, Price, Volume, Weight, Ratio, Effect FROM PupaInfo"		);		while (pResult->next()) 		{			uint i = 0;			PupaInfo* pPupaInfo = new PupaInfo();			pPupaInfo->setItemType(pResult->getInt(++i));			pPupaInfo->setName(pResult->getString(++i));			pPupaInfo->setEName(pResult->getString(++i));			pPupaInfo->setPrice(pResult->getInt(++i));			pPupaInfo->setVolumeType(pResult->getInt(++i));			pPupaInfo->setWeight(pResult->getInt(++i));			pPupaInfo->setRatio(pResult->getInt(++i));			pPupaInfo->parseEffect(pResult->getString(++i));			addItemInfo(pPupaInfo);		}				SAFE_DELETE(pStmt);	}	END_DB(pStmt)		__END_CATCH}//--------------------------------------------------------------------------------// load to creature//--------------------------------------------------------------------------------void PupaLoader::load(Creature* pCreature) 	throw(Error){	__BEGIN_TRY	Assert(pCreature != NULL);	Statement* pStmt;	BEGIN_DB 	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();		Result* pResult = pStmt->executeQuery( "SELECT ItemID, ObjectID, ItemType, Storage, StorageID, X, Y, Num FROM PupaObject WHERE OwnerID = '%s' AND Storage IN(0, 1, 2, 3, 4, 9)",												pCreature->getName().c_str() );		while (pResult->next())		{			try {				uint i = 0;				Pupa* pPupa = new Pupa();				pPupa->setItemID(pResult->getDWORD(++i));				pPupa->setObjectID(pResult->getDWORD(++i));				pPupa->setItemType(pResult->getDWORD(++i));				Storage storage =(Storage)pResult->getInt(++i);				StorageID_t storageID = pResult->getDWORD(++i);				BYTE x = pResult->getBYTE(++i);				BYTE y = pResult->getBYTE(++i);				pPupa->setNum(pResult->getBYTE(++i));				Inventory*  pInventory      = NULL;				Slayer*     pSlayer         = NULL;				Vampire*    pVampire        = NULL;				Ousters*    pOusters        = NULL;				Motorcycle* pMotorcycle     = NULL;				Inventory*  pMotorInventory = NULL;				Item*       pItem           = NULL;				Stash*      pStash          = NULL;				Belt*       pBelt           = NULL;				Inventory*  pBeltInventory  = NULL;				OustersArmsband* pOustersArmsband = NULL;				Inventory* pArmsbandInventory = NULL;				if (pCreature->isSlayer())				{					pSlayer     = dynamic_cast<Slayer*>(pCreature);					pInventory  = pSlayer->getInventory();					pStash      = pSlayer->getStash();					pMotorcycle = pSlayer->getMotorcycle();					if (pMotorcycle) pMotorInventory = pMotorcycle->getInventory();				}				else if (pCreature->isVampire()) 				{					pVampire   = dynamic_cast<Vampire*>(pCreature);					pInventory = pVampire->getInventory();					pStash     = pVampire->getStash();				}				else if (pCreature->isOusters()) 				{					pOusters   = dynamic_cast<Ousters*>(pCreature);					pInventory = pOusters->getInventory();					pStash     = pOusters->getStash();				}				else throw UnsupportedError("Monster,NPC 牢亥配府狼 历厘篮 酒流 瘤盔登瘤 臼嚼聪促.");				switch(storage)				{					case STORAGE_INVENTORY:						if (pInventory->canAddingEx(x, y, pPupa))						{							pInventory->addItemEx(x, y, pPupa);						}						else						{							processItemBugEx(pCreature, pPupa);						}						break;					case STORAGE_GEAR:						processItemBugEx(pCreature, pPupa);						break;					case STORAGE_BELT :						if (pCreature->isSlayer())						{							pItem = pSlayer->findBeltIID(storageID);							if (pItem != NULL && pItem->getItemClass() == Item::ITEM_CLASS_BELT)							{								pBelt = dynamic_cast<Belt*>(pItem);								pBeltInventory = pBelt->getInventory();								if (pBeltInventory->canAddingEx(x, 0, pPupa))								{									pBeltInventory->addItem(x, 0, pPupa);								}								else								{									processItemBugEx(pCreature, pPupa);								}							}							else							{								processItemBugEx(pCreature, pPupa);							}						}						else if (pCreature->isVampire())						{							pItem = pVampire->findBeltIID(storageID);							if (pItem != NULL && pItem->getItemClass() == Item::ITEM_CLASS_BELT)							{								pBelt = dynamic_cast<Belt*>(pItem);								pBeltInventory = pBelt->getInventory();								if (pBeltInventory->canAddingEx(x, 0, pPupa))								{									pBeltInventory->addItemEx(x, 0, pPupa);								}								else								{									processItemBugEx(pCreature, pPupa);								}							}							else							{								processItemBugEx(pCreature, pPupa);							}						}						else if (pCreature->isOusters())						{							pItem = findItemIID( pOusters, storageID, Item::ITEM_CLASS_OUSTERS_ARMSBAND );							if (pItem != NULL && pItem->getItemClass() == Item::ITEM_CLASS_OUSTERS_ARMSBAND)							{								pOustersArmsband = dynamic_cast<OustersArmsband*>(pItem);								pArmsbandInventory = pOustersArmsband->getInventory();								if (pArmsbandInventory->canAddingEx(x, 0, pPupa))								{									pArmsbandInventory->addItemEx(x, 0, pPupa);								}								else								{									processItemBugEx(pCreature, pPupa);								}							}							else							{								processItemBugEx(pCreature, pPupa);							}						}						break;					case STORAGE_EXTRASLOT :						if (pCreature->isSlayer())       pSlayer->addItemToExtraInventorySlot(pPupa);						else if (pCreature->isVampire()) pVampire->addItemToExtraInventorySlot(pPupa);						else if (pCreature->isOusters()) pOusters->addItemToExtraInventorySlot(pPupa);						break;					case STORAGE_MOTORCYCLE:						processItemBugEx(pCreature, pPupa);						break;					case STORAGE_STASH:						if (pStash->isExist(x, y))						{							processItemBugEx(pCreature, pPupa);						}						else pStash->insert(x, y, pPupa);						break;					case STORAGE_GARBAGE:						processItemBug(pCreature, pPupa);						break;					default :						SAFE_DELETE(pStmt);	// by sigi						throw Error("invalid storage or OwnerID must be NULL");				}			} catch (Error& error) {				filelog("itemLoadError.txt", "[%s] %s", getItemClassName().c_str(), error.toString().c_str());				throw;			} catch (Throwable& t) {				filelog("itemLoadError.txt", "[%s] %s", getItemClassName().c_str(), t.toString().c_str());			}		}		SAFE_DELETE(pStmt);	}	END_DB(pStmt)		__END_CATCH}//--------------------------------------------------------------------------------// load to zone//--------------------------------------------------------------------------------void PupaLoader::load(Zone* pZone) 	throw(Error){	__BEGIN_TRY	Assert(pZone != NULL);	Statement* pStmt;	BEGIN_DB 	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();		StringStream sql;		sql << "SELECT ItemID, ObjectID, ItemType, Storage, StorageID, X, Y, Num FROM PupaObject"			<< " WHERE Storage = " <<(int)STORAGE_ZONE << " AND StorageID = " << pZone->getZoneID();		Result* pResult = pStmt->executeQuery(sql.toString());		while (pResult->next())		{			uint i = 0;			Pupa* pPupa = new Pupa();			pPupa->setItemID(pResult->getInt(++i));			pPupa->setObjectID(pResult->getInt(++i));			pPupa->setItemType(pResult->getInt(++i));			Storage storage =(Storage)pResult->getInt(++i);			StorageID_t storageID = pResult->getInt(++i);			BYTE x = pResult->getInt(++i);			BYTE y = pResult->getInt(++i);			pPupa->setNum(pResult->getBYTE(++i));			switch(storage)			{				case STORAGE_ZONE :						{						Tile & pTile = pZone->getTile(x,y);						Assert(!pTile.hasItem());						pTile.addItem(pPupa);					}					break;				case STORAGE_STASH :				case STORAGE_CORPSE :					throw UnsupportedError("惑磊 棺 矫眉救狼 酒捞袍狼 历厘篮 酒流 瘤盔登瘤 臼嚼聪促.");				default :					throw Error("Storage must be STORAGE_ZONE");			}		}		SAFE_DELETE(pStmt);	}	END_DB(pStmt)	__END_CATCH}//--------------------------------------------------------------------------------// load to inventory//--------------------------------------------------------------------------------void PupaLoader::load(StorageID_t storageID, Inventory* pInventory) 	throw(Error){	__BEGIN_TRY	Statement* pStmt;	BEGIN_DB 	{	}	END_DB(pStmt)		__END_CATCH}PupaLoader* g_pPupaLoader = NULL;

⌨️ 快捷键说明

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