diff options
20 files changed, 133 insertions, 122 deletions
diff --git a/src/server/game/Achievements/CriteriaHandler.cpp b/src/server/game/Achievements/CriteriaHandler.cpp index 02576edbd5c..bf5988b1ce0 100644 --- a/src/server/game/Achievements/CriteriaHandler.cpp +++ b/src/server/game/Achievements/CriteriaHandler.cpp @@ -1698,8 +1698,7 @@ bool CriteriaHandler::ModifierSatisfied(ModifierTreeEntry const* modifier, uint6 } case ModifierTreeType::PlayerMeetsCondition: // 2 { - PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(reqValue); - if (!playerCondition || !ConditionMgr::IsPlayerMeetingCondition(referencePlayer, playerCondition)) + if (!ConditionMgr::IsPlayerMeetingCondition(referencePlayer, reqValue)) return false; break; } @@ -1963,8 +1962,7 @@ bool CriteriaHandler::ModifierSatisfied(ModifierTreeEntry const* modifier, uint6 if (!ref || !ref->IsPlayer()) return false; - PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(reqValue); - if (!playerCondition || !ConditionMgr::IsPlayerMeetingCondition(ref->ToPlayer(), playerCondition)) + if (!ConditionMgr::IsPlayerMeetingCondition(ref->ToPlayer(), reqValue)) return false; break; } diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 4dd0aeec1e5..0f0180a7301 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -92,7 +92,8 @@ char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX_D "AreaTrigger Client Triggered", "Trainer Spell", "Object Visibility (by ID)", - "Spawn Group" + "Spawn Group", + "Player Condition" }; ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] = @@ -657,8 +658,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) const case CONDITION_PLAYER_CONDITION: { if (Player const* player = object->ToPlayer()) - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(ConditionValue1)) - condMeets = ConditionMgr::IsPlayerMeetingCondition(player, playerCondition); + condMeets = ConditionMgr::IsPlayerMeetingCondition(player, ConditionValue1); break; } case CONDITION_PRIVATE_OBJECT: @@ -1444,6 +1444,40 @@ void ConditionMgr::LoadConditions(bool isReload) for (auto&& [id, conditions] : ConditionStore[CONDITION_SOURCE_TYPE_GRAVEYARD]) addToGraveyardData(id, conditions); + struct + { + bool operator()(uint32 playerConditionId, std::vector<Condition> const& conditions, ConditionsByEntryMap const& referenceConditions) const + { + return std::any_of(conditions.begin(), conditions.end(), [&](Condition const& condition) + { + if (condition.ConditionType == CONDITION_PLAYER_CONDITION) + { + if (condition.ConditionValue1 == playerConditionId) + return true; + } + else if (condition.ReferenceId) + { + auto refItr = referenceConditions.find({ condition.ReferenceId, 0, 0 }); + if (refItr != referenceConditions.end()) + if (operator()(playerConditionId, *refItr->second, referenceConditions)) + return true; + } + return false; + }); + } + } isPlayerConditionIdUsedByCondition; + + for (auto&& [id, conditions] : ConditionStore[CONDITION_SOURCE_TYPE_PLAYER_CONDITION]) + { + if (isPlayerConditionIdUsedByCondition(id.SourceEntry, *conditions, ConditionStore[CONDITION_SOURCE_TYPE_REFERENCE_CONDITION])) + { + TC_LOG_ERROR("sql.sql", "[Condition SourceType: CONDITION_SOURCE_TYPE_PLAYER_CONDITION, SourceGroup: {}, SourceEntry: {}, SourceId: {}] " + "has a circular reference to player condition id {}, removed all conditions for this SourceEntry!", + id.SourceGroup, id.SourceEntry, id.SourceId, id.SourceEntry); + conditions->clear(); + } + } + TC_LOG_INFO("server.loading", ">> Loaded {} conditions in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); } @@ -2028,10 +2062,6 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const } break; } - case CONDITION_SOURCE_TYPE_GOSSIP_MENU: - case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION: - case CONDITION_SOURCE_TYPE_SMART_EVENT: - break; case CONDITION_SOURCE_TYPE_GRAVEYARD: if (!sObjectMgr->FindGraveyardData(cond->SourceEntry, cond->SourceGroup)) { @@ -2125,6 +2155,11 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const } break; } + case CONDITION_SOURCE_TYPE_GOSSIP_MENU: + case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION: + case CONDITION_SOURCE_TYPE_SMART_EVENT: + case CONDITION_SOURCE_TYPE_PLAYER_CONDITION: + break; default: TC_LOG_ERROR("sql.sql", "{} Invalid ConditionSourceType in `condition` table, ignoring.", cond->ToString()); return false; @@ -2822,6 +2857,20 @@ uint32 ConditionMgr::GetPlayerConditionLfgValue(Player const* player, PlayerCond return 0; } +bool ConditionMgr::IsPlayerMeetingCondition(Player const* player, uint32 conditionId) +{ + if (!conditionId) + return true; + + if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_PLAYER_CONDITION, conditionId, player)) + return false; + + if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(conditionId)) + return IsPlayerMeetingCondition(player, playerCondition); + + return true; +} + bool ConditionMgr::IsPlayerMeetingCondition(Player const* player, PlayerConditionEntry const* condition) { if (!condition->RaceMask.IsEmpty() && !condition->RaceMask.HasRace(player->GetRace())) diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 1eb24ca1b92..f28c9771aca 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -185,6 +185,7 @@ enum ConditionSourceType CONDITION_SOURCE_TYPE_TRAINER_SPELL = 31, CONDITION_SOURCE_TYPE_OBJECT_ID_VISIBILITY = 32, CONDITION_SOURCE_TYPE_SPAWN_GROUP = 33, + CONDITION_SOURCE_TYPE_PLAYER_CONDITION = 34, CONDITION_SOURCE_TYPE_MAX_DB_ALLOWED, CONDITION_SOURCE_TYPE_REFERENCE_CONDITION = CONDITION_SOURCE_TYPE_MAX_DB_ALLOWED, // internal, not set in db @@ -327,6 +328,7 @@ class TC_GAME_API ConditionMgr bool IsObjectMeetingVisibilityByObjectIdConditions(uint32 objectType, uint32 entry, WorldObject const* seer) const; static uint32 GetPlayerConditionLfgValue(Player const* player, PlayerConditionLfgStatus status); + static bool IsPlayerMeetingCondition(Player const* player, uint32 conditionId); static bool IsPlayerMeetingCondition(Player const* player, PlayerConditionEntry const* condition); static bool IsMeetingWorldStateExpression(Map const* map, WorldStateExpressionEntry const* expression); static bool IsUnitMeetingCondition(Unit const* unit, Unit const* otherUnit, UnitConditionEntry const* condition); diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index ad775307b47..ec3b687283e 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -2228,7 +2228,7 @@ bool GameObject::CanActivateForPlayer(Player const* target) const if (!MeetsInteractCondition(target)) return false; - if (sObjectMgr->IsGameObjectForQuests(GetEntry()) && !ActivateToQuest(target)) + if (!ActivateToQuest(target)) return false; return true; @@ -2240,7 +2240,7 @@ bool GameObject::ActivateToQuest(Player const* target) const return true; if (!sObjectMgr->IsGameObjectForQuests(GetEntry())) - return false; + return true; switch (GetGoType()) { @@ -3321,9 +3321,9 @@ void GameObject::Use(Unit* user) return; Player* player = user->ToPlayer(); - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(info->itemForge.conditionID1)) - if (!sConditionMgr->IsPlayerMeetingCondition(player, playerCondition)) - return; + + if (!MeetsInteractCondition(player)) + return; switch (info->itemForge.ForgeType) { @@ -4431,14 +4431,7 @@ GuidUnorderedSet const* GameObject::GetInsidePlayers() const bool GameObject::MeetsInteractCondition(Player const* user) const { - if (!m_goInfo->GetConditionID1()) - return true; - - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(m_goInfo->GetConditionID1())) - if (!ConditionMgr::IsPlayerMeetingCondition(user, playerCondition)) - return false; - - return true; + return ConditionMgr::IsPlayerMeetingCondition(user, m_goInfo->GetConditionID1()); } std::unordered_map<ObjectGuid, GameObject::PerPlayerState>& GameObject::GetOrCreatePerPlayerStates() diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 89b950bb54a..42e16152695 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -401,9 +401,8 @@ bool Item::Create(ObjectGuid::LowType guidlow, uint32 itemId, ItemContext contex if (itemProto->GetArtifactID() != artifactAppearanceSet->ArtifactID) continue; - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(artifactAppearance->UnlockPlayerConditionID)) - if (!owner || !sConditionMgr->IsPlayerMeetingCondition(owner, playerCondition)) - continue; + if (!owner || !ConditionMgr::IsPlayerMeetingCondition(owner, artifactAppearance->UnlockPlayerConditionID)) + continue; SetModifier(ITEM_MODIFIER_ARTIFACT_APPEARANCE_ID, artifactAppearance->ID); SetAppearanceModId(artifactAppearance->ItemAppearanceModifierID); @@ -934,13 +933,10 @@ void Item::LoadArtifactData(Player const* owner, uint64 xp, uint32 artifactAppea case ITEM_ENCHANTMENT_TYPE_ARTIFACT_POWER_BONUS_RANK_PICKER: if (_bonusData.GemRelicType[e - SOCK_ENCHANTMENT_SLOT] != -1) { - if (ArtifactPowerPickerEntry const* artifactPowerPicker = sArtifactPowerPickerStore.LookupEntry(enchant->EffectArg[i])) - { - PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(artifactPowerPicker->PlayerConditionID); - if (!playerCondition || (owner && sConditionMgr->IsPlayerMeetingCondition(owner, playerCondition))) - if (artifactPower->Label == _bonusData.GemRelicType[e - SOCK_ENCHANTMENT_SLOT]) - power.CurrentRankWithBonus += enchant->EffectPointsMin[i]; - } + ArtifactPowerPickerEntry const* artifactPowerPicker = sArtifactPowerPickerStore.LookupEntry(enchant->EffectArg[i]); + if (artifactPowerPicker && owner && ConditionMgr::IsPlayerMeetingCondition(owner, artifactPowerPicker->PlayerConditionID)) + if (artifactPower->Label == _bonusData.GemRelicType[e - SOCK_ENCHANTMENT_SLOT]) + power.CurrentRankWithBonus += enchant->EffectPointsMin[i]; } break; default: @@ -2607,8 +2603,7 @@ void Item::ApplyArtifactPowerEnchantmentBonuses(EnchantmentSlot slot, uint32 enc { if (ArtifactPowerPickerEntry const* artifactPowerPicker = sArtifactPowerPickerStore.LookupEntry(enchant->EffectArg[i])) { - PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(artifactPowerPicker->PlayerConditionID); - if (!playerCondition || sConditionMgr->IsPlayerMeetingCondition(owner, playerCondition)) + if (ConditionMgr::IsPlayerMeetingCondition(owner, artifactPowerPicker->PlayerConditionID)) { for (uint32 artifactPowerIndex = 0; artifactPowerIndex < m_itemData->ArtifactPowers.size(); ++artifactPowerIndex) { diff --git a/src/server/game/Entities/Item/ItemBonusMgr.cpp b/src/server/game/Entities/Item/ItemBonusMgr.cpp index 478b7be0826..7d743604455 100644 --- a/src/server/game/Entities/Item/ItemBonusMgr.cpp +++ b/src/server/game/Entities/Item/ItemBonusMgr.cpp @@ -94,8 +94,7 @@ ItemContext GetContextForPlayer(MapDifficultyEntry const* mapDifficulty, Player bool meetsPlayerCondition = false; if (player) - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(itemContextPickerEntry->PlayerConditionID)) - meetsPlayerCondition = ConditionMgr::IsPlayerMeetingCondition(player, playerCondition); + meetsPlayerCondition = ConditionMgr::IsPlayerMeetingCondition(player, itemContextPickerEntry->PlayerConditionID); if (itemContextPickerEntry->Flags & 0x1) meetsPlayerCondition = !meetsPlayerCondition; diff --git a/src/server/game/Entities/Object/Updates/ViewerDependentValues.h b/src/server/game/Entities/Object/Updates/ViewerDependentValues.h index 8c7c5c22580..c89b74cafdf 100644 --- a/src/server/game/Entities/Object/Updates/ViewerDependentValues.h +++ b/src/server/game/Entities/Object/Updates/ViewerDependentValues.h @@ -90,15 +90,27 @@ public: uint16 pathProgress = 0xFFFF; switch (gameObject->GetGoType()) { + case GAMEOBJECT_TYPE_BUTTON: + case GAMEOBJECT_TYPE_GOOBER: + if (gameObject->GetGOInfo()->GetQuestID() || gameObject->GetGOInfo()->GetConditionID1()) + { + if (gameObject->CanActivateForPlayer(receiver)) + { + dynFlags |= GO_DYNFLAG_LO_HIGHLIGHT; + if (gameObject->GetGoStateFor(receiver->GetGUID()) != GO_STATE_ACTIVE) + dynFlags |= GO_DYNFLAG_LO_ACTIVATE; + } + } + break; case GAMEOBJECT_TYPE_QUESTGIVER: - if (gameObject->ActivateToQuest(receiver)) + if (gameObject->CanActivateForPlayer(receiver)) dynFlags |= GO_DYNFLAG_LO_ACTIVATE; break; case GAMEOBJECT_TYPE_CHEST: - if (gameObject->ActivateToQuest(receiver)) + if (gameObject->CanActivateForPlayer(receiver)) dynFlags |= GO_DYNFLAG_LO_ACTIVATE | GO_DYNFLAG_LO_SPARKLE | GO_DYNFLAG_LO_HIGHLIGHT; else if (receiver->IsGameMaster()) - dynFlags |= GO_DYNFLAG_LO_ACTIVATE; + dynFlags |= GO_DYNFLAG_LO_ACTIVATE | GO_DYNFLAG_LO_SPARKLE; break; case GAMEOBJECT_TYPE_GENERIC: case GAMEOBJECT_TYPE_SPELL_FOCUS: @@ -106,16 +118,6 @@ public: if (gameObject->CanActivateForPlayer(receiver)) dynFlags |= GO_DYNFLAG_LO_SPARKLE | GO_DYNFLAG_LO_HIGHLIGHT; break; - case GAMEOBJECT_TYPE_GOOBER: - if (gameObject->ActivateToQuest(receiver)) - { - dynFlags |= GO_DYNFLAG_LO_HIGHLIGHT; - if (gameObject->GetGoStateFor(receiver->GetGUID()) != GO_STATE_ACTIVE) - dynFlags |= GO_DYNFLAG_LO_ACTIVATE; - } - else if (receiver->IsGameMaster()) - dynFlags |= GO_DYNFLAG_LO_ACTIVATE; - break; case GAMEOBJECT_TYPE_TRANSPORT: case GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT: { @@ -130,7 +132,7 @@ public: dynFlags &= ~GO_DYNFLAG_LO_NO_INTERACT; break; case GAMEOBJECT_TYPE_GATHERING_NODE: - if (gameObject->ActivateToQuest(receiver)) + if (gameObject->CanActivateForPlayer(receiver)) dynFlags |= GO_DYNFLAG_LO_ACTIVATE | GO_DYNFLAG_LO_SPARKLE | GO_DYNFLAG_LO_HIGHLIGHT; if (gameObject->GetGoStateFor(receiver->GetGUID()) == GO_STATE_ACTIVE) dynFlags |= GO_DYNFLAG_LO_DEPLETED; diff --git a/src/server/game/Entities/Player/CollectionMgr.cpp b/src/server/game/Entities/Player/CollectionMgr.cpp index 2089afdcb86..e54e0b88d05 100644 --- a/src/server/game/Entities/Player/CollectionMgr.cpp +++ b/src/server/game/Entities/Player/CollectionMgr.cpp @@ -391,12 +391,8 @@ bool CollectionMgr::AddMount(uint32 spellId, MountStatusFlags flags, bool factio _mounts.insert(MountContainer::value_type(spellId, flags)); // Mount condition only applies to using it, should still learn it. - if (mount->PlayerConditionID) - { - PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(mount->PlayerConditionID); - if (playerCondition && !ConditionMgr::IsPlayerMeetingCondition(player, playerCondition)) - return false; - } + if (!ConditionMgr::IsPlayerMeetingCondition(player, mount->PlayerConditionID)) + return false; if (!learned) { diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5b8c848c95d..49ce1431de5 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -6928,10 +6928,8 @@ void Player::SendCurrencies() const continue; // Check award condition - if (currency->AwardConditionID) - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(currency->AwardConditionID)) - if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition)) - continue; + if (!ConditionMgr::IsPlayerMeetingCondition(this, currency->AwardConditionID)) + continue; WorldPackets::Misc::SetupCurrency::Record record; record.Type = currency->ID; @@ -6997,10 +6995,8 @@ void Player::ModifyCurrency(uint32 id, int32 amount, CurrencyGainSource gainSour return; // Check award condition - if (currency->AwardConditionID) - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(currency->AwardConditionID)) - if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition)) - return; + if (!ConditionMgr::IsPlayerMeetingCondition(this, currency->AwardConditionID)) + return; bool isGainOnRefund = [&]() -> bool { @@ -8038,7 +8034,7 @@ void Player::_ApplyWeaponDamage(uint8 slot, Item* item, bool apply) // { // float average = extraDPS * proto->GetDelay() / 1000.0f; // float mod = ssv->isTwoHand(proto->GetScalingStatValue()) ? 0.2f : 0.3f; - // + // // minDamage = (1.0f - mod) * average; // maxDamage = (1.0f + mod) * average; // } @@ -15025,9 +15021,8 @@ void Player::RewardQuest(Quest const* quest, LootItemType rewardType, uint32 rew { for (QuestRewardDisplaySpell displaySpell : quest->RewardDisplaySpell) { - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(displaySpell.PlayerConditionId)) - if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition)) - continue; + if (!ConditionMgr::IsPlayerMeetingCondition(this, displaySpell.PlayerConditionId)) + continue; SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(displaySpell.SpellId, GetMap()->GetDifficultyID()); Unit* caster = this; @@ -19324,7 +19319,7 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, TransferAbo { for (auto&& itr : *mapDifficultyConditions) { - if (!ConditionMgr::IsPlayerMeetingCondition(this, itr.second)) + if (!ConditionMgr::IsPlayerMeetingCondition(this, itr.second->ID)) { failedMapDifficultyXCondition = itr.first; break; @@ -22678,13 +22673,10 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin return false; } - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(crItem->PlayerConditionId)) + if (!ConditionMgr::IsPlayerMeetingCondition(this, crItem->PlayerConditionId)) { - if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition)) - { - SendEquipError(EQUIP_ERR_ITEM_LOCKED, nullptr, nullptr); - return false; - } + SendEquipError(EQUIP_ERR_ITEM_LOCKED, nullptr, nullptr); + return false; } // check current item amount if it limited @@ -28866,11 +28858,7 @@ void Player::SendPlayerChoice(ObjectGuid sender, int32 choiceId) bool Player::MeetPlayerCondition(uint32 conditionId) const { - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(conditionId)) - if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition)) - return false; - - return true; + return ConditionMgr::IsPlayerMeetingCondition(this, conditionId); } bool Player::IsInFriendlyArea() const @@ -29373,8 +29361,7 @@ uint8 Player::GetItemLimitCategoryQuantity(ItemLimitCategoryEntry const* limitEn { for (ItemLimitCategoryConditionEntry const* limitCondition : *limitConditions) { - PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(limitCondition->PlayerConditionID); - if (!playerCondition || ConditionMgr::IsPlayerMeetingCondition(this, playerCondition)) + if (ConditionMgr::IsPlayerMeetingCondition(this, limitCondition->PlayerConditionID)) limit += limitCondition->AddQuantity; } } diff --git a/src/server/game/Entities/Taxi/TaxiPathGraph.cpp b/src/server/game/Entities/Taxi/TaxiPathGraph.cpp index a5395bbdc68..2885a4341ac 100644 --- a/src/server/game/Entities/Taxi/TaxiPathGraph.cpp +++ b/src/server/game/Entities/Taxi/TaxiPathGraph.cpp @@ -46,9 +46,8 @@ struct EdgeCost if (!isVisibleForFaction) return std::numeric_limits<uint16>::max(); - if (PlayerConditionEntry const* condition = sPlayerConditionStore.LookupEntry(To->ConditionID)) - if (!sConditionMgr->IsPlayerMeetingCondition(player, condition)) - return std::numeric_limits<uint16>::max(); + if (!ConditionMgr::IsPlayerMeetingCondition(player, To->ConditionID)) + return std::numeric_limits<uint16>::max(); return Distance; } diff --git a/src/server/game/Entities/Unit/Vignette.cpp b/src/server/game/Entities/Unit/Vignette.cpp index 1f4aa074ea2..5b3953c7d7f 100644 --- a/src/server/game/Entities/Unit/Vignette.cpp +++ b/src/server/game/Entities/Unit/Vignette.cpp @@ -119,9 +119,8 @@ bool CanSee(Player const* player, VignetteData const& vignette) if (player->IsQuestRewarded(vignette.Data->VisibleTrackingQuestID)) return false; - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(vignette.Data->PlayerConditionID)) - if (!ConditionMgr::IsPlayerMeetingCondition(player, playerCondition)) - return false; + if (!ConditionMgr::IsPlayerMeetingCondition(player, vignette.Data->PlayerConditionID)) + return false; return true; } diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 157d7402aea..aec596871b8 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -9852,8 +9852,11 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, VendorItem const& vItem, if (vItem.PlayerConditionId && !sPlayerConditionStore.LookupEntry(vItem.PlayerConditionId)) { - TC_LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` has Item (Entry: {}) with invalid PlayerConditionId ({}) for vendor ({}), ignore", vItem.item, vItem.PlayerConditionId, vendor_entry); - return false; + if (!sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_PLAYER_CONDITION, vItem.PlayerConditionId)) + { + TC_LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` has Item (Entry: {}) with serverside PlayerConditionId ({}) for vendor ({}) without conditions, ignore", vItem.item, vItem.PlayerConditionId, vendor_entry); + return false; + } } if (vItem.ExtendedCost && !sItemExtendedCostStore.LookupEntry(vItem.ExtendedCost)) diff --git a/src/server/game/Handlers/ArtifactHandler.cpp b/src/server/game/Handlers/ArtifactHandler.cpp index 2412a20a9ac..4ec494bd2bc 100644 --- a/src/server/game/Handlers/ArtifactHandler.cpp +++ b/src/server/game/Handlers/ArtifactHandler.cpp @@ -171,9 +171,8 @@ void WorldSession::HandleArtifactSetAppearance(WorldPackets::Artifact::ArtifactS if (!artifactAppearanceSet || artifactAppearanceSet->ArtifactID != artifact->GetTemplate()->GetArtifactID()) return; - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(artifactAppearance->UnlockPlayerConditionID)) - if (!sConditionMgr->IsPlayerMeetingCondition(_player, playerCondition)) - return; + if (!ConditionMgr::IsPlayerMeetingCondition(_player, artifactAppearance->UnlockPlayerConditionID)) + return; artifact->SetAppearanceModId(artifactAppearance->ItemAppearanceModifierID); artifact->SetModifier(ITEM_MODIFIER_ARTIFACT_APPEARANCE_ID, artifactAppearance->ID); diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index ebb57753f3a..9beee837a50 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -1703,9 +1703,8 @@ void WorldSession::HandleAlterAppearance(WorldPackets::Character::AlterApperance if (!MeetsChrCustomizationReq(req, Races(packet.CustomizedRace), Classes(_player->GetClass()), false, customizations)) return; - if (PlayerConditionEntry const* condition = sPlayerConditionStore.LookupEntry(conditionalChrModel->PlayerConditionID)) - if (!ConditionMgr::IsPlayerMeetingCondition(_player, condition)) - return; + if (!ConditionMgr::IsPlayerMeetingCondition(_player, conditionalChrModel->PlayerConditionID)) + return; } if (!ValidateAppearance(Races(_player->GetRace()), Classes(_player->GetClass()), Gender(packet.NewSex), customizations)) diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 5a8bb2d2b98..224a5aea0bf 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -628,9 +628,8 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid) WorldPackets::NPC::VendorItem& item = packet.Items[count]; - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(vendorItem->PlayerConditionId)) - if (!ConditionMgr::IsPlayerMeetingCondition(_player, playerCondition)) - item.PlayerConditionFailed = playerCondition->ID; + if (!ConditionMgr::IsPlayerMeetingCondition(_player, vendorItem->PlayerConditionId)) + item.PlayerConditionFailed = vendorItem->PlayerConditionId; if (vendorItem->Type == ITEM_VENDOR_TYPE_ITEM) { diff --git a/src/server/game/Handlers/TaxiHandler.cpp b/src/server/game/Handlers/TaxiHandler.cpp index 5d60d098e9b..48cb5a1cb99 100644 --- a/src/server/game/Handlers/TaxiHandler.cpp +++ b/src/server/game/Handlers/TaxiHandler.cpp @@ -202,10 +202,7 @@ void WorldSession::HandleActivateTaxiOpcode(WorldPackets::Taxi::ActivateTaxi& ac DB2Manager::MountXDisplayContainer usableDisplays; std::copy_if(mountDisplays->begin(), mountDisplays->end(), std::back_inserter(usableDisplays), [this](MountXDisplayEntry const* mountDisplay) { - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(mountDisplay->PlayerConditionID)) - return sConditionMgr->IsPlayerMeetingCondition(GetPlayer(), playerCondition); - - return true; + return ConditionMgr::IsPlayerMeetingCondition(GetPlayer(), mountDisplay->PlayerConditionID); }); if (!usableDisplays.empty()) diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index 5e7a46641f6..1ddcefd2c98 100644 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -151,8 +151,11 @@ void Quest::LoadRewardDisplaySpell(Field* fields) if (playerConditionId && !sPlayerConditionStore.LookupEntry(playerConditionId)) { - TC_LOG_ERROR("sql.sql", "Table `quest_reward_display_spell` has non-existing PlayerCondition ({}) set for quest {} and spell {}. Set to 0.", playerConditionId, fields[0].GetUInt32(), spellId); - playerConditionId = 0; + if (!sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_PLAYER_CONDITION, playerConditionId)) + { + TC_LOG_ERROR("sql.sql", "Table `quest_reward_display_spell` has serverside PlayerCondition ({}) set for quest {} and spell {} without conditions. Set to 0.", playerConditionId, fields[0].GetUInt32(), spellId); + playerConditionId = 0; + } } if (type >= AsUnderlyingType(QuestCompleteSpellType::Max)) @@ -482,9 +485,8 @@ void Quest::BuildQuestRewards(WorldPackets::Quest::QuestRewards& rewards, Player auto displaySpellItr = rewards.SpellCompletionDisplayID.begin(); for (QuestRewardDisplaySpell displaySpell : RewardDisplaySpell) { - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(displaySpell.PlayerConditionId)) - if (!ConditionMgr::IsPlayerMeetingCondition(player, playerCondition)) - continue; + if (!ConditionMgr::IsPlayerMeetingCondition(player, displaySpell.PlayerConditionId)) + continue; *displaySpellItr = displaySpell.SpellId; if (++displaySpellItr == rewards.SpellCompletionDisplayID.end()) diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index abb5aa00594..cfd10dda464 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -2713,8 +2713,7 @@ void AuraEffect::HandleAuraMounted(AuraApplication const* aurApp, uint8 mode, bo std::copy_if(mountDisplays->begin(), mountDisplays->end(), std::back_inserter(usableDisplays), [target](MountXDisplayEntry const* mountDisplay) { if (Player* playerTarget = target->ToPlayer()) - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(mountDisplay->PlayerConditionID)) - return sConditionMgr->IsPlayerMeetingCondition(playerTarget, playerCondition); + return ConditionMgr::IsPlayerMeetingCondition(playerTarget, mountDisplay->PlayerConditionID); return true; }); diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index a34444b8fd9..4cc681a03fb 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -4325,9 +4325,8 @@ uint32 SpellInfo::GetSpellXSpellVisualId(WorldObject const* caster /*= nullptr*/ { for (SpellXSpellVisualEntry const* visual : _visuals) { - if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(visual->CasterPlayerConditionID)) - if (!caster || !caster->IsPlayer() || !ConditionMgr::IsPlayerMeetingCondition(caster->ToPlayer(), playerCondition)) - continue; + if (!caster || !caster->IsPlayer() || !ConditionMgr::IsPlayerMeetingCondition(caster->ToPlayer(), visual->CasterPlayerConditionID)) + continue; if (UnitConditionEntry const* unitCondition = sUnitConditionStore.LookupEntry(visual->CasterUnitConditionID)) if (!caster || !caster->IsUnit() || !ConditionMgr::IsUnitMeetingCondition(caster->ToUnit(), Object::ToUnit(viewer), unitCondition)) @@ -4891,8 +4890,7 @@ bool SpellInfo::MeetsFutureSpellPlayerCondition(Player const* player) const if (ShowFutureSpellPlayerConditionID == 0) return false; - PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(ShowFutureSpellPlayerConditionID); - return !playerCondition || ConditionMgr::IsPlayerMeetingCondition(player, playerCondition); + return ConditionMgr::IsPlayerMeetingCondition(player, ShowFutureSpellPlayerConditionID); } bool SpellInfo::HasLabel(uint32 labelId) const diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index a73c8329993..d03dd7b96cb 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -1616,11 +1616,7 @@ public: return false; } - PlayerConditionEntry const* playerConditionEntry = sPlayerConditionStore.LookupEntry(playerConditionId); - if (!playerConditionEntry) - return false; - - if (ConditionMgr::IsPlayerMeetingCondition(target, playerConditionEntry)) + if (ConditionMgr::IsPlayerMeetingCondition(target, playerConditionId)) handler->PSendSysMessage("PlayerCondition %u met", playerConditionId); else handler->PSendSysMessage("PlayerCondition %u not met", playerConditionId); |