mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 17:49:10 +00:00
refactor(Core/Game): restyle game lib with astyle (#3466)
This commit is contained in:
@@ -51,21 +51,30 @@ uint32 GuidHigh2TypeId(uint32 guid_hi)
|
||||
{
|
||||
switch (guid_hi)
|
||||
{
|
||||
case HIGHGUID_ITEM: return TYPEID_ITEM;
|
||||
case HIGHGUID_ITEM:
|
||||
return TYPEID_ITEM;
|
||||
//case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER == HIGHGUID_ITEM currently
|
||||
case HIGHGUID_UNIT: return TYPEID_UNIT;
|
||||
case HIGHGUID_PET: return TYPEID_UNIT;
|
||||
case HIGHGUID_PLAYER: return TYPEID_PLAYER;
|
||||
case HIGHGUID_GAMEOBJECT: return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_DYNAMICOBJECT:return TYPEID_DYNAMICOBJECT;
|
||||
case HIGHGUID_CORPSE: return TYPEID_CORPSE;
|
||||
case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_VEHICLE: return TYPEID_UNIT;
|
||||
case HIGHGUID_UNIT:
|
||||
return TYPEID_UNIT;
|
||||
case HIGHGUID_PET:
|
||||
return TYPEID_UNIT;
|
||||
case HIGHGUID_PLAYER:
|
||||
return TYPEID_PLAYER;
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
return TYPEID_DYNAMICOBJECT;
|
||||
case HIGHGUID_CORPSE:
|
||||
return TYPEID_CORPSE;
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_VEHICLE:
|
||||
return TYPEID_UNIT;
|
||||
}
|
||||
return NUM_CLIENT_OBJECT_TYPES; // unknown
|
||||
}
|
||||
|
||||
Object::Object() : m_PackGUID(sizeof(uint64)+1)
|
||||
Object::Object() : m_PackGUID(sizeof(uint64) + 1)
|
||||
{
|
||||
m_objectTypeId = TYPEID_OBJECT;
|
||||
m_objectType = TYPEMASK_OBJECT;
|
||||
@@ -124,7 +133,7 @@ Object::~Object()
|
||||
void Object::_InitValues()
|
||||
{
|
||||
m_uint32Values = new uint32[m_valuesCount];
|
||||
memset(m_uint32Values, 0, m_valuesCount*sizeof(uint32));
|
||||
memset(m_uint32Values, 0, m_valuesCount * sizeof(uint32));
|
||||
|
||||
_changesMask.SetCount(m_valuesCount);
|
||||
|
||||
@@ -221,7 +230,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
break;
|
||||
default:
|
||||
if (((GameObject*)this)->GetOwner())
|
||||
updatetype = UPDATETYPE_CREATE_OBJECT2;
|
||||
updatetype = UPDATETYPE_CREATE_OBJECT2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -328,7 +337,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
// 0x08000000
|
||||
if (unit->m_movementInfo.GetMovementFlags() & MOVEMENTFLAG_SPLINE_ENABLED)
|
||||
{
|
||||
const G3D::Vector3 * p = &unit->movespline->_Spline().getPoints(true)[0];
|
||||
const G3D::Vector3* p = &unit->movespline->_Spline().getPoints(true)[0];
|
||||
if (unit->movespline->_Spline().getPoints(true).empty() || (!unit->movespline->_Spline().getPoints(true).empty() && !p))
|
||||
const_cast<Unit*>(unit)->DisableSpline();
|
||||
else
|
||||
@@ -469,7 +478,7 @@ void Object::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* targe
|
||||
for (uint16 index = 0; index < m_valuesCount; ++index)
|
||||
{
|
||||
if (_fieldNotifyFlags & flags[index] ||
|
||||
((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)))
|
||||
((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)))
|
||||
{
|
||||
updateMask.SetBit(index);
|
||||
fieldBuffer << m_uint32Values[index];
|
||||
@@ -524,20 +533,20 @@ uint32 Object::GetUpdateFieldData(Player const* target, uint32*& flags) const
|
||||
break;
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
{
|
||||
Player* plr = ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
flags = UnitUpdateFieldFlags;
|
||||
if (ToUnit()->GetOwnerGUID() == target->GetGUID())
|
||||
visibleFlag |= UF_FLAG_OWNER;
|
||||
{
|
||||
Player* plr = ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
flags = UnitUpdateFieldFlags;
|
||||
if (ToUnit()->GetOwnerGUID() == target->GetGUID())
|
||||
visibleFlag |= UF_FLAG_OWNER;
|
||||
|
||||
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO))
|
||||
if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID()))
|
||||
visibleFlag |= UF_FLAG_SPECIAL_INFO;
|
||||
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO))
|
||||
if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID()))
|
||||
visibleFlag |= UF_FLAG_SPECIAL_INFO;
|
||||
|
||||
if (plr && plr->IsInSameRaidWith(target))
|
||||
visibleFlag |= UF_FLAG_PARTY_MEMBER;
|
||||
break;
|
||||
}
|
||||
if (plr && plr->IsInSameRaidWith(target))
|
||||
visibleFlag |= UF_FLAG_PARTY_MEMBER;
|
||||
break;
|
||||
}
|
||||
case TYPEID_GAMEOBJECT:
|
||||
flags = GameObjectUpdateFieldFlags;
|
||||
if (ToGameObject()->GetOwnerGUID() == target->GetGUID())
|
||||
@@ -622,7 +631,7 @@ void Object::UpdateUInt32Value(uint16 index, uint32 value)
|
||||
void Object::SetUInt64Value(uint16 index, uint64 value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
if (*((uint64*)&(m_uint32Values[index])) != value)
|
||||
if (*((uint64*) & (m_uint32Values[index])) != value)
|
||||
{
|
||||
m_uint32Values[index] = PAIR64_LOPART(value);
|
||||
m_uint32Values[index + 1] = PAIR64_HIPART(value);
|
||||
@@ -640,7 +649,7 @@ void Object::SetUInt64Value(uint16 index, uint64 value)
|
||||
bool Object::AddUInt64Value(uint16 index, uint64 value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
if (value && !*((uint64*)&(m_uint32Values[index])))
|
||||
if (value && !*((uint64*) & (m_uint32Values[index])))
|
||||
{
|
||||
m_uint32Values[index] = PAIR64_LOPART(value);
|
||||
m_uint32Values[index + 1] = PAIR64_HIPART(value);
|
||||
@@ -662,7 +671,7 @@ bool Object::AddUInt64Value(uint16 index, uint64 value)
|
||||
bool Object::RemoveUInt64Value(uint16 index, uint64 value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
if (value && *((uint64*)&(m_uint32Values[index])) == value)
|
||||
if (value && *((uint64*) & (m_uint32Values[index])) == value)
|
||||
{
|
||||
m_uint32Values[index] = 0;
|
||||
m_uint32Values[index + 1] = 0;
|
||||
@@ -976,11 +985,11 @@ void MovementInfo::OutDebug()
|
||||
|
||||
WorldObject::WorldObject(bool isWorldObject) : WorldLocation(),
|
||||
#ifdef ELUNA
|
||||
elunaEvents(nullptr),
|
||||
elunaEvents(nullptr),
|
||||
#endif
|
||||
LastUsedScriptID(0), m_name(""), m_isActive(false), m_isVisibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
|
||||
m_transport(nullptr), m_currMap(nullptr), m_InstanceId(0),
|
||||
m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
|
||||
LastUsedScriptID(0), m_name(""), m_isActive(false), m_isVisibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
|
||||
m_transport(nullptr), m_currMap(nullptr), m_InstanceId(0),
|
||||
m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
|
||||
{
|
||||
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
|
||||
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
|
||||
@@ -1118,11 +1127,11 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
|
||||
|
||||
float dx = GetPositionX() - obj->GetPositionX();
|
||||
float dy = GetPositionY() - obj->GetPositionY();
|
||||
float distsq = dx*dx + dy*dy;
|
||||
float distsq = dx * dx + dy * dy;
|
||||
if (is3D)
|
||||
{
|
||||
float dz = GetPositionZ() - obj->GetPositionZ();
|
||||
distsq += dz*dz;
|
||||
distsq += dz * dz;
|
||||
}
|
||||
|
||||
return distsq < maxdist * maxdist;
|
||||
@@ -1178,20 +1187,20 @@ bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* o
|
||||
{
|
||||
float dx1 = GetPositionX() - obj1->GetPositionX();
|
||||
float dy1 = GetPositionY() - obj1->GetPositionY();
|
||||
float distsq1 = dx1*dx1 + dy1*dy1;
|
||||
float distsq1 = dx1 * dx1 + dy1 * dy1;
|
||||
if (is3D)
|
||||
{
|
||||
float dz1 = GetPositionZ() - obj1->GetPositionZ();
|
||||
distsq1 += dz1*dz1;
|
||||
distsq1 += dz1 * dz1;
|
||||
}
|
||||
|
||||
float dx2 = GetPositionX() - obj2->GetPositionX();
|
||||
float dy2 = GetPositionY() - obj2->GetPositionY();
|
||||
float distsq2 = dx2*dx2 + dy2*dy2;
|
||||
float distsq2 = dx2 * dx2 + dy2 * dy2;
|
||||
if (is3D)
|
||||
{
|
||||
float dz2 = GetPositionZ() - obj2->GetPositionZ();
|
||||
distsq2 += dz2*dz2;
|
||||
distsq2 += dz2 * dz2;
|
||||
}
|
||||
|
||||
return distsq1 < distsq2;
|
||||
@@ -1201,11 +1210,11 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan
|
||||
{
|
||||
float dx = GetPositionX() - obj->GetPositionX();
|
||||
float dy = GetPositionY() - obj->GetPositionY();
|
||||
float distsq = dx*dx + dy*dy;
|
||||
float distsq = dx * dx + dy * dy;
|
||||
if (is3D)
|
||||
{
|
||||
float dz = GetPositionZ() - obj->GetPositionZ();
|
||||
distsq += dz*dz;
|
||||
distsq += dz * dz;
|
||||
}
|
||||
|
||||
float sizefactor = GetObjectSize() + obj->GetObjectSize();
|
||||
@@ -1226,7 +1235,7 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange)
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
float distsq = dx*dx + dy*dy;
|
||||
float distsq = dx * dx + dy * dy;
|
||||
|
||||
float sizefactor = GetObjectSize();
|
||||
|
||||
@@ -1247,7 +1256,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
float dz = GetPositionZ() - z;
|
||||
float distsq = dx*dx + dy*dy + dz*dz;
|
||||
float distsq = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
float sizefactor = GetObjectSize();
|
||||
|
||||
@@ -1263,7 +1272,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
void Position::RelocateOffset(const Position & offset)
|
||||
void Position::RelocateOffset(const Position& offset)
|
||||
{
|
||||
m_positionX = GetPositionX() + (offset.GetPositionX() * cos(GetOrientation()) + offset.GetPositionY() * sin(GetOrientation() + M_PI));
|
||||
m_positionY = GetPositionY() + (offset.GetPositionY() * cos(GetOrientation()) + offset.GetPositionX() * sin(GetOrientation()));
|
||||
@@ -1271,7 +1280,7 @@ void Position::RelocateOffset(const Position & offset)
|
||||
m_orientation = GetOrientation() + offset.GetOrientation();
|
||||
}
|
||||
|
||||
void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset) const
|
||||
void Position::GetPositionOffsetTo(const Position& endPos, Position& retOffset) const
|
||||
{
|
||||
float dx = endPos.GetPositionX() - GetPositionX();
|
||||
float dy = endPos.GetPositionY() - GetPositionY();
|
||||
@@ -1301,20 +1310,20 @@ float Position::GetAngle(const float x, const float y) const
|
||||
return ang;
|
||||
}
|
||||
|
||||
void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) const
|
||||
void Position::GetSinCos(const float x, const float y, float& vsin, float& vcos) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
float dy = GetPositionY() - y;
|
||||
|
||||
if (fabs(dx) < 0.001f && fabs(dy) < 0.001f)
|
||||
{
|
||||
float angle = (float)rand_norm()*static_cast<float>(2*M_PI);
|
||||
float angle = (float)rand_norm() * static_cast<float>(2 * M_PI);
|
||||
vcos = cos(angle);
|
||||
vsin = sin(angle);
|
||||
}
|
||||
else
|
||||
{
|
||||
float dist = sqrt((dx*dx) + (dy*dy));
|
||||
float dist = sqrt((dx * dx) + (dy * dy));
|
||||
vcos = dx / dist;
|
||||
vsin = dy / dist;
|
||||
}
|
||||
@@ -1333,16 +1342,16 @@ bool Position::IsWithinBox(const Position& center, float xradius, float yradius,
|
||||
float BoxDistX = GetPositionX() - center.GetPositionX();
|
||||
float BoxDistY = GetPositionY() - center.GetPositionY();
|
||||
|
||||
float rotX = float(center.GetPositionX() + BoxDistX * cosVal - BoxDistY*sinVal);
|
||||
float rotY = float(center.GetPositionY() + BoxDistY * cosVal + BoxDistX*sinVal);
|
||||
float rotX = float(center.GetPositionX() + BoxDistX * cosVal - BoxDistY * sinVal);
|
||||
float rotY = float(center.GetPositionY() + BoxDistY * cosVal + BoxDistX * sinVal);
|
||||
|
||||
// box edges are parallel to coordiante axis, so we can treat every dimension independently :D
|
||||
float dz = GetPositionZ() - center.GetPositionZ();
|
||||
float dx = rotX - center.GetPositionX();
|
||||
float dy = rotY - center.GetPositionY();
|
||||
if ((std::fabs(dx) > xradius) ||
|
||||
(std::fabs(dy) > yradius) ||
|
||||
(std::fabs(dz) > zradius))
|
||||
(std::fabs(dy) > yradius) ||
|
||||
(std::fabs(dz) > zradius))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -1363,17 +1372,17 @@ bool Position::HasInArc(float arc, const Position* obj, float targetRadius) cons
|
||||
// move angle to range -pi ... +pi
|
||||
angle = Position::NormalizeOrientation(angle);
|
||||
if (angle > M_PI)
|
||||
angle -= 2.0f*M_PI;
|
||||
angle -= 2.0f * M_PI;
|
||||
|
||||
float lborder = -1 * (arc/2.0f); // in range -pi..0
|
||||
float rborder = (arc/2.0f); // in range 0..pi
|
||||
float lborder = -1 * (arc / 2.0f); // in range -pi..0
|
||||
float rborder = (arc / 2.0f); // in range 0..pi
|
||||
|
||||
// pussywizard: take into consideration target size
|
||||
if (targetRadius > 0.0f)
|
||||
{
|
||||
float distSq = GetExactDist2dSq(obj);
|
||||
// pussywizard: at least a part of target's model is in every direction
|
||||
if (distSq < targetRadius*targetRadius)
|
||||
if (distSq < targetRadius * targetRadius)
|
||||
return true;
|
||||
float angularRadius = 2.0f * atan(targetRadius / (2.0f * sqrt(distSq)));
|
||||
lborder -= angularRadius;
|
||||
@@ -1396,12 +1405,12 @@ bool WorldObject::IsInBetween(const WorldObject* obj1, const WorldObject* obj2,
|
||||
return false;
|
||||
|
||||
if (G3D::fuzzyEq(obj1->GetPositionX(), obj2->GetPositionX()))
|
||||
return GetPositionX() >= obj1->GetPositionX()-size && GetPositionX() <= obj1->GetPositionX()+size;
|
||||
return GetPositionX() >= obj1->GetPositionX() - size && GetPositionX() <= obj1->GetPositionX() + size;
|
||||
|
||||
float A = (obj2->GetPositionY()-obj1->GetPositionY())/(obj2->GetPositionX()-obj1->GetPositionX());
|
||||
float A = (obj2->GetPositionY() - obj1->GetPositionY()) / (obj2->GetPositionX() - obj1->GetPositionX());
|
||||
float B = -1;
|
||||
float C = obj1->GetPositionY() - A*obj1->GetPositionX();
|
||||
float dist = fabs(A*GetPositionX()+B*GetPositionY()+C)/sqrt(A*A+B*B);
|
||||
float C = obj1->GetPositionY() - A * obj1->GetPositionX();
|
||||
float dist = fabs(A * GetPositionX() + B * GetPositionY() + C) / sqrt(A * A + B * B);
|
||||
return dist <= size;
|
||||
}
|
||||
|
||||
@@ -1415,7 +1424,7 @@ bool WorldObject::isInBack(WorldObject const* target, float arc) const
|
||||
return !HasInArc(2 * M_PI - arc, target);
|
||||
}
|
||||
|
||||
void WorldObject::GetRandomPoint(const Position &pos, float distance, float &rand_x, float &rand_y, float &rand_z) const
|
||||
void WorldObject::GetRandomPoint(const Position& pos, float distance, float& rand_x, float& rand_y, float& rand_z) const
|
||||
{
|
||||
if (!distance)
|
||||
{
|
||||
@@ -1424,8 +1433,8 @@ void WorldObject::GetRandomPoint(const Position &pos, float distance, float &ran
|
||||
}
|
||||
|
||||
// angle to face `obj` to `this`
|
||||
float angle = (float)rand_norm()*static_cast<float>(2*M_PI);
|
||||
float new_dist = (float)rand_norm()*static_cast<float>(distance);
|
||||
float angle = (float)rand_norm() * static_cast<float>(2 * M_PI);
|
||||
float new_dist = (float)rand_norm() * static_cast<float>(distance);
|
||||
|
||||
rand_x = pos.m_positionX + new_dist * cos(angle);
|
||||
rand_y = pos.m_positionY + new_dist * sin(angle);
|
||||
@@ -1436,14 +1445,14 @@ 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::UpdateGroundPositionZ(float x, float y, float &z) const
|
||||
void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const
|
||||
{
|
||||
float new_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z /*+ 2.0f*/, true); // pussywizard: +2.0f is added in all inner functions
|
||||
if (new_z > INVALID_HEIGHT)
|
||||
z = new_z + 0.05f; // just to be sure that we are not a few pixel under the surface
|
||||
}
|
||||
|
||||
void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
||||
void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
|
||||
{
|
||||
// TODO: Allow transports to be part of dynamic vmap tree
|
||||
//if (GetTransport())
|
||||
@@ -1452,62 +1461,62 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
||||
switch (GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
{
|
||||
// non fly unit don't must be in air
|
||||
// non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast
|
||||
if (!ToCreature()->CanFly())
|
||||
{
|
||||
bool canSwim = ToCreature()->CanSwim();
|
||||
float ground_z = z;
|
||||
float max_z = canSwim
|
||||
? GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK))
|
||||
: ((ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true)));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
// non fly unit don't must be in air
|
||||
// non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast
|
||||
if (!ToCreature()->CanFly())
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
bool canSwim = ToCreature()->CanSwim();
|
||||
float ground_z = z;
|
||||
float max_z = canSwim
|
||||
? GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK))
|
||||
: ((ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true)));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPEID_PLAYER:
|
||||
{
|
||||
// for server controlled moves playr work same as creature (but it can always swim)
|
||||
if (!ToPlayer()->CanFly())
|
||||
{
|
||||
float ground_z = z;
|
||||
float max_z = GetMap()->GetWaterOrGroundLevel(GetPhaseMask(),x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
// for server controlled moves playr work same as creature (but it can always swim)
|
||||
if (!ToPlayer()->CanFly())
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
float ground_z = z;
|
||||
float max_z = GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, &ground_z, !ToUnit()->HasAuraType(SPELL_AURA_WATER_WALK));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
default:
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (z < ground_z)
|
||||
if (ground_z > INVALID_HEIGHT)
|
||||
z = ground_z;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z, true);
|
||||
if (ground_z > INVALID_HEIGHT)
|
||||
z = ground_z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1535,11 +1544,11 @@ float WorldObject::GetVisibilityRange() const
|
||||
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
{
|
||||
if (IsInWintergrasp())
|
||||
return VISIBILITY_DIST_WINTERGRASP+VISIBILITY_INC_FOR_GOBJECTS;
|
||||
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
else if (IsVisibilityOverridden())
|
||||
return MAX_VISIBILITY_DISTANCE;
|
||||
else
|
||||
return GetMap()->GetVisibilityRange()+VISIBILITY_INC_FOR_GOBJECTS;
|
||||
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
else
|
||||
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
@@ -1558,11 +1567,11 @@ float WorldObject::GetSightRange(const WorldObject* target) const
|
||||
else if (target->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
{
|
||||
if (IsInWintergrasp() && target->IsInWintergrasp())
|
||||
return VISIBILITY_DIST_WINTERGRASP+VISIBILITY_INC_FOR_GOBJECTS;
|
||||
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
else if (target->IsVisibilityOverridden())
|
||||
return MAX_VISIBILITY_DISTANCE;
|
||||
else
|
||||
return GetMap()->GetVisibilityRange()+VISIBILITY_INC_FOR_GOBJECTS;
|
||||
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
|
||||
return IsInWintergrasp() && target->IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
@@ -1607,7 +1616,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
||||
if (Player const* thisPlayer = ToPlayer())
|
||||
{
|
||||
if (thisPlayer->isDead() && thisPlayer->GetHealth() > 0 && // Cheap way to check for ghost state
|
||||
!(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & GHOST_VISIBILITY_GHOST))
|
||||
!(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & GHOST_VISIBILITY_GHOST))
|
||||
{
|
||||
if (Corpse* corpse = thisPlayer->GetCorpse())
|
||||
{
|
||||
@@ -1879,51 +1888,51 @@ void Object::ForceValuesUpdateAtIndex(uint32 i)
|
||||
|
||||
namespace acore
|
||||
{
|
||||
class MonsterChatBuilder
|
||||
class MonsterChatBuilder
|
||||
{
|
||||
public:
|
||||
MonsterChatBuilder(WorldObject const* obj, ChatMsg msgtype, int32 textId, uint32 language, WorldObject const* target)
|
||||
: i_object(obj), i_msgtype(msgtype), i_textId(textId), i_language(Language(language)), i_target(target) { }
|
||||
void operator()(WorldPacket& data, LocaleConstant loc_idx)
|
||||
public:
|
||||
MonsterChatBuilder(WorldObject const* obj, ChatMsg msgtype, int32 textId, uint32 language, WorldObject const* target)
|
||||
: i_object(obj), i_msgtype(msgtype), i_textId(textId), i_language(Language(language)), i_target(target) { }
|
||||
void operator()(WorldPacket& data, LocaleConstant loc_idx)
|
||||
{
|
||||
if (BroadcastText const* broadcastText = sObjectMgr->GetBroadcastText(i_textId))
|
||||
{
|
||||
if (BroadcastText const* broadcastText = sObjectMgr->GetBroadcastText(i_textId))
|
||||
{
|
||||
uint8 gender = GENDER_MALE;
|
||||
if (Unit const* unit = i_object->ToUnit())
|
||||
gender = unit->getGender();
|
||||
uint8 gender = GENDER_MALE;
|
||||
if (Unit const* unit = i_object->ToUnit())
|
||||
gender = unit->getGender();
|
||||
|
||||
std::string text = broadcastText->GetText(loc_idx, gender);
|
||||
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, text, 0, "", loc_idx);
|
||||
}
|
||||
else
|
||||
sLog->outError("MonsterChatBuilder: `broadcast_text` id %i missing", i_textId);
|
||||
std::string text = broadcastText->GetText(loc_idx, gender);
|
||||
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, text, 0, "", loc_idx);
|
||||
}
|
||||
else
|
||||
sLog->outError("MonsterChatBuilder: `broadcast_text` id %i missing", i_textId);
|
||||
}
|
||||
|
||||
private:
|
||||
WorldObject const* i_object;
|
||||
ChatMsg i_msgtype;
|
||||
int32 i_textId;
|
||||
Language i_language;
|
||||
WorldObject const* i_target;
|
||||
private:
|
||||
WorldObject const* i_object;
|
||||
ChatMsg i_msgtype;
|
||||
int32 i_textId;
|
||||
Language i_language;
|
||||
WorldObject const* i_target;
|
||||
};
|
||||
|
||||
class MonsterCustomChatBuilder
|
||||
{
|
||||
public:
|
||||
MonsterCustomChatBuilder(WorldObject const* obj, ChatMsg msgtype, const char* text, uint32 language, WorldObject const* target)
|
||||
: i_object(obj), i_msgtype(msgtype), i_text(text), i_language(Language(language)), i_target(target)
|
||||
{}
|
||||
void operator()(WorldPacket& data, LocaleConstant loc_idx)
|
||||
{
|
||||
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, i_text, 0, "", loc_idx);
|
||||
}
|
||||
public:
|
||||
MonsterCustomChatBuilder(WorldObject const* obj, ChatMsg msgtype, const char* text, uint32 language, WorldObject const* target)
|
||||
: i_object(obj), i_msgtype(msgtype), i_text(text), i_language(Language(language)), i_target(target)
|
||||
{}
|
||||
void operator()(WorldPacket& data, LocaleConstant loc_idx)
|
||||
{
|
||||
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, i_text, 0, "", loc_idx);
|
||||
}
|
||||
|
||||
private:
|
||||
WorldObject const* i_object;
|
||||
ChatMsg i_msgtype;
|
||||
const char* i_text;
|
||||
Language i_language;
|
||||
WorldObject const* i_target;
|
||||
private:
|
||||
WorldObject const* i_object;
|
||||
ChatMsg i_msgtype;
|
||||
const char* i_text;
|
||||
Language i_language;
|
||||
WorldObject const* i_target;
|
||||
};
|
||||
} // namespace acore
|
||||
|
||||
@@ -2142,33 +2151,33 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
|
||||
case SUMMON_CATEGORY_WILD:
|
||||
case SUMMON_CATEGORY_ALLY:
|
||||
case SUMMON_CATEGORY_UNK:
|
||||
{
|
||||
switch (properties->Type)
|
||||
{
|
||||
case SUMMON_TYPE_MINION:
|
||||
case SUMMON_TYPE_GUARDIAN:
|
||||
case SUMMON_TYPE_GUARDIAN2:
|
||||
mask = UNIT_MASK_GUARDIAN;
|
||||
break;
|
||||
case SUMMON_TYPE_TOTEM:
|
||||
case SUMMON_TYPE_LIGHTWELL:
|
||||
mask = UNIT_MASK_TOTEM;
|
||||
break;
|
||||
case SUMMON_TYPE_VEHICLE:
|
||||
case SUMMON_TYPE_VEHICLE2:
|
||||
mask = UNIT_MASK_SUMMON;
|
||||
break;
|
||||
case SUMMON_TYPE_MINIPET:
|
||||
case SUMMON_TYPE_JEEVES:
|
||||
mask = UNIT_MASK_MINION;
|
||||
break;
|
||||
default:
|
||||
if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
|
||||
mask = UNIT_MASK_GUARDIAN;
|
||||
switch (properties->Type)
|
||||
{
|
||||
case SUMMON_TYPE_MINION:
|
||||
case SUMMON_TYPE_GUARDIAN:
|
||||
case SUMMON_TYPE_GUARDIAN2:
|
||||
mask = UNIT_MASK_GUARDIAN;
|
||||
break;
|
||||
case SUMMON_TYPE_TOTEM:
|
||||
case SUMMON_TYPE_LIGHTWELL:
|
||||
mask = UNIT_MASK_TOTEM;
|
||||
break;
|
||||
case SUMMON_TYPE_VEHICLE:
|
||||
case SUMMON_TYPE_VEHICLE2:
|
||||
mask = UNIT_MASK_SUMMON;
|
||||
break;
|
||||
case SUMMON_TYPE_MINIPET:
|
||||
case SUMMON_TYPE_JEEVES:
|
||||
mask = UNIT_MASK_MINION;
|
||||
break;
|
||||
default:
|
||||
if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
|
||||
mask = UNIT_MASK_GUARDIAN;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
@@ -2282,7 +2291,7 @@ void WorldObject::SetZoneScript()
|
||||
}
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/, SummonPropertiesEntry const *properties) const
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position& pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/, SummonPropertiesEntry const* properties) const
|
||||
{
|
||||
if (Map* map = FindMap())
|
||||
{
|
||||
@@ -2331,7 +2340,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
|
||||
return go;
|
||||
}
|
||||
|
||||
Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint32 duration, bool setLevel, CreatureAI* (*GetAI)(Creature*))
|
||||
Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint32 duration, bool setLevel, CreatureAI * (*GetAI)(Creature*))
|
||||
{
|
||||
TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
|
||||
Creature* summon = SummonCreature(WORLD_TRIGGER, x, y, z, ang, summonType, duration);
|
||||
@@ -2512,7 +2521,7 @@ namespace acore
|
||||
|
||||
//===================================================================================================
|
||||
|
||||
void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle) const
|
||||
void WorldObject::GetNearPoint2D(float& x, float& y, float distance2d, float absAngle) const
|
||||
{
|
||||
x = GetPositionX() + (GetObjectSize() + distance2d) * cos(absAngle);
|
||||
y = GetPositionY() + (GetObjectSize() + distance2d) * sin(absAngle);
|
||||
@@ -2521,9 +2530,9 @@ void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float abs
|
||||
acore::NormalizeMapCoord(y);
|
||||
}
|
||||
|
||||
void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle, float controlZ) const
|
||||
void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, float& z, float searcher_size, float distance2d, float absAngle, float controlZ) const
|
||||
{
|
||||
GetNearPoint2D(x, y, distance2d+searcher_size, absAngle);
|
||||
GetNearPoint2D(x, y, distance2d + searcher_size, absAngle);
|
||||
z = GetPositionZ();
|
||||
if (searcher)
|
||||
searcher->UpdateAllowedPositionZ(x, y, z);
|
||||
@@ -2568,12 +2577,12 @@ void WorldObject::GetVoidClosePoint(float& x, float& y, float& z, float size, fl
|
||||
GetNearPoint(nullptr, x, y, z, size, distance2d, GetOrientation() + relAngle, controlZ);
|
||||
}
|
||||
|
||||
bool WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float distance2d, float angle, const WorldObject* forWho, bool force) const
|
||||
bool WorldObject::GetClosePoint(float& x, float& y, float& z, float size, float distance2d, float angle, const WorldObject* forWho, bool force) const
|
||||
{
|
||||
// angle calculated from current orientation
|
||||
GetNearPoint(forWho, x, y, z, size, distance2d, GetOrientation() + angle);
|
||||
|
||||
if (fabs(this->GetPositionZ()-z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
if (fabs(this->GetPositionZ() - z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
{
|
||||
x = this->GetPositionX();
|
||||
y = this->GetPositionY();
|
||||
@@ -2583,7 +2592,7 @@ bool WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float
|
||||
u->UpdateAllowedPositionZ(x, y, z);
|
||||
}
|
||||
float maxDist = GetObjectSize() + size + distance2d + 1.0f;
|
||||
if (GetExactDistSq(x, y, z) >= maxDist*maxDist)
|
||||
if (GetExactDistSq(x, y, z) >= maxDist * maxDist)
|
||||
{
|
||||
if (force)
|
||||
{
|
||||
@@ -2597,12 +2606,12 @@ bool WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float
|
||||
return true;
|
||||
}
|
||||
|
||||
void WorldObject::GetContactPoint(const WorldObject* obj, float &x, float &y, float &z, float distance2d) const
|
||||
void WorldObject::GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d) const
|
||||
{
|
||||
// angle to face `obj` to `this` using distance includes size of `obj`
|
||||
GetNearPoint(obj, x, y, z, obj->GetObjectSize(), distance2d, GetAngle(obj));
|
||||
|
||||
if (fabs(this->GetPositionZ()-z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
if (fabs(this->GetPositionZ() - z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
{
|
||||
x = this->GetPositionX();
|
||||
y = this->GetPositionY();
|
||||
@@ -2612,12 +2621,12 @@ void WorldObject::GetContactPoint(const WorldObject* obj, float &x, float &y, fl
|
||||
}
|
||||
|
||||
|
||||
void WorldObject::GetChargeContactPoint(const WorldObject* obj, float &x, float &y, float &z, float distance2d) const
|
||||
void WorldObject::GetChargeContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d) const
|
||||
{
|
||||
// angle to face `obj` to `this` using distance includes size of `obj`
|
||||
GetNearPoint(obj, x, y, z, obj->GetObjectSize(), distance2d, GetAngle(obj));
|
||||
|
||||
if (fabs(this->GetPositionZ()-z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
if (fabs(this->GetPositionZ() - z) > 3.0f || !IsWithinLOS(x, y, z))
|
||||
{
|
||||
x = this->GetPositionX();
|
||||
y = this->GetPositionY();
|
||||
@@ -2626,7 +2635,7 @@ void WorldObject::GetChargeContactPoint(const WorldObject* obj, float &x, float
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObject::MovePosition(Position &pos, float dist, float angle)
|
||||
void WorldObject::MovePosition(Position& pos, float dist, float angle)
|
||||
{
|
||||
angle += m_orientation;
|
||||
float destx, desty, destz, ground, floor;
|
||||
@@ -2644,7 +2653,7 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle)
|
||||
floor = GetMap()->GetHeight(GetPhaseMask(), destx, desty, pos.m_positionZ, true);
|
||||
destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
|
||||
|
||||
float step = dist/10.0f;
|
||||
float step = dist / 10.0f;
|
||||
|
||||
for (uint8 j = 0; j < 10; ++j)
|
||||
{
|
||||
@@ -2670,14 +2679,14 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle)
|
||||
pos.m_orientation = m_orientation;
|
||||
}
|
||||
|
||||
void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float angle)
|
||||
void WorldObject::MovePositionToFirstCollision(Position& pos, float dist, float angle)
|
||||
{
|
||||
angle += m_orientation;
|
||||
float destx, desty, destz;
|
||||
destx = pos.m_positionX + dist * cos(angle);
|
||||
desty = pos.m_positionY + dist * sin(angle);
|
||||
destz = pos.m_positionZ;
|
||||
if (isType(TYPEMASK_UNIT|TYPEMASK_PLAYER) && !ToUnit()->IsInWater())
|
||||
if (isType(TYPEMASK_UNIT | TYPEMASK_PLAYER) && !ToUnit()->IsInWater())
|
||||
destz += 2.0f;
|
||||
|
||||
// Prevent invalid coordinates here, position is unchanged
|
||||
@@ -2700,7 +2709,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
else
|
||||
UpdateAllowedPositionZ(destx, desty, destz);
|
||||
|
||||
bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.m_positionX, pos.m_positionY, pos.m_positionZ+selfAddition, destx, desty, destz+0.5f, destx, desty, destz, -0.5f);
|
||||
bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + selfAddition, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
|
||||
|
||||
// collision occured
|
||||
if (col)
|
||||
@@ -2712,11 +2721,11 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
desty -= CONTACT_DISTANCE * sin(angle);
|
||||
}
|
||||
|
||||
newDist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
|
||||
newDist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
|
||||
}
|
||||
|
||||
// check dynamic collision
|
||||
col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ+selfAddition, destx, desty, destz+0.5f, destx, desty, destz, -0.5f);
|
||||
col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + selfAddition, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
|
||||
|
||||
// Collided with a gameobject
|
||||
if (col)
|
||||
@@ -2727,7 +2736,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
destx -= CONTACT_DISTANCE * cos(angle);
|
||||
desty -= CONTACT_DISTANCE * sin(angle);
|
||||
}
|
||||
newDist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
|
||||
newDist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
|
||||
}
|
||||
|
||||
float step = newDist / 10.0f;
|
||||
@@ -2771,7 +2780,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
|
||||
pos.m_orientation = m_orientation;
|
||||
}
|
||||
|
||||
void WorldObject::MovePositionToFirstCollisionForTotem(Position &pos, float dist, float angle, bool forGameObject)
|
||||
void WorldObject::MovePositionToFirstCollisionForTotem(Position& pos, float dist, float angle, bool forGameObject)
|
||||
{
|
||||
angle += m_orientation;
|
||||
float destx, desty, destz, ground, floor;
|
||||
@@ -2799,11 +2808,11 @@ void WorldObject::MovePositionToFirstCollisionForTotem(Position &pos, float dist
|
||||
desty -= CONTACT_DISTANCE * sin(angle);
|
||||
}
|
||||
|
||||
dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
|
||||
dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
|
||||
}
|
||||
|
||||
// check dynamic collision
|
||||
col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ+0.5f, destx, desty, destz+0.5f, destx, desty, destz, -0.5f);
|
||||
col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + 0.5f, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
|
||||
|
||||
// Collided with a gameobject
|
||||
if (col)
|
||||
@@ -2814,7 +2823,7 @@ void WorldObject::MovePositionToFirstCollisionForTotem(Position &pos, float dist
|
||||
destx -= CONTACT_DISTANCE * cos(angle);
|
||||
desty -= CONTACT_DISTANCE * sin(angle);
|
||||
}
|
||||
dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
|
||||
dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
|
||||
}
|
||||
|
||||
float prevdx = destx, prevdy = desty, prevdz = destz;
|
||||
@@ -2829,7 +2838,7 @@ void WorldObject::MovePositionToFirstCollisionForTotem(Position &pos, float dist
|
||||
if (forGameObject)
|
||||
prevdz = destz;
|
||||
|
||||
float step = dist/10.0f;
|
||||
float step = dist / 10.0f;
|
||||
for (uint8 j = 0; j < 10; ++j)
|
||||
{
|
||||
// do not allow too big z changes
|
||||
@@ -2875,7 +2884,7 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
|
||||
|
||||
void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= NULL*/)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4+8);
|
||||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
|
||||
data << uint32(sound_id);
|
||||
data << uint64(GetGUID());
|
||||
if (target)
|
||||
@@ -2915,9 +2924,9 @@ void WorldObject::DestroyForNearbyPlayers()
|
||||
return;
|
||||
|
||||
std::list<Player*> targets;
|
||||
acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange()+VISIBILITY_COMPENSATION, false);
|
||||
acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange() + VISIBILITY_COMPENSATION, false);
|
||||
acore::PlayerListSearcherWithSharedVision<acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
|
||||
VisitNearbyWorldObject(GetVisibilityRange()+VISIBILITY_COMPENSATION, searcher);
|
||||
VisitNearbyWorldObject(GetVisibilityRange() + VISIBILITY_COMPENSATION, searcher);
|
||||
for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
||||
{
|
||||
Player* player = (*iter);
|
||||
@@ -2940,7 +2949,7 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/, bool /*fromUpdate*/)
|
||||
{
|
||||
//updates object's visibility for nearby players
|
||||
acore::VisibleChangesNotifier notifier(*this);
|
||||
VisitNearbyWorldObject(GetVisibilityRange()+VISIBILITY_COMPENSATION, notifier);
|
||||
VisitNearbyWorldObject(GetVisibilityRange() + VISIBILITY_COMPENSATION, notifier);
|
||||
}
|
||||
|
||||
void WorldObject::AddToNotify(uint16 f)
|
||||
@@ -2953,12 +2962,12 @@ void WorldObject::AddToNotify(uint16 f)
|
||||
uint32 EVENT_VISIBILITY_DELAY = u->FindMap() ? DynamicVisibilityMgr::GetVisibilityNotifyDelay(u->FindMap()->GetEntry()->map_type) : 1000;
|
||||
|
||||
uint32 diff = getMSTimeDiff(u->m_last_notify_mstime, World::GetGameTimeMS());
|
||||
if (diff >= EVENT_VISIBILITY_DELAY/2)
|
||||
if (diff >= EVENT_VISIBILITY_DELAY / 2)
|
||||
EVENT_VISIBILITY_DELAY /= 2;
|
||||
else
|
||||
EVENT_VISIBILITY_DELAY -= diff;
|
||||
u->m_delayed_unit_relocation_timer = EVENT_VISIBILITY_DELAY;
|
||||
u->m_last_notify_mstime = World::GetGameTimeMS()+EVENT_VISIBILITY_DELAY-1;
|
||||
u->m_last_notify_mstime = World::GetGameTimeMS() + EVENT_VISIBILITY_DELAY - 1;
|
||||
}
|
||||
else if (f & NOTIFY_AI_RELOCATION)
|
||||
{
|
||||
@@ -2974,11 +2983,11 @@ struct WorldObjectChangeAccumulator
|
||||
UpdateDataMapType& i_updateDatas;
|
||||
UpdatePlayerSet& i_playerSet;
|
||||
WorldObject& i_object;
|
||||
WorldObjectChangeAccumulator(WorldObject &obj, UpdateDataMapType &d, UpdatePlayerSet &p) : i_updateDatas(d), i_playerSet(p), i_object(obj)
|
||||
WorldObjectChangeAccumulator(WorldObject& obj, UpdateDataMapType& d, UpdatePlayerSet& p) : i_updateDatas(d), i_playerSet(p), i_object(obj)
|
||||
{
|
||||
i_playerSet.clear();
|
||||
}
|
||||
void Visit(PlayerMapType &m)
|
||||
void Visit(PlayerMapType& m)
|
||||
{
|
||||
Player* source = nullptr;
|
||||
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
@@ -2996,7 +3005,7 @@ struct WorldObjectChangeAccumulator
|
||||
}
|
||||
}
|
||||
|
||||
void Visit(CreatureMapType &m)
|
||||
void Visit(CreatureMapType& m)
|
||||
{
|
||||
Creature* source = nullptr;
|
||||
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
@@ -3011,7 +3020,7 @@ struct WorldObjectChangeAccumulator
|
||||
}
|
||||
}
|
||||
|
||||
void Visit(DynamicObjectMapType &m)
|
||||
void Visit(DynamicObjectMapType& m)
|
||||
{
|
||||
DynamicObject* source = nullptr;
|
||||
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
@@ -3039,7 +3048,7 @@ struct WorldObjectChangeAccumulator
|
||||
}
|
||||
}
|
||||
|
||||
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
|
||||
template<class SKIP> void Visit(GridRefManager<SKIP>&) {}
|
||||
};
|
||||
|
||||
void WorldObject::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& player_set)
|
||||
@@ -3051,12 +3060,12 @@ void WorldObject::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& play
|
||||
TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
|
||||
Map& map = *GetMap();
|
||||
//we must build packets for all visible players
|
||||
cell.Visit(p, player_notifier, map, *this, GetVisibilityRange()+VISIBILITY_COMPENSATION);
|
||||
cell.Visit(p, player_notifier, map, *this, GetVisibilityRange() + VISIBILITY_COMPENSATION);
|
||||
|
||||
ClearUpdateMask(false);
|
||||
}
|
||||
|
||||
void WorldObject::GetCreaturesWithEntryInRange(std::list<Creature*> &creatureList, float radius, uint32 entry)
|
||||
void WorldObject::GetCreaturesWithEntryInRange(std::list<Creature*>& creatureList, float radius, uint32 entry)
|
||||
{
|
||||
CellCoord pair(acore::ComputeCellCoord(this->GetPositionX(), this->GetPositionY()));
|
||||
Cell cell(pair);
|
||||
|
||||
Reference in New Issue
Block a user