aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOvahlord <dreadkiller@gmx.de>2023-11-21 14:33:48 +0100
committerOvahlord <dreadkiller@gmx.de>2023-11-21 14:33:48 +0100
commit6472640e5511f91f310547e81b4b2d407f283005 (patch)
tree4c1a75d45d9208f357236f97cef33f8b35d8b011
parent731e3bc83069f9d704739025aea5e2c15d33d4a8 (diff)
Core/Players: restore class and talent tier checks in Player::LearnTalent
-rw-r--r--src/server/game/DataStores/DB2Stores.h1
-rw-r--r--src/server/game/Entities/Player/Player.cpp30
2 files changed, 16 insertions, 15 deletions
diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h
index 7f935189268..bec4b932b64 100644
--- a/src/server/game/DataStores/DB2Stores.h
+++ b/src/server/game/DataStores/DB2Stores.h
@@ -250,6 +250,7 @@ TC_GAME_API extern DB2Storage<SpellVisualKitEntry> sSpellVisual
TC_GAME_API extern DB2Storage<SpellXSpellVisualEntry> sSpellXSpellVisualStore;
TC_GAME_API extern DB2Storage<SummonPropertiesEntry> sSummonPropertiesStore;
TC_GAME_API extern DB2Storage<TalentEntry> sTalentStore;
+TC_GAME_API extern DB2Storage<TalentTabEntry> sTalentTabStore;
TC_GAME_API extern DB2Storage<TaxiNodesEntry> sTaxiNodesStore;
TC_GAME_API extern DB2Storage<TaxiPathEntry> sTaxiPathStore;
TC_GAME_API extern DB2Storage<TraitCondEntry> sTraitCondStore;
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 50cf8a1e90b..82cbb0ab5af 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -26121,15 +26121,13 @@ bool Player::LearnTalent(uint32 talentId, uint8 requestedRank)
if (!talentInfo)
return false;
- /*
TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TabID);
if (!talentTabInfo)
- return;
+ return false;
// prevent learn talent for different class (cheating)
if (!(GetClassMask() & talentTabInfo->ClassMask))
- return;
- */
+ return false;
// Check for existing talents
@@ -26163,21 +26161,23 @@ bool Player::LearnTalent(uint32 talentId, uint8 requestedRank)
}
// Find out how many points we have in this field
- /*
uint32 spentPoints = 0;
- uint32 tTab = talentInfo->TabID;
if (talentInfo->TierID > 0)
+ {
for (TalentEntry const* tmpTalent : sTalentStore) // the way talents are tracked
- if (tmpTalent->TabID == tTab)
- for (uint8 rank = 0; rank < MAX_TALENT_RANK; rank++)
- if (tmpTalent->SpellRank[rank] != 0)
- if (HasSpell(tmpTalent->SpellRank[rank]))
- spentPoints += (rank + 1);
+ {
+ if (tmpTalent->TabID != talentInfo->TabID)
+ continue;
- // not have required min points spent in talent tree
- if (spentPoints < (talentInfo->TierID * NEEDED_TALENT_POINT_PER_TIER))
- return;
- >*/
+ for (size_t i = 0; i < tmpTalent->SpellRank.size(); ++i)
+ if (tmpTalent->SpellRank[i] != 0 && HasSpell(tmpTalent->SpellRank[i]))
+ spentPoints += (i + 1);
+ }
+
+ // not have required min points spent in talent tree
+ if (spentPoints < static_cast<uint32>(talentInfo->TierID * NEEDED_TALENT_POINT_PER_TIER))
+ return false;
+ }
// spell not set in talent.dbc
uint32 spellId = talentInfo->SpellRank[requestedRank];