mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
Reduced number of cells (doubled max visibility distance).
Use 2D distance for visibility checks.
This commit is contained in:
parent
9254ca19e6
commit
d00a453863
9 changed files with 28 additions and 24 deletions
|
|
@ -209,5 +209,5 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
|
||||||
|
|
||||||
bool Corpse::isVisibleForInState(Player const* u, bool inVisibleList) const
|
bool Corpse::isVisibleForInState(Player const* u, bool inVisibleList) const
|
||||||
{
|
{
|
||||||
return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f));
|
return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,5 +148,5 @@ void DynamicObject::Delay(int32 delaytime)
|
||||||
|
|
||||||
bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const
|
bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const
|
||||||
{
|
{
|
||||||
return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f));
|
return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -723,7 +723,7 @@ bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const
|
||||||
|
|
||||||
// check distance
|
// check distance
|
||||||
return IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject() +
|
return IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject() +
|
||||||
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f) );
|
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameObject::Respawn()
|
void GameObject::Respawn()
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,10 @@ class Player;
|
||||||
#define MIN_GRID_DELAY MINUTE*1000
|
#define MIN_GRID_DELAY MINUTE*1000
|
||||||
#define MIN_MAP_UPDATE_DELAY 50
|
#define MIN_MAP_UPDATE_DELAY 50
|
||||||
|
|
||||||
#define MAX_NUMBER_OF_CELLS 8
|
#define MAX_NUMBER_OF_CELLS 4
|
||||||
#define SIZE_OF_GRID_CELL (SIZE_OF_GRIDS/MAX_NUMBER_OF_CELLS)
|
#define SIZE_OF_GRID_CELL (SIZE_OF_GRIDS/MAX_NUMBER_OF_CELLS)
|
||||||
|
|
||||||
#define CENTER_GRID_CELL_ID 256
|
#define CENTER_GRID_CELL_ID 128
|
||||||
#define CENTER_GRID_CELL_OFFSET (SIZE_OF_GRID_CELL/2)
|
#define CENTER_GRID_CELL_OFFSET (SIZE_OF_GRID_CELL/2)
|
||||||
|
|
||||||
#define TOTAL_NUMBER_OF_CELLS_PER_MAP (MAX_NUMBER_OF_GRIDS*MAX_NUMBER_OF_CELLS)
|
#define TOTAL_NUMBER_OF_CELLS_PER_MAP (MAX_NUMBER_OF_GRIDS*MAX_NUMBER_OF_CELLS)
|
||||||
|
|
|
||||||
|
|
@ -1027,14 +1027,18 @@ float WorldObject::GetDistanceZ(const WorldObject* obj) const
|
||||||
return ( dist > 0 ? dist : 0);
|
return ( dist > 0 ? dist : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldObject::IsWithinDistInMap(const WorldObject* obj, const float dist2compare) const
|
bool WorldObject::IsWithinDistInMap(const WorldObject* obj, const float dist2compare, const bool is3D) const
|
||||||
{
|
{
|
||||||
if (!obj || !IsInMap(obj)) return false;
|
if (!obj || !IsInMap(obj)) return false;
|
||||||
|
|
||||||
float dx = GetPositionX() - obj->GetPositionX();
|
float dx = GetPositionX() - obj->GetPositionX();
|
||||||
float dy = GetPositionY() - obj->GetPositionY();
|
float dy = GetPositionY() - obj->GetPositionY();
|
||||||
|
float distsq = dx*dx + dy*dy;
|
||||||
|
if(is3D)
|
||||||
|
{
|
||||||
float dz = GetPositionZ() - obj->GetPositionZ();
|
float dz = GetPositionZ() - obj->GetPositionZ();
|
||||||
float distsq = dx*dx + dy*dy + dz*dz;
|
distsq += dz*dz;
|
||||||
|
}
|
||||||
float sizefactor = GetObjectSize() + obj->GetObjectSize();
|
float sizefactor = GetObjectSize() + obj->GetObjectSize();
|
||||||
float maxdist = dist2compare + sizefactor;
|
float maxdist = dist2compare + sizefactor;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
|
||||||
float GetDistance2d(const float x, const float y) const;
|
float GetDistance2d(const float x, const float y) const;
|
||||||
float GetDistanceZ(const WorldObject* obj) const;
|
float GetDistanceZ(const WorldObject* obj) const;
|
||||||
bool IsInMap(const WorldObject* obj) const { return GetMapId()==obj->GetMapId() && GetInstanceId()==obj->GetInstanceId(); }
|
bool IsInMap(const WorldObject* obj) const { return GetMapId()==obj->GetMapId() && GetInstanceId()==obj->GetInstanceId(); }
|
||||||
bool IsWithinDistInMap(const WorldObject* obj, const float dist2compare) const;
|
bool IsWithinDistInMap(const WorldObject* obj, const float dist2compare, const bool is3D = true) const;
|
||||||
bool IsWithinLOS(const float x, const float y, const float z ) const;
|
bool IsWithinLOS(const float x, const float y, const float z ) const;
|
||||||
bool IsWithinLOSInMap(const WorldObject* obj) const;
|
bool IsWithinLOSInMap(const WorldObject* obj) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8500,7 +8500,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
|
||||||
return gain;
|
return gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList) const
|
bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList, bool is3dDistance) const
|
||||||
{
|
{
|
||||||
if(!u)
|
if(!u)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -8551,12 +8551,12 @@ bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList)
|
||||||
if(u->isInFlight()) // what see player in flight
|
if(u->isInFlight()) // what see player in flight
|
||||||
{
|
{
|
||||||
// use object grey distance for all (only see objects any way)
|
// use object grey distance for all (only see objects any way)
|
||||||
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f)))
|
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if(!isAlive()) // distance for show body
|
else if(!isAlive()) // distance for show body
|
||||||
{
|
{
|
||||||
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f)))
|
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if(GetTypeId()==TYPEID_PLAYER) // distance for show player
|
else if(GetTypeId()==TYPEID_PLAYER) // distance for show player
|
||||||
|
|
@ -8564,26 +8564,26 @@ bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList)
|
||||||
if(u->GetTypeId()==TYPEID_PLAYER)
|
if(u->GetTypeId()==TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
// Players far than max visible distance for player or not in our map are not visible too
|
// Players far than max visible distance for player or not in our map are not visible too
|
||||||
if (!at_same_transport && !IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))
|
if (!at_same_transport && !IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Units far than max visible distance for creature or not in our map are not visible too
|
// Units far than max visible distance for creature or not in our map are not visible too
|
||||||
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))
|
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GetCharmerOrOwnerGUID()) // distance for show pet/charmed
|
else if(GetCharmerOrOwnerGUID()) // distance for show pet/charmed
|
||||||
{
|
{
|
||||||
// Pet/charmed far than max visible distance for player or not in our map are not visible too
|
// Pet/charmed far than max visible distance for player or not in our map are not visible too
|
||||||
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))
|
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else // distance for show creature
|
else // distance for show creature
|
||||||
{
|
{
|
||||||
// Units far than max visible distance for creature or not in our map are not visible too
|
// Units far than max visible distance for creature or not in our map are not visible too
|
||||||
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))
|
if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9391,7 +9391,7 @@ Unit* Unit::GetUnit(WorldObject& object, uint64 guid)
|
||||||
|
|
||||||
bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const
|
bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const
|
||||||
{
|
{
|
||||||
return isVisibleForOrDetect(u,false,inVisibleList);
|
return isVisibleForOrDetect(u, false, inVisibleList, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Unit::GetCreatureType() const
|
uint32 Unit::GetCreatureType() const
|
||||||
|
|
|
||||||
|
|
@ -1102,7 +1102,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
void SetVisibility(UnitVisibility x);
|
void SetVisibility(UnitVisibility x);
|
||||||
|
|
||||||
// common function for visibility checks for player/creatures with detection code
|
// common function for visibility checks for player/creatures with detection code
|
||||||
bool isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList = false) const;
|
bool isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
|
||||||
bool canDetectInvisibilityOf(Unit const* u) const;
|
bool canDetectInvisibilityOf(Unit const* u) const;
|
||||||
|
|
||||||
// virtual functions for all world objects types
|
// virtual functions for all world objects types
|
||||||
|
|
|
||||||
|
|
@ -863,9 +863,9 @@ GM.StartLevel = 1
|
||||||
# Visibility.Distance.Creature
|
# Visibility.Distance.Creature
|
||||||
# Visibility.Distance.Player
|
# Visibility.Distance.Player
|
||||||
# Visibility distance for different in game object
|
# Visibility distance for different in game object
|
||||||
# Max limited by active player zone: ~ 166
|
# Max limited by active player zone: ~ 333
|
||||||
# Min limit dependent from objects
|
# Min limit dependent from objects
|
||||||
# Default: 66 (cell size)
|
# Default: 132 (cell size)
|
||||||
# Min limit is max aggro radius (45) * Rate.Creature.Aggro
|
# Min limit is max aggro radius (45) * Rate.Creature.Aggro
|
||||||
#
|
#
|
||||||
# Visibility.Distance.Object
|
# Visibility.Distance.Object
|
||||||
|
|
@ -891,10 +891,10 @@ GM.StartLevel = 1
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
|
|
||||||
Visibility.GroupMode = 0
|
Visibility.GroupMode = 0
|
||||||
Visibility.Distance.Creature = 66
|
Visibility.Distance.Creature = 132
|
||||||
Visibility.Distance.Player = 66
|
Visibility.Distance.Player = 132
|
||||||
Visibility.Distance.Object = 66
|
Visibility.Distance.Object = 132
|
||||||
Visibility.Distance.InFlight = 66
|
Visibility.Distance.InFlight = 132
|
||||||
Visibility.Distance.Grey.Unit = 1
|
Visibility.Distance.Grey.Unit = 1
|
||||||
Visibility.Distance.Grey.Object = 10
|
Visibility.Distance.Grey.Object = 10
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue