Core/Conditions: Added CONDITION_SOURCE_TYPE_PLAYER_CONDITION (#29832)
This commit is contained in:
@@ -1700,8 +1700,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;
|
||||
}
|
||||
@@ -1965,8 +1964,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;
|
||||
}
|
||||
|
||||
@@ -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 (Optional<ContentTuningLevels> levels = sDB2Manager.GetContentTuningData(condition->ContentTuningID, player->m_playerData->CtrOptions->ContentTuningConditionMask))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -2230,7 +2230,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;
|
||||
@@ -2242,7 +2242,7 @@ bool GameObject::ActivateToQuest(Player const* target) const
|
||||
return true;
|
||||
|
||||
if (!sObjectMgr->IsGameObjectForQuests(GetEntry()))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
switch (GetGoType())
|
||||
{
|
||||
@@ -3323,9 +3323,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)
|
||||
{
|
||||
@@ -4445,14 +4445,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()
|
||||
|
||||
@@ -295,10 +295,7 @@ GameObject const* AzeriteItem::FindHeartForge(Player const* owner)
|
||||
|
||||
bool AzeriteItem::CanUseEssences() const
|
||||
{
|
||||
if (PlayerConditionEntry const* condition = sPlayerConditionStore.LookupEntry(PLAYER_CONDITION_ID_UNLOCKED_AZERITE_ESSENCES))
|
||||
return ConditionMgr::IsPlayerMeetingCondition(GetOwner(), condition);
|
||||
|
||||
return false;
|
||||
return ConditionMgr::IsPlayerMeetingCondition(GetOwner(), PLAYER_CONDITION_ID_UNLOCKED_AZERITE_ESSENCES);
|
||||
}
|
||||
|
||||
bool AzeriteItem::HasUnlockedEssenceSlot(uint8 slot) const
|
||||
|
||||
@@ -505,9 +505,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);
|
||||
@@ -1038,13 +1037,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:
|
||||
@@ -2716,8 +2712,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)
|
||||
{
|
||||
|
||||
@@ -106,8 +106,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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -7053,10 +7053,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;
|
||||
@@ -7122,10 +7120,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
|
||||
{
|
||||
@@ -15365,9 +15361,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;
|
||||
@@ -18516,9 +18511,8 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
|
||||
if (GetSession()->GetCollectionMgr()->HasTransmogIllusion(transmogIllusion->ID))
|
||||
continue;
|
||||
|
||||
if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(transmogIllusion->UnlockConditionID))
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition))
|
||||
continue;
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(this, transmogIllusion->UnlockConditionID))
|
||||
continue;
|
||||
|
||||
GetSession()->GetCollectionMgr()->AddTransmogIllusion(transmogIllusion->ID);
|
||||
}
|
||||
@@ -19746,7 +19740,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;
|
||||
@@ -23108,13 +23102,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
|
||||
@@ -26950,9 +26941,8 @@ TalentLearnResult Player::LearnPvpTalent(uint32 talentID, uint8 slot, int32* spe
|
||||
if (HasPvpTalent(talentID, GetActiveTalentGroup()))
|
||||
return TALENT_FAILED_UNKNOWN;
|
||||
|
||||
if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(talentInfo->PlayerConditionID))
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition))
|
||||
return TALENT_FAILED_CANT_DO_THAT_RIGHT_NOW;
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(this, talentInfo->PlayerConditionID))
|
||||
return TALENT_FAILED_CANT_DO_THAT_RIGHT_NOW;
|
||||
|
||||
if (PvpTalentEntry const* talent = sPvpTalentStore.LookupEntry(GetPvpTalentMap(GetActiveTalentGroup())[slot]))
|
||||
{
|
||||
@@ -29389,11 +29379,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
|
||||
@@ -29896,8 +29882,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -739,13 +739,10 @@ void Player::UpdateCorruption()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(corruptionEffect->PlayerConditionID))
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(this, corruptionEffect->PlayerConditionID))
|
||||
{
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition))
|
||||
{
|
||||
RemoveAura(corruptionEffect->Aura);
|
||||
continue;
|
||||
}
|
||||
RemoveAura(corruptionEffect->Aura);
|
||||
continue;
|
||||
}
|
||||
|
||||
CastSpell(this, corruptionEffect->Aura, true);
|
||||
|
||||
@@ -8038,9 +8038,8 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const
|
||||
continue;
|
||||
|
||||
if (Player const* thisPlayer = ToPlayer())
|
||||
if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(mountCapability->PlayerConditionID))
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(thisPlayer, playerCondition))
|
||||
continue;
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(thisPlayer, mountCapability->PlayerConditionID))
|
||||
continue;
|
||||
|
||||
return mountCapability;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -9843,8 +9843,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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1755,9 +1755,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))
|
||||
@@ -2003,9 +2002,8 @@ void WorldSession::HandleEquipmentSetSave(WorldPackets::EquipmentSet::SaveEquipm
|
||||
if (!illusion->ItemVisual || !illusion->GetFlags().HasFlag(SpellItemEnchantmentFlags::AllowTransmog))
|
||||
return false;
|
||||
|
||||
if (PlayerConditionEntry const* condition = sPlayerConditionStore.LookupEntry(illusion->TransmogUseConditionID))
|
||||
if (!sConditionMgr->IsPlayerMeetingCondition(_player, condition))
|
||||
return false;
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(_player, illusion->TransmogUseConditionID))
|
||||
return false;
|
||||
|
||||
if (illusion->ScalingClassRestricted > 0 && uint8(illusion->ScalingClassRestricted) != _player->GetClass())
|
||||
return false;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -1170,9 +1170,8 @@ void WorldSession::HandleRequestLatestSplashScreen(WorldPackets::Misc::RequestLa
|
||||
UISplashScreenEntry const* splashScreen = nullptr;
|
||||
for (auto itr = sUISplashScreenStore.begin(); itr != sUISplashScreenStore.end(); ++itr)
|
||||
{
|
||||
if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(itr->CharLevelConditionID))
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(_player, playerCondition))
|
||||
continue;
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(_player, itr->CharLevelConditionID))
|
||||
continue;
|
||||
|
||||
splashScreen = *itr;
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -135,13 +135,10 @@ void WorldSession::HandleTransmogrifyItems(WorldPackets::Transmogrification::Tra
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerConditionEntry const* condition = sPlayerConditionStore.LookupEntry(illusion->UnlockConditionID))
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(player, illusion->UnlockConditionID))
|
||||
{
|
||||
if (!ConditionMgr::IsPlayerMeetingCondition(player, condition))
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - {}, Name: {} tried to transmogrify illusion using not allowed enchant ({}).", player->GetGUID().ToString(), player->GetName(), transmogItem.SpellItemEnchantmentID);
|
||||
return;
|
||||
}
|
||||
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - {}, Name: {} tried to transmogrify illusion using not allowed enchant ({}).", player->GetGUID().ToString(), player->GetName(), transmogItem.SpellItemEnchantmentID);
|
||||
return;
|
||||
}
|
||||
|
||||
illusionItems[itemTransmogrified] = transmogItem.SpellItemEnchantmentID;
|
||||
|
||||
@@ -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))
|
||||
@@ -484,9 +487,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())
|
||||
|
||||
@@ -2634,8 +2634,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;
|
||||
});
|
||||
|
||||
@@ -4364,9 +4364,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))
|
||||
@@ -4930,8 +4929,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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user