From 1868e0ccf1beba675736c1d2c47579854110241e Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sat, 6 Feb 2021 15:58:03 +0100 Subject: GH-3229 fix copy seed button not working for newer worlds Added the `optional-bare` library and refactored NBT reading code to support this change. --- api/logic/minecraft/World.h | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'api/logic/minecraft/World.h') diff --git a/api/logic/minecraft/World.h b/api/logic/minecraft/World.h index d04c1040..ba7c357c 100644 --- a/api/logic/minecraft/World.h +++ b/api/logic/minecraft/World.h @@ -16,17 +16,27 @@ #pragma once #include #include +#include #include "multimc_logic_export.h" -enum class GameType -{ - Survival, - Creative, - Adventure, - Spectator +struct MULTIMC_LOGIC_EXPORT GameType { + GameType() = default; + GameType (nonstd::optional original); + + QString toTranslatedString() const; + QString toLogString() const; + + enum + { + Unknown = -1, + Survival = 0, + Creative, + Adventure, + Spectator + } type = Unknown; + nonstd::optional original; }; -QString MULTIMC_LOGIC_EXPORT gameTypeToString(GameType type); class MULTIMC_LOGIC_EXPORT World { @@ -98,6 +108,6 @@ protected: QDateTime levelDatTime; QDateTime m_lastPlayed; int64_t m_randomSeed = 0; - GameType m_gameType = GameType::Survival; + GameType m_gameType; bool is_valid = false; }; -- cgit