aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Player
diff options
context:
space:
mode:
authorMeji <alvaro.megias@outlook.com>2024-03-27 21:38:08 +0100
committerGitHub <noreply@github.com>2024-03-27 21:38:08 +0100
commit4913d027bf3b8231b925be3f203feac590bb3607 (patch)
tree830f91b8f86fe9fa653ff6d41be256f850140dbf /src/server/game/Entities/Player
parent1f855ef56336c6a7fd74898e9c9beba77828c69b (diff)
Core/Conditions: Added CONDITION_SOURCE_TYPE_PLAYER_CONDITION (#29832)
Diffstat (limited to 'src/server/game/Entities/Player')
-rw-r--r--src/server/game/Entities/Player/CollectionMgr.cpp8
-rw-r--r--src/server/game/Entities/Player/Player.cpp47
2 files changed, 18 insertions, 37 deletions
diff --git a/src/server/game/Entities/Player/CollectionMgr.cpp b/src/server/game/Entities/Player/CollectionMgr.cpp
index 51a8cac3879..3160d99b27a 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 f2d321fe6b5..8473f53ffe2 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -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;
}
}