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

📄 sg.cpp

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	msg << "SGInfo("		<< "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		<< ",minDamage:" << m_MinDamage		<< ",maxDamage:" << m_MaxDamage		<< ",ToHitBonus:" << m_ToHitBonus		<< ",Range:" <<(int)m_Range		<< ",ReqAbility:?"		<< ")";	return msg.toString();}//--------------------------------------------------------------------------------// load from DB//--------------------------------------------------------------------------------void SGInfoManager::load() 	throw(Error){	__BEGIN_TRY	Statement* pStmt;	BEGIN_DB 	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();        Result* pResult = pStmt->executeQuery("SELECT MAX(ItemType) FROM SGInfo");        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, Durability, minDamage, maxDamage, ToHitBonus, Range, Speed, ReqAbility, ItemLevel, CriticalBonus, DefaultOption, UpgradeRatio, UpgradeCrashPercent, NextOptionRatio, NextItemType, DowngradeRatio FROM SGInfo"		);		while (pResult->next()) 		{			uint i = 0;			SGInfo* pSGInfo = new SGInfo();			pSGInfo->setItemType(pResult->getInt(++i));			pSGInfo->setName(pResult->getString(++i));			pSGInfo->setEName(pResult->getString(++i));			pSGInfo->setPrice(pResult->getInt(++i));			pSGInfo->setVolumeType(pResult->getInt(++i));			pSGInfo->setWeight(pResult->getInt(++i));			pSGInfo->setRatio(pResult->getInt(++i));			pSGInfo->setDurability(pResult->getInt(++i));			pSGInfo->setMinDamage(pResult->getInt(++i));			pSGInfo->setMaxDamage(pResult->getInt(++i));			pSGInfo->setToHitBonus(pResult->getInt(++i));			pSGInfo->setRange(pResult->getInt(++i));			pSGInfo->setSpeed(pResult->getInt(++i));			pSGInfo->setReqAbility(pResult->getString(++i));			pSGInfo->setItemLevel(pResult->getInt(++i));			pSGInfo->setCriticalBonus(pResult->getInt(++i));			pSGInfo->setDefaultOptions(pResult->getString(++i));			pSGInfo->setUpgradeRatio(pResult->getInt(++i));			pSGInfo->setUpgradeCrashPercent(pResult->getInt(++i));			pSGInfo->setNextOptionRatio(pResult->getInt(++i));			pSGInfo->setNextItemType(pResult->getInt(++i));			pSGInfo->setDowngradeRatio(pResult->getInt(++i));			addItemInfo(pSGInfo);		}				SAFE_DELETE(pStmt);	}	END_DB(pStmt)		__END_CATCH}//--------------------------------------------------------------------------------// load to creature//--------------------------------------------------------------------------------void SGLoader::load(Creature* pCreature) 	throw(Error){	__BEGIN_TRY	Assert(pCreature != NULL);	Statement* pStmt;	BEGIN_DB 	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();		/*		StringStream sql;		sql << "SELECT ItemID, ObjectID, ItemType, Storage, StorageID, X, Y,"			<< "OptionType, Durability, EnchantLevel, BulletCount, Silver FROM SGObject"			<< " WHERE OwnerID = '" << pCreature->getName() << "' AND Storage IN("			<<(int)STORAGE_INVENTORY << ", " <<(int)STORAGE_GEAR << ", " <<(int)STORAGE_BELT << ", " 			<<(int)STORAGE_EXTRASLOT << ", " <<(int)STORAGE_MOTORCYCLE << ", " <<(int)STORAGE_STASH << ", " 			<<(int)STORAGE_GARBAGE << ")";		Result* pResult = pStmt->executeQuery(sql.toString());		*/		Result* pResult = pStmt->executeQuery( "SELECT ItemID, ObjectID, ItemType, Storage, StorageID, X, Y,OptionType, Durability, EnchantLevel, BulletCount, Silver, Grade, ItemFlag FROM SGObject WHERE OwnerID = '%s' AND Storage IN(0, 1, 2, 3, 4, 9)",								pCreature->getName().c_str() );		while (pResult->next())		{			try {				uint i = 0;				SG* pSG = new SG();				pSG->setItemID(pResult->getDWORD(++i));				pSG->setObjectID(pResult->getDWORD(++i));				pSG->setItemType(pResult->getDWORD(++i));					if (g_pSGInfoManager->getItemInfo(pSG->getItemType())->isUnique())					pSG->setUnique();				Storage storage =(Storage)pResult->getInt(++i);				StorageID_t storageID = pResult->getDWORD(++i);				BYTE x = pResult->getBYTE(++i);				BYTE y = pResult->getBYTE(++i);				string optionField = pResult->getString(++i);				list<OptionType_t> optionTypes;				setOptionTypeFromField(optionTypes, optionField);				pSG->setOptionType(optionTypes);				pSG->setDurability(pResult->getInt(++i));				pSG->setEnchantLevel(pResult->getInt(++i));				pSG->setBulletCount(pResult->getInt(++i));				pSG->setSilver(pResult->getInt(++i));				pSG->setGrade(pResult->getInt(++i));				pSG->setCreateType((Item::CreateType)pResult->getInt(++i));				Inventory*  pInventory      = NULL;				Slayer*     pSlayer         = NULL;				Vampire*    pVampire        = 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 throw UnsupportedError("Monster,NPC 牢亥配府狼 历厘篮 酒流 瘤盔登瘤 臼嚼聪促.");				switch(storage)				{					case STORAGE_INVENTORY:						if (pInventory->canAddingEx(x, y, pSG))						{							pInventory->addItemEx(x, y, pSG);						}						else						{							processItemBugEx(pCreature, pSG);						}						break;					case STORAGE_GEAR:						if (pCreature->isSlayer())						{							if (!pSlayer->isWear((Slayer::WearPart)x))							{								pSlayer->wearItem((Slayer::WearPart)x, pSG);							}							else							{								processItemBugEx(pCreature, pSG);							}						}						else if (pCreature->isVampire())						{							processItemBugEx(pCreature, pSG);						}						break;					case STORAGE_BELT :						processItemBugEx(pCreature, pSG);						break;					case STORAGE_EXTRASLOT :						if (pCreature->isSlayer())       pSlayer->addItemToExtraInventorySlot(pSG);						else if (pCreature->isVampire()) pVampire->addItemToExtraInventorySlot(pSG);						break;					case STORAGE_MOTORCYCLE:						processItemBugEx(pCreature, pSG);						break;					case STORAGE_STASH:						if (pStash->isExist(x, y))						{							processItemBugEx(pCreature, pSG);						}						else pStash->insert(x, y, pSG);						break;					case STORAGE_GARBAGE:						processItemBug(pCreature, pSG);						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 SGLoader::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,"			<< " OptionType, Durability, EnchantLevel, BulletCount, Silver, ItemFlag FROM SGObject"			<< " WHERE Storage = " <<(int)STORAGE_ZONE << " AND StorageID = " << pZone->getZoneID();		Result* pResult = pStmt->executeQuery(sql.toString());		while (pResult->next())		{			uint i = 0;			SG* pSG = new SG();			pSG->setItemID(pResult->getInt(++i));			pSG->setObjectID(pResult->getInt(++i));			pSG->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);			string optionField = pResult->getString(++i);			list<OptionType_t> optionTypes;			setOptionTypeFromField(optionTypes, optionField);			pSG->setOptionType(optionTypes);			pSG->setDurability(pResult->getInt(++i));			pSG->setEnchantLevel(pResult->getInt(++i));			pSG->setBulletCount(pResult->getInt(++i));			pSG->setSilver(pResult->getInt(++i));			pSG->setCreateType((Item::CreateType)pResult->getInt(++i));			switch(storage)			{				case STORAGE_ZONE :						{						Tile & pTile = pZone->getTile(x,y);						Assert(!pTile.hasItem());						pTile.addItem(pSG);					}					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 SGLoader::load(StorageID_t storageID, Inventory* pInventory) 	throw(Error){	__BEGIN_TRY	Statement* pStmt;	BEGIN_DB 	{	}	END_DB(pStmt)		__END_CATCH}SGLoader* g_pSGLoader = NULL;

⌨️ 快捷键说明

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