mirror of
https://github.com/celisej567/mcpe.git
synced 2026-01-06 22:10:04 +03:00
* * Undo some of the changes done in the "* Work on survival mode." commit. * TEST_SURVIVAL_MODE is now on by default. * * Dying no longer crashes the game. * * Death seems to work ok. * * Improve some of the damage code. * x * work * Fixed the Makefile (#54) * * Finally fix the crack texture appearing to flicker/restart * * Add VS2010 as an optional target. Fix build with VS2010 (both windows_vs and xenon_vs). * * Disable survival mode. Getting ready to merge now! --------- Co-authored-by: Alexander Argentakis <38327951+MFDGaming@users.noreply.github.com>
79 lines
1.8 KiB
C++
79 lines
1.8 KiB
C++
/********************************************************************
|
|
Minecraft: Pocket Edition - Decompilation Project
|
|
Copyright (C) 2023 iProgramInCpp
|
|
|
|
The following code is licensed under the BSD 1 clause license.
|
|
SPDX-License-Identifier: BSD-1-Clause
|
|
********************************************************************/
|
|
|
|
#include "SavingWorldScreen.hpp"
|
|
#include "RenameMPLevelScreen.hpp"
|
|
#include "StartMenuScreen.hpp"
|
|
|
|
#ifdef ENH_IMPROVED_SAVING
|
|
|
|
SavingWorldScreen::SavingWorldScreen(bool bCopyMap, Entity *pEnt)
|
|
{
|
|
m_bCopyMapAtEnd = bCopyMap;
|
|
m_timer = 0;
|
|
m_pEntityToDeleteAfterSave = pEnt;
|
|
}
|
|
|
|
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, 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->saveUnsavedChunks();
|
|
pLevel->saveLevelData();
|
|
pLevel->savePlayerData();
|
|
|
|
LevelStorage* pStorage = pLevel->getLevelStorage();
|
|
SAFE_DELETE(pStorage);
|
|
SAFE_DELETE(pLevel);
|
|
|
|
m_pMinecraft->m_pLevel = nullptr;
|
|
}
|
|
|
|
// this is safe to do, since on destruction, nothing accesses the parent level or anything
|
|
SAFE_DELETE(m_pEntityToDeleteAfterSave);
|
|
|
|
m_pMinecraft->m_pMobPersp = m_pMinecraft->m_pLocalPlayer = nullptr;
|
|
|
|
|
|
m_pMinecraft->m_bUsingScreen = true;
|
|
|
|
if (m_bCopyMapAtEnd)
|
|
m_pMinecraft->setScreen(new RenameMPLevelScreen("_LastJoinedServer"));
|
|
else
|
|
m_pMinecraft->setScreen(new StartMenuScreen);
|
|
|
|
m_pMinecraft->m_bUsingScreen = false;
|
|
|
|
m_pMinecraft->field_288 = false;
|
|
}
|
|
}
|
|
|
|
#endif
|