1
0

Added temporary block type mapping for 1.13+ protocols.

This commit is contained in:
Mattes D
2020-01-03 17:31:13 +01:00
parent e234fbdafe
commit 4aef80b47e
16 changed files with 375 additions and 76 deletions

View File

@@ -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)