From e832736e0bf315585f873b43520d1d771930a1c2 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 4 Nov 2013 21:51:24 +0000 Subject: Autogeneration of settings.ini and webadmin.ini Fixes issue #75 --- source/PluginManager.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'source/PluginManager.cpp') diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index 5ae70d48d..ac79942b7 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -94,6 +94,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; @@ -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()); } -- cgit v1.2.3 From 0c2c803a168183c95d9b191cd8b35debed5d3f54 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 4 Nov 2013 22:06:23 +0000 Subject: Removed settings/webadmin.example.ini files Additionally, added some default plugins to autogeneration. Also moved nbt examples to docs/NBT Examples. --- source/PluginManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/PluginManager.cpp') diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index ac79942b7..0ff7736ec 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -119,7 +119,12 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) if (KeyNum == -1) { a_SettingsIni.AddKeyName("Plugins"); - a_SettingsIni.AddKeyComment("Plugins", " Plugin=Core"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=Debuggers"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=HookNotify"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=ChunkWorx"); + a_SettingsIni.SetValue("Plugins", "Plugin", "Core"); + a_SettingsIni.SetValue("Plugins", "Plugin", "TransAPI"); + a_SettingsIni.SetValue("Plugins", "Plugin", "ChatLog"); } else if (NumPlugins > 0) { -- cgit v1.2.3 From a263dc8e83d1dc805aac8469cc2c740d88336575 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 5 Nov 2013 21:15:39 +0000 Subject: Implemented suggestions - Reverted changes to WebAdmin.cpp IPv6 ports and Server.cpp server description + Added default value explicitly for HardCore value * Split PluginManager plugin defaults write to new function - Removed a commented block from BlockTorch and... + Added g_BlockIsTorchPlaceable to Defines.h --- source/PluginManager.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'source/PluginManager.cpp') diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index 0ff7736ec..3ac2366ca 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -118,13 +118,7 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) unsigned int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0); if (KeyNum == -1) { - a_SettingsIni.AddKeyName("Plugins"); - a_SettingsIni.AddKeyComment("Plugins", " Plugin=Debuggers"); - a_SettingsIni.AddKeyComment("Plugins", " Plugin=HookNotify"); - a_SettingsIni.AddKeyComment("Plugins", " Plugin=ChunkWorx"); - a_SettingsIni.SetValue("Plugins", "Plugin", "Core"); - a_SettingsIni.SetValue("Plugins", "Plugin", "TransAPI"); - a_SettingsIni.SetValue("Plugins", "Plugin", "ChatLog"); + InsertDefaultPlugins(a_SettingsIni); } else if (NumPlugins > 0) { @@ -163,6 +157,22 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) +void cPluginManager::InsertDefaultPlugins(cIniFile & a_SettingsIni) +{ + a_SettingsIni.AddKeyName("Plugins"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=Debuggers"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=HookNotify"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=ChunkWorx"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=APIDump"); + a_SettingsIni.SetValue("Plugins", "Plugin", "Core"); + a_SettingsIni.SetValue("Plugins", "Plugin", "TransAPI"); + a_SettingsIni.SetValue("Plugins", "Plugin", "ChatLog"); +} + + + + + void cPluginManager::Tick(float a_Dt) { while (!m_DisablePluginList.empty()) -- cgit v1.2.3