diff --git a/config/world.ini.default b/config/world.ini.default index ec461c19..4dacbc65 100644 --- a/config/world.ini.default +++ b/config/world.ini.default @@ -10,6 +10,7 @@ HotSwap = true ListenIp = 0.0.0.0 ListenPort = 54992 DisconnectTimeout = 20 +InRangeDistance = 100.0 [General] ; Sent on login - each line must be shorter than 307 characters, split lines with ';' diff --git a/src/common/Config/ConfigDef.h b/src/common/Config/ConfigDef.h index 3aca9cff..4d99591f 100644 --- a/src/common/Config/ConfigDef.h +++ b/src/common/Config/ConfigDef.h @@ -44,6 +44,8 @@ namespace Sapphire::Common::Config uint16_t listenPort; uint16_t disconnectTimeout; + + float inRangeDistance; } network; struct Housing diff --git a/src/world/Manager/TerritoryMgr.cpp b/src/world/Manager/TerritoryMgr.cpp index 2c2edb83..da8ff1ac 100644 --- a/src/world/Manager/TerritoryMgr.cpp +++ b/src/world/Manager/TerritoryMgr.cpp @@ -2,6 +2,8 @@ #include #include +#include "ServerMgr.h" + #include #include "Actor/Player.h" @@ -59,6 +61,10 @@ bool Sapphire::World::Manager::TerritoryMgr::init() return false; } + auto& cfg = framework()->get< World::ServerMgr >()->getConfig(); + + m_inRangeDistance = cfg.network.inRangeDistance; + return true; } @@ -584,5 +590,9 @@ void Sapphire::World::Manager::TerritoryMgr::disableCurrentFestival() setCurrentFestival( 0 ); } +float Sapphire::World::Manager::TerritoryMgr::getInRangeDistance() const +{ + return m_inRangeDistance; +} diff --git a/src/world/Manager/TerritoryMgr.h b/src/world/Manager/TerritoryMgr.h index 1905b7f6..1c8846be 100644 --- a/src/world/Manager/TerritoryMgr.h +++ b/src/world/Manager/TerritoryMgr.h @@ -155,6 +155,8 @@ namespace Sapphire::World::Manager */ const std::pair< uint16_t, uint16_t >& getCurrentFestival() const; + float getInRangeDistance() const; + private: using TerritoryTypeDetailCache = std::unordered_map< uint16_t, Data::TerritoryTypePtr >; using InstanceIdToZonePtrMap = std::unordered_map< uint32_t, ZonePtr >; @@ -202,6 +204,9 @@ namespace Sapphire::World::Manager /*! current festival(s) to set for public zones from festival.exd */ std::pair< uint16_t, uint16_t > m_currentFestival; + /*! Max distance at which actors in range of a player are sent */ + float m_inRangeDistance; + public: /*! returns a list of instanceContent InstanceIds currently active */ InstanceIdList getInstanceContentIdList( uint16_t instanceContentId ) const; diff --git a/src/world/ServerMgr.cpp b/src/world/ServerMgr.cpp index 7149356d..e5b0367f 100644 --- a/src/world/ServerMgr.cpp +++ b/src/world/ServerMgr.cpp @@ -101,6 +101,7 @@ bool Sapphire::World::ServerMgr::loadSettings( int32_t argc, char* argv[] ) m_config.network.disconnectTimeout = pConfig->getValue< uint16_t >( "Network", "DisconnectTimeout", 20 ); m_config.network.listenIp = pConfig->getValue< std::string >( "Network", "ListenIp", "0.0.0.0" ); m_config.network.listenPort = pConfig->getValue< uint16_t >( "Network", "ListenPort", 54992 ); + m_config.network.inRangeDistance = pConfig->getValue< float >( "Network", "InRangeDistance", 100.f ); m_config.motd = pConfig->getValue< std::string >( "General", "MotD", "" ); diff --git a/src/world/Territory/Zone.cpp b/src/world/Territory/Zone.cpp index f691e25a..d0472427 100644 --- a/src/world/Territory/Zone.cpp +++ b/src/world/Territory/Zone.cpp @@ -645,7 +645,7 @@ void Sapphire::Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ) auto iter = pCell->m_actors.begin(); - float fRange = 100.0f; + float fRange = pTeriMgr->getInRangeDistance(); int32_t count = 0; while( iter != pCell->m_actors.end() ) {