aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Player
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2018-12-09 14:45:03 +0100
committerShauren <shauren.trinity@gmail.com>2018-12-09 14:45:03 +0100
commitf94deace764f0b8d99249760d2bc2e85c891c387 (patch)
tree4c7c56f34768fc7aef05268061a12845c5bf67ce /src/server/game/Entities/Player
parent8725eec9c1c15f3e76bd9d524d4a5d8d0b3f0a44 (diff)
parenta70030ff252b266d12023ffada2a309409c1ccdb (diff)
Merge branch 'bfa'
Diffstat (limited to 'src/server/game/Entities/Player')
-rw-r--r--src/server/game/Entities/Player/CollectionMgr.cpp38
-rw-r--r--src/server/game/Entities/Player/Player.cpp954
-rw-r--r--src/server/game/Entities/Player/Player.h92
-rw-r--r--src/server/game/Entities/Player/PlayerTaxi.cpp8
-rw-r--r--src/server/game/Entities/Player/PlayerTaxi.h4
-rw-r--r--src/server/game/Entities/Player/RestMgr.cpp22
6 files changed, 532 insertions, 586 deletions
diff --git a/src/server/game/Entities/Player/CollectionMgr.cpp b/src/server/game/Entities/Player/CollectionMgr.cpp
index eb4834967ba..6aff0ca300a 100644
--- a/src/server/game/Entities/Player/CollectionMgr.cpp
+++ b/src/server/game/Entities/Player/CollectionMgr.cpp
@@ -81,14 +81,14 @@ CollectionMgr::~CollectionMgr()
void CollectionMgr::LoadToys()
{
for (auto const& t : _toys)
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_TOYS, t.first);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_TOYS, t.first);
}
bool CollectionMgr::AddToy(uint32 itemId, bool isFavourite /*= false*/)
{
if (UpdateAccountToys(itemId, isFavourite))
{
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_TOYS, itemId);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_TOYS, itemId);
return true;
}
@@ -204,8 +204,8 @@ void CollectionMgr::LoadHeirlooms()
{
for (auto const& item : _heirlooms)
{
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_HEIRLOOMS, item.first);
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_HEIRLOOM_FLAGS, item.second.flags);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_HEIRLOOMS, item.first);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_HEIRLOOM_FLAGS, item.second.flags);
}
}
@@ -213,8 +213,8 @@ void CollectionMgr::AddHeirloom(uint32 itemId, uint32 flags)
{
if (UpdateAccountHeirlooms(itemId, flags))
{
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_HEIRLOOMS, itemId);
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_HEIRLOOM_FLAGS, flags);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_HEIRLOOMS, itemId);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_HEIRLOOM_FLAGS, flags);
}
}
@@ -255,10 +255,10 @@ void CollectionMgr::UpgradeHeirloom(uint32 itemId, int32 castItem)
item->AddBonuses(bonusId);
// Get heirloom offset to update only one part of dynamic field
- std::vector<uint32> const& fields = player->GetDynamicValues(PLAYER_DYNAMIC_FIELD_HEIRLOOMS);
+ std::vector<uint32> const& fields = player->GetDynamicValues(ACTIVE_PLAYER_DYNAMIC_FIELD_HEIRLOOMS);
uint16 offset = uint16(std::find(fields.begin(), fields.end(), itemId) - fields.begin());
- player->SetDynamicValue(PLAYER_DYNAMIC_FIELD_HEIRLOOM_FLAGS, offset, flags);
+ player->SetDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_HEIRLOOM_FLAGS, offset, flags);
itr->second.flags = flags;
itr->second.bonusId = bonusId;
}
@@ -295,11 +295,11 @@ void CollectionMgr::CheckHeirloomUpgrades(Item* item)
if (newItemId)
{
- std::vector<uint32> const& fields = player->GetDynamicValues(PLAYER_DYNAMIC_FIELD_HEIRLOOMS);
+ std::vector<uint32> const& fields = player->GetDynamicValues(ACTIVE_PLAYER_DYNAMIC_FIELD_HEIRLOOMS);
uint16 offset = uint16(std::find(fields.begin(), fields.end(), itr->first) - fields.begin());
- player->SetDynamicValue(PLAYER_DYNAMIC_FIELD_HEIRLOOMS, offset, newItemId);
- player->SetDynamicValue(PLAYER_DYNAMIC_FIELD_HEIRLOOM_FLAGS, offset, 0);
+ player->SetDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_HEIRLOOMS, offset, newItemId);
+ player->SetDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_HEIRLOOM_FLAGS, offset, 0);
_heirlooms.erase(itr);
_heirlooms[newItemId] = 0;
@@ -460,11 +460,11 @@ void CollectionMgr::LoadItemAppearances()
{
boost::to_block_range(*_appearances, DynamicBitsetBlockOutputIterator([this](uint32 blockValue)
{
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_TRANSMOG, blockValue);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_TRANSMOG, blockValue);
}));
for (auto itr = _temporaryAppearances.begin(); itr != _temporaryAppearances.end(); ++itr)
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_CONDITIONAL_TRANSMOG, itr->first);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_CONDITIONAL_TRANSMOG, itr->first);
}
void CollectionMgr::LoadAccountItemAppearances(PreparedQueryResult knownAppearances, PreparedQueryResult favoriteAppearances)
@@ -738,18 +738,18 @@ void CollectionMgr::AddItemAppearance(ItemModifiedAppearanceEntry const* itemMod
_appearances->resize(itemModifiedAppearance->ID + 1);
numBlocks = _appearances->num_blocks() - numBlocks;
while (numBlocks--)
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_TRANSMOG, 0);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_TRANSMOG, 0);
}
_appearances->set(itemModifiedAppearance->ID);
uint32 blockIndex = itemModifiedAppearance->ID / 32;
uint32 bitIndex = itemModifiedAppearance->ID % 32;
- uint32 currentMask = _owner->GetPlayer()->GetDynamicValue(PLAYER_DYNAMIC_FIELD_TRANSMOG, blockIndex);
- _owner->GetPlayer()->SetDynamicValue(PLAYER_DYNAMIC_FIELD_TRANSMOG, blockIndex, currentMask | (1 << bitIndex));
+ uint32 currentMask = _owner->GetPlayer()->GetDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_TRANSMOG, blockIndex);
+ _owner->GetPlayer()->SetDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_TRANSMOG, blockIndex, currentMask | (1 << bitIndex));
auto temporaryAppearance = _temporaryAppearances.find(itemModifiedAppearance->ID);
if (temporaryAppearance != _temporaryAppearances.end())
{
- _owner->GetPlayer()->RemoveDynamicValue(PLAYER_DYNAMIC_FIELD_CONDITIONAL_TRANSMOG, itemModifiedAppearance->ID);
+ _owner->GetPlayer()->RemoveDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_CONDITIONAL_TRANSMOG, itemModifiedAppearance->ID);
_temporaryAppearances.erase(temporaryAppearance);
}
@@ -770,7 +770,7 @@ void CollectionMgr::AddTemporaryAppearance(ObjectGuid const& itemGuid, ItemModif
{
std::unordered_set<ObjectGuid>& itemsWithAppearance = _temporaryAppearances[itemModifiedAppearance->ID];
if (itemsWithAppearance.empty())
- _owner->GetPlayer()->AddDynamicValue(PLAYER_DYNAMIC_FIELD_CONDITIONAL_TRANSMOG, itemModifiedAppearance->ID);
+ _owner->GetPlayer()->AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_CONDITIONAL_TRANSMOG, itemModifiedAppearance->ID);
itemsWithAppearance.insert(itemGuid);
}
@@ -788,7 +788,7 @@ void CollectionMgr::RemoveTemporaryAppearance(Item* item)
itr->second.erase(item->GetGUID());
if (itr->second.empty())
{
- _owner->GetPlayer()->RemoveDynamicValue(PLAYER_DYNAMIC_FIELD_CONDITIONAL_TRANSMOG, itemModifiedAppearance->ID);
+ _owner->GetPlayer()->RemoveDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_CONDITIONAL_TRANSMOG, itemModifiedAppearance->ID);
_temporaryAppearances.erase(itr);
}
}
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 5ec2a72d2ad..f32bfb5d3e2 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -140,8 +140,8 @@ Player::Player(WorldSession* session) : Unit(true), m_sceneMgr(this)
m_objectType |= TYPEMASK_PLAYER;
m_objectTypeId = TYPEID_PLAYER;
- m_valuesCount = PLAYER_END;
- _dynamicValuesCount = PLAYER_DYNAMIC_END;
+ m_valuesCount = ACTIVE_PLAYER_END;
+ _dynamicValuesCount = ACTIVE_PLAYER_DYNAMIC_END;
m_session = session;
@@ -469,7 +469,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, WorldPackets::Character::Charac
SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); // default for players in 3.0.3
- SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); // -1 is default value
+ SetInt32Value(ACTIVE_PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); // -1 is default value
SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID, createInfo->Skin);
SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID, createInfo->Face);
@@ -478,23 +478,23 @@ bool Player::Create(ObjectGuid::LowType guidlow, WorldPackets::Character::Charac
SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE, createInfo->FacialHairStyle);
for (uint32 i = 0; i < PLAYER_CUSTOM_DISPLAY_SIZE; ++i)
SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_CUSTOM_DISPLAY_OPTION + i, createInfo->CustomDisplay[i]);
- SetUInt32Value(PLAYER_FIELD_REST_INFO + REST_STATE_XP, (GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0) ? REST_STATE_RAF_LINKED : REST_STATE_NOT_RAF_LINKED);
- SetUInt32Value(PLAYER_FIELD_REST_INFO + REST_STATE_HONOR, REST_STATE_NOT_RAF_LINKED);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + REST_STATE_XP, (GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0) ? REST_STATE_RAF_LINKED : REST_STATE_NOT_RAF_LINKED);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + REST_STATE_HONOR, REST_STATE_NOT_RAF_LINKED);
SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER, createInfo->Sex);
SetByteValue(PLAYER_BYTES_4, PLAYER_BYTES_4_OFFSET_ARENA_FACTION, 0);
SetInventorySlotCount(INVENTORY_DEFAULT_SIZE);
- SetGuidValue(OBJECT_FIELD_DATA, ObjectGuid::Empty);
+ SetGuidValue(UNIT_FIELD_GUILD_GUID, ObjectGuid::Empty);
SetUInt32Value(PLAYER_GUILDRANK, 0);
SetGuildLevel(0);
SetUInt32Value(PLAYER_GUILD_TIMESTAMP, 0);
for (int i = 0; i < KNOWN_TITLES_SIZE; ++i)
- SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES + i, 0); // 0=disabled
+ SetUInt64Value(ACTIVE_PLAYER_FIELD_KNOWN_TITLES + i, 0); // 0=disabled
SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
- SetUInt32Value(PLAYER_FIELD_KILLS, 0);
- SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, 0);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_KILLS, 0);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, 0);
// set starting level
uint32 start_level = sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL);
@@ -528,7 +528,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, WorldPackets::Character::Charac
InitRunes();
- SetUInt64Value(PLAYER_FIELD_COINAGE, sWorld->getIntConfig(CONFIG_START_PLAYER_MONEY));
+ SetUInt64Value(ACTIVE_PLAYER_FIELD_COINAGE, sWorld->getIntConfig(CONFIG_START_PLAYER_MONEY));
SetCurrency(CURRENCY_TYPE_APEXIS_CRYSTALS, sWorld->getIntConfig(CONFIG_CURRENCY_START_APEXIS_CRYSTALS));
SetCurrency(CURRENCY_TYPE_JUSTICE_POINTS, sWorld->getIntConfig(CONFIG_CURRENCY_START_JUSTICE_POINTS));
@@ -536,7 +536,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, WorldPackets::Character::Charac
if (sWorld->getBoolConfig(CONFIG_START_ALL_EXPLORED))
{
for (uint16 i=0; i<PLAYER_EXPLORED_ZONES_SIZE; i++)
- SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0xFFFFFFFF);
+ SetFlag(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES+i, 0xFFFFFFFF);
}
//Reputations if "StartAllReputation" is enabled, -- @todo Fix this in a better way
@@ -1404,7 +1404,7 @@ void Player::setDeathState(DeathState s)
if (IsAlive() && !oldIsAlive)
//clear aura case after resurrection by another way (spells will be applied before next death)
- ClearDynamicValue(PLAYER_DYNAMIC_FIELD_SELF_RES_SPELLS);
+ ClearDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_SELF_RES_SPELLS);
}
void Player::ToggleAFK()
@@ -2331,15 +2331,15 @@ void Player::RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method
void Player::SetXP(uint32 xp)
{
- SetUInt32Value(PLAYER_XP, xp);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_XP, xp);
int32 playerLevelDelta = 0;
// If XP < 50%, player should see scaling creature with -1 level except for level max
- if (getLevel() < MAX_LEVEL && xp < (GetUInt32Value(PLAYER_NEXT_LEVEL_XP) / 2))
+ if (getLevel() < MAX_LEVEL && xp < (GetUInt32Value(ACTIVE_PLAYER_FIELD_NEXT_LEVEL_XP) / 2))
playerLevelDelta = -1;
- SetInt32Value(PLAYER_FIELD_SCALING_PLAYER_LEVEL_DELTA, playerLevelDelta);
+ SetInt32Value(ACTIVE_PLAYER_FIELD_SCALING_PLAYER_LEVEL_DELTA, playerLevelDelta);
}
void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
@@ -2382,8 +2382,8 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
packet.ReferAFriendBonusType = recruitAFriend ? 1 : 0;
GetSession()->SendPacket(packet.Write());
- uint32 curXP = GetUInt32Value(PLAYER_XP);
- uint32 nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
+ uint32 curXP = GetUInt32Value(ACTIVE_PLAYER_FIELD_XP);
+ uint32 nextLvlXP = GetUInt32Value(ACTIVE_PLAYER_FIELD_NEXT_LEVEL_XP);
uint32 newXP = curXP + xp + bonus_xp;
while (newXP >= nextLvlXP && level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
@@ -2394,7 +2394,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
GiveLevel(level + 1);
level = getLevel();
- nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
+ nextLvlXP = GetUInt32Value(ACTIVE_PLAYER_FIELD_NEXT_LEVEL_XP);
}
SetXP(newXP);
@@ -2433,13 +2433,12 @@ void Player::GiveLevel(uint8 level)
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
packet.StatDelta[i] = int32(info.stats[i]) - GetCreateStat(Stats(i));
- uint32 const* rowLevels = (getClass() != CLASS_DEATH_KNIGHT) ? DefaultTalentRowLevels : DKTalentRowLevels;
-
- packet.Cp = std::find(rowLevels, rowLevels + MAX_TALENT_TIERS, level) != (rowLevels + MAX_TALENT_TIERS);
+ packet.NumNewTalents = DB2Manager::GetNumTalentsAtLevel(level, Classes(getClass())) - DB2Manager::GetNumTalentsAtLevel(oldLevel, Classes(getClass()));
+ packet.NumNewPvpTalentSlots = sDB2Manager.GetPvpTalentNumSlotsAtLevel(level, Classes(getClass())) - sDB2Manager.GetPvpTalentNumSlotsAtLevel(oldLevel, Classes(getClass()));
GetSession()->SendPacket(packet.Write());
- SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(level));
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(level));
//update level, max level of skills
m_Played_time[PLAYED_TIME_LEVEL] = 0; // Level Played Time reset
@@ -2503,8 +2502,8 @@ void Player::GiveLevel(uint8 level)
{
++m_grantableLevels;
- if (!HasByteFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_RAF_GRANTABLE_LEVEL, 0x01))
- SetByteFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_RAF_GRANTABLE_LEVEL, 0x01);
+ if (!HasByteFlag(ACTIVE_PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_RAF_GRANTABLE_LEVEL, 0x01))
+ SetByteFlag(ACTIVE_PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_RAF_GRANTABLE_LEVEL, 0x01);
}
}
}
@@ -2519,7 +2518,7 @@ void Player::InitTalentForLevel()
if (level < MIN_SPECIALIZATION_LEVEL)
ResetTalentSpecialization();
- uint32 talentTiers = CalculateTalentsTiers();
+ uint32 talentTiers = DB2Manager::GetNumTalentsAtLevel(level, Classes(getClass()));
if (level < 15)
{
// Remove all talent points
@@ -2534,7 +2533,7 @@ void Player::InitTalentForLevel()
RemoveTalent(talent);
}
- SetUInt32Value(PLAYER_FIELD_MAX_TALENT_TIERS, talentTiers);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_MAX_TALENT_TIERS, talentTiers);
if (!GetSession()->PlayerLoading())
SendTalentsInfoData(); // update at client
@@ -2551,8 +2550,8 @@ void Player::InitStatsForLevel(bool reapplyMods)
PlayerLevelInfo info;
sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), getLevel(), &info);
- SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
- SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(getLevel()));
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_MAX_LEVEL, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(getLevel()));
// reset before any aura state sources (health set/aura apply)
SetUInt32Value(UNIT_FIELD_AURASTATE, 0);
@@ -2582,26 +2581,26 @@ void Player::InitStatsForLevel(bool reapplyMods)
//set create powers
SetCreateMana(basemana);
- SetArmor(int32(m_createStats[STAT_AGILITY]*2));
+ SetArmor(int32(m_createStats[STAT_AGILITY]*2), 0);
InitStatBuffMods();
//reset rating fields values
- for (uint16 index = PLAYER_FIELD_COMBAT_RATING_1; index < PLAYER_FIELD_COMBAT_RATING_1 + MAX_COMBAT_RATING; ++index)
- SetUInt32Value(index, 0);
+ for (uint16 index = 0; index < MAX_COMBAT_RATING; ++index)
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_COMBAT_RATING + index, 0);
- SetUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, 0);
- SetFloatValue(PLAYER_FIELD_MOD_HEALING_PCT, 1.0f);
- SetFloatValue(PLAYER_FIELD_MOD_HEALING_DONE_PCT, 1.0f);
- SetFloatValue(PLAYER_FIELD_MOD_PERIODIC_HEALING_DONE_PERCENT, 1.0f);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_MOD_HEALING_DONE_POS, 0);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_MOD_HEALING_PCT, 1.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_MOD_HEALING_DONE_PCT, 1.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_MOD_PERIODIC_HEALING_DONE_PERCENT, 1.0f);
for (uint8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
{
- SetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, 0);
- SetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, 0);
- SetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, 1.00f);
+ SetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, 0);
+ SetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, 0);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, 1.00f);
}
- SetFloatValue(PLAYER_FIELD_MOD_SPELL_POWER_PCT, 1.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_MOD_SPELL_POWER_PCT, 1.0f);
//reset attack power, damage and attack speed fields
for (uint8 i = BASE_ATTACK; i < MAX_ATTACK; ++i)
@@ -2615,8 +2614,8 @@ void Player::InitStatsForLevel(bool reapplyMods)
SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, 0.0f);
for (uint16 i = 0; i < 3; ++i)
{
- SetFloatValue(PLAYER_FIELD_WEAPON_DMG_MULTIPLIERS + i, 1.0f);
- SetFloatValue(PLAYER_FIELD_WEAPON_ATK_SPEED_MULTIPLIERS + i, 1.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_WEAPON_DMG_MULTIPLIERS + i, 1.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_WEAPON_ATK_SPEED_MULTIPLIERS + i, 1.0f);
}
SetInt32Value(UNIT_FIELD_ATTACK_POWER, 0);
@@ -2625,44 +2624,42 @@ void Player::InitStatsForLevel(bool reapplyMods)
SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER, 0.0f);
// Base crit values (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset
- SetFloatValue(PLAYER_CRIT_PERCENTAGE, 0.0f);
- SetFloatValue(PLAYER_OFFHAND_CRIT_PERCENTAGE, 0.0f);
- SetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE, 0.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_CRIT_PERCENTAGE, 0.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_OFFHAND_CRIT_PERCENTAGE, 0.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_RANGED_CRIT_PERCENTAGE, 0.0f);
// Init spell schools (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset
- SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1, 0.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_SPELL_CRIT_PERCENTAGE1, 0.0f);
- SetFloatValue(PLAYER_PARRY_PERCENTAGE, 0.0f);
- SetFloatValue(PLAYER_BLOCK_PERCENTAGE, 0.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_PARRY_PERCENTAGE, 0.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_BLOCK_PERCENTAGE, 0.0f);
// Static 30% damage blocked
- SetUInt32Value(PLAYER_SHIELD_BLOCK, 30);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_SHIELD_BLOCK, 30);
// Dodge percentage
- SetFloatValue(PLAYER_DODGE_PERCENTAGE, 0.0f);
+ SetFloatValue(ACTIVE_PLAYER_FIELD_DODGE_PERCENTAGE, 0.0f);
// set armor (resistance 0) to original value (create_agility*2)
- SetArmor(int32(m_createStats[STAT_AGILITY]*2));
- SetResistanceBuffMods(SPELL_SCHOOL_NORMAL, true, 0.0f);
- SetResistanceBuffMods(SPELL_SCHOOL_NORMAL, false, 0.0f);
+ SetArmor(int32(m_createStats[STAT_AGILITY]*2), 0);
+ SetBonusResistanceMod(SPELL_SCHOOL_NORMAL, 0);
// set other resistance to original value (0)
for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
{
SetResistance(SpellSchools(i), 0);
- SetResistanceBuffMods(SpellSchools(i), true, 0.0f);
- SetResistanceBuffMods(SpellSchools(i), false, 0.0f);
+ SetBonusResistanceMod(SpellSchools(i), 0);
}
- SetUInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, 0);
- SetUInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE, 0);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_MOD_TARGET_RESISTANCE, 0);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE, 0);
for (uint8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
{
SetUInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + i, 0);
SetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, 0.0f);
}
// Reset no reagent cost field
- for (uint8 i = 0; i < 3; ++i)
- SetUInt32Value(PLAYER_NO_REAGENT_COST_1 + i, 0);
+ for (uint8 i = 0; i < 4; ++i)
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_NO_REAGENT_COST + i, 0);
// Init data for form but skip reapply item mods for form
InitDataForForm(reapplyMods);
@@ -2694,9 +2691,9 @@ void Player::InitStatsForLevel(bool reapplyMods)
RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY);
// restore if need some important flags
- SetByteValue(PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_IGNORE_POWER_REGEN_PREDICTION_MASK, 0);
- SetByteValue(PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_AURA_VISION, 0);
- SetByteValue(PLAYER_FIELD_BYTES2, 3, 0);
+ SetByteValue(ACTIVE_PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_IGNORE_POWER_REGEN_PREDICTION_MASK, 0);
+ SetByteValue(ACTIVE_PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_AURA_VISION, 0);
+ SetByteValue(ACTIVE_PLAYER_FIELD_BYTES2, 3, 0);
if (reapplyMods) // reapply stats values only on .reset stats (level) command
_ApplyAllStatBonuses();
@@ -3579,9 +3576,6 @@ void Player::ResetPvpTalents()
if (!talentInfo)
continue;
- if (talentInfo->ClassID && talentInfo->ClassID != getClass())
- continue;
-
RemovePvpTalent(talentInfo);
}
@@ -4316,7 +4310,7 @@ void Player::KillPlayer()
//SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_IN_PVP);
SetUInt32Value(OBJECT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
- ApplyModFlag(PLAYER_FIELD_LOCAL_FLAGS, PLAYER_LOCAL_FLAG_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable() && !HasAuraType(SPELL_AURA_PREVENT_RESURRECTION));
+ ApplyModFlag(ACTIVE_PLAYER_FIELD_LOCAL_FLAGS, PLAYER_LOCAL_FLAG_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable() && !HasAuraType(SPELL_AURA_PREVENT_RESURRECTION));
// 6 minutes until repop at graveyard
m_deathTimer = 6 * MINUTE * IN_MILLISECONDS;
@@ -5011,7 +5005,7 @@ float Player::GetRatingMultiplier(CombatRating cr) const
float Player::GetRatingBonusValue(CombatRating cr) const
{
- float baseResult = float(GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr)) * GetRatingMultiplier(cr);
+ float baseResult = float(GetUInt32Value(ACTIVE_PLAYER_FIELD_COMBAT_RATING + cr)) * GetRatingMultiplier(cr);
if (cr != CR_RESILIENCE_PLAYER_DAMAGE)
return baseResult;
return float(1.0f - pow(0.99f, baseResult)) * 100.0f;
@@ -5023,9 +5017,9 @@ float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const
switch (attType)
{
case BASE_ATTACK:
- return baseExpertise + GetUInt32Value(PLAYER_EXPERTISE) / 4.0f;
+ return baseExpertise + GetUInt32Value(ACTIVE_PLAYER_FIELD_EXPERTISE) / 4.0f;
case OFF_ATTACK:
- return baseExpertise + GetUInt32Value(PLAYER_OFFHAND_EXPERTISE) / 4.0f;
+ return baseExpertise + GetUInt32Value(ACTIVE_PLAYER_FIELD_OFFHAND_EXPERTISE) / 4.0f;
default:
break;
}
@@ -5056,8 +5050,8 @@ void Player::UpdateRating(CombatRating cr)
if (amount < 0)
amount = 0;
- uint32 oldRating = GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr);
- SetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr, uint32(amount));
+ uint32 oldRating = GetUInt32Value(ACTIVE_PLAYER_FIELD_COMBAT_RATING + cr);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_COMBAT_RATING + cr, uint32(amount));
bool affectStats = CanModifyStats();
@@ -5192,43 +5186,6 @@ void Player::SetRegularAttackTime()
}
}
-//skill+step, checking for max value
-bool Player::UpdateSkill(uint32 skill_id, uint32 step)
-{
- if (!skill_id)
- return false;
-
- SkillStatusMap::iterator itr = mSkillStatus.find(skill_id);
- if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
- return false;
-
- uint16 field = itr->second.pos / 2;
- uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
-
- uint16 value = GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset);
- uint16 max = GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
-
- if (!max || !value || value >= max)
- return false;
-
- if (value < max)
- {
- uint32 new_value = value + step;
- if (new_value > max)
- new_value = max;
-
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, new_value);
- if (itr->second.uState != SKILL_NEW)
- itr->second.uState = SKILL_CHANGED;
-
- UpdateSkillEnchantments(skill_id, value, new_value);
- UpdateCriteria(CRITERIA_TYPE_REACH_SKILL_LEVEL, skill_id);
- return true;
- }
-
- return false;
-}
-
inline int SkillGainChance(uint32 SkillValue, uint32 GrayLevel, uint32 GreenLevel, uint32 YellowLevel)
{
if (SkillValue >= GrayLevel)
@@ -5249,21 +5206,21 @@ bool Player::UpdateCraftSkill(uint32 spellid)
for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
{
- if (_spell_idx->second->SkillLine)
+ if (_spell_idx->second->SkillupSkillLineID)
{
- uint32 SkillValue = GetPureSkillValue(_spell_idx->second->SkillLine);
+ uint32 SkillValue = GetPureSkillValue(_spell_idx->second->SkillupSkillLineID);
// Alchemy Discoveries here
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spellid);
if (spellEntry && spellEntry->Mechanic == MECHANIC_DISCOVERY)
{
- if (uint32 discoveredSpell = GetSkillDiscoverySpell(_spell_idx->second->SkillLine, spellid, this))
+ if (uint32 discoveredSpell = GetSkillDiscoverySpell(_spell_idx->second->SkillupSkillLineID, spellid, this))
LearnSpell(discoveredSpell, false);
}
uint32 craft_skill_gain = _spell_idx->second->NumSkillUps * sWorld->getIntConfig(CONFIG_SKILL_GAIN_CRAFTING);
- return UpdateSkillPro(_spell_idx->second->SkillLine, SkillGainChance(SkillValue,
+ return UpdateSkillPro(_spell_idx->second->SkillupSkillLineID, SkillGainChance(SkillValue,
_spell_idx->second->TrivialSkillLineRankHigh,
(_spell_idx->second->TrivialSkillLineRankHigh + _spell_idx->second->TrivialSkillLineRankLow)/2,
_spell_idx->second->TrivialSkillLineRankLow),
@@ -5284,15 +5241,39 @@ bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLeve
switch (SkillId)
{
case SKILL_HERBALISM:
+ case SKILL_HERBALISM_2:
+ case SKILL_OUTLAND_HERBALISM:
+ case SKILL_NORTHREND_HERBALISM:
+ case SKILL_CATACLYSM_HERBALISM:
+ case SKILL_PANDARIA_HERBALISM:
+ case SKILL_DRAENOR_HERBALISM:
+ case SKILL_LEGION_HERBALISM:
+ case SKILL_KUL_TIRAN_HERBALISM:
case SKILL_JEWELCRAFTING:
case SKILL_INSCRIPTION:
return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator, gathering_skill_gain);
case SKILL_SKINNING:
+ case SKILL_SKINNING_2:
+ case SKILL_OUTLAND_SKINNING:
+ case SKILL_NORTHREND_SKINNING:
+ case SKILL_CATACLYSM_SKINNING:
+ case SKILL_PANDARIA_SKINNING:
+ case SKILL_DRAENOR_SKINNING:
+ case SKILL_LEGION_SKINNING:
+ case SKILL_KUL_TIRAN_SKINNING:
if (sWorld->getIntConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS) == 0)
return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator, gathering_skill_gain);
else
return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/sWorld->getIntConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS)), gathering_skill_gain);
case SKILL_MINING:
+ case SKILL_MINING_2:
+ case SKILL_OUTLAND_MINING:
+ case SKILL_NORTHREND_MINING:
+ case SKILL_CATACLYSM_MINING:
+ case SKILL_PANDARIA_MINING:
+ case SKILL_DRAENOR_MINING:
+ case SKILL_LEGION_MINING:
+ case SKILL_KUL_TIRAN_MINING:
if (sWorld->getIntConfig(CONFIG_SKILL_CHANCE_MINING_STEPS) == 0)
return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator, gathering_skill_gain);
else
@@ -5341,8 +5322,7 @@ bool Player::UpdateSkillPro(uint16 skillId, int32 chance, uint32 step)
// levels sync. with spell requirement for skill levels to learn
// bonus abilities in sSkillLineAbilityStore
// Used only to avoid scan DBC at each skill grow
- static uint32 bonusSkillLevels[] = { 75, 150, 225, 300, 375, 450, 525 };
- static const size_t bonusSkillLevelsSize = sizeof(bonusSkillLevels) / sizeof(uint32);
+ uint32 const bonusSkillLevels[] = { 75, 150, 225, 300, 375, 450, 525, 600, 700, 850 };
TC_LOG_DEBUG("entities.player.skills", "Player::UpdateSkillPro: Player '%s' (%s), SkillID: %u, Chance: %3.1f%%)",
GetName().c_str(), GetGUID().ToString().c_str(), skillId, chance / 10.0f);
@@ -5363,8 +5343,8 @@ bool Player::UpdateSkillPro(uint16 skillId, int32 chance, uint32 step)
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
- uint16 value = GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset);
- uint16 max = GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
+ uint16 value = GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset);
+ uint16 max = GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
if (!max || !value || value >= max)
return false;
@@ -5380,13 +5360,12 @@ bool Player::UpdateSkillPro(uint16 skillId, int32 chance, uint32 step)
if (new_value > max)
new_value = max;
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, new_value);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, new_value);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
- for (size_t i = 0; i < bonusSkillLevelsSize; ++i)
+ for (uint32 bsl : bonusSkillLevels)
{
- uint32 bsl = bonusSkillLevels[i];
if (value < bsl && new_value >= bsl)
{
LearnSkillRewardedSpells(skillId, new_value);
@@ -5407,7 +5386,7 @@ void Player::ModifySkillBonus(uint32 skillid, int32 val, bool talent)
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return;
- uint16 field = itr->second.pos / 2 + (talent ? PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET : PLAYER_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET);
+ uint16 field = itr->second.pos / 2 + (talent ? ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET : ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET);
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
uint16 bonus = GetUInt16Value(field, offset);
@@ -5436,13 +5415,13 @@ void Player::UpdateSkillsForLevel()
{
if (!IsWeaponSkill(rcEntry->SkillID))
{
- uint16 max = GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
+ uint16 max = GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
/// update only level dependent max skill values
if (max != 1)
{
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, maxSkill);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, maxSkill);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, maxSkill);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, maxSkill);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
}
@@ -5450,7 +5429,7 @@ void Player::UpdateSkillsForLevel()
}
// Update level dependent skillline spells
- LearnSkillRewardedSpells(rcEntry->SkillID, GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset));
+ LearnSkillRewardedSpells(rcEntry->SkillID, GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset));
}
}
@@ -5475,11 +5454,11 @@ void Player::UpdateSkillsToMaxSkillsForLevel()
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
- uint16 max = GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
+ uint16 max = GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
if (max > 1)
{
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, max);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, max);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
@@ -5502,7 +5481,7 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
{
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1; // itr->second.pos % 2
- currVal = GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset);
+ currVal = GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset);
if (newVal)
{
// if skill value is going down, update enchantments before setting the new value
@@ -5510,10 +5489,10 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
UpdateSkillEnchantments(id, currVal, newVal);
// update step
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, step);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, step);
// update value
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, newVal);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, maxVal);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, newVal);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, maxVal);
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
@@ -5531,12 +5510,12 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
//remove enchantments needing this skill
UpdateSkillEnchantments(id, currVal, 0);
// clear skill fields
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_ID_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_ID_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset, 0);
// mark as deleted or simply remove from map if not saved yet
if (itr->second.uState != SKILL_NEW)
@@ -5545,16 +5524,19 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
mSkillStatus.erase(itr);
// remove all spells that related to this skill
- for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
- if (SkillLineAbilityEntry const* pAbility = sSkillLineAbilityStore.LookupEntry(j))
- if (pAbility->SkillLine == id)
- RemoveSpell(sSpellMgr->GetFirstSpellInChain(pAbility->Spell));
+ if (std::vector<SkillLineAbilityEntry const*> const* skillLineAbilities = sDB2Manager.GetSkillLineAbilitiesBySkill(id))
+ for (SkillLineAbilityEntry const* skillLineAbility : *skillLineAbilities)
+ RemoveSpell(sSpellMgr->GetFirstSpellInChain(skillLineAbility->Spell));
+
+ for (SkillLineEntry const* childSkillLine : sSkillLineStore)
+ if (childSkillLine->ParentSkillLineID == id)
+ SetSkill(childSkillLine->ID, 0, 0, 0);
// Clear profession lines
- if (GetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1) == id)
- SetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1, 0);
- else if (GetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1 + 1) == id)
- SetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1 + 1, 0);
+ if (GetUInt32Value(ACTIVE_PLAYER_FIELD_PROFESSION_SKILL_LINE) == id)
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_PROFESSION_SKILL_LINE, 0);
+ else if (GetUInt32Value(ACTIVE_PLAYER_FIELD_PROFESSION_SKILL_LINE + 1) == id)
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_PROFESSION_SKILL_LINE + 1, 0);
}
}
else if (newVal) //add
@@ -5565,7 +5547,7 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
uint16 field = i / 2;
uint8 offset = i & 1; // i % 2
- if (!GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_ID_OFFSET + field, offset))
+ if (!GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_ID_OFFSET + field, offset))
{
SkillLineEntry const* skillEntry = sSkillLineStore.LookupEntry(id);
if (!skillEntry)
@@ -5575,18 +5557,30 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
return;
}
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_ID_OFFSET + field, offset, id);
- if (skillEntry->CategoryID == SKILL_CATEGORY_PROFESSION)
+ if (skillEntry->ParentSkillLineID && skillEntry->ParentTierIndex > 0)
{
- if (!GetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1))
- SetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1, id);
- else if (!GetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1 + 1))
- SetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1 + 1, id);
+ if (SkillRaceClassInfoEntry const* rcEntry = sDB2Manager.GetSkillRaceClassInfo(skillEntry->ParentSkillLineID, getRace(), getClass()))
+ {
+ if (SkillTiersEntry const* tier = sObjectMgr->GetSkillTier(rcEntry->SkillTierID))
+ {
+ uint16 skillval = GetPureSkillValue(skillEntry->ParentSkillLineID);
+ SetSkill(skillEntry->ParentSkillLineID, skillEntry->ParentTierIndex, std::max<uint16>(skillval, 1), tier->Value[skillEntry->ParentTierIndex - 1]);
+ }
+ }
+
+ if (skillEntry->CategoryID == SKILL_CATEGORY_PROFESSION)
+ {
+ int32 freeProfessionSlot = FindProfessionSlotFor(id);
+ if (freeProfessionSlot != -1)
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_PROFESSION_SKILL_LINE + freeProfessionSlot, id);
+ }
}
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, step);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, newVal);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, maxVal);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_ID_OFFSET + field, offset, id);
+
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, step);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, newVal);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, maxVal);
UpdateSkillEnchantments(id, currVal, newVal);
UpdateCriteria(CRITERIA_TYPE_REACH_SKILL_LEVEL, id);
@@ -5602,8 +5596,8 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
mSkillStatus.insert(SkillStatusMap::value_type(id, SkillStatusData(i, SKILL_NEW)));
// apply skill bonuses
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset, 0);
// temporary bonuses
AuraEffectList const& mModSkill = GetAuraEffectsByType(SPELL_AURA_MOD_SKILL);
for (AuraEffectList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j)
@@ -5646,7 +5640,7 @@ uint16 Player::GetSkillStep(uint16 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
- return GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_STEP_OFFSET + itr->second.pos / 2, itr->second.pos & 1);
+ return GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_STEP_OFFSET + itr->second.pos / 2, itr->second.pos & 1);
}
uint16 Player::GetSkillValue(uint32 skill) const
@@ -5661,9 +5655,9 @@ uint16 Player::GetSkillValue(uint32 skill) const
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
- int32 result = int32(GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset));
- result += int32(GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset));
- result += int32(GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset));
+ int32 result = int32(GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset));
+ result += int32(GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset));
+ result += int32(GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset));
return result < 0 ? 0 : result;
}
@@ -5679,9 +5673,9 @@ uint16 Player::GetMaxSkillValue(uint32 skill) const
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
- int32 result = int32(GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset));
- result += int32(GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset));
- result += int32(GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset));
+ int32 result = int32(GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset));
+ result += int32(GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset));
+ result += int32(GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset));
return result < 0 ? 0 : result;
}
@@ -5697,7 +5691,7 @@ uint16 Player::GetPureMaxSkillValue(uint32 skill) const
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
- return GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
+ return GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
}
uint16 Player::GetBaseSkillValue(uint32 skill) const
@@ -5712,8 +5706,8 @@ uint16 Player::GetBaseSkillValue(uint32 skill) const
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
- int32 result = int32(GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset));
- result += int32(GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset));
+ int32 result = int32(GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset));
+ result += int32(GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset));
return result < 0 ? 0 : result;
}
@@ -5729,7 +5723,7 @@ uint16 Player::GetPureSkillValue(uint32 skill) const
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
- return GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset);
+ return GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset);
}
int16 Player::GetSkillPermBonusValue(uint32 skill) const
@@ -5744,7 +5738,7 @@ int16 Player::GetSkillPermBonusValue(uint32 skill) const
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
- return GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset);
+ return GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset);
}
int16 Player::GetSkillTempBonusValue(uint32 skill) const
@@ -5759,7 +5753,7 @@ int16 Player::GetSkillTempBonusValue(uint32 skill) const
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
- return GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset);
+ return GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset);
}
void Player::SendActionButtons(uint32 state) const
@@ -5993,11 +5987,11 @@ void Player::CheckAreaExploreAndOutdoor()
}
uint32 val = (uint32)(1 << (areaEntry->AreaBit % 32));
- uint32 currFields = GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
+ uint32 currFields = GetUInt32Value(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + offset);
if (!(currFields & val))
{
- SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields | val));
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + offset, (uint32)(currFields | val));
UpdateCriteria(CRITERIA_TYPE_EXPLORE_AREA);
@@ -6272,14 +6266,14 @@ void Player::UpdateHonorFields()
if (m_lastHonorUpdateTime >= yesterday)
{
// this is the first update today, reset today's contribution
- uint16 killsToday = GetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS);
- SetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS, 0);
- SetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS, killsToday);
+ uint16 killsToday = GetUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS, killsToday);
}
else
{
// no honor/kills yesterday or today, reset
- SetUInt32Value(PLAYER_FIELD_KILLS, 0);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_KILLS, 0);
}
}
@@ -6363,9 +6357,9 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
honor_f = std::ceil(Trinity::Honor::hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey));
// count the number of playerkills in one day
- ApplyModUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS, 1, true);
+ ApplyModUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS, 1, true);
// and those in a lifetime
- ApplyModUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, 1, true);
+ ApplyModUInt32Value(ACTIVE_PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, 1, true);
UpdateCriteria(CRITERIA_TYPE_EARN_HONORABLE_KILL);
UpdateCriteria(CRITERIA_TYPE_HK_CLASS, victim->getClass());
UpdateCriteria(CRITERIA_TYPE_HK_RACE, victim->getRace());
@@ -6443,15 +6437,12 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
return true;
}
-void Player::_InitHonorLevelOnLoadFromDB(uint32 honor, uint32 honorLevel, uint32 prestigeLevel)
+void Player::_InitHonorLevelOnLoadFromDB(uint32 honor, uint32 honorLevel)
{
SetUInt32Value(PLAYER_FIELD_HONOR_LEVEL, honorLevel);
- SetUInt32Value(PLAYER_FIELD_PRESTIGE, prestigeLevel);
UpdateHonorNextLevel();
AddHonorXP(honor);
- if (CanPrestige())
- Prestige();
}
void Player::RewardPlayerWithRewardPack(uint32 rewardPackID)
@@ -6480,12 +6471,12 @@ void Player::RewardPlayerWithRewardPack(RewardPackEntry const* rewardPackEntry)
void Player::AddHonorXP(uint32 xp)
{
- uint32 currentHonorXP = GetUInt32Value(PLAYER_FIELD_HONOR);
- uint32 nextHonorLevelXP = GetUInt32Value(PLAYER_FIELD_HONOR_NEXT_LEVEL);
+ uint32 currentHonorXP = GetUInt32Value(ACTIVE_PLAYER_FIELD_HONOR);
+ uint32 nextHonorLevelXP = GetUInt32Value(ACTIVE_PLAYER_FIELD_HONOR_NEXT_LEVEL);
uint32 newHonorXP = currentHonorXP + xp;
uint32 honorLevel = GetHonorLevel();
- if (xp < 1 || getLevel() < PLAYER_LEVEL_MIN_HONOR || IsMaxHonorLevelAndPrestige())
+ if (xp < 1 || getLevel() < PLAYER_LEVEL_MIN_HONOR || IsMaxHonorLevel())
return;
while (newHonorXP >= nextHonorLevelXP)
@@ -6496,67 +6487,30 @@ void Player::AddHonorXP(uint32 xp)
SetHonorLevel(honorLevel + 1);
honorLevel = GetHonorLevel();
- nextHonorLevelXP = GetUInt32Value(PLAYER_FIELD_HONOR_NEXT_LEVEL);
+ nextHonorLevelXP = GetUInt32Value(ACTIVE_PLAYER_FIELD_HONOR_NEXT_LEVEL);
}
- SetUInt32Value(PLAYER_FIELD_HONOR, IsMaxHonorLevelAndPrestige() ? 0 : newHonorXP);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_HONOR, IsMaxHonorLevel() ? 0 : newHonorXP);
}
void Player::SetHonorLevel(uint8 level)
{
uint8 oldHonorLevel = GetHonorLevel();
- uint8 prestige = GetPrestigeLevel();
if (level == oldHonorLevel)
return;
- uint32 rewardPackID = sDB2Manager.GetRewardPackIDForPvpRewardByHonorLevelAndPrestige(level, prestige);
- RewardPlayerWithRewardPack(rewardPackID);
-
SetUInt32Value(PLAYER_FIELD_HONOR_LEVEL, level);
UpdateHonorNextLevel();
UpdateCriteria(CRITERIA_TYPE_HONOR_LEVEL_REACHED);
-
- // This code is here because no link was found between those items and this reward condition in the db2 files.
- // Interesting CriteriaTree found: Tree ids: 51140, 51156 (criteria id 31773, modifier tree id 37759)
- if (level == 50 && prestige == 1)
- {
- if (GetTeam() == ALLIANCE)
- AddItem(138992, 1);
- else
- AddItem(138996, 1);
- }
-
- if (CanPrestige())
- Prestige();
-}
-
-void Player::Prestige()
-{
- SetUInt32Value(PLAYER_FIELD_PRESTIGE, GetPrestigeLevel() + 1);
- SetUInt32Value(PLAYER_FIELD_HONOR_LEVEL, 1);
- UpdateHonorNextLevel();
-
- UpdateCriteria(CRITERIA_TYPE_PRESTIGE_REACHED);
-}
-
-bool Player::CanPrestige() const
-{
- if (GetSession()->GetExpansion() >= EXPANSION_LEGION && getLevel() >= PLAYER_LEVEL_MIN_HONOR && GetHonorLevel() >= PLAYER_MAX_HONOR_LEVEL && GetPrestigeLevel() < sDB2Manager.GetMaxPrestige())
- return true;
-
- return false;
-}
-
-bool Player::IsMaxPrestige() const
-{
- return GetPrestigeLevel() == sDB2Manager.GetMaxPrestige();
}
void Player::UpdateHonorNextLevel()
{
- uint32 prestige = std::min(static_cast<uint32>(PRESTIGE_COLUMN_COUNT - 1), GetPrestigeLevel());
- SetUInt32Value(PLAYER_FIELD_HONOR_NEXT_LEVEL, sHonorLevelGameTable.GetRow(GetHonorLevel())->Prestige[prestige]);
+ // 5500 at honor level 1
+ // no idea what between here
+ // 8800 at honor level ~14 (never goes above 8800)
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_HONOR_NEXT_LEVEL, 8800);
}
void Player::_LoadCurrency(PreparedQueryResult result)
@@ -6897,12 +6851,11 @@ uint32 Player::GetCurrencyTotalCap(CurrencyTypesEntry const* currency) const
void Player::SetInGuild(ObjectGuid::LowType guildId)
{
if (guildId)
- SetGuidValue(OBJECT_FIELD_DATA, ObjectGuid::Create<HighGuid::Guild>(guildId));
+ SetGuidValue(UNIT_FIELD_GUILD_GUID, ObjectGuid::Create<HighGuid::Guild>(guildId));
else
- SetGuidValue(OBJECT_FIELD_DATA, ObjectGuid::Empty);
+ SetGuidValue(UNIT_FIELD_GUILD_GUID, ObjectGuid::Empty);
ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_GUILD_LEVEL_ENABLED, guildId != 0);
- SetUInt16Value(OBJECT_FIELD_TYPE, 1, guildId != 0);
}
ObjectGuid::LowType Player::GetGuildIdFromDB(ObjectGuid guid)
@@ -6927,7 +6880,7 @@ uint8 Player::GetRankFromDB(ObjectGuid guid)
void Player::SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value)
{
- SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_ARENA_TEAM_INFO + (slot * ARENA_TEAM_END) + type, value);
}
void Player::SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
@@ -7516,6 +7469,9 @@ void Player::_ApplyItemBonuses(Item* item, uint8 slot, bool apply)
case ITEM_MOD_MASTERY_RATING:
ApplyRatingMod(CR_MASTERY, int32(val * combatRatingMultiplier), apply);
break;
+ case ITEM_MOD_EXTRA_ARMOR:
+ HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(val), apply);
+ break;
case ITEM_MOD_FIRE_RESISTANCE:
HandleStatModifier(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(val), apply);
break;
@@ -7597,29 +7553,7 @@ void Player::_ApplyItemBonuses(Item* item, uint8 slot, bool apply)
}
if (uint32 armor = item->GetArmor(this))
- {
- UnitModifierType modType = TOTAL_VALUE;
- if (proto->GetClass() == ITEM_CLASS_ARMOR)
- {
- switch (proto->GetSubClass())
- {
- case ITEM_SUBCLASS_ARMOR_CLOTH:
- case ITEM_SUBCLASS_ARMOR_LEATHER:
- case ITEM_SUBCLASS_ARMOR_MAIL:
- case ITEM_SUBCLASS_ARMOR_PLATE:
- case ITEM_SUBCLASS_ARMOR_SHIELD:
- modType = BASE_VALUE;
- break;
- }
- }
-
- HandleStatModifier(UNIT_MOD_ARMOR, modType, float(armor), apply);
- }
-
- /*
- if (proto->GetArmorDamageModifier() > 0)
- HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(proto->GetArmorDamageModifier()), apply);
- */
+ HandleStatModifier(UNIT_MOD_ARMOR, BASE_VALUE, float(armor), apply);
WeaponAttackType attType = BASE_ATTACK;
@@ -9989,7 +9923,7 @@ void Player::SetInventorySlotCount(uint8 slots)
}
}
- SetByteValue(PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_NUM_BACKPACK_SLOTS, slots);
+ SetByteValue(ACTIVE_PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_NUM_BACKPACK_SLOTS, slots);
}
bool Player::HasItemCount(uint32 item, uint32 count, bool inBankAlso) const
@@ -11883,7 +11817,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool
if (!pBag)
{
m_items[slot] = pItem;
- SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), pItem->GetGUID());
+ SetGuidValue(ACTIVE_PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), pItem->GetGUID());
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID());
pItem->SetOwnerGUID(GetGUID());
@@ -12230,7 +12164,7 @@ void Player::VisualizeItem(uint8 slot, Item* pItem)
GetName().c_str(), GetGUID().ToString().c_str(), slot, pItem->GetEntry());
m_items[slot] = pItem;
- SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), pItem->GetGUID());
+ SetGuidValue(ACTIVE_PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), pItem->GetGUID());
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID());
pItem->SetOwnerGUID(GetGUID());
pItem->SetSlot(slot);
@@ -12310,7 +12244,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update)
}
m_items[slot] = nullptr;
- SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), ObjectGuid::Empty);
+ SetGuidValue(ACTIVE_PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), ObjectGuid::Empty);
if (slot < EQUIPMENT_SLOT_END)
{
@@ -12412,7 +12346,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
if (bag == INVENTORY_SLOT_BAG_0)
{
- SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), ObjectGuid::Empty);
+ SetGuidValue(ACTIVE_PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), ObjectGuid::Empty);
// equipment and equipped bags can have applied bonuses
if (slot < INVENTORY_SLOT_BAG_END)
@@ -13381,7 +13315,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem)
// if current back slot non-empty search oldest or free
if (m_items[slot])
{
- uint32 oldest_time = GetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1);
+ uint32 oldest_time = GetUInt32Value(ACTIVE_PLAYER_FIELD_BUYBACK_TIMESTAMP);
uint32 oldest_slot = BUYBACK_SLOT_START;
for (uint32 i = BUYBACK_SLOT_START+1; i < BUYBACK_SLOT_END; ++i)
@@ -13393,7 +13327,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem)
break;
}
- uint32 i_time = GetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + i - BUYBACK_SLOT_START);
+ uint32 i_time = GetUInt32Value(ACTIVE_PLAYER_FIELD_BUYBACK_TIMESTAMP + i - BUYBACK_SLOT_START);
if (oldest_time > i_time)
{
@@ -13415,13 +13349,13 @@ void Player::AddItemToBuyBackSlot(Item* pItem)
uint32 etime = uint32(base - m_logintime + (30 * 3600));
uint32 eslot = slot - BUYBACK_SLOT_START;
- SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), pItem->GetGUID());
+ SetGuidValue(ACTIVE_PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), pItem->GetGUID());
if (ItemTemplate const* proto = pItem->GetTemplate())
- SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, proto->GetSellPrice() * pItem->GetCount());
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_BUYBACK_PRICE + eslot, proto->GetSellPrice() * pItem->GetCount());
else
- SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_BUYBACK_PRICE + eslot, 0);
- SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, (uint32)etime);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_BUYBACK_TIMESTAMP + eslot, (uint32)etime);
// move to next (for non filled list is move most optimized choice)
if (m_currentBuybackSlot < BUYBACK_SLOT_END - 1)
@@ -13455,9 +13389,9 @@ void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del)
m_items[slot] = nullptr;
uint32 eslot = slot - BUYBACK_SLOT_START;
- SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), ObjectGuid::Empty);
- SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0);
- SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0);
+ SetGuidValue(ACTIVE_PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), ObjectGuid::Empty);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_BUYBACK_PRICE + eslot, 0);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_BUYBACK_TIMESTAMP + eslot, 0);
// if current backslot is filled set to now free slot
if (m_items[m_currentBuybackSlot])
@@ -14648,6 +14582,38 @@ uint32 Player::GetDefaultGossipMenuForSource(WorldObject* source)
/*** QUEST SYSTEM ***/
/*********************************************************/
+int32 Player::GetQuestMinLevel(Quest const* quest) const
+{
+ if (quest->GetQuestLevel() == -1 && quest->GetQuestScalingFactionGroup())
+ {
+ ChrRacesEntry const* race = sChrRacesStore.AssertEntry(getRace());
+ FactionTemplateEntry const* raceFaction = sFactionTemplateStore.LookupEntry(race->FactionID);
+ if (!raceFaction || raceFaction->FactionGroup != quest->GetQuestScalingFactionGroup())
+ return quest->GetQuestMaxScalingLevel();
+ }
+
+ return quest->GetMinLevel();
+}
+
+int32 Player::GetQuestLevel(Quest const* quest) const
+{
+ if (!quest)
+ return 0;
+
+ if (quest->GetQuestLevel() == -1)
+ {
+ int32 minLevel = GetQuestMinLevel(quest);
+ int32 maxLevel = quest->GetQuestMaxScalingLevel();
+ int32 level = getLevel();
+ if (level >= minLevel)
+ return std::min(level, maxLevel);
+
+ return minLevel;
+ }
+
+ return quest->GetQuestLevel();
+}
+
void Player::PrepareQuestMenu(ObjectGuid guid)
{
QuestRelationBounds objectQR;
@@ -14815,7 +14781,7 @@ bool Player::CanSeeStartQuest(Quest const* quest)
SatisfyQuestPrevChain(quest, false) && SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) &&
SatisfyQuestMonth(quest, false) && SatisfyQuestSeasonal(quest, false))
{
- return int32(getLevel() + sWorld->getIntConfig(CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF)) >= quest->GetMinLevel();
+ return int32(getLevel() + sWorld->getIntConfig(CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF)) >= GetQuestMinLevel(quest);
}
return false;
@@ -15241,7 +15207,7 @@ void Player::IncompleteQuest(uint32 quest_id)
uint32 Player::GetQuestMoneyReward(Quest const* quest) const
{
- return quest->MoneyValue(getLevel()) * sWorld->getRate(RATE_MONEY_QUEST);
+ return quest->MoneyValue(this) * sWorld->getRate(RATE_MONEY_QUEST);
}
uint32 Player::GetQuestXPReward(Quest const* quest)
@@ -15252,7 +15218,7 @@ uint32 Player::GetQuestXPReward(Quest const* quest)
if (rewarded && !quest->IsDFQuest())
return 0;
- uint32 XP = quest->XPValue(getLevel()) * sWorld->getRate(RATE_XP_QUEST);
+ uint32 XP = quest->XPValue(this) * sWorld->getRate(RATE_XP_QUEST);
// handle SPELL_AURA_MOD_XP_QUEST_PCT auras
Unit::AuraEffectList const& ModXPPctAuras = GetAuraEffectsByType(SPELL_AURA_MOD_XP_QUEST_PCT);
@@ -15648,7 +15614,7 @@ bool Player::SatisfyQuestSkill(Quest const* qInfo, bool msg) const
bool Player::SatisfyQuestLevel(Quest const* qInfo, bool msg) const
{
- if (getLevel() < qInfo->GetMinLevel())
+ if (getLevel() < GetQuestMinLevel(qInfo))
{
if (msg)
{
@@ -16039,7 +16005,7 @@ bool Player::SatisfyQuestDay(Quest const* qInfo, bool /*msg*/) const
return true;
}
- std::vector<uint32> const& dailies = GetDynamicValues(PLAYER_DYNAMIC_FIELD_DAILY_QUESTS);
+ std::vector<uint32> const& dailies = GetDynamicValues(ACTIVE_PLAYER_DYNAMIC_FIELD_DAILY_QUESTS);
for (uint32 dailyQuestId : dailies)
if (dailyQuestId == qInfo->GetQuestId())
return false;
@@ -16473,7 +16439,7 @@ void Player::SetQuestCompletedBit(uint32 questBit, bool completed)
if (fieldOffset >= QUESTS_COMPLETED_BITS_SIZE)
return;
- ApplyModFlag(PLAYER_FIELD_QUEST_COMPLETED + ((questBit - 1) >> 5), 1 << ((questBit - 1) & 31), completed);
+ ApplyModFlag(ACTIVE_PLAYER_FIELD_QUEST_COMPLETED + ((questBit - 1) >> 5), 1 << ((questBit - 1) & 31), completed);
}
void Player::AreaExploredOrEventHappens(uint32 questId)
@@ -17377,7 +17343,7 @@ void Player::_LoadDeclinedNames(PreparedQueryResult result)
void Player::_LoadArenaTeamInfo(PreparedQueryResult result)
{
// arenateamid, played_week, played_season, personal_rating
- memset((void*)&m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1], 0, sizeof(uint32) * MAX_ARENA_SLOT * ARENA_TEAM_END);
+ memset((void*)&m_uint32Values[ACTIVE_PLAYER_FIELD_ARENA_TEAM_INFO], 0, sizeof(uint32) * MAX_ARENA_SLOT * ARENA_TEAM_END);
uint16 personalRatingCache[] = {0, 0, 0};
@@ -17664,8 +17630,8 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
SetUInt32Value(UNIT_FIELD_LEVEL, fields[6].GetUInt8());
SetXP(fields[7].GetUInt32());
- _LoadIntoDataField(fields[66].GetString(), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE);
- _LoadIntoDataField(fields[67].GetString(), PLAYER__FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE * 2);
+ _LoadIntoDataField(fields[66].GetString(), ACTIVE_PLAYER_FIELD_EXPLORED_ZONES, PLAYER_EXPLORED_ZONES_SIZE);
+ _LoadIntoDataField(fields[67].GetString(), ACTIVE_PLAYER_FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE * 2);
SetObjectScale(1.0f);
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
@@ -17697,7 +17663,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_INEBRIATION, fields[55].GetUInt8());
SetUInt32Value(PLAYER_FLAGS, fields[20].GetUInt32());
SetUInt32Value(PLAYER_FLAGS_EX, fields[21].GetUInt32());
- SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fields[54].GetUInt32());
+ SetInt32Value(ACTIVE_PLAYER_FIELD_WATCHED_FACTION_INDEX, fields[54].GetUInt32());
if (!ValidateAppearance(
fields[3].GetUInt8(), // race
@@ -17715,7 +17681,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
}
// set which actionbars the client has active - DO NOT REMOVE EVER AGAIN (can be changed though, if it does change fieldwise)
- SetByteValue(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_ACTION_BAR_TOGGLES, fields[68].GetUInt8());
+ SetByteValue(ACTIVE_PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_ACTION_BAR_TOGGLES, fields[68].GetUInt8());
m_fishingSteps = fields[72].GetUInt8();
@@ -17724,7 +17690,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
// cleanup inventory related item value fields (it will be filled correctly in _LoadInventory)
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
{
- SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), ObjectGuid::Empty);
+ SetGuidValue(ACTIVE_PLAYER_FIELD_INV_SLOT_HEAD + (slot * 4), ObjectGuid::Empty);
SetVisibleItemSlot(slot, nullptr);
delete m_items[slot];
@@ -17781,9 +17747,9 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
}
_LoadCurrency(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_CURRENCY));
- SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, fields[50].GetUInt32());
- SetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS, fields[51].GetUInt16());
- SetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS, fields[52].GetUInt16());
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, fields[50].GetUInt32());
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS, fields[51].GetUInt16());
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS, fields[52].GetUInt16());
_LoadBoundInstances(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_BOUND_INSTANCES));
_LoadInstanceTimeRestrictions(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_INSTANCE_LOCK_TIMES));
@@ -18113,14 +18079,14 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
SetGuidValue(UNIT_FIELD_CHARMEDBY, ObjectGuid::Empty);
SetGuidValue(UNIT_FIELD_CHARM, ObjectGuid::Empty);
SetGuidValue(UNIT_FIELD_SUMMON, ObjectGuid::Empty);
- SetGuidValue(PLAYER_FARSIGHT, ObjectGuid::Empty);
+ SetGuidValue(ACTIVE_PLAYER_FIELD_FARSIGHT, ObjectGuid::Empty);
SetCreatorGUID(ObjectGuid::Empty);
RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVEMENT);
// reset some aura modifiers before aura apply
- SetUInt32Value(PLAYER_TRACK_CREATURES, 0);
- SetUInt32Value(PLAYER_TRACK_RESOURCES, 0);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_TRACK_CREATURES, 0);
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_TRACK_RESOURCES, 0);
// make sure the unit is considered out of combat for proper loading
ClearInCombat();
@@ -18322,7 +18288,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
SetFlag(OBJECT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND);
if (m_grantableLevels > 0)
- SetByteValue(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_RAF_GRANTABLE_LEVEL, 0x01);
+ SetByteValue(ACTIVE_PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_RAF_GRANTABLE_LEVEL, 0x01);
_LoadDeclinedNames(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_DECLINED_NAMES));
@@ -18339,9 +18305,9 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_GARRISON_FOLLOWER_ABILITIES)))
_garrison = std::move(garrison);
- _InitHonorLevelOnLoadFromDB(fields[73].GetUInt32(), fields[74].GetUInt32(), fields[75].GetUInt32());
+ _InitHonorLevelOnLoadFromDB(fields[73].GetUInt32(), fields[74].GetUInt32());
- _restMgr->LoadRestBonus(REST_TYPE_HONOR, PlayerRestState(fields[76].GetUInt8()), fields[77].GetFloat());
+ _restMgr->LoadRestBonus(REST_TYPE_HONOR, PlayerRestState(fields[75].GetUInt8()), fields[76].GetFloat());
if (time_diff > 0)
{
//speed collect rest bonus in offline, in logout, far from tavern, city (section/in hour)
@@ -18582,7 +18548,7 @@ void Player::LoadCorpse(PreparedQueryResult result)
{
Field* fields = result->Fetch();
_corpseLocation.WorldRelocate(fields[0].GetUInt16(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat());
- ApplyModFlag(PLAYER_FIELD_LOCAL_FLAGS, PLAYER_LOCAL_FLAG_RELEASE_TIMER, !sMapStore.LookupEntry(_corpseLocation.GetMapId())->Instanceable());
+ ApplyModFlag(ACTIVE_PLAYER_FIELD_LOCAL_FLAGS, PLAYER_LOCAL_FLAG_RELEASE_TIMER, !sMapStore.LookupEntry(_corpseLocation.GetMapId())->Instanceable());
}
else
ResurrectPlayer(0.5f);
@@ -19307,7 +19273,7 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result)
if (!quest)
continue;
- AddDynamicValue(PLAYER_DYNAMIC_FIELD_DAILY_QUESTS, quest_id);
+ AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_DAILY_QUESTS, quest_id);
if (uint32 questBit = sDB2Manager.GetQuestUniqueBitFlag(quest_id))
SetQuestCompletedBit(questBit, true);
@@ -19703,7 +19669,7 @@ void Player::SendRaidInfo()
{
InstanceSave* save = itr->second.save;
- WorldPackets::Instance::InstanceLockInfos lockInfos;
+ WorldPackets::Instance::InstanceLock lockInfos;
lockInfos.InstanceID = save->GetInstanceId();
lockInfos.MapID = save->GetMapId();
@@ -19985,7 +19951,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setUInt8(index++, getClass());
stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect
stmt->setUInt8(index++, getLevel());
- stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP));
+ stmt->setUInt32(index++, GetUInt32Value(ACTIVE_PLAYER_FIELD_XP));
stmt->setUInt64(index++, GetMoney());
stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID));
stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID));
@@ -19996,7 +19962,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_CUSTOM_DISPLAY_OPTION + i));
stmt->setUInt8(index++, GetInventorySlotCount());
stmt->setUInt8(index++, GetBankBagSlotCount());
- stmt->setUInt8(index++, uint8(GetUInt32Value(PLAYER_FIELD_REST_INFO + REST_STATE_XP)));
+ stmt->setUInt8(index++, uint8(GetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + REST_STATE_XP)));
stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS));
stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS_EX));
stmt->setUInt16(index++, (uint16)GetMapId());
@@ -20041,11 +20007,11 @@ void Player::SaveToDB(bool create /*=false*/)
ss << m_taxi.SaveTaxiDestinationsToString();
stmt->setString(index++, ss.str());
- stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS));
- stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS));
- stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS));
+ stmt->setUInt32(index++, GetUInt32Value(ACTIVE_PLAYER_FIELD_LIFETIME_HONORABLE_KILLS));
+ stmt->setUInt16(index++, GetUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS));
+ stmt->setUInt16(index++, GetUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS));
stmt->setUInt32(index++, GetUInt32Value(PLAYER_CHOSEN_TITLE));
- stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX));
+ stmt->setUInt32(index++, GetUInt32Value(ACTIVE_PLAYER_FIELD_WATCHED_FACTION_INDEX));
stmt->setUInt8(index++, GetDrunkValue());
stmt->setUInt32(index++, GetHealth());
@@ -20071,7 +20037,7 @@ void Player::SaveToDB(bool create /*=false*/)
ss.str("");
for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
- ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' ';
+ ss << GetUInt32Value(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + i) << ' ';
stmt->setString(index++, ss.str());
ss.str("");
@@ -20096,10 +20062,10 @@ void Player::SaveToDB(bool create /*=false*/)
ss.str("");
for (uint32 i = 0; i < KNOWN_TITLES_SIZE * 2; ++i)
- ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' ';
+ ss << GetUInt32Value(ACTIVE_PLAYER_FIELD_KNOWN_TITLES + i) << ' ';
stmt->setString(index++, ss.str());
- stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_ACTION_BAR_TOGGLES));
+ stmt->setUInt8(index++, GetByteValue(ACTIVE_PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_ACTION_BAR_TOGGLES));
stmt->setUInt32(index++, m_grantableLevels);
stmt->setUInt32(index++, realm.Build);
}
@@ -20112,7 +20078,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setUInt8(index++, getClass());
stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect
stmt->setUInt8(index++, getLevel());
- stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP));
+ stmt->setUInt32(index++, GetUInt32Value(ACTIVE_PLAYER_FIELD_XP));
stmt->setUInt64(index++, GetMoney());
stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID));
stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID));
@@ -20123,7 +20089,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_CUSTOM_DISPLAY_OPTION + i));
stmt->setUInt8(index++, GetInventorySlotCount());
stmt->setUInt8(index++, GetBankBagSlotCount());
- stmt->setUInt8(index++, uint8(GetUInt32Value(PLAYER_FIELD_REST_INFO + REST_STATE_XP)));
+ stmt->setUInt8(index++, uint8(GetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + REST_STATE_XP)));
stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS));
stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS_EX));
@@ -20185,11 +20151,11 @@ void Player::SaveToDB(bool create /*=false*/)
ss << m_taxi.SaveTaxiDestinationsToString();
stmt->setString(index++, ss.str());
- stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS));
- stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS));
- stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS));
+ stmt->setUInt32(index++, GetUInt32Value(ACTIVE_PLAYER_FIELD_LIFETIME_HONORABLE_KILLS));
+ stmt->setUInt16(index++, GetUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS));
+ stmt->setUInt16(index++, GetUInt16Value(ACTIVE_PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS));
stmt->setUInt32(index++, GetUInt32Value(PLAYER_CHOSEN_TITLE));
- stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX));
+ stmt->setUInt32(index++, GetUInt32Value(ACTIVE_PLAYER_FIELD_WATCHED_FACTION_INDEX));
stmt->setUInt8(index++, GetDrunkValue());
stmt->setUInt32(index++, GetHealth());
@@ -20215,7 +20181,7 @@ void Player::SaveToDB(bool create /*=false*/)
ss.str("");
for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
- ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' ';
+ ss << GetUInt32Value(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + i) << ' ';
stmt->setString(index++, ss.str());
ss.str("");
@@ -20240,17 +20206,16 @@ void Player::SaveToDB(bool create /*=false*/)
ss.str("");
for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i)
- ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' ';
+ ss << GetUInt32Value(ACTIVE_PLAYER_FIELD_KNOWN_TITLES + i) << ' ';
stmt->setString(index++, ss.str());
- stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_ACTION_BAR_TOGGLES));
+ stmt->setUInt8(index++, GetByteValue(ACTIVE_PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_ACTION_BAR_TOGGLES));
stmt->setUInt32(index++, m_grantableLevels);
stmt->setUInt8(index++, IsInWorld() && !GetSession()->PlayerLogout() ? 1 : 0);
- stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_HONOR));
+ stmt->setUInt32(index++, GetUInt32Value(ACTIVE_PLAYER_FIELD_HONOR));
stmt->setUInt32(index++, GetHonorLevel());
- stmt->setUInt32(index++, GetPrestigeLevel());
- stmt->setUInt8(index++, uint8(GetUInt32Value(PLAYER_FIELD_REST_INFO + REST_STATE_HONOR)));
+ stmt->setUInt8(index++, uint8(GetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + REST_STATE_HONOR)));
stmt->setFloat(index++, finiteAlways(_restMgr->GetRestBonus(REST_TYPE_HONOR)));
stmt->setUInt32(index++, realm.Build);
@@ -20821,7 +20786,7 @@ void Player::_SaveDailyQuestStatus(SQLTransaction& trans)
stmt->setUInt64(0, GetGUID().GetCounter());
trans->Append(stmt);
- std::vector<uint32> const& dailies = GetDynamicValues(PLAYER_DYNAMIC_FIELD_DAILY_QUESTS);
+ std::vector<uint32> const& dailies = GetDynamicValues(ACTIVE_PLAYER_DYNAMIC_FIELD_DAILY_QUESTS);
for (uint32 questId : dailies)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_QUESTSTATUS_DAILY);
@@ -20945,8 +20910,8 @@ void Player::_SaveSkills(SQLTransaction& trans)
uint16 field = itr->second.pos / 2;
uint8 offset = itr->second.pos & 1;
- uint16 value = GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset);
- uint16 max = GetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
+ uint16 value = GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset);
+ uint16 max = GetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset);
switch (itr->second.uState)
{
@@ -21040,18 +21005,18 @@ void Player::_SaveStats(SQLTransaction& trans) const
stmt->setUInt32(index++, GetStat(Stats(i)));
for (int i = 0; i < MAX_SPELL_SCHOOL; ++i)
- stmt->setUInt32(index++, GetResistance(SpellSchools(i)));
-
- stmt->setFloat(index++, GetFloatValue(PLAYER_BLOCK_PERCENTAGE));
- stmt->setFloat(index++, GetFloatValue(PLAYER_DODGE_PERCENTAGE));
- stmt->setFloat(index++, GetFloatValue(PLAYER_PARRY_PERCENTAGE));
- stmt->setFloat(index++, GetFloatValue(PLAYER_CRIT_PERCENTAGE));
- stmt->setFloat(index++, GetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE));
- stmt->setFloat(index++, GetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1));
+ stmt->setUInt32(index++, GetResistance(SpellSchools(i)) + GetBonusResistanceMod(SpellSchools(i)));
+
+ stmt->setFloat(index++, GetFloatValue(ACTIVE_PLAYER_FIELD_BLOCK_PERCENTAGE));
+ stmt->setFloat(index++, GetFloatValue(ACTIVE_PLAYER_FIELD_DODGE_PERCENTAGE));
+ stmt->setFloat(index++, GetFloatValue(ACTIVE_PLAYER_FIELD_PARRY_PERCENTAGE));
+ stmt->setFloat(index++, GetFloatValue(ACTIVE_PLAYER_FIELD_CRIT_PERCENTAGE));
+ stmt->setFloat(index++, GetFloatValue(ACTIVE_PLAYER_FIELD_RANGED_CRIT_PERCENTAGE));
+ stmt->setFloat(index++, GetFloatValue(ACTIVE_PLAYER_FIELD_SPELL_CRIT_PERCENTAGE1));
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_ATTACK_POWER));
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER));
stmt->setUInt32(index++, GetBaseSpellPowerBonus());
- stmt->setUInt32(index, GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_RESILIENCE_PLAYER_DAMAGE));
+ stmt->setUInt32(index, GetUInt32Value(ACTIVE_PLAYER_FIELD_COMBAT_RATING + CR_RESILIENCE_PLAYER_DAMAGE));
trans->Append(stmt);
}
@@ -21065,10 +21030,10 @@ void Player::outDebugValues() const
TC_LOG_DEBUG("entities.unit", "AGILITY is: \t\t%f\t\tSTRENGTH is: \t\t%f", GetStat(STAT_AGILITY), GetStat(STAT_STRENGTH));
TC_LOG_DEBUG("entities.unit", "INTELLECT is: \t\t%f", GetStat(STAT_INTELLECT));
TC_LOG_DEBUG("entities.unit", "STAMINA is: \t\t%f", GetStat(STAT_STAMINA));
- TC_LOG_DEBUG("entities.unit", "Armor is: \t\t%u\t\tBlock is: \t\t%f", GetArmor(), GetFloatValue(PLAYER_BLOCK_PERCENTAGE));
- TC_LOG_DEBUG("entities.unit", "HolyRes is: \t\t%u\t\tFireRes is: \t\t%u", GetResistance(SPELL_SCHOOL_HOLY), GetResistance(SPELL_SCHOOL_FIRE));
- TC_LOG_DEBUG("entities.unit", "NatureRes is: \t\t%u\t\tFrostRes is: \t\t%u", GetResistance(SPELL_SCHOOL_NATURE), GetResistance(SPELL_SCHOOL_FROST));
- TC_LOG_DEBUG("entities.unit", "ShadowRes is: \t\t%u\t\tArcaneRes is: \t\t%u", GetResistance(SPELL_SCHOOL_SHADOW), GetResistance(SPELL_SCHOOL_ARCANE));
+ TC_LOG_DEBUG("entities.unit", "Armor is: \t\t%u\t\tBlock is: \t\t%f", GetArmor(), GetFloatValue(ACTIVE_PLAYER_FIELD_BLOCK_PERCENTAGE));
+ TC_LOG_DEBUG("entities.unit", "HolyRes is: \t\t%u\t\tFireRes is: \t\t%u", GetResistance(SPELL_SCHOOL_MASK_HOLY), GetResistance(SPELL_SCHOOL_MASK_FIRE));
+ TC_LOG_DEBUG("entities.unit", "NatureRes is: \t\t%u\t\tFrostRes is: \t\t%u", GetResistance(SPELL_SCHOOL_MASK_NATURE), GetResistance(SPELL_SCHOOL_MASK_FROST));
+ TC_LOG_DEBUG("entities.unit", "ShadowRes is: \t\t%u\t\tArcaneRes is: \t\t%u", GetResistance(SPELL_SCHOOL_MASK_SHADOW), GetResistance(SPELL_SCHOOL_MASK_ARCANE));
TC_LOG_DEBUG("entities.unit", "MIN_DAMAGE is: \t\t%f\tMAX_DAMAGE is: \t\t%f", GetFloatValue(UNIT_FIELD_MINDAMAGE), GetFloatValue(UNIT_FIELD_MAXDAMAGE));
TC_LOG_DEBUG("entities.unit", "MIN_OFFHAND_DAMAGE is: \t%f\tMAX_OFFHAND_DAMAGE is: \t%f", GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE), GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE));
TC_LOG_DEBUG("entities.unit", "MIN_RANGED_DAMAGE is: \t%f\tMAX_RANGED_DAMAGE is: \t%f", GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE), GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE));
@@ -22392,6 +22357,8 @@ void Player::InitDisplayIds()
default:
TC_LOG_ERROR("entities.player", "Player::InitDisplayIds: Player '%s' (%s) has invalid gender %u", GetName().c_str(), GetGUID().ToString().c_str(), gender);
}
+
+ SetUInt32Value(UNIT_FIELD_STATE_ANIM_ID, sAnimationDataStore.GetNumRows());
}
inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int64 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore)
@@ -23303,7 +23270,7 @@ bool Player::CanAlwaysSee(WorldObject const* obj) const
if (m_unitMovedByMe == obj)
return true;
- ObjectGuid guid = GetGuidValue(PLAYER_FARSIGHT);
+ ObjectGuid guid = GetGuidValue(ACTIVE_PLAYER_FIELD_FARSIGHT);
if (!guid.IsEmpty())
if (obj->GetGUID() == guid)
return true;
@@ -23575,7 +23542,7 @@ bool Player::HasEnoughMoney(int64 amount) const
void Player::SetMoney(uint64 value)
{
- SetUInt64Value(PLAYER_FIELD_COINAGE, value);
+ SetUInt64Value(ACTIVE_PLAYER_FIELD_COINAGE, value);
MoneyChanged(value);
UpdateCriteria(CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED);
}
@@ -24063,19 +24030,15 @@ void Player::LearnDefaultSkill(SkillRaceClassInfoEntry const* rcInfo)
break;
case SKILL_RANGE_RANK:
{
- uint16 rank = 1;
- if (getClass() == CLASS_DEATH_KNIGHT && skillId == SKILL_FIRST_AID)
- rank = 4;
-
SkillTiersEntry const* tier = sObjectMgr->GetSkillTier(rcInfo->SkillTierID);
- uint16 maxValue = tier->Value[std::max<int32>(rank - 1, 0)];
+ uint16 maxValue = tier->Value[0];
uint16 skillValue = 1;
if (rcInfo->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE)
skillValue = maxValue;
else if (getClass() == CLASS_DEATH_KNIGHT)
skillValue = std::min(std::max(uint16(1), uint16((getLevel() - 1) * 5)), maxValue);
- SetSkill(skillId, rank, skillValue, maxValue);
+ SetSkill(skillId, 1, skillValue, maxValue);
break;
}
default:
@@ -24154,12 +24117,12 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue)
{
uint64 raceMask = getRaceMask();
uint32 classMask = getClassMask();
- for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
- {
- SkillLineAbilityEntry const* ability = sSkillLineAbilityStore.LookupEntry(j);
- if (!ability || ability->SkillLine != int32(skillId))
- continue;
+ std::vector<SkillLineAbilityEntry const*> const* skillLineAbilities = sDB2Manager.GetSkillLineAbilitiesBySkill(skillId);
+ if (!skillLineAbilities)
+ return;
+ for (SkillLineAbilityEntry const* ability : *skillLineAbilities)
+ {
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(ability->Spell);
if (!spellInfo)
continue;
@@ -24194,6 +24157,42 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue)
}
}
+int32 Player::FindProfessionSlotFor(uint32 skillId) const
+{
+ SkillLineEntry const* skillEntry = sSkillLineStore.LookupEntry(skillId);
+ if (!skillEntry)
+ return -1;
+
+ uint32 constexpr professionSlots = 2;
+ uint32 const* professionsBegin = &m_uint32Values[ACTIVE_PLAYER_FIELD_PROFESSION_SKILL_LINE];
+ uint32 const* professionsEnd = professionsBegin + professionSlots;
+
+ // both free, return first slot
+ if (std::none_of(professionsBegin, professionsEnd, [](uint32 slot) { return slot != 0; }))
+ return 0;
+
+ // when any slot is filled we need to check both - one of them might be earlier step of the same profession
+ auto sameProfessionSlot = std::find_if(professionsBegin, professionsEnd, [&](uint32 slot)
+ {
+ if (SkillLineEntry const* slotProfession = sSkillLineStore.LookupEntry(slot))
+ if (slotProfession->ParentSkillLineID == skillEntry->ParentSkillLineID)
+ return true;
+ return false;
+ });
+
+ if (sameProfessionSlot != professionsEnd)
+ {
+ if (sSkillLineStore.AssertEntry(*sameProfessionSlot)->ParentTierIndex < skillEntry->ParentTierIndex)
+ return std::distance(professionsBegin, sameProfessionSlot);
+
+ return -1;
+ }
+
+ // if there is no same profession, find any free slot
+ auto freeSlot = std::find(professionsBegin, professionsEnd, 0u);
+ return freeSlot != professionsEnd ? std::distance(professionsBegin, freeSlot) : -1;
+}
+
void Player::SendAurasForTarget(Unit* target) const
{
if (!target || target->GetVisibleAuras().empty()) // speedup things
@@ -24222,7 +24221,7 @@ void Player::SetDailyQuestStatus(uint32 quest_id)
{
if (!qQuest->IsDFQuest())
{
- AddDynamicValue(PLAYER_DYNAMIC_FIELD_DAILY_QUESTS, quest_id);
+ AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_DAILY_QUESTS, quest_id);
m_lastDailyQuestTime = time(nullptr); // last daily quest time
m_DailyQuestChanged = true;
}
@@ -24240,7 +24239,7 @@ bool Player::IsDailyQuestDone(uint32 quest_id)
bool found = false;
if (sObjectMgr->GetQuestTemplate(quest_id))
{
- std::vector<uint32> const& dailies = GetDynamicValues(PLAYER_DYNAMIC_FIELD_DAILY_QUESTS);
+ std::vector<uint32> const& dailies = GetDynamicValues(ACTIVE_PLAYER_DYNAMIC_FIELD_DAILY_QUESTS);
for (uint32 dailyQuestId : dailies)
{
if (dailyQuestId == quest_id)
@@ -24278,15 +24277,15 @@ void Player::SetMonthlyQuestStatus(uint32 quest_id)
void Player::DailyReset()
{
- for (uint32 questId : GetDynamicValues(PLAYER_DYNAMIC_FIELD_DAILY_QUESTS))
+ for (uint32 questId : GetDynamicValues(ACTIVE_PLAYER_DYNAMIC_FIELD_DAILY_QUESTS))
if (uint32 questBit = sDB2Manager.GetQuestUniqueBitFlag(questId))
SetQuestCompletedBit(questBit, false);
WorldPackets::Quest::DailyQuestsReset dailyQuestsReset;
- dailyQuestsReset.Count = int32(GetDynamicValues(PLAYER_DYNAMIC_FIELD_DAILY_QUESTS).size());
+ dailyQuestsReset.Count = int32(GetDynamicValues(ACTIVE_PLAYER_DYNAMIC_FIELD_DAILY_QUESTS).size());
SendDirectMessage(dailyQuestsReset.Write());
- ClearDynamicValue(PLAYER_DYNAMIC_FIELD_DAILY_QUESTS);
+ ClearDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_DAILY_QUESTS);
m_DFQuests.clear(); // Dungeon Finder Quests.
@@ -24506,7 +24505,7 @@ Player* Player::GetTrader() const
bool Player::IsSpellFitByClassAndRace(uint32 spell_id) const
{
- uint32 racemask = getRaceMask();
+ uint64 racemask = getRaceMask();
uint32 classmask = getClassMask();
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spell_id);
@@ -24801,10 +24800,10 @@ bool Player::CanNoReagentCast(SpellInfo const* spellInfo) const
// Check no reagent use mask
flag128 noReagentMask;
- noReagentMask[0] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1);
- noReagentMask[1] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 1);
- noReagentMask[2] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 2);
- noReagentMask[3] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 3);
+ noReagentMask[0] = GetUInt32Value(ACTIVE_PLAYER_FIELD_NO_REAGENT_COST);
+ noReagentMask[1] = GetUInt32Value(ACTIVE_PLAYER_FIELD_NO_REAGENT_COST + 1);
+ noReagentMask[2] = GetUInt32Value(ACTIVE_PLAYER_FIELD_NO_REAGENT_COST + 2);
+ noReagentMask[3] = GetUInt32Value(ACTIVE_PLAYER_FIELD_NO_REAGENT_COST + 3);
if (spellInfo->SpellFamilyFlags & noReagentMask)
return true;
@@ -24845,7 +24844,7 @@ void Player::RemoveItemDependentAurasAndCasts(Item* pItem)
void Player::InitializeSelfResurrectionSpells()
{
- ClearDynamicValue(PLAYER_DYNAMIC_FIELD_SELF_RES_SPELLS);
+ ClearDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_SELF_RES_SPELLS);
uint32 spells[3] = { };
@@ -24866,7 +24865,7 @@ void Player::InitializeSelfResurrectionSpells()
for (uint32 selfResSpell : spells)
if (selfResSpell)
- AddDynamicValue(PLAYER_DYNAMIC_FIELD_SELF_RES_SPELLS, selfResSpell);
+ AddDynamicValue(ACTIVE_PLAYER_DYNAMIC_FIELD_SELF_RES_SPELLS, selfResSpell);
}
// Used in triggers for check "Only to targets that grant experience or honor" req
@@ -25439,7 +25438,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
TC_LOG_DEBUG("maps", "Player::CreateViewpoint: Player '%s' (%s) creates seer (Entry: %u, TypeId: %u).",
GetName().c_str(), GetGUID().ToString().c_str(), target->GetEntry(), target->GetTypeId());
- if (!AddGuidValue(PLAYER_FARSIGHT, target->GetGUID()))
+ if (!AddGuidValue(ACTIVE_PLAYER_FIELD_FARSIGHT, target->GetGUID()))
{
TC_LOG_FATAL("entities.player", "Player::CreateViewpoint: Player '%s' (%s) cannot add new viewpoint!", GetName().c_str(), GetGUID().ToString().c_str());
return;
@@ -25456,7 +25455,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
{
TC_LOG_DEBUG("maps", "Player::CreateViewpoint: Player %s removed seer", GetName().c_str());
- if (!RemoveGuidValue(PLAYER_FARSIGHT, target->GetGUID()))
+ if (!RemoveGuidValue(ACTIVE_PLAYER_FIELD_FARSIGHT, target->GetGUID()))
{
TC_LOG_FATAL("entities.player", "Player::CreateViewpoint: Player '%s' (%s) cannot remove current viewpoint!", GetName().c_str(), GetGUID().ToString().c_str());
return;
@@ -25475,7 +25474,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
WorldObject* Player::GetViewpoint() const
{
- ObjectGuid guid = GetGuidValue(PLAYER_FARSIGHT);
+ ObjectGuid guid = GetGuidValue(ACTIVE_PLAYER_FIELD_FARSIGHT);
if (!guid.IsEmpty())
return static_cast<WorldObject*>(ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_SEER));
return nullptr;
@@ -25577,7 +25576,7 @@ bool Player::HasTitle(uint32 bitIndex) const
uint32 fieldIndexOffset = bitIndex / 32;
uint32 flag = 1 << (bitIndex % 32);
- return HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag);
+ return HasFlag(ACTIVE_PLAYER_FIELD_KNOWN_TITLES + fieldIndexOffset, flag);
}
bool Player::HasTitle(CharTitlesEntry const* title) const
@@ -25592,17 +25591,17 @@ void Player::SetTitle(CharTitlesEntry const* title, bool lost)
if (lost)
{
- if (!HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag))
+ if (!HasFlag(ACTIVE_PLAYER_FIELD_KNOWN_TITLES + fieldIndexOffset, flag))
return;
- RemoveFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag);
+ RemoveFlag(ACTIVE_PLAYER_FIELD_KNOWN_TITLES + fieldIndexOffset, flag);
}
else
{
- if (HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag))
+ if (HasFlag(ACTIVE_PLAYER_FIELD_KNOWN_TITLES + fieldIndexOffset, flag))
return;
- SetFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag);
+ SetFlag(ACTIVE_PLAYER_FIELD_KNOWN_TITLES + fieldIndexOffset, flag);
}
WorldPackets::Character::TitleEarned packet(lost ? SMSG_TITLE_LOST : SMSG_TITLE_EARNED);
@@ -25834,7 +25833,6 @@ void Player::_LoadSkills(PreparedQueryResult result)
// SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", GUID_LOPART(m_guid));
uint32 count = 0;
- uint8 professionCount = 0;
std::unordered_map<uint32, uint32> loadedSkillValues;
if (result)
{
@@ -25888,7 +25886,7 @@ void Player::_LoadSkills(PreparedQueryResult result)
uint16 field = count / 2;
uint8 offset = count & 1;
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_ID_OFFSET + field, offset, skill);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_ID_OFFSET + field, offset, skill);
uint16 step = 0;
SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(rcEntry->SkillID);
@@ -25901,16 +25899,20 @@ void Player::_LoadSkills(PreparedQueryResult result)
{
step = max / 75;
- if (professionCount < 2)
- SetUInt32Value(PLAYER_PROFESSION_SKILL_LINE_1 + professionCount++, skill);
+ if (skillLine->ParentSkillLineID && skillLine->ParentTierIndex)
+ {
+ int32 professionSlot = FindProfessionSlotFor(skill);
+ if (professionSlot != -1)
+ SetUInt32Value(ACTIVE_PLAYER_FIELD_PROFESSION_SKILL_LINE + professionSlot, skill);
+ }
}
}
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, step);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, value);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, max);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, step);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, value);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, max);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset, 0);
mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(count, SKILL_UNCHANGED)));
loadedSkillValues[skill] = value;
@@ -25939,12 +25941,12 @@ void Player::_LoadSkills(PreparedQueryResult result)
uint16 field = count / 2;
uint8 offset = count & 1;
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_ID_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset, 0);
- SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_ID_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_STEP_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_RANK_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_MAX_RANK_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_TEMP_BONUS_OFFSET + field, offset, 0);
+ SetUInt16Value(ACTIVE_PLAYER_FIELD_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset, 0);
}
}
@@ -26151,7 +26153,7 @@ TalentLearnResult Player::LearnTalent(uint32 talentId, int32* spellOnCooldown)
return TALENT_FAILED_UNKNOWN;
// check if we have enough talent points
- if (talentInfo->TierID >= GetUInt32Value(PLAYER_FIELD_MAX_TALENT_TIERS))
+ if (talentInfo->TierID >= GetUInt32Value(ACTIVE_PLAYER_FIELD_MAX_TALENT_TIERS))
return TALENT_FAILED_UNKNOWN;
// TODO: prevent changing talents that are on cooldown
@@ -26243,62 +26245,59 @@ void Player::ResetTalentSpecialization()
UpdateItemSetAuras(false);
}
-TalentLearnResult Player::LearnPvpTalent(uint32 talentID, int32* spellOnCooldown)
+TalentLearnResult Player::LearnPvpTalent(uint32 talentID, uint8 slot, int32* spellOnCooldown)
{
+ if (slot >= MAX_PVP_TALENT_SLOTS)
+ return TALENT_FAILED_UNKNOWN;
+
if (IsInCombat())
return TALENT_FAILED_AFFECTING_COMBAT;
- if (getLevel() < PLAYER_LEVEL_MIN_HONOR)
- return TALENT_FAILED_UNKNOWN;
+ if (isDead())
+ return TALENT_FAILED_CANT_DO_THAT_RIGHT_NOW;
PvpTalentEntry const* talentInfo = sPvpTalentStore.LookupEntry(talentID);
if (!talentInfo)
return TALENT_FAILED_UNKNOWN;
- if (talentInfo->SpecID)
- {
- if (talentInfo->SpecID != GetInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID))
- return TALENT_FAILED_UNKNOWN;
- }
- else if (talentInfo->Role >= 0)
- {
- if (talentInfo->Role != sChrSpecializationStore.AssertEntry(GetUInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID))->Role)
- return TALENT_FAILED_UNKNOWN;
- }
+ if (talentInfo->SpecID != GetInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID))
+ return TALENT_FAILED_UNKNOWN;
- // prevent learn talent for different class (cheating)
- if (talentInfo->ClassID && talentInfo->ClassID != getClass())
+ if (talentInfo->LevelRequired > getLevel())
+ return TALENT_FAILED_UNKNOWN;
+
+ if (sDB2Manager.GetRequiredLevelForPvpTalentSlot(slot, Classes(getClass())) > getLevel())
return TALENT_FAILED_UNKNOWN;
- if (!GetPrestigeLevel())
- if (sDB2Manager.GetRequiredHonorLevelForPvpTalent(talentInfo) > GetHonorLevel())
+ if (PvpTalentCategoryEntry const* talentCategory = sPvpTalentCategoryStore.LookupEntry(talentInfo->PvpTalentCategoryID))
+ if (!(talentCategory->TalentSlotMask & (1 << slot)))
return TALENT_FAILED_UNKNOWN;
- // Check if player doesn't have any talent in current tier
- for (uint32 c = 0; c < MAX_PVP_TALENT_COLUMNS; ++c)
- {
- for (PvpTalentEntry const* talent : sDB2Manager.GetPvpTalentsByPosition(getClass(), talentInfo->TierID, c))
- {
- if (HasPvpTalent(talent->ID, GetActiveTalentGroup()) && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
- return TALENT_FAILED_REST_AREA;
+ // Check if player doesn't have this talent in other slot
+ if (HasPvpTalent(talentID, GetActiveTalentGroup()))
+ return TALENT_FAILED_UNKNOWN;
- if (GetSpellHistory()->HasCooldown(talent->SpellID))
- {
- *spellOnCooldown = talent->SpellID;
- return TALENT_FAILED_CANT_REMOVE_TALENT;
- }
+ if (PvpTalentEntry const* talent = sPvpTalentStore.LookupEntry(GetPvpTalentMap(GetActiveTalentGroup())[slot]))
+ {
+ if (!HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) && !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHANGING_TALENTS))
+ return TALENT_FAILED_REST_AREA;
- RemovePvpTalent(talent);
+ if (GetSpellHistory()->HasCooldown(talent->SpellID))
+ {
+ *spellOnCooldown = talent->SpellID;
+ return TALENT_FAILED_CANT_REMOVE_TALENT;
}
+
+ RemovePvpTalent(talent);
}
- if (!AddPvpTalent(talentInfo, GetActiveTalentGroup(), true))
+ if (!AddPvpTalent(talentInfo, GetActiveTalentGroup(), slot))
return TALENT_FAILED_UNKNOWN;
return TALENT_LEARN_OK;
}
-bool Player::AddPvpTalent(PvpTalentEntry const* talent, uint8 activeTalentGroup, bool learning)
+bool Player::AddPvpTalent(PvpTalentEntry const* talent, uint8 activeTalentGroup, uint8 slot)
{
ASSERT(talent);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(talent->SpellID);
@@ -26321,11 +26320,7 @@ bool Player::AddPvpTalent(PvpTalentEntry const* talent, uint8 activeTalentGroup,
if (talent->OverridesSpellID)
AddOverrideSpell(talent->OverridesSpellID, talent->SpellID);
- PlayerTalentMap::iterator itr = GetPvpTalentMap(activeTalentGroup)->find(talent->ID);
- if (itr != GetPvpTalentMap(activeTalentGroup)->end())
- itr->second = PLAYERSPELL_UNCHANGED;
- else
- (*GetPvpTalentMap(activeTalentGroup))[talent->ID] = learning ? PLAYERSPELL_NEW : PLAYERSPELL_UNCHANGED;
+ GetPvpTalentMap(activeTalentGroup)[slot] = talent->ID;
return true;
}
@@ -26343,28 +26338,29 @@ void Player::RemovePvpTalent(PvpTalentEntry const* talent)
RemoveOverrideSpell(talent->OverridesSpellID, talent->SpellID);
// if this talent rank can be found in the PlayerTalentMap, mark the talent as removed so it gets deleted
- PlayerTalentMap::iterator plrPvpTalent = GetPvpTalentMap(GetActiveTalentGroup())->find(talent->ID);
- if (plrPvpTalent != GetPvpTalentMap(GetActiveTalentGroup())->end())
- plrPvpTalent->second = PLAYERSPELL_REMOVED;
+ auto plrPvpTalent = std::find(GetPvpTalentMap(GetActiveTalentGroup()).begin(), GetPvpTalentMap(GetActiveTalentGroup()).end(), talent->ID);
+ if (plrPvpTalent != GetPvpTalentMap(GetActiveTalentGroup()).end())
+ *plrPvpTalent = 0;
}
void Player::TogglePvpTalents(bool enable)
{
- PlayerTalentMap const* pvpTalents = GetPvpTalentMap(GetActiveTalentGroup());
- for (PlayerTalentMap::value_type const& v : *pvpTalents)
+ PlayerPvpTalentMap const& pvpTalents = GetPvpTalentMap(GetActiveTalentGroup());
+ for (uint32 pvpTalentId : pvpTalents)
{
- PvpTalentEntry const* pvpTalentInfo = sPvpTalentStore.AssertEntry(v.first);
- if (enable && v.second != PLAYERSPELL_REMOVED)
- LearnSpell(pvpTalentInfo->SpellID, false);
- else
- RemoveSpell(pvpTalentInfo->SpellID, true);
+ if (PvpTalentEntry const* pvpTalentInfo = sPvpTalentStore.LookupEntry(pvpTalentId))
+ {
+ if (enable)
+ LearnSpell(pvpTalentInfo->SpellID, false);
+ else
+ RemoveSpell(pvpTalentInfo->SpellID, true);
+ }
}
}
bool Player::HasPvpTalent(uint32 talentID, uint8 activeTalentGroup) const
{
- PlayerTalentMap::const_iterator itr = GetPvpTalentMap(activeTalentGroup)->find(talentID);
- return (itr != GetPvpTalentMap(activeTalentGroup)->end() && itr->second != PLAYERSPELL_REMOVED);
+ return std::find(GetPvpTalentMap(activeTalentGroup).begin(), GetPvpTalentMap(activeTalentGroup).end(), talentID) != GetPvpTalentMap(activeTalentGroup).end();
}
void Player::EnablePvpRules(bool dueToCombat /*= false*/)
@@ -26522,12 +26518,11 @@ void Player::SendTalentsInfoData()
continue;
PlayerTalentMap* talents = GetTalentMap(i);
- PlayerTalentMap* pvpTalents = GetPvpTalentMap(i);
+ PlayerPvpTalentMap const& pvpTalents = GetPvpTalentMap(i);
WorldPackets::Talent::TalentGroupInfo groupInfoPkt;
groupInfoPkt.SpecID = spec->ID;
groupInfoPkt.TalentIDs.reserve(talents->size());
- groupInfoPkt.PvPTalentIDs.reserve(pvpTalents->size());
for (PlayerTalentMap::const_iterator itr = talents->begin(); itr != talents->end(); ++itr)
{
@@ -26542,9 +26537,6 @@ void Player::SendTalentsInfoData()
continue;
}
- if (talentInfo->ClassID != getClass())
- continue;
-
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(talentInfo->SpellID);
if (!spellEntry)
{
@@ -26556,22 +26548,19 @@ void Player::SendTalentsInfoData()
groupInfoPkt.TalentIDs.push_back(uint16(itr->first));
}
- for (PlayerTalentMap::const_iterator itr = pvpTalents->begin(); itr != pvpTalents->end(); ++itr)
+ for (std::size_t slot = 0; slot < MAX_PVP_TALENT_SLOTS; ++slot)
{
- if (itr->second == PLAYERSPELL_REMOVED)
+ if (!pvpTalents[slot])
continue;
- PvpTalentEntry const* talentInfo = sPvpTalentStore.LookupEntry(itr->first);
+ PvpTalentEntry const* talentInfo = sPvpTalentStore.LookupEntry(pvpTalents[slot]);
if (!talentInfo)
{
TC_LOG_ERROR("entities.player", "Player::SendTalentsInfoData: Player '%s' (%s) has unknown pvp talent id: %u",
- GetName().c_str(), GetGUID().ToString().c_str(), itr->first);
+ GetName().c_str(), GetGUID().ToString().c_str(), pvpTalents[slot]);
continue;
}
- if (talentInfo->ClassID && talentInfo->ClassID != getClass())
- continue;
-
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(talentInfo->SpellID);
if (!spellEntry)
{
@@ -26580,7 +26569,10 @@ void Player::SendTalentsInfoData()
continue;
}
- groupInfoPkt.PvPTalentIDs.push_back(uint16(itr->first));
+ groupInfoPkt.PvPTalents.emplace_back();
+ WorldPackets::Talent::PvPTalent& pvpTalent = groupInfoPkt.PvPTalents.back();
+ pvpTalent.PvPTalentID = pvpTalents[slot];
+ pvpTalent.Slot = slot;
}
packet.Info.TalentGroups.push_back(groupInfoPkt);
@@ -26859,12 +26851,13 @@ void Player::_LoadTalents(PreparedQueryResult result)
void Player::_LoadPvpTalents(PreparedQueryResult result)
{
- // "SELECT TalentID, TalentGroup FROM character_pvp_talent WHERE guid = ?"
+ // "SELECT talentID0, talentID1, talentID2, talentID3, talentGroup FROM character_pvp_talent WHERE guid = ?"
if (result)
{
do
- if (PvpTalentEntry const* talent = sPvpTalentStore.LookupEntry((*result)[0].GetUInt32()))
- AddPvpTalent(talent, (*result)[1].GetUInt8(), false);
+ for (uint8 slot = 0; slot < MAX_PVP_TALENT_SLOTS; ++slot)
+ if (PvpTalentEntry const* talent = sPvpTalentStore.LookupEntry((*result)[slot].GetUInt32()))
+ AddPvpTalent(talent, (*result)[4].GetUInt8(), slot);
while (result->NextRow());
}
}
@@ -26875,11 +26868,10 @@ void Player::_SaveTalents(SQLTransaction& trans)
stmt->setUInt64(0, GetGUID().GetCounter());
trans->Append(stmt);
- PlayerTalentMap* talents;
for (uint8 group = 0; group < MAX_SPECIALIZATIONS; ++group)
{
- talents = GetTalentMap(group);
- for (PlayerTalentMap::iterator itr = talents->begin(); itr != talents->end();)
+ PlayerTalentMap* talents = GetTalentMap(group);
+ for (auto itr = talents->begin(); itr != talents->end();)
{
if (itr->second == PLAYERSPELL_REMOVED)
{
@@ -26902,22 +26894,15 @@ void Player::_SaveTalents(SQLTransaction& trans)
for (uint8 group = 0; group < MAX_SPECIALIZATIONS; ++group)
{
- talents = GetPvpTalentMap(group);
- for (PlayerTalentMap::iterator itr = talents->begin(); itr != talents->end();)
- {
- if (itr->second == PLAYERSPELL_REMOVED)
- {
- itr = talents->erase(itr);
- continue;
- }
-
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_PVP_TALENT);
- stmt->setUInt64(0, GetGUID().GetCounter());
- stmt->setUInt32(1, itr->first);
- stmt->setUInt8(2, group);
- trans->Append(stmt);
- ++itr;
- }
+ PlayerPvpTalentMap const& talents = GetPvpTalentMap(group);
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_PVP_TALENT);
+ stmt->setUInt64(0, GetGUID().GetCounter());
+ stmt->setUInt32(1, talents[0]);
+ stmt->setUInt32(2, talents[1]);
+ stmt->setUInt32(3, talents[2]);
+ stmt->setUInt32(4, talents[3]);
+ stmt->setUInt8(5, group);
+ trans->Append(stmt);
}
}
@@ -27001,15 +26986,6 @@ void Player::ActivateTalentGroup(ChrSpecializationEntry const* spec)
if (!talentInfo)
continue;
- // unlearn only talents for character class
- // some spell learned by one class as normal spells or know at creation but another class learn it as talent,
- // to prevent unexpected lost normal learned spell skip another class talents
- if (talentInfo->ClassID && talentInfo->ClassID != getClass())
- continue;
-
- if (talentInfo->SpellID == 0)
- continue;
-
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(talentInfo->SpellID);
if (!spellInfo)
continue;
@@ -27058,21 +27034,16 @@ void Player::ActivateTalentGroup(ChrSpecializationEntry const* spec)
}
}
- for (uint32 pvpTalentID = 0; pvpTalentID < sTalentStore.GetNumRows(); ++pvpTalentID)
+ for (uint8 slot = 0; slot < MAX_PVP_TALENT_SLOTS; ++slot)
{
- PvpTalentEntry const* talentInfo = sPvpTalentStore.LookupEntry(pvpTalentID);
+ PvpTalentEntry const* talentInfo = sPvpTalentStore.LookupEntry(GetPvpTalentMap(GetActiveTalentGroup())[slot]);
if (!talentInfo)
continue;
- // learn only talents for character class (or x-class talents)
- if (talentInfo->ClassID && talentInfo->ClassID != getClass())
- continue;
-
if (!talentInfo->SpellID)
continue;
- if (HasPvpTalent(talentInfo->ID, GetActiveTalentGroup()))
- AddPvpTalent(talentInfo, GetActiveTalentGroup(), true);
+ AddPvpTalent(talentInfo, GetActiveTalentGroup(), slot);
}
LearnSpecializationSpells();
@@ -27622,6 +27593,7 @@ void Player::SendPlayerChoice(ObjectGuid sender, int32 choiceId)
displayPlayerChoice.Responses.resize(playerChoice->Responses.size());
displayPlayerChoice.CloseChoiceFrame = false;
displayPlayerChoice.HideWarboardHeader = playerChoice->HideWarboardHeader;
+ displayPlayerChoice.KeepOpenAfterChoice = playerChoice->KeepOpenAfterChoice;
for (std::size_t i = 0; i < playerChoice->Responses.size(); ++i)
{
@@ -27629,6 +27601,9 @@ void Player::SendPlayerChoice(ObjectGuid sender, int32 choiceId)
WorldPackets::Quest::PlayerChoiceResponse& playerChoiceResponse = displayPlayerChoice.Responses[i];
playerChoiceResponse.ResponseID = playerChoiceResponseTemplate.ResponseId;
playerChoiceResponse.ChoiceArtFileID = playerChoiceResponseTemplate.ChoiceArtFileId;
+ playerChoiceResponse.Flags = playerChoiceResponseTemplate.Flags;
+ playerChoiceResponse.WidgetSetID = playerChoiceResponseTemplate.WidgetSetID;
+ playerChoiceResponse.GroupID = playerChoiceResponseTemplate.GroupID;
playerChoiceResponse.Answer = playerChoiceResponseTemplate.Answer;
playerChoiceResponse.Header = playerChoiceResponseTemplate.Header;
playerChoiceResponse.Description = playerChoiceResponseTemplate.Description;
@@ -27953,29 +27928,6 @@ void Player::SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const
GetSession()->SendPacket(supercededSpells.Write());
}
-uint32 Player::CalculateTalentsTiers() const
-{
- uint32 const* rowLevels;
- switch (getClass())
- {
- case CLASS_DEATH_KNIGHT:
- rowLevels = DKTalentRowLevels;
- break;
- case CLASS_DEMON_HUNTER:
- rowLevels = DHTalentRowLevels;
- break;
- default:
- rowLevels = DefaultTalentRowLevels;
- break;
- }
-
- for (uint32 i = MAX_TALENT_TIERS; i; --i)
- if (getLevel() >= rowLevels[i - 1])
- return i;
-
- return 0;
-}
-
Difficulty Player::GetDifficultyID(MapEntry const* mapEntry) const
{
if (!mapEntry->IsRaid())
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index eb12abc021c..391fbb34be3 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -101,16 +101,23 @@ namespace WorldPackets
typedef std::deque<Mail*> PlayerMails;
-#define PLAYER_MAX_SKILLS 128
-enum SkillFieldOffset
+#define PLAYER_MAX_SKILLS 256
+
+template<typename SkillArrayType>
+constexpr std::size_t CalculateSkillFieldArraySize()
{
- SKILL_ID_OFFSET = 0,
- SKILL_STEP_OFFSET = 64,
- SKILL_RANK_OFFSET = SKILL_STEP_OFFSET + 64,
- SUBSKILL_START_RANK_OFFSET = SKILL_RANK_OFFSET + 64,
- SKILL_MAX_RANK_OFFSET = SUBSKILL_START_RANK_OFFSET + 64,
- SKILL_TEMP_BONUS_OFFSET = SKILL_MAX_RANK_OFFSET + 64,
- SKILL_PERM_BONUS_OFFSET = SKILL_TEMP_BONUS_OFFSET + 64
+ return PLAYER_MAX_SKILLS / sizeof(uint32) * sizeof(SkillArrayType);
+}
+
+enum SkillFieldOffset : uint16
+{
+ SKILL_ID_OFFSET = 0,
+ SKILL_STEP_OFFSET = SKILL_ID_OFFSET + CalculateSkillFieldArraySize<uint16>(),
+ SKILL_RANK_OFFSET = SKILL_STEP_OFFSET + CalculateSkillFieldArraySize<uint16>(),
+ SUBSKILL_START_RANK_OFFSET = SKILL_RANK_OFFSET + CalculateSkillFieldArraySize<uint16>(),
+ SKILL_MAX_RANK_OFFSET = SUBSKILL_START_RANK_OFFSET + CalculateSkillFieldArraySize<uint16>(),
+ SKILL_TEMP_BONUS_OFFSET = SKILL_MAX_RANK_OFFSET + CalculateSkillFieldArraySize<uint16>(),
+ SKILL_PERM_BONUS_OFFSET = SKILL_TEMP_BONUS_OFFSET + CalculateSkillFieldArraySize<uint16>()
};
#define PLAYER_EXPLORED_ZONES_SIZE 320
@@ -240,6 +247,7 @@ struct PlayerCurrency
};
typedef std::unordered_map<uint32, PlayerSpellState> PlayerTalentMap;
+typedef std::array<uint32, MAX_PVP_TALENT_SLOTS> PlayerPvpTalentMap;
typedef std::unordered_map<uint32, PlayerSpell*> PlayerSpellMap;
typedef std::unordered_set<SpellModifier*> SpellModContainer;
typedef std::unordered_map<uint32, PlayerCurrency> PlayerCurrenciesMap;
@@ -391,7 +399,7 @@ enum PlayerFlags
PLAYER_FLAGS_GM = 0x00000008,
PLAYER_FLAGS_GHOST = 0x00000010,
PLAYER_FLAGS_RESTING = 0x00000020,
- PLAYER_FLAGS_UNK6 = 0x00000040,
+ PLAYER_FLAGS_VOICE_CHAT = 0x00000040,
PLAYER_FLAGS_UNK7 = 0x00000080, // pre-3.0.3 PLAYER_FLAGS_FFA_PVP flag for FFA PVP state
PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards
PLAYER_FLAGS_IN_PVP = 0x00000200,
@@ -422,7 +430,8 @@ enum PlayerFlags
enum PlayerFlagsEx
{
PLAYER_FLAGS_EX_REAGENT_BANK_UNLOCKED = 0x0001,
- PLAYER_FLAGS_EX_MERCENARY_MODE = 0x0002
+ PLAYER_FLAGS_EX_MERCENARY_MODE = 0x0002,
+ PLAYER_FLAGS_EX_ARTIFACT_FORGE_CHEAT = 0x0004
};
enum PlayerLocalFlags
@@ -1001,10 +1010,6 @@ enum TalentLearnResult
TALENT_FAILED_REST_AREA = 8
};
-static uint32 const DefaultTalentRowLevels[MAX_TALENT_TIERS] = { 15, 30, 45, 60, 75, 90, 100 };
-static uint32 const DKTalentRowLevels[MAX_TALENT_TIERS] = { 57, 58, 59, 60, 75, 90, 100 };
-static uint32 const DHTalentRowLevels[MAX_TALENT_TIERS] = { 99, 100, 102, 104, 106, 108, 110 };
-
struct TC_GAME_API SpecializationInfo
{
SpecializationInfo() : ResetTalentsCost(0), ResetTalentsTime(0), PrimarySpecialization(0), ActiveGroup(0)
@@ -1012,7 +1017,7 @@ struct TC_GAME_API SpecializationInfo
}
PlayerTalentMap Talents[MAX_SPECIALIZATIONS];
- PlayerTalentMap PvpTalents[MAX_SPECIALIZATIONS];
+ PlayerPvpTalentMap PvpTalents[MAX_SPECIALIZATIONS];
std::vector<uint32> Glyphs[MAX_SPECIALIZATIONS];
uint32 ResetTalentsCost;
time_t ResetTalentsTime;
@@ -1033,7 +1038,7 @@ struct PlayerDynamicFieldSpellModByLabel
};
#pragma pack(pop)
-uint8 constexpr PLAYER_MAX_HONOR_LEVEL = 50;
+uint32 constexpr PLAYER_MAX_HONOR_LEVEL = 500;
uint8 constexpr PLAYER_LEVEL_MIN_HONOR = 110;
uint32 constexpr SPELL_PVP_RULES_ENABLED = 134735;
@@ -1188,7 +1193,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
static bool IsChildEquipmentPos(uint8 bag, uint8 slot);
bool IsValidPos(uint16 pos, bool explicit_pos) const { return IsValidPos(pos >> 8, pos & 255, explicit_pos); }
bool IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const;
- uint8 GetInventorySlotCount() const { return GetByteValue(PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_NUM_BACKPACK_SLOTS); }
+ uint8 GetInventorySlotCount() const { return GetByteValue(ACTIVE_PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_NUM_BACKPACK_SLOTS); }
void SetInventorySlotCount(uint8 slots);
uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_BANK_BAG_SLOTS); }
void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_BANK_BAG_SLOTS, count); }
@@ -1349,13 +1354,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
/*** QUEST SYSTEM ***/
/*********************************************************/
- int32 GetQuestLevel(Quest const* quest) const
- {
- if (!quest)
- return getLevel();
- return quest->GetQuestLevel() > 0 ? quest->GetQuestLevel() : std::min<int32>(getLevel(), quest->GetQuestMaxScalingLevel());
- }
-
+ int32 GetQuestMinLevel(Quest const* quest) const;
+ int32 GetQuestLevel(Quest const* quest) const;
void PrepareQuestMenu(ObjectGuid guid);
void SendPreparedQuest(WorldObject* source);
bool IsActiveQuest(uint32 quest_id) const;
@@ -1501,7 +1501,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; }
static bool IsValidClass(uint8 Class) { return ((1 << (Class - 1)) & CLASSMASK_ALL_PLAYABLE) != 0; }
- static bool IsValidRace(uint8 Race) { return ((1 << (Race - 1)) & RACEMASK_ALL_PLAYABLE) != 0; }
+ static bool IsValidRace(uint8 Race) { return ((UI64LIT(1) << (Race - 1)) & RACEMASK_ALL_PLAYABLE) != 0; }
static bool ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialHair, uint8 skinColor, std::array<uint8, PLAYER_CUSTOM_DISPLAY_SIZE> const& customDisplay, bool create = false);
/*********************************************************/
@@ -1530,7 +1530,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void setRegenTimerCount(uint32 time) {m_regenTimerCount = time;}
void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
- uint64 GetMoney() const { return GetUInt64Value(PLAYER_FIELD_COINAGE); }
+ uint64 GetMoney() const { return GetUInt64Value(ACTIVE_PLAYER_FIELD_COINAGE); }
bool ModifyMoney(int64 amount, bool sendError = true);
bool HasEnoughMoney(uint64 amount) const { return (GetMoney() >= amount); }
bool HasEnoughMoney(int64 amount) const;
@@ -1622,8 +1622,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
std::string GetGuildName() const;
// Loot Spec
- void SetLootSpecId(uint32 id) { SetUInt32Value(PLAYER_FIELD_LOOT_SPEC_ID, id); }
- uint32 GetLootSpecId() const { return GetUInt32Value(PLAYER_FIELD_LOOT_SPEC_ID); }
+ void SetLootSpecId(uint32 id) { SetUInt32Value(ACTIVE_PLAYER_FIELD_LOOT_SPEC_ID, id); }
+ uint32 GetLootSpecId() const { return GetUInt32Value(ACTIVE_PLAYER_FIELD_LOOT_SPEC_ID); }
// Talents
uint32 GetTalentResetCost() const { return _specializationInfo.ResetTalentsCost; }
@@ -1645,11 +1645,10 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
bool AddTalent(TalentEntry const* talent, uint8 spec, bool learning);
bool HasTalent(uint32 spell_id, uint8 spec) const;
void RemoveTalent(TalentEntry const* talent);
- uint32 CalculateTalentsTiers() const;
void ResetTalentSpecialization();
- TalentLearnResult LearnPvpTalent(uint32 talentID, int32* spellOnCooldown);
- bool AddPvpTalent(PvpTalentEntry const* talent, uint8 activeTalentGroup, bool learning);
+ TalentLearnResult LearnPvpTalent(uint32 talentID, uint8 slot, int32* spellOnCooldown);
+ bool AddPvpTalent(PvpTalentEntry const* talent, uint8 activeTalentGroup, uint8 slot);
void RemovePvpTalent(PvpTalentEntry const* talent);
void TogglePvpTalents(bool enable);
bool HasPvpTalent(uint32 talentID, uint8 activeTalentGroup) const;
@@ -1664,14 +1663,14 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
PlayerTalentMap const* GetTalentMap(uint8 spec) const { return &_specializationInfo.Talents[spec]; }
PlayerTalentMap* GetTalentMap(uint8 spec) { return &_specializationInfo.Talents[spec]; }
- PlayerTalentMap const* GetPvpTalentMap(uint8 spec) const { return &_specializationInfo.PvpTalents[spec]; }
- PlayerTalentMap* GetPvpTalentMap(uint8 spec) { return &_specializationInfo.PvpTalents[spec]; }
+ PlayerPvpTalentMap const& GetPvpTalentMap(uint8 spec) const { return _specializationInfo.PvpTalents[spec]; }
+ PlayerPvpTalentMap& GetPvpTalentMap(uint8 spec) { return _specializationInfo.PvpTalents[spec]; }
std::vector<uint32> const& GetGlyphs(uint8 spec) const { return _specializationInfo.Glyphs[spec]; }
std::vector<uint32>& GetGlyphs(uint8 spec) { return _specializationInfo.Glyphs[spec]; }
ActionButtonList const& GetActionButtons() const { return m_actionButtons; }
- uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS); }
- void SetFreePrimaryProfessions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS, profs); }
+ uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(ACTIVE_PLAYER_FIELD_CHARACTER_POINTS); }
+ void SetFreePrimaryProfessions(uint16 profs) { SetUInt32Value(ACTIVE_PLAYER_FIELD_CHARACTER_POINTS, profs); }
void InitPrimaryProfessions();
PlayerSpellMap const& GetSpellMap() const { return m_spells; }
@@ -1756,7 +1755,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SetGuildLevel(uint32 level) { SetUInt32Value(PLAYER_GUILDLEVEL, level); }
uint32 GetGuildLevel() const { return GetUInt32Value(PLAYER_GUILDLEVEL); }
void SetGuildIdInvited(ObjectGuid::LowType GuildId) { m_GuildIdInvited = GuildId; }
- ObjectGuid::LowType GetGuildId() const { return GetUInt64Value(OBJECT_FIELD_DATA); /* return only lower part */ }
+ ObjectGuid::LowType GetGuildId() const { return GetUInt64Value(UNIT_FIELD_GUILD_GUID); /* return only lower part */ }
Guild* GetGuild();
Guild const* GetGuild() const;
static ObjectGuid::LowType GetGuildIdFromDB(ObjectGuid guid);
@@ -1769,8 +1768,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value);
static uint32 GetArenaTeamIdFromDB(ObjectGuid guid, uint8 slot);
static void LeaveAllArenaTeams(ObjectGuid guid);
- uint32 GetArenaTeamId(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID); }
- uint32 GetArenaPersonalRating(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING); }
+ uint32 GetArenaTeamId(uint8 slot) const { return GetUInt32Value(ACTIVE_PLAYER_FIELD_ARENA_TEAM_INFO + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID); }
+ uint32 GetArenaPersonalRating(uint8 slot) const { return GetUInt32Value(ACTIVE_PLAYER_FIELD_ARENA_TEAM_INFO + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING); }
void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
uint32 GetArenaTeamIdInvited() const { return m_ArenaTeamIdInvited; }
uint32 GetRBGPersonalRating() const { return 0; }
@@ -1787,9 +1786,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
static Difficulty CheckLoadedLegacyRaidDifficultyID(Difficulty difficulty);
void SendRaidGroupOnlyMessage(RaidGroupReason reason, int32 delay) const;
- bool UpdateSkill(uint32 skill_id, uint32 step);
bool UpdateSkillPro(uint16 skillId, int32 chance, uint32 step);
-
bool UpdateCraftSkill(uint32 spellid);
bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1);
bool UpdateFishingSkill();
@@ -1929,6 +1926,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
uint16 GetSkillStep(uint16 skill) const; // 0...6
bool HasSkill(uint32 skill) const;
void LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue);
+ int32 FindProfessionSlotFor(uint32 skillId) const;
WorldLocation& GetTeleportDest() { return m_teleport_dest; }
bool IsBeingTeleported() const { return mSemaphoreTeleport_Near || mSemaphoreTeleport_Far; }
@@ -1985,15 +1983,11 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void RestoreHealthAfterDuel() { SetHealth(healthBeforeDuel); }
void RestoreManaAfterDuel() { SetPower(POWER_MANA, manaBeforeDuel); }
- uint32 GetPrestigeLevel() const { return GetUInt32Value(PLAYER_FIELD_PRESTIGE); }
uint32 GetHonorLevel() const { return GetUInt32Value(PLAYER_FIELD_HONOR_LEVEL); }
void AddHonorXP(uint32 xp);
void SetHonorLevel(uint8 honorLevel);
- void Prestige();
- bool CanPrestige() const;
- bool IsMaxPrestige() const;
- bool IsMaxHonorLevelAndPrestige() const { return IsMaxPrestige() && GetHonorLevel() == PLAYER_MAX_HONOR_LEVEL; }
- // Updates PLAYER_FIELD_HONOR_NEXT_LEVEL based on PLAYER_FIELD_HONOR_LEVEL and the smallest value of PLAYER_FIELD_PRESTIGE and (PRESTIGE_COLUMN_COUNT - 1)
+ bool IsMaxHonorLevel() const { return GetHonorLevel() == PLAYER_MAX_HONOR_LEVEL; }
+ // Updates PLAYER_FIELD_HONOR_NEXT_LEVEL based on PLAYER_FIELD_HONOR_LEVEL
void UpdateHonorNextLevel();
//End of PvP System
@@ -2010,7 +2004,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
int32 CalculateCorpseReclaimDelay(bool load = false) const;
void SendCorpseReclaimDelay(uint32 delay) const;
- uint32 GetBlockPercent() const override { return GetUInt32Value(PLAYER_SHIELD_BLOCK); }
+ uint32 GetBlockPercent() const override { return GetUInt32Value(ACTIVE_PLAYER_FIELD_SHIELD_BLOCK); }
bool CanParry() const { return m_canParry; }
void SetCanParry(bool value);
bool CanBlock() const { return m_canBlock; }
@@ -2727,7 +2721,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
std::unordered_map<ObjectGuid /*LootObject*/, ObjectGuid /*world object*/> m_AELootView;
- void _InitHonorLevelOnLoadFromDB(uint32 /*honor*/, uint32 /*honorLevel*/, uint32 /*prestigeLevel*/);
+ void _InitHonorLevelOnLoadFromDB(uint32 honor, uint32 honorLevel);
std::unique_ptr<RestMgr> _restMgr;
bool _usePvpItemLevels;
diff --git a/src/server/game/Entities/Player/PlayerTaxi.cpp b/src/server/game/Entities/Player/PlayerTaxi.cpp
index 7a7f8d8533c..68d34e97c33 100644
--- a/src/server/game/Entities/Player/PlayerTaxi.cpp
+++ b/src/server/game/Entities/Player/PlayerTaxi.cpp
@@ -111,13 +111,13 @@ void PlayerTaxi::AppendTaximaskTo(WorldPackets::Taxi::ShowTaxiNodes& data, bool
{
if (all)
{
- data.CanLandNodes = &sTaxiNodesMask; // all existed nodes
- data.CanUseNodes = &sTaxiNodesMask;
+ data.CanLandNodes = sTaxiNodesMask; // all existed nodes
+ data.CanUseNodes = sTaxiNodesMask;
}
else
{
- data.CanLandNodes = &m_taximask; // known nodes
- data.CanUseNodes = &m_taximask;
+ data.CanLandNodes = m_taximask; // known nodes
+ data.CanUseNodes = m_taximask;
}
}
diff --git a/src/server/game/Entities/Player/PlayerTaxi.h b/src/server/game/Entities/Player/PlayerTaxi.h
index 7a98e01baa1..9da960883a6 100644
--- a/src/server/game/Entities/Player/PlayerTaxi.h
+++ b/src/server/game/Entities/Player/PlayerTaxi.h
@@ -44,13 +44,13 @@ class TC_GAME_API PlayerTaxi
bool IsTaximaskNodeKnown(uint32 nodeidx) const
{
- uint8 field = uint8((nodeidx - 1) / 8);
+ uint32 field = uint32((nodeidx - 1) / 8);
uint32 submask = 1 << ((nodeidx-1) % 8);
return (m_taximask[field] & submask) == submask;
}
bool SetTaximaskNode(uint32 nodeidx)
{
- uint8 field = uint8((nodeidx - 1) / 8);
+ uint32 field = uint32((nodeidx - 1) / 8);
uint32 submask = 1 << ((nodeidx- 1) % 8);
if ((m_taximask[field] & submask) != submask)
{
diff --git a/src/server/game/Entities/Player/RestMgr.cpp b/src/server/game/Entities/Player/RestMgr.cpp
index ba8c11c5ee0..fc100d36088 100644
--- a/src/server/game/Entities/Player/RestMgr.cpp
+++ b/src/server/game/Entities/Player/RestMgr.cpp
@@ -44,17 +44,17 @@ void RestMgr::SetRestBonus(RestTypes restType, float restBonus)
rest_rested_offset = REST_RESTED_XP;
rest_state_offset = REST_STATE_XP;
- next_level_xp_field = PLAYER_NEXT_LEVEL_XP;
+ next_level_xp_field = ACTIVE_PLAYER_FIELD_NEXT_LEVEL_XP;
affectedByRaF = true;
break;
case REST_TYPE_HONOR:
// Reset restBonus (Honor only) for players with max honor level.
- if (_player->IsMaxHonorLevelAndPrestige())
+ if (_player->IsMaxHonorLevel())
restBonus = 0;
rest_rested_offset = REST_RESTED_HONOR;
rest_state_offset = REST_STATE_HONOR;
- next_level_xp_field = PLAYER_FIELD_HONOR_NEXT_LEVEL;
+ next_level_xp_field = ACTIVE_PLAYER_FIELD_HONOR_NEXT_LEVEL;
break;
default:
return;
@@ -72,17 +72,17 @@ void RestMgr::SetRestBonus(RestTypes restType, float restBonus)
// update data for client
if (affectedByRaF && _player->GetsRecruitAFriendBonus(true) && (_player->GetSession()->IsARecruiter() || _player->GetSession()->GetRecruiterId() != 0))
- _player->SetUInt32Value(PLAYER_FIELD_REST_INFO + rest_state_offset, REST_STATE_RAF_LINKED);
+ _player->SetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + rest_state_offset, REST_STATE_RAF_LINKED);
else
{
if (_restBonus[restType] > 10)
- _player->SetUInt32Value(PLAYER_FIELD_REST_INFO + rest_state_offset, REST_STATE_RESTED);
+ _player->SetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + rest_state_offset, REST_STATE_RESTED);
else if (_restBonus[restType] <= 1)
- _player->SetUInt32Value(PLAYER_FIELD_REST_INFO + rest_state_offset, REST_STATE_NOT_RAF_LINKED);
+ _player->SetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + rest_state_offset, REST_STATE_NOT_RAF_LINKED);
}
// RestTickUpdate
- _player->SetUInt32Value(PLAYER_FIELD_REST_INFO + rest_rested_offset, uint32(_restBonus[restType]));
+ _player->SetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + rest_rested_offset, uint32(_restBonus[restType]));
}
void RestMgr::AddRestBonus(RestTypes restType, float restBonus)
@@ -153,8 +153,8 @@ void RestMgr::Update(time_t now)
void RestMgr::LoadRestBonus(RestTypes restType, PlayerRestState state, float restBonus)
{
_restBonus[restType] = restBonus;
- _player->SetUInt32Value(PLAYER_FIELD_REST_INFO + restType * 2, state);
- _player->SetUInt32Value(PLAYER_FIELD_REST_INFO + restType * 2 + 1, uint32(restBonus));
+ _player->SetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + restType * 2, state);
+ _player->SetUInt32Value(ACTIVE_PLAYER_FIELD_REST_INFO + restType * 2 + 1, uint32(restBonus));
}
float RestMgr::CalcExtraPerSec(RestTypes restType, float bubble) const
@@ -162,9 +162,9 @@ float RestMgr::CalcExtraPerSec(RestTypes restType, float bubble) const
switch (restType)
{
case REST_TYPE_HONOR:
- return float(_player->GetUInt32Value(PLAYER_FIELD_HONOR_NEXT_LEVEL)) / 72000.0f * bubble;
+ return float(_player->GetUInt32Value(ACTIVE_PLAYER_FIELD_HONOR_NEXT_LEVEL)) / 72000.0f * bubble;
case REST_TYPE_XP:
- return float(_player->GetUInt32Value(PLAYER_NEXT_LEVEL_XP)) / 72000.0f * bubble;
+ return float(_player->GetUInt32Value(ACTIVE_PLAYER_FIELD_NEXT_LEVEL_XP)) / 72000.0f * bubble;
default:
return 0.0f;
}