From e5d5896a24695e25278db230a3e909022087d2e2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 27 Sep 2013 16:31:48 +0200 Subject: Fixed a typo in cEntity doxycomments. --- source/Entities/Entity.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/Entities/Entity.h b/source/Entities/Entity.h index a2c99d2a0..c7c362b40 100644 --- a/source/Entities/Entity.h +++ b/source/Entities/Entity.h @@ -234,16 +234,16 @@ public: /// Returns the curently equipped weapon; empty item if none virtual cItem GetEquippedWeapon(void) const { return cItem(); } - /// Returns the currently equipped helmet; empty item if nonte + /// Returns the currently equipped helmet; empty item if none virtual cItem GetEquippedHelmet(void) const { return cItem(); } - /// Returns the currently equipped chestplate; empty item if nonte + /// Returns the currently equipped chestplate; empty item if none virtual cItem GetEquippedChestplate(void) const { return cItem(); } - /// Returns the currently equipped leggings; empty item if nonte + /// Returns the currently equipped leggings; empty item if none virtual cItem GetEquippedLeggings(void) const { return cItem(); } - /// Returns the currently equipped boots; empty item if nonte + /// Returns the currently equipped boots; empty item if none virtual cItem GetEquippedBoots(void) const { return cItem(); } /// Called when the health drops below zero. a_Killer may be NULL (environmental damage) -- cgit v1.2.3 From cc5c56d545c0735d28a99b89d4970bd507608f7f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Sep 2013 20:36:01 +0100 Subject: Minor startup streamlining * LOGD'd unneeded debugging messages, streamlining startup + Added a basic timer for how long in seconds it took to start up + Added two checks for plural (plugin/s, second/s) --- source/CraftingRecipes.cpp | 4 +- source/FurnaceRecipe.cpp | 4 +- source/Generating/ComposableGenerator.cpp | 2 +- source/GroupManager.cpp | 8 ++-- source/PluginManager.cpp | 10 +++-- source/Root.cpp | 64 ++++++++++++++++++++----------- source/Server.cpp | 7 ++-- source/WebAdmin.cpp | 2 +- 8 files changed, 60 insertions(+), 41 deletions(-) (limited to 'source') diff --git a/source/CraftingRecipes.cpp b/source/CraftingRecipes.cpp index 13a8ac1e0..9dc471781 100644 --- a/source/CraftingRecipes.cpp +++ b/source/CraftingRecipes.cpp @@ -310,7 +310,7 @@ void cCraftingRecipes::GetRecipe(const cPlayer * a_Player, const cCraftingGrid & void cCraftingRecipes::LoadRecipes(void) { - LOG("-- Loading crafting recipes from crafting.txt --"); + LOGD("Loading crafting recipes from crafting.txt..."); ClearRecipes(); // Load the crafting.txt file: @@ -338,7 +338,7 @@ void cCraftingRecipes::LoadRecipes(void) } AddRecipeLine(LineNum, Recipe); } // for itr - Split[] - LOG("-- %d crafting recipes loaded from crafting.txt --", m_Recipes.size()); + LOG("Loaded %d crafting recipes", m_Recipes.size()); } diff --git a/source/FurnaceRecipe.cpp b/source/FurnaceRecipe.cpp index 8b1ee09a2..2e2276981 100644 --- a/source/FurnaceRecipe.cpp +++ b/source/FurnaceRecipe.cpp @@ -51,7 +51,7 @@ cFurnaceRecipe::~cFurnaceRecipe() void cFurnaceRecipe::ReloadRecipes(void) { ClearRecipes(); - LOG("-- Loading furnace recipes --"); + LOGD("Loading furnace recipes..."); std::ifstream f; char a_File[] = "furnace.txt"; @@ -175,7 +175,7 @@ void cFurnaceRecipe::ReloadRecipes(void) { LOGERROR("ERROR: FurnaceRecipe, syntax error" ); } - LOG("Got %u furnace recipes, and %u fuels.", m_pState->Recipes.size(), m_pState->Fuel.size()); + LOG("Loaded %u furnace recipes and %u fuels", m_pState->Recipes.size(), m_pState->Fuel.size()); } diff --git a/source/Generating/ComposableGenerator.cpp b/source/Generating/ComposableGenerator.cpp index 0852f559e..e2a8df11b 100644 --- a/source/Generating/ComposableGenerator.cpp +++ b/source/Generating/ComposableGenerator.cpp @@ -294,7 +294,7 @@ void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile) ); CacheSize = 4; } - LOGINFO("Using a cache for Heightgen of size %d.", CacheSize); + LOGD("Using a cache for Heightgen of size %d.", CacheSize); m_UnderlyingHeightGen = m_HeightGen; m_HeightGen = new cHeiGenCache(m_UnderlyingHeightGen, CacheSize); } diff --git a/source/GroupManager.cpp b/source/GroupManager.cpp index cef32dd58..b79fde9dc 100644 --- a/source/GroupManager.cpp +++ b/source/GroupManager.cpp @@ -43,7 +43,7 @@ cGroupManager::~cGroupManager() cGroupManager::cGroupManager() : m_pState( new sGroupManagerState ) { - LOG("-- Loading Groups --"); + LOGD("-- Loading Groups --"); cIniFile IniFile("groups.ini"); if (!IniFile.ReadFile()) { @@ -57,7 +57,7 @@ cGroupManager::cGroupManager() std::string KeyName = IniFile.GetKeyName( i ); cGroup* Group = GetGroup( KeyName.c_str() ); - LOG("Loading group: %s", KeyName.c_str() ); + LOGD("Loading group: %s", KeyName.c_str() ); Group->SetName( KeyName ); char Color = IniFile.GetValue( KeyName, "Color", "-" )[0]; @@ -73,7 +73,6 @@ cGroupManager::cGroupManager() for( unsigned int i = 0; i < Split.size(); i++) { Group->AddCommand( Split[i] ); - //LOG("%s", Split[i].c_str() ); } } @@ -84,7 +83,6 @@ cGroupManager::cGroupManager() for( unsigned int i = 0; i < Split.size(); i++) { Group->AddPermission( Split[i] ); - //LOGINFO("Permission: %s", Split[i].c_str() ); } } @@ -98,7 +96,7 @@ cGroupManager::cGroupManager() } } } - LOG("-- Groups Successfully Loaded --"); + LOGD("-- Groups Successfully Loaded --"); } diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index 93ee71926..862c6d32b 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -95,7 +95,7 @@ void cPluginManager::FindPlugins(void) void cPluginManager::ReloadPluginsNow(void) { - LOG("Loading plugins"); + LOG("-- Loading Plugins --"); m_bReloadPlugins = false; UnloadPluginsNow(); @@ -135,11 +135,15 @@ void cPluginManager::ReloadPluginsNow(void) if (GetNumPlugins() == 0) { - LOG("No plugins loaded"); + LOG("-- No Plugins Loaded --"); + } + else if ((GetNumPlugins() > 1) || (GetNumPlugins() == 0)) + { + LOG("-- Loaded %i Plugins --", GetNumPlugins()); } else { - LOG("Loaded %i plugin(s)", GetNumPlugins()); + LOG("-- Loaded 1 Plugin --"); } } diff --git a/source/Root.cpp b/source/Root.cpp index 3933535f1..24ff77e42 100644 --- a/source/Root.cpp +++ b/source/Root.cpp @@ -21,6 +21,7 @@ #include "../iniFile/iniFile.h" #include +#include @@ -91,6 +92,17 @@ void cRoot::InputThread(void * a_Params) void cRoot::Start(void) { + time_t timer; + struct tm y2k; + double seconds; + double finishseconds; + + y2k.tm_hour = 0; y2k.tm_min = 0; y2k.tm_sec = 0; + y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1; + + time(&timer); + seconds = difftime(timer,mktime(&y2k)); + cDeadlockDetect dd; delete m_Log; m_Log = new cMCLogger(); @@ -125,7 +137,7 @@ void cRoot::Start(void) LOG("Starting server..."); if (!m_Server->InitServer(IniFile)) { - LOGERROR("Failed to start server, shutting down."); + LOGERROR("Failure starting server, aborting..."); return; } IniFile.WriteFile(); @@ -138,45 +150,51 @@ void cRoot::Start(void) if (WebIniFile.GetValueB("WebAdmin", "Enabled", false)) { - LOG("Creating WebAdmin..."); + LOGD("Creating WebAdmin..."); m_WebAdmin = new cWebAdmin(8080); } - LOG("Loading settings..."); + LOGD("Loading settings..."); m_GroupManager = new cGroupManager(); m_CraftingRecipes = new cCraftingRecipes; m_FurnaceRecipe = new cFurnaceRecipe(); - LOG("Loading worlds..."); + LOGD("Loading worlds..."); LoadWorlds(); - LOG("Loading plugin manager..."); + LOGD("Loading plugin manager..."); m_PluginManager = new cPluginManager(); m_PluginManager->ReloadPluginsNow(); - LOG("Loading MonsterConfig..."); + LOGD("Loading MonsterConfig..."); m_MonsterConfig = new cMonsterConfig; // This sets stuff in motion - LOG("Starting Authenticator..."); + LOGD("Starting Authenticator..."); m_Authenticator.Start(); - LOG("Starting worlds..."); + LOGD("Starting worlds..."); StartWorlds(); - LOG("Starting deadlock detector..."); + LOGD("Starting deadlock detector..."); dd.Start(); - LOG("Starting server..."); + LOGD("Finalising startup..."); m_Server->Start(); #if !defined(ANDROID_NDK) - LOG("Starting InputThread..."); + LOGD("Starting InputThread..."); m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" ); m_InputThread->Start( false ); // We should NOT wait? Otherwise we canīt stop the server from other threads than the input thread #endif - LOG("Initialization done, server running now."); + time(&timer); + finishseconds = difftime(timer,mktime(&y2k)); + finishseconds -= seconds; + + if ((finishseconds > 1) || (finishseconds == 0)) { LOG("Startup complete, took %.f seconds!", finishseconds); } + else { LOG("Startup complete, took 1 second!"); } + while (!m_bStop && !m_bRestart) // These are modified by external threads { cSleep::MilliSleep(1000); @@ -190,37 +208,37 @@ void cRoot::Start(void) LOG("Shutting down server..."); m_Server->Shutdown(); - LOG("Shutting down deadlock detector..."); + LOGD("Shutting down deadlock detector..."); dd.Stop(); - LOG("Stopping world threads..."); + LOGD("Stopping world threads..."); StopWorlds(); - LOG("Stopping authenticator..."); + LOGD("Stopping authenticator..."); m_Authenticator.Stop(); - LOG("Freeing MonsterConfig..."); + LOGD("Freeing MonsterConfig..."); delete m_MonsterConfig; m_MonsterConfig = NULL; - LOG("Stopping WebAdmin..."); + LOGD("Stopping WebAdmin..."); delete m_WebAdmin; m_WebAdmin = NULL; - LOG("Unloading recipes..."); + LOGD("Unloading recipes..."); delete m_FurnaceRecipe; m_FurnaceRecipe = NULL; delete m_CraftingRecipes; m_CraftingRecipes = NULL; - LOG("Forgetting groups..."); + LOGD("Forgetting groups..."); delete m_GroupManager; m_GroupManager = 0; - LOG("Unloading worlds..."); + LOGD("Unloading worlds..."); UnloadWorlds(); - LOG("Stopping plugin manager..."); + LOGD("Stopping plugin manager..."); delete m_PluginManager; m_PluginManager = NULL; cItemHandler::Deinit(); cBlockHandler::Deinit(); - LOG("Destroying server..."); + LOG("Cleaning up..."); //delete HeartBeat; HeartBeat = 0; delete m_Server; m_Server = 0; - LOG("Shutdown done."); + LOG("Shutdown successful!"); } delete m_Log; m_Log = 0; diff --git a/source/Server.cpp b/source/Server.cpp index dd18f8d3d..4283dbfae 100644 --- a/source/Server.cpp +++ b/source/Server.cpp @@ -206,9 +206,8 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) return false; } - LOG("Starting up server."); - LOGINFO("Compatible clients: %s", MCS_CLIENT_VERSIONS); - LOGINFO("Compatible protocol versions %s", MCS_PROTOCOL_VERSIONS); + LOGD("Compatible clients: %s", MCS_CLIENT_VERSIONS); + LOGD("Compatible protocol versions %s", MCS_PROTOCOL_VERSIONS); if (cSocket::WSAStartup() != 0) // Only does anything on Windows, but whatever { @@ -292,7 +291,7 @@ void cServer::PrepareKeys(void) // TODO: Save and load key for persistence across sessions // But generating the key takes only a moment, do we even need that? - LOG("Generating protocol encryption keypair..."); + LOGD("Generating protocol encryption keypair..."); time_t CurTime = time(NULL); CryptoPP::RandomPool rng; diff --git a/source/WebAdmin.cpp b/source/WebAdmin.cpp index 77a5865d3..4f10d80a7 100644 --- a/source/WebAdmin.cpp +++ b/source/WebAdmin.cpp @@ -286,7 +286,7 @@ bool cWebAdmin::Init(int a_Port) } - LOG("Starting WebAdmin on port %i", m_Port); + LOGD("Starting WebAdmin on port %i", m_Port); #ifdef _WIN32 HANDLE hThread = CreateThread( -- cgit v1.2.3 From 9c7cfd29ad435d98ab70ad32282b9ec4dac666cd Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Sep 2013 21:37:50 +0100 Subject: Improvements to startup timer As suggested by xoft. Also reverted changes of displayed protocol version. --- source/Root.cpp | 22 +++++++--------------- source/Server.cpp | 4 ++-- 2 files changed, 9 insertions(+), 17 deletions(-) (limited to 'source') diff --git a/source/Root.cpp b/source/Root.cpp index 24ff77e42..c33af52ad 100644 --- a/source/Root.cpp +++ b/source/Root.cpp @@ -17,11 +17,11 @@ #include "Protocol/ProtocolRecognizer.h" // for protocol version constants #include "CommandOutput.h" #include "DeadlockDetect.h" +#include "OSSupport/Timer.h" #include "../iniFile/iniFile.h" #include -#include @@ -92,16 +92,9 @@ void cRoot::InputThread(void * a_Params) void cRoot::Start(void) { - time_t timer; - struct tm y2k; - double seconds; - double finishseconds; + cTimer Time; - y2k.tm_hour = 0; y2k.tm_min = 0; y2k.tm_sec = 0; - y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1; - - time(&timer); - seconds = difftime(timer,mktime(&y2k)); + long long mseconds = Time.GetNowTime(); cDeadlockDetect dd; delete m_Log; @@ -188,12 +181,11 @@ void cRoot::Start(void) m_InputThread->Start( false ); // We should NOT wait? Otherwise we canīt stop the server from other threads than the input thread #endif - time(&timer); - finishseconds = difftime(timer,mktime(&y2k)); - finishseconds -= seconds; + long long finishmseconds = Time.GetNowTime(); + finishmseconds -= mseconds; - if ((finishseconds > 1) || (finishseconds == 0)) { LOG("Startup complete, took %.f seconds!", finishseconds); } - else { LOG("Startup complete, took 1 second!"); } + if ((finishmseconds > 1) || (finishmseconds == 0)) { LOG("Startup complete, took %i miliseconds!", finishmseconds); } // Milisecs, why not :P + else { LOG("Startup complete, took 1 milisecond!"); } while (!m_bStop && !m_bRestart) // These are modified by external threads { diff --git a/source/Server.cpp b/source/Server.cpp index 4283dbfae..fec8fcd36 100644 --- a/source/Server.cpp +++ b/source/Server.cpp @@ -206,8 +206,8 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) return false; } - LOGD("Compatible clients: %s", MCS_CLIENT_VERSIONS); - LOGD("Compatible protocol versions %s", MCS_PROTOCOL_VERSIONS); + LOGINFO("Compatible clients: %s", MCS_CLIENT_VERSIONS); + LOGINFO("Compatible protocol versions %s", MCS_PROTOCOL_VERSIONS); if (cSocket::WSAStartup() != 0) // Only does anything on Windows, but whatever { -- cgit v1.2.3 From ab34da78e7ef249acb01924cf184b7c1fba2ab3a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Sep 2013 23:39:58 +0100 Subject: Fixed a fire simulator bug Fire now doesn't stay when it isn't on a flammable block. Fixes the "fire creates chandeliers" bug in report #131 --- source/Simulator/FireSimulator.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/Simulator/FireSimulator.cpp b/source/Simulator/FireSimulator.cpp index 587f45306..e0b4f1f02 100644 --- a/source/Simulator/FireSimulator.cpp +++ b/source/Simulator/FireSimulator.cpp @@ -221,7 +221,7 @@ void cFireSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) { - if (a_RelY > 0) + if ((a_RelY > 0) && (a_RelY < cChunkDef::Height - 1)) { BLOCKTYPE BlockBelow = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ); if (IsForever(BlockBelow)) @@ -234,10 +234,6 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in return m_BurnStepTimeFuel; } } - if ((a_RelY < cChunkDef::Height - 1) && IsFuel(a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ))) - { - return m_BurnStepTimeFuel; - } for (int i = 0; i < ARRAYCOUNT(gCrossCoords); i++) { @@ -251,7 +247,23 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in } } } // for i - gCrossCoords[] - return m_BurnStepTimeNonfuel; + + if ((a_RelY > 0) && (a_RelY < cChunkDef::Height - 1)) + { + // Checked through everything, nothing was flammable + // If block below isn't solid, we can't have fire, otherwise, we have non-fueled fire + BLOCKTYPE BlockBelow = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ); + if (g_BlockIsSolid[BlockBelow]) + { + return m_BurnStepTimeNonfuel; + } + else + { + // SetBlock just to make sure fire doesn't spawn + a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0); + return 0; + } + } } -- cgit v1.2.3 From c4750ef003363a79ac4930f985c4f78002c63642 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 30 Sep 2013 21:15:48 +0100 Subject: Fixed issues --- source/Simulator/FireSimulator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/Simulator/FireSimulator.cpp b/source/Simulator/FireSimulator.cpp index e0b4f1f02..da1dc8d15 100644 --- a/source/Simulator/FireSimulator.cpp +++ b/source/Simulator/FireSimulator.cpp @@ -221,7 +221,7 @@ void cFireSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) { - if ((a_RelY > 0) && (a_RelY < cChunkDef::Height - 1)) + if (a_RelY > 0) { BLOCKTYPE BlockBelow = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ); if (IsForever(BlockBelow)) @@ -260,7 +260,7 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in else { // SetBlock just to make sure fire doesn't spawn - a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0); + a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0); return 0; } } -- cgit v1.2.3 From 20902e125c9b042ff77ddf4419e3eb9474de674e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 30 Sep 2013 21:17:52 +0100 Subject: Removed unneeded statement Also LOGINFO'd "Starting WebAdmin" --- source/Root.cpp | 3 +-- source/WebAdmin.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/Root.cpp b/source/Root.cpp index c33af52ad..abe153b30 100644 --- a/source/Root.cpp +++ b/source/Root.cpp @@ -184,8 +184,7 @@ void cRoot::Start(void) long long finishmseconds = Time.GetNowTime(); finishmseconds -= mseconds; - if ((finishmseconds > 1) || (finishmseconds == 0)) { LOG("Startup complete, took %i miliseconds!", finishmseconds); } // Milisecs, why not :P - else { LOG("Startup complete, took 1 milisecond!"); } + LOG("Startup complete, took %i ms!", finishmseconds); while (!m_bStop && !m_bRestart) // These are modified by external threads { diff --git a/source/WebAdmin.cpp b/source/WebAdmin.cpp index 4f10d80a7..9d68931af 100644 --- a/source/WebAdmin.cpp +++ b/source/WebAdmin.cpp @@ -286,7 +286,7 @@ bool cWebAdmin::Init(int a_Port) } - LOGD("Starting WebAdmin on port %i", m_Port); + LOGINFO("Starting WebAdmin on port %i", m_Port); #ifdef _WIN32 HANDLE hThread = CreateThread( -- cgit v1.2.3