📄 ring.cpp
字号:
for (uint i = 0 ; i <= m_InfoCount ; i ++) m_pItemInfos[i] = NULL; pResult = pStmt->executeQuery( "SELECT ItemType, Name, EName, Price, Volume, Weight, Ratio, Durability, Defense, Protection, ReqAbility, ItemLevel, DefaultOption, UpgradeRatio, UpgradeCrashPercent, NextOptionRatio, NextItemType, DowngradeRatio FROM RingInfo" ); while (pResult->next()) { uint i = 0; RingInfo* pRingInfo = new RingInfo(); pRingInfo->setItemType(pResult->getInt(++i)); pRingInfo->setName(pResult->getString(++i)); pRingInfo->setEName(pResult->getString(++i)); pRingInfo->setPrice(pResult->getInt(++i)); pRingInfo->setVolumeType(pResult->getInt(++i)); pRingInfo->setWeight(pResult->getInt(++i)); pRingInfo->setRatio(pResult->getInt(++i)); pRingInfo->setDurability(pResult->getInt(++i)); pRingInfo->setDefenseBonus(pResult->getInt(++i)); pRingInfo->setProtectionBonus(pResult->getInt(++i)); pRingInfo->setReqAbility(pResult->getString(++i)); pRingInfo->setItemLevel(pResult->getInt(++i)); pRingInfo->setDefaultOptions(pResult->getString(++i)); pRingInfo->setUpgradeRatio(pResult->getInt(++i)); pRingInfo->setUpgradeCrashPercent(pResult->getInt(++i)); pRingInfo->setNextOptionRatio(pResult->getInt(++i)); pRingInfo->setNextItemType(pResult->getInt(++i)); pRingInfo->setDowngradeRatio(pResult->getInt(++i)); addItemInfo(pRingInfo); } SAFE_DELETE(pStmt); } END_DB(pStmt) __END_CATCH}//--------------------------------------------------------------------------------// load to creature//--------------------------------------------------------------------------------void RingLoader::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 FROM RingObject" << " 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, Grade, EnchantLevel, ItemFlag FROM RingObject WHERE OwnerID = '%s' AND Storage IN(0, 1, 2, 3, 4, 9)", pCreature->getName().c_str() ); while (pResult->next()) { try { uint i = 0; Ring* pRing = new Ring(); pRing->setItemID(pResult->getDWORD(++i)); pRing->setObjectID(pResult->getDWORD(++i)); pRing->setItemType(pResult->getDWORD(++i)); if (g_pRingInfoManager->getItemInfo(pRing->getItemType())->isUnique()) pRing->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); pRing->setOptionType(optionTypes); pRing->setDurability(pResult->getInt(++i)); pRing->setGrade(pResult->getInt(++i)); pRing->setEnchantLevel(pResult->getInt(++i)); pRing->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, pRing)) { pInventory->addItemEx(x, y, pRing); } else { processItemBugEx(pCreature, pRing); } break; case STORAGE_GEAR: if (pCreature->isSlayer()) { if (!pSlayer->isWear((Slayer::WearPart)x)) { pSlayer->wearItem((Slayer::WearPart)x, pRing); } else { processItemBugEx(pCreature, pRing); } } else if (pCreature->isVampire()) { processItemBugEx(pCreature, pRing); } break; case STORAGE_BELT : processItemBugEx(pCreature, pRing); break; case STORAGE_EXTRASLOT : if (pCreature->isSlayer()) pSlayer->addItemToExtraInventorySlot(pRing); else if (pCreature->isVampire()) pVampire->addItemToExtraInventorySlot(pRing); break; case STORAGE_MOTORCYCLE: processItemBugEx(pCreature, pRing); break; case STORAGE_STASH: if (pStash->isExist(x, y)) { processItemBugEx(pCreature, pRing); } else pStash->insert(x, y, pRing); break; case STORAGE_GARBAGE: processItemBug(pCreature, pRing); 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 RingLoader::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, ItemFlag FROM RingObject" << " WHERE Storage = " <<(int)STORAGE_ZONE << " AND StorageID = " << pZone->getZoneID(); Result* pResult = pStmt->executeQuery(sql.toString()); while (pResult->next()) { uint i = 0; Ring* pRing = new Ring(); pRing->setItemID(pResult->getInt(++i)); pRing->setObjectID(pResult->getInt(++i)); pRing->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); pRing->setOptionType(optionTypes); pRing->setDurability(pResult->getInt(++i)); pRing->setEnchantLevel(pResult->getInt(++i)); pRing->setCreateType((Item::CreateType)pResult->getInt(++i)); switch(storage) { case STORAGE_ZONE : { Tile & pTile = pZone->getTile(x,y); Assert(!pTile.hasItem()); pTile.addItem(pRing); } 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 RingLoader::load(StorageID_t storageID, Inventory* pInventory) throw(Error){ __BEGIN_TRY Statement* pStmt; BEGIN_DB { } END_DB(pStmt) __END_CATCH}RingLoader* g_pRingLoader = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -