Skip to content

Commit

Permalink
Add missing GetWeakPtr functions (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Foereaper authored and killerwife committed Aug 16, 2024
1 parent 219c347 commit b96ace5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/game/Entities/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ class Object
inline bool IsGameObject() const { return GetTypeId() == TYPEID_GAMEOBJECT; }
inline bool IsCorpse() const { return GetTypeId() == TYPEID_CORPSE; }

MaNGOS::unique_weak_ptr<Object> GetWeakPtr() const { return m_scriptRef; }

protected:
Object();

Expand Down
6 changes: 6 additions & 0 deletions src/game/Entities/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,4 +960,10 @@ void VehicleInfo::RemoveSeatMods(Unit* passenger, uint32 seatFlags)
}
}

MaNGOS::unique_weak_ptr<VehicleInfo> VehicleInfo::GetWeakPtr() const
{
Unit* pVehicle = (Unit*)m_owner;
return pVehicle->GetVehicleInfoWeakPtr();
}

/*! @} */
2 changes: 2 additions & 0 deletions src/game/Entities/Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class VehicleInfo : public TransportBase
void RespawnAccessories(int32 seatIndex = -1);
void RecallAccessories(float distance = 0.f, int32 seatIndex = -1);

MaNGOS::unique_weak_ptr<VehicleInfo> GetWeakPtr() const;

private:
// Internal use to calculate the boarding position
void CalculateBoardingPositionOf(float gx, float gy, float gz, float go, float& lx, float& ly, float& lz, float& lo) const;
Expand Down
4 changes: 4 additions & 0 deletions src/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9980,3 +9980,7 @@ SpellCastResult Spell::CheckVehicle(Unit const* caster, SpellEntry const& spellI
return SPELL_CAST_OK;
}

MaNGOS::unique_weak_ptr<Spell> Spell::GetWeakPtr() const
{
return m_spellEvent->GetSpellWeakPtr();
}
7 changes: 6 additions & 1 deletion src/game/Spells/Spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ class SpellEvent : public BasicEvent
virtual bool IsDeletable() const override;

Spell* GetSpell() const { return m_Spell.get(); }
protected:
MaNGOS::unique_weak_ptr<Spell> GetSpellWeakPtr() const { return m_Spell; }

protected:
MaNGOS::unique_trackable_ptr<Spell> m_Spell;
};

Expand Down Expand Up @@ -903,6 +905,9 @@ class Spell
void SetDamageDoneModifier(float mod, SpellEffectIndex effIdx);
void SetIgnoreOwnerLevel(bool state) { m_ignoreOwnerLevel = state; }
void SetUsableWhileStunned(bool state) { m_usableWhileStunned = state; }

MaNGOS::unique_weak_ptr<Spell> GetWeakPtr() const;

protected:
void SendLoot(ObjectGuid guid, LootType loottype, LockType lockType);
bool IgnoreItemRequirements() const; // some item use spells have unexpected reagent data
Expand Down

0 comments on commit b96ace5

Please sign in to comment.