Skip to content

Commit

Permalink
Core/Objects: Removed type casts before accessing WorldObject::m_Even…
Browse files Browse the repository at this point in the history
…ts that became unneccessary after moving it from Unit to WorldObject
  • Loading branch information
Shauren committed Jan 24, 2025
1 parent 68b10dc commit bc8874f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 28 deletions.
10 changes: 1 addition & 9 deletions src/server/game/Entities/Creature/TemporarySummon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,7 @@ void TempSummon::UnSummon(uint32 msTime)
{
if (msTime)
{
ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);

m_Events.AddEvent(pEvent, m_Events.CalculateTime(Milliseconds(msTime)));
m_Events.AddEventAtOffset(new ForcedDespawnDelayEvent(*this, 0s), Milliseconds(msTime));
return;
}

Expand All @@ -358,12 +356,6 @@ void TempSummon::UnSummon(uint32 msTime)
AddObjectToRemoveList();
}

bool ForcedUnsummonDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
m_owner.UnSummon();
return true;
}

void TempSummon::RemoveFromWorld()
{
if (!IsInWorld())
Expand Down
9 changes: 0 additions & 9 deletions src/server/game/Entities/Creature/TemporarySummon.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,4 @@ class TC_GAME_API Puppet : public Minion
void Update(uint32 time) override;
};

class TC_GAME_API ForcedUnsummonDelayEvent : public BasicEvent
{
public:
ForcedUnsummonDelayEvent(TempSummon& owner) : BasicEvent(), m_owner(owner) { }
bool Execute(uint64 e_time, uint32 p_time) override;

private:
TempSummon& m_owner;
};
#endif
2 changes: 1 addition & 1 deletion src/server/game/Entities/Totem/Totem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void Totem::UnSummon(uint32 msTime)
{
if (msTime)
{
m_Events.AddEvent(new ForcedUnsummonDelayEvent(*this), m_Events.CalculateTime(Milliseconds(msTime)));
m_Events.AddEventAtOffset(new ForcedDespawnDelayEvent(*this, 0s), Milliseconds(msTime));
return;
}

Expand Down
6 changes: 1 addition & 5 deletions src/server/game/Spells/Auras/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,13 +1025,9 @@ void Aura::DropChargeDelayed(uint32 delay, AuraRemoveMode removeMode)
// aura is already during delayed charge drop
if (m_dropEvent)
return;
// only units have events
Unit* owner = m_owner->ToUnit();
if (!owner)
return;

m_dropEvent = new ChargeDropEvent(this, removeMode);
owner->m_Events.AddEvent(m_dropEvent, owner->m_Events.CalculateTime(Milliseconds(delay)));
m_owner->m_Events.AddEventAtOffset(m_dropEvent, Milliseconds(delay));
}

void Aura::SetStackAmount(uint8 stackAmount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ class spell_ioc_parachute_ic : public AuraScript
class StartLaunchEvent : public BasicEvent
{
public:
StartLaunchEvent(Position const& pos, ObjectGuid const& guid) : _pos(pos), _guid(guid)
StartLaunchEvent(Map const* map, Position const& pos, ObjectGuid const& guid) : _map(map), _pos(pos), _guid(guid)
{
}

bool Execute(uint64 /*time*/, uint32 /*diff*/) override
{
Player* player = ObjectAccessor::FindPlayer(_guid);
Player* player = ObjectAccessor::GetPlayer(_map, _guid);
if (!player || !player->GetVehicle())
return true;

Expand All @@ -263,6 +263,7 @@ class StartLaunchEvent : public BasicEvent
}

private:
Map const* _map;
Position _pos;
ObjectGuid _guid;
};
Expand All @@ -272,10 +273,10 @@ class spell_ioc_launch : public SpellScript
{
void Launch()
{
if (!GetCaster()->ToCreature() || !GetExplTargetDest())
if (!GetCaster()->IsCreature() || !GetExplTargetDest())
return;

GetCaster()->ToCreature()->m_Events.AddEvent(new StartLaunchEvent(*GetExplTargetDest(), ASSERT_NOTNULL(GetHitPlayer())->GetGUID()), GetCaster()->ToCreature()->m_Events.CalculateTime(2500ms));
GetCaster()->m_Events.AddEventAtOffset(new StartLaunchEvent(GetCaster()->GetMap(), *GetExplTargetDest(), GetHitUnit()->GetGUID()), 2500ms);
}

void Register() override
Expand Down

0 comments on commit bc8874f

Please sign in to comment.