mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Player: moved zone/area updating and tavern resting checks into Heartbeat and movement updates
This commit is contained in:
@@ -137,8 +137,6 @@
|
||||
#include <G3D/g3dmath.h>
|
||||
#include <sstream>
|
||||
|
||||
#define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS)
|
||||
|
||||
// corpse reclaim times
|
||||
#define DEATH_EXPIRE_STEP (5*MINUTE)
|
||||
#define MAX_DEATH_COUNT 3
|
||||
@@ -175,7 +173,6 @@ Player::Player(WorldSession* session) : Unit(true), m_sceneMgr(this)
|
||||
m_weaponChangeTimer = 0;
|
||||
|
||||
m_zoneUpdateId = uint32(-1);
|
||||
m_zoneUpdateTimer = 0;
|
||||
|
||||
m_areaUpdateId = 0;
|
||||
m_team = TEAM_OTHER;
|
||||
@@ -1008,37 +1005,6 @@ void Player::Update(uint32 p_time)
|
||||
m_weaponChangeTimer -= p_time;
|
||||
}
|
||||
|
||||
if (m_zoneUpdateTimer > 0)
|
||||
{
|
||||
if (p_time >= m_zoneUpdateTimer)
|
||||
{
|
||||
// On zone update tick check if we are still in an inn if we are supposed to be in one
|
||||
if (_restMgr->HasRestFlag(REST_FLAG_IN_TAVERN))
|
||||
{
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(_restMgr->GetInnTriggerID());
|
||||
if (!atEntry || !IsInAreaTrigger(atEntry))
|
||||
_restMgr->RemoveRestFlag(REST_FLAG_IN_TAVERN);
|
||||
}
|
||||
|
||||
uint32 newzone, newarea;
|
||||
GetZoneAndAreaId(newzone, newarea);
|
||||
|
||||
if (m_zoneUpdateId != newzone)
|
||||
UpdateZone(newzone, newarea); // also update area
|
||||
else
|
||||
{
|
||||
// use area updates as well
|
||||
// needed for free far all arenas for example
|
||||
if (m_areaUpdateId != newarea)
|
||||
UpdateArea(newarea);
|
||||
|
||||
m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
m_zoneUpdateTimer -= p_time;
|
||||
}
|
||||
|
||||
if (m_deathState == JUST_DIED)
|
||||
KillPlayer();
|
||||
|
||||
@@ -1143,8 +1109,14 @@ void Player::Heartbeat()
|
||||
// Group update
|
||||
SendUpdateToOutOfRangeGroupMembers();
|
||||
|
||||
// Indoor/Outdoor aura requirements
|
||||
CheckOutdoorsAuraRequirements();
|
||||
// Updating Zone and AreaId. This will also trigger spell_area and phasing related updates
|
||||
UpdateZoneAndAreaId();
|
||||
|
||||
// Updating auras which can only be used inside or outside (such as Mounts)
|
||||
UpdateIndoorsOutdoorsAuras();
|
||||
|
||||
// Updating the resting state when entering resting places
|
||||
UpdateTavernRestingState();
|
||||
}
|
||||
|
||||
void Player::setDeathState(DeathState s)
|
||||
@@ -5965,12 +5937,38 @@ bool Player::HasExploredZone(uint32 areaId) const
|
||||
return (m_activePlayerData->DataFlags[PLAYER_DATA_FLAG_EXPLORED_ZONES_INDEX][playerIndexOffset] & mask) != 0;
|
||||
}
|
||||
|
||||
void Player::CheckOutdoorsAuraRequirements()
|
||||
void Player::UpdateZoneAndAreaId()
|
||||
{
|
||||
uint32 newzone = 0, newarea = 0;
|
||||
GetZoneAndAreaId(newzone, newarea);
|
||||
|
||||
if (m_zoneUpdateId != newzone)
|
||||
UpdateZone(newzone, newarea); // also update area
|
||||
else
|
||||
{
|
||||
// use area updates as well
|
||||
// needed for free far all arenas for example
|
||||
if (m_areaUpdateId != newarea)
|
||||
UpdateArea(newarea);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::UpdateIndoorsOutdoorsAuras()
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK))
|
||||
RemoveAurasWithAttribute(IsOutdoors() ? SPELL_ATTR0_ONLY_INDOORS : SPELL_ATTR0_ONLY_OUTDOORS);
|
||||
}
|
||||
|
||||
void Player::UpdateTavernRestingState()
|
||||
{
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(_restMgr->GetInnTriggerID());
|
||||
|
||||
if (_restMgr->HasRestFlag(REST_FLAG_IN_TAVERN) && (!atEntry || !IsInAreaTrigger(atEntry)))
|
||||
_restMgr->RemoveRestFlag(REST_FLAG_IN_TAVERN);
|
||||
else if (!_restMgr->HasRestFlag(REST_FLAG_IN_TAVERN) && IsInAreaTrigger(atEntry))
|
||||
_restMgr->SetRestFlag(REST_FLAG_IN_TAVERN);
|
||||
}
|
||||
|
||||
Team Player::TeamForRace(uint8 race)
|
||||
{
|
||||
if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race))
|
||||
@@ -7055,7 +7053,6 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
|
||||
|
||||
uint32 const oldZone = m_zoneUpdateId;
|
||||
m_zoneUpdateId = newZone;
|
||||
m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL;
|
||||
|
||||
GetMap()->UpdatePlayerZoneStats(oldZone, newZone);
|
||||
|
||||
|
||||
@@ -2183,7 +2183,10 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
|
||||
void RemoveExploredZones(uint32 pos, uint64 mask);
|
||||
bool HasExploredZone(uint32 areaId) const;
|
||||
|
||||
void CheckOutdoorsAuraRequirements();
|
||||
// These methods are used to periodically update certain area and aura based mechanics used in Heartbeat and Movement
|
||||
void UpdateZoneAndAreaId();
|
||||
void UpdateIndoorsOutdoorsAuras();
|
||||
void UpdateTavernRestingState();
|
||||
|
||||
static Team TeamForRace(uint8 race);
|
||||
static TeamId TeamIdForRace(uint8 race);
|
||||
@@ -3025,7 +3028,6 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
|
||||
uint32 m_weaponChangeTimer;
|
||||
|
||||
uint32 m_zoneUpdateId;
|
||||
uint32 m_zoneUpdateTimer;
|
||||
uint32 m_areaUpdateId;
|
||||
|
||||
uint32 m_deathTimer;
|
||||
|
||||
@@ -92,7 +92,7 @@ void RestMgr::AddRestBonus(RestTypes restType, float restBonus)
|
||||
SetRestBonus(restType, totalRestBonus);
|
||||
}
|
||||
|
||||
void RestMgr::SetRestFlag(RestFlag restFlag, uint32 triggerID)
|
||||
void RestMgr::SetRestFlag(RestFlag restFlag)
|
||||
{
|
||||
uint32 oldRestMask = _restFlagMask;
|
||||
_restFlagMask |= restFlag;
|
||||
@@ -102,9 +102,6 @@ void RestMgr::SetRestFlag(RestFlag restFlag, uint32 triggerID)
|
||||
_restTime = GameTime::GetGameTime();
|
||||
_player->SetPlayerFlag(PLAYER_FLAGS_RESTING);
|
||||
}
|
||||
|
||||
if (triggerID)
|
||||
_innAreaTriggerId = triggerID;
|
||||
}
|
||||
|
||||
void RestMgr::RemoveRestFlag(RestFlag restFlag)
|
||||
|
||||
@@ -68,11 +68,12 @@ public:
|
||||
void AddRestBonus(RestTypes restType, float restBonus);
|
||||
|
||||
bool HasRestFlag(RestFlag restFlag) const { return (_restFlagMask & restFlag) != 0; }
|
||||
void SetRestFlag(RestFlag restFlag, uint32 triggerId = 0);
|
||||
void SetRestFlag(RestFlag restFlag);
|
||||
void RemoveRestFlag(RestFlag restFlag);
|
||||
|
||||
uint32 GetRestBonusFor(RestTypes restType, uint32 xp);
|
||||
uint32 GetInnTriggerID() const { return _innAreaTriggerId; }
|
||||
void SetInnTriggerID(uint32 id) { _innAreaTriggerId = id; }
|
||||
|
||||
void Update(time_t now);
|
||||
|
||||
|
||||
@@ -566,7 +566,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPackets::AreaTrigger::AreaTrigge
|
||||
{
|
||||
// set resting flag we are in the inn
|
||||
if (packet.Entered)
|
||||
player->GetRestMgr().SetRestFlag(REST_FLAG_IN_TAVERN, atEntry->ID);
|
||||
player->GetRestMgr().SetInnTriggerID(atEntry->ID);
|
||||
else
|
||||
player->GetRestMgr().RemoveRestFlag(REST_FLAG_IN_TAVERN);
|
||||
|
||||
|
||||
@@ -486,7 +486,7 @@ void WorldSession::HandleMovementOpcode(OpcodeClient opcode, MovementInfo& movem
|
||||
Unit::ProcSkillsAndAuras(plrMover, nullptr, PROC_FLAG_JUMP, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
// Whenever a player stops a movement action, an indoor/outdoor check is being performed
|
||||
// Whenever a player stops a movement action, several position based checks and updates are being performed
|
||||
switch (opcode)
|
||||
{
|
||||
case CMSG_MOVE_SET_FLY:
|
||||
@@ -497,7 +497,9 @@ void WorldSession::HandleMovementOpcode(OpcodeClient opcode, MovementInfo& movem
|
||||
case CMSG_MOVE_STOP_SWIM:
|
||||
case CMSG_MOVE_STOP_PITCH:
|
||||
case CMSG_MOVE_STOP_ASCEND:
|
||||
plrMover->CheckOutdoorsAuraRequirements();
|
||||
plrMover->UpdateZoneAndAreaId();
|
||||
plrMover->UpdateIndoorsOutdoorsAuras();
|
||||
plrMover->UpdateTavernRestingState();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user