Merge remote-tracking branch 'Revelations/main' into upstream-merge
# Conflicts: # .github/workflows/nightly.yml # CMakeLists.txt # Minecraft.Client/CMakeLists.txt # Minecraft.Client/StringTable.cpp # Minecraft.Server/FourKitNatives.cpp # Minecraft.Server/Windows64/ServerMain.cpp # Minecraft.World/BiomeDecorator.cpp # Minecraft.World/BiomeSource.cpp # Minecraft.World/cmake/sources/Common.cmake # README.md # cmake/ServerTarget.cmake
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "../../Minecraft.World/ConsoleSaveFileOriginal.h"
|
||||
#include "../../Minecraft.World/net.minecraft.world.level.tile.h"
|
||||
#include "../../Minecraft.World/Random.h"
|
||||
#include "../../Minecraft.World/MobCategory.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -165,6 +166,7 @@ static void PrintUsage()
|
||||
ServerRuntime::LogInfo("usage", " -maxplayers <1-8> Public slots (default: server.properties:max-players)");
|
||||
ServerRuntime::LogInfo("usage", " -seed <int64> World seed (overrides server.properties:level-seed)");
|
||||
ServerRuntime::LogInfo("usage", " -loglevel <level> debug|info|warn|error (default: server.properties:log-level)");
|
||||
ServerRuntime::LogInfo("usage", " -perftrace Enable noisy [perf] sampling output (histograms, per-iter samples)");
|
||||
ServerRuntime::LogInfo("usage", " -help Show this help");
|
||||
}
|
||||
|
||||
@@ -271,6 +273,10 @@ static bool ParseCommandLine(int argc, char **argv, DedicatedServerConfig *confi
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (_stricmp(arg, "-perftrace") == 0)
|
||||
{
|
||||
ServerRuntime::g_serverPerfTrace = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogErrorf("startup", "Unknown or incomplete argument: %s", arg);
|
||||
@@ -557,10 +563,18 @@ int main(int argc, char **argv)
|
||||
{
|
||||
LogError("startup", "Minecraft initialization failed.");
|
||||
CleanupDevice();
|
||||
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
MobCategory::monster->setMaxInstancesPerLevel(serverProperties.maxMonsters);
|
||||
MobCategory::creature->setMaxInstancesPerLevel(serverProperties.maxAnimals);
|
||||
MobCategory::ambient->setMaxInstancesPerLevel(serverProperties.maxAmbient);
|
||||
MobCategory::waterCreature->setMaxInstancesPerLevel(serverProperties.maxWaterAnimals);
|
||||
MobCategory::creature_wolf->setMaxInstancesPerLevel(serverProperties.maxWolves);
|
||||
MobCategory::creature_chicken->setMaxInstancesPerLevel(serverProperties.maxChickens);
|
||||
MobCategory::creature_mushroomcow->setMaxInstancesPerLevel(serverProperties.maxMushroomCows);
|
||||
|
||||
app.InitGameSettings();
|
||||
|
||||
MinecraftServer::resetFlags();
|
||||
@@ -737,7 +751,7 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
if (autosaveRequested && app.GetXuiServerAction(kServerActionPad) == eXuiServerAction_Idle)
|
||||
if (autosaveRequested && app.GetXuiServerAction(kServerActionPad) == eXuiServerAction_Idle && !ConsoleSaveFileOriginal::hasPendingBackgroundSave())
|
||||
{
|
||||
LogWorldIO("autosave completed");
|
||||
autosaveRequested = false;
|
||||
@@ -749,7 +763,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
DWORD now = GetTickCount();
|
||||
if ((LONG)(now - nextAutosaveTick) >= 0)
|
||||
if ((LONG)(now - nextAutosaveTick) >= 0 && !IsShutdownRequested() && !app.m_bShutdown)
|
||||
{
|
||||
if (app.GetXuiServerAction(kServerActionPad) == eXuiServerAction_Idle)
|
||||
{
|
||||
@@ -772,12 +786,28 @@ int main(int argc, char **argv)
|
||||
MinecraftServer *server = MinecraftServer::getInstance();
|
||||
if (server != NULL)
|
||||
{
|
||||
// Drain any in-flight autosave before requesting the exit save so the
|
||||
// async autosave can't overwrite the exit save with an older snapshot,
|
||||
// and so m_saveOnExit gets set (prior logic skipped it when a save was
|
||||
// pending, causing silent data loss on restart).
|
||||
if (ConsoleSaveFileOriginal::hasPendingBackgroundSave())
|
||||
{
|
||||
LogWorldIO("Draining pending autosave before exit save...");
|
||||
const DWORD kDrainTimeoutMs = 30000;
|
||||
DWORD drainStart = GetTickCount();
|
||||
while (ConsoleSaveFileOriginal::hasPendingBackgroundSave())
|
||||
{
|
||||
if ((LONG)(GetTickCount() - drainStart) > (LONG)kDrainTimeoutMs)
|
||||
{
|
||||
LogWorldIO("Autosave drain timed out; continuing with exit save");
|
||||
break;
|
||||
}
|
||||
TickCoreSystems();
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
server->setSaveOnExit(true);
|
||||
}
|
||||
if (server != NULL)
|
||||
{
|
||||
LogWorldIO("requesting save before shutdown");
|
||||
LogWorldIO("using saveOnExit for shutdown");
|
||||
LogWorldIO("requesting exit save");
|
||||
}
|
||||
|
||||
MinecraftServer::HaltServer();
|
||||
|
||||
Reference in New Issue
Block a user