Made the viewdistance settable by users and default in settings.ini. The default is 9.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@326 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -174,20 +174,10 @@ bool cServer::InitServer( int a_Port )
|
||||
m_bIsConnected = true;
|
||||
|
||||
cIniFile IniFile("settings.ini");
|
||||
if( IniFile.ReadFile() )
|
||||
if (IniFile.ReadFile())
|
||||
{
|
||||
g_bWaterPhysics = IniFile.GetValueB("Physics", "Water", false );
|
||||
|
||||
/* Replaced below with 1.0.0 compatible ServerID generation
|
||||
|
||||
std::string ServerID = IniFile.GetValue("Server", "ServerID");
|
||||
if( ServerID.empty() )
|
||||
{
|
||||
ServerID = "MCServer";
|
||||
IniFile.SetValue("Server", "ServerID", ServerID, true );
|
||||
IniFile.WriteFile();
|
||||
}
|
||||
*/
|
||||
m_pState->ServerID = "-";
|
||||
if (IniFile.GetValueB("Authentication", "Authenticate"))
|
||||
{
|
||||
@@ -201,6 +191,23 @@ bool cServer::InitServer( int a_Port )
|
||||
ServerID.resize(16, '0');
|
||||
m_pState->ServerID = ServerID;
|
||||
}
|
||||
|
||||
m_ClientViewDistance = IniFile.GetValueI("Server", "DefaultViewDistance", -1);
|
||||
if (m_ClientViewDistance == -1)
|
||||
{
|
||||
m_ClientViewDistance = cClientHandle::DEFAULT_VIEW_DISTANCE;
|
||||
LOG("[Server].DefaultViewDistance not set, using a default of %d", m_ClientViewDistance);
|
||||
}
|
||||
if (m_ClientViewDistance < cClientHandle::MIN_VIEW_DISTANCE)
|
||||
{
|
||||
m_ClientViewDistance = cClientHandle::MIN_VIEW_DISTANCE;
|
||||
LOGINFO("Setting default viewdistance to the minimum of %d", m_ClientViewDistance);
|
||||
}
|
||||
if (m_ClientViewDistance > cClientHandle::MAX_VIEW_DISTANCE)
|
||||
{
|
||||
m_ClientViewDistance = cClientHandle::MAX_VIEW_DISTANCE;
|
||||
LOGINFO("Setting default viewdistance to the maximum of %d", m_ClientViewDistance);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -273,7 +280,7 @@ void cServer::StartListenClient()
|
||||
|
||||
LOG("Client \"%s\" connected!", ClientIP.c_str());
|
||||
|
||||
cClientHandle *NewHandle = new cClientHandle(SClient);
|
||||
cClientHandle *NewHandle = new cClientHandle(SClient, m_ClientViewDistance);
|
||||
if (!m_SocketThreads.AddClient(&(NewHandle->GetSocket()), NewHandle))
|
||||
{
|
||||
// For some reason SocketThreads have rejected the handle, clean it up
|
||||
@@ -398,9 +405,11 @@ bool from_string(
|
||||
|
||||
bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd )
|
||||
{
|
||||
cPluginManager* PM = cRoot::Get()->GetPluginManager();
|
||||
cPluginManager* PM = cRoot::Get()->GetPluginManager();
|
||||
if( PM->CallHook( cPluginManager::E_PLUGIN_CHAT, 2, a_Cmd, a_Client.GetPlayer() ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Command( a_Cmd );
|
||||
if( Command.length() <= 0 ) return false;
|
||||
@@ -417,6 +426,18 @@ bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd )
|
||||
a_Client.Send( cPacket_Chat(cChatColor::Green + Pos));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (split[0].compare("/viewdistance") == 0)
|
||||
{
|
||||
if (split.size() != 2)
|
||||
{
|
||||
a_Client.Send(cPacket_Chat(cChatColor::Green + "Invalid syntax, expected 1 parameter, the numebr of chunks to stream"));
|
||||
return false;
|
||||
}
|
||||
int dist = atol(split[1].c_str());
|
||||
a_Client.SetViewDistance(dist);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user