mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 14:46:24 +00:00
feat(Core/Misc): change how Position struct is retrieved (#9017)
Update Position::GetPosition() and similar methods signatures to reflect 2a4c9bc changes by return a Position object instead of accepting a Position parameter by reference.
Cherry pick of 2585e799f9
This commit is contained in:
@@ -355,15 +355,13 @@ Creature* CreatureAI::DoSummon(uint32 entry, const Position& pos, uint32 despawn
|
||||
|
||||
Creature* CreatureAI::DoSummon(uint32 entry, WorldObject* obj, float radius, uint32 despawnTime, TempSummonType summonType)
|
||||
{
|
||||
Position pos;
|
||||
obj->GetRandomNearPosition(pos, radius);
|
||||
Position pos = obj->GetRandomNearPosition(radius);
|
||||
return me->SummonCreature(entry, pos, summonType, despawnTime);
|
||||
}
|
||||
|
||||
Creature* CreatureAI::DoSummonFlyer(uint32 entry, WorldObject* obj, float flightZ, float radius, uint32 despawnTime, TempSummonType summonType)
|
||||
{
|
||||
Position pos;
|
||||
obj->GetRandomNearPosition(pos, radius);
|
||||
Position pos = obj->GetRandomNearPosition(radius);
|
||||
pos.m_positionZ += flightZ;
|
||||
return me->SummonCreature(entry, pos, summonType, despawnTime);
|
||||
}
|
||||
|
||||
@@ -1484,9 +1484,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
for (uint32 i = 0; i < e.target.randomPoint.amount; i++)
|
||||
{
|
||||
if (e.target.randomPoint.self > 0)
|
||||
me->GetRandomPoint(me->GetPosition(), range, randomPoint);
|
||||
randomPoint = me->GetRandomPoint(me->GetPosition(), range);
|
||||
else
|
||||
me->GetRandomPoint(srcPos, range, randomPoint);
|
||||
randomPoint = me->GetRandomPoint(srcPos, range);
|
||||
if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, randomPoint, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration))
|
||||
{
|
||||
if (unit && e.action.summonCreature.attackInvoker)
|
||||
@@ -1854,9 +1854,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (me)
|
||||
{
|
||||
float range = (float)e.target.randomPoint.range;
|
||||
Position randomPoint;
|
||||
Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
|
||||
me->GetRandomPoint(srcPos, range, randomPoint);
|
||||
Position randomPoint = me->GetRandomPoint(srcPos, range);
|
||||
me->GetMotionMaster()->MovePoint(
|
||||
e.action.MoveToPos.pointId,
|
||||
randomPoint.m_positionX,
|
||||
@@ -2438,9 +2437,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (me)
|
||||
{
|
||||
float range = (float)e.target.randomPoint.range;
|
||||
Position randomPoint;
|
||||
Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
|
||||
me->GetRandomPoint(srcPos, range, randomPoint);
|
||||
Position randomPoint = me->GetRandomPoint(srcPos, range);
|
||||
me->GetMotionMaster()->MoveJump(randomPoint, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,8 +155,7 @@ bool BattlefieldWG::SetupBattlefield()
|
||||
// Spawn turrets and hide them per default
|
||||
for (uint8 i = 0; i < WG_MAX_TURRET; i++)
|
||||
{
|
||||
Position towerCannonPos;
|
||||
WGTurret[i].GetPosition(&towerCannonPos);
|
||||
Position towerCannonPos = WGTurret[i].GetPosition();
|
||||
if (Creature* creature = SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE))
|
||||
{
|
||||
CanonList.insert(creature->GetGUID());
|
||||
|
||||
@@ -1338,8 +1338,7 @@ struct BfWGGameObjectBuilding
|
||||
// Spawn Turret bottom
|
||||
for (uint8 i = 0; i < TowerCannon[towerid].nbTowerCannonBottom; i++)
|
||||
{
|
||||
Position turretPos;
|
||||
TowerCannon[towerid].TowerCannonBottom[i].GetPosition(&turretPos);
|
||||
Position turretPos = TowerCannon[towerid].TowerCannonBottom[i].GetPosition();
|
||||
if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, turretPos, TEAM_ALLIANCE))
|
||||
{
|
||||
m_TowerCannonBottomList.insert(turret->GetGUID());
|
||||
@@ -1350,8 +1349,7 @@ struct BfWGGameObjectBuilding
|
||||
// Spawn Turret top
|
||||
for (uint8 i = 0; i < TowerCannon[towerid].nbTurretTop; i++)
|
||||
{
|
||||
Position towerCannonPos;
|
||||
TowerCannon[towerid].TurretTop[i].GetPosition(&towerCannonPos);
|
||||
Position towerCannonPos = TowerCannon[towerid].TurretTop[i].GetPosition();
|
||||
if (Creature* turret = m_WG->SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE))
|
||||
{
|
||||
m_TurretTopList.insert(turret->GetGUID());
|
||||
|
||||
@@ -310,11 +310,10 @@ inline void Battleground::_CheckSafePositions(uint32 diff)
|
||||
{
|
||||
m_ValidStartPositionTimer = 0;
|
||||
|
||||
Position pos;
|
||||
float x, y, z, o;
|
||||
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
|
||||
{
|
||||
itr->second->GetPosition(&pos);
|
||||
Position pos = itr->second->GetPosition();
|
||||
GetTeamStartLoc(itr->second->GetBgTeamId(), x, y, z, o);
|
||||
if (pos.GetExactDistSq(x, y, z) > maxDist)
|
||||
{
|
||||
|
||||
@@ -1684,11 +1684,11 @@ void WorldObject::GetRandomPoint(const Position& pos, float distance, float& ran
|
||||
UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
|
||||
}
|
||||
|
||||
void WorldObject::GetRandomPoint(const Position& srcPos, float distance, Position& pos) const
|
||||
Position WorldObject::GetRandomPoint(const Position& srcPos, float distance) const
|
||||
{
|
||||
float x, y, z;
|
||||
GetRandomPoint(srcPos, distance, x, y, z);
|
||||
pos.Relocate(x, y, z, GetOrientation());
|
||||
return Position(x, y, z, GetOrientation());
|
||||
}
|
||||
|
||||
void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
|
||||
@@ -2797,22 +2797,18 @@ bool WorldObject::GetClosePoint(float& x, float& y, float& z, float size, float
|
||||
return true;
|
||||
}
|
||||
|
||||
void WorldObject::GetNearPosition(Position& pos, float dist, float angle)
|
||||
Position WorldObject::GetNearPosition(float dist, float angle)
|
||||
{
|
||||
GetPosition(&pos);
|
||||
Position pos = GetPosition();
|
||||
MovePosition(pos, dist, angle);
|
||||
return pos;
|
||||
}
|
||||
|
||||
void WorldObject::GetFirstCollisionPosition(Position& pos, float dist, float angle)
|
||||
Position WorldObject::GetRandomNearPosition(float radius)
|
||||
{
|
||||
GetPosition(&pos);
|
||||
MovePositionToFirstCollision(pos, dist, angle);
|
||||
}
|
||||
|
||||
void WorldObject::GetRandomNearPosition(Position& pos, float radius)
|
||||
{
|
||||
GetPosition(&pos);
|
||||
Position pos = GetPosition();
|
||||
MovePosition(pos, radius * (float) rand_norm(), (float) rand_norm() * static_cast<float>(2 * M_PI));
|
||||
return pos;
|
||||
}
|
||||
|
||||
void WorldObject::GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d) const
|
||||
@@ -2926,7 +2922,7 @@ Position WorldObject::GetFirstCollisionPosition(float destX, float destY, float
|
||||
Position WorldObject::GetFirstCollisionPosition(float dist, float angle)
|
||||
{
|
||||
Position pos = GetPosition();
|
||||
GetFirstCollisionPosition(pos, dist, angle);
|
||||
MovePositionToFirstCollision(pos, dist, angle);
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -354,11 +354,6 @@ struct Position
|
||||
z = m_positionZ;
|
||||
o = m_orientation;
|
||||
}
|
||||
void GetPosition(Position* pos) const
|
||||
{
|
||||
if (pos)
|
||||
pos->Relocate(m_positionX, m_positionY, m_positionZ, m_orientation);
|
||||
}
|
||||
|
||||
[[nodiscard]] Position GetPosition() const { return *this; }
|
||||
|
||||
@@ -697,13 +692,12 @@ public:
|
||||
void GetVoidClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float relAngle = 0, float controlZ = 0) const;
|
||||
bool GetClosePoint(float& x, float& y, float& z, float size, float distance2d = 0, float angle = 0, const WorldObject* forWho = nullptr, bool force = false) const;
|
||||
void MovePosition(Position& pos, float dist, float angle);
|
||||
void GetNearPosition(Position& pos, float dist, float angle);
|
||||
Position GetNearPosition(float dist, float angle);
|
||||
void MovePositionToFirstCollision(Position& pos, float dist, float angle);
|
||||
Position GetFirstCollisionPosition(float startX, float startY, float startZ, float destX, float destY);
|
||||
Position GetFirstCollisionPosition(float destX, float destY, float destZ);
|
||||
Position GetFirstCollisionPosition(float dist, float angle);
|
||||
void GetFirstCollisionPosition(Position& pos, float dist, float angle);
|
||||
void GetRandomNearPosition(Position& pos, float radius);
|
||||
Position GetRandomNearPosition(float radius);
|
||||
|
||||
void GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const;
|
||||
void GetChargeContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const;
|
||||
@@ -715,7 +709,7 @@ public:
|
||||
void UpdateAllowedPositionZ(float x, float y, float& z, float* groundZ = nullptr) const;
|
||||
|
||||
void GetRandomPoint(const Position& srcPos, float distance, float& rand_x, float& rand_y, float& rand_z) const;
|
||||
void GetRandomPoint(const Position& srcPos, float distance, Position& pos) const;
|
||||
Position GetRandomPoint(const Position& srcPos, float distance) const;
|
||||
|
||||
[[nodiscard]] uint32 GetInstanceId() const { return m_InstanceId; }
|
||||
|
||||
|
||||
@@ -1439,8 +1439,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
// near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing
|
||||
if (!GetSession()->PlayerLogout())
|
||||
{
|
||||
Position oldPos;
|
||||
GetPosition(&oldPos);
|
||||
Position oldPos = GetPosition();
|
||||
Relocate(x, y, z, orientation);
|
||||
SendTeleportAckPacket();
|
||||
SendTeleportPacket(oldPos); // this automatically relocates to oldPos in order to broadcast the packet in the right place
|
||||
|
||||
@@ -18833,7 +18833,7 @@ void Unit::_ExitVehicle(Position const* exitPosition)
|
||||
|
||||
Position pos;
|
||||
if (!exitPosition) // Exit position not specified
|
||||
vehicleBase->GetPosition(&pos); // This should use passenger's current position, leaving it as it is now
|
||||
pos = vehicleBase->GetPosition(); // This should use passenger's current position, leaving it as it is now
|
||||
// because we calculate positions incorrect (sometimes under map)
|
||||
else
|
||||
pos = *exitPosition;
|
||||
|
||||
@@ -2491,7 +2491,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
|
||||
pos = *destTarget;
|
||||
else
|
||||
// randomize position for multiple summons
|
||||
m_caster->GetRandomPoint(*destTarget, radius, pos);
|
||||
pos = m_caster->GetRandomPoint(*destTarget, radius);
|
||||
|
||||
summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration);
|
||||
if (!summon)
|
||||
@@ -4883,8 +4883,7 @@ void Spell::EffectLeap(SpellEffIndex /*effIndex*/)
|
||||
if (!m_targets.HasDst())
|
||||
return;
|
||||
|
||||
Position dstpos;
|
||||
destTarget->GetPosition(&dstpos);
|
||||
Position dstpos = destTarget->GetPosition();
|
||||
unitTarget->NearTeleportTo(dstpos.GetPositionX(), dstpos.GetPositionY(), dstpos.GetPositionZ(), dstpos.GetOrientation(), unitTarget == m_caster);
|
||||
}
|
||||
|
||||
@@ -5118,15 +5117,7 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/)
|
||||
}
|
||||
else
|
||||
{
|
||||
Position pos;
|
||||
unitTarget->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
|
||||
// assume that target is not in water - else should be always in los
|
||||
if (!m_caster->IsWithinLOS(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()))
|
||||
{
|
||||
float angle = m_caster->GetRelativeAngle(&pos);
|
||||
float dist = m_caster->GetDistance(pos);
|
||||
m_caster->GetFirstCollisionPosition(pos, dist, angle);
|
||||
}
|
||||
Position pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetObjectSize(), unitTarget->GetRelativeAngle(m_caster));
|
||||
|
||||
m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ + Z_OFFSET_FIND_HEIGHT, SPEED_CHARGE, EVENT_CHARGE,
|
||||
nullptr, false, 0.f, targetGUID);
|
||||
@@ -5156,14 +5147,13 @@ void Spell::EffectChargeDest(SpellEffIndex /*effIndex*/)
|
||||
|
||||
if (m_targets.HasDst())
|
||||
{
|
||||
Position pos;
|
||||
destTarget->GetPosition(&pos);
|
||||
Position pos = destTarget->GetPosition();
|
||||
|
||||
if (!m_caster->IsWithinLOS(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()))
|
||||
{
|
||||
float angle = m_caster->GetRelativeAngle(pos.GetPositionX(), pos.GetPositionY());
|
||||
float dist = m_caster->GetDistance(pos);
|
||||
m_caster->GetFirstCollisionPosition(pos, dist, angle);
|
||||
pos = m_caster->GetFirstCollisionPosition(dist, angle);
|
||||
}
|
||||
|
||||
m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ);
|
||||
@@ -6206,7 +6196,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const*
|
||||
else
|
||||
{
|
||||
// randomize position
|
||||
m_caster->GetRandomPoint(*destTarget, radius, pos);
|
||||
pos = m_caster->GetRandomPoint(*destTarget, radius);
|
||||
}
|
||||
|
||||
summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id);
|
||||
@@ -6470,8 +6460,7 @@ void Spell::EffectBind(SpellEffIndex effIndex)
|
||||
homeLoc.WorldRelocate(*destTarget);
|
||||
else
|
||||
{
|
||||
player->GetPosition(&homeLoc);
|
||||
homeLoc.m_mapId = player->GetMapId();
|
||||
homeLoc = player->GetWorldLocation();
|
||||
}
|
||||
|
||||
player->SetHomebind(homeLoc, areaId);
|
||||
|
||||
Reference in New Issue
Block a user