From a263dc8e83d1dc805aac8469cc2c740d88336575 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 5 Nov 2013 21:15:39 +0000 Subject: [PATCH] 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/Blocks/BlockTorch.h | 13 ------------- source/Defines.h | 5 +++++ source/PluginManager.cpp | 24 +++++++++++++++++------- source/PluginManager.h | 4 +++- source/Server.cpp | 4 ++-- source/WebAdmin.cpp | 2 +- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/source/Blocks/BlockTorch.h b/source/Blocks/BlockTorch.h index a52b373cb..36383a524 100644 --- a/source/Blocks/BlockTorch.h +++ b/source/Blocks/BlockTorch.h @@ -166,19 +166,6 @@ public: } - /* - virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override - { - if (TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace)) - { - return true; - } - - return (FindSuitableFace(a_World, a_BlockX, a_BlockY, a_BlockZ) != BLOCK_FACE_BOTTOM); - } - */ - - virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { char Face = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); diff --git a/source/Defines.h b/source/Defines.h index 6dd81137e..60dab12be 100644 --- a/source/Defines.h +++ b/source/Defines.h @@ -35,10 +35,15 @@ extern bool g_BlockPistonBreakable[256]; /// Can this block hold snow atop? extern bool g_BlockIsSnowable[256]; +/// Does this block require a tool to drop? extern bool g_BlockRequiresSpecialTool[256]; +/// Is this block solid (player cannot walk through)? extern bool g_BlockIsSolid[256]; +/// Can torches be placed on this block? +extern bool g_BlockIsTorchPlaceable[256]; + 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()) diff --git a/source/PluginManager.h b/source/PluginManager.h index f2ea000c9..4140bffb5 100644 --- a/source/PluginManager.h +++ b/source/PluginManager.h @@ -275,12 +275,14 @@ private: 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); + /// Handles writing default plugins if 'Plugins' key not found using a cIniFile object expected to be intialised to settings.ini + void InsertDefaultPlugins(cIniFile & a_SettingsIni); + /// Adds the plugin into the internal list of plugins and initializes it. If initialization fails, the plugin is removed again. bool AddPlugin(cPlugin * a_Plugin); diff --git a/source/Server.cpp b/source/Server.cpp index 380c7416e..75ce35cb7 100644 --- a/source/Server.cpp +++ b/source/Server.cpp @@ -195,9 +195,9 @@ void cServer::PlayerDestroying(const cPlayer * a_Player) bool cServer::InitServer(cIniFile & a_SettingsIni) { - m_Description = a_SettingsIni.GetValueSet("Server", "Description", "MCServer - The Minecraft server in C++!").c_str(); + m_Description = a_SettingsIni.GetValueSet("Server", "Description", "MCServer - in C++!").c_str(); m_MaxPlayers = a_SettingsIni.GetValueSetI("Server", "MaxPlayers", 100); - m_bIsHardcore = a_SettingsIni.GetValueSetB("Server", "HardcoreEnabled"); + m_bIsHardcore = a_SettingsIni.GetValueSetB("Server", "HardcoreEnabled", false); m_PlayerCount = 0; m_PlayerCountDiff = 0; diff --git a/source/WebAdmin.cpp b/source/WebAdmin.cpp index 7dc49942f..7a1d332a5 100644 --- a/source/WebAdmin.cpp +++ b/source/WebAdmin.cpp @@ -103,7 +103,7 @@ bool cWebAdmin::Init(void) LOGD("Initialising WebAdmin..."); AString PortsIPv4 = m_IniFile.GetValueSet("WebAdmin", "Port", "8080"); - AString PortsIPv6 = m_IniFile.GetValueSet("WebAdmin", "Port-IPv6", ""); + AString PortsIPv6 = m_IniFile.GetValueSet("WebAdmin", "PortsIPv6", ""); if (!m_HTTPServer.Initialize(PortsIPv4, PortsIPv6)) {