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

📄 larva.cpp

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		else if (recover == "MP")		{			m_MPAmount       =(int)amount;			m_MPDelay        =(int)delay;			m_MPRecoveryUnit =(int)unit;		}	}	__END_CATCH}//--------------------------------------------------------------------------------// get debug string//--------------------------------------------------------------------------------string LarvaInfo::toString() const 	throw(){	StringStream msg;	msg << "LarvaInfo("		<< "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 LarvaInfoManager::load() 	throw(Error){	__BEGIN_TRY	Statement* pStmt;	BEGIN_DB 	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();        Result* pResult = pStmt->executeQuery("SELECT MAX(ItemType) FROM LarvaInfo");        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 LarvaInfo"		);		while (pResult->next()) 		{			uint i = 0;			LarvaInfo* pLarvaInfo = new LarvaInfo();			pLarvaInfo->setItemType(pResult->getInt(++i));			pLarvaInfo->setName(pResult->getString(++i));			pLarvaInfo->setEName(pResult->getString(++i));			pLarvaInfo->setPrice(pResult->getInt(++i));			pLarvaInfo->setVolumeType(pResult->getInt(++i));			pLarvaInfo->setWeight(pResult->getInt(++i));			pLarvaInfo->setRatio(pResult->getInt(++i));			pLarvaInfo->parseEffect(pResult->getString(++i));			addItemInfo(pLarvaInfo);		}				SAFE_DELETE(pStmt);	}	END_DB(pStmt)		__END_CATCH}//--------------------------------------------------------------------------------// load to creature//--------------------------------------------------------------------------------void LarvaLoader::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 LarvaObject WHERE OwnerID = '%s' AND Storage IN(0, 1, 2, 3, 4, 9)",												pCreature->getName().c_str() );		while (pResult->next())		{			try {				uint i = 0;				Larva* pLarva = new Larva();				pLarva->setItemID(pResult->getDWORD(++i));				pLarva->setObjectID(pResult->getDWORD(++i));				pLarva->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);				pLarva->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;				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, pLarva))						{							pInventory->addItemEx(x, y, pLarva);						}						else						{							processItemBugEx(pCreature, pLarva);						}						break;					case STORAGE_GEAR:						processItemBugEx(pCreature, pLarva);						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, pLarva))								{									pBeltInventory->addItem(x, 0, pLarva);								}								else								{									processItemBugEx(pCreature, pLarva);								}							}							else							{								processItemBugEx(pCreature, pLarva);							}						}						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, pLarva))								{									pBeltInventory->addItemEx(x, 0, pLarva);								}								else								{									processItemBugEx(pCreature, pLarva);								}							}							else							{								processItemBugEx(pCreature, pLarva);							}						}						else if (pCreature->isOusters())						{							pItem = pOusters->findBeltIID(storageID);							if (pItem != NULL && pItem->getItemClass() == Item::ITEM_CLASS_BELT)							{								pBelt = dynamic_cast<Belt*>(pItem);								pBeltInventory = pBelt->getInventory();								if (pBeltInventory->canAddingEx(x, 0, pLarva))								{									pBeltInventory->addItemEx(x, 0, pLarva);								}								else								{									processItemBugEx(pCreature, pLarva);								}							}							else							{								processItemBugEx(pCreature, pLarva);							}						}						break;					case STORAGE_EXTRASLOT :						if (pCreature->isSlayer())       pSlayer->addItemToExtraInventorySlot(pLarva);						else if (pCreature->isVampire()) pVampire->addItemToExtraInventorySlot(pLarva);						else if (pCreature->isOusters()) pOusters->addItemToExtraInventorySlot(pLarva);						break;					case STORAGE_MOTORCYCLE:						processItemBugEx(pCreature, pLarva);						break;					case STORAGE_STASH:						if (pStash->isExist(x, y))						{							processItemBugEx(pCreature, pLarva);						}						else pStash->insert(x, y, pLarva);						break;					case STORAGE_GARBAGE:						processItemBug(pCreature, pLarva);						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 LarvaLoader::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 LarvaObject"			<< " WHERE Storage = " <<(int)STORAGE_ZONE << " AND StorageID = " << pZone->getZoneID();		Result* pResult = pStmt->executeQuery(sql.toString());		while (pResult->next())		{			uint i = 0;			Larva* pLarva = new Larva();			pLarva->setItemID(pResult->getInt(++i));			pLarva->setObjectID(pResult->getInt(++i));			pLarva->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);			pLarva->setNum(pResult->getBYTE(++i));			switch(storage)			{				case STORAGE_ZONE :						{						Tile & pTile = pZone->getTile(x,y);						Assert(!pTile.hasItem());						pTile.addItem(pLarva);					}					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 LarvaLoader::load(StorageID_t storageID, Inventory* pInventory) 	throw(Error){	__BEGIN_TRY	Statement* pStmt;	BEGIN_DB 	{	}	END_DB(pStmt)		__END_CATCH}LarvaLoader* g_pLarvaLoader = NULL;

⌨️ 快捷键说明

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