diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Conditions/ConditionMgr.cpp | 75 | ||||
-rwxr-xr-x | src/server/game/Conditions/ConditionMgr.h | 4 | ||||
-rwxr-xr-x | src/server/game/Entities/Item/Item.cpp | 18 | ||||
-rwxr-xr-x | src/server/game/Entities/Item/Item.h | 1 | ||||
-rwxr-xr-x | src/server/game/Handlers/SpellHandler.cpp | 18 |
5 files changed, 8 insertions, 108 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index f52cb96501f..f624328546f 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -203,11 +203,6 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) case CONDITION_AREAID: condMeets = object->GetAreaId() == ConditionValue1; break; - case CONDITION_ITEM_TARGET: - { - condMeets = true; //handled in Item::IsTargetValidForItemUse - break; - } case CONDITION_SPELL: { if (Player* player = object->ToPlayer()) @@ -553,6 +548,9 @@ void ConditionMgr::LoadConditions(bool isReload) if (iConditionTypeOrReference >= 0) cond->ConditionType = ConditionTypes(iConditionTypeOrReference); + if (iSourceTypeOrReferenceId >= 0) + cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId); + if (iConditionTypeOrReference < 0)//it has a reference { if (iConditionTypeOrReference == iSourceTypeOrReferenceId)//self referencing, skip @@ -601,8 +599,6 @@ void ConditionMgr::LoadConditions(bool isReload) continue; }//end of reference templates - cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId); - //if not a reference and SourceType is invalid, skip if (iConditionTypeOrReference >= 0 && !isSourceTypeValid(cond)) { @@ -1092,50 +1088,6 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } break; } - case CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET: - { - if (cond->ConditionType != CONDITION_ITEM_TARGET) - { - sLog->outErrorDb("SourceEntry %u in `condition` table, has ConditionType %u. Only CONDITION_ITEM_TARGET(24) is valid for CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET(18), ignoring.", cond->SourceEntry, uint32(cond->ConditionType)); - return false; - } - - ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry); - if (!pItemProto) - { - sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `item_tamplate`, ignoring.", cond->SourceEntry); - return false; - } - - bool bIsItemSpellValid = false; - for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) - { - if (SpellInfo const* pSpellInfo = sSpellMgr->GetSpellInfo(pItemProto->Spells[i].SpellId)) - { - if (pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE || - pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE) - { - ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_SCRIPT_TARGET, pSpellInfo->Id);//script loading is done before item target loading - if (!conditions.empty()) - break; - - if (pSpellInfo->NeedsExplicitUnitTarget()) - { - bIsItemSpellValid = true; - break; - } - } - } - } - - if (!bIsItemSpellValid) - { - sLog->outErrorDb("Conditions: CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET for item %u, which either doesn't have item spelltrigger or its spells don't allow caster to select a unit target" - ", or the spells are already listed in CONDITION_SOURCE_TYPE_SPELL_SCRIPT_TARGET conditions.", cond->SourceEntry); - break; - } - break; - } case CONDITION_SOURCE_TYPE_QUEST_ACCEPT: if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry)) { @@ -1163,6 +1115,9 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) return false; } break; + case CONDITION_SOURCE_TYPE_UNUSED_18: + sLog->outErrorDb("Found SourceTypeOrReferenceId = CONDITION_SOURCE_TYPE_UNUSED_18 in `condition` table - ignoring"); + return false; case CONDITION_SOURCE_TYPE_GOSSIP_MENU: case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION: case CONDITION_SOURCE_TYPE_SMART_EVENT: @@ -1469,24 +1424,6 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) sLog->outErrorDb("Map condition has useless data in value3 (%u)!", cond->ConditionValue3); break; } - case CONDITION_ITEM_TARGET: - { - if (!cond->ConditionValue1 || cond->ConditionValue1 > MAX_ITEM_REQ_TARGET_TYPE) - { - sLog->outErrorDb("ItemTarget condition has incorrect target type (%u), skipped", cond->ConditionValue1); - return false; - } - - if (!cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2)) - { - sLog->outErrorDb("ItemTarget condition has non existing creature template entry (%u) as target, skipped", cond->ConditionValue2); - return false; - } - - if (cond->ConditionValue3) - sLog->outErrorDb("ItemTarget condition has useless data in value3 (%u)!", cond->ConditionValue3); - break; - } case CONDITION_SPELL: { if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1)) diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index c0bc5635838..e1e4328a3b9 100755 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -54,7 +54,7 @@ enum ConditionTypes CONDITION_TARGET_RANGE = 21, // minDistance maxDist 0 true if target is closer then minDist and further then maxDist or if max is 0 then max dist is infinit CONDITION_MAPID = 22, // map_id 0 0 true if in map_id CONDITION_AREAID = 23, // area_id 0 0 true if in area_id - CONDITION_ITEM_TARGET = 24, // ItemRequiredTargetType, TargetEntry, 0 + CONDITION_UNUSED_24 = 24, // CONDITION_SPELL = 25, // spell_id 0 0 true if player has learned spell CONDITION_PHASEMASK = 26, // phasemask 0 0 true if object is in phasemask CONDITION_LEVEL = 27, // level ComparisonType 0 true if unit's level is equal to param1 (param2 can modify the statement) @@ -92,7 +92,7 @@ enum ConditionSourceType CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION = 15, CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE = 16, CONDITION_SOURCE_TYPE_SPELL = 17, - CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET = 18, + CONDITION_SOURCE_TYPE_UNUSED_18 = 18, CONDITION_SOURCE_TYPE_QUEST_ACCEPT = 19, CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK = 20, CONDITION_SOURCE_TYPE_VEHICLE_SPELL = 21, diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index f303f7bf877..9cac6822b60 100755 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -870,24 +870,6 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const return true; } -bool Item::IsTargetValidForItemUse(Unit* pUnitTarget) -{ - ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET, GetTemplate()->ItemId); - if (conditions.empty()) - return true; - - if (!pUnitTarget) - return false; - - for (ConditionList::const_iterator itr = conditions.begin(); itr != conditions.end(); ++itr) - { - ItemRequiredTarget irt(ItemRequiredTargetType((*itr)->ConditionValue1), (*itr)->ConditionValue2); - if (irt.IsFitToRequirements(pUnitTarget)) - return true; - } - return false; -} - void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges) { // Better lost small time at check in comparison lost time at item save to DB. diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index 0960a3e5563..de5f8220208 100755 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -268,7 +268,6 @@ class Item : public Object uint32 GetEnchantRequiredLevel() const; bool IsFitToSpellRequirements(SpellInfo const* spellInfo) const; - bool IsTargetValidForItemUse(Unit* pUnitTarget); bool IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const; bool GemsFitSockets() const; diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index b8908d0f9f9..9ea0e124112 100755 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -165,24 +165,6 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) targets.Read(recvPacket, pUser); HandleClientCastFlags(recvPacket, castFlags, targets); - if (!pItem->IsTargetValidForItemUse(targets.GetUnitTarget())) - { - // free gray item after use fail - pUser->SendEquipError(EQUIP_ERR_NONE, pItem, NULL); - - // send spell error - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) - { - // for implicit area/coord target spells - if (!targets.GetUnitTarget()) - Spell::SendCastResult(_player, spellInfo, castCount, SPELL_FAILED_NO_VALID_TARGETS); - // for explicit target spells - else - Spell::SendCastResult(_player, spellInfo, castCount, SPELL_FAILED_BAD_TARGETS); - } - return; - } - // Note: If script stop casting it must send appropriate data to client to prevent stuck item in gray state. if (!sScriptMgr->OnItemUse(pUser, pItem, targets)) { |