Core/Position: Remove Position implicit object slicing

This commit is contained in:
Shauren
2025-05-19 15:34:32 +02:00
parent fe788a5eeb
commit a5ca817ff6
7 changed files with 15 additions and 17 deletions

View File

@@ -22,8 +22,8 @@
#include <G3D/Vector3.h>
#include "Errors.h"
inline G3D::Vector3 PositionToVector3(Position p) { return { p.m_positionX, p.m_positionY, p.m_positionZ }; }
inline G3D::Vector3 PositionToVector3(Position const* p) { return { ASSERT_NOTNULL(p)->m_positionX, p->m_positionY, p->m_positionZ }; }
inline Position Vector3ToPosition(G3D::Vector3 v) { return { v.x, v.y, v.z }; }
inline G3D::Vector3 PositionToVector3(Position const& p) { return { p.m_positionX, p.m_positionY, p.m_positionZ }; }
inline G3D::Vector3 PositionToVector3(Position const* p) { ASSERT(p); return { p->m_positionX, p->m_positionY, p->m_positionZ }; }
inline Position Vector3ToPosition(G3D::Vector3 const& v) { return { v.x, v.y, v.z }; }
#endif

View File

@@ -2257,7 +2257,7 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
void KillPlayer();
static void OfflineResurrect(ObjectGuid const& guid, CharacterDatabaseTransaction trans);
bool HasCorpse() const { return _corpseLocation.GetMapId() != MAPID_INVALID; }
WorldLocation GetCorpseLocation() const { return _corpseLocation; }
WorldLocation const& GetCorpseLocation() const { return _corpseLocation; }
void InitializeSelfResurrectionSpells();
void ResurrectPlayer(float restore_percent, bool applySickness = false);
void BuildPlayerRepop();

View File

@@ -559,9 +559,7 @@ void WorldSession::HandleMissileTrajectoryCollision(WorldPackets::Spells::Missil
if (!spell || !spell->m_targets.HasDst())
return;
Position pos = *spell->m_targets.GetDstPos();
pos.Relocate(packet.CollisionPos);
spell->m_targets.ModDst(pos);
spell->m_targets.ModDst(packet.CollisionPos);
// we changed dest, recalculate flight time
spell->RecalculateDelayMomentForDst();

View File

@@ -1250,7 +1250,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffectInfo const& spellEffectInfo,
void Spell::SelectImplicitConeTargets(SpellEffectInfo const& spellEffectInfo, SpellImplicitTargetInfo const& targetType, SpellTargetIndex targetIndex, uint32 effMask)
{
Position coneSrc(*m_caster);
Position coneSrc = m_caster->GetPosition();
float coneAngle = m_spellInfo->ConeAngle;
switch (targetType.GetReferenceType())
{
@@ -1554,7 +1554,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn
}();
}
Position pos = dest._position;
Position pos = dest._position.GetPosition();
MovePosition(pos, unitCaster, dist, angle);
dest.Relocate(pos);
@@ -1621,7 +1621,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn
if (dist < objSize)
dist = objSize;
Position pos = dest._position;
Position pos = dest._position.GetPosition();
MovePosition(pos, m_caster, dist, angle);
dest.Relocate(pos);
@@ -1658,7 +1658,7 @@ void Spell::SelectImplicitTargetDestTargets(SpellEffectInfo const& spellEffectIn
float angle = targetType.CalcDirectionAngle();
float dist = spellEffectInfo.CalcRadius(nullptr, targetIndex);
Position pos = dest._position;
Position pos = dest._position.GetPosition();
MovePosition(pos, target, dist, angle);
dest.Relocate(pos);
@@ -1696,7 +1696,7 @@ void Spell::SelectImplicitDestDestTargets(SpellEffectInfo const& spellEffectInfo
case TARGET_DEST_DEST_TARGET_TOWARDS_CASTER:
{
float dist = spellEffectInfo.CalcRadius(m_caster, targetIndex);
Position pos = dest._position;
Position pos = dest._position.GetPosition();
float angle = pos.GetAbsoluteAngle(m_caster) - m_caster->GetOrientation();
MovePosition(pos, m_caster, dist, angle);
@@ -1710,7 +1710,7 @@ void Spell::SelectImplicitDestDestTargets(SpellEffectInfo const& spellEffectInfo
float angle = targetType.CalcDirectionAngle();
float dist = spellEffectInfo.CalcRadius(m_caster, targetIndex);
Position pos = dest._position;
Position pos = dest._position.GetPosition();
MovePosition(pos, m_caster, dist, angle);
dest.Relocate(pos);

View File

@@ -58,7 +58,7 @@ ChatPacketSender::ChatPacketSender(ChatMsg chatType, ::Language language, WorldO
receiver ? receiver->GetGUID() : ObjectGuid::Empty,
sender ? sender->GetGUID() : ObjectGuid::Empty,
soundKitId,
receiver ? receiver->GetWorldLocation() : Position(0, 0, 0),
receiver ? receiver->GetPosition() : Position(),
broadcastTextId
);
}

View File

@@ -224,7 +224,7 @@ class spell_midsummer_juggle_torch : public SpellScript
if (!GetExplTargetDest())
return;
Position spellDest = *GetExplTargetDest();
WorldLocation spellDest = *GetExplTargetDest();
float distance = GetCaster()->GetExactDist2d(spellDest.GetPositionX(), spellDest.GetPositionY());
uint32 torchSpellID = 0;
@@ -234,7 +234,7 @@ class spell_midsummer_juggle_torch : public SpellScript
{
torchSpellID = SPELL_JUGGLE_TORCH_SELF;
torchShadowSpellID = SPELL_JUGGLE_TORCH_SHADOW_SELF;
spellDest = GetCaster()->GetPosition();
spellDest = GetCaster()->GetWorldLocation();
}
else if (distance <= 10.0f)
{

View File

@@ -2772,7 +2772,7 @@ class spell_hor_evasion : public SpellScriptLoader
void SetDest(SpellDestination& dest)
{
WorldObject* target = GetExplTargetWorldObject();
Position pos(*target);
Position pos = target->GetPosition();
Position home = GetCaster()->ToCreature()->GetHomePosition();
// prevent evasion outside the room