aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp701
-rw-r--r--src/server/game/Entities/Player/Player.h228
-rw-r--r--src/server/game/Server/WorldSession.cpp2
-rw-r--r--src/server/game/Server/WorldSession.h2
4 files changed, 467 insertions, 466 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index f3d45b005d8..f25125da993 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -306,7 +306,7 @@ Player::Player(WorldSession* session): Unit(true)
m_ExtraFlags = 0;
- m_spellModTakingSpell = NULL;
+ m_spellModTakingSpell = nullptr;
//m_pad = 0;
// players always accept
@@ -336,15 +336,15 @@ Player::Player(WorldSession* session): Unit(true)
memset(m_items, 0, sizeof(Item*)*PLAYER_SLOTS_COUNT);
- m_social = NULL;
+ m_social = nullptr;
// group is initialized in the reference constructor
- SetGroupInvite(NULL);
+ SetGroupInvite(nullptr);
m_groupUpdateMask = 0;
m_auraRaidUpdateMask = 0;
m_bPassOnGroupLoot = false;
- duel = NULL;
+ duel = nullptr;
m_GuildIdInvited = 0;
m_ArenaTeamIdInvited = 0;
@@ -359,7 +359,7 @@ Player::Player(WorldSession* session): Unit(true)
m_bHasDelayedTeleport = false;
m_teleport_options = 0;
- m_trade = NULL;
+ m_trade = nullptr;
m_cinematic = 0;
@@ -394,7 +394,7 @@ Player::Player(WorldSession* session): Unit(true)
m_bgBattlegroundQueueID[j].invitedToInstance = 0;
}
- m_logintime = time(NULL);
+ m_logintime = time(nullptr);
m_Last_tick = m_logintime;
m_Played_time[PLAYED_TIME_TOTAL] = 0;
m_Played_time[PLAYED_TIME_LEVEL] = 0;
@@ -470,7 +470,7 @@ Player::Player(WorldSession* session): Unit(true)
m_spellPenetrationItemMod = 0;
// Honor System
- m_lastHonorUpdateTime = time(NULL);
+ m_lastHonorUpdateTime = time(nullptr);
m_IsBGRandomWinner = false;
@@ -499,11 +499,11 @@ Player::Player(WorldSession* session): Unit(true)
m_contestedPvPTimer = 0;
- m_declinedname = NULL;
+ m_declinedname = nullptr;
m_isActive = true;
- m_runes = NULL;
+ m_runes = nullptr;
m_lastFallTime = 0;
m_lastFallZ = 0;
@@ -543,7 +543,7 @@ Player::Player(WorldSession* session): Unit(true)
Player::~Player()
{
- // it must be unloaded already in PlayerLogout and accessed only for loggined player
+ // it must be unloaded already in PlayerLogout and accessed only for logged in player
//m_social = NULL;
// Note: buy back item already deleted from DB when player was saved
@@ -611,7 +611,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
}
for (uint8 i = 0; i < PLAYER_SLOTS_COUNT; i++)
- m_items[i] = NULL;
+ m_items[i] = nullptr;
Relocate(info->positionX, info->positionY, info->positionZ, info->orientation);
@@ -752,7 +752,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
}
// Played time
- m_Last_tick = time(NULL);
+ m_Last_tick = time(nullptr);
m_Played_time[PLAYED_TIME_TOTAL] = 0;
m_Played_time[PLAYED_TIME_LEVEL] = 0;
@@ -851,7 +851,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
if (msg == EQUIP_ERR_OK)
{
RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
- pItem = StoreItem(sDest, pItem, true);
+ StoreItem(sDest, pItem, true);
}
// if this is ammo then use it
@@ -927,10 +927,10 @@ void Player::StopMirrorTimer(MirrorTimerType Type)
GetSession()->SendPacket(&data);
}
-bool Player::IsImmuneToEnvironmentalDamage()
+bool Player::IsImmuneToEnvironmentalDamage() const
{
// check for GM and death state included in isAttackableByAOE
- return (!isTargetableForAttack(false));
+ return !isTargetableForAttack(false);
}
uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
@@ -958,7 +958,7 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
data << uint32(resist);
SendMessageToSet(&data, true);
- uint32 final_damage = DealDamage(this, damage, NULL, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
+ uint32 final_damage = DealDamage(this, damage, nullptr, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
if (!IsAlive())
{
@@ -977,7 +977,7 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
return final_damage;
}
-int32 Player::getMaxTimer(MirrorTimerType timer)
+int32 Player::getMaxTimer(MirrorTimerType timer) const
{
switch (timer)
{
@@ -1018,7 +1018,7 @@ void Player::StopMirrorTimers()
StopMirrorTimer(FIRE_TIMER);
}
-bool Player::IsMirrorTimerActive(MirrorTimerType type)
+bool Player::IsMirrorTimerActive(MirrorTimerType type) const
{
return m_MirrorTimer[type] == getMaxTimer(type);
}
@@ -1200,7 +1200,7 @@ void Player::Update(uint32 p_time)
return;
// undelivered mail
- if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL))
+ if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(nullptr))
{
SendNewMail();
++unReadMails;
@@ -1217,7 +1217,7 @@ void Player::Update(uint32 p_time)
//TC_LOG_FATAL("entities.player", "Player has m_pad %u during update!", m_pad);
//if (m_spellModTakingSpell)
TC_LOG_FATAL("spells", "Player has m_spellModTakingSpell %u during update!", m_spellModTakingSpell->m_spellInfo->Id);
- m_spellModTakingSpell = NULL;
+ m_spellModTakingSpell = nullptr;
}
//used to implement delayed far teleports
@@ -1225,7 +1225,7 @@ void Player::Update(uint32 p_time)
Unit::Update(p_time);
SetCanDelayTeleport(false);
- time_t now = time(NULL);
+ time_t now = time(nullptr);
UpdatePvPFlag(now);
@@ -1564,7 +1564,7 @@ void Player::setDeathState(DeathState s)
clearResurrectRequestData();
//FIXME: is pet dismissed at dying or releasing spirit? if second, add setDeathState(DEAD) to HandleRepopRequestOpcode and define pet unsummon here with (s == DEAD)
- RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
+ RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true);
// save value before aura remove in Unit::setDeathState
ressSpellId = GetUInt32Value(PLAYER_SELF_RES_SPELL);
@@ -2389,14 +2389,14 @@ void Player::ResetAllPowers()
}
}
-bool Player::CanInteractWithQuestGiver(Object* questGiver)
+bool Player::CanInteractWithQuestGiver(Object* questGiver) const
{
switch (questGiver->GetTypeId())
{
case TYPEID_UNIT:
- return GetNPCIfCanInteractWith(questGiver->GetGUID(), UNIT_NPC_FLAG_QUESTGIVER) != NULL;
+ return GetNPCIfCanInteractWith(questGiver->GetGUID(), UNIT_NPC_FLAG_QUESTGIVER) != nullptr;
case TYPEID_GAMEOBJECT:
- return GetGameObjectIfCanInteractWith(questGiver->GetGUID(), GAMEOBJECT_TYPE_QUESTGIVER) != NULL;
+ return GetGameObjectIfCanInteractWith(questGiver->GetGUID(), GAMEOBJECT_TYPE_QUESTGIVER) != nullptr;
case TYPEID_PLAYER:
return IsAlive() && questGiver->ToPlayer()->IsAlive();
case TYPEID_ITEM:
@@ -2407,46 +2407,46 @@ bool Player::CanInteractWithQuestGiver(Object* questGiver)
return false;
}
-Creature* Player::GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask)
+Creature* Player::GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask) const
{
// unit checks
if (!guid)
- return NULL;
+ return nullptr;
if (!IsInWorld())
- return NULL;
+ return nullptr;
if (IsInFlight())
- return NULL;
+ return nullptr;
// exist (we need look pets also for some interaction (quest/etc)
Creature* creature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, guid);
if (!creature)
- return NULL;
+ return nullptr;
// Deathstate checks
if (!IsAlive() && !(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_GHOST))
- return NULL;
+ return nullptr;
// alive or spirit healer
if (!creature->IsAlive() && !(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_DEAD_INTERACT))
- return NULL;
+ return nullptr;
// appropriate npc type
if (npcflagmask && !creature->HasFlag(UNIT_NPC_FLAGS, npcflagmask))
- return NULL;
+ return nullptr;
// not allow interaction under control, but allow with own pets
if (creature->GetCharmerGUID())
- return NULL;
+ return nullptr;
// not unfriendly/hostile
if (creature->GetReactionTo(this) <= REP_UNFRIENDLY)
- return NULL;
+ return nullptr;
// not too far
if (!creature->IsWithinDistInMap(this, INTERACTION_DISTANCE))
- return NULL;
+ return nullptr;
return creature;
}
@@ -2626,14 +2626,14 @@ bool Player::IsGroupVisibleFor(Player const* p) const
bool Player::IsInSameGroupWith(Player const* p) const
{
- return p == this || (GetGroup() != NULL &&
+ return p == this || (GetGroup() != nullptr &&
GetGroup() == p->GetGroup() &&
GetGroup()->SameSubGroup(this, p));
}
bool Player::IsInSameRaidWith(Player const* p) const
{
- return p == this || (GetGroup() != NULL && GetGroup() == p->GetGroup());
+ return p == this || (GetGroup() != nullptr && GetGroup() == p->GetGroup());
}
///- If the player is invited, remove him. If the group if then only 1 person, disband the group.
@@ -2668,7 +2668,7 @@ void Player::RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method
group->RemoveMember(guid, method, kicker, reason);
}
-void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend, float /*group_rate*/)
+void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend, float /*group_rate*/) const
{
WorldPacket data(SMSG_LOG_XPGAIN, 21); // guess size?
data << uint64(victim ? victim->GetGUID() : ObjectGuid::Empty);
@@ -2709,7 +2709,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
if (level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
return;
- uint32 bonus_xp = 0;
+ uint32 bonus_xp;
bool recruitAFriend = GetsRecruitAFriendBonus(true);
// RaF does NOT stack with rested experience
@@ -3087,7 +3087,7 @@ void Player::RemoveMail(uint32 id)
}
}
-void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, ObjectGuid::LowType item_guid, uint32 item_count)
+void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, ObjectGuid::LowType item_guid, uint32 item_count) const
{
WorldPacket data(SMSG_SEND_MAIL_RESULT, (4+4+4+(mailError == MAIL_ERR_EQUIP_ERROR?4:(mailAction == MAIL_ITEM_TAKEN?4+4:0))));
data << (uint32) mailId;
@@ -3103,7 +3103,7 @@ void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResp
GetSession()->SendPacket(&data);
}
-void Player::SendNewMail()
+void Player::SendNewMail() const
{
// deliver undelivered mail
WorldPacket data(SMSG_RECEIVED_MAIL, 4);
@@ -3115,7 +3115,7 @@ void Player::UpdateNextMailTimeAndUnreads()
{
// calculate next delivery time (min. from non-delivered mails
// and recalculate unReadMail
- time_t cTime = time(NULL);
+ time_t cTime = time(nullptr);
m_nextMailDelivereTime = 0;
unReadMails = 0;
for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
@@ -3132,7 +3132,7 @@ void Player::UpdateNextMailTimeAndUnreads()
void Player::AddNewMailDeliverTime(time_t deliver_time)
{
- if (deliver_time <= time(NULL)) // ready now
+ if (deliver_time <= time(nullptr)) // ready now
{
++unReadMails;
SendNewMail();
@@ -3940,12 +3940,12 @@ bool Player::ResetTalents(bool no_cost)
if (!HasEnoughMoney(cost))
{
- SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
+ SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, nullptr, 0, 0);
return false;
}
}
- RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
+ RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true);
for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
{
@@ -4025,7 +4025,7 @@ Mail* Player::GetMail(uint32 id)
if ((*itr)->messageID == id)
return (*itr);
- return NULL;
+ return nullptr;
}
void Player::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const
@@ -4034,7 +4034,7 @@ void Player::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
{
for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
{
- if (m_items[i] == NULL)
+ if (m_items[i] == nullptr)
continue;
m_items[i]->BuildCreateUpdateBlockForPlayer(data, target);
@@ -4042,7 +4042,7 @@ void Player::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
for (uint8 i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
{
- if (m_items[i] == NULL)
+ if (m_items[i] == nullptr)
continue;
m_items[i]->BuildCreateUpdateBlockForPlayer(data, target);
@@ -4065,7 +4065,7 @@ void Player::DestroyForPlayer(Player* target, bool onDeath) const
for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
{
- if (m_items[i] == NULL)
+ if (m_items[i] == nullptr)
continue;
m_items[i]->DestroyForPlayer(target);
@@ -4075,7 +4075,7 @@ void Player::DestroyForPlayer(Player* target, bool onDeath) const
{
for (uint8 i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
{
- if (m_items[i] == NULL)
+ if (m_items[i] == nullptr)
continue;
m_items[i]->DestroyForPlayer(target);
@@ -4165,7 +4165,7 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell
}
// check primary prof. limit
- // first rank of primary profession spell when there are no proffesions avalible is disabled
+ // first rank of primary profession spell when there are no professions available is disabled
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (!trainer_spell->learnedSpell[i])
@@ -4579,7 +4579,7 @@ void Player::DeleteOldCharacters(uint32 keepDays)
TC_LOG_INFO("entities.player", "Player::DeleteOldChars: Removing characters older than %u day(s)", keepDays);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_OLD_CHARS);
- stmt->setUInt32(0, uint32(time(NULL) - time_t(keepDays * DAY)));
+ stmt->setUInt32(0, uint32(time(nullptr) - time_t(keepDays * DAY)));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
@@ -4963,7 +4963,7 @@ void Player::DurabilityPointsLossAll(int32 points, bool inventory)
//for (int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++)
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
- if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
+ if (Bag* pBag = static_cast<Bag*>(GetItemByPos(INVENTORY_SLOT_BAG_0, i)))
for (uint32 j = 0; j < pBag->GetBagSize(); j++)
if (Item* pItem = GetItemByPos(i, j))
DurabilityPointsLoss(pItem, points);
@@ -5113,7 +5113,7 @@ void Player::RepopAtGraveyard()
SpawnCorpseBones();
}
- WorldSafeLocsEntry const* ClosestGrave = NULL;
+ WorldSafeLocsEntry const* ClosestGrave;
// Special handle for battleground maps
if (Battleground* bg = GetBattleground())
@@ -5150,7 +5150,7 @@ void Player::RepopAtGraveyard()
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_IS_OUT_OF_BOUNDS);
}
-bool Player::CanJoinConstantChannelInZone(ChatChannelsEntry const* channel, AreaTableEntry const* zone)
+bool Player::CanJoinConstantChannelInZone(ChatChannelsEntry const* channel, AreaTableEntry const* zone) const
{
if (channel->flags & CHANNEL_DBC_FLAG_ZONE_DEP && zone->flags & AREA_FLAG_ARENA_INSTANCE)
return false;
@@ -5206,7 +5206,7 @@ void Player::UpdateLocalChannels(uint32 newZone)
{
if (ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(i))
{
- Channel* usedChannel = NULL;
+ Channel* usedChannel = nullptr;
for (JoinedChannelsList::iterator itr = m_channels.begin(); itr != m_channels.end(); ++itr)
{
@@ -5217,8 +5217,8 @@ void Player::UpdateLocalChannels(uint32 newZone)
}
}
- Channel* removeChannel = NULL;
- Channel* joinChannel = NULL;
+ Channel* removeChannel = nullptr;
+ Channel* joinChannel = nullptr;
bool sendRemove = true;
if (CanJoinConstantChannelInZone(channel, current_zone))
@@ -5247,7 +5247,7 @@ void Player::UpdateLocalChannels(uint32 newZone)
sendRemove = false; // Do not send leave channel, it already replaced at client
}
else
- joinChannel = NULL;
+ joinChannel = nullptr;
}
}
else
@@ -5351,7 +5351,7 @@ uint32 Player::GetShieldBlockValue() const
return uint32(value);
}
-float Player::GetMeleeCritFromAgility()
+float Player::GetMeleeCritFromAgility() const
{
uint8 level = getLevel();
uint32 pclass = getClass();
@@ -5361,14 +5361,14 @@ float Player::GetMeleeCritFromAgility()
GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass-1);
GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1);
- if (critBase == NULL || critRatio == NULL)
+ if (critBase == nullptr || critRatio == nullptr)
return 0.0f;
float crit = critBase->base + GetStat(STAT_AGILITY)*critRatio->ratio;
return crit*100.0f;
}
-void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing)
+void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing) const
{
// Table for base dodge values
const float dodge_base[MAX_CLASSES] =
@@ -5409,7 +5409,7 @@ void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing)
// Dodge per agility is proportional to crit per agility, which is available from DBC files
GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1);
- if (dodgeRatio == NULL || pclass > MAX_CLASSES)
+ if (dodgeRatio == nullptr || pclass > MAX_CLASSES)
return;
/// @todo research if talents/effects that increase total agility by x% should increase non-diminishing part
@@ -5421,7 +5421,7 @@ void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing)
nondiminishing = 100.0f * (dodge_base[pclass-1] + base_agility * dodgeRatio->ratio * crit_to_dodge[pclass-1]);
}
-float Player::GetSpellCritFromIntellect()
+float Player::GetSpellCritFromIntellect() const
{
uint8 level = getLevel();
uint32 pclass = getClass();
@@ -5431,7 +5431,7 @@ float Player::GetSpellCritFromIntellect()
GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass-1);
GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1);
- if (critBase == NULL || critRatio == NULL)
+ if (critBase == nullptr || critRatio == nullptr)
return 0.0f;
float crit=critBase->base + GetStat(STAT_INTELLECT)*critRatio->ratio;
@@ -5473,7 +5473,7 @@ float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const
return 0.0f;
}
-float Player::OCTRegenHPPerSpirit()
+float Player::OCTRegenHPPerSpirit() const
{
uint8 level = getLevel();
uint32 pclass = getClass();
@@ -5496,7 +5496,7 @@ float Player::OCTRegenHPPerSpirit()
return regen;
}
-float Player::OCTRegenMPPerSpirit()
+float Player::OCTRegenMPPerSpirit() const
{
uint8 level = getLevel();
uint32 pclass = getClass();
@@ -5506,7 +5506,7 @@ float Player::OCTRegenMPPerSpirit()
// GtOCTRegenMPEntry const* baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1);
GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1);
- if (moreRatio == NULL)
+ if (moreRatio == nullptr)
return 0.0f;
// Formula get from PaperDollFrame script
@@ -6251,7 +6251,7 @@ void Player::SendActionButtons(uint32 state) const
TC_LOG_DEBUG("network", "SMSG_ACTION_BUTTONS sent '%u' spec '%u' Sent", GetGUID().GetCounter(), m_activeSpec);
}
-bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type)
+bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) const
{
if (button >= MAX_ACTION_BUTTONS)
{
@@ -6303,7 +6303,7 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type)
ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type)
{
if (!IsActionButtonDataValid(button, action, type))
- return NULL;
+ return nullptr;
// it create new button (NEW state) if need or return existing
ActionButton& ab = m_actionButtons[button];
@@ -6333,7 +6333,7 @@ ActionButton const* Player::GetActionButton(uint8 button)
{
ActionButtonList::iterator buttonItr = m_actionButtons.find(button);
if (buttonItr == m_actionButtons.end() || buttonItr->second.uState == ACTIONBUTTON_DELETED)
- return NULL;
+ return nullptr;
return &buttonItr->second;
}
@@ -6405,19 +6405,19 @@ void Player::SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr)
VisitNearbyWorldObject(GetVisibilityRange(), notifier);
}
-void Player::SendDirectMessage(WorldPacket* data)
+void Player::SendDirectMessage(WorldPacket const* data) const
{
m_session->SendPacket(data);
}
-void Player::SendCinematicStart(uint32 CinematicSequenceId)
+void Player::SendCinematicStart(uint32 CinematicSequenceId) const
{
WorldPacket data(SMSG_TRIGGER_CINEMATIC, 4);
data << uint32(CinematicSequenceId);
SendDirectMessage(&data);
}
-void Player::SendMovieStart(uint32 MovieId)
+void Player::SendMovieStart(uint32 MovieId) const
{
WorldPacket data(SMSG_TRIGGER_MOVIE, 4);
data << uint32(MovieId);
@@ -6476,7 +6476,7 @@ void Player::CheckAreaExploreAndOutdoor()
else
{
int32 diff = int32(getLevel()) - areaEntry->area_level;
- uint32 XP = 0;
+ uint32 XP;
if (diff < -5)
{
XP = uint32(sObjectMgr->GetBaseXP(getLevel()+5)*sWorld->getRate(RATE_XP_EXPLORE));
@@ -6494,7 +6494,7 @@ void Player::CheckAreaExploreAndOutdoor()
XP = uint32(sObjectMgr->GetBaseXP(areaEntry->area_level)*sWorld->getRate(RATE_XP_EXPLORE));
}
- GiveXP(XP, NULL);
+ GiveXP(XP, nullptr);
SendExplorationExperience(areaId, XP);
}
TC_LOG_DEBUG("entities.player", "Player '%s' (%s) discovered a new area: %u", GetName().c_str(),GetGUID().ToString().c_str(), areaId);
@@ -6711,8 +6711,8 @@ void Player::RewardReputation(Quest const* quest)
void Player::UpdateHonorFields()
{
/// called when rewarding honor and at each save
- time_t now = time_t(time(NULL));
- time_t today = time_t(time(NULL) / DAY) * DAY;
+ time_t now = time_t(time(nullptr));
+ time_t today = time_t(time(nullptr) / DAY) * DAY;
if (m_lastHonorUpdateTime < today)
{
@@ -6836,7 +6836,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
}
}
- if (victim != NULL)
+ if (victim != nullptr)
{
if (groupsize > 1)
honor_f /= groupsize;
@@ -7213,7 +7213,7 @@ void Player::CheckDuelDistance(time_t currTime)
}
}
-bool Player::IsOutdoorPvPActive()
+bool Player::IsOutdoorPvPActive() const
{
return IsAlive() && !HasInvisibilityAura() && !HasStealthAura() && IsPvP() && !HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && !IsInFlight();
}
@@ -7272,7 +7272,7 @@ void Player::DuelComplete(DuelCompleteType type)
// Honor points after duel (the winner) - ImpConfig
if (uint32 amount = sWorld->getIntConfig(CONFIG_HONOR_AFTER_DUEL))
- duel->opponent->RewardHonor(NULL, 1, amount);
+ duel->opponent->RewardHonor(nullptr, 1, amount);
break;
default:
@@ -7327,9 +7327,9 @@ void Player::DuelComplete(DuelCompleteType type)
duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0);
delete duel->opponent->duel;
- duel->opponent->duel = NULL;
+ duel->opponent->duel = nullptr;
delete duel;
- duel = NULL;
+ duel = nullptr;
}
//---------------------------------------------------------//
@@ -7742,7 +7742,7 @@ void Player::_ApplyWeaponDependentAuraCritMod(Item* item, WeaponAttackType attac
if (aura->GetSpellInfo()->EquippedItemClass == -1)
return;
- BaseModGroup mod = BASEMOD_END;
+ BaseModGroup mod;
switch (attackType)
{
case BASE_ATTACK: mod = CRIT_PERCENTAGE; break;
@@ -7769,7 +7769,7 @@ void Player::_ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType att
if (aura->GetSpellInfo()->EquippedItemClass == -1)
return;
- UnitMods unitMod = UNIT_MOD_END;
+ UnitMods unitMod;
switch (attackType)
{
case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break;
@@ -7778,7 +7778,7 @@ void Player::_ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType att
default: return;
}
- UnitModifierType unitModType = TOTAL_VALUE;
+ UnitModifierType unitModType;
switch (aura->GetAuraType())
{
case SPELL_AURA_MOD_DAMAGE_DONE: unitModType = TOTAL_VALUE; break;
@@ -8326,7 +8326,7 @@ void Player::RemovedInsignia(Player* looterPlr)
looterPlr->SendLoot(bones->GetGUID(), LOOT_INSIGNIA);
}
-void Player::SendLootRelease(ObjectGuid guid)
+void Player::SendLootRelease(ObjectGuid guid) const
{
WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8+1));
data << uint64(guid) << uint8(1);
@@ -8338,7 +8338,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
if (ObjectGuid lguid = GetLootGUID())
m_session->DoLootRelease(lguid);
- Loot* loot = 0;
+ Loot* loot;
PermissionTypes permission = ALL_PERMISSION;
TC_LOG_DEBUG("loot", "Player::SendLoot");
@@ -8553,7 +8553,6 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
}
else
{
- permission = NONE_PERMISSION;
SendLootError(guid, LOOT_ERROR_ALREADY_PICKPOCKETED);
return;
}
@@ -8668,7 +8667,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
}
-void Player::SendLootError(ObjectGuid guid, LootError error)
+void Player::SendLootError(ObjectGuid guid, LootError error) const
{
WorldPacket data(SMSG_LOOT_RESPONSE, 10);
data << uint64(guid);
@@ -8677,20 +8676,20 @@ void Player::SendLootError(ObjectGuid guid, LootError error)
SendDirectMessage(&data);
}
-void Player::SendNotifyLootMoneyRemoved()
+void Player::SendNotifyLootMoneyRemoved() const
{
WorldPacket data(SMSG_LOOT_CLEAR_MONEY, 0);
GetSession()->SendPacket(&data);
}
-void Player::SendNotifyLootItemRemoved(uint8 lootSlot)
+void Player::SendNotifyLootItemRemoved(uint8 lootSlot) const
{
WorldPacket data(SMSG_LOOT_REMOVED, 1);
data << uint8(lootSlot);
GetSession()->SendPacket(&data);
}
-void Player::SendUpdateWorldState(uint32 Field, uint32 Value)
+void Player::SendUpdateWorldState(uint32 Field, uint32 Value) const
{
WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8);
data << Field;
@@ -9325,7 +9324,7 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
SendBattlefieldWorldStates();
}
-void Player::SendBGWeekendWorldStates()
+void Player::SendBGWeekendWorldStates() const
{
for (uint32 i = 1; i < sBattlemasterListStore.GetNumRows(); ++i)
{
@@ -9340,7 +9339,7 @@ void Player::SendBGWeekendWorldStates()
}
}
-void Player::SendBattlefieldWorldStates()
+void Player::SendBattlefieldWorldStates() const
{
/// Send misc stuff that needs to be sent on every login, like the battle timers.
if (sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE))
@@ -9349,7 +9348,7 @@ void Player::SendBattlefieldWorldStates()
{
SendUpdateWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, wg->IsWarTime() ? 0 : 1);
uint32 timer = wg->IsWarTime() ? 0 : (wg->GetTimer() / 1000); // 0 - Time to next battle
- SendUpdateWorldState(ClockWorldState[1], uint32(time(NULL) + timer));
+ SendUpdateWorldState(ClockWorldState[1], uint32(time(nullptr) + timer));
}
}
}
@@ -9367,14 +9366,14 @@ uint32 Player::GetXPRestBonus(uint32 xp)
return rested_bonus;
}
-void Player::SetBindPoint(ObjectGuid guid)
+void Player::SetBindPoint(ObjectGuid guid) const
{
WorldPacket data(SMSG_BINDER_CONFIRM, 8);
data << uint64(guid);
GetSession()->SendPacket(&data);
}
-void Player::SendTalentWipeConfirm(ObjectGuid guid)
+void Player::SendTalentWipeConfirm(ObjectGuid guid) const
{
WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8+4));
data << uint64(guid);
@@ -9431,24 +9430,24 @@ void Player::SetSheath(SheathState sheathed)
switch (sheathed)
{
case SHEATH_STATE_UNARMED: // no prepared weapon
- SetVirtualItemSlot(0, NULL);
- SetVirtualItemSlot(1, NULL);
- SetVirtualItemSlot(2, NULL);
+ SetVirtualItemSlot(0, nullptr);
+ SetVirtualItemSlot(1, nullptr);
+ SetVirtualItemSlot(2, nullptr);
break;
case SHEATH_STATE_MELEE: // prepared melee weapon
SetVirtualItemSlot(0, GetWeaponForAttack(BASE_ATTACK, true));
SetVirtualItemSlot(1, GetWeaponForAttack(OFF_ATTACK, true));
- SetVirtualItemSlot(2, NULL);
+ SetVirtualItemSlot(2, nullptr);
break;
case SHEATH_STATE_RANGED: // prepared ranged weapon
- SetVirtualItemSlot(0, NULL);
- SetVirtualItemSlot(1, NULL);
+ SetVirtualItemSlot(0, nullptr);
+ SetVirtualItemSlot(1, nullptr);
SetVirtualItemSlot(2, GetWeaponForAttack(RANGED_ATTACK, true));
break;
default:
- SetVirtualItemSlot(0, NULL);
- SetVirtualItemSlot(1, NULL);
- SetVirtualItemSlot(2, NULL);
+ SetVirtualItemSlot(0, nullptr);
+ SetVirtualItemSlot(1, nullptr);
+ SetVirtualItemSlot(2, nullptr);
break;
}
Unit::SetSheath(sheathed); // this must visualize Sheath changing for other players...
@@ -9796,7 +9795,7 @@ Item* Player::GetItemByGuid(ObjectGuid guid) const
if (pItem->GetGUID() == guid)
return pItem;
- return NULL;
+ return nullptr;
}
Item* Player::GetItemByPos(uint16 pos) const
@@ -9810,9 +9809,9 @@ Item* Player::GetItemByPos(uint8 bag, uint8 slot) const
{
if (bag == INVENTORY_SLOT_BAG_0 && (slot < BANK_SLOT_BAG_END || (slot >= KEYRING_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)))
return m_items[slot];
- else if (Bag* pBag = GetBagByPos(bag))
+ if (Bag* pBag = GetBagByPos(bag))
return pBag->GetItemByPos(slot);
- return NULL;
+ return nullptr;
}
//Does additional check for disarmed weapons
@@ -9829,7 +9828,7 @@ Bag* Player::GetBagByPos(uint8 bag) const
|| (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END))
if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, bag))
return item->ToBag();
- return NULL;
+ return nullptr;
}
Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= false*/) const
@@ -9840,41 +9839,41 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= f
case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break;
case OFF_ATTACK: slot = EQUIPMENT_SLOT_OFFHAND; break;
case RANGED_ATTACK: slot = EQUIPMENT_SLOT_RANGED; break;
- default: return NULL;
+ default: return nullptr;
}
- Item* item = NULL;
+ Item* item;
if (useable)
item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, slot);
else
item = GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
if (!item || item->GetTemplate()->Class != ITEM_CLASS_WEAPON)
- return NULL;
+ return nullptr;
if (!useable)
return item;
if (item->IsBroken() || IsInFeralForm())
- return NULL;
+ return nullptr;
return item;
}
Item* Player::GetShield(bool useable) const
{
- Item* item = NULL;
+ Item* item;
if (useable)
item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
else
item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
if (!item || item->GetTemplate()->Class != ITEM_CLASS_ARMOR)
- return NULL;
+ return nullptr;
if (!useable)
return item;
if (item->IsBroken())
- return NULL;
+ return nullptr;
return item;
}
@@ -9934,7 +9933,7 @@ bool Player::IsBagPos(uint16 pos)
return false;
}
-bool Player::IsValidPos(uint8 bag, uint8 slot, bool explicit_pos)
+bool Player::IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const
{
// post selected
if (bag == NULL_BAG && !explicit_pos)
@@ -10191,7 +10190,7 @@ InventoryResult Player::CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item
InventoryResult Player::CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count /*= NULL*/) const
{
- return CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count);
+ return CanStoreItem(bag, slot, dest, item, count, nullptr, false, no_space_count);
}
InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap /*= false*/) const
@@ -10199,7 +10198,7 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& des
if (!pItem)
return EQUIP_ERR_ITEM_NOT_FOUND;
uint32 count = pItem->GetCount();
- return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL);
+ return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, nullptr);
}
bool Player::HasItemTotemCategory(uint32 TotemCategory) const
@@ -10238,7 +10237,7 @@ InventoryResult Player::CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemP
// ignore move item (this slot will be empty at move)
if (pItem2 == pSrcItem)
- pItem2 = NULL;
+ pItem2 = nullptr;
uint32 need_space;
@@ -10324,7 +10323,7 @@ InventoryResult Player::CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, Ite
if (!pBagProto)
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
- // specialized bag mode or non-specilized
+ // specialized bag mode or non-specialized
if (non_specialized != (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER))
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
@@ -10341,10 +10340,10 @@ InventoryResult Player::CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, Ite
// ignore move item (this slot will be empty at move)
if (pItem2 == pSrcItem)
- pItem2 = NULL;
+ pItem2 = nullptr;
// if merge skip empty, if !merge skip non-empty
- if ((pItem2 != NULL) != merge)
+ if ((pItem2 != nullptr) != merge)
continue;
uint32 need_space = pProto->GetMaxStackSize();
@@ -10392,10 +10391,10 @@ InventoryResult Player::CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 sl
// ignore move item (this slot will be empty at move)
if (pItem2 == pSrcItem)
- pItem2 = NULL;
+ pItem2 = nullptr;
// if merge skip empty, if !merge skip non-empty
- if ((pItem2 != NULL) != merge)
+ if ((pItem2 != nullptr) != merge)
continue;
uint32 need_space = pProto->GetMaxStackSize();
@@ -11802,7 +11801,7 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update
Item* Player::StoreItem(ItemPosCountVec const& dest, Item* pItem, bool update)
{
if (!pItem)
- return NULL;
+ return nullptr;
Item* lastItem = pItem;
for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end();)
@@ -11827,7 +11826,7 @@ Item* Player::StoreItem(ItemPosCountVec const& dest, Item* pItem, bool update)
Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update)
{
if (!pItem)
- return NULL;
+ return nullptr;
uint8 bag = pos >> 8;
uint8 slot = pos & 255;
@@ -11844,7 +11843,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool
pItem->SetCount(count);
if (!pItem)
- return NULL;
+ return nullptr;
if (pItem->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP ||
pItem->GetTemplate()->Bonding == BIND_QUEST_ITEM ||
@@ -11860,7 +11859,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool
pItem->SetGuidValue(ITEM_FIELD_OWNER, GetGUID());
pItem->SetSlot(slot);
- pItem->SetContainer(NULL);
+ pItem->SetContainer(nullptr);
// need update known currency
if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
@@ -11945,7 +11944,7 @@ Item* Player::EquipNewItem(uint16 pos, uint32 item, bool update)
return EquipItem(pos, pItem, update);
}
- return NULL;
+ return nullptr;
}
Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
@@ -12105,7 +12104,7 @@ void Player::VisualizeItem(uint8 slot, Item* pItem)
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID());
pItem->SetGuidValue(ITEM_FIELD_OWNER, GetGUID());
pItem->SetSlot(slot);
- pItem->SetContainer(NULL);
+ pItem->SetContainer(nullptr);
if (slot < EQUIPMENT_SLOT_END)
SetVisibleItemSlot(slot, pItem);
@@ -12182,11 +12181,11 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update)
}
}
- m_items[slot] = NULL;
+ m_items[slot] = nullptr;
SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty);
if (slot < EQUIPMENT_SLOT_END)
- SetVisibleItemSlot(slot, NULL);
+ SetVisibleItemSlot(slot, nullptr);
}
else if (Bag* pBag = GetBagByPos(bag))
pBag->RemoveItem(slot, update);
@@ -12316,10 +12315,10 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
UpdateExpertise(OFF_ATTACK);
// equipment visual show
- SetVisibleItemSlot(slot, NULL);
+ SetVisibleItemSlot(slot, nullptr);
}
- m_items[slot] = NULL;
+ m_items[slot] = nullptr;
}
else if (Bag* pBag = GetBagByPos(bag))
pBag->RemoveItem(slot, update);
@@ -12616,7 +12615,7 @@ Item* Player::GetItemByEntry(uint32 entry) const
if (pItem->GetEntry() == entry)
return pItem;
- return NULL;
+ return nullptr;
}
void Player::DestroyItemCount(Item* pItem, uint32 &count, bool update)
@@ -12654,28 +12653,28 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
Item* pSrcItem = GetItemByPos(srcbag, srcslot);
if (!pSrcItem)
{
- SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL);
+ SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, nullptr);
return;
}
if (pSrcItem->m_lootGenerated) // prevent split looting item (item
{
//best error message found for attempting to split while looting
- SendEquipError(EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL);
+ SendEquipError(EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, nullptr);
return;
}
// not let split all items (can be only at cheating)
if (pSrcItem->GetCount() == count)
{
- SendEquipError(EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL);
+ SendEquipError(EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, nullptr);
return;
}
// not let split more existing items (can be only at cheating)
if (pSrcItem->GetCount() < count)
{
- SendEquipError(EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT, pSrcItem, NULL);
+ SendEquipError(EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT, pSrcItem, nullptr);
return;
}
@@ -12691,7 +12690,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
Item* pNewItem = pSrcItem->CloneItem(count, this);
if (!pNewItem)
{
- SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL);
+ SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, nullptr);
return;
}
@@ -12706,7 +12705,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
{
delete pNewItem;
pSrcItem->SetCount(pSrcItem->GetCount() + count);
- SendEquipError(msg, pSrcItem, NULL);
+ SendEquipError(msg, pSrcItem, nullptr);
return;
}
@@ -12726,7 +12725,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
{
delete pNewItem;
pSrcItem->SetCount(pSrcItem->GetCount() + count);
- SendEquipError(msg, pSrcItem, NULL);
+ SendEquipError(msg, pSrcItem, nullptr);
return;
}
@@ -12746,7 +12745,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
{
delete pNewItem;
pSrcItem->SetCount(pSrcItem->GetCount() + count);
- SendEquipError(msg, pSrcItem, NULL);
+ SendEquipError(msg, pSrcItem, nullptr);
return;
}
@@ -12837,7 +12836,7 @@ void Player::SwapItem(uint16 src, uint16 dst)
InventoryResult msg = CanStoreItem(dstbag, dstslot, dest, pSrcItem, false);
if (msg != EQUIP_ERR_OK)
{
- SendEquipError(msg, pSrcItem, NULL);
+ SendEquipError(msg, pSrcItem, nullptr);
return;
}
@@ -12852,7 +12851,7 @@ void Player::SwapItem(uint16 src, uint16 dst)
InventoryResult msg = CanBankItem(dstbag, dstslot, dest, pSrcItem, false);
if (msg != EQUIP_ERR_OK)
{
- SendEquipError(msg, pSrcItem, NULL);
+ SendEquipError(msg, pSrcItem, nullptr);
return;
}
@@ -12866,7 +12865,7 @@ void Player::SwapItem(uint16 src, uint16 dst)
InventoryResult msg = CanEquipItem(dstslot, dest, pSrcItem, false);
if (msg != EQUIP_ERR_OK)
{
- SendEquipError(msg, pSrcItem, NULL);
+ SendEquipError(msg, pSrcItem, nullptr);
return;
}
@@ -12975,8 +12974,8 @@ void Player::SwapItem(uint16 src, uint16 dst)
{
if (Bag* dstBag = pDstItem->ToBag())
{
- Bag* emptyBag = NULL;
- Bag* fullBag = NULL;
+ Bag* emptyBag = nullptr;
+ Bag* fullBag = nullptr;
if (srcBag->IsEmpty() && !IsBagPos(src))
{
emptyBag = srcBag;
@@ -13089,7 +13088,6 @@ void Player::SwapItem(uint16 src, uint16 dst)
if (bagItem->m_lootGenerated)
{
m_session->DoLootRelease(GetLootGUID());
- released = true; // not realy needed here
break;
}
}
@@ -13137,7 +13135,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem)
TC_LOG_DEBUG("entities.player.items", "STORAGE: AddItemToBuyBackSlot item = %u, slot = %u", pItem->GetEntry(), slot);
m_items[slot] = pItem;
- time_t base = time(NULL);
+ time_t base = time(nullptr);
uint32 etime = uint32(base - m_logintime + (30 * 3600));
uint32 eslot = slot - BUYBACK_SLOT_START;
@@ -13159,7 +13157,7 @@ Item* Player::GetItemFromBuyBackSlot(uint32 slot)
TC_LOG_DEBUG("entities.player.items", "STORAGE: GetItemFromBuyBackSlot slot = %u", slot);
if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END)
return m_items[slot];
- return NULL;
+ return nullptr;
}
void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del)
@@ -13175,7 +13173,7 @@ void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del)
pItem->SetState(ITEM_REMOVED, this);
}
- m_items[slot] = NULL;
+ m_items[slot] = nullptr;
uint32 eslot = slot - BUYBACK_SLOT_START;
SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), ObjectGuid::Empty);
@@ -13188,7 +13186,7 @@ void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del)
}
}
-void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint32 itemid)
+void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint32 itemid) const
{
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg);
WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I ? 22 : 18));
@@ -13231,7 +13229,7 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint
GetSession()->SendPacket(&data);
}
-void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param)
+void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param) const
{
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_BUY_FAILED");
WorldPacket data(SMSG_BUY_FAILED, (8+4+4+1));
@@ -13243,7 +13241,7 @@ void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32
GetSession()->SendPacket(&data);
}
-void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param)
+void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param) const
{
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_SELL_ITEM");
WorldPacket data(SMSG_SELL_ITEM, (8+8+(param?4:0)+1)); // last check 2.0.10
@@ -13281,9 +13279,9 @@ void Player::TradeCancel(bool sendback)
// cleanup
delete m_trade;
- m_trade = NULL;
+ m_trade = nullptr;
delete trader->m_trade;
- trader->m_trade = NULL;
+ trader->m_trade = nullptr;
}
}
@@ -13776,7 +13774,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
{
if (getClass() == CLASS_SHAMAN)
{
- float addValue = 0.0f;
+ float addValue;
if (item->GetSlot() == EQUIPMENT_SLOT_MAINHAND)
{
addValue = float(enchant_amount * item->GetTemplate()->Delay / 1000.0f);
@@ -14143,7 +14141,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
int32 cost = int32(item->BoxMoney);
if (!HasEnoughMoney(cost))
{
- SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
+ SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, nullptr, 0, 0);
PlayerTalkClass->SendCloseGossip();
return;
}
@@ -14168,7 +14166,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
break;
case GOSSIP_OPTION_SPIRITHEALER:
if (isDead())
- source->ToCreature()->CastSpell(source->ToCreature(), 17251, true, NULL, NULL, GetGUID());
+ source->ToCreature()->CastSpell(source->ToCreature(), 17251, true, nullptr, nullptr, GetGUID());
break;
case GOSSIP_OPTION_QUESTGIVER:
PrepareQuestMenu(guid);
@@ -14189,8 +14187,8 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
{
// Cast spells that teach dual spec
// Both are also ImplicitTarget self and must be cast by player
- CastSpell(this, 63680, true, NULL, NULL, GetGUID());
- CastSpell(this, 63624, true, NULL, NULL, GetGUID());
+ CastSpell(this, 63680, true, nullptr, nullptr, GetGUID());
+ CastSpell(this, 63624, true, nullptr, nullptr, GetGUID());
// Should show another Gossip text with "Congratulations..."
PlayerTalkClass->SendCloseGossip();
@@ -14443,7 +14441,7 @@ bool Player::IsActiveQuest(uint32 quest_id) const
return m_QuestStatus.find(quest_id) != m_QuestStatus.end();
}
-Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest)
+Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest) const
{
QuestRelationBounds objectQR;
@@ -14460,7 +14458,7 @@ Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest)
if (pGameObject)
objectQR = sObjectMgr->GetGOQuestRelationBounds(pGameObject->GetEntry());
else
- return NULL;
+ return nullptr;
}
uint32 nextQuestID = quest->GetNextQuestInChain();
@@ -14470,7 +14468,7 @@ Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest)
return sObjectMgr->GetQuestTemplate(nextQuestID);
}
- return NULL;
+ return nullptr;
}
bool Player::CanSeeStartQuest(Quest const* quest)
@@ -14500,7 +14498,7 @@ bool Player::CanTakeQuest(Quest const* quest, bool msg)
&& SatisfyQuestConditions(quest, msg);
}
-bool Player::CanAddQuest(Quest const* quest, bool msg)
+bool Player::CanAddQuest(Quest const* quest, bool msg) const
{
if (!SatisfyQuestLog(msg))
return false;
@@ -14515,9 +14513,9 @@ bool Player::CanAddQuest(Quest const* quest, bool msg)
// player already have max number (in most case 1) source item, no additional item needed and quest can be added.
if (msg2 == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS)
return true;
- else if (msg2 != EQUIP_ERR_OK)
+ if (msg2 != EQUIP_ERR_OK)
{
- SendEquipError(msg2, NULL, NULL, srcitem);
+ SendEquipError(msg2, nullptr, nullptr, srcitem);
return false;
}
}
@@ -14636,7 +14634,7 @@ bool Player::CanRewardQuest(Quest const* quest, bool msg)
GetItemCount(quest->RequiredItemId[i]) < quest->RequiredItemCount[i])
{
if (msg)
- SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL, quest->RequiredItemId[i]);
+ SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr, quest->RequiredItemId[i]);
return false;
}
}
@@ -14668,7 +14666,7 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver)
case TYPEID_ITEM:
case TYPEID_CONTAINER:
{
- Item* item = (Item*)questGiver;
+ Item* item = static_cast<Item*>(questGiver);
sScriptMgr->OnQuestAccept(this, item, quest);
// destroy not required for quest finish quest starting item
@@ -14710,7 +14708,7 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg)
InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardChoiceItemId[reward], quest->RewardChoiceItemCount[reward]);
if (res != EQUIP_ERR_OK)
{
- SendEquipError(res, NULL, NULL, quest->RewardChoiceItemId[reward]);
+ SendEquipError(res, nullptr, nullptr, quest->RewardChoiceItemId[reward]);
return false;
}
}
@@ -14725,7 +14723,7 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg)
InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardItemId[i], quest->RewardItemIdCount[i]);
if (res != EQUIP_ERR_OK)
{
- SendEquipError(res, NULL, NULL, quest->RewardItemId[i]);
+ SendEquipError(res, nullptr, nullptr, quest->RewardItemId[i]);
return false;
}
}
@@ -14788,7 +14786,7 @@ void Player::AddQuest(Quest const* quest, Object* questGiver)
AddTimedQuest(quest_id);
questStatusData.Timer = timeAllowed * IN_MILLISECONDS;
- qtime = static_cast<uint32>(time(NULL)) + timeAllowed;
+ qtime = static_cast<uint32>(time(nullptr)) + timeAllowed;
}
else
questStatusData.Timer = 0;
@@ -14842,7 +14840,7 @@ void Player::CompleteQuest(uint32 quest_id)
if (sWorld->getBoolConfig(CONFIG_QUEST_ENABLE_QUEST_TRACKER)) // check if Quest Tracker is enabled
{
- // prepare Quest Tracker datas
+ // prepare Quest Tracker data
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_COMPLETE_TIME);
stmt->setUInt32(0, quest_id);
stmt->setUInt32(1, GetGUID().GetCounter());
@@ -14936,7 +14934,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
int32 moneyRew = 0;
if (getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
- GiveXP(XP, NULL);
+ GiveXP(XP, nullptr);
else
moneyRew = int32(quest->GetRewMoneyMaxLevel() * sWorld->getRate(RATE_DROP_MONEY));
@@ -14954,7 +14952,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
// honor reward
if (uint32 honor = quest->CalculateHonorGain(getLevel()))
- RewardHonor(NULL, 0, honor);
+ RewardHonor(nullptr, 0, honor);
// title reward
if (quest->GetCharTitleId())
@@ -15004,7 +15002,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
// StoreNewItem, mail reward, etc. save data directly to the database
// to prevent exploitable data desynchronisation we save the quest status to the database too
// (to prevent rewarding this quest another time while rewards were already given out)
- SQLTransaction trans = SQLTransaction(NULL);
+ SQLTransaction trans = SQLTransaction(nullptr);
_SaveQuestStatus(trans);
if (announce)
@@ -15117,7 +15115,7 @@ bool Player::SatisfyQuestSkill(Quest const* qInfo, bool msg) const
return true;
}
-bool Player::SatisfyQuestLevel(Quest const* qInfo, bool msg)
+bool Player::SatisfyQuestLevel(Quest const* qInfo, bool msg) const
{
if (getLevel() < qInfo->GetMinLevel())
{
@@ -15128,7 +15126,8 @@ bool Player::SatisfyQuestLevel(Quest const* qInfo, bool msg)
}
return false;
}
- else if (qInfo->GetMaxLevel() > 0 && getLevel() > qInfo->GetMaxLevel())
+
+ if (qInfo->GetMaxLevel() > 0 && getLevel() > qInfo->GetMaxLevel())
{
if (msg)
{
@@ -15140,7 +15139,7 @@ bool Player::SatisfyQuestLevel(Quest const* qInfo, bool msg)
return true;
}
-bool Player::SatisfyQuestLog(bool msg)
+bool Player::SatisfyQuestLog(bool msg) const
{
// exist free slot
if (FindQuestSlot(0) < MAX_QUEST_LOG_SIZE)
@@ -15270,7 +15269,7 @@ bool Player::SatisfyQuestClass(Quest const* qInfo, bool msg) const
return true;
}
-bool Player::SatisfyQuestRace(Quest const* qInfo, bool msg)
+bool Player::SatisfyQuestRace(Quest const* qInfo, bool msg) const
{
uint32 reqraces = qInfo->GetAllowableRaces();
if (reqraces == 0)
@@ -15328,7 +15327,7 @@ bool Player::SatisfyQuestReputation(Quest const* qInfo, bool msg)
return true;
}
-bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg)
+bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg) const
{
if (GetQuestStatus(qInfo->GetQuestId()) != QUEST_STATUS_NONE)
{
@@ -15357,7 +15356,7 @@ bool Player::SatisfyQuestConditions(Quest const* qInfo, bool msg)
return true;
}
-bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg)
+bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg) const
{
if (!m_timedquests.empty() && qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED))
{
@@ -15415,7 +15414,7 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg)
return true;
}
-bool Player::SatisfyQuestNextChain(Quest const* qInfo, bool msg)
+bool Player::SatisfyQuestNextChain(Quest const* qInfo, bool msg) const
{
uint32 nextQuest = qInfo->GetNextQuestInChain();
if (!nextQuest)
@@ -15469,7 +15468,7 @@ bool Player::SatisfyQuestPrevChain(Quest const* qInfo, bool msg)
return true;
}
-bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg)
+bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg) const
{
if (!qInfo->IsDaily() && !qInfo->IsDFQuest())
return true;
@@ -15557,8 +15556,8 @@ bool Player::GiveQuestSourceItem(Quest const* quest)
// player already have max amount required item, just report success
else if (msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS)
return true;
- else
- SendEquipError(msg, NULL, NULL, srcitem);
+
+ SendEquipError(msg, nullptr, nullptr, srcitem);
return false;
}
@@ -15587,7 +15586,7 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg)
if (res != EQUIP_ERR_OK)
{
if (msg)
- SendEquipError(res, NULL, NULL, srcItemId);
+ SendEquipError(res, nullptr, nullptr, srcItemId);
return false;
}
@@ -15833,15 +15832,17 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
}
// not used in Trinity, but used in scripting code
-uint16 Player::GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry)
+uint16 Player::GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) const
{
Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id);
if (!qInfo)
return 0;
- for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
- if (qInfo->RequiredNpcOrGo[j] == entry)
- return m_QuestStatus[quest_id].CreatureOrGOCount[j];
+ auto itr = m_QuestStatus.find(quest_id);
+ if (itr != m_QuestStatus.end())
+ for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
+ if (qInfo->RequiredNpcOrGo[j] == entry)
+ return itr->second.CreatureOrGOCount[j];
return 0;
}
@@ -15964,7 +15965,7 @@ void Player::GroupEventHappens(uint32 questId, WorldObject const* pEventObject)
{
if (Group* group = GetGroup())
{
- for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
+ for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* player = itr->GetSource();
@@ -16074,7 +16075,7 @@ void Player::KilledMonsterCredit(uint32 entry, ObjectGuid guid /*= ObjectGuid::E
{
uint16 addkillcount = 1;
uint32 real_entry = entry;
- Creature* killed = NULL;
+ Creature* killed = nullptr;
if (guid)
{
killed = GetMap()->GetCreature(guid);
@@ -16427,7 +16428,7 @@ bool Player::HasQuestForItem(uint32 itemid) const
return false;
}
-void Player::SendQuestComplete(uint32 quest_id)
+void Player::SendQuestComplete(uint32 quest_id) const
{
if (quest_id)
{
@@ -16438,7 +16439,7 @@ void Player::SendQuestComplete(uint32 quest_id)
}
}
-void Player::SendQuestReward(Quest const* quest, uint32 XP)
+void Player::SendQuestReward(Quest const* quest, uint32 XP) const
{
uint32 questid = quest->GetQuestId();
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_COMPLETE quest = %u", questid);
@@ -16463,7 +16464,7 @@ void Player::SendQuestReward(Quest const* quest, uint32 XP)
GetSession()->SendPacket(&data);
}
-void Player::SendQuestFailed(uint32 questId, InventoryResult reason)
+void Player::SendQuestFailed(uint32 questId, InventoryResult reason) const
{
if (questId)
{
@@ -16475,7 +16476,7 @@ void Player::SendQuestFailed(uint32 questId, InventoryResult reason)
}
}
-void Player::SendQuestTimerFailed(uint32 quest_id)
+void Player::SendQuestTimerFailed(uint32 quest_id) const
{
if (quest_id)
{
@@ -16494,7 +16495,7 @@ void Player::SendCanTakeQuestResponse(QuestFailedReason msg) const
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_INVALID");
}
-void Player::SendQuestConfirmAccept(const Quest* quest, Player* pReceiver)
+void Player::SendQuestConfirmAccept(const Quest* quest, Player* pReceiver) const
{
if (pReceiver)
{
@@ -16515,7 +16516,7 @@ void Player::SendQuestConfirmAccept(const Quest* quest, Player* pReceiver)
}
}
-void Player::SendPushToPartyResponse(Player* player, uint8 msg)
+void Player::SendPushToPartyResponse(Player* player, uint8 msg) const
{
if (player)
{
@@ -16527,7 +16528,7 @@ void Player::SendPushToPartyResponse(Player* player, uint8 msg)
}
}
-void Player::SendQuestUpdateAddItem(Quest const* /*quest*/, uint32 /*item_idx*/, uint16 /*count*/)
+void Player::SendQuestUpdateAddItem(Quest const* /*quest*/, uint32 /*item_idx*/, uint16 /*count*/) const
{
WorldPacket data(SMSG_QUESTUPDATE_ADD_ITEM, 0);
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTUPDATE_ADD_ITEM");
@@ -16901,10 +16902,10 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
{
SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty);
- SetVisibleItemSlot(slot, NULL);
+ SetVisibleItemSlot(slot, nullptr);
delete m_items[slot];
- m_items[slot] = NULL;
+ m_items[slot] = nullptr;
}
TC_LOG_DEBUG("entities.player.loading", "Load Basic values of player %s: ", m_name.c_str());
@@ -16983,7 +16984,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
// Player was saved in Arena or Bg
else if (mapEntry && mapEntry->IsBattlegroundOrArena())
{
- Battleground* currentBg = NULL;
+ Battleground* currentBg = nullptr;
if (m_bgData.bgInstanceID) //saved in Battleground
currentBg = sBattlegroundMgr->GetBattleground(m_bgData.bgInstanceID, BATTLEGROUND_TYPE_NONE);
@@ -17033,7 +17034,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
{
ObjectGuid transGUID(HighGuid::Mo_Transport, transLowGUID);
- Transport* transport = NULL;
+ Transport* transport = nullptr;
if (Transport* go = HashMapHolder<Transport>::Find(transGUID))
transport = go;
@@ -17086,7 +17087,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
else if (!m_taxi.LoadTaxiDestinationsFromString(taxi_nodes, GetTeam()))
{
// problems with taxi path loading
- TaxiNodesEntry const* nodeEntry = NULL;
+ TaxiNodesEntry const* nodeEntry = nullptr;
if (uint32 node_id = m_taxi.GetTaxiSource())
nodeEntry = sTaxiNodesStore.LookupEntry(node_id);
@@ -17140,7 +17141,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
// NOW player must have valid map
// load the player's map here if it's not already loaded
Map* map = sMapMgr->CreateMap(mapId, this, instanceId);
- AreaTrigger const* areaTrigger = NULL;
+ AreaTrigger const* areaTrigger = nullptr;
bool check = false;
if (!map)
@@ -17198,7 +17199,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
TC_LOG_ERROR("entities.player", "Player %s %s Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.",
m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
RelocateToHomebind();
- map = NULL;
+ map = nullptr;
}
}
@@ -17228,7 +17229,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
SaveRecallPosition();
- time_t now = time(NULL);
+ time_t now = time(nullptr);
time_t logoutTime = time_t(fields[22].GetUInt32());
// since last logout (in seconds)
@@ -17619,7 +17620,7 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff)
else
remaincharges = 0;
- if (Aura* aura = Aura::TryCreate(spellInfo, effmask, this, NULL, &baseDamage[0], NULL, caster_guid))
+ if (Aura* aura = Aura::TryCreate(spellInfo, effmask, this, nullptr, &baseDamage[0], nullptr, caster_guid))
{
if (!aura->CanBeSaved())
{
@@ -17717,7 +17718,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff)
// Item is not in bag
if (!bagGuid)
{
- item->SetContainer(NULL);
+ item->SetContainer(nullptr);
item->SetSlot(slot);
if (IsInventoryPos(INVENTORY_SLOT_BAG_0, slot))
@@ -17819,7 +17820,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff)
Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields)
{
- Item* item = NULL;
+ Item* item = nullptr;
ObjectGuid::LowType itemGuid = fields[13].GetUInt32();
uint32 itemEntry = fields[14].GetUInt32();
if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry))
@@ -17828,7 +17829,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F
item = NewItemOrBag(proto);
if (item->LoadFromDB(itemGuid, GetGUID(), fields, itemEntry))
{
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
// Do not allow to have item limited to another map/zone in alive state
if (IsAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(), zoneId))
@@ -17931,7 +17932,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F
Item::DeleteFromInventoryDB(trans, itemGuid);
item->FSetState(ITEM_REMOVED);
item->SaveToDB(trans); // it also deletes item object!
- item = NULL;
+ item = nullptr;
}
}
else
@@ -17991,7 +17992,7 @@ void Player::_LoadMailedItems(Mail* mail)
item->FSetState(ITEM_REMOVED);
- SQLTransaction temp = SQLTransaction(NULL);
+ SQLTransaction temp = SQLTransaction(nullptr);
item->SaveToDB(temp); // it also deletes item object !
continue;
}
@@ -18438,7 +18439,7 @@ InstancePlayerBind* Player::GetBoundInstance(uint32 mapid, Difficulty difficulty
// some instances only have one difficulty
MapDifficulty const* mapDiff = GetDownscaledMapDifficultyData(mapid, difficulty);
if (!mapDiff)
- return NULL;
+ return nullptr;
BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid);
if (itr != m_boundInstances[difficulty].end())
@@ -18549,7 +18550,7 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave* save, bool permanent, B
return &bind;
}
- return NULL;
+ return nullptr;
}
void Player::BindToInstance()
@@ -18583,7 +18584,7 @@ void Player::SendRaidInfo()
size_t p_counter = data.wpos();
data << uint32(counter); // placeholder
- time_t now = time(NULL);
+ time_t now = time(nullptr);
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
@@ -18885,7 +18886,7 @@ void Player::SaveToDB(bool create /*=false*/)
if (!create)
sScriptMgr->OnPlayerSave(this);
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
uint8 index = 0;
if (create)
@@ -18928,7 +18929,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]);
stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]);
stmt->setFloat(index++, finiteAlways(m_rest_bonus));
- stmt->setUInt32(index++, uint32(time(NULL)));
+ stmt->setUInt32(index++, uint32(time(nullptr)));
stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
//save, far from tavern/city
//save, but in tavern/city
@@ -18994,7 +18995,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setString(index++, ss.str());
stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, 2));
- stmt->setUInt32(index++, m_grantableLevels);
+ stmt->setUInt32(index, m_grantableLevels);
}
else
{
@@ -19048,7 +19049,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]);
stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]);
stmt->setFloat(index++, finiteAlways(m_rest_bonus));
- stmt->setUInt32(index++, uint32(time(NULL)));
+ stmt->setUInt32(index++, uint32(time(nullptr)));
stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
//save, far from tavern/city
//save, but in tavern/city
@@ -19167,7 +19168,7 @@ void Player::SaveInventoryAndGoldToDB(SQLTransaction& trans)
SaveGoldToDB(trans);
}
-void Player::SaveGoldToDB(SQLTransaction& trans)
+void Player::SaveGoldToDB(SQLTransaction& trans) const
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_MONEY);
stmt->setUInt32(0, GetMoney());
@@ -19177,7 +19178,7 @@ void Player::SaveGoldToDB(SQLTransaction& trans)
void Player::_SaveActions(SQLTransaction& trans)
{
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
for (ActionButtonList::iterator itr = m_actionButtons.begin(); itr != m_actionButtons.end();)
{
@@ -19281,7 +19282,7 @@ void Player::_SaveAuras(SQLTransaction& trans)
void Player::_SaveInventory(SQLTransaction& trans)
{
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
// force items in buyback slots to new state
// and remove those that aren't already
for (uint8 i = BUYBACK_SLOT_START; i < BUYBACK_SLOT_END; ++i)
@@ -19345,7 +19346,7 @@ void Player::_SaveInventory(SQLTransaction& trans)
if (item->GetState() != ITEM_REMOVED)
{
Item* test = GetItemByPos(item->GetBagSlot(), item->GetSlot());
- if (test == NULL)
+ if (test == nullptr)
{
ObjectGuid::LowType bagTestGUID = 0;
if (Item* test2 = GetItemByPos(INVENTORY_SLOT_BAG_0, item->GetBagSlot()))
@@ -19405,7 +19406,7 @@ void Player::_SaveMail(SQLTransaction& trans)
if (!m_mailsLoaded)
return;
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
{
@@ -19481,7 +19482,7 @@ void Player::_SaveQuestStatus(SQLTransaction& trans)
QuestStatusSaveMap::iterator saveItr;
QuestStatusMap::iterator statusItr;
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
bool keepAbandoned = !(sWorld->GetCleaningFlags() & CharacterDatabaseCleaner::CLEANING_FLAG_QUESTSTATUS);
@@ -19663,7 +19664,7 @@ void Player::_SaveMonthlyQuestStatus(SQLTransaction& trans)
void Player::_SaveSkills(SQLTransaction& trans)
{
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
// we don't need transactions here.
for (SkillStatusMap::iterator itr = mSkillStatus.begin(); itr != mSkillStatus.end();)
{
@@ -19719,7 +19720,7 @@ void Player::_SaveSkills(SQLTransaction& trans)
void Player::_SaveSpells(SQLTransaction& trans)
{
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
for (PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end();)
{
@@ -19757,13 +19758,13 @@ void Player::_SaveSpells(SQLTransaction& trans)
// save player stats -- only for external usage
// real stats will be recalculated on player login
-void Player::_SaveStats(SQLTransaction& trans)
+void Player::_SaveStats(SQLTransaction& trans) const
{
// check if stat saving is enabled and if char level is high enough
if (!sWorld->getIntConfig(CONFIG_MIN_LEVEL_STAT_SAVE) || getLevel() < sWorld->getIntConfig(CONFIG_MIN_LEVEL_STAT_SAVE))
return;
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_STATS);
stmt->setUInt32(0, GetGUID().GetCounter());
@@ -19827,7 +19828,7 @@ void Player::UpdateSpeakTime()
if (GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHAT_SPAM))
return;
- time_t current = time (NULL);
+ time_t current = time(nullptr);
if (m_speakTime > current)
{
uint32 max_count = sWorld->getIntConfig(CONFIG_CHATFLOOD_MESSAGE_COUNT);
@@ -19853,14 +19854,14 @@ void Player::UpdateSpeakTime()
bool Player::CanSpeak() const
{
- return GetSession()->m_muteTime <= time (NULL);
+ return GetSession()->m_muteTime <= time (nullptr);
}
/*********************************************************/
/*** LOW LEVEL FUNCTIONS:Notifiers ***/
/*********************************************************/
-void Player::SendAttackSwingNotInRange()
+void Player::SendAttackSwingNotInRange() const
{
WorldPacket data(SMSG_ATTACKSWING_NOTINRANGE, 0);
GetSession()->SendPacket(&data);
@@ -19917,25 +19918,25 @@ void Player::Customize(CharacterCustomizeInfo const* customizeInfo, SQLTransacti
CharacterDatabase.ExecuteOrAppend(trans, stmt);
}
-void Player::SendAttackSwingDeadTarget()
+void Player::SendAttackSwingDeadTarget() const
{
WorldPacket data(SMSG_ATTACKSWING_DEADTARGET, 0);
GetSession()->SendPacket(&data);
}
-void Player::SendAttackSwingCantAttack()
+void Player::SendAttackSwingCantAttack() const
{
WorldPacket data(SMSG_ATTACKSWING_CANT_ATTACK, 0);
GetSession()->SendPacket(&data);
}
-void Player::SendAttackSwingCancelAttack()
+void Player::SendAttackSwingCancelAttack() const
{
WorldPacket data(SMSG_CANCEL_COMBAT, 0);
GetSession()->SendPacket(&data);
}
-void Player::SendAttackSwingBadFacingAttack()
+void Player::SendAttackSwingBadFacingAttack() const
{
WorldPacket data(SMSG_ATTACKSWING_BADFACING, 0);
GetSession()->SendPacket(&data);
@@ -19948,7 +19949,7 @@ void Player::SendAutoRepeatCancel(Unit* target)
SendMessageToSet(&data, false);
}
-void Player::SendExplorationExperience(uint32 Area, uint32 Experience)
+void Player::SendExplorationExperience(uint32 Area, uint32 Experience) const
{
WorldPacket data(SMSG_EXPLORATION_EXPERIENCE, 8);
data << uint32(Area);
@@ -19956,7 +19957,7 @@ void Player::SendExplorationExperience(uint32 Area, uint32 Experience)
GetSession()->SendPacket(&data);
}
-void Player::SendDungeonDifficulty(bool IsInGroup)
+void Player::SendDungeonDifficulty(bool IsInGroup) const
{
uint8 val = 0x00000001;
WorldPacket data(MSG_SET_DUNGEON_DIFFICULTY, 12);
@@ -19966,7 +19967,7 @@ void Player::SendDungeonDifficulty(bool IsInGroup)
GetSession()->SendPacket(&data);
}
-void Player::SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty)
+void Player::SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty) const
{
uint8 val = 0x00000001;
WorldPacket data(MSG_SET_RAID_DIFFICULTY, 12);
@@ -19976,7 +19977,7 @@ void Player::SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty)
GetSession()->SendPacket(&data);
}
-void Player::SendResetFailedNotify(uint32 mapid)
+void Player::SendResetFailedNotify(uint32 mapid) const
{
WorldPacket data(SMSG_RESET_FAILED_NOTIFY, 4);
data << uint32(mapid);
@@ -20032,14 +20033,14 @@ void Player::ResetInstances(uint8 method, bool isRaid)
}
}
-void Player::SendResetInstanceSuccess(uint32 MapId)
+void Player::SendResetInstanceSuccess(uint32 MapId) const
{
WorldPacket data(SMSG_INSTANCE_RESET, 4);
data << uint32(MapId);
GetSession()->SendPacket(&data);
}
-void Player::SendResetInstanceFailed(uint32 reason, uint32 MapId)
+void Player::SendResetInstanceFailed(uint32 reason, uint32 MapId) const
{
/*reasons for instance reset failure:
// 0: There are players inside the instance.
@@ -20117,12 +20118,12 @@ Pet* Player::GetPet() const
if (ObjectGuid pet_guid = GetPetGUID())
{
if (!pet_guid.IsPet())
- return NULL;
+ return nullptr;
Pet* pet = ObjectAccessor::GetPet(*this, pet_guid);
if (!pet)
- return NULL;
+ return nullptr;
if (IsInWorld() && pet)
return pet;
@@ -20132,7 +20133,7 @@ Pet* Player::GetPet() const
//const_cast<Player*>(this)->SetPetGUID(0);
}
- return NULL;
+ return nullptr;
}
void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
@@ -20227,7 +20228,7 @@ void Player::StopCastingCharm()
if (charm->GetTypeId() == TYPEID_UNIT)
{
if (charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET))
- ((Puppet*)charm)->UnSummon();
+ static_cast<Puppet*>(charm)->UnSummon();
else if (charm->IsVehicle())
ExitVehicle();
}
@@ -20242,8 +20243,8 @@ void Player::StopCastingCharm()
TC_LOG_FATAL("entities.player", "Charmed unit has charmer %s", charm->GetCharmerGUID().ToString().c_str());
ABORT();
}
- else
- SetCharm(charm, false);
+
+ SetCharm(charm, false);
}
}
@@ -20331,7 +20332,7 @@ bool Player::RemoveMItem(uint32 id)
return mMitems.erase(id) ? true : false;
}
-void Player::SendOnCancelExpectedVehicleRideAura()
+void Player::SendOnCancelExpectedVehicleRideAura() const
{
WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
GetSession()->SendPacket(&data);
@@ -20518,14 +20519,14 @@ void Player::CharmSpellInitialize()
GetSession()->SendPacket(&data);
}
-void Player::SendRemoveControlBar()
+void Player::SendRemoveControlBar() const
{
WorldPacket data(SMSG_PET_SPELLS, 8);
data << uint64(0);
GetSession()->SendPacket(&data);
}
-bool Player::IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell)
+bool Player::IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell) const
{
if (!mod || !spellInfo)
return false;
@@ -20714,7 +20715,7 @@ void Player::SetSpellModTakingSpell(Spell* spell, bool apply)
}
// send Proficiency
-void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask)
+void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const
{
WorldPacket data(SMSG_SET_PROFICIENCY, 1 + 4);
data << uint8(itemClass) << uint32(itemSubclassMask);
@@ -20960,7 +20961,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
uint32 firstcost = 0;
uint32 prevnode = sourcenode;
- uint32 lastnode = 0;
+ uint32 lastnode;
for (uint32 i = 1; i < nodes.size(); ++i)
{
@@ -20993,7 +20994,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
// only one mount ID for both sides. Probably not good to use 315 in case DBC nodes
// change but I couldn't find a suitable alternative. OK to use class because only DK
// can use this taxi.
- uint32 mount_display_id = sObjectMgr->GetTaxiMountDisplayId(sourcenode, GetTeam(), npc == NULL || (sourcenode == 315 && getClass() == CLASS_DEATH_KNIGHT));
+ uint32 mount_display_id = sObjectMgr->GetTaxiMountDisplayId(sourcenode, GetTeam(), npc == nullptr || (sourcenode == 315 && getClass() == CLASS_DEATH_KNIGHT));
// in spell case allow 0 model
if ((mount_display_id == 0 && spellid == 0) || sourcepath == 0)
@@ -21053,7 +21054,7 @@ bool Player::ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid /*= 0*/)
nodes[0] = entry->from;
nodes[1] = entry->to;
- return ActivateTaxiPathTo(nodes, NULL, spellid);
+ return ActivateTaxiPathTo(nodes, nullptr, spellid);
}
void Player::CleanupAfterTaxiFlight()
@@ -21064,7 +21065,7 @@ void Player::CleanupAfterTaxiFlight()
getHostileRefManager().setOnlineOfflineState(true);
}
-void Player::ContinueTaxiFlight()
+void Player::ContinueTaxiFlight() const
{
uint32 sourceNode = m_taxi.GetTaxiSource();
if (!sourceNode)
@@ -21083,7 +21084,7 @@ void Player::ContinueTaxiFlight()
TaxiPathNodeList const& nodeList = sTaxiPathNodesByPath[path];
- float distPrev = MAP_SIZE*MAP_SIZE;
+ float distPrev;
float distNext =
(nodeList[0]->LocX - GetPositionX())*(nodeList[0]->LocX - GetPositionX()) +
(nodeList[0]->LocY - GetPositionY())*(nodeList[0]->LocY - GetPositionY()) +
@@ -21201,7 +21202,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c
CanEquipNewItem(slot, uiDest, item, false);
if (msg != EQUIP_ERR_OK)
{
- SendEquipError(msg, NULL, NULL, item);
+ SendEquipError(msg, nullptr, nullptr, item);
return false;
}
@@ -21271,13 +21272,13 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
if (!pProto)
{
- SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, item, 0);
+ SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, item, 0);
return false;
}
if (!(pProto->AllowableClass & getClassMask()) && pProto->Bonding == BIND_WHEN_PICKED_UP && !IsGameMaster())
{
- SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, item, 0);
+ SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, item, 0);
return false;
}
@@ -21288,7 +21289,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
if (!creature)
{
TC_LOG_DEBUG("network", "WORLD: BuyItemFromVendor - %s not found or you can't interact with him.", vendorguid.ToString().c_str());
- SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, NULL, item, 0);
+ SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, item, 0);
return false;
}
@@ -21355,7 +21356,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
// arena points price
if (GetArenaPoints() < (iece->reqarenapoints * count))
{
- SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL);
+ SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, nullptr, nullptr);
return false;
}
@@ -21364,7 +21365,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
{
if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count)))
{
- SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
+ SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, nullptr, nullptr);
return false;
}
}
@@ -21373,7 +21374,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
if (GetMaxPersonalArenaRatingRequirement(iece->reqarenaslot) < iece->reqpersonalarenarating)
{
// probably not the proper equip err
- SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK, NULL, NULL);
+ SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK, nullptr, nullptr);
return false;
}
}
@@ -21408,7 +21409,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
{
if (pProto->BuyCount * count != 1)
{
- SendEquipError(EQUIP_ERR_ITEM_CANT_BE_EQUIPPED, NULL, NULL);
+ SendEquipError(EQUIP_ERR_ITEM_CANT_BE_EQUIPPED, nullptr, nullptr);
return false;
}
if (!_StoreOrEquipNewItem(vendorslot, item, count, bag, slot, price, pProto, creature, crItem, false))
@@ -21416,7 +21417,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
}
else
{
- SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL);
+ SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr);
return false;
}
@@ -21514,7 +21515,7 @@ void Player::UpdatePvPState(bool onlyFFA)
else // in friendly area
{
if (IsPvP() && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) && !pvpInfo.EndTimer)
- pvpInfo.EndTimer = time(NULL); // start toggle-off
+ pvpInfo.EndTimer = time(nullptr); // start toggle-off
}
}
@@ -21534,7 +21535,7 @@ void Player::UpdatePvP(bool state, bool _override)
}
else
{
- pvpInfo.EndTimer = time(NULL);
+ pvpInfo.EndTimer = time(nullptr);
SetPvP(state);
}
}
@@ -21581,7 +21582,7 @@ void Player::clearResurrectRequestData()
m_ghoulResurrectGhoulGUID = ObjectGuid::Empty;
}
//slot to be excluded while counting
-bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot)
+bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) const
{
if (!enchantmentcondition)
return true;
@@ -21983,7 +21984,7 @@ template<>
inline void BeforeVisibilityDestroy<Creature>(Creature* t, Player* p)
{
if (p->GetPetGUID() == t->GetGUID() && t->IsPet())
- ((Pet*)t)->Remove(PET_SAVE_NOT_IN_SLOT, true);
+ t->ToPet()->Remove(PET_SAVE_NOT_IN_SLOT, true);
}
void Player::UpdateVisibilityOf(WorldObject* target)
@@ -22017,7 +22018,7 @@ void Player::UpdateVisibilityOf(WorldObject* target)
// target aura duration for caster show only if target exist at caster client
// send data at target visibility change (adding to client)
if (target->isType(TYPEMASK_UNIT))
- SendInitialVisiblePackets((Unit*)target);
+ SendInitialVisiblePackets(static_cast<Unit*>(target));
}
}
}
@@ -22064,7 +22065,7 @@ void Player::UpdateTriggerVisibility()
GetSession()->SendPacket(&packet);
}
-void Player::SendInitialVisiblePackets(Unit* target)
+void Player::SendInitialVisiblePackets(Unit* target) const
{
SendAurasForTarget(target);
if (target->IsAlive())
@@ -22153,7 +22154,7 @@ bool Player::ModifyMoney(int32 amount, bool sendError /*= true*/)
sScriptMgr->OnPlayerMoneyLimit(this, amount);
if (sendError)
- SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, NULL, NULL);
+ SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, nullptr, nullptr);
return false;
}
}
@@ -22184,14 +22185,14 @@ Unit* Player::GetSelectedUnit() const
{
if (ObjectGuid selectionGUID = GetTarget())
return ObjectAccessor::GetUnit(*this, selectionGUID);
- return NULL;
+ return nullptr;
}
Player* Player::GetSelectedPlayer() const
{
if (ObjectGuid selectionGUID = GetTarget())
return ObjectAccessor::GetPlayer(*this, selectionGUID);
- return NULL;
+ return nullptr;
}
void Player::SendComboPoints()
@@ -22282,7 +22283,7 @@ void Player::ClearComboPoints()
void Player::SetGroup(Group* group, int8 subgroup)
{
- if (group == NULL)
+ if (group == nullptr)
m_group.unlink();
else
{
@@ -22422,7 +22423,7 @@ void Player::SendUpdateToOutOfRangeGroupMembers()
pet->ResetAuraUpdateMaskForRaid();
}
-void Player::SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg)
+void Player::SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg) const
{
WorldPacket data(SMSG_TRANSFER_ABORTED, 4+2);
data << uint32(mapid);
@@ -22441,7 +22442,7 @@ void Player::SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8
GetSession()->SendPacket(&data);
}
-void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome)
+void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome) const
{
// type of warning, based on the time remaining until reset
uint32 type;
@@ -22737,7 +22738,7 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue)
}
}
-void Player::SendAurasForTarget(Unit* target)
+void Player::SendAurasForTarget(Unit* target) const
{
if (!target || target->GetVisibleAuras()->empty()) // speedup things
return;
@@ -22778,7 +22779,7 @@ void Player::SetDailyQuestStatus(uint32 quest_id)
if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
{
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx, quest_id);
- m_lastDailyQuestTime = time(NULL); // last daily quest time
+ m_lastDailyQuestTime = time(nullptr); // last daily quest time
m_DailyQuestChanged = true;
break;
}
@@ -22786,7 +22787,7 @@ void Player::SetDailyQuestStatus(uint32 quest_id)
} else
{
m_DFQuests.insert(quest_id);
- m_lastDailyQuestTime = time(NULL);
+ m_lastDailyQuestTime = time(nullptr);
m_DailyQuestChanged = true;
}
}
@@ -22859,7 +22860,7 @@ void Player::ResetMonthlyQuestStatus()
Battleground* Player::GetBattleground() const
{
if (GetBattlegroundId() == 0)
- return NULL;
+ return nullptr;
return sBattlegroundMgr->GetBattleground(GetBattlegroundId(), m_bgData.bgTypeID);
}
@@ -22918,7 +22919,7 @@ uint32 Player::AddBattlegroundQueueId(BattlegroundQueueTypeId val)
return PLAYER_MAX_BATTLEGROUND_QUEUES;
}
-bool Player::HasFreeBattlegroundQueueId()
+bool Player::HasFreeBattlegroundQueueId() const
{
for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
@@ -23106,7 +23107,7 @@ void Player::UpdateForQuestWorldObjects()
void Player::SetSummonPoint(uint32 mapid, float x, float y, float z)
{
- m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
+ m_summon_expire = time(nullptr) + MAX_PLAYER_SUMMON_DELAY;
m_summon_mapid = mapid;
m_summon_x = x;
m_summon_y = y;
@@ -23122,7 +23123,7 @@ void Player::SummonIfPossible(bool agree)
}
// expire and auto declined
- if (m_summon_expire < time(NULL))
+ if (m_summon_expire < time(nullptr))
return;
// stop taxi flight at summon
@@ -23369,7 +23370,7 @@ bool Player::GetsRecruitAFriendBonus(bool forXP)
{
if (Group* group = this->GetGroup())
{
- for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
+ for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* player = itr->GetSource();
if (!player)
@@ -23418,7 +23419,7 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar
// prepare data for near group iteration
if (Group* group = GetGroup())
{
- for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
+ for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* player = itr->GetSource();
if (!player)
@@ -23528,7 +23529,7 @@ void Player::SetClientControl(Unit* target, bool allowMove)
void Player::SetMover(Unit* target)
{
- m_mover->m_movedPlayer = NULL;
+ m_mover->m_movedPlayer = nullptr;
m_mover = target;
m_mover->m_movedPlayer = this;
}
@@ -23573,7 +23574,7 @@ uint32 Player::GetCorpseReclaimDelay(bool pvp) const
else if (!sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))
return 0;
- time_t now = time(NULL);
+ time_t now = time(nullptr);
// 0..2 full period
// should be ceil(x)-1 but not floor(x)
uint64 count = (now < m_deathExpireTime - 1) ? (m_deathExpireTime - 1 - now) / DEATH_EXPIRE_STEP : 0;
@@ -23588,7 +23589,7 @@ void Player::UpdateCorpseReclaimDelay()
(!pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE)))
return;
- time_t now = time(NULL);
+ time_t now = time(nullptr);
if (now < m_deathExpireTime)
{
@@ -23604,7 +23605,7 @@ void Player::UpdateCorpseReclaimDelay()
m_deathExpireTime = now + DEATH_EXPIRE_STEP;
}
-int32 Player::CalculateCorpseReclaimDelay(bool load)
+int32 Player::CalculateCorpseReclaimDelay(bool load) const
{
Corpse* corpse = GetCorpse();
@@ -23632,7 +23633,7 @@ int32 Player::CalculateCorpseReclaimDelay(bool load)
}
time_t expected_time = corpse->GetGhostTime() + copseReclaimDelay[count];
- time_t now = time(NULL);
+ time_t now = time(nullptr);
if (now >= expected_time)
return -1;
@@ -23645,7 +23646,7 @@ int32 Player::CalculateCorpseReclaimDelay(bool load)
return delay * IN_MILLISECONDS;
}
-void Player::SendCorpseReclaimDelay(uint32 delay)
+void Player::SendCorpseReclaimDelay(uint32 delay) const
{
WorldPacket data(SMSG_CORPSE_RECLAIM_DELAY, 4);
data << uint32(delay);
@@ -23656,12 +23657,12 @@ Player* Player::GetNextRandomRaidMember(float radius)
{
Group* group = GetGroup();
if (!group)
- return NULL;
+ return nullptr;
std::vector<Player*> nearMembers;
nearMembers.reserve(group->GetMembersCount());
- for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
+ for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* Target = itr->GetSource();
@@ -23672,7 +23673,7 @@ Player* Player::GetNextRandomRaidMember(float radius)
}
if (nearMembers.empty())
- return NULL;
+ return nullptr;
uint32 randTarget = urand(0, nearMembers.size()-1);
return nearMembers[randTarget];
@@ -23704,7 +23705,7 @@ PartyResult Player::CanUninviteFromGroup(ObjectGuid guidMember) const
return ERR_PARTY_LFG_BOOT_LOOT_ROLLS;
/// @todo Should also be sent when anyone has recently left combat, with an aprox ~5 seconds timer.
- for (GroupReference const* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
+ for (GroupReference const* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
if (itr->GetSource() && itr->GetSource()->IsInCombat())
return ERR_PARTY_LFG_BOOT_IN_COMBAT;
@@ -23728,12 +23729,12 @@ PartyResult Player::CanUninviteFromGroup(ObjectGuid guidMember) const
return ERR_PARTY_RESULT_OK;
}
-bool Player::isUsingLfg()
+bool Player::isUsingLfg() const
{
return sLFGMgr->GetState(GetGUID()) != lfg::LFG_STATE_NONE;
}
-bool Player::inRandomLfgDungeon()
+bool Player::inRandomLfgDungeon() const
{
if (sLFGMgr->selectedRandomLfgDungeon(GetGUID()))
{
@@ -23763,12 +23764,12 @@ void Player::RemoveFromBattlegroundOrBattlefieldRaid()
m_group.link(group, this);
m_group.setSubGroup(GetOriginalSubGroup());
}
- SetOriginalGroup(NULL);
+ SetOriginalGroup(nullptr);
}
void Player::SetOriginalGroup(Group* group, int8 subgroup)
{
- if (group == NULL)
+ if (group == nullptr)
m_originalGroup.unlink();
else
{
@@ -23789,7 +23790,7 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z)
if (_lastLiquid && _lastLiquid->SpellId)
RemoveAurasDueToSpell(_lastLiquid->SpellId);
- _lastLiquid = NULL;
+ _lastLiquid = nullptr;
return;
}
@@ -23815,7 +23816,7 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z)
else if (_lastLiquid && _lastLiquid->SpellId)
{
RemoveAurasDueToSpell(_lastLiquid->SpellId);
- _lastLiquid = NULL;
+ _lastLiquid = nullptr;
}
@@ -23870,7 +23871,7 @@ void Player::SetCanBlock(bool value)
UpdateBlockPercentage();
}
-bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const
+bool ItemPosCount::isContainedIn(std::vector<ItemPosCount> const& vec) const
{
for (ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end(); ++itr)
if (itr->pos == pos)
@@ -23878,15 +23879,15 @@ bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const
return false;
}
-void Player::StopCastingBindSight()
+void Player::StopCastingBindSight() const
{
if (WorldObject* target = GetViewpoint())
{
if (target->isType(TYPEMASK_UNIT))
{
- ((Unit*)target)->RemoveAurasByType(SPELL_AURA_BIND_SIGHT, GetGUID());
- ((Unit*)target)->RemoveAurasByType(SPELL_AURA_MOD_POSSESS, GetGUID());
- ((Unit*)target)->RemoveAurasByType(SPELL_AURA_MOD_POSSESS_PET, GetGUID());
+ static_cast<Unit*>(target)->RemoveAurasByType(SPELL_AURA_BIND_SIGHT, GetGUID());
+ static_cast<Unit*>(target)->RemoveAurasByType(SPELL_AURA_MOD_POSSESS, GetGUID());
+ static_cast<Unit*>(target)->RemoveAurasByType(SPELL_AURA_MOD_POSSESS_PET, GetGUID());
}
}
}
@@ -23907,7 +23908,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
UpdateVisibilityOf(target);
if (target->isType(TYPEMASK_UNIT) && target != GetVehicleBase())
- ((Unit*)target)->AddPlayerToVision(this);
+ static_cast<Unit*>(target)->AddPlayerToVision(this);
}
else
{
@@ -23920,7 +23921,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
}
if (target->isType(TYPEMASK_UNIT) && target != GetVehicleBase())
- ((Unit*)target)->RemovePlayerFromVision(this);
+ static_cast<Unit*>(target)->RemovePlayerFromVision(this);
//must immediately set seer back otherwise may crash
m_seer = this;
@@ -23958,11 +23959,11 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
WorldObject* Player::GetViewpoint() const
{
if (ObjectGuid guid = GetGuidValue(PLAYER_FARSIGHT))
- return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_SEER);
- return NULL;
+ return static_cast<WorldObject*>(ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_SEER));
+ return nullptr;
}
-bool Player::CanUseBattlegroundObject(GameObject* gameobject)
+bool Player::CanUseBattlegroundObject(GameObject* gameobject) const
{
// It is possible to call this method with a null pointer, only skipping faction check.
if (gameobject)
@@ -23981,14 +23982,14 @@ bool Player::CanUseBattlegroundObject(GameObject* gameobject)
IsAlive()); // Alive
}
-bool Player::CanCaptureTowerPoint()
+bool Player::CanCaptureTowerPoint() const
{
return (!HasStealthAura() && // not stealthed
!HasInvisibilityAura() && // not invisible
IsAlive()); // live player
}
-uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin)
+uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin) const
{
uint8 level = getLevel();
@@ -24056,7 +24057,7 @@ void Player::SetGlyph(uint8 slot, uint32 glyph)
SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph);
}
-bool Player::isTotalImmune()
+bool Player::isTotalImmune() const
{
AuraEffectList const& immune = GetAuraEffectsByType(SPELL_AURA_SCHOOL_IMMUNITY);
@@ -24106,7 +24107,7 @@ void Player::SetTitle(CharTitlesEntry const* title, bool lost)
GetSession()->SendPacket(&data);
}
-bool Player::isTotalImmunity()
+bool Player::isTotalImmunity() const
{
AuraEffectList const& immune = GetAuraEffectsByType(SPELL_AURA_SCHOOL_IMMUNITY);
@@ -24182,7 +24183,7 @@ void Player::RemoveRunesByAuraEffect(AuraEffect const* aura)
if (m_runes->runes[i].ConvertAura == aura)
{
ConvertRune(i, GetBaseRune(i));
- SetRuneConvertAura(i, NULL);
+ SetRuneConvertAura(i, nullptr);
}
}
}
@@ -24190,11 +24191,11 @@ void Player::RemoveRunesByAuraEffect(AuraEffect const* aura)
void Player::RestoreBaseRune(uint8 index)
{
AuraEffect const* aura = m_runes->runes[index].ConvertAura;
- // If rune was converted by a non-pasive aura that still active we should keep it converted
+ // If rune was converted by a non-passive aura that still active we should keep it converted
if (aura && !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_PASSIVE))
return;
ConvertRune(index, GetBaseRune(index));
- SetRuneConvertAura(index, NULL);
+ SetRuneConvertAura(index, nullptr);
// Don't drop passive talents providing rune convertion
if (!aura || aura->GetAuraType() != SPELL_AURA_CONVERT_RUNE)
return;
@@ -24216,7 +24217,7 @@ void Player::ConvertRune(uint8 index, RuneType newType)
GetSession()->SendPacket(&data);
}
-void Player::ResyncRunes(uint8 count)
+void Player::ResyncRunes(uint8 count) const
{
WorldPacket data(SMSG_RESYNC_RUNES, 4 + count * 2);
data << uint32(count);
@@ -24228,7 +24229,7 @@ void Player::ResyncRunes(uint8 count)
GetSession()->SendPacket(&data);
}
-void Player::AddRunePower(uint8 index)
+void Player::AddRunePower(uint8 index) const
{
WorldPacket data(SMSG_ADD_RUNE_POWER, 4);
data << uint32(1 << index); // mask (0x00-0x3F probably)
@@ -24262,7 +24263,7 @@ void Player::InitRunes()
SetRuneCooldown(i, 0); // reset cooldowns
SetRuneTimer(i, 0xFFFFFFFF); // Reset rune flags
SetLastRuneGraceTimer(i, 0);
- SetRuneConvertAura(i, NULL);
+ SetRuneConvertAura(i, nullptr);
m_runes->SetRuneState(i);
}
@@ -24297,7 +24298,7 @@ void Player::AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore cons
msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, lootItem->itemid, lootItem->count);
if (msg != EQUIP_ERR_OK)
{
- SendEquipError(msg, NULL, NULL, lootItem->itemid);
+ SendEquipError(msg, nullptr, nullptr, lootItem->itemid);
continue;
}
@@ -24308,15 +24309,15 @@ void Player::AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore cons
void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
{
- QuestItem* qitem = NULL;
- QuestItem* ffaitem = NULL;
- QuestItem* conditem = NULL;
+ QuestItem* qitem = nullptr;
+ QuestItem* ffaitem = nullptr;
+ QuestItem* conditem = nullptr;
LootItem* item = loot->LootItemInSlot(lootSlot, this, &qitem, &ffaitem, &conditem);
if (!item)
{
- SendEquipError(EQUIP_ERR_ALREADY_LOOTED, NULL, NULL);
+ SendEquipError(EQUIP_ERR_ALREADY_LOOTED, nullptr, nullptr);
return;
}
@@ -24383,7 +24384,7 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
}
else
- SendEquipError(msg, NULL, NULL, item->itemid);
+ SendEquipError(msg, nullptr, nullptr, item->itemid);
}
uint32 Player::CalculateTalentsPoints() const
@@ -25291,7 +25292,7 @@ void Player::_SaveEquipmentSets(SQLTransaction& trans)
{
uint32 index = itr->first;
EquipmentSet& eqset = itr->second;
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt = nullptr;
uint8 j = 0;
switch (eqset.state)
{
@@ -25429,7 +25430,7 @@ void Player::_LoadGlyphs(PreparedQueryResult result)
while (result->NextRow());
}
-void Player::_SaveGlyphs(SQLTransaction& trans)
+void Player::_SaveGlyphs(SQLTransaction& trans) const
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GLYPHS);
stmt->setUInt32(0, GetGUID().GetCounter());
@@ -25513,7 +25514,7 @@ void Player::UpdateSpecCount(uint8 count)
ActivateSpec(0);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
- PreparedStatement* stmt = NULL;
+ PreparedStatement* stmt;
// Copy spec data
if (count > curCount)
@@ -25721,7 +25722,7 @@ uint32 Player::GetReputation(uint32 factionentry) const
return GetReputationMgr().GetReputation(sFactionStore.LookupEntry(factionentry));
}
-std::string const& Player::GetGuildName()
+std::string const& Player::GetGuildName() const
{
return sGuildMgr->GetGuildById(GetGuildId())->GetName();
}
@@ -25929,7 +25930,7 @@ void Player::SendItemRetrievalMail(uint32 itemEntry, uint32 count)
MailDraft draft("Recovered Item", "We recovered a lost item in the twisting nether and noted that it was yours.$B$BPlease find said object enclosed."); // This is the text used in Cataclysm, it probably wasn't changed.
SQLTransaction trans = CharacterDatabase.BeginTransaction();
- if (Item* item = Item::CreateItem(itemEntry, count, 0))
+ if (Item* item = Item::CreateItem(itemEntry, count, nullptr))
{
item->SaveToDB(trans);
draft.AddItem(item);
@@ -25960,7 +25961,7 @@ void Player::_LoadRandomBGStatus(PreparedQueryResult result)
m_IsBGRandomWinner = true;
}
-float Player::GetAverageItemLevel()
+float Player::GetAverageItemLevel() const
{
float sum = 0;
uint32 count = 0;
@@ -26138,7 +26139,7 @@ float Player::GetCollisionHeight(bool mounted) const
}
}
-std::string Player::GetMapAreaAndZoneString()
+std::string Player::GetMapAreaAndZoneString() const
{
uint32 areaId = GetAreaId();
std::string areaName = "Unknown";
@@ -26156,7 +26157,7 @@ std::string Player::GetMapAreaAndZoneString()
return str.str();
}
-std::string Player::GetCoordsMapAreaAndZoneString()
+std::string Player::GetCoordsMapAreaAndZoneString() const
{
std::ostringstream str;
str << Position::ToString() << " " << GetMapAreaAndZoneString();
@@ -26191,14 +26192,14 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
if (duration > 0)
pet->SetDuration(duration);
- return NULL;
+ return nullptr;
}
// petentry == 0 for hunter "call pet" (current pet summoned if any)
if (!entry)
{
delete pet;
- return NULL;
+ return nullptr;
}
pet->Relocate(x, y, z, ang);
@@ -26206,7 +26207,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
{
TC_LOG_ERROR("misc", "Pet (guidlow %d, entry %d) not summoned. Suggested coordinates are not valid (X: %f Y: %f)", pet->GetGUID().GetCounter(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY());
delete pet;
- return NULL;
+ return nullptr;
}
Map* map = GetMap();
@@ -26215,7 +26216,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
{
TC_LOG_ERROR("misc", "No such creature entry %u", entry);
delete pet;
- return NULL;
+ return nullptr;
}
pet->SetCreatorGUID(GetGUID());
@@ -26238,7 +26239,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
pet->SetFullHealth();
pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA));
- pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped in this case
+ pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); // cast can't be helped in this case
break;
default:
break;
@@ -26282,7 +26283,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
return pet;
}
-void Player::SendSupercededSpell(uint32 oldSpell, uint32 newSpell)
+void Player::SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const
{
WorldPacket data(SMSG_SUPERCEDED_SPELL, 8);
data << uint32(oldSpell) << uint32(newSpell);
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 0d6d21c6b28..ab82d70d8bd 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -117,7 +117,7 @@ struct PlayerTalent
// Spell modifier (used for modify other spells)
struct SpellModifier
{
- SpellModifier(Aura* _ownerAura = NULL) : op(SPELLMOD_DAMAGE), type(SPELLMOD_FLAT), charges(0), value(0), mask(), spellId(0), ownerAura(_ownerAura) { }
+ SpellModifier(Aura* _ownerAura = nullptr) : op(SPELLMOD_DAMAGE), type(SPELLMOD_FLAT), charges(0), value(0), mask(), spellId(0), ownerAura(_ownerAura) { }
SpellModOp op : 8;
SpellModType type : 8;
int16 charges : 16;
@@ -256,7 +256,7 @@ typedef std::list<PlayerCreateInfoSkill> PlayerCreateInfoSkills;
struct PlayerInfo
{
// existence checked by displayId != 0
- PlayerInfo() : mapId(0), areaId(0), positionX(0.0f), positionY(0.0f), positionZ(0.0f), orientation(0.0f), displayId_m(0), displayId_f(0), levelInfo(NULL) { }
+ PlayerInfo() : mapId(0), areaId(0), positionX(0.0f), positionY(0.0f), positionZ(0.0f), orientation(0.0f), displayId_m(0), displayId_f(0), levelInfo(nullptr) { }
uint32 mapId;
uint32 areaId;
@@ -287,7 +287,7 @@ struct PvPInfo
struct DuelInfo
{
- DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0), isMounted(false) { }
+ DuelInfo() : initiator(nullptr), opponent(nullptr), startTimer(0), startTime(0), outOfBound(0), isMounted(false) { }
Player* initiator;
Player* opponent;
@@ -349,7 +349,7 @@ struct Runes
struct EnchantDuration
{
- EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) { }
+ EnchantDuration() : item(nullptr), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) { }
EnchantDuration(Item* _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot),
leftduration(_leftduration){ ASSERT(item); }
@@ -855,7 +855,7 @@ struct InstancePlayerBind
EXTENDED - won't be promoted to EXPIRED at next reset period, will instead be promoted to NORMAL */
BindExtensionState extendState;
- InstancePlayerBind() : save(NULL), perm(false), extendState(EXTEND_STATE_NORMAL) { }
+ InstancePlayerBind() : save(nullptr), perm(false), extendState(EXTEND_STATE_NORMAL) { }
};
struct AccessRequirement
@@ -1061,12 +1061,12 @@ class Player : public Unit, public GridObject<Player>
void SendInitialPacketsBeforeAddToMap();
void SendInitialPacketsAfterAddToMap();
- void SendSupercededSpell(uint32 oldSpell, uint32 newSpell);
- void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg = 0);
- void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome);
+ void SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const;
+ void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg = 0) const;
+ void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome) const;
- bool CanInteractWithQuestGiver(Object* questGiver);
- Creature* GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask);
+ bool CanInteractWithQuestGiver(Object* questGiver) const;
+ Creature* GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask) const;
GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid) const;
GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid, GameobjectTypes type) const;
@@ -1077,16 +1077,16 @@ class Player : public Unit, public GridObject<Player>
uint8 GetChatTag() const;
std::string autoReplyMsg;
- uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin=NULL);
+ uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin = nullptr) const;
- PlayerSocial *GetSocial() { return m_social; }
+ PlayerSocial *GetSocial() const { return m_social; }
PlayerTaxi m_taxi;
void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(), getClass(), getLevel()); }
- bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = NULL, uint32 spellid = 0);
+ bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = nullptr, uint32 spellid = 0);
bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0);
void CleanupAfterTaxiFlight();
- void ContinueTaxiFlight();
+ void ContinueTaxiFlight() const;
// mount_id can be used in scripting calls
bool isAcceptWhispers() const { return (m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS) != 0; }
void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
@@ -1153,8 +1153,8 @@ class Player : public Unit, public GridObject<Player>
void SetVirtualItemSlot(uint8 i, Item* item);
void SetSheath(SheathState sheathed) override; // overwrite Unit version
uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const;
- uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = NULL) const;
- uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = NULL) const;
+ uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = nullptr) const;
+ uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const;
Item* GetItemByGuid(ObjectGuid guid) const;
Item* GetItemByEntry(uint32 entry) const;
Item* GetItemByPos(uint16 pos) const;
@@ -1172,18 +1172,18 @@ class Player : public Unit, public GridObject<Player>
static bool IsBagPos(uint16 pos);
static bool IsBankPos(uint16 pos) { return IsBankPos(pos >> 8, pos & 255); }
static bool IsBankPos(uint8 bag, uint8 slot);
- bool IsValidPos(uint16 pos, bool explicit_pos) { return IsValidPos(pos >> 8, pos & 255, explicit_pos); }
- bool IsValidPos(uint8 bag, uint8 slot, bool explicit_pos);
+ 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 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, 2); }
void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); }
bool HasItemCount(uint32 item, uint32 count = 1, bool inBankAlso = false) const;
- bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = NULL) const;
+ bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = nullptr) const;
bool CanNoReagentCast(SpellInfo const* spellInfo) const;
bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const;
bool HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
InventoryResult CanTakeMoreSimilarItems(Item* pItem, uint32* itemLimitCategory = NULL) const { return CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem, NULL, itemLimitCategory); }
InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, uint32* itemLimitCategory = NULL) const { return CanTakeMoreSimilarItems(entry, count, NULL, NULL, itemLimitCategory); }
- InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL) const;
+ InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = nullptr) const;
InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const;
InventoryResult CanStoreItems(Item** items, int count, uint32* itemLimitCategory) const;
InventoryResult CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const;
@@ -1210,7 +1210,7 @@ class Player : public Unit, public GridObject<Player>
void StoreLootItem(uint8 lootSlot, Loot* loot);
InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL, uint32* itemLimitCategory = NULL) const;
- InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = NULL, bool swap = false, uint32* no_space_count = NULL) const;
+ InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = nullptr, bool swap = false, uint32* no_space_count = nullptr) const;
void AddRefundReference(ObjectGuid it);
void DeleteRefundReference(ObjectGuid it);
@@ -1241,9 +1241,9 @@ class Player : public Unit, public GridObject<Player>
Item* GetItemFromBuyBackSlot(uint32 slot);
void RemoveItemFromBuyBackSlot(uint32 slot, bool del);
uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
- void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = NULL, uint32 itemid = 0);
- void SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param);
- void SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param);
+ void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = nullptr, uint32 itemid = 0) const;
+ void SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param) const;
+ void SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param) const;
void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
@@ -1305,10 +1305,10 @@ class Player : public Unit, public GridObject<Player>
void PrepareQuestMenu(ObjectGuid guid);
void SendPreparedQuest(ObjectGuid guid);
bool IsActiveQuest(uint32 quest_id) const;
- Quest const* GetNextQuest(ObjectGuid guid, Quest const* quest);
+ Quest const* GetNextQuest(ObjectGuid guid, Quest const* quest) const;
bool CanSeeStartQuest(Quest const* quest);
bool CanTakeQuest(Quest const* quest, bool msg);
- bool CanAddQuest(Quest const* quest, bool msg);
+ bool CanAddQuest(Quest const* quest, bool msg) const;
bool CanCompleteQuest(uint32 quest_id);
bool CanCompleteRepeatableQuest(Quest const* quest);
bool CanRewardQuest(Quest const* quest, bool msg);
@@ -1320,19 +1320,19 @@ class Player : public Unit, public GridObject<Player>
void RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, bool announce = true);
void FailQuest(uint32 quest_id);
bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const;
- bool SatisfyQuestLevel(Quest const* qInfo, bool msg);
- bool SatisfyQuestLog(bool msg);
+ bool SatisfyQuestLevel(Quest const* qInfo, bool msg) const;
+ bool SatisfyQuestLog(bool msg) const;
bool SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg);
bool SatisfyQuestClass(Quest const* qInfo, bool msg) const;
- bool SatisfyQuestRace(Quest const* qInfo, bool msg);
+ bool SatisfyQuestRace(Quest const* qInfo, bool msg) const;
bool SatisfyQuestReputation(Quest const* qInfo, bool msg);
- bool SatisfyQuestStatus(Quest const* qInfo, bool msg);
+ bool SatisfyQuestStatus(Quest const* qInfo, bool msg) const;
bool SatisfyQuestConditions(Quest const* qInfo, bool msg);
- bool SatisfyQuestTimed(Quest const* qInfo, bool msg);
+ bool SatisfyQuestTimed(Quest const* qInfo, bool msg) const;
bool SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg);
- bool SatisfyQuestNextChain(Quest const* qInfo, bool msg);
+ bool SatisfyQuestNextChain(Quest const* qInfo, bool msg) const;
bool SatisfyQuestPrevChain(Quest const* qInfo, bool msg);
- bool SatisfyQuestDay(Quest const* qInfo, bool msg);
+ bool SatisfyQuestDay(Quest const* qInfo, bool msg) const;
bool SatisfyQuestWeek(Quest const* qInfo, bool msg);
bool SatisfyQuestMonth(Quest const* qInfo, bool msg);
bool SatisfyQuestSeasonal(Quest const* qInfo, bool msg);
@@ -1367,7 +1367,7 @@ class Player : public Unit, public GridObject<Player>
void SetQuestSlotTimer(uint16 slot, uint32 timer);
void SwapQuestSlot(uint16 slot1, uint16 slot2);
- uint16 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry);
+ uint16 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) const;
void AreaExploredOrEventHappens(uint32 questId);
void GroupEventHappens(uint32 questId, WorldObject const* pEventObject);
void ItemAddedQuestCheck(uint32 entry, uint32 count);
@@ -1385,14 +1385,14 @@ class Player : public Unit, public GridObject<Player>
void UpdateForQuestWorldObjects();
bool CanShareQuest(uint32 questId) const;
- void SendQuestComplete(uint32 questId);
- void SendQuestReward(Quest const* quest, uint32 XP);
- void SendQuestFailed(uint32 questId, InventoryResult reason = EQUIP_ERR_OK);
- void SendQuestTimerFailed(uint32 questId);
+ void SendQuestComplete(uint32 questId) const;
+ void SendQuestReward(Quest const* quest, uint32 XP) const;
+ void SendQuestFailed(uint32 questId, InventoryResult reason = EQUIP_ERR_OK) const;
+ void SendQuestTimerFailed(uint32 questId) const;
void SendCanTakeQuestResponse(QuestFailedReason msg) const;
- void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver);
- void SendPushToPartyResponse(Player* player, uint8 msg);
- void SendQuestUpdateAddItem(Quest const* quest, uint32 itemIdx, uint16 count);
+ void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver) const;
+ void SendPushToPartyResponse(Player* player, uint8 msg) const;
+ void SendQuestUpdateAddItem(Quest const* quest, uint32 itemIdx, uint16 count) const;
void SendQuestUpdateAddCreatureOrGo(Quest const* quest, ObjectGuid guid, uint32 creatureOrGOIdx, uint16 oldCount, uint16 addCount);
void SendQuestUpdateAddPlayer(Quest const* quest, uint16 oldCount, uint16 addCount);
@@ -1430,7 +1430,7 @@ class Player : public Unit, public GridObject<Player>
void SaveToDB(bool create = false);
void SaveInventoryAndGoldToDB(SQLTransaction& trans); // fast save function for item/money cheating preventing
- void SaveGoldToDB(SQLTransaction& trans);
+ void SaveGoldToDB(SQLTransaction& trans) const;
static void SetUInt32ValueInArray(Tokenizer& data, uint16 index, uint32 value);
static void SetFloatValueInArray(Tokenizer& data, uint16 index, float value);
@@ -1444,8 +1444,8 @@ class Player : public Unit, public GridObject<Player>
bool m_mailsLoaded;
bool m_mailsUpdated;
- void SetBindPoint(ObjectGuid guid);
- void SendTalentWipeConfirm(ObjectGuid guid);
+ void SetBindPoint(ObjectGuid guid) const;
+ void SendTalentWipeConfirm(ObjectGuid guid) const;
void ResetPetTalents();
void CalcRage(uint32 damage, bool attacker);
void RegenerateAll();
@@ -1475,13 +1475,13 @@ class Player : public Unit, public GridObject<Player>
uint8 GetComboPoints() const { return m_comboPoints; }
ObjectGuid GetComboTarget() const { return m_comboTarget; }
- void AddComboPoints(Unit* target, int8 count, Spell* spell = NULL);
+ void AddComboPoints(Unit* target, int8 count, Spell* spell = nullptr);
void GainSpellComboPoints(int8 count);
void ClearComboPoints();
void SendComboPoints();
- void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType item_guid = 0, uint32 item_count = 0);
- void SendNewMail();
+ void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType item_guid = 0, uint32 item_count = 0) const;
+ void SendNewMail() const;
void UpdateNextMailTimeAndUnreads();
void AddNewMailDeliverTime(time_t deliver_time);
bool IsMailsLoaded() const { return m_mailsLoaded; }
@@ -1512,19 +1512,19 @@ class Player : public Unit, public GridObject<Player>
void AddMItem(Item* it);
bool RemoveMItem(uint32 id);
- void SendOnCancelExpectedVehicleRideAura();
+ void SendOnCancelExpectedVehicleRideAura() const;
void PetSpellInitialize();
void CharmSpellInitialize();
void PossessSpellInitialize();
void VehicleSpellInitialize();
- void SendRemoveControlBar();
+ void SendRemoveControlBar() const;
bool HasSpell(uint32 spell) const override;
bool HasActiveSpell(uint32 spell) const; // show in spellbook
TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
bool IsSpellFitByClassAndRace(uint32 spell_id) const;
bool IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const;
- void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask);
+ void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const;
void SendInitialSpells();
bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, uint32 fromSkill = 0);
void LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill = 0);
@@ -1540,7 +1540,7 @@ class Player : public Unit, public GridObject<Player>
void RemoveTemporarySpell(uint32 spellId);
void SetReputation(uint32 factionentry, uint32 value);
uint32 GetReputation(uint32 factionentry) const;
- std::string const& GetGuildName();
+ std::string const& GetGuildName() const;
uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
void SetFreeTalentPoints(uint32 points);
bool ResetTalents(bool no_cost = false);
@@ -1579,18 +1579,18 @@ class Player : public Unit, public GridObject<Player>
PlayerSpellMap & GetSpellMap() { return m_spells; }
void AddSpellMod(SpellModifier* mod, bool apply);
- bool IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell = NULL);
- template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell* spell = NULL);
+ bool IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell = nullptr) const;
+ template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell* spell = nullptr);
void RemoveSpellMods(Spell* spell);
- void RestoreSpellMods(Spell* spell, uint32 ownerAuraId = 0, Aura* aura = NULL);
- void RestoreAllSpellMods(uint32 ownerAuraId = 0, Aura* aura = NULL);
+ void RestoreSpellMods(Spell* spell, uint32 ownerAuraId = 0, Aura* aura = nullptr);
+ void RestoreAllSpellMods(uint32 ownerAuraId = 0, Aura* aura = nullptr);
void DropModCharge(SpellModifier* mod, Spell* spell);
void SetSpellModTakingSpell(Spell* spell, bool apply);
void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false);
uint32 GetLastPotionId() const { return m_lastPotionId; }
void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
- void UpdatePotionCooldown(Spell* spell = NULL);
+ void UpdatePotionCooldown(Spell* spell = nullptr);
void setResurrectRequestData(ObjectGuid guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana);
void clearResurrectRequestData();
@@ -1598,7 +1598,7 @@ class Player : public Unit, public GridObject<Player>
bool isResurrectRequested() const { return !m_resurrectGUID.IsEmpty(); }
void ResurrectUsingRequestData();
- uint8 getCinematic() { return m_cinematic; }
+ uint8 getCinematic() const { return m_cinematic; }
void setCinematic(uint8 cine) { m_cinematic = cine; }
ActionButton* addActionButton(uint8 button, uint32 action, uint8 type);
@@ -1606,7 +1606,7 @@ class Player : public Unit, public GridObject<Player>
ActionButton const* GetActionButton(uint8 button);
void SendInitialActionButtons() const { SendActionButtons(1); }
void SendActionButtons(uint32 state) const;
- bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type);
+ bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) const;
PvPInfo pvpInfo;
void UpdatePvPState(bool onlyFFA = false);
@@ -1636,7 +1636,7 @@ class Player : public Unit, public GridObject<Player>
bool IsInSameGroupWith(Player const* p) const;
bool IsInSameRaidWith(Player const* p) const;
void UninviteFromGroup();
- static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, const char* reason = NULL);
+ static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, const char* reason = nullptr);
void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); }
void SendUpdateToOutOfRangeGroupMembers();
@@ -1704,12 +1704,12 @@ class Player : public Unit, public GridObject<Player>
void UpdateDefenseBonusesMod();
inline void RecalculateRating(CombatRating cr) { ApplyRatingMod(cr, 0, true);}
- float GetMeleeCritFromAgility();
- void GetDodgeFromAgility(float &diminishing, float &nondiminishing);
+ float GetMeleeCritFromAgility() const;
+ void GetDodgeFromAgility(float &diminishing, float &nondiminishing) const;
float GetMissPercentageFromDefence() const;
- float GetSpellCritFromIntellect();
- float OCTRegenHPPerSpirit();
- float OCTRegenMPPerSpirit();
+ float GetSpellCritFromIntellect() const;
+ float OCTRegenHPPerSpirit() const;
+ float OCTRegenMPPerSpirit() const;
float GetRatingMultiplier(CombatRating cr) const;
float GetRatingBonusValue(CombatRating cr) const;
uint32 GetBaseSpellPowerBonus() const { return m_baseSpellPower; }
@@ -1747,23 +1747,23 @@ class Player : public Unit, public GridObject<Player>
void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override;
void DestroyForPlayer(Player* target, bool onDeath = false) const override;
- void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend = false, float group_rate=1.0f);
+ void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend = false, float group_rate=1.0f) const;
// notifiers
- void SendAttackSwingCantAttack();
- void SendAttackSwingCancelAttack();
- void SendAttackSwingDeadTarget();
- void SendAttackSwingNotInRange();
- void SendAttackSwingBadFacingAttack();
+ void SendAttackSwingCantAttack() const;
+ void SendAttackSwingCancelAttack() const;
+ void SendAttackSwingDeadTarget() const;
+ void SendAttackSwingNotInRange() const;
+ void SendAttackSwingBadFacingAttack() const;
void SendAutoRepeatCancel(Unit* target);
- void SendExplorationExperience(uint32 Area, uint32 Experience);
+ void SendExplorationExperience(uint32 Area, uint32 Experience) const;
- void SendDungeonDifficulty(bool IsInGroup);
- void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty = -1);
+ void SendDungeonDifficulty(bool IsInGroup) const;
+ void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty = -1) const;
void ResetInstances(uint8 method, bool isRaid);
- void SendResetInstanceSuccess(uint32 MapId);
- void SendResetInstanceFailed(uint32 reason, uint32 MapId);
- void SendResetFailedNotify(uint32 mapid);
+ void SendResetInstanceSuccess(uint32 MapId) const;
+ void SendResetInstanceFailed(uint32 reason, uint32 MapId) const;
+ void SendResetFailedNotify(uint32 mapid) const;
virtual bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false) override;
bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }
@@ -1807,11 +1807,11 @@ class Player : public Unit, public GridObject<Player>
void UpdateMirrorTimers();
void StopMirrorTimers();
- bool IsMirrorTimerActive(MirrorTimerType type);
+ bool IsMirrorTimerActive(MirrorTimerType type) const;
void SetMovement(PlayerMovementType pType);
- bool CanJoinConstantChannelInZone(ChatChannelsEntry const* channel, AreaTableEntry const* zone);
+ bool CanJoinConstantChannelInZone(ChatChannelsEntry const* channel, AreaTableEntry const* zone) const;
void JoinedChannel(Channel* c);
void LeftChannel(Channel* c);
@@ -1902,8 +1902,8 @@ class Player : public Unit, public GridObject<Player>
uint32 GetDeathTimer() const { return m_deathTimer; }
uint32 GetCorpseReclaimDelay(bool pvp) const;
void UpdateCorpseReclaimDelay();
- int32 CalculateCorpseReclaimDelay(bool load = false);
- void SendCorpseReclaimDelay(uint32 delay);
+ int32 CalculateCorpseReclaimDelay(bool load = false) const;
+ void SendCorpseReclaimDelay(uint32 delay) const;
uint32 GetShieldBlockValue() const override; // overwrite Unit version (virtual)
bool CanParry() const { return m_canParry; }
@@ -1936,7 +1936,7 @@ class Player : public Unit, public GridObject<Player>
void _ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply, bool only_level_scale = false);
void _ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingStatValuesEntry const* ssv, bool apply);
void _ApplyAmmoBonuses();
- bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot);
+ bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) const;
void ToggleMetaGemsActive(uint8 exceptslot, bool apply);
void CorrectMetaGemEnchants(uint8 slot, bool apply);
void InitDataForForm(bool reapplyMods = false);
@@ -1953,21 +1953,21 @@ class Player : public Unit, public GridObject<Player>
void DeleteEquipmentSet(uint64 setGuid);
void SendInitWorldStates(uint32 zone, uint32 area);
- void SendUpdateWorldState(uint32 Field, uint32 Value);
- void SendDirectMessage(WorldPacket* data);
- void SendBGWeekendWorldStates();
- void SendBattlefieldWorldStates();
+ void SendUpdateWorldState(uint32 Field, uint32 Value) const;
+ void SendDirectMessage(WorldPacket const* data) const;
+ void SendBGWeekendWorldStates() const;
+ void SendBattlefieldWorldStates() const;
- void SendAurasForTarget(Unit* target);
+ void SendAurasForTarget(Unit* target) const;
PlayerMenu* PlayerTalkClass;
std::vector<ItemSetEffect*> ItemSetEff;
void SendLoot(ObjectGuid guid, LootType loot_type);
- void SendLootError(ObjectGuid guid, LootError error);
- void SendLootRelease(ObjectGuid guid);
- void SendNotifyLootItemRemoved(uint8 lootSlot);
- void SendNotifyLootMoneyRemoved();
+ void SendLootError(ObjectGuid guid, LootError error) const;
+ void SendLootRelease(ObjectGuid guid) const;
+ void SendNotifyLootItemRemoved(uint8 lootSlot) const;
+ void SendNotifyLootMoneyRemoved() const;
/*********************************************************/
/*** BATTLEGROUND SYSTEM ***/
@@ -1988,7 +1988,7 @@ class Player : public Unit, public GridObject<Player>
void SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId);
uint32 AddBattlegroundQueueId(BattlegroundQueueTypeId val);
- bool HasFreeBattlegroundQueueId();
+ bool HasFreeBattlegroundQueueId() const;
void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val);
void SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId);
bool IsInvitedForBattlegroundInstance(uint32 instanceId) const;
@@ -2005,10 +2005,10 @@ class Player : public Unit, public GridObject<Player>
void ClearAfkReports() { m_bgData.bgAfkReporter.clear(); }
bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const;
- bool isTotalImmunity();
- bool CanUseBattlegroundObject(GameObject* gameobject);
- bool isTotalImmune();
- bool CanCaptureTowerPoint();
+ bool isTotalImmunity() const;
+ bool CanUseBattlegroundObject(GameObject* gameobject) const;
+ bool isTotalImmune() const;
+ bool CanCaptureTowerPoint() const;
bool GetRandomWinner() const { return m_IsBGRandomWinner; }
void SetRandomWinner(bool isWinner);
@@ -2019,13 +2019,13 @@ class Player : public Unit, public GridObject<Player>
OutdoorPvP* GetOutdoorPvP() const;
// returns true if the player is in active state for outdoor pvp objective capturing, false otherwise
- bool IsOutdoorPvPActive();
+ bool IsOutdoorPvPActive() const;
/*********************************************************/
/*** ENVIROMENTAL SYSTEM ***/
/*********************************************************/
- bool IsImmuneToEnvironmentalDamage();
+ bool IsImmuneToEnvironmentalDamage() const;
uint32 EnvironmentalDamage(EnviromentalDamage type, uint32 damage);
/*********************************************************/
@@ -2055,7 +2055,7 @@ class Player : public Unit, public GridObject<Player>
void SetViewpoint(WorldObject* target, bool apply);
WorldObject* GetViewpoint() const;
void StopCastingCharm();
- void StopCastingBindSight();
+ void StopCastingBindSight() const;
uint32 GetSaveTimer() const { return m_nextSave; }
void SetSaveTimer(uint32 timer) { m_nextSave = timer; }
@@ -2088,7 +2088,7 @@ class Player : public Unit, public GridObject<Player>
bool IsVisibleGloballyFor(Player const* player) const;
- void SendInitialVisiblePackets(Unit* target);
+ void SendInitialVisiblePackets(Unit* target) const;
void UpdateObjectVisibility(bool forced = true) override;
void UpdateVisibilityForPlayer();
void UpdateVisibilityOf(WorldObject* target);
@@ -2103,8 +2103,8 @@ class Player : public Unit, public GridObject<Player>
void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
void RemoveAtLoginFlag(AtLoginFlags flags, bool persist = false);
- bool isUsingLfg();
- bool inRandomLfgDungeon();
+ bool isUsingLfg() const;
+ bool inRandomLfgDungeon() const;
typedef std::set<uint32> DFQuestsDoneList;
DFQuestsDoneList m_DFQuests;
@@ -2116,8 +2116,8 @@ class Player : public Unit, public GridObject<Player>
void ResummonPetTemporaryUnSummonedIfAny();
bool IsPetNeedBeTemporaryUnsummoned() const;
- void SendCinematicStart(uint32 CinematicSequenceId);
- void SendMovieStart(uint32 MovieId);
+ void SendCinematicStart(uint32 CinematicSequenceId) const;
+ void SendMovieStart(uint32 MovieId) const;
/*********************************************************/
/*** INSTANCE SYSTEM ***/
@@ -2155,10 +2155,10 @@ class Player : public Unit, public GridObject<Player>
/*** GROUP SYSTEM ***/
/*********************************************************/
- Group* GetGroupInvite() { return m_groupInvite; }
+ Group* GetGroupInvite() const { return m_groupInvite; }
void SetGroupInvite(Group* group) { m_groupInvite = group; }
Group* GetGroup() { return m_group.getTarget(); }
- const Group* GetGroup() const { return (const Group*)m_group.getTarget(); }
+ Group const* GetGroup() const { return const_cast<Group const*>(m_group.getTarget()); }
GroupReference& GetGroupRef() { return m_group; }
void SetGroup(Group* group, int8 subgroup = -1);
uint8 GetSubGroup() const { return m_group.getSubGroup(); }
@@ -2172,7 +2172,7 @@ class Player : public Unit, public GridObject<Player>
// Battleground / Battlefield Group System
void SetBattlegroundOrBattlefieldRaid(Group* group, int8 subgroup = -1);
void RemoveFromBattlegroundOrBattlefieldRaid();
- Group* GetOriginalGroup() { return m_originalGroup.getTarget(); }
+ Group* GetOriginalGroup() const { return m_originalGroup.getTarget(); }
GroupReference& GetOriginalGroupRef() { return m_originalGroup; }
uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); }
void SetOriginalGroup(Group* group, int8 subgroup = -1);
@@ -2205,8 +2205,8 @@ class Player : public Unit, public GridObject<Player>
void RemoveRunesByAuraEffect(AuraEffect const* aura);
void RestoreBaseRune(uint8 index);
void ConvertRune(uint8 index, RuneType newType);
- void ResyncRunes(uint8 count);
- void AddRunePower(uint8 index);
+ void ResyncRunes(uint8 count) const;
+ void AddRunePower(uint8 index) const;
void InitRunes();
void SendRespondInspectAchievements(Player* player) const;
@@ -2230,7 +2230,7 @@ class Player : public Unit, public GridObject<Player>
void SetChampioningFaction(uint32 faction) { m_ChampioningFaction = faction; }
Spell* m_spellModTakingSpell;
- float GetAverageItemLevel();
+ float GetAverageItemLevel() const;
bool isDebugAreaTriggers;
void ClearWhisperWhiteList() { WhisperList.clear(); }
@@ -2249,8 +2249,8 @@ class Player : public Unit, public GridObject<Player>
//! Return collision height sent to client
float GetCollisionHeight(bool mounted) const;
- std::string GetMapAreaAndZoneString();
- std::string GetCoordsMapAreaAndZoneString();
+ std::string GetMapAreaAndZoneString() const;
+ std::string GetCoordsMapAreaAndZoneString() const;
protected:
// Gamemaster whisper whitelist
@@ -2341,9 +2341,9 @@ class Player : public Unit, public GridObject<Player>
void _SaveSpells(SQLTransaction& trans);
void _SaveEquipmentSets(SQLTransaction& trans);
void _SaveBGData(SQLTransaction& trans);
- void _SaveGlyphs(SQLTransaction& trans);
+ void _SaveGlyphs(SQLTransaction& trans) const;
void _SaveTalents(SQLTransaction& trans);
- void _SaveStats(SQLTransaction& trans);
+ void _SaveStats(SQLTransaction& trans) const;
void _SaveInstanceTimeRestrictions(SQLTransaction& trans);
/*********************************************************/
@@ -2353,7 +2353,7 @@ class Player : public Unit, public GridObject<Player>
void SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen);
void StopMirrorTimer(MirrorTimerType Type);
void HandleDrowning(uint32 time_diff);
- int32 getMaxTimer(MirrorTimerType timer);
+ int32 getMaxTimer(MirrorTimerType timer) const;
/*********************************************************/
/*** HONOR SYSTEM ***/
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index 34ed31a7813..de68bf53cc7 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -187,7 +187,7 @@ ObjectGuid::LowType WorldSession::GetGUIDLow() const
}
/// Send a packet to the client
-void WorldSession::SendPacket(WorldPacket* packet)
+void WorldSession::SendPacket(WorldPacket const* packet)
{
if (!m_Socket)
return;
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 2253b6bc684..d98143fcec0 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -264,7 +264,7 @@ class WorldSession
void ReadMovementInfo(WorldPacket& data, MovementInfo* mi);
void WriteMovementInfo(WorldPacket* data, MovementInfo* mi);
- void SendPacket(WorldPacket* packet);
+ void SendPacket(WorldPacket const* packet);
void SendNotification(const char *format, ...) ATTR_PRINTF(2, 3);
void SendNotification(uint32 string_id, ...);
void SendPetNameInvalid(uint32 error, std::string const& name, DeclinedName *declinedName);