mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[11342] Use Position struct to hold object coordinates - minor code refactoring.
Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
parent
ece78f44fa
commit
695ad4d54e
5 changed files with 30 additions and 37 deletions
|
|
@ -693,8 +693,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
void SetCombatStartPosition(float x, float y, float z) { m_combatStartX = x; m_combatStartY = y; m_combatStartZ = z; }
|
||||
void GetCombatStartPosition(float &x, float &y, float &z) { x = m_combatStartX; y = m_combatStartY; z = m_combatStartZ; }
|
||||
|
||||
void SetSummonPoint(CreatureCreatePos const& pos) { m_summonXpoint = pos.m_pos.x; m_summonYpoint = pos.m_pos.y; m_summonZpoint = pos.m_pos.z; m_summonOrientation = pos.m_pos.o; }
|
||||
void GetSummonPoint(float &fX, float &fY, float &fZ, float &fOrient) const { fX = m_summonXpoint; fY = m_summonYpoint; fZ = m_summonZpoint; fOrient = m_summonOrientation; }
|
||||
void SetSummonPoint(CreatureCreatePos const& pos) { m_summonPos = pos.m_pos; }
|
||||
void GetSummonPoint(float &fX, float &fY, float &fZ, float &fOrient) const { fX = m_summonPos.x; fY = m_summonPos.y; fZ = m_summonPos.z; fOrient = m_summonPos.o; }
|
||||
|
||||
void SetDeadByDefault (bool death_state) { m_isDeadByDefault = death_state; }
|
||||
|
||||
|
|
@ -757,10 +757,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
float m_combatStartY;
|
||||
float m_combatStartZ;
|
||||
|
||||
float m_summonXpoint;
|
||||
float m_summonYpoint;
|
||||
float m_summonZpoint;
|
||||
float m_summonOrientation;
|
||||
Position m_summonPos;
|
||||
|
||||
private:
|
||||
GridReference<Creature> m_gridRef;
|
||||
|
|
|
|||
|
|
@ -1037,8 +1037,7 @@ void Object::MarkForClientUpdate()
|
|||
}
|
||||
|
||||
WorldObject::WorldObject()
|
||||
: m_isActiveObject(false), m_currMap(NULL), m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL),
|
||||
m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f)
|
||||
: m_isActiveObject(false), m_currMap(NULL), m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1055,10 +1054,10 @@ void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask )
|
|||
|
||||
void WorldObject::Relocate(float x, float y, float z, float orientation)
|
||||
{
|
||||
m_positionX = x;
|
||||
m_positionY = y;
|
||||
m_positionZ = z;
|
||||
m_orientation = orientation;
|
||||
m_position.x = x;
|
||||
m_position.y = y;
|
||||
m_position.z = z;
|
||||
m_position.o = orientation;
|
||||
|
||||
if(isType(TYPEMASK_UNIT))
|
||||
((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, orientation);
|
||||
|
|
@ -1066,9 +1065,9 @@ void WorldObject::Relocate(float x, float y, float z, float orientation)
|
|||
|
||||
void WorldObject::Relocate(float x, float y, float z)
|
||||
{
|
||||
m_positionX = x;
|
||||
m_positionY = y;
|
||||
m_positionZ = z;
|
||||
m_position.x = x;
|
||||
m_position.y = y;
|
||||
m_position.z = z;
|
||||
|
||||
if(isType(TYPEMASK_UNIT))
|
||||
((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, GetOrientation());
|
||||
|
|
@ -1076,7 +1075,7 @@ void WorldObject::Relocate(float x, float y, float z)
|
|||
|
||||
void WorldObject::SetOrientation(float orientation)
|
||||
{
|
||||
m_orientation = orientation;
|
||||
m_position.o = orientation;
|
||||
|
||||
if(isType(TYPEMASK_UNIT))
|
||||
((Unit*)this)->m_movementInfo.ChangeOrientation(orientation);
|
||||
|
|
@ -1084,17 +1083,17 @@ void WorldObject::SetOrientation(float orientation)
|
|||
|
||||
uint32 WorldObject::GetZoneId() const
|
||||
{
|
||||
return GetTerrain()->GetZoneId(m_positionX, m_positionY, m_positionZ);
|
||||
return GetTerrain()->GetZoneId(m_position.x, m_position.y, m_position.z);
|
||||
}
|
||||
|
||||
uint32 WorldObject::GetAreaId() const
|
||||
{
|
||||
return GetTerrain()->GetAreaId(m_positionX, m_positionY, m_positionZ);
|
||||
return GetTerrain()->GetAreaId(m_position.x, m_position.y, m_position.z);
|
||||
}
|
||||
|
||||
void WorldObject::GetZoneAndAreaId(uint32& zoneid, uint32& areaid) const
|
||||
{
|
||||
GetTerrain()->GetZoneAndAreaId(zoneid, areaid, m_positionX, m_positionY, m_positionZ);
|
||||
GetTerrain()->GetZoneAndAreaId(zoneid, areaid, m_position.x, m_position.y, m_position.z);
|
||||
}
|
||||
|
||||
InstanceData* WorldObject::GetInstanceData() const
|
||||
|
|
@ -1324,7 +1323,7 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const
|
|||
arc = MapManager::NormalizeOrientation(arc);
|
||||
|
||||
float angle = GetAngle( obj );
|
||||
angle -= m_orientation;
|
||||
angle -= m_position.o;
|
||||
|
||||
// move angle to range -pi ... +pi
|
||||
angle = MapManager::NormalizeOrientation(angle);
|
||||
|
|
@ -1452,7 +1451,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
|||
|
||||
bool WorldObject::IsPositionValid() const
|
||||
{
|
||||
return MaNGOS::IsValidMapCoord(m_positionX,m_positionY,m_positionZ,m_orientation);
|
||||
return MaNGOS::IsValidMapCoord(m_position.x,m_position.y,m_position.z,m_position.o);
|
||||
}
|
||||
|
||||
void WorldObject::MonsterSay(const char* text, uint32 language, Unit* target)
|
||||
|
|
|
|||
|
|
@ -73,6 +73,12 @@ class TerrainInfo;
|
|||
|
||||
typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
|
||||
|
||||
struct Position
|
||||
{
|
||||
Position() : x(0.0f), y(0.0f), z(0.0f), o(0.0f) {}
|
||||
float x, y, z, o;
|
||||
};
|
||||
|
||||
struct WorldLocation
|
||||
{
|
||||
uint32 mapid;
|
||||
|
|
@ -434,14 +440,14 @@ class MANGOS_DLL_SPEC WorldObject : public Object
|
|||
|
||||
void SetOrientation(float orientation);
|
||||
|
||||
float GetPositionX( ) const { return m_positionX; }
|
||||
float GetPositionY( ) const { return m_positionY; }
|
||||
float GetPositionZ( ) const { return m_positionZ; }
|
||||
float GetPositionX( ) const { return m_position.x; }
|
||||
float GetPositionY( ) const { return m_position.y; }
|
||||
float GetPositionZ( ) const { return m_position.z; }
|
||||
void GetPosition( float &x, float &y, float &z ) const
|
||||
{ x = m_positionX; y = m_positionY; z = m_positionZ; }
|
||||
{ x = m_position.x; y = m_position.y; z = m_position.z; }
|
||||
void GetPosition( WorldLocation &loc ) const
|
||||
{ loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); }
|
||||
float GetOrientation( ) const { return m_orientation; }
|
||||
float GetOrientation( ) const { return m_position.o; }
|
||||
void GetNearPoint2D( float &x, float &y, float distance, float absAngle) const;
|
||||
void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_bounding_radius, float distance2d, float absAngle) const;
|
||||
void GetClosePoint(float &x, float &y, float &z, float bounding_radius, float distance2d = 0, float angle = 0, const WorldObject* obj = NULL ) const
|
||||
|
|
@ -598,10 +604,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
|
|||
uint32 m_InstanceId; // in map copy with instance id
|
||||
uint32 m_phaseMask; // in area phase state
|
||||
|
||||
float m_positionX;
|
||||
float m_positionY;
|
||||
float m_positionZ;
|
||||
float m_orientation;
|
||||
Position m_position;
|
||||
|
||||
ViewPoint m_viewPoint;
|
||||
|
||||
|
|
|
|||
|
|
@ -711,12 +711,6 @@ enum SplineType
|
|||
SPLINETYPE_FACINGANGLE = 4
|
||||
};
|
||||
|
||||
struct Position
|
||||
{
|
||||
Position() : x(0.0f), y(0.0f), z(0.0f), o(0.0f) {}
|
||||
float x, y, z, o;
|
||||
};
|
||||
|
||||
class MovementInfo
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11341"
|
||||
#define REVISION_NR "11342"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue