Fix Player crash caused by unable to find ReplayStream file. Resolved it by utilizing MetaCoreDiscoverProjectRoot to find projectRoot and use relative path.
This commit is contained in:
parent
e85a5b8422
commit
77626017a3
Binary file not shown.
BIN
SandboxProject/Runtime/Diagnostics.mcruntimestate
Normal file
BIN
SandboxProject/Runtime/Diagnostics.mcruntimestate
Normal file
Binary file not shown.
Binary file not shown.
6
SandboxProject/Scenes/Main.mcscene.mcmeta
Normal file
6
SandboxProject/Scenes/Main.mcscene.mcmeta
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"asset_type": "scene",
|
||||
"guid": "8fc71145-66bd-4481-9b50-4f1bf9c908d7",
|
||||
"importer": "SceneImporter",
|
||||
"source_path": "Scenes/Main.mcscene"
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
#include "MetaCoreRuntimeData/MetaCoreRuntimeDataSource.h"
|
||||
#include "MetaCoreFoundation/MetaCoreProject.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@ -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<std::filesystem::path> candidates{
|
||||
std::filesystem::current_path() / inputPath,
|
||||
std::filesystem::current_path() / ".." / ".." / ".." / inputPath,
|
||||
std::filesystem::current_path() / ".." / ".." / ".." / "TestProject" / "Runtime" / inputPath.filename()
|
||||
std::vector<std::filesystem::path> 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;
|
||||
|
||||
@ -41,7 +41,8 @@ int main(int argc, char* argv[]) {
|
||||
MetaCore::MetaCoreDataSourceSetting{"port", "7001"}
|
||||
}
|
||||
: std::vector<MetaCore::MetaCoreDataSourceSetting>{
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user