summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
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)