mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-11 20:11:18 +03:00
* Add improved saving.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#define ENH_ALLOW_SCROLL_WHEEL // Allow use of the scroll wheel to change selected inventory slots
|
||||
#define ENH_DISABLE_TURN_ACCEL // Disable the turn acceleration mechanism. It should only be used on Xperia Play
|
||||
#define ENH_3D_INVENTORY_TILES // Uses 3D rendered inventory tiles, use with ENH_SHADE_HELD_TILES to render correctly.
|
||||
#define ENH_IMPROVED_SAVING // Improve world saving. The original Minecraft doesn't always really save for some reason
|
||||
|
||||
// Mods
|
||||
//#define MOD_USE_FLAT_WORLD // Use a flat world instead of the regular world generation
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "PauseScreen.hpp"
|
||||
#include "StartMenuScreen.hpp"
|
||||
#include "RenameMPLevelScreen.hpp"
|
||||
#include "SavingWorldScreen.hpp"
|
||||
#include "ServerSideNetworkHandler.hpp"
|
||||
#include "ClientSideNetworkHandler.hpp"
|
||||
|
||||
@@ -299,7 +300,7 @@ void Minecraft::tickInput()
|
||||
{
|
||||
if (!field_D14->field_10)
|
||||
{
|
||||
field_DB0 = 1;
|
||||
field_DB0 = true;
|
||||
field_D14->updateEvents();
|
||||
field_DB0 = false;
|
||||
if (field_DB1)
|
||||
@@ -839,16 +840,12 @@ void Minecraft::leaveGame(bool bCopyMap)
|
||||
// @BUG: Deleting ServerSideNetworkHandler too late! This causes
|
||||
// access to invalid memory in the destructor seeing as we already deleted the level.
|
||||
delete m_pNetEventCallback;
|
||||
|
||||
// @NOTE: Saving only happens once every 50 ticks. Force it to happen when quitting.
|
||||
if (m_pLevel)
|
||||
{
|
||||
m_pLevel->saveAllChunks();
|
||||
m_pLevel->saveLevelData();
|
||||
m_pLevel->savePlayerData();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENH_IMPROVED_SAVING
|
||||
field_288 = true;
|
||||
setScreen(new SavingWorldScreen(bCopyMap));
|
||||
#else
|
||||
if (m_pLevel)
|
||||
{
|
||||
LevelStorage* pStorage = m_pLevel->getLevelStorage();
|
||||
@@ -857,6 +854,7 @@ void Minecraft::leaveGame(bool bCopyMap)
|
||||
|
||||
m_pLevel = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ORIGINAL_CODE
|
||||
delete m_pNetEventCallback;
|
||||
@@ -865,10 +863,12 @@ void Minecraft::leaveGame(bool bCopyMap)
|
||||
m_pNetEventCallback = nullptr;
|
||||
field_D9C = 0;
|
||||
|
||||
#ifndef ENH_IMPROVED_SAVING
|
||||
if (bCopyMap)
|
||||
setScreen(new RenameMPLevelScreen("_LastJoinedServer"));
|
||||
else
|
||||
setScreen(new StartMenuScreen);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Minecraft::hostMultiplayer()
|
||||
|
||||
63
source/GUI/Screen/SavingWorldScreen.cpp
Normal file
63
source/GUI/Screen/SavingWorldScreen.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "SavingWorldScreen.hpp"
|
||||
#include "RenameMPLevelScreen.hpp"
|
||||
#include "StartMenuScreen.hpp"
|
||||
|
||||
#ifdef ENH_IMPROVED_SAVING
|
||||
|
||||
SavingWorldScreen::SavingWorldScreen(bool bCopyMap)
|
||||
{
|
||||
m_bCopyMapAtEnd = bCopyMap;
|
||||
m_timer = 0;
|
||||
}
|
||||
|
||||
void SavingWorldScreen::render(int mouseX, int mouseY, float f)
|
||||
{
|
||||
renderDirtBackground(0);
|
||||
|
||||
int x_width = int(Minecraft::width * Gui::InvGuiScale);
|
||||
int x_height = int(Minecraft::height * Gui::InvGuiScale);
|
||||
int yPos = x_height / 2;
|
||||
|
||||
int width = m_pFont->width("Saving chunks");
|
||||
m_pFont->drawShadow("Saving chunks", (x_width - width) / 2, yPos + 4, 0xFFFFFF);
|
||||
}
|
||||
|
||||
void SavingWorldScreen::tick()
|
||||
{
|
||||
if (m_timer < 0)
|
||||
return;
|
||||
|
||||
m_timer++;
|
||||
|
||||
if (m_timer >= 5)
|
||||
{
|
||||
m_timer = -1;
|
||||
|
||||
Level* pLevel = m_pMinecraft->m_pLevel;
|
||||
if (pLevel)
|
||||
{
|
||||
pLevel->saveAllChunks();
|
||||
pLevel->saveLevelData();
|
||||
pLevel->savePlayerData();
|
||||
|
||||
LevelStorage* pStorage = pLevel->getLevelStorage();
|
||||
SAFE_DELETE(pStorage);
|
||||
SAFE_DELETE(pLevel);
|
||||
|
||||
m_pMinecraft->m_pLevel = nullptr;
|
||||
}
|
||||
|
||||
m_pMinecraft->field_DB0 = true;
|
||||
|
||||
if (m_bCopyMapAtEnd)
|
||||
m_pMinecraft->setScreen(new RenameMPLevelScreen("_LastJoinedServer"));
|
||||
else
|
||||
m_pMinecraft->setScreen(new StartMenuScreen);
|
||||
|
||||
m_pMinecraft->field_DB0 = false;
|
||||
|
||||
m_pMinecraft->field_288 = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
20
source/GUI/Screen/SavingWorldScreen.hpp
Normal file
20
source/GUI/Screen/SavingWorldScreen.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "Screen.hpp"
|
||||
|
||||
#ifdef ENH_IMPROVED_SAVING
|
||||
|
||||
class SavingWorldScreen : public Screen
|
||||
{
|
||||
public:
|
||||
SavingWorldScreen(bool bCopyMap);
|
||||
|
||||
void render(int mouseX, int mouseY, float f) override;
|
||||
void tick() override;
|
||||
|
||||
public:
|
||||
bool m_bCopyMapAtEnd;
|
||||
int m_timer = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -65,6 +65,7 @@
|
||||
<ClInclude Include="..\source\GUI\Screen\PauseScreen.hpp" />
|
||||
<ClInclude Include="..\source\GUI\Screen\ProgressScreen.hpp" />
|
||||
<ClInclude Include="..\source\GUI\Screen\RenameMPLevelScreen.hpp" />
|
||||
<ClInclude Include="..\source\GUI\Screen\SavingWorldScreen.hpp" />
|
||||
<ClInclude Include="..\source\GUI\Screen\Screen.hpp" />
|
||||
<ClInclude Include="..\source\GUI\Screen\SelectWorldScreen.hpp" />
|
||||
<ClInclude Include="..\source\GUI\Screen\StartMenuScreen.hpp" />
|
||||
@@ -358,6 +359,7 @@
|
||||
<ClCompile Include="..\source\GUI\Screen\PauseScreen.cpp" />
|
||||
<ClCompile Include="..\source\GUI\Screen\ProgressScreen.cpp" />
|
||||
<ClCompile Include="..\source\GUI\Screen\RenameMPLevelScreen.cpp" />
|
||||
<ClCompile Include="..\source\GUI\Screen\SavingWorldScreen.cpp" />
|
||||
<ClCompile Include="..\source\GUI\Screen\Screen.cpp" />
|
||||
<ClCompile Include="..\source\GUI\Screen\SelectWorldScreen.cpp" />
|
||||
<ClCompile Include="..\source\GUI\Screen\StartMenuScreen.cpp" />
|
||||
|
||||
@@ -1068,6 +1068,9 @@
|
||||
<ClCompile Include="..\source\World\Storage\ExternalFileLevelStorageSource.cpp">
|
||||
<Filter>Source Files\World\Storage</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\GUI\Screen\SavingWorldScreen.cpp">
|
||||
<Filter>Source Files\GUI\Screen</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\source\Options.hpp">
|
||||
@@ -1937,12 +1940,15 @@
|
||||
<ClInclude Include="..\source\World\RegionFile.hpp">
|
||||
<Filter>Header Files\World</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\source\World\Storage\ExternalFileLevelStorageSource.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\source\World\Storage\ExternalFileLevelStorage.hpp">
|
||||
<Filter>Header Files\World\Storage</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\source\World\Storage\ExternalFileLevelStorageSource.hpp">
|
||||
<Filter>Header Files\World\Storage</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\source\GUI\Screen\SavingWorldScreen.hpp">
|
||||
<Filter>Header Files\GUI\Screen</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\thirdparty\raknet\CMakeLists.txt">
|
||||
|
||||
Reference in New Issue
Block a user