Merge branch 'azerothcore:master' into Playerbot

This commit is contained in:
ZhengPeiRu21
2022-04-07 08:55:50 -06:00
committed by GitHub
143 changed files with 665 additions and 546 deletions

View File

@@ -894,7 +894,7 @@ void Player::HandleDrowning(uint32 time_diff)
uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel() - 1);
EnvironmentalDamage(DAMAGE_EXHAUSTED, damage);
}
else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard
else if (HasPlayerFlag(PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard
RepopAtGraveyard();
}
else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER))
@@ -1066,14 +1066,14 @@ void Player::SetRestState(uint32 triggerId)
{
_innTriggerId = triggerId;
_restTime = GameTime::GetGameTime().count();
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
SetPlayerFlag(PLAYER_FLAGS_RESTING);
}
void Player::RemoveRestState()
{
_innTriggerId = 0;
_restTime = 0;
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
RemovePlayerFlag(PLAYER_FLAGS_RESTING);
}
bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data)
@@ -2062,7 +2062,7 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask)
return nullptr;
// appropriate npc type
if (npcflagmask && !creature->HasFlag(UNIT_NPC_FLAGS, npcflagmask))
if (npcflagmask && !creature->HasNpcFlag(NPCFlags(npcflagmask)))
return nullptr;
// not allow interaction under control, but allow with own pets
@@ -2172,7 +2172,7 @@ void Player::SetGameMaster(bool on)
m_ExtraFlags |= PLAYER_EXTRA_GM_ON;
if (AccountMgr::IsGMAccount(GetSession()->GetSecurity()))
SetFaction(FACTION_FRIENDLY);
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
SetPlayerFlag(PLAYER_FLAGS_GM);
SetUnitFlag2(UNIT_FLAG2_ALLOW_CHEAT_SPELLS);
if (Pet* pet = GetPet())
@@ -2203,7 +2203,7 @@ void Player::SetGameMaster(bool on)
m_ExtraFlags &= ~ PLAYER_EXTRA_GM_ON;
SetFactionForRace(getRace(true));
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
RemovePlayerFlag(PLAYER_FLAGS_GM);
RemoveUnitFlag2(UNIT_FLAG2_ALLOW_CHEAT_SPELLS);
if (Pet* pet = GetPet())
@@ -2337,7 +2337,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate, bool isLFGReward)
return;
}
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN))
if (HasPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN))
{
return;
}
@@ -2654,7 +2654,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
SetUnitFlag2(UNIT_FLAG2_REGENERATE_POWER);// must be set
// cleanup player flags (will be re-applied if need at aura load), to avoid have ghost flag without ghost aura, for example.
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_ALLOW_ONLY_ABILITY);
RemovePlayerFlag(PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_ALLOW_ONLY_ABILITY);
RemoveStandFlags(UNIT_STAND_FLAGS_ALL); // one form stealth modified bytes
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY);
@@ -4499,9 +4499,9 @@ Corpse* Player::CreateCorpse()
corpse->SetUInt32Value(CORPSE_FIELD_BYTES_2, _cfb2);
uint32 flags = CORPSE_FLAG_UNK2;
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM))
if (HasPlayerFlag(PLAYER_FLAGS_HIDE_HELM))
flags |= CORPSE_FLAG_HIDE_HELM;
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK))
if (HasPlayerFlag(PLAYER_FLAGS_HIDE_CLOAK))
flags |= CORPSE_FLAG_HIDE_CLOAK;
// Xinef: Player can loop corpses while in BG or in WG
@@ -4844,7 +4844,7 @@ void Player::RepopAtGraveyard()
else if (GetPositionZ() < GetMap()->GetMinHeight(GetPositionX(), GetPositionY()))
TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation());
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_IS_OUT_OF_BOUNDS);
RemovePlayerFlag(PLAYER_FLAGS_IS_OUT_OF_BOUNDS);
}
bool Player::CanJoinConstantChannelInZone(ChatChannelsEntry const* channel, AreaTableEntry const* zone)
@@ -7545,7 +7545,7 @@ void Player::SendQuestGiverStatusMultiple()
Creature* questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr);
if (!questgiver || questgiver->IsHostileTo(this))
continue;
if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
if (!questgiver->HasNpcFlag(UNIT_NPC_FLAG_QUESTGIVER))
continue;
questStatus = GetQuestDialogStatus(questgiver);
@@ -8828,7 +8828,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
pet->SetCreatorGUID(GetGUID());
pet->SetFaction(GetFaction());
pet->setPowerType(POWER_MANA);
pet->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
pet->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
pet->InitStatsForLevel(getLevel());
@@ -13878,7 +13878,7 @@ bool Player::CanResummonPet(uint32 spellid)
bool Player::CanSeeSpellClickOn(Creature const* c) const
{
if (!c->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
if (!c->HasNpcFlag(UNIT_NPC_FLAG_SPELLCLICK))
return false;
SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(c->GetEntry());
@@ -13901,7 +13901,7 @@ bool Player::CanSeeSpellClickOn(Creature const* c) const
bool Player::CanSeeVendor(Creature const* creature) const
{
if (!creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR))
if (!creature->HasNpcFlag(UNIT_NPC_FLAG_VENDOR))
return true;
ConditionList conditions = sConditionMgr->GetConditionsForNpcVendorEvent(creature->GetEntry(), 0);
@@ -14313,7 +14313,7 @@ void Player::_SaveCharacter(bool create, CharacterDatabaseTransaction trans)
stmt->SetData(index++, GetByteValue(PLAYER_BYTES_2, 0));
stmt->SetData(index++, GetByteValue(PLAYER_BYTES_2, 2));
stmt->SetData(index++, GetByteValue(PLAYER_BYTES_2, 3));
stmt->SetData(index++, GetUInt32Value(PLAYER_FLAGS));
stmt->SetData(index++, (uint32)GetPlayerFlags());
stmt->SetData(index++, (uint16)GetMapId());
stmt->SetData(index++, (uint32)GetInstanceId());
stmt->SetData(index++, (uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4));
@@ -14344,7 +14344,7 @@ void Player::_SaveCharacter(bool create, CharacterDatabaseTransaction trans)
stmt->SetData(index++, m_Played_time[PLAYED_TIME_LEVEL]);
stmt->SetData(index++, finiteAlways(_restBonus));
stmt->SetData(index++, uint32(GameTime::GetGameTime().count()));
stmt->SetData(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
stmt->SetData(index++, (HasPlayerFlag(PLAYER_FLAGS_RESTING) ? 1 : 0));
//save, far from tavern/city
//save, but in tavern/city
stmt->SetData(index++, m_resetTalentsCost);
@@ -14430,7 +14430,7 @@ void Player::_SaveCharacter(bool create, CharacterDatabaseTransaction trans)
stmt->SetData(index++, GetByteValue(PLAYER_BYTES_2, 0));
stmt->SetData(index++, GetByteValue(PLAYER_BYTES_2, 2));
stmt->SetData(index++, GetByteValue(PLAYER_BYTES_2, 3));
stmt->SetData(index++, GetUInt32Value(PLAYER_FLAGS));
stmt->SetData(index++, GetPlayerFlags());
if (!IsBeingTeleported())
{
@@ -14483,7 +14483,7 @@ void Player::_SaveCharacter(bool create, CharacterDatabaseTransaction trans)
stmt->SetData(index++, m_Played_time[PLAYED_TIME_LEVEL]);
stmt->SetData(index++, finiteAlways(_restBonus));
stmt->SetData(index++, uint32(GameTime::GetGameTime().count()));
stmt->SetData(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
stmt->SetData(index++, (HasPlayerFlag(PLAYER_FLAGS_RESTING) ? 1 : 0));
//save, far from tavern/city
//save, but in tavern/city
stmt->SetData(index++, m_resetTalentsCost);
@@ -15745,7 +15745,7 @@ void Player::SetRestFlag(RestFlag restFlag, uint32 triggerId /*= 0*/)
if (!oldRestMask && _restFlagMask) // only set flag/time on the first rest state
{
_restTime = GameTime::GetGameTime().count();
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
SetPlayerFlag(PLAYER_FLAGS_RESTING);
}
if (triggerId)
@@ -15760,7 +15760,7 @@ void Player::RemoveRestFlag(RestFlag restFlag)
if (oldRestMask && !_restFlagMask) // only remove flag/time on the last rest state remove
{
_restTime = 0;
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
RemovePlayerFlag(PLAYER_FLAGS_RESTING);
}
}

View File

@@ -24,6 +24,7 @@
#include "CinematicMgr.h"
#include "DBCStores.h"
#include "DatabaseEnvFwd.h"
#include "EnumFlag.h"
#include "GroupReference.h"
#include "InstanceSaveMgr.h"
#include "Item.h"
@@ -464,7 +465,7 @@ enum DrunkenState
#define MAX_DRUNKEN 4
enum PlayerFlags
enum PlayerFlags : uint32
{
PLAYER_FLAGS_GROUP_LEADER = 0x00000001,
PLAYER_FLAGS_AFK = 0x00000002,
@@ -500,6 +501,8 @@ enum PlayerFlags
PLAYER_FLAGS_UNK31 = 0x80000000,
};
DEFINE_ENUM_FLAG(PlayerFlags);
enum PlayerBytesOffsets //@todo: Implement
{
PLAYER_BYTES_OFFSET_SKIN_ID = 0,
@@ -1078,6 +1081,12 @@ public:
void Update(uint32 time) override;
PlayerFlags GetPlayerFlags() const { return PlayerFlags(GetUInt32Value(PLAYER_FLAGS)); }
bool HasPlayerFlag(PlayerFlags flags) const { return HasFlag(PLAYER_FLAGS, flags) != 0; }
void SetPlayerFlag(PlayerFlags flags) { SetFlag(PLAYER_FLAGS, flags); }
void RemovePlayerFlag(PlayerFlags flags) { RemoveFlag(PLAYER_FLAGS, flags); }
void ReplaceAllPlayerFlags(PlayerFlags flags) { SetUInt32Value(PLAYER_FLAGS, flags); }
static bool BuildEnumData(PreparedQueryResult result, WorldPacket* data);
void SetInWater(bool apply);
@@ -1097,8 +1106,8 @@ public:
void ToggleAFK();
void ToggleDND();
[[nodiscard]] bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); }
[[nodiscard]] bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); }
[[nodiscard]] bool isAFK() const { return HasPlayerFlag(PLAYER_FLAGS_AFK); }
[[nodiscard]] bool isDND() const { return HasPlayerFlag(PLAYER_FLAGS_DND); }
[[nodiscard]] uint8 GetChatTag() const;
std::string autoReplyMsg;
@@ -1114,7 +1123,7 @@ public:
void ContinueTaxiFlight();
// mount_id can be used in scripting calls
[[nodiscard]] bool IsDeveloper() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER); }
[[nodiscard]] bool IsDeveloper() const { return HasPlayerFlag(PLAYER_FLAGS_DEVELOPER); }
void SetDeveloper(bool on) { ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER, on); }
[[nodiscard]] bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
@@ -1803,7 +1812,7 @@ public:
void ResetContestedPvP()
{
ClearUnitState(UNIT_STATE_ATTACK_PLAYER);
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
RemovePlayerFlag(PLAYER_FLAGS_CONTESTED_PVP);
m_contestedPvPTimer = 0;
}

View File

@@ -45,7 +45,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
if (source->GetTypeId() == TYPEID_UNIT)
{
npcflags = source->GetUInt32Value(UNIT_NPC_FLAGS);
npcflags = source->ToUnit()->GetNpcFlags();
if (showQuests && npcflags & UNIT_NPC_FLAG_QUESTGIVER)
PrepareQuestMenu(source->GetGUID());
}
@@ -215,7 +215,7 @@ void Player::SendPreparedGossip(WorldObject* source)
if (source->GetTypeId() == TYPEID_UNIT)
{
// in case no gossip flag and quest menu not empty, open quest menu (client expect gossip menu with this flag)
if (!source->ToCreature()->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP) && !PlayerTalkClass->GetQuestMenu().Empty())
if (!source->ToCreature()->HasNpcFlag(UNIT_NPC_FLAG_GOSSIP) && !PlayerTalkClass->GetQuestMenu().Empty())
{
SendPreparedQuest(source->GetGUID());
return;
@@ -259,7 +259,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
if (sWorld->getIntConfig(CONFIG_INSTANT_TAXI) == 2 && source->GetTypeId() == TYPEID_UNIT)
{
if (gossipOptionId == GOSSIP_ACTION_TOGGLE_INSTANT_FLIGHT && source->GetUInt32Value(UNIT_NPC_FLAGS) & UNIT_NPC_FLAG_FLIGHTMASTER)
if (gossipOptionId == GOSSIP_ACTION_TOGGLE_INSTANT_FLIGHT && source->ToUnit()->GetNpcFlags() & UNIT_NPC_FLAG_FLIGHTMASTER)
{
ToggleInstantFlight();

View File

@@ -353,8 +353,8 @@ void Player::UpdatePvPFlag(time_t currTime)
if (currTime < (pvpInfo.EndTimer + 300 + 5))
{
if (currTime > (pvpInfo.EndTimer + 4) && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER))
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER);
if (currTime > (pvpInfo.EndTimer + 4) && !HasPlayerFlag(PLAYER_FLAGS_PVP_TIMER))
SetPlayerFlag(PLAYER_FLAGS_PVP_TIMER);
return;
}

View File

@@ -5053,7 +5053,7 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
SetByteValue(PLAYER_BYTES_2, 3, fields[15].Get<uint8>());
SetByteValue(PLAYER_BYTES_3, 0, fields[5].Get<uint8>());
SetByteValue(PLAYER_BYTES_3, 1, fields[54].Get<uint8>());
SetUInt32Value(PLAYER_FLAGS, fields[16].Get<uint32>());
ReplaceAllPlayerFlags((PlayerFlags)fields[16].Get<uint32>());
SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fields[53].Get<uint32>());
SetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES, fields[52].Get<uint64>());
@@ -5460,7 +5460,7 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
_LoadGlyphAuras();
_LoadAuras(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_AURAS), time_diff);
// add ghost flag (must be after aura load: PLAYER_FLAGS_GHOST set in aura)
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
if (HasPlayerFlag(PLAYER_FLAGS_GHOST))
{
m_deathState = DEAD;
AddUnitState(UNIT_STATE_ISOLATED);
@@ -6514,7 +6514,7 @@ void Player::_LoadGroup()
{
if (group->IsLeader(GetGUID()))
{
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GROUP_LEADER);
SetPlayerFlag(PLAYER_FLAGS_GROUP_LEADER);
}
uint8 subgroup = group->GetMemberGroup(GetGUID());
@@ -6528,7 +6528,7 @@ void Player::_LoadGroup()
}
if (!GetGroup() || !GetGroup()->IsLeader(GetGUID()))
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GROUP_LEADER);
RemovePlayerFlag(PLAYER_FLAGS_GROUP_LEADER);
}
void Player::BindToInstance()

View File

@@ -232,7 +232,7 @@ void Player::Update(uint32 p_time)
}
}
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING))
if (HasPlayerFlag(PLAYER_FLAGS_RESTING))
{
if (now > lastTick && _restTime > 0) // freeze update
{
@@ -1386,7 +1386,7 @@ void Player::UpdatePvPState()
}
else // in friendly area
{
if (IsPvP() && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) &&
if (IsPvP() && !HasPlayerFlag(PLAYER_FLAGS_IN_PVP) &&
pvpInfo.EndTimer == 0)
pvpInfo.EndTimer = GameTime::GetGameTime().count(); // start toggle-off
}
@@ -1474,7 +1474,7 @@ void Player::UpdatePvP(bool state, bool _override)
SetPvP(state);
}
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER);
RemovePlayerFlag(PLAYER_FLAGS_PVP_TIMER);
sScriptMgr->OnPlayerPVPFlagChange(this, state);
}
@@ -1741,7 +1741,7 @@ void Player::UpdateForQuestWorldObjects()
continue;
// check if this unit requires quest specific flags
if (!obj->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
if (!obj->HasNpcFlag(UNIT_NPC_FLAG_SPELLCLICK))
continue;
SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry());