From b8d62896ddf40650c7fc5a7d3e773176aa9a6a79 Mon Sep 17 00:00:00 2001 From: kuwacom Date: Fri, 6 Mar 2026 21:55:00 +0900 Subject: [PATCH] fix: add initial save for newly created worlds in dedicated server on the server side, I fixed the behavior introduced after commit aadb511, where newly created worlds are intentionally not saved to disk immediately. --- Minecraft.Server/Windows64/ServerMain.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Minecraft.Server/Windows64/ServerMain.cpp b/Minecraft.Server/Windows64/ServerMain.cpp index 9ef8ef9a9..86af283b3 100644 --- a/Minecraft.Server/Windows64/ServerMain.cpp +++ b/Minecraft.Server/Windows64/ServerMain.cpp @@ -121,6 +121,7 @@ using ServerRuntime::ServerPropertiesConfig; using ServerRuntime::TryParseServerLogLevel; using ServerRuntime::WideToUtf8; using ServerRuntime::BootstrapWorldForServer; +using ServerRuntime::eWorldBootstrap_CreatedNew; using ServerRuntime::eWorldBootstrap_Failed; using ServerRuntime::eWorldBootstrap_Loaded; using ServerRuntime::WaitForWorldActionIdle; @@ -473,6 +474,23 @@ int main(int argc, char **argv) LogStartupStep("server startup complete"); LogInfof("startup", "Dedicated server listening on %s:%d", g_Win64MultiplayerIP, g_Win64MultiplayerPort); + if (worldBootstrap.status == eWorldBootstrap_CreatedNew && !g_shutdownRequested && !app.m_bShutdown) + { + // Windows64 では新規ワールド直後の saveToDisc を抑止しているため + // Dedicated Server はここで初回保存を明示的に実行する + LogWorldIO("requesting initial save for newly created world"); + WaitForWorldActionIdle(kServerActionPad, 5000, &TickCoreSystems, &HandleXuiActions); + app.SetXuiServerAction(kServerActionPad, eXuiServerAction_AutoSaveGame); + if (!WaitForWorldActionIdle(kServerActionPad, 30000, &TickCoreSystems, &HandleXuiActions)) + { + LogWorldIO("initial save timed out"); + LogWarn("world-io", "Timed out waiting for initial save action to finish."); + } + else + { + LogWorldIO("initial save completed"); + } + } DWORD nextAutosaveTick = GetTickCount() + kAutosaveIntervalMs; bool autosaveRequested = false;