Root: Load the UpgradeBlockTypePalette on startup.
This commit is contained in:
parent
208313dba1
commit
b63bb2f694
19
src/Root.cpp
19
src/Root.cpp
@ -39,6 +39,7 @@
|
|||||||
#include "OverridesSettingsRepository.h"
|
#include "OverridesSettingsRepository.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "ClientHandle.h"
|
#include "ClientHandle.h"
|
||||||
|
#include "BlockTypePalette.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -192,6 +193,24 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
|
|||||||
// cClientHandle::FASTBREAK_PERCENTAGE = settingsRepo->GetValueSetI("AntiCheat", "FastBreakPercentage", 97) / 100.0f;
|
// 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.
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
m_MojangAPI = new cMojangAPI;
|
m_MojangAPI = new cMojangAPI;
|
||||||
bool ShouldAuthenticate = settingsRepo->GetValueSetB("Authentication", "Authenticate", true);
|
bool ShouldAuthenticate = settingsRepo->GetValueSetB("Authentication", "Authenticate", true);
|
||||||
m_MojangAPI->Start(*settingsRepo, ShouldAuthenticate); // Mojang API needs to be started before plugins, so that plugins may use it for DB upgrades on server init
|
m_MojangAPI->Start(*settingsRepo, ShouldAuthenticate); // Mojang API needs to be started before plugins, so that plugins may use it for DB upgrades on server init
|
||||||
|
@ -28,6 +28,7 @@ class cCompositeChat;
|
|||||||
class cSettingsRepositoryInterface;
|
class cSettingsRepositoryInterface;
|
||||||
class cDeadlockDetect;
|
class cDeadlockDetect;
|
||||||
class cUUID;
|
class cUUID;
|
||||||
|
class BlockTypePalette;
|
||||||
|
|
||||||
using cPlayerListCallback = cFunctionRef<bool(cPlayer &)>;
|
using cPlayerListCallback = cFunctionRef<bool(cPlayer &)>;
|
||||||
using cWorldListCallback = cFunctionRef<bool(cWorld &)>;
|
using cWorldListCallback = cFunctionRef<bool(cWorld &)>;
|
||||||
@ -92,6 +93,9 @@ public:
|
|||||||
/** Returns the (read-write) storage for registered block types. */
|
/** Returns the (read-write) storage for registered block types. */
|
||||||
BlockTypeRegistry & GetBlockTypeRegistry() { return m_BlockTypeRegistry; }
|
BlockTypeRegistry & GetBlockTypeRegistry() { return m_BlockTypeRegistry; }
|
||||||
|
|
||||||
|
/** Returns the block type palette used for upgrading blocks from pre-1.13 data. */
|
||||||
|
const BlockTypePalette & GetUpgradeBlockTypePalette() const { return *m_UpgradeBlockTypePalette; }
|
||||||
|
|
||||||
/** Returns the number of ticks for how long the item would fuel a furnace. Returns zero if not a fuel */
|
/** Returns the number of ticks for how long the item would fuel a furnace. Returns zero if not a fuel */
|
||||||
static int GetFurnaceFuelBurnTime(const cItem & a_Fuel); // tolua_export
|
static int GetFurnaceFuelBurnTime(const cItem & a_Fuel); // tolua_export
|
||||||
|
|
||||||
@ -234,6 +238,9 @@ private:
|
|||||||
/** The storage for all registered block types. */
|
/** The storage for all registered block types. */
|
||||||
BlockTypeRegistry m_BlockTypeRegistry;
|
BlockTypeRegistry m_BlockTypeRegistry;
|
||||||
|
|
||||||
|
/** The upgrade palette for pre-1.13 blocks. */
|
||||||
|
std::unique_ptr<BlockTypePalette> m_UpgradeBlockTypePalette;
|
||||||
|
|
||||||
|
|
||||||
void LoadGlobalSettings();
|
void LoadGlobalSettings();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user