summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/Authenticator.cpp36
-rw-r--r--source/ClientHandle.cpp4
-rw-r--r--source/LeakFinder.cpp4
-rw-r--r--source/MobSpawner.cpp6
-rw-r--r--source/PluginManager.cpp37
-rw-r--r--source/PluginManager.h7
-rw-r--r--source/Root.cpp17
-rw-r--r--source/Server.cpp9
-rw-r--r--source/Server.h4
-rw-r--r--source/WebAdmin.cpp15
-rw-r--r--source/World.cpp6
11 files changed, 80 insertions, 65 deletions
diff --git a/source/Authenticator.cpp b/source/Authenticator.cpp
index e09fd0871..9a6dcf51b 100644
--- a/source/Authenticator.cpp
+++ b/source/Authenticator.cpp
@@ -46,28 +46,9 @@ cAuthenticator::~cAuthenticator()
/// Read custom values from INI
void cAuthenticator::ReadINI(cIniFile & IniFile)
{
- m_Server = IniFile.GetValue("Authentication", "Server");
- m_Address = IniFile.GetValue("Authentication", "Address");
- m_ShouldAuthenticate = IniFile.GetValueB("Authentication", "Authenticate", true);
- bool bSave = false;
-
- if (m_Server.length() == 0)
- {
- m_Server = DEFAULT_AUTH_SERVER;
- IniFile.SetValue("Authentication", "Server", m_Server);
- bSave = true;
- }
- if (m_Address.length() == 0)
- {
- m_Address = DEFAULT_AUTH_ADDRESS;
- IniFile.SetValue("Authentication", "Address", m_Address);
- bSave = true;
- }
-
- if (bSave)
- {
- IniFile.SetValueB("Authentication", "Authenticate", m_ShouldAuthenticate);
- }
+ m_Server = IniFile.GetValueSet("Authentication", "Server", DEFAULT_AUTH_SERVER);
+ m_Address = IniFile.GetValueSet("Authentication", "Address", DEFAULT_AUTH_ADDRESS);
+ m_ShouldAuthenticate = IniFile.GetValueSetB("Authentication", "Authenticate", true);
}
@@ -199,7 +180,7 @@ bool cAuthenticator::AuthFromAddress(const AString & a_Server, const AString & a
}
else if (code == 200)
{
- LOGINFO("Got 200 OK :D");
+ LOGD("cAuthenticator: Received status 200 OK! :D");
bOK = true;
}
}
@@ -268,17 +249,16 @@ bool cAuthenticator::AuthFromAddress(const AString & a_Server, const AString & a
std::string Result;
ss >> Result;
- LOGINFO("Got result: %s", Result.c_str());
- //if (Result.compare("3") == 0) // FIXME: Quick and dirty hack to support auth
- //Lapayo: Wtf 3?
+ LOGD("cAuthenticator: Authentication result was %s", Result.c_str());
+
if (Result.compare("YES") == 0) //Works well
{
- LOGINFO("Result was \"YES\", so player is authenticated!");
+ LOGINFO("Authentication result \"YES\", player authentication success!");
return true;
}
- LOGINFO("Result was \"%s\", so player is NOT authenticated!", Result.c_str());
+ LOGINFO("Authentication result was \"%s\", player authentication failure!", Result.c_str());
return false;
}
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 6860a29ca..5bef11988 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -205,7 +205,7 @@ void cClientHandle::Kick(const AString & a_Reason)
{
if (m_State >= csAuthenticating) // Don't log pings
{
- LOG("Kicking user \"%s\" for \"%s\"", m_Username.c_str(), a_Reason.c_str());
+ LOG("Kicking user \"%s\" for \"%s\"", m_Username.c_str(), StripColorCodes(a_Reason).c_str());
}
SendDisconnect(a_Reason);
}
@@ -2196,7 +2196,7 @@ void cClientHandle::SocketClosed(void)
{
// The socket has been closed for any reason
- LOG("Client \"%s\" @ %s disconnected", m_Username.c_str(), m_IPString.c_str());
+ LOGD("Client \"%s\" @ %s disconnected", m_Username.c_str(), m_IPString.c_str());
Destroy();
}
diff --git a/source/LeakFinder.cpp b/source/LeakFinder.cpp
index 272e313a0..0f84adb2b 100644
--- a/source/LeakFinder.cpp
+++ b/source/LeakFinder.cpp
@@ -108,8 +108,8 @@
#include "LeakFinder.h"
// Currently only tested with MS VC++ 5 to 10
-#if (_MSC_VER < 1100) || (_MSC_VER > 1700)
-#error Only MS VC++ 5/6/7/7.1/8/9 supported. Check if the '_CrtMemBlockHeader' has not changed with this compiler!
+#if (_MSC_VER < 1100) || (_MSC_VER > 1800)
+#error Only MS VC++ 5/6/7/7.1/8/9/10/11/12 supported. Check if the '_CrtMemBlockHeader' has not changed with this compiler!
#endif
diff --git a/source/MobSpawner.cpp b/source/MobSpawner.cpp
index d4926bbe5..dd9419ba4 100644
--- a/source/MobSpawner.cpp
+++ b/source/MobSpawner.cpp
@@ -71,10 +71,10 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
addIfAllowed(cMonster::mtZombiePigman, allowedMobs);
addIfAllowed(cMonster::mtMagmaCube, allowedMobs);
}
- /*else if (a_Biome == biEnder) MG TODO : figure out what are the biomes of the ender
+ else if (a_Biome == biEnd)
{
addIfAllowed(cMonster::mtEnderman, allowedMobs);
- }*/
+ }
else
{
addIfAllowed(cMonster::mtBat, allowedMobs);
@@ -210,7 +210,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
(m_Random.NextInt(20,a_Biome) == 0);
default:
- LOGD("MG TODO : check I've got a Rule to write for type %d",a_MobType);
+ LOGD("MG TODO: Write spawning rule for mob type %d", a_MobType);
return false;
}
}
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp
index 5ae70d48d..ac79942b7 100644
--- a/source/PluginManager.cpp
+++ b/source/PluginManager.cpp
@@ -95,6 +95,17 @@ void cPluginManager::FindPlugins(void)
void cPluginManager::ReloadPluginsNow(void)
{
+ cIniFile a_SettingsIni;
+ a_SettingsIni.ReadFile("settings.ini");
+ ReloadPluginsNow(a_SettingsIni);
+}
+
+
+
+
+
+void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
+{
LOG("-- Loading Plugins --");
m_bReloadPlugins = false;
UnloadPluginsNow();
@@ -102,26 +113,22 @@ void cPluginManager::ReloadPluginsNow(void)
FindPlugins();
cServer::BindBuiltInConsoleCommands();
-
- cIniFile IniFile;
- if (!IniFile.ReadFile("settings.ini"))
+
+ unsigned int KeyNum = a_SettingsIni.FindKey("Plugins");
+ unsigned int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0);
+ if (KeyNum == -1)
{
- LOGWARNING("cPluginManager: Can't find settings.ini, so can't load any plugins.");
+ a_SettingsIni.AddKeyName("Plugins");
+ a_SettingsIni.AddKeyComment("Plugins", " Plugin=Core");
}
-
- unsigned int KeyNum = IniFile.FindKey("Plugins");
- unsigned int NumPlugins = IniFile.GetNumValues(KeyNum);
- if (NumPlugins > 0)
+ else if (NumPlugins > 0)
{
for(unsigned int i = 0; i < NumPlugins; i++)
{
- AString ValueName = IniFile.GetValueName(KeyNum, i );
- if (
- (ValueName.compare("NewPlugin") == 0) ||
- (ValueName.compare("Plugin") == 0)
- )
+ AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
+ if (ValueName.compare("Plugin") == 0)
{
- AString PluginFile = IniFile.GetValue(KeyNum, i);
+ AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
if (!PluginFile.empty())
{
if (m_Plugins.find(PluginFile) != m_Plugins.end())
@@ -137,7 +144,7 @@ void cPluginManager::ReloadPluginsNow(void)
{
LOG("-- No Plugins Loaded --");
}
- else if ((GetNumPlugins() > 1) || (GetNumPlugins() == 0))
+ else if (GetNumPlugins() > 1)
{
LOG("-- Loaded %i Plugins --", GetNumPlugins());
}
diff --git a/source/PluginManager.h b/source/PluginManager.h
index 816e4a40c..f2ea000c9 100644
--- a/source/PluginManager.h
+++ b/source/PluginManager.h
@@ -271,7 +271,14 @@ private:
cPluginManager();
~cPluginManager();
+ /// Reloads all plugins, defaulting to settings.ini for settings location
void ReloadPluginsNow(void);
+
+ /// Reloads all plugins with a cIniFile object expected to be initialised to settings.ini
+ /// Used because cRoot otherwise overwrites any configuration generation here if cRoot's IniFile is not used
+ void ReloadPluginsNow(cIniFile & a_SettingsIni);
+
+ /// Unloads all plugins
void UnloadPluginsNow(void);
/// Adds the plugin into the internal list of plugins and initializes it. If initialization fails, the plugin is removed again.
diff --git a/source/Root.cpp b/source/Root.cpp
index e992ff614..8ec94629b 100644
--- a/source/Root.cpp
+++ b/source/Root.cpp
@@ -119,8 +119,12 @@ void cRoot::Start(void)
cIniFile IniFile;
if (!IniFile.ReadFile("settings.ini"))
{
- LOGWARNING("settings.ini inaccessible, all settings are reset to default values");
+ LOGWARN("Regenerating settings.ini, all settings will be reset");
+ IniFile.AddHeaderComment(" This is the main server configuration");
+ IniFile.AddHeaderComment(" Most of the settings here can be configured using the webadmin interface, if enabled in webadmin.ini");
+ IniFile.AddHeaderComment(" See: http://www.mc-server.org/wiki/doku.php?id=configure:settings.ini for further configuration help");
}
+
m_PrimaryServerVersion = IniFile.GetValueI("Server", "PrimaryServerVersion", 0);
if (m_PrimaryServerVersion == 0)
{
@@ -129,7 +133,7 @@ void cRoot::Start(void)
else
{
// Make a note in the log that the primary server version is explicitly set in the ini file
- LOGINFO("settings.ini: [Server].PrimaryServerVersion set to %d.", m_PrimaryServerVersion);
+ LOGINFO("Primary server version set explicitly to %d.", m_PrimaryServerVersion);
}
LOG("Starting server...");
@@ -152,7 +156,7 @@ void cRoot::Start(void)
LOGD("Loading plugin manager...");
m_PluginManager = new cPluginManager();
- m_PluginManager->ReloadPluginsNow();
+ m_PluginManager->ReloadPluginsNow(IniFile);
LOGD("Loading MonsterConfig...");
m_MonsterConfig = new cMonsterConfig;
@@ -261,6 +265,7 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
return;
}
+ bool FoundAdditionalWorlds = false;
for (unsigned int i = 0; i < NumWorlds; i++)
{
AString ValueName = IniFile.GetValueName(KeyNum, i );
@@ -273,9 +278,15 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
{
continue;
}
+ FoundAdditionalWorlds = true;
cWorld* NewWorld = new cWorld( WorldName.c_str() );
m_WorldsByName[ WorldName ] = NewWorld;
} // for i - Worlds
+
+ if (!FoundAdditionalWorlds)
+ {
+ IniFile.AddKeyComment("Worlds", " World=secondworld");
+ }
}
diff --git a/source/Server.cpp b/source/Server.cpp
index 879bfae5a..380c7416e 100644
--- a/source/Server.cpp
+++ b/source/Server.cpp
@@ -195,8 +195,9 @@ void cServer::PlayerDestroying(const cPlayer * a_Player)
bool cServer::InitServer(cIniFile & a_SettingsIni)
{
- m_Description = a_SettingsIni.GetValue ("Server", "Description", "MCServer! - In C++!").c_str();
- m_MaxPlayers = a_SettingsIni.GetValueI("Server", "MaxPlayers", 100);
+ m_Description = a_SettingsIni.GetValueSet("Server", "Description", "MCServer - The Minecraft server in C++!").c_str();
+ m_MaxPlayers = a_SettingsIni.GetValueSetI("Server", "MaxPlayers", 100);
+ m_bIsHardcore = a_SettingsIni.GetValueSetB("Server", "HardcoreEnabled");
m_PlayerCount = 0;
m_PlayerCountDiff = 0;
@@ -320,7 +321,7 @@ void cServer::OnConnectionAccepted(cSocket & a_Socket)
return;
}
- LOG("Client \"%s\" connected!", ClientIP.c_str());
+ LOGD("Client \"%s\" connected!", ClientIP.c_str());
cClientHandle * NewHandle = new cClientHandle(&a_Socket, m_ClientViewDistance);
if (!m_SocketThreads.AddClient(a_Socket, NewHandle))
@@ -507,7 +508,7 @@ void cServer::BindBuiltInConsoleCommands(void)
PlgMgr->BindConsoleCommand("chunkstats", NULL, " - Displays detailed chunk memory statistics");
#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
PlgMgr->BindConsoleCommand("dumpmem", NULL, " - Dumps all used memory blocks together with their callstacks into memdump.xml");
- #endif
+ #endif
}
diff --git a/source/Server.h b/source/Server.h
index b4fe81d8f..6742153ac 100644
--- a/source/Server.h
+++ b/source/Server.h
@@ -46,6 +46,9 @@ public: // tolua_export
int GetNumPlayers(void);
void SetMaxPlayers(int a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; }
+ // Hardcore mode or not:
+ bool IsHardcore(void) const {return m_bIsHardcore; }
+
// tolua_end
bool Start(void);
@@ -161,6 +164,7 @@ private:
AString m_Description;
int m_MaxPlayers;
+ bool m_bIsHardcore;
cTickThread m_TickThread;
cEvent m_RestartEvent;
diff --git a/source/WebAdmin.cpp b/source/WebAdmin.cpp
index 8c95e4e21..7dc49942f 100644
--- a/source/WebAdmin.cpp
+++ b/source/WebAdmin.cpp
@@ -56,7 +56,7 @@ cWebAdmin::~cWebAdmin()
{
if (m_IsInitialized)
{
- LOG("Stopping WebAdmin...");
+ LOGD("Stopping WebAdmin...");
}
}
@@ -87,7 +87,11 @@ bool cWebAdmin::Init(void)
{
if (!m_IniFile.ReadFile("webadmin.ini"))
{
- return false;
+ LOGWARN("Regenerating webadmin.ini, all settings will be reset");
+ m_IniFile.AddHeaderComment(" This file controls the webadmin feature of MCServer");
+ m_IniFile.AddHeaderComment(" Username format: [User:*username*] | Password format: Password=*password*; for example:");
+ m_IniFile.AddHeaderComment(" [User:admin]");
+ m_IniFile.AddHeaderComment(" Password=admin");
}
if (!m_IniFile.GetValueSetB("WebAdmin", "Enabled", true))
@@ -96,16 +100,17 @@ bool cWebAdmin::Init(void)
return true;
}
- LOG("Initialising WebAdmin...");
+ LOGD("Initialising WebAdmin...");
AString PortsIPv4 = m_IniFile.GetValueSet("WebAdmin", "Port", "8080");
- AString PortsIPv6 = m_IniFile.GetValueSet("WebAdmin", "PortsIPv6", "");
+ AString PortsIPv6 = m_IniFile.GetValueSet("WebAdmin", "Port-IPv6", "");
if (!m_HTTPServer.Initialize(PortsIPv4, PortsIPv6))
{
return false;
}
m_IsInitialized = true;
+ m_IniFile.WriteFile("webadmin.ini");
return true;
}
@@ -121,7 +126,7 @@ bool cWebAdmin::Start(void)
return false;
}
- LOG("Starting WebAdmin...");
+ LOGD("Starting WebAdmin...");
// Initialize the WebAdmin template script and load the file
m_TemplateScript.Create();
diff --git a/source/World.cpp b/source/World.cpp
index dd3965e3d..c6bc47be5 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -509,7 +509,7 @@ void cWorld::Start(void)
break;
}
}
- m_bAnimals = IniFile.GetValueB("Monsters", "AnimalsOn", true);
+ m_bAnimals = IniFile.GetValueSetB("Monsters", "AnimalsOn", true);
AString AllMonsters = IniFile.GetValueSet("Monsters", "Types", DefaultMonsters);
AStringVector SplitList = StringSplitAndTrim(AllMonsters, ",");
for (AStringVector::const_iterator itr = SplitList.begin(), end = SplitList.end(); itr != end; ++itr)
@@ -784,8 +784,8 @@ void cWorld::TickMobs(float a_Dt)
SpawnMobFinalize(*itr2);
}
}
- } // for i - AllFamilies[]
- } // if (Spawning enabled)
+ } // for i - AllFamilies[]
+ } // if (Spawning enabled)
// move close mobs
cMobProximityCounter::sIterablePair allCloseEnoughToMoveMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(-1, 64 * 16);// MG TODO : deal with this magic number (the 16 is the size of a block)