mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Add executeSaveAll and wait for async chunk saves
This commit is contained in:
parent
d7596aa28c
commit
b4cd510cc7
|
|
@ -23,6 +23,7 @@
|
||||||
#include "..\Minecraft.World\net.minecraft.world.level.storage.h"
|
#include "..\Minecraft.World\net.minecraft.world.level.storage.h"
|
||||||
#include "..\Minecraft.World\net.minecraft.world.h"
|
#include "..\Minecraft.World\net.minecraft.world.h"
|
||||||
#include "..\Minecraft.World\net.minecraft.world.level.h"
|
#include "..\Minecraft.World\net.minecraft.world.level.h"
|
||||||
|
#include "..\Minecraft.World\ChunkStorage.h"
|
||||||
#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
|
#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
|
||||||
#include "..\Minecraft.World\Pos.h"
|
#include "..\Minecraft.World\Pos.h"
|
||||||
#include "..\Minecraft.World\System.h"
|
#include "..\Minecraft.World\System.h"
|
||||||
|
|
@ -234,11 +235,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom
|
||||||
|
|
||||||
if (action == L"save-all")
|
if (action == L"save-all")
|
||||||
{
|
{
|
||||||
if (playerList != nullptr)
|
server->executeSaveAll();
|
||||||
{
|
|
||||||
playerList->saveAll(nullptr, false);
|
|
||||||
}
|
|
||||||
server->info(L"World saved.");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1369,6 +1366,46 @@ void MinecraftServer::saveAllChunks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4J-JEV: Added
|
||||||
|
void MinecraftServer::executeSaveAll()
|
||||||
|
{
|
||||||
|
broadcastStartSavingPacket();
|
||||||
|
if (players != nullptr)
|
||||||
|
{
|
||||||
|
players->saveAll(Minecraft::GetInstance()->progressRenderer, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < levels.length; i++)
|
||||||
|
{
|
||||||
|
ServerLevel *level = levels[levels.length - 1 - i];
|
||||||
|
if (level != nullptr)
|
||||||
|
{
|
||||||
|
level->save(true, Minecraft::GetInstance()->progressRenderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (levels[0] != nullptr)
|
||||||
|
{
|
||||||
|
levels[0]->saveToDisc(Minecraft::GetInstance()->progressRenderer, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveGameRules();
|
||||||
|
|
||||||
|
// 4J - ensure all asynchronous chunk saves are completed
|
||||||
|
for (unsigned int i = 0; i < levels.length; i++)
|
||||||
|
{
|
||||||
|
ServerLevel *level = levels[i];
|
||||||
|
if (level != nullptr && level->cache != nullptr && level->cache->getStorage() != nullptr)
|
||||||
|
{
|
||||||
|
level->cache->getStorage()->WaitForAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
broadcastStopSavingPacket();
|
||||||
|
|
||||||
|
info(L"World saved.");
|
||||||
|
}
|
||||||
|
|
||||||
// 4J-JEV: Added
|
// 4J-JEV: Added
|
||||||
void MinecraftServer::saveGameRules()
|
void MinecraftServer::saveGameRules()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,9 @@ public:
|
||||||
|
|
||||||
// static Logger logger = Logger.getLogger("Minecraft");
|
// static Logger logger = Logger.getLogger("Minecraft");
|
||||||
static unordered_map<wstring, int> ironTimers;
|
static unordered_map<wstring, int> ironTimers;
|
||||||
|
void saveAllChunks();
|
||||||
|
void saveGameRules();
|
||||||
|
void executeSaveAll();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int DEFAULT_MINECRAFT_PORT = 25565;
|
static const int DEFAULT_MINECRAFT_PORT = 25565;
|
||||||
|
|
@ -142,8 +145,7 @@ private:
|
||||||
bool loadLevel(LevelStorageSource *storageSource, const wstring& name, int64_t levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
|
bool loadLevel(LevelStorageSource *storageSource, const wstring& name, int64_t levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
|
||||||
void setProgress(const wstring& status, int progress);
|
void setProgress(const wstring& status, int progress);
|
||||||
void endProgress();
|
void endProgress();
|
||||||
void saveAllChunks();
|
private:
|
||||||
void saveGameRules();
|
|
||||||
void stopServer(bool didInit);
|
void stopServer(bool didInit);
|
||||||
#ifdef _LARGE_WORLDS
|
#ifdef _LARGE_WORLDS
|
||||||
void overwriteBordersForNewWorldSize(ServerLevel* level);
|
void overwriteBordersForNewWorldSize(ServerLevel* level);
|
||||||
|
|
@ -207,6 +209,7 @@ public:
|
||||||
static void resetFlags() { s_bServerHalted = false; s_bSaveOnExitAnswered = false; }
|
static void resetFlags() { s_bServerHalted = false; s_bSaveOnExitAnswered = false; }
|
||||||
|
|
||||||
bool flagEntitiesToBeRemoved(unsigned int *flags); // 4J added
|
bool flagEntitiesToBeRemoved(unsigned int *flags); // 4J added
|
||||||
|
//void MinecraftServer::executeSaveAll();
|
||||||
private:
|
private:
|
||||||
//4J Added
|
//4J Added
|
||||||
static MinecraftServer *server;
|
static MinecraftServer *server;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "..\Minecraft.World\net.minecraft.world.level.h"
|
#include "..\Minecraft.World\net.minecraft.world.level.h"
|
||||||
#include "..\Minecraft.World\File.h"
|
#include "..\Minecraft.World\File.h"
|
||||||
|
#include "..\Minecraft.World\ChunkStorage.h"
|
||||||
#include "..\Minecraft.World\net.minecraft.world.level.storage.h"
|
#include "..\Minecraft.World\net.minecraft.world.level.storage.h"
|
||||||
#include "..\Minecraft.World\JavaIntHash.h"
|
#include "..\Minecraft.World\JavaIntHash.h"
|
||||||
#include "..\Minecraft.World\RandomLevelSource.h"
|
#include "..\Minecraft.World\RandomLevelSource.h"
|
||||||
|
|
@ -53,6 +54,7 @@ public:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
virtual LevelChunk **getCache() { return cache; } // 4J added
|
virtual LevelChunk **getCache() { return cache; } // 4J added
|
||||||
|
virtual ChunkStorage *getStorage() { return storage; } // 4J added
|
||||||
|
|
||||||
// 4J-JEV Added; Remove chunk from the toDrop queue.
|
// 4J-JEV Added; Remove chunk from the toDrop queue.
|
||||||
#ifdef _LARGE_WORLDS
|
#ifdef _LARGE_WORLDS
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include "..\Minecraft.Client\Common\BuildVer.h"
|
||||||
|
|
||||||
#ifdef _DURANGO
|
#ifdef _DURANGO
|
||||||
#include <xdk.h>
|
#include <xdk.h>
|
||||||
|
|
@ -192,7 +193,7 @@ void MemSect(int sect);
|
||||||
#include "..\Minecraft.Client\Common\Minecraft_Macros.h"
|
#include "..\Minecraft.Client\Common\Minecraft_Macros.h"
|
||||||
#include "..\Minecraft.Client\Common\Colours\ColourTable.h"
|
#include "..\Minecraft.Client\Common\Colours\ColourTable.h"
|
||||||
|
|
||||||
#include "..\Minecraft.Client\Common\BuildVer.h"
|
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
#include "..\Minecraft.Client\Xbox\Xbox_App.h"
|
#include "..\Minecraft.Client\Xbox\Xbox_App.h"
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue