Skip to content

Commit 744aca5

Browse files
author
Github Actions
committed
Merge 3.3.5 to 3.3.5-base_patch
2 parents 3077bcf + 77724bf commit 744aca5

File tree

10 files changed

+101
-44
lines changed

10 files changed

+101
-44
lines changed

src/server/game/Entities/GameObject/GameObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
452452

453453
void GameObject::Update(uint32 diff)
454454
{
455-
m_Events.Update(diff);
455+
WorldObject::Update(diff);
456456

457457
if (AI())
458458
AI()->UpdateAI(diff);

src/server/game/Entities/Object/Object.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ void MovementInfo::OutDebug()
936936
WorldObject::WorldObject(bool isWorldObject) : Object(), WorldLocation(), LastUsedScriptID(0),
937937
m_movementInfo(), m_name(), m_isActive(false), m_isFarVisible(false), m_isStoredInWorldObjectGridContainer(isWorldObject), m_zoneScript(nullptr),
938938
m_transport(nullptr), m_zoneId(0), m_areaId(0), m_staticFloorZ(VMAP_INVALID_HEIGHT), m_outdoors(false), m_liquidStatus(LIQUID_MAP_NO_WATER),
939-
m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0)
939+
m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0), _heartbeatTimer(HEARTBEAT_INTERVAL)
940940
{
941941
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
942942
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
@@ -957,6 +957,18 @@ WorldObject::~WorldObject()
957957
}
958958
}
959959

960+
void WorldObject::Update(uint32 diff)
961+
{
962+
m_Events.Update(diff);
963+
964+
_heartbeatTimer -= Milliseconds(diff);
965+
while (_heartbeatTimer <= 0ms)
966+
{
967+
_heartbeatTimer += HEARTBEAT_INTERVAL;
968+
Heartbeat();
969+
}
970+
}
971+
960972
void WorldObject::SetIsStoredInWorldObjectGridContainer(bool on)
961973
{
962974
if (!IsInWorld())
@@ -1023,6 +1035,8 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
10231035

10241036
if (Transport* transport = GetTransport())
10251037
transport->RemovePassenger(this);
1038+
1039+
m_Events.KillAllEvents(false); // non-delatable (currently cast spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
10261040
}
10271041

10281042
void WorldObject::UpdatePositionData()

src/server/game/Entities/Object/Object.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct QuaternionData;
6363
typedef std::unordered_map<Player*, UpdateData> UpdateDataMapType;
6464

6565
float const DEFAULT_COLLISION_HEIGHT = 2.03128f; // Most common value in dbc
66+
static constexpr Milliseconds const HEARTBEAT_INTERVAL = 5s + 200ms;
6667

6768
class TC_GAME_API Object
6869
{
@@ -339,7 +340,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
339340
public:
340341
virtual ~WorldObject();
341342

342-
virtual void Update(uint32 /*time_diff*/) { }
343+
virtual void Update(uint32 diff);
343344

344345
void AddToWorld() override;
345346
void RemoveFromWorld() override;
@@ -624,6 +625,8 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
624625
virtual bool IsInvisibleDueToDespawn() const { return false; }
625626
//difference from IsAlwaysVisibleFor: 1. after distance check; 2. use owner or charmer as seer
626627
virtual bool IsAlwaysDetectableFor(WorldObject const* /*seer*/) const { return false; }
628+
629+
virtual void Heartbeat() { }
627630
private:
628631
Map* m_currMap; // current object's Map location
629632

@@ -634,6 +637,8 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
634637

635638
ObjectGuid _privateObjectOwner;
636639

640+
Milliseconds _heartbeatTimer;
641+
637642
virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool incOwnRadius = true, bool incTargetRadius = true) const;
638643

639644
bool CanNeverSee(WorldObject const* obj) const;

src/server/game/Entities/Player/Player.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,6 @@ Player::Player(WorldSession* session): Unit(true)
344344

345345
m_achievementMgr = new AchievementMgr(this);
346346
m_reputationMgr = new ReputationMgr(this);
347-
348-
m_groupUpdateTimer.Reset(5000);
349347
}
350348

351349
Player::~Player()
@@ -1230,14 +1228,6 @@ void Player::Update(uint32 p_time)
12301228
}
12311229
}
12321230

1233-
// group update
1234-
m_groupUpdateTimer.Update(p_time);
1235-
if (m_groupUpdateTimer.Passed())
1236-
{
1237-
SendUpdateToOutOfRangeGroupMembers();
1238-
m_groupUpdateTimer.Reset(5000);
1239-
}
1240-
12411231
Pet* pet = GetPet();
12421232
if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityRange()) && !pet->isPossessed())
12431233
//if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID())))
@@ -1259,6 +1249,17 @@ void Player::Update(uint32 p_time)
12591249
TeleportTo(m_teleport_dest, m_teleport_options);
12601250
}
12611251

1252+
void Player::Heartbeat()
1253+
{
1254+
Unit::Heartbeat();
1255+
1256+
// Group update
1257+
SendUpdateToOutOfRangeGroupMembers();
1258+
1259+
// Indoor/Outdoor aura requirements
1260+
CheckOutdoorsAuraRequirements();
1261+
}
1262+
12621263
void Player::setDeathState(DeathState s)
12631264
{
12641265
uint32 ressSpellId = 0;
@@ -6149,7 +6150,7 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation, bool t
61496150
if (GetGroup())
61506151
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
61516152

6152-
CheckAreaExploreAndOutdoor();
6153+
CheckAreaExplore();
61536154

61546155
return true;
61556156
}
@@ -6206,17 +6207,14 @@ void Player::SendMovieStart(uint32 movieId)
62066207
SendDirectMessage(packet.Write());
62076208
}
62086209

6209-
void Player::CheckAreaExploreAndOutdoor()
6210+
void Player::CheckAreaExplore()
62106211
{
62116212
if (!IsAlive())
62126213
return;
62136214

62146215
if (IsInFlight())
62156216
return;
62166217

6217-
if (sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK) && !IsOutdoors())
6218-
RemoveAurasWithAttribute(SPELL_ATTR0_OUTDOORS_ONLY);
6219-
62206218
uint32 const areaId = GetAreaId();
62216219
if (!areaId)
62226220
return;
@@ -6288,6 +6286,12 @@ void Player::CheckAreaExploreAndOutdoor()
62886286
}
62896287
}
62906288

6289+
void Player::CheckOutdoorsAuraRequirements()
6290+
{
6291+
if (sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK))
6292+
RemoveAurasWithAttribute(IsOutdoors() ? SPELL_ATTR0_INDOORS_ONLY : SPELL_ATTR0_OUTDOORS_ONLY);
6293+
}
6294+
62916295
uint32 Player::TeamForRace(uint8 race)
62926296
{
62936297
if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race))

src/server/game/Entities/Player/Player.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
957957

958958
void Update(uint32 time) override;
959959

960+
void Heartbeat() override;
961+
960962
static bool BuildEnumData(PreparedQueryResult result, WorldPacket* data);
961963

962964
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster, bool requireImmunityPurgesEffectAttribute = false) const override;
@@ -1828,7 +1830,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
18281830
void SetSemaphoreTeleportFar(bool semphsetting) { mSemaphoreTeleport_Far = semphsetting; }
18291831
void ProcessDelayedOperations();
18301832

1831-
void CheckAreaExploreAndOutdoor(void);
1833+
void CheckAreaExplore();
1834+
void CheckOutdoorsAuraRequirements();
18321835

18331836
static uint32 TeamForRace(uint8 race);
18341837
static TeamId TeamIdForRace(uint8 race);
@@ -2507,8 +2510,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
25072510

25082511
bool m_needsZoneUpdate;
25092512

2510-
TimeTracker m_groupUpdateTimer;
2511-
25122513
private:
25132514
// internal common parts for CanStore/StoreItem functions
25142515
InventoryResult CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const;

src/server/game/Entities/Unit/Unit.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void Unit::Update(uint32 p_time)
434434
// WARNING! Order of execution here is important, do not change.
435435
// Spells must be processed with event system BEFORE they go to _UpdateSpells.
436436
// Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
437-
m_Events.Update(p_time);
437+
WorldObject::Update(p_time);
438438

439439
CheckPendingMovementAcks();
440440

@@ -499,6 +499,14 @@ void Unit::Update(uint32 p_time)
499499
RefreshAI();
500500
}
501501

502+
void Unit::Heartbeat()
503+
{
504+
WorldObject::Heartbeat();
505+
506+
// SMSG_FLIGHT_SPLINE_SYNC for cyclic splines
507+
SendFlightSplineSyncUpdate();
508+
}
509+
502510
bool Unit::haveOffhandWeapon() const
503511
{
504512
if (Player const* player = ToPlayer())
@@ -525,20 +533,6 @@ void Unit::UpdateSplineMovement(uint32 t_diff)
525533
movespline->updateState(t_diff);
526534
bool arrived = movespline->Finalized();
527535

528-
if (movespline->isCyclic())
529-
{
530-
m_splineSyncTimer.Update(t_diff);
531-
if (m_splineSyncTimer.Passed())
532-
{
533-
m_splineSyncTimer.Reset(5000); // Retail value, do not change
534-
535-
WorldPacket data(SMSG_FLIGHT_SPLINE_SYNC, 4 + GetPackGUID().size());
536-
Movement::PacketBuilder::WriteSplineSync(*movespline, data);
537-
data << GetPackGUID();
538-
SendMessageToSet(&data, true);
539-
}
540-
}
541-
542536
if (arrived)
543537
{
544538
DisableSpline();
@@ -574,6 +568,17 @@ void Unit::UpdateSplinePosition()
574568
UpdatePosition(loc.x, loc.y, loc.z, loc.orientation);
575569
}
576570

571+
void Unit::SendFlightSplineSyncUpdate()
572+
{
573+
if (!movespline->isCyclic() || movespline->Finalized())
574+
return;
575+
576+
WorldPacket data(SMSG_FLIGHT_SPLINE_SYNC, 4 + GetPackGUID().size());
577+
Movement::PacketBuilder::WriteSplineSync(*movespline, data);
578+
data << GetPackGUID();
579+
SendMessageToSet(&data, true);
580+
}
581+
577582
void Unit::InterruptMovementBasedAuras()
578583
{
579584
// TODO: Check if orientation transport offset changed instead of only global orientation
@@ -9666,7 +9671,6 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup)
96669671
if (finalCleanup)
96679672
m_cleanupDone = true;
96689673

9669-
m_Events.KillAllEvents(false); // non-delatable (currently cast spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
96709674
CombatStop();
96719675
ClearComboPoints();
96729676
ClearComboPointHolders();

src/server/game/Entities/Unit/Unit.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,8 @@ class TC_GAME_API Unit : public WorldObject
827827

828828
virtual void Update(uint32 time) override;
829829

830+
void Heartbeat() override;
831+
830832
void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; }
831833
void resetAttackTimer(WeaponAttackType type = BASE_ATTACK);
832834
uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; }
@@ -1921,6 +1923,7 @@ class TC_GAME_API Unit : public WorldObject
19211923
friend class ImmediateMovementGenerator; // for UpdateSplineMovement
19221924
void UpdateSplineMovement(uint32 t_diff);
19231925
void UpdateSplinePosition();
1926+
void SendFlightSplineSyncUpdate();
19241927
void InterruptMovementBasedAuras();
19251928
void CheckPendingMovementAcks();
19261929

@@ -1940,7 +1943,6 @@ class TC_GAME_API Unit : public WorldObject
19401943

19411944
uint32 m_state; // Even derived shouldn't modify
19421945
uint32 m_lastManaUse; // msecs
1943-
TimeTracker m_splineSyncTimer;
19441946

19451947
Diminishing m_Diminishing;
19461948

src/server/game/Handlers/LootHandler.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,18 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
282282
else if (loot->isLooted() || go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
283283
{
284284
if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE)
285-
{ // The fishing hole used once more
286-
go->AddUse(); // if the max usage is reached, will be despawned in next tick
287-
if (go->GetUseCount() >= go->GetGOValue()->FishingHole.MaxOpens)
288-
go->SetLootState(GO_JUST_DEACTIVATED);
289-
else
290-
go->SetLootState(GO_READY);
285+
{
286+
bool allOpensConsumed = false;
287+
if (go->GetGOValue()->FishingHole.MaxOpens)
288+
{
289+
// The fishing hole used once more
290+
go->AddUse();
291+
292+
// If the max usage is reached, will be despawned in next tick
293+
allOpensConsumed = go->GetUseCount() >= go->GetGOValue()->FishingHole.MaxOpens;
294+
}
295+
296+
go->SetLootState(allOpensConsumed ? GO_JUST_DEACTIVATED : GO_READY);
291297
}
292298
else
293299
go->SetLootState(GO_JUST_DEACTIVATED);

src/server/game/Handlers/MovementHandler.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,23 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvPacket)
419419
}
420420
else
421421
plrMover->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_IS_OUT_OF_BOUNDS);
422+
423+
// Whenever a player stops a movement action, an indoor/outdoor check is being performed
424+
switch (opcode)
425+
{
426+
case CMSG_MOVE_SET_FLY:
427+
case MSG_MOVE_FALL_LAND:
428+
case MSG_MOVE_STOP:
429+
case MSG_MOVE_STOP_STRAFE:
430+
case MSG_MOVE_STOP_TURN:
431+
case MSG_MOVE_STOP_SWIM:
432+
case MSG_MOVE_STOP_PITCH:
433+
case MSG_MOVE_STOP_ASCEND:
434+
plrMover->CheckOutdoorsAuraRequirements();
435+
break;
436+
default:
437+
break;
438+
}
422439
}
423440
}
424441

src/server/game/Scripting/ScriptMgr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ class CreatureGameObjectScriptRegistrySwapHooks
404404
// Hook which is called before a gameobject is swapped
405405
static void UnloadResetScript(GameObject* gameobject)
406406
{
407+
// Remove deletable events only,
408+
// otherwise it causes crashes with non-deletable spell events.
409+
gameobject->m_Events.KillAllEvents(false);
410+
407411
gameobject->AI()->Reset();
408412
}
409413

0 commit comments

Comments
 (0)