mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/Position: Position constructor improvements
* Prevent constructing with only X coord
* Remove unneccessary NormalizeOrientation calls when constructed with default orientation (0)
(cherry picked from commit d6ae7030da)
# Conflicts:
# src/server/game/Garrison/Garrison.cpp
This commit is contained in:
@@ -28,11 +28,11 @@ struct MovementInfo
|
||||
{
|
||||
// common
|
||||
ObjectGuid guid;
|
||||
uint32 flags;
|
||||
uint32 flags2;
|
||||
uint32 flags3;
|
||||
uint32 flags = 0;
|
||||
uint32 flags2 = 0;
|
||||
uint32 flags3 = 0;
|
||||
Position pos;
|
||||
uint32 time;
|
||||
uint32 time = 0;
|
||||
|
||||
// transport
|
||||
struct TransportInfo
|
||||
@@ -49,14 +49,14 @@ struct MovementInfo
|
||||
|
||||
ObjectGuid guid;
|
||||
Position pos;
|
||||
int8 seat;
|
||||
uint32 time;
|
||||
uint32 prevTime;
|
||||
uint32 vehicleId;
|
||||
int8 seat = -1;
|
||||
uint32 time = 0;
|
||||
uint32 prevTime = 0;
|
||||
uint32 vehicleId = 0;
|
||||
} transport;
|
||||
|
||||
// swimming/flying
|
||||
float pitch;
|
||||
float pitch = 0.0f;
|
||||
|
||||
struct Inertia
|
||||
{
|
||||
@@ -78,13 +78,16 @@ struct MovementInfo
|
||||
zspeed = sinAngle = cosAngle = xyspeed = 0.0f;
|
||||
}
|
||||
|
||||
uint32 fallTime;
|
||||
uint32 fallTime = 0;
|
||||
|
||||
float zspeed, sinAngle, cosAngle, xyspeed;
|
||||
float zspeed = 0.0f;
|
||||
float sinAngle = 0.0f;
|
||||
float cosAngle = 0.0f;
|
||||
float xyspeed = 0.0f;
|
||||
|
||||
} jump;
|
||||
|
||||
float stepUpStartElevation;
|
||||
float stepUpStartElevation = 0.0f;
|
||||
|
||||
// advflying
|
||||
struct AdvFlying
|
||||
@@ -97,14 +100,6 @@ struct MovementInfo
|
||||
|
||||
Optional<ObjectGuid> standingOnGameObjectGUID;
|
||||
|
||||
MovementInfo() :
|
||||
flags(0), flags2(0), flags3(0), time(0), pitch(0.0f), stepUpStartElevation(0.0f)
|
||||
{
|
||||
pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
transport.Reset();
|
||||
jump.Reset();
|
||||
}
|
||||
|
||||
uint32 GetMovementFlags() const { return flags; }
|
||||
void SetMovementFlags(uint32 flag) { flags = flag; }
|
||||
void AddMovementFlag(uint32 flag) { flags |= flag; }
|
||||
|
||||
@@ -27,7 +27,16 @@ class ByteBuffer;
|
||||
|
||||
struct TC_GAME_API Position
|
||||
{
|
||||
constexpr Position(float x = 0, float y = 0, float z = 0, float o = 0)
|
||||
constexpr Position()
|
||||
: m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f) { }
|
||||
|
||||
constexpr Position(float x, float y)
|
||||
: m_positionX(x), m_positionY(y), m_positionZ(0.0f), m_orientation(0.0f) { }
|
||||
|
||||
constexpr Position(float x, float y, float z)
|
||||
: m_positionX(x), m_positionY(y), m_positionZ(z), m_orientation(0.0f) { }
|
||||
|
||||
constexpr Position(float x, float y, float z, float o)
|
||||
: m_positionX(x), m_positionY(y), m_positionZ(z), m_orientation(NormalizeOrientationConstexprWrapper(o)) { }
|
||||
|
||||
// streamer tags
|
||||
@@ -181,16 +190,18 @@ private:
|
||||
class TC_GAME_API WorldLocation : public Position
|
||||
{
|
||||
public:
|
||||
constexpr explicit WorldLocation(uint32 mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f)
|
||||
: Position(x, y, z, o), m_mapId(mapId) { }
|
||||
constexpr WorldLocation() : m_mapId(MAPID_INVALID) { }
|
||||
|
||||
constexpr WorldLocation(uint32 mapId, Position const& position)
|
||||
: Position(position), m_mapId(mapId) { }
|
||||
constexpr WorldLocation(uint32 mapId, float x, float y) : Position(x, y), m_mapId(mapId) { }
|
||||
constexpr WorldLocation(uint32 mapId, float x, float y, float z) : Position(x, y, z), m_mapId(mapId) { }
|
||||
constexpr WorldLocation(uint32 mapId, float x, float y, float z, float o) : Position(x, y, z, o), m_mapId(mapId) { }
|
||||
|
||||
constexpr WorldLocation(uint32 mapId, Position const& position) : Position(position), m_mapId(mapId) { }
|
||||
|
||||
constexpr void WorldRelocate(WorldLocation const& loc) { m_mapId = loc.GetMapId(); Relocate(loc); }
|
||||
constexpr void WorldRelocate(WorldLocation const* loc) { m_mapId = loc->GetMapId(); Relocate(loc); }
|
||||
constexpr void WorldRelocate(uint32 mapId, Position const& pos) { m_mapId = mapId; Relocate(pos); }
|
||||
constexpr void WorldRelocate(uint32 mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f)
|
||||
constexpr void WorldRelocate(uint32 mapId, float x, float y, float z, float o)
|
||||
{
|
||||
m_mapId = mapId;
|
||||
Relocate(x, y, z, o);
|
||||
@@ -219,7 +230,10 @@ TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, Position::ConstStreamer<Posi
|
||||
template<class Tag>
|
||||
struct TaggedPosition
|
||||
{
|
||||
constexpr TaggedPosition(float x = 0.0f, float y = 0.0f, float z = 0.0f, float o = 0.0f) : Pos(x, y, z, o) { }
|
||||
constexpr TaggedPosition() { }
|
||||
constexpr TaggedPosition(float x, float y) : Pos(x, y) { }
|
||||
constexpr TaggedPosition(float x, float y, float z) : Pos(x, y, z) { }
|
||||
constexpr TaggedPosition(float x, float y, float z, float o) : Pos(x, y, z, o) { }
|
||||
constexpr TaggedPosition(Position const& pos) : Pos(pos) { }
|
||||
|
||||
constexpr TaggedPosition& operator=(Position const& pos)
|
||||
|
||||
@@ -4151,7 +4151,7 @@ Corpse* Player::CreateCorpse()
|
||||
|
||||
void Player::SpawnCorpseBones(bool triggerSave /*= true*/)
|
||||
{
|
||||
_corpseLocation.WorldRelocate();
|
||||
_corpseLocation.WorldRelocate(MAPID_INVALID, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
if (GetMap()->ConvertCorpseToBones(GetGUID()))
|
||||
if (triggerSave && !GetSession()->PlayerLogoutWithSave()) // at logout we will already store the player
|
||||
SaveToDB(); // prevent loading as ghost without corpse
|
||||
@@ -8150,7 +8150,7 @@ void Player::RemovedInsignia(Player* looterPlr)
|
||||
RepopAtGraveyard();
|
||||
}
|
||||
|
||||
_corpseLocation.WorldRelocate();
|
||||
_corpseLocation.WorldRelocate(MAPID_INVALID, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
// We have to convert player corpse to bones, not to be able to resurrect there
|
||||
// SpawnCorpseBones isn't handy, 'cos it saves player while he in BG
|
||||
@@ -22516,7 +22516,7 @@ void Player::SetBattlegroundEntryPoint()
|
||||
if (GetMap()->IsDungeon())
|
||||
{
|
||||
if (WorldSafeLocsEntry const* entry = sObjectMgr->GetClosestGraveyard(*this, GetTeam(), this))
|
||||
m_bgData.joinPos.WorldRelocate(entry->Loc.GetMapId(), entry->Loc.GetPositionX(), entry->Loc.GetPositionY(), entry->Loc.GetPositionZ());
|
||||
m_bgData.joinPos.WorldRelocate(entry->Loc.GetMapId(), entry->Loc.GetPositionX(), entry->Loc.GetPositionY(), entry->Loc.GetPositionZ(), 0.0f);
|
||||
else
|
||||
TC_LOG_ERROR("entities.player", "Player::SetBattlegroundEntryPoint: Dungeon (MapID: {}) has no linked graveyard, setting home location as entry point.", GetMapId());
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ struct RaidMarker
|
||||
|
||||
RaidMarker(uint32 mapId, float positionX, float positionY, float positionZ, ObjectGuid transportGuid = ObjectGuid::Empty)
|
||||
{
|
||||
Location.WorldRelocate(mapId, positionX, positionY, positionZ);
|
||||
Location.WorldRelocate(mapId, positionX, positionY, positionZ, 0.0f);
|
||||
TransportGUID = transportGuid;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user