diff options
author | Mattes D <github@xoft.cz> | 2014-08-28 15:53:36 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-08-28 15:53:36 +0200 |
commit | 52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c (patch) | |
tree | c7d8ad9c38a32102bd46e0450d271ea1308828ce /Tools | |
parent | CheckBasicStyle: Added checking for the "template" keyword. (diff) | |
parent | Fixed ItemCategory code example. (diff) | |
download | cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.gz cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.bz2 cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.lz cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.xz cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.zst cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.zip |
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/AnvilStats/.gitignore | 5 | ||||
-rw-r--r-- | Tools/AnvilStats/AnvilStats.sln | 55 | ||||
-rw-r--r-- | Tools/AnvilStats/AnvilStats.vcproj | 468 | ||||
-rw-r--r-- | Tools/AnvilStats/CMakeLists.txt | 144 | ||||
-rw-r--r-- | Tools/AnvilStats/Globals.h | 11 | ||||
-rw-r--r-- | Tools/AnvilStats/Processor.cpp | 24 | ||||
-rw-r--r-- | Tools/AnvilStats/Processor.h | 10 | ||||
-rw-r--r-- | Tools/AnvilStats/Statistics.cpp | 127 | ||||
-rw-r--r-- | Tools/AnvilStats/Statistics.h | 6 | ||||
-rw-r--r-- | Tools/AnvilStats/Utils.cpp | 2 | ||||
-rw-r--r-- | Tools/MCADefrag/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Tools/MCADefrag/MCADefrag.cpp | 16 | ||||
-rw-r--r-- | Tools/ProtoProxy/CMakeLists.txt | 6 |
13 files changed, 331 insertions, 549 deletions
diff --git a/Tools/AnvilStats/.gitignore b/Tools/AnvilStats/.gitignore index 96210cfc9..f093bbe7d 100644 --- a/Tools/AnvilStats/.gitignore +++ b/Tools/AnvilStats/.gitignore @@ -1,3 +1,7 @@ +*.vcproj +*.vcxproj +*.sln +*.user .xls Statistics.txt *.bmp @@ -7,3 +11,4 @@ Profiling *.png world/ *.html +*.xls diff --git a/Tools/AnvilStats/AnvilStats.sln b/Tools/AnvilStats/AnvilStats.sln deleted file mode 100644 index 46bed8969..000000000 --- a/Tools/AnvilStats/AnvilStats.sln +++ /dev/null @@ -1,55 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnvilStats", "AnvilStats.vcxproj", "{CF996A5E-0A86-4004-9710-682B06B5AEBA}" - ProjectSection(ProjectDependencies) = postProject - {B61007AC-B557-4B67-A765-E468C0C3A821} = {B61007AC-B557-4B67-A765-E468C0C3A821} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\lib\zlib\zlib.vcxproj", "{B61007AC-B557-4B67-A765-E468C0C3A821}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - DebugProfile|Win32 = DebugProfile|Win32 - MinSizeRel|Win32 = MinSizeRel|Win32 - Release profiled|Win32 = Release profiled|Win32 - Release|Win32 = Release|Win32 - ReleaseProfile|Win32 = ReleaseProfile|Win32 - RelWithDebInfo|Win32 = RelWithDebInfo|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Debug|Win32.ActiveCfg = Debug|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Debug|Win32.Build.0 = Debug|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.DebugProfile|Win32.ActiveCfg = Debug|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.DebugProfile|Win32.Build.0 = Debug|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.MinSizeRel|Win32.ActiveCfg = Release|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.MinSizeRel|Win32.Build.0 = Release|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release profiled|Win32.Build.0 = Release profiled|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release|Win32.ActiveCfg = Release|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.Release|Win32.Build.0 = Release|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.ReleaseProfile|Win32.ActiveCfg = Release|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.ReleaseProfile|Win32.Build.0 = Release|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32 - {CF996A5E-0A86-4004-9710-682B06B5AEBA}.RelWithDebInfo|Win32.Build.0 = Release|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.Debug|Win32.ActiveCfg = Debug|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.Debug|Win32.Build.0 = Debug|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.DebugProfile|Win32.ActiveCfg = DebugProfile|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.DebugProfile|Win32.Build.0 = DebugProfile|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.Release profiled|Win32.ActiveCfg = Release|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.Release profiled|Win32.Build.0 = Release|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.Release|Win32.ActiveCfg = Release|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.Release|Win32.Build.0 = Release|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.ReleaseProfile|Win32.ActiveCfg = ReleaseProfile|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.ReleaseProfile|Win32.Build.0 = ReleaseProfile|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32 - {B61007AC-B557-4B67-A765-E468C0C3A821}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Tools/AnvilStats/AnvilStats.vcproj b/Tools/AnvilStats/AnvilStats.vcproj deleted file mode 100644 index c7a2e9390..000000000 --- a/Tools/AnvilStats/AnvilStats.vcproj +++ /dev/null @@ -1,468 +0,0 @@ -<?xml version="1.0" encoding="windows-1250"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9,00" - Name="AnvilStats" - ProjectGUID="{CF996A5E-0A86-4004-9710-682B06B5AEBA}" - RootNamespace="AnvilStats" - Keyword="Win32Proj" - TargetFrameworkVersion="196613" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="$(SolutionDir)$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="1" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories=""..\..\lib"" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - UsePrecompiledHeader="2" - PrecompiledHeaderThrough="Globals.h" - WarningLevel="3" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="ws2_32.lib" - LinkIncremental="2" - GenerateDebugInformation="true" - SubSystem="1" - StackReserveSize="16777216" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="$(SolutionDir)$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="1" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories=""..\..\lib"" - PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="2" - PrecompiledHeaderThrough="Globals.h" - WarningLevel="3" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="ws2_32.lib" - LinkIncremental="1" - GenerateDebugInformation="true" - SubSystem="1" - StackReserveSize="16777216" - OptimizeReferences="2" - EnableCOMDATFolding="2" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release profiled|Win32" - OutputDirectory="$(SolutionDir)$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="1" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories=""..\..\lib"" - PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="2" - PrecompiledHeaderThrough="Globals.h" - WarningLevel="3" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="ws2_32.lib" - LinkIncremental="1" - GenerateDebugInformation="true" - SubSystem="1" - StackReserveSize="16777216" - OptimizeReferences="2" - EnableCOMDATFolding="2" - TargetMachine="1" - Profile="true" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" - > - <File - RelativePath=".\AnvilStats.cpp" - > - </File> - <File - RelativePath=".\BiomeMap.cpp" - > - </File> - <File - RelativePath=".\BiomeMap.h" - > - </File> - <File - RelativePath=".\Callback.h" - > - </File> - <File - RelativePath=".\ChunkExtract.cpp" - > - </File> - <File - RelativePath=".\ChunkExtract.h" - > - </File> - <File - RelativePath=".\Globals.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1" - /> - </FileConfiguration> - <FileConfiguration - Name="Release profiled|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1" - /> - </FileConfiguration> - </File> - <File - RelativePath=".\Globals.h" - > - </File> - <File - RelativePath=".\HeightBiomeMap.cpp" - > - </File> - <File - RelativePath=".\HeightBiomeMap.h" - > - </File> - <File - RelativePath=".\HeightMap.cpp" - > - </File> - <File - RelativePath=".\HeightMap.h" - > - </File> - <File - RelativePath=".\ImageComposingCallback.cpp" - > - </File> - <File - RelativePath=".\ImageComposingCallback.h" - > - </File> - <File - RelativePath=".\Processor.cpp" - > - </File> - <File - RelativePath=".\Processor.h" - > - </File> - <File - RelativePath=".\SpringStats.cpp" - > - </File> - <File - RelativePath=".\SpringStats.h" - > - </File> - <File - RelativePath=".\Statistics.cpp" - > - </File> - <File - RelativePath=".\Statistics.h" - > - </File> - <File - RelativePath=".\Utils.cpp" - > - </File> - <File - RelativePath=".\Utils.h" - > - </File> - </Filter> - <Filter - Name="shared" - > - <File - RelativePath="..\..\src\OSSupport\CriticalSection.cpp" - > - </File> - <File - RelativePath="..\..\src\OSSupport\CriticalSection.h" - > - </File> - <File - RelativePath="..\..\src\Endianness.h" - > - </File> - <File - RelativePath="..\..\src\OSSupport\Event.cpp" - > - </File> - <File - RelativePath="..\..\src\OSSupport\Event.h" - > - </File> - <File - RelativePath="..\..\src\WorldStorage\FastNBT.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="NBT_RESERVE_SIZE=10000" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="NBT_RESERVE_SIZE=10000" - /> - </FileConfiguration> - <FileConfiguration - Name="Release profiled|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="NBT_RESERVE_SIZE=10000" - /> - </FileConfiguration> - </File> - <File - RelativePath="..\..\src\WorldStorage\FastNBT.h" - > - </File> - <File - RelativePath="..\..\src\OSSupport\File.cpp" - > - </File> - <File - RelativePath="..\..\src\OSSupport\File.h" - > - </File> - <File - RelativePath="..\..\src\OSSupport\GZipFile.cpp" - > - </File> - <File - RelativePath="..\..\src\OSSupport\GZipFile.h" - > - </File> - <File - RelativePath="..\..\src\OSSupport\IsThread.cpp" - > - </File> - <File - RelativePath="..\..\src\OSSupport\IsThread.h" - > - </File> - <File - RelativePath="..\..\src\StringUtils.cpp" - > - </File> - <File - RelativePath="..\..\src\StringUtils.h" - > - </File> - </Filter> - <File - RelativePath=".\AnvilStats.txt" - > - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/Tools/AnvilStats/CMakeLists.txt b/Tools/AnvilStats/CMakeLists.txt new file mode 100644 index 000000000..557a4c17a --- /dev/null +++ b/Tools/AnvilStats/CMakeLists.txt @@ -0,0 +1,144 @@ + +cmake_minimum_required (VERSION 2.8.3) + +project (AnvilStats) + +include(../../SetFlags.cmake) + +set_flags() +set_lib_flags() + + +# Set include paths to the used libraries: +include_directories("../../lib") +include_directories("../../src") + + + +function(flatten_files arg1) + set(res "") + foreach(f ${${arg1}}) + get_filename_component(f ${f} ABSOLUTE) + list(APPEND res ${f}) + endforeach() + set(${arg1} "${res}" PARENT_SCOPE) +endfunction() + +add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib) + +set_exe_flags() + +# Include the shared files: +set(SHARED_SRC + ../../src/ByteBuffer.cpp + ../../src/StringUtils.cpp + ../../src/LoggerListeners.cpp + ../../src/Logger.cpp + ../../src/WorldStorage/FastNBT.cpp + ../BiomeVisualiser/BiomeColors.cpp +) + +set(SHARED_HDR + ../../src/ByteBuffer.h + ../../src/StringUtils.h + ../../src/LoggerListeners.h + ../../src/Logger.h + ../../src/WorldStorage/FastNBT.h + ../BiomeVisualiser/BiomeColors.h +) + +set(SHARED_OSS_SRC + ../../src/OSSupport/CriticalSection.cpp + ../../src/OSSupport/Event.cpp + ../../src/OSSupport/File.cpp + ../../src/OSSupport/GZipFile.cpp + ../../src/OSSupport/IsThread.cpp + ../../src/OSSupport/Timer.cpp +) + +set(SHARED_OSS_HDR + ../../src/OSSupport/CriticalSection.h + ../../src/OSSupport/Event.h + ../../src/OSSupport/File.h + ../../src/OSSupport/GZipFile.h + ../../src/OSSupport/IsThread.h + ../../src/OSSupport/Timer.h +) + +flatten_files(SHARED_SRC) +flatten_files(SHARED_HDR) +flatten_files(SHARED_OSS_SRC) +flatten_files(SHARED_OSS_HDR) +source_group("Shared" FILES ${SHARED_SRC} ${SHARED_HDR}) +source_group("Shared\\OSSupport" FILES ${SHARED_OSS_SRC} ${SHARED_OSS_HDR}) + + + +# Include the main source files: +set(SOURCES + AnvilStats.cpp + BiomeMap.cpp + ChunkExtract.cpp + Globals.cpp + HeightBiomeMap.cpp + HeightMap.cpp + ImageComposingCallback.cpp + Processor.cpp + SpringStats.cpp + Statistics.cpp + Utils.cpp +) + +set(HEADERS + BiomeMap.h + Callback.h + ChunkExtract.h + Globals.h + HeightBiomeMap.h + HeightMap.h + ImageComposingCallback.h + Processor.h + SpringStats.h + Statistics.h + Utils.h + + AnvilStats.txt +) + +source_group("" FILES ${SOURCES} ${HEADERS}) + +add_definitions(-DNBT_RESERVE_SIZE=10000) + +add_executable(AnvilStats + ${SOURCES} + ${HEADERS} + ${SHARED_SRC} + ${SHARED_HDR} + ${SHARED_OSS_SRC} + ${SHARED_OSS_HDR} +) + + +target_link_libraries(AnvilStats zlib) + + + + + +# Under MSVC we need to enlarge the default stack size for the executable: +if (MSVC) + get_target_property(TEMP AnvilStats LINK_FLAGS) + if (TEMP STREQUAL "TEMP-NOTFOUND") + SET(TEMP "") # set to empty string + message("LINKER_FLAGS not found") + else () + SET(TEMP "${TEMP} ") # a space to cleanly separate from existing content + message("LINKER_FLAGS: ${LINKER_FLAGS}") + endif () + # append our values + SET(TEMP "${TEMP}/STACK:16777216") + set_target_properties(AnvilStats PROPERTIES LINK_FLAGS ${TEMP}) +endif () + + + diff --git a/Tools/AnvilStats/Globals.h b/Tools/AnvilStats/Globals.h index df1430cc4..21d54739a 100644 --- a/Tools/AnvilStats/Globals.h +++ b/Tools/AnvilStats/Globals.h @@ -241,6 +241,17 @@ public: +/** Clamp value to the specified range. */ +template <typename T> +T Clamp(T a_Value, T a_Min, T a_Max) +{ + return (a_Value < a_Min) ? a_Min : ((a_Value > a_Max) ? a_Max : a_Value); +} + + + + + // Common headers (part 2, with macros): #include "../../src/ChunkDef.h" #include "../../src/BlockID.h" diff --git a/Tools/AnvilStats/Processor.cpp b/Tools/AnvilStats/Processor.cpp index a16f78c18..6c4bb0ad5 100644 --- a/Tools/AnvilStats/Processor.cpp +++ b/Tools/AnvilStats/Processor.cpp @@ -28,6 +28,7 @@ cProcessor::cThread::cThread(cCallback & a_Callback, cProcessor & a_ParentProces m_Callback(a_Callback), m_ParentProcessor(a_ParentProcessor) { + LOG("Created a new thread: %p", this); super::Start(); } @@ -35,11 +36,20 @@ cProcessor::cThread::cThread(cCallback & a_Callback, cProcessor & a_ParentProces +void cProcessor::cThread::WaitForStart(void) +{ + m_HasStarted.Wait(); +} + + + + + void cProcessor::cThread::Execute(void) { - LOG("Started a new thread: %d", cIsThread::GetCurrentID()); + LOG("Started a new thread: %p, ID %d", this, cIsThread::GetCurrentID()); - m_ParentProcessor.m_ThreadsHaveStarted.Set(); + m_HasStarted.Set(); for (;;) { @@ -52,7 +62,7 @@ void cProcessor::cThread::Execute(void) ProcessFile(FileName); } // for-ever - LOG("Thread %d terminated", cIsThread::GetCurrentID()); + LOG("Thread %p (ID %d) terminated", this, cIsThread::GetCurrentID()); } @@ -522,20 +532,18 @@ void cProcessor::ProcessWorld(const AString & a_WorldFolder, cCallbackFactory & #endif // _DEBUG //*/ + // Start all the threads: for (int i = 0; i < NumThreads; i++) { cCallback * Callback = a_CallbackFactory.GetNewCallback(); m_Threads.push_back(new cThread(*Callback, *this)); } - // Wait for the first thread to start processing: - m_ThreadsHaveStarted.Wait(); - - // Wait for all threads to finish - // simply by calling each thread's destructor sequentially + // Wait for all threads to finish: LOG("Waiting for threads to finish"); for (cThreads::iterator itr = m_Threads.begin(), end = m_Threads.end(); itr != end; ++itr) { + (*itr)->WaitForStart(); delete *itr; } // for itr - m_Threads[] LOG("Processor finished"); diff --git a/Tools/AnvilStats/Processor.h b/Tools/AnvilStats/Processor.h index 72fea3081..db50ec619 100644 --- a/Tools/AnvilStats/Processor.h +++ b/Tools/AnvilStats/Processor.h @@ -30,6 +30,7 @@ class cProcessor cCallback & m_Callback; cProcessor & m_ParentProcessor; + cEvent m_HasStarted; // cIsThread override: virtual void Execute(void) override; @@ -48,6 +49,9 @@ class cProcessor public: cThread(cCallback & a_Callback, cProcessor & a_ParentProcessor); + + /** Waits until the thread starts processing the callback code. */ + void WaitForStart(void); } ; typedef std::vector<cThread *> cThreads; @@ -65,10 +69,12 @@ protected: AStringList m_FileQueue; cThreads m_Threads; - cEvent m_ThreadsHaveStarted; // This is signalled by each thread to notify the parent thread that it can start waiting for those threads - + + + /** Populates m_FileQueue with Anvil files from the specified folder. */ void PopulateFileQueue(const AString & a_WorldFolder); + /** Returns one filename from m_FileQueue, and removes the name from the queue. */ AString GetOneFileName(void); } ; diff --git a/Tools/AnvilStats/Statistics.cpp b/Tools/AnvilStats/Statistics.cpp index f7519fd37..c8a98b488 100644 --- a/Tools/AnvilStats/Statistics.cpp +++ b/Tools/AnvilStats/Statistics.cpp @@ -26,9 +26,11 @@ cStatistics::cStats::cStats(void) : m_MinChunkZ(0x7fffffff), m_MaxChunkZ(0x80000000) { - memset(m_BiomeCounts, 0, sizeof(m_BiomeCounts)); - memset(m_BlockCounts, 0, sizeof(m_BlockCounts)); - memset(m_SpawnerEntity, 0, sizeof(m_SpawnerEntity)); + memset(m_BiomeCounts, 0, sizeof(m_BiomeCounts)); + memset(m_BlockCounts, 0, sizeof(m_BlockCounts)); + memset(m_PerHeightBlockCounts, 0, sizeof(m_PerHeightBlockCounts)); + memset(m_PerHeightSpawners, 0, sizeof(m_PerHeightSpawners)); + memset(m_SpawnerEntity, 0, sizeof(m_SpawnerEntity)); } @@ -46,6 +48,11 @@ void cStatistics::cStats::Add(const cStatistics::cStats & a_Stats) for (int j = 0; j <= 255; j++) { m_BlockCounts[i][j] += a_Stats.m_BlockCounts[i][j]; + m_PerHeightBlockCounts[i][j] += a_Stats.m_PerHeightBlockCounts[i][j]; + } + for (int j = 0; j < ARRAYCOUNT(m_PerHeightSpawners[0]); j++) + { + m_PerHeightSpawners[i][j] += a_Stats.m_PerHeightSpawners[i][j]; } } for (int i = 0; i < ARRAYCOUNT(m_SpawnerEntity); i++) @@ -149,6 +156,7 @@ bool cStatistics::OnSection for (int y = 0; y < 16; y++) { + int Height = (int)a_Y * 16 + y; for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) @@ -156,6 +164,7 @@ bool cStatistics::OnSection unsigned char Biome = m_BiomeData[x + 16 * z]; // Cannot use cChunkDef, different datatype unsigned char BlockType = cChunkDef::GetBlock(a_BlockTypes, x, y, z); m_Stats.m_BlockCounts[Biome][BlockType] += 1; + m_Stats.m_PerHeightBlockCounts[Height][BlockType] += 1; } } } @@ -259,16 +268,27 @@ bool cStatistics::OnTileTick( void cStatistics::OnSpawner(cParsedNBT & a_NBT, int a_TileEntityTag) { + // Get the spawned entity type: int EntityIDTag = a_NBT.FindChildByName(a_TileEntityTag, "EntityId"); if ((EntityIDTag < 0) || (a_NBT.GetType(EntityIDTag) != TAG_String)) { return; } eEntityType Ent = GetEntityType(a_NBT.GetString(EntityIDTag)); - if (Ent < ARRAYCOUNT(m_Stats.m_SpawnerEntity)) + if (Ent >= ARRAYCOUNT(m_Stats.m_SpawnerEntity)) { - m_Stats.m_SpawnerEntity[Ent] += 1; + return; + } + m_Stats.m_SpawnerEntity[Ent] += 1; + + // Get the spawner pos: + int PosYTag = a_NBT.FindChildByName(a_TileEntityTag, "y"); + if ((PosYTag < 0) || (a_NBT.GetType(PosYTag) != TAG_Int)) + { + return; } + int BlockY = Clamp(a_NBT.GetInt(PosYTag), 0, 255); + m_Stats.m_PerHeightSpawners[BlockY][Ent] += 1; } @@ -316,10 +336,14 @@ cStatisticsFactory::~cStatisticsFactory() SaveBiomes(); LOG(" BlockTypes.xls"); SaveBlockTypes(); + LOG(" PerHeightBlockTypes.xls"); + SavePerHeightBlockTypes(); LOG(" BiomeBlockTypes.xls"); SaveBiomeBlockTypes(); LOG(" Spawners.xls"); SaveSpawners(); + LOG(" PerHeightSpawners.xls"); + SavePerHeightSpawners(); } @@ -395,6 +419,61 @@ void cStatisticsFactory::SaveBlockTypes(void) +void cStatisticsFactory::SavePerHeightBlockTypes(void) +{ + // Export as two tables: biomes 0-127 and 128-255, because OpenOffice doesn't support more than 256 columns + + cFile f; + if (!f.Open("PerHeightBlockTypes.xls", cFile::fmWrite)) + { + LOG("Cannot write to file PerHeightBlockTypes.xls. Statistics not written."); + return; + } + + // Write header: + f.Printf("Blocks 0 - 127:\nHeight"); + for (int i = 0; i < 128; i++) + { + f.Printf("\t%s(%d)", GetBlockTypeString(i), i); + } + f.Printf("\n"); + + // Write first half: + for (int y = 0; y < 256; y++) + { + f.Printf("%d", y); + for (int BlockType = 0; BlockType < 128; BlockType++) + { + f.Printf("\t%llu", m_CombinedStats.m_PerHeightBlockCounts[y][BlockType]); + } // for BlockType + f.Printf("\n"); + } // for y - height (0 - 127) + f.Printf("\n"); + + // Write second header: + f.Printf("Blocks 128 - 255:\nHeight"); + for (int i = 128; i < 256; i++) + { + f.Printf("\t%s(%d)", GetBlockTypeString(i), i); + } + f.Printf("\n"); + + // Write second half: + for (int y = 0; y < 256; y++) + { + f.Printf("%d", y); + for (int BlockType = 128; BlockType < 256; BlockType++) + { + f.Printf("\t%llu", m_CombinedStats.m_PerHeightBlockCounts[y][BlockType]); + } // for BlockType + f.Printf("\n"); + } // for y - height (0 - 127) +} + + + + + void cStatisticsFactory::SaveBiomeBlockTypes(void) { // Export as two tables: biomes 0-127 and 128-255, because OpenOffice doesn't support more than 256 columns @@ -521,3 +600,41 @@ void cStatisticsFactory::SaveSpawners(void) + +void cStatisticsFactory::SavePerHeightSpawners(void) +{ + cFile f; + if (!f.Open("PerHeightSpawners.xls", cFile::fmWrite)) + { + LOG("Cannot write to file PerHeightSpawners.xls. Statistics not written."); + return; + } + + // Write header: + f.Printf("Height\tTotal"); + for (int i = 0; i < entMax; i++) + { + f.Printf("\t%s", GetEntityTypeString((eEntityType)i)); + } + f.Printf("\n"); + + // Write individual lines: + for (int y = 0; y < 256; y++) + { + UInt64 Total = 0; + for (int i = 0; i < entMax; i++) + { + Total += m_CombinedStats.m_PerHeightSpawners[y][i]; + } + f.Printf("%d\t%llu", y, Total); + for (int i = 0; i < entMax; i++) + { + f.Printf("\t%llu", m_CombinedStats.m_PerHeightSpawners[y][i]); + } + f.Printf("\n"); + } +} + + + + diff --git a/Tools/AnvilStats/Statistics.h b/Tools/AnvilStats/Statistics.h index 53e353f22..1b012e283 100644 --- a/Tools/AnvilStats/Statistics.h +++ b/Tools/AnvilStats/Statistics.h @@ -31,6 +31,8 @@ public: UInt64 m_NumEntities; UInt64 m_NumTileEntities; UInt64 m_NumTileTicks; + UInt64 m_PerHeightBlockCounts[256][256]; // First dimension is the height, second dimension is BlockType + UInt64 m_PerHeightSpawners[256][entMax + 1]; // First dimension is the height, second dimension is spawned entity type int m_MinChunkX, m_MaxChunkX; // X coords range int m_MinChunkZ, m_MaxChunkZ; // Z coords range @@ -74,6 +76,8 @@ protected: virtual bool OnEmptySection(unsigned char a_Y) override; + virtual bool OnSectionsFinished(void) override { return false; } // continue processing + virtual bool OnEntity( const AString & a_EntityType, double a_PosX, double a_PosY, double a_PosZ, @@ -128,9 +132,11 @@ protected: void JoinResults(void); void SaveBiomes(void); void SaveBlockTypes(void); + void SavePerHeightBlockTypes(void); void SaveBiomeBlockTypes(void); void SaveStatistics(void); void SaveSpawners(void); + void SavePerHeightSpawners(void); } ; diff --git a/Tools/AnvilStats/Utils.cpp b/Tools/AnvilStats/Utils.cpp index baa87bd69..d7543cb4c 100644 --- a/Tools/AnvilStats/Utils.cpp +++ b/Tools/AnvilStats/Utils.cpp @@ -272,7 +272,7 @@ extern const char * GetEntityTypeString(eEntityType a_EntityType) int GetNumCores(void) { // Get number of cores by querying the system process affinity mask (Windows-specific) - DWORD Affinity, ProcAffinity; + DWORD_PTR Affinity, ProcAffinity; GetProcessAffinityMask(GetCurrentProcess(), &ProcAffinity, &Affinity); int NumCores = 0; while (Affinity > 0) diff --git a/Tools/MCADefrag/CMakeLists.txt b/Tools/MCADefrag/CMakeLists.txt index 2a021049f..42b42018b 100644 --- a/Tools/MCADefrag/CMakeLists.txt +++ b/Tools/MCADefrag/CMakeLists.txt @@ -39,14 +39,12 @@ set_exe_flags() set(SHARED_SRC ../../src/StringCompression.cpp ../../src/StringUtils.cpp - ../../src/Log.cpp - ../../src/MCLogger.cpp + ../../src/LoggerListeners.cpp + ../../src/Logger.cpp ) set(SHARED_HDR ../../src/ByteBuffer.h ../../src/StringUtils.h - ../../src/Log.h - ../../src/MCLogger.h ) flatten_files(SHARED_SRC) flatten_files(SHARED_HDR) diff --git a/Tools/MCADefrag/MCADefrag.cpp b/Tools/MCADefrag/MCADefrag.cpp index a2de7f957..d5d233fd2 100644 --- a/Tools/MCADefrag/MCADefrag.cpp +++ b/Tools/MCADefrag/MCADefrag.cpp @@ -5,7 +5,8 @@ #include "Globals.h" #include "MCADefrag.h" -#include "MCLogger.h" +#include "Logger.h" +#include "LoggerListeners.h" #include "zlib/zlib.h" @@ -21,7 +22,13 @@ static const Byte g_Zeroes[4096] = {0}; int main(int argc, char ** argv) { - new cMCLogger(Printf("Defrag_%08x.log", time(NULL))); + cLogger::cListener * consoleLogListener = MakeConsoleListener(); + cLogger::cListener * fileLogListener = new cFileListener(); + cLogger::GetInstance().AttachListener(consoleLogListener); + cLogger::GetInstance().AttachListener(fileLogListener); + + cLogger::InitiateMultithreading(); + cMCADefrag Defrag; if (!Defrag.Init(argc, argv)) { @@ -30,6 +37,11 @@ int main(int argc, char ** argv) Defrag.Run(); + cLogger::GetInstance().DetachListener(consoleLogListener); + delete consoleLogListener; + cLogger::GetInstance().DetachListener(fileLogListener); + delete fileLogListener; + return 0; } diff --git a/Tools/ProtoProxy/CMakeLists.txt b/Tools/ProtoProxy/CMakeLists.txt index f0796363c..bc3923d90 100644 --- a/Tools/ProtoProxy/CMakeLists.txt +++ b/Tools/ProtoProxy/CMakeLists.txt @@ -34,20 +34,18 @@ set_exe_flags() set(SHARED_SRC ../../src/ByteBuffer.cpp ../../src/StringUtils.cpp - ../../src/Log.cpp - ../../src/MCLogger.cpp ../../src/PolarSSL++/AesCfb128Decryptor.cpp ../../src/PolarSSL++/AesCfb128Encryptor.cpp ../../src/PolarSSL++/CryptoKey.cpp ../../src/PolarSSL++/CtrDrbgContext.cpp ../../src/PolarSSL++/EntropyContext.cpp ../../src/PolarSSL++/RsaPrivateKey.cpp + ../../src/LoggerListeners.cpp + ../../src/Logger.cpp ) set(SHARED_HDR ../../src/ByteBuffer.h ../../src/StringUtils.h - ../../src/Log.h - ../../src/MCLogger.h ../../src/PolarSSL++/AesCfb128Decryptor.h ../../src/PolarSSL++/AesCfb128Encryptor.h ../../src/PolarSSL++/CryptoKey.h |