diff --git a/platforms/ios/minecraftpe-Info.plist b/platforms/ios/minecraftpe-Info.plist
index f257e8cdc..ef8fd2e60 100644
--- a/platforms/ios/minecraftpe-Info.plist
+++ b/platforms/ios/minecraftpe-Info.plist
@@ -5,7 +5,7 @@
CFBundleDevelopmentRegion
en
CFBundleDisplayName
- ReMinecraftPE
+ ReMCPE
CFBundleExecutable
${EXECUTABLE_NAME}
CFBundleIconFiles
@@ -36,8 +36,6 @@
UIStatusBarHidden
- UIViewControllerBasedStatusBarAppearance
-
UISupportedInterfaceOrientations
UIInterfaceOrientationLandscapeLeft
@@ -48,5 +46,7 @@
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
+ UIViewControllerBasedStatusBarAppearance
+
diff --git a/platforms/ios/minecraftpeViewController.mm b/platforms/ios/minecraftpeViewController.mm
index e34e212b0..132bd9732 100644
--- a/platforms/ios/minecraftpeViewController.mm
+++ b/platforms/ios/minecraftpeViewController.mm
@@ -285,9 +285,7 @@ - (void)initView
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDrawSize) name:UIDeviceOrientationDidChangeNotification object:nil];
/*Minecraft *mc = (Minecraft *)app;
- mc->selectLevel("TestWorld", "Test", (int)"iOS");
- mc->hostMultiplayer();
- mc->setScreen(new ProgressScreen);*/
+ mc->selectLevel("TestWorld", "Test", (int)"iOS");*/
}
- (NSInteger)animationFrameInterval
diff --git a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig
index 42a1a844f..4cf8f6948 100644
--- a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig
+++ b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig
@@ -18,5 +18,5 @@ SDKROOT = $(SDKROOT_IOS)
ARCHS_IOS = armv6 armv7 armv7s arm64
ARCHS = $(ARCHS_IOS)
-IPHONEOS_DEPLOYMENT_TARGET = 3.0 // iOS 3.0
+IPHONEOS_DEPLOYMENT_TARGET = 5.0 // iOS 3.0
TARGETED_DEVICE_FAMILY = 1,2 // iPhone/iPad
diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj
index b01f8f7e6..3e68c6c60 100644
--- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj
+++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj
@@ -1216,6 +1216,8 @@
84CCBC9E2E618C1D00E251AF /* libNBT.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CCBC452E61849800E251AF /* libNBT.a */; };
84CCBC9F2E61910500E251AF /* libClient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B8AEE72AF188D8008DE93D /* libClient.a */; };
84CCBCA02E61910500E251AF /* libWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BF630B2AF1859D008A9995 /* libWorld.a */; };
+ 84CED51F2E672826006BC585 /* ConvertWorldScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CED51D2E672826006BC585 /* ConvertWorldScreen.cpp */; };
+ 84CED5202E672826006BC585 /* ConvertWorldScreen.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CED51E2E672826006BC585 /* ConvertWorldScreen.hpp */; };
84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CEF0022AE3C97D006C5829 /* EAGLView.m */; };
84D9A30E2AF18EC000B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; };
84D9A30F2AF18EE700B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; settings = {ATTRIBUTES = (Required, ); }; };
@@ -2875,6 +2877,8 @@
84CCBC922E61880600E251AF /* EntityFactory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityFactory.hpp; sourceTree = ""; };
84CCBC952E61886800E251AF /* RakIO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RakIO.cpp; sourceTree = ""; };
84CCBC962E61886800E251AF /* RakIO.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RakIO.hpp; sourceTree = ""; };
+ 84CED51D2E672826006BC585 /* ConvertWorldScreen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertWorldScreen.cpp; sourceTree = ""; };
+ 84CED51E2E672826006BC585 /* ConvertWorldScreen.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConvertWorldScreen.hpp; sourceTree = ""; };
84CEF0012AE3C97D006C5829 /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EAGLView.h; sourceTree = ""; };
84CEF0022AE3C97D006C5829 /* EAGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EAGLView.m; sourceTree = ""; };
84D6694F2B1EAEBF00B34FC1 /* GlobalDebugSettings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GlobalDebugSettings.xcconfig; path = ../Configuration/GlobalDebugSettings.xcconfig; sourceTree = ""; };
@@ -3173,6 +3177,8 @@
840DD59E2AC810620006A435 /* ChatScreen.hpp */,
840DD59F2AC810620006A435 /* ConfirmScreen.cpp */,
840DD5A02AC810620006A435 /* ConfirmScreen.hpp */,
+ 84CED51D2E672826006BC585 /* ConvertWorldScreen.cpp */,
+ 84CED51E2E672826006BC585 /* ConvertWorldScreen.hpp */,
840DD5A12AC810620006A435 /* CreateWorldScreen.cpp */,
840DD5A22AC810620006A435 /* CreateWorldScreen.hpp */,
840DD5A32AC810620006A435 /* DeathScreen.cpp */,
@@ -5496,6 +5502,7 @@
84AA8C2B2B32F3F3003F5B82 /* LightUpdate.hpp in Headers */,
84AA8C2D2B32F3F3003F5B82 /* PatchManager.hpp in Headers */,
84AA8C2F2B32F3F3003F5B82 /* RenderChunk.hpp in Headers */,
+ 84CED5202E672826006BC585 /* ConvertWorldScreen.hpp in Headers */,
84A2FF162DB5B7B70090CE3E /* AssetFile.hpp in Headers */,
84AA8C312B32F3F3003F5B82 /* RenderList.hpp in Headers */,
84AA8C332B32F3F3003F5B82 /* Tesselator.hpp in Headers */,
@@ -6729,6 +6736,7 @@
84B8AEEF2AF1890A008DE93D /* ScrolledSelectionList.cpp in Sources */,
84B8AEF02AF1890A008DE93D /* SmallButton.cpp in Sources */,
84B8AEF12AF1890A008DE93D /* TextInputBox.cpp in Sources */,
+ 84CED51F2E672826006BC585 /* ConvertWorldScreen.cpp in Sources */,
84B8AEF22AF1890A008DE93D /* WorldSelectionList.cpp in Sources */,
84B8AEF32AF1890A008DE93D /* Gui.cpp in Sources */,
84B8AEF42AF1890A008DE93D /* GuiComponent.cpp in Sources */,
diff --git a/platforms/sdl/base/AppPlatform_sdl_base.cpp b/platforms/sdl/base/AppPlatform_sdl_base.cpp
index dcbecc134..cb28389c1 100644
--- a/platforms/sdl/base/AppPlatform_sdl_base.cpp
+++ b/platforms/sdl/base/AppPlatform_sdl_base.cpp
@@ -74,24 +74,6 @@ void AppPlatform_sdl_base::initSoundSystem()
}
}
-std::string AppPlatform_sdl_base::getDateString(int time)
-{
- time_t tt = time;
- struct tm t;
-#ifdef _WIN32
- gmtime_s(&t, &tt);
-#else
- gmtime_r(&tt, &t);
-#endif
-
- // Format String
- char buf[2048];
- strftime(buf, sizeof buf, "%b %d %Y %H:%M:%S", &t);
-
- // Return
- return std::string(buf);
-}
-
void AppPlatform_sdl_base::setIcon(const Texture& icon)
{
if (!icon.m_pixels)
diff --git a/platforms/sdl/base/AppPlatform_sdl_base.hpp b/platforms/sdl/base/AppPlatform_sdl_base.hpp
index 7fe614cef..4904edae6 100644
--- a/platforms/sdl/base/AppPlatform_sdl_base.hpp
+++ b/platforms/sdl/base/AppPlatform_sdl_base.hpp
@@ -28,7 +28,6 @@ class AppPlatform_sdl_base : public AppPlatform
Texture loadTexture(const std::string& path, bool bIsRequired = false) override = 0;
int getUserInputStatus() override;
SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; }
- std::string getDateString(int time) override;
// Also add these to allow proper turning within the game.
void setMouseGrabbed(bool b) override;
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index d8c9ad044..e6b5eff09 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -4,7 +4,7 @@ project(reminecraftpe-core)
# Build
add_library(reminecraftpe-core STATIC
common/CThread.cpp
- common/DataIO.cpp
+ common/DataIO.cpp
common/Logger.cpp
common/Matrix.cpp
common/Mth.cpp
@@ -70,6 +70,7 @@ add_library(reminecraftpe-core STATIC
client/gui/Screen.cpp
client/gui/screens/OptionsScreen.cpp
client/gui/screens/StartMenuScreen.cpp
+ client/gui/screens/ConvertWorldScreen.cpp
client/gui/screens/CreateWorldScreen.cpp
client/gui/screens/DirectConnectScreen.cpp
client/gui/screens/DisconnectionScreen.cpp
@@ -138,21 +139,21 @@ add_library(reminecraftpe-core STATIC
client/player/input/TouchscreenInput_TestFps.cpp
client/player/input/UnifiedTurnBuild.cpp
client/network/ClientSideNetworkHandler.cpp
- nbt/CompoundTag.cpp
- nbt/DoubleTag.cpp
- nbt/EndTag.cpp
- nbt/FloatTag.cpp
- nbt/Int8ArrayTag.cpp
- nbt/Int8Tag.cpp
- nbt/Int16Tag.cpp
- nbt/Int32ArrayTag.cpp
- nbt/Int32Tag.cpp
- nbt/Int64ArrayTag.cpp
- nbt/Int64Tag.cpp
- nbt/ListTag.cpp
- nbt/NbtIo.cpp
- nbt/StringTag.cpp
- nbt/Tag.cpp
+ nbt/CompoundTag.cpp
+ nbt/DoubleTag.cpp
+ nbt/EndTag.cpp
+ nbt/FloatTag.cpp
+ nbt/Int8ArrayTag.cpp
+ nbt/Int8Tag.cpp
+ nbt/Int16Tag.cpp
+ nbt/Int32ArrayTag.cpp
+ nbt/Int32Tag.cpp
+ nbt/Int64ArrayTag.cpp
+ nbt/Int64Tag.cpp
+ nbt/ListTag.cpp
+ nbt/NbtIo.cpp
+ nbt/StringTag.cpp
+ nbt/Tag.cpp
network/packets/UpdateBlockPacket.cpp
network/packets/RequestChunkPacket.cpp
network/packets/PlayerEquipmentPacket.cpp
@@ -206,7 +207,7 @@ add_library(reminecraftpe-core STATIC
world/entity/WaterAnimal.cpp
world/entity/Monster.cpp
world/entity/Rocket.cpp
- world/entity/EntityFactory.cpp
+ world/entity/EntityFactory.cpp
world/entity/MobFactory.cpp
world/entity/Chicken.cpp
world/entity/Cow.cpp
diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp
index 0613cff5a..b102a6b73 100644
--- a/source/client/app/AppPlatform.cpp
+++ b/source/client/app/AppPlatform.cpp
@@ -55,7 +55,20 @@ void AppPlatform::finish()
std::string AppPlatform::getDateString(int time)
{
- return "";
+ time_t tt = time;
+ struct tm t;
+#ifdef _WIN32
+ gmtime_s(&t, &tt);
+#else
+ gmtime_r(&tt, &t);
+#endif
+
+ // Format String
+ char buf[2048];
+ strftime(buf, sizeof buf, "%b %d %Y %H:%M:%S", &t);
+
+ // Return
+ return std::string(buf);
}
// ??? AppPlatform::getOptionStrings()
diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp
index 05706f409..ffd0b2d5f 100644
--- a/source/client/app/Minecraft.cpp
+++ b/source/client/app/Minecraft.cpp
@@ -12,6 +12,8 @@
#include "client/gui/screens/RenameMPLevelScreen.hpp"
#include "client/gui/screens/SavingWorldScreen.hpp"
#include "client/gui/screens/DeathScreen.hpp"
+#include "client/gui/screens/ProgressScreen.hpp"
+#include "client/gui/screens/ConvertWorldScreen.hpp"
#include "network/ServerSideNetworkHandler.hpp"
#include "client/network/ClientSideNetworkHandler.hpp"
@@ -1145,15 +1147,29 @@ void Minecraft::setLevel(Level* pLevel, const std::string& text, LocalPlayer* pL
}
}
-void Minecraft::selectLevel(const std::string& levelDir, const std::string& levelName, int c)
+void Minecraft::selectLevel(const LevelSummary& ls, bool forceConversion)
{
- LevelStorage* pStor = m_pLevelStorageSource->selectLevel(levelDir, false);
+ if (ls.m_storageVersion != LEVEL_STORAGE_VERSION_DEFAULT && !forceConversion)
+ {
+ setScreen(new ConvertWorldScreen(ls));
+ return;
+ }
+
+ selectLevel(ls.m_fileName, ls.m_levelName, 0, forceConversion);
+}
+
+void Minecraft::selectLevel(const std::string& levelDir, const std::string& levelName, int32_t seed, bool forceConversion)
+{
+ LevelStorage* pStor = m_pLevelStorageSource->selectLevel(levelDir, false, forceConversion);
Dimension* pDim = Dimension::getNew(0);
- m_pLevel = new Level(pStor, levelName, c, LEVEL_STORAGE_VERSION_DEFAULT, pDim);
+ m_pLevel = new Level(pStor, levelName, seed, LEVEL_STORAGE_VERSION_DEFAULT, pDim);
setLevel(m_pLevel, "Generating level", nullptr);
field_D9C = 1;
+
+ hostMultiplayer();
+ setScreen(new ProgressScreen);
}
const char* Minecraft::getProgressMessage()
diff --git a/source/client/app/Minecraft.hpp b/source/client/app/Minecraft.hpp
index 28e8fc252..7857d752c 100644
--- a/source/client/app/Minecraft.hpp
+++ b/source/client/app/Minecraft.hpp
@@ -46,7 +46,8 @@ class Minecraft : public App
void saveOptions();
void handleBuildAction(const BuildActionIntention& action);
bool isLevelGenerated() const;
- void selectLevel(const std::string&, const std::string&, int);
+ void selectLevel(const LevelSummary& ls, bool forceConversion = false);
+ void selectLevel(const std::string&, const std::string&, int, bool forceConversion = false);
void setLevel(Level*, const std::string&, LocalPlayer*);
bool pauseGame();
bool resumeGame();
diff --git a/source/client/gui/components/RolledSelectionList.cpp b/source/client/gui/components/RolledSelectionList.cpp
index 729111c54..96bc3e3d6 100644
--- a/source/client/gui/components/RolledSelectionList.cpp
+++ b/source/client/gui/components/RolledSelectionList.cpp
@@ -202,7 +202,7 @@ void RolledSelectionList::render(int mouseX, int mouseY, float f)
float right = itemX + width;
float up = float(field_1C) / 2.0f - 48.0f - 4.0f;
- float dn = float(field_1C) / 2.0f + 56.0f - 4.0f;
+ float dn = float(field_1C) / 2.0f + 48.0f - 4.0f;
t.vertexUV(itemX - 2, up, 0.0f, 0.0f, 0.0f);
t.vertexUV(itemX - 2, dn, 0.0f, 1.0f, 0.0f);
diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp
index 260e36dff..47b35e99d 100644
--- a/source/client/gui/components/TextInputBox.cpp
+++ b/source/client/gui/components/TextInputBox.cpp
@@ -173,41 +173,11 @@ void TextInputBox::keyPressed(int key)
switch (key) {
case AKEYCODE_DEL:
{
- // Backspace
- if (m_text.empty())
- {
- return;
- }
- if (m_insertHead <= 0)
- {
- return;
- }
- if (m_insertHead > int(m_text.size()))
- {
- m_insertHead = int(m_text.size());
- }
- m_text.erase(m_text.begin() + m_insertHead - 1, m_text.begin() + m_insertHead);
- m_insertHead--;
- recalculateScroll();
- break;
+ charPressed('\b');
}
case AKEYCODE_FORWARD_DEL:
{
- // Delete
- if (m_text.empty())
- {
- return;
- }
- if (m_insertHead < 0)
- {
- return;
- }
- if (m_insertHead >= int(m_text.size()))
- {
- return;
- }
- m_text.erase(m_text.begin() + m_insertHead, m_text.begin() + m_insertHead + 1);
- break;
+ charPressed(AKEYCODE_FORWARD_DEL);
}
case AKEYCODE_ARROW_LEFT:
{
@@ -307,20 +277,64 @@ void TextInputBox::charPressed(int k)
if (!m_bFocused)
return;
- // Ignore Unprintable Characters
- if (k == '\n' || k < ' ' || k > '~')
- return;
-
- // Check Max Length
- if (m_maxLength != -1 && int(m_text.length()) >= m_maxLength)
- {
- return;
- }
-
- // Insert
- m_text.insert(m_text.begin() + m_insertHead, k);
- m_insertHead++;
- recalculateScroll();
+ switch (k) {
+ case '\b':
+ {
+ // Backspace
+ if (m_text.empty())
+ {
+ return;
+ }
+ if (m_insertHead <= 0)
+ {
+ return;
+ }
+ if (m_insertHead > int(m_text.size()))
+ {
+ m_insertHead = int(m_text.size());
+ }
+ m_text.erase(m_text.begin() + m_insertHead - 1, m_text.begin() + m_insertHead);
+ m_insertHead--;
+ recalculateScroll();
+ break;
+ }
+ case AKEYCODE_FORWARD_DEL:
+ {
+ // Delete
+ if (m_text.empty())
+ {
+ return;
+ }
+ if (m_insertHead < 0)
+ {
+ return;
+ }
+ if (m_insertHead >= int(m_text.size()))
+ {
+ return;
+ }
+ m_text.erase(m_text.begin() + m_insertHead, m_text.begin() + m_insertHead + 1);
+ break;
+ }
+ default:
+ {
+ // Ignore Unprintable Characters
+ if (k == '\n' || k < ' ' || k > '~')
+ return;
+
+ // Check Max Length
+ if (m_maxLength != -1 && int(m_text.length()) >= m_maxLength)
+ {
+ return;
+ }
+
+ // Insert
+ m_text.insert(m_text.begin() + m_insertHead, k);
+ m_insertHead++;
+ recalculateScroll();
+ break;
+ }
+ }
}
constexpr int PADDING = 5;
diff --git a/source/client/gui/components/WorldSelectionList.cpp b/source/client/gui/components/WorldSelectionList.cpp
index 307c5f350..4c13dff90 100644
--- a/source/client/gui/components/WorldSelectionList.cpp
+++ b/source/client/gui/components/WorldSelectionList.cpp
@@ -135,6 +135,9 @@ void WorldSelectionList::touched()
void WorldSelectionList::renderItem(int index, int xPos, int yPos, int width, Tesselator& t)
{
+ int yPadding = -4;
+ yPos += yPadding; // Move up
+
int xCenter = xPos + m_itemWidth / 2;
float mult = Mth::Max(1.1f - 0.0055f * float(abs(field_18 / 2 - xCenter)), 0.2f);
if (mult > 1.0f)
@@ -145,13 +148,16 @@ void WorldSelectionList::renderItem(int index, int xPos, int yPos, int width, Te
std::vector details = m_vvs[index];
+ int x = xCenter + 5 - m_itemWidth / 2;
// Draw name
- drawString(m_pMinecraft->m_pFont, details[0], xCenter + 5 - m_itemWidth / 2, yPos + 50, color1);
+ drawString(m_pMinecraft->m_pFont, details[0], x, yPos + 50 + yPadding, color1);
// Draw other details
- for (unsigned int i = 1; i < details.size(); i++)
+ for (unsigned int i = 1; i < details.size()-1; i++)
{
- drawString(m_pMinecraft->m_pFont, details[i], xCenter + 5 - m_itemWidth / 2, yPos + (50 + (10 * i)), color2);
+ drawString(m_pMinecraft->m_pFont, details[i], x, yPos + (50 + yPadding + (10 * i)), color2);
}
+ // Draw storage version
+ drawString(m_pMinecraft->m_pFont, details[details.size()-1], xCenter + 42, yPos + (50 + yPadding + (10 * 3)), color2);
m_pMinecraft->m_pTextures->loadAndBindTexture(m_previewImages[index]);
@@ -190,6 +196,9 @@ void WorldSelectionList::commit()
vs.push_back(m_pMinecraft->platform()->getDateString(item.m_lastPlayed));
vs.push_back(item.m_fileName);
vs.push_back(GameTypeConv::GameTypeToNonLocString(item.m_gameType));
+ std::stringstream ss;
+ ss << "V" << item.m_storageVersion;
+ vs.push_back(ss.str());
m_vvs.push_back(vs);
}
}
diff --git a/source/client/gui/screens/ConvertWorldScreen.cpp b/source/client/gui/screens/ConvertWorldScreen.cpp
new file mode 100644
index 000000000..0ef6b47ed
--- /dev/null
+++ b/source/client/gui/screens/ConvertWorldScreen.cpp
@@ -0,0 +1,24 @@
+#include "ConvertWorldScreen.hpp"
+
+ConvertWorldScreen::ConvertWorldScreen(const LevelSummary& level) :
+ConfirmScreen(nullptr,
+ "A new world storage format is available!",
+ "Would you like to convert '" + level.m_levelName + "'?",
+ "Convert", "Don't Convert", 0)
+{
+ m_level = level;
+}
+
+void ConvertWorldScreen::postResult(bool b)
+{
+ if (b)
+ {
+ // Convert
+ m_pMinecraft->selectLevel(m_level, true);
+ }
+ else
+ {
+ // Don't Convert
+ m_pMinecraft->selectLevel(m_level.m_fileName, m_level.m_levelName, 0, false);
+ }
+}
diff --git a/source/client/gui/screens/ConvertWorldScreen.hpp b/source/client/gui/screens/ConvertWorldScreen.hpp
new file mode 100644
index 000000000..32cb54980
--- /dev/null
+++ b/source/client/gui/screens/ConvertWorldScreen.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "ConfirmScreen.hpp"
+#include "world/level/storage/LevelStorageSource.hpp"
+
+class ConvertWorldScreen : public ConfirmScreen
+{
+public:
+ ConvertWorldScreen(const LevelSummary& level);
+
+ void postResult(bool b) override;
+
+private:
+ LevelSummary m_level;
+};
+
diff --git a/source/client/gui/screens/CreateWorldScreen.cpp b/source/client/gui/screens/CreateWorldScreen.cpp
index 79c4a2c00..029a21ad6 100644
--- a/source/client/gui/screens/CreateWorldScreen.cpp
+++ b/source/client/gui/screens/CreateWorldScreen.cpp
@@ -126,8 +126,6 @@ void CreateWorldScreen::buttonClicked(Button* pButton)
}
m_pMinecraft->selectLevel(levelUniqueName, levelNickname, seed);
- m_pMinecraft->hostMultiplayer();
- m_pMinecraft->setScreen(new ProgressScreen);
}
}
diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp
index 2be55b6d5..6b1f5dc89 100644
--- a/source/client/gui/screens/SelectWorldScreen.cpp
+++ b/source/client/gui/screens/SelectWorldScreen.cpp
@@ -9,8 +9,8 @@
#include "SelectWorldScreen.hpp"
#include "DeleteWorldScreen.hpp"
#include "CreateWorldScreen.hpp"
-#include "ProgressScreen.hpp"
#include "StartMenuScreen.hpp"
+#include "ProgressScreen.hpp"
#include "common/Util.hpp"
SelectWorldScreen::SelectWorldScreen() :
@@ -130,8 +130,6 @@ void SelectWorldScreen::tick()
}
m_pMinecraft->selectLevel(levelUniqueName, levelNickname, seed);
- m_pMinecraft->hostMultiplayer();
- m_pMinecraft->setScreen(new ProgressScreen);
// @BUG: Use of deallocated memory. SetScreen frees us
#ifdef ORIGINAL_CODE
@@ -144,10 +142,7 @@ void SelectWorldScreen::tick()
m_pWorldSelectionList->tick();
if (m_pWorldSelectionList->field_90)
{
- LevelSummary& ls = m_pWorldSelectionList->m_levelSummary;
- m_pMinecraft->selectLevel(ls.m_fileName, ls.m_levelName, 0);
- m_pMinecraft->hostMultiplayer();
- m_pMinecraft->setScreen(new ProgressScreen);
+ m_pMinecraft->selectLevel(m_pWorldSelectionList->m_levelSummary);
return;
}
diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp
index 5156523d0..66da953a2 100644
--- a/source/client/gui/screens/StartMenuScreen.cpp
+++ b/source/client/gui/screens/StartMenuScreen.cpp
@@ -405,8 +405,6 @@ void StartMenuScreen::buttonClicked(Button* pButton)
{
#if defined(DEMO)
m_pMinecraft->selectLevel("_DemoLevel", "_DemoLevel", int(getEpochTimeS()));
- m_pMinecraft->hostMultiplayer();
- m_pMinecraft->setScreen(new ProgressScreen);
#else
m_pMinecraft->setScreen(new SelectWorldScreen);
#endif
diff --git a/source/common/Util.cpp b/source/common/Util.cpp
index 38fafba74..fcc4cb861 100644
--- a/source/common/Util.cpp
+++ b/source/common/Util.cpp
@@ -52,7 +52,7 @@ std::string Util::vformat(const char *fmt, va_list argPtr)
vsnprintf(str, sizeof(str), fmt, argPtr);
- return std::string(str);
+ return std::string(str, sizeof(str));
}
std::string Util::format(const char *fmt, ...)
diff --git a/source/world/level/storage/ExternalFileLevelStorage.cpp b/source/world/level/storage/ExternalFileLevelStorage.cpp
index ca0aa132e..2136daec9 100644
--- a/source/world/level/storage/ExternalFileLevelStorage.cpp
+++ b/source/world/level/storage/ExternalFileLevelStorage.cpp
@@ -20,12 +20,13 @@
#define C_CHUNKS_TO_SAVE_PER_TICK (2)
-ExternalFileLevelStorage::ExternalFileLevelStorage(const std::string& a, const std::string& path) :
- field_8(a),
+ExternalFileLevelStorage::ExternalFileLevelStorage(const std::string& name, const std::string& path, bool forceConversion) :
+ m_levelName(name),
m_levelDirPath(path),
m_timer(0),
m_storageVersion(LEVEL_STORAGE_VERSION_DEFAULT),
- m_lastEntitySave(-999999)
+ m_lastEntitySave(-999999),
+ m_bForceConversion(forceConversion)
{
m_pRegionFile = nullptr;
m_pLevel = nullptr;
@@ -83,8 +84,11 @@ void ExternalFileLevelStorage::saveLevelData(const std::string& levelPath, Level
std::string pathOld = pathBase + "level.dat_old";
#ifndef ENH_DISABLE_FORCED_SAVE_UPGRADES
- // Forces world to upgrade to new default storage version.
- levelData->setStorageVersion(LEVEL_STORAGE_VERSION_DEFAULT);
+ if (m_bForceConversion)
+ {
+ // Forces world to upgrade to new default storage version.
+ levelData->setStorageVersion(LEVEL_STORAGE_VERSION_DEFAULT);
+ }
#endif
writeLevelData(path, *levelData, players);
diff --git a/source/world/level/storage/ExternalFileLevelStorage.hpp b/source/world/level/storage/ExternalFileLevelStorage.hpp
index cb3916a77..5c5007421 100644
--- a/source/world/level/storage/ExternalFileLevelStorage.hpp
+++ b/source/world/level/storage/ExternalFileLevelStorage.hpp
@@ -25,7 +25,7 @@ struct UnsavedLevelChunk
class ExternalFileLevelStorage : public LevelStorage, public ChunkStorage
{
public:
- ExternalFileLevelStorage(const std::string& a, const std::string& path);
+ ExternalFileLevelStorage(const std::string& name, const std::string& path, bool forceConversion = false);
~ExternalFileLevelStorage();
private:
@@ -54,7 +54,7 @@ class ExternalFileLevelStorage : public LevelStorage, public ChunkStorage
static bool writeLevelData(const std::string& path, const LevelData& levelData, const std::vector* players = nullptr);
public:
- std::string field_8;
+ std::string m_levelName;
std::string m_levelDirPath;
LevelData* m_pLevelData;
RegionFile* m_pRegionFile;
@@ -63,6 +63,7 @@ class ExternalFileLevelStorage : public LevelStorage, public ChunkStorage
unsigned int m_storageVersion;
std::list m_unsavedLevelChunks;
int m_lastEntitySave;
+ bool m_bForceConversion;
};
#endif
diff --git a/source/world/level/storage/ExternalFileLevelStorageSource.cpp b/source/world/level/storage/ExternalFileLevelStorageSource.cpp
index dd13acc16..8e3f7399e 100644
--- a/source/world/level/storage/ExternalFileLevelStorageSource.cpp
+++ b/source/world/level/storage/ExternalFileLevelStorageSource.cpp
@@ -39,9 +39,9 @@ std::string ExternalFileLevelStorageSource::getName() const
return "External File Level Storage";
}
-LevelStorage* ExternalFileLevelStorageSource::selectLevel(const std::string& name, bool b)
+LevelStorage* ExternalFileLevelStorageSource::selectLevel(const std::string& name, bool b, bool forceConversion)
{
- return new ExternalFileLevelStorage(name, m_worldsPath + "/" + name);
+ return new ExternalFileLevelStorage(name, m_worldsPath + "/" + name, forceConversion);
}
void ExternalFileLevelStorageSource::getLevelList(std::vector& vls)
@@ -165,7 +165,7 @@ void ExternalFileLevelStorageSource::addLevelSummaryIfExists(std::vector&) override;
void clearAll() override;
int getDataTagFor(const std::string&) override;
diff --git a/source/world/level/storage/LevelData.hpp b/source/world/level/storage/LevelData.hpp
index ade1cfac6..982fb293f 100644
--- a/source/world/level/storage/LevelData.hpp
+++ b/source/world/level/storage/LevelData.hpp
@@ -14,7 +14,7 @@
#include "world/phys/Vec3.hpp"
#include "world/item/Inventory.hpp"
-#define LEVEL_STORAGE_VERSION_DEFAULT 2
+#define LEVEL_STORAGE_VERSION_DEFAULT 2
struct PlayerData
{
diff --git a/source/world/level/storage/LevelStorageSource.cpp b/source/world/level/storage/LevelStorageSource.cpp
index 22f5654d5..7922a8a57 100644
--- a/source/world/level/storage/LevelStorageSource.cpp
+++ b/source/world/level/storage/LevelStorageSource.cpp
@@ -16,10 +16,10 @@ void LevelStorageSource::getLevelList(std::vector& vec)
{
// @TODO: complete mock
#ifndef ORIGINAL_CODE
- vec.push_back(LevelSummary("Level1", "Level-1", 12345, 1234567, GAME_TYPE_CREATIVE));
- vec.push_back(LevelSummary("Level2", "Level-2", 23456, 2345678, GAME_TYPE_CREATIVE));
- vec.push_back(LevelSummary("Level3", "Level-3", 34567, 3456789, GAME_TYPE_CREATIVE));
- vec.push_back(LevelSummary("Level4", "Level-4", 45678, 4567890, GAME_TYPE_CREATIVE));
- vec.push_back(LevelSummary("Level5", "Level-5", 56789, 5678901, GAME_TYPE_CREATIVE));
+ vec.push_back(LevelSummary("Level1", "Level-1", 12345, 1234567, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT));
+ vec.push_back(LevelSummary("Level2", "Level-2", 23456, 2345678, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT));
+ vec.push_back(LevelSummary("Level3", "Level-3", 34567, 3456789, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT));
+ vec.push_back(LevelSummary("Level4", "Level-4", 45678, 4567890, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT));
+ vec.push_back(LevelSummary("Level5", "Level-5", 56789, 5678901, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT));
#endif
}
diff --git a/source/world/level/storage/LevelStorageSource.hpp b/source/world/level/storage/LevelStorageSource.hpp
index de2c5841e..1609e317d 100644
--- a/source/world/level/storage/LevelStorageSource.hpp
+++ b/source/world/level/storage/LevelStorageSource.hpp
@@ -17,21 +17,24 @@ struct LevelSummary
int m_lastPlayed;
int m_sizeOnDisk;
GameType m_gameType;
+ unsigned int m_storageVersion;
LevelSummary()
{
m_lastPlayed = 0;
m_sizeOnDisk = 0;
m_gameType = GAME_TYPE_CREATIVE;
+ m_storageVersion = LEVEL_STORAGE_VERSION_DEFAULT;
}
- LevelSummary(const std::string& fileName, const std::string& levelName, int lastPlayed, int sizeOnDisk, GameType gameType)
+ LevelSummary(const std::string& fileName, const std::string& levelName, int lastPlayed, int sizeOnDisk, GameType gameType = GAME_TYPE_CREATIVE, unsigned int storageVersion = LEVEL_STORAGE_VERSION_DEFAULT)
{
m_fileName = fileName;
m_levelName = levelName;
m_lastPlayed = lastPlayed;
m_sizeOnDisk = sizeOnDisk;
m_gameType = gameType;
+ m_storageVersion = storageVersion;
}
bool operator<(const LevelSummary& b) const
@@ -45,7 +48,7 @@ class LevelStorageSource
public:
virtual ~LevelStorageSource();
virtual std::string getName() const = 0;
- virtual LevelStorage* selectLevel(const std::string&, bool) = 0;
+ virtual LevelStorage* selectLevel(const std::string& name, bool b, bool forceConversion = false) = 0;
virtual void getLevelList(std::vector&);
virtual void clearAll() = 0;
virtual int getDataTagFor(const std::string&) = 0;