From 77626017a36cf42259384b443804d3b4a2c31ebb Mon Sep 17 00:00:00 2001 From: ayuan9957 <107920784+ayuan9957@users.noreply.github.com> Date: Thu, 21 May 2026 17:49:16 +0800 Subject: [PATCH] Fix Player crash caused by unable to find ReplayStream file. Resolved it by utilizing MetaCoreDiscoverProjectRoot to find projectRoot and use relative path. --- SandboxProject/Runtime/DataSources.mcruntime | Bin 1487 -> 1475 bytes .../Runtime/Diagnostics.mcruntimestate | Bin 0 -> 1735 bytes SandboxProject/Scenes/Main.mcscene | Bin 2447 -> 2447 bytes SandboxProject/Scenes/Main.mcscene.mcmeta | 6 ++++++ .../Private/MetaCoreRuntimeDataSource.cpp | 12 ++++++++---- tools/MetaCoreRuntimeConfigTool/main.cpp | 3 ++- 6 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 SandboxProject/Runtime/Diagnostics.mcruntimestate create mode 100644 SandboxProject/Scenes/Main.mcscene.mcmeta diff --git a/SandboxProject/Runtime/DataSources.mcruntime b/SandboxProject/Runtime/DataSources.mcruntime index 25dc4854c9853da85deaeceac1e14fbcdb70c492..1753d3f94043de6b2b5c10eaf55374acf4d1921e 100644 GIT binary patch delta 38 kcmX@leVBWKIAhjCiEWJe6VH1Hs4+l*9F*Q{%s7Vy0LKRi4FCWD delta 50 wcmX@ieV%)QIAhsFiEWJ46VH3d7%@PA7L*Q2EiMTt%FjwoF45nt&Nzn!08?iS;{X5v diff --git a/SandboxProject/Runtime/Diagnostics.mcruntimestate b/SandboxProject/Runtime/Diagnostics.mcruntimestate new file mode 100644 index 0000000000000000000000000000000000000000..b4ed9ac05c98fa4667385ba0f1dd03e66eb9c686 GIT binary patch literal 1735 zcmd^9T~5O=4DQ6g#Lo+e7ZAMwy~9ADO@bE&&&X}f7RZt+PA7H>&WFSSI0i{;LpO;7 zFd{{EBImQeFP3{rlB|WjA9h?LTe|{B9(+wm@9kyM>)4IpZ}Yj09+pRZ-ec>q(l9@# z1}r{^D}v&B>o++M*uMetm)008JeGYg;F5H=6ZTM*0pusF|7dVlDr#_t1x2-ZvM?Yg%tqV$`S(r delta 49 rcmeAd?iZf0U7#>C>*U6Z&VS~eJ^L@)E%(O8<0{M;f}4LcPhkZBg`ygX diff --git a/SandboxProject/Scenes/Main.mcscene.mcmeta b/SandboxProject/Scenes/Main.mcscene.mcmeta new file mode 100644 index 0000000..2eec4ad --- /dev/null +++ b/SandboxProject/Scenes/Main.mcscene.mcmeta @@ -0,0 +1,6 @@ +{ + "asset_type": "scene", + "guid": "8fc71145-66bd-4481-9b50-4f1bf9c908d7", + "importer": "SceneImporter", + "source_path": "Scenes/Main.mcscene" +} \ No newline at end of file diff --git a/Source/MetaCoreRuntimeData/Private/MetaCoreRuntimeDataSource.cpp b/Source/MetaCoreRuntimeData/Private/MetaCoreRuntimeDataSource.cpp index 45edaea..83f1caf 100644 --- a/Source/MetaCoreRuntimeData/Private/MetaCoreRuntimeDataSource.cpp +++ b/Source/MetaCoreRuntimeData/Private/MetaCoreRuntimeDataSource.cpp @@ -1,4 +1,5 @@ #include "MetaCoreRuntimeData/MetaCoreRuntimeDataSource.h" +#include "MetaCoreFoundation/MetaCoreProject.h" #include #include @@ -119,11 +120,14 @@ constexpr SOCKET MetaCoreInvalidSocket = INVALID_SOCKET; [[nodiscard]] std::string MetaCoreResolveReplayFilePath(const std::string& replayFilePath) { const std::filesystem::path inputPath(replayFilePath); - const std::vector candidates{ - std::filesystem::current_path() / inputPath, - std::filesystem::current_path() / ".." / ".." / ".." / inputPath, - std::filesystem::current_path() / ".." / ".." / ".." / "TestProject" / "Runtime" / inputPath.filename() + std::vector candidates{ + std::filesystem::current_path() / inputPath }; + if (const auto projectRoot = MetaCoreDiscoverProjectRoot()) { + candidates.push_back(*projectRoot / inputPath); + } + candidates.push_back(std::filesystem::current_path() / ".." / ".." / ".." / inputPath); + candidates.push_back(std::filesystem::current_path() / ".." / ".." / ".." / "TestProject" / "Runtime" / inputPath.filename()); for (const auto& candidate : candidates) { std::error_code errorCode; diff --git a/tools/MetaCoreRuntimeConfigTool/main.cpp b/tools/MetaCoreRuntimeConfigTool/main.cpp index bff0034..13a2870 100644 --- a/tools/MetaCoreRuntimeConfigTool/main.cpp +++ b/tools/MetaCoreRuntimeConfigTool/main.cpp @@ -41,7 +41,8 @@ int main(int argc, char* argv[]) { MetaCore::MetaCoreDataSourceSetting{"port", "7001"} } : std::vector{ - MetaCore::MetaCoreDataSourceSetting{"file_path", "TestProject/Runtime/RuntimeReplay.mcstream"} + // 动态计算相对于项目根目录的播放流文件路径,替代原先硬编码的 TestProject + MetaCore::MetaCoreDataSourceSetting{"file_path", (std::filesystem::path(argv[1]).filename() / "RuntimeReplay.mcstream").generic_string()} }, true, 1000