summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Protocol/CMakeLists.txt2
-rw-r--r--src/Protocol/ProtocolPalettes.cpp107
-rw-r--r--src/Protocol/ProtocolPalettes.h63
-rw-r--r--src/Root.cpp43
-rw-r--r--src/Root.h16
5 files changed, 0 insertions, 231 deletions
diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt
index cc96f1878..f3d0e1901 100644
--- a/src/Protocol/CMakeLists.txt
+++ b/src/Protocol/CMakeLists.txt
@@ -12,7 +12,6 @@ target_sources(
Protocol_1_11.cpp
Protocol_1_12.cpp
Protocol_1_13.cpp
- ProtocolPalettes.cpp
ProtocolRecognizer.cpp
RecipeMapper.cpp
@@ -28,7 +27,6 @@ target_sources(
Protocol_1_11.h
Protocol_1_12.h
Protocol_1_13.h
- ProtocolPalettes.h
ProtocolRecognizer.h
RecipeMapper.h
)
diff --git a/src/Protocol/ProtocolPalettes.cpp b/src/Protocol/ProtocolPalettes.cpp
deleted file mode 100644
index 2dc0857a9..000000000
--- a/src/Protocol/ProtocolPalettes.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-#include "Globals.h"
-#include "ProtocolPalettes.h"
-#include "../BlockTypePalette.h"
-
-
-
-
-
-void ProtocolPalettes::load(const AString & aProtocolFolder)
-{
- auto contents = cFile::GetFolderContents(aProtocolFolder);
- for (const auto & c: contents)
- {
- auto fullName = aProtocolFolder + cFile::PathSeparator() + c;
- if (cFile::IsFolder(fullName))
- {
- loadSingleVersion(c, fullName);
- }
- }
-}
-
-
-
-
-
-std::shared_ptr<const BlockTypePalette> ProtocolPalettes::blockTypePalette(const AString & aProtocolVersion) const
-{
- cCSLock lock(mCS);
- auto itr = mPalettes.find(aProtocolVersion);
- if (itr == mPalettes.end())
- {
- return nullptr;
- }
- return itr->second.mBlockTypePalette;
-}
-
-
-
-
-
-std::vector<AString> ProtocolPalettes::protocolVersions() const
-{
- cCSLock lock(mCS);
-
- std::vector<AString> res;
- for (const auto & p: mPalettes)
- {
- res.push_back(p.first);
- }
- return res;
-}
-
-
-
-
-
-void ProtocolPalettes::loadSingleVersion(const AString & aProtocolVersion, const AString & aFolder)
-{
- // Get the file list, sort by name
- auto contents = cFile::GetFolderContents(aFolder);
- std::sort(contents.begin(), contents.end());
-
- // Load files into the palettes:
- cCSLock lock(mCS);
- auto & pal = mPalettes[aProtocolVersion];
- for (const auto & c: contents)
- {
- if (c.length() < 8)
- {
- // Name too short, can't have the ".btp.txt" etc. suffix
- continue;
- }
- auto fnam = aFolder + cFile::PathSeparator() + c;
- if (!cFile::IsFile(fnam))
- {
- continue;
- }
- auto fileType = c.substr(c.length() - 8);
- if ((fileType == ".btp.txt") || (c == "blocks.json"))
- {
- try
- {
- pal.mBlockTypePalette->loadFromString(cFile::ReadWholeFile(fnam));
- }
- catch (...)
- {
- // Ignore silently
- }
- }
- else if ((fileType == ".itp.txt") || (c == "items.json"))
- {
- // TODO: Load item type palette
- }
- }
-}
-
-
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-// ProtocolPalettes::Palettes:
-
-ProtocolPalettes::Palettes::Palettes():
- mBlockTypePalette(new BlockTypePalette)
-{
-}
diff --git a/src/Protocol/ProtocolPalettes.h b/src/Protocol/ProtocolPalettes.h
deleted file mode 100644
index fad093a04..000000000
--- a/src/Protocol/ProtocolPalettes.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#pragma once
-
-#include "../OSSupport/CriticalSection.h"
-
-
-
-
-
-// fwd:
-class BlockTypePalette;
-
-
-
-
-
-/** Loads the protocol-specific palettes on startup and provides them to the individual protocol
-instances when they are created.
-Uses the data in the $/Server/Protocol folder. Each protocol version has a subfolder there,
-containing possibly multiple palette files. All the files are loaded in sequence (alpha-sorted),
-into the palette corresponding to the file's extension (*.btp.txt -> BlockTypePalette).
-Provides thread safety for the data properly. */
-class ProtocolPalettes
-{
-public:
-
- /** Loads all the per-protocol palettes.
- aProtocolFolder is the folder that contains a subfolder for each protocol version;
- each subfolder contains the protocol-specific palettes (as in $/Server/Protocol)
- If a protocol version is already loaded, yet present in the folder, the newly loaded data is merged
- into the current data.
- Always succeeds (even when there are no palettes). */
- void load(const AString & aProtocolFolder);
-
- /** Returns the BlockTypePalette for the specified protocol.
- Returns nullptr if no such palette has been loaded. */
- std::shared_ptr<const BlockTypePalette> blockTypePalette(const AString & aProtocolVersion) const;
-
- /** Returns the version names of all protocols that have been loaded. */
- std::vector<AString> protocolVersions() const;
-
-
-protected:
-
- /** Container for all palettes for a single protocol. */
- struct Palettes
- {
- std::shared_ptr<BlockTypePalette> mBlockTypePalette;
- // TODO: ItemTypePalette
-
- Palettes();
- };
-
-
- /** The CS protecting all members against multithreaded access. */
- mutable cCriticalSection mCS;
-
- /** The map of protocol version -> all its palettes. */
- std::map<AString, Palettes> mPalettes;
-
-
- /** Loads all the palettes from the specified folder into mPalettes under the aProtocolVersion key. */
- void loadSingleVersion(const AString & aProtocolVersion, const AString & aFolder);
-};
diff --git a/src/Root.cpp b/src/Root.cpp
index e2d4f71c3..8b8df817d 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -41,7 +41,6 @@
#include "Logger.h"
#include "ClientHandle.h"
#include "BlockTypePalette.h"
-#include "Protocol/ProtocolPalettes.h"
@@ -398,48 +397,6 @@ 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)
diff --git a/src/Root.h b/src/Root.h
index 2092bb9be..2610d28b8 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -97,12 +97,6 @@ public:
/** Returns the (read-write) storage for registered block types. */
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 per-protocol palettes manager. */
- ProtocolPalettes & GetProtocolPalettes() const { return *m_ProtocolPalettes; }
-
/** 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
@@ -246,19 +240,9 @@ private:
/** The storage for all registered block types. */
BlockTypeRegistry m_BlockTypeRegistry;
- /** The upgrade palette for pre-1.13 blocks. */
- std::unique_ptr<BlockTypePalette> m_UpgradeBlockTypePalette;
-
- /** The per-protocol palettes manager. */
- std::unique_ptr<ProtocolPalettes> m_ProtocolPalettes;
-
void LoadGlobalSettings();
- /** Loads the upgrade palette and the per-protocol palettes.
- The aProtocolFolder is the path to the folder containing the per-protocol palettes. */
- void LoadPalettes(const AString & aProtocolFolder);
-
/** Loads the worlds from settings.ini, creates the worldmap */
void LoadWorlds(cDeadlockDetect & a_dd, cSettingsRepositoryInterface & a_Settings, bool a_IsNewIniFile);