summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-01-03 17:31:13 +0100
committerMattes D <github@xoft.cz>2020-01-07 06:53:17 +0100
commit4aef80b47eb6941d7fc41e57efe147af0ece1f9b (patch)
tree4aeb7c9e8e4aa3ae2ceed1cc60155d868852c5cd /src/Root.cpp
parentStringUtils: Added note to StringsConcat about StringJoin. (diff)
downloadcuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.gz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.bz2
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.lz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.xz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.zst
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.zip
Diffstat (limited to 'src/Root.cpp')
-rw-r--r--src/Root.cpp61
1 files changed, 44 insertions, 17 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index 0869192b8..8ccf55d47 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -40,6 +40,7 @@
#include "Logger.h"
#include "ClientHandle.h"
#include "BlockTypePalette.h"
+#include "Protocol/ProtocolPalettes.h"
@@ -193,23 +194,7 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
// cClientHandle::FASTBREAK_PERCENTAGE = settingsRepo->GetValueSetI("AntiCheat", "FastBreakPercentage", 97) / 100.0f;
cClientHandle::FASTBREAK_PERCENTAGE = 0; // AntiCheat disabled due to bugs. We will enabled it once they are fixed. See #3506.
- // Load the UpgradeBlockTypePalette:
- LOG("Loading UpgradeBlockTypePalette...");
- try
- {
- auto paletteStr = cFile::ReadWholeFile("Protocol/UpgradeBlockTypePalette.txt");
- if (paletteStr.empty())
- {
- throw std::runtime_error("File is empty");
- }
- m_UpgradeBlockTypePalette.reset(new BlockTypePalette);
- m_UpgradeBlockTypePalette->loadFromString(paletteStr);
- }
- catch (const std::exception & exc)
- {
- LOGERROR("Failed to load the Upgrade block type palette from Protocol/UpgradeBlockTypePalette.txt: %s\nAborting", exc.what());
- throw;
- }
+ LoadPalettes(settingsRepo->GetValueSet("Folders", "ProtocolPalettes", "Protocol"));
m_MojangAPI = new cMojangAPI;
bool ShouldAuthenticate = settingsRepo->GetValueSetB("Authentication", "Authenticate", true);
@@ -416,6 +401,48 @@ void cRoot::LoadGlobalSettings()
+void cRoot::LoadPalettes(const AString & aProtocolFolder)
+{
+ LOG("Loading UpgradeBlockTypePalette...");
+ try
+ {
+ auto paletteStr = cFile::ReadWholeFile(aProtocolFolder + cFile::PathSeparator() + "UpgradeBlockTypePalette.txt");
+ if (paletteStr.empty())
+ {
+ throw std::runtime_error("File is empty");
+ }
+ m_UpgradeBlockTypePalette.reset(new BlockTypePalette);
+ m_UpgradeBlockTypePalette->loadFromString(paletteStr);
+ }
+ catch (const std::exception & exc)
+ {
+ LOGERROR("Failed to load the Upgrade block type palette from %s/UpgradeBlockTypePalette.txt: %s\nAborting",
+ aProtocolFolder, exc.what()
+ );
+ throw;
+ }
+
+ // Note: This can take a lot of time in MSVC debug builds
+ // If impatient, edit the settings.ini: [Folders] ProtocolPalettes=DummyDir; copy only one palette to DummyDir
+ LOG("Loading per-protocol palettes...");
+ m_ProtocolPalettes.reset(new ProtocolPalettes);
+ m_ProtocolPalettes->load(aProtocolFolder);
+ auto versions = m_ProtocolPalettes->protocolVersions();
+ if (versions.empty())
+ {
+ LOGWARNING("No per-protocol palettes were loaded");
+ }
+ else
+ {
+ std::sort(versions.begin(), versions.end());
+ LOG("Loaded palettes for protocol versions: %s", StringJoin(versions, ", "));
+ }
+}
+
+
+
+
+
void cRoot::LoadWorlds(cDeadlockDetect & a_dd, cSettingsRepositoryInterface & a_Settings, bool a_IsNewIniFile)
{
if (a_IsNewIniFile)