From 15918506c37c53fb918bfc09c142c614a3dbbebb Mon Sep 17 00:00:00 2001 From: LJW-Dev Date: Sat, 11 Oct 2025 19:01:48 +0800 Subject: [PATCH] Added a default entity string if the entity file isn't given --- .../Game/T6/CustomMap/CustomMapConsts.h | 17 +++++++++++++++++ .../Game/T6/CustomMap/CustomMapLinker.h | 12 ++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/ObjLoading/Game/T6/CustomMap/CustomMapConsts.h b/src/ObjLoading/Game/T6/CustomMap/CustomMapConsts.h index c8ce1d0d..e65152f4 100644 --- a/src/ObjLoading/Game/T6/CustomMap/CustomMapConsts.h +++ b/src/ObjLoading/Game/T6/CustomMap/CustomMapConsts.h @@ -104,3 +104,20 @@ const std::string defaultSpawnpointString = "{" "}"; +const std::string defaultMapEntsString = "{" + "\"entities\": [" + "{" + "\"classname\": \"worldspawn\"" + "}," + "{" + "\"angles\": \"0 0 0\"," + "\"classname\": \"info_player_start\"," + "\"origin\": \"0 0 0\"" + "}," + "{" + "\"angles\": \"0 0 0\"," + "\"classname\": \"mp_global_intermission\"," + "\"origin\": \"0 0 0\"" + "}" + "]" +"}"; diff --git a/src/ObjLoading/Game/T6/CustomMap/CustomMapLinker.h b/src/ObjLoading/Game/T6/CustomMap/CustomMapLinker.h index 708b53e7..9f0de39a 100644 --- a/src/ObjLoading/Game/T6/CustomMap/CustomMapLinker.h +++ b/src/ObjLoading/Game/T6/CustomMap/CustomMapLinker.h @@ -1817,19 +1817,23 @@ private: std::string entityString; const auto entFile = m_search_path.Open("custom_map/entities.json"); + json entJs; if (!entFile.IsOpen()) { - printf("ERROR: can't find entity json!\n"); - return; + printf("WARN: can't find entity json custom_map/entities.json, using default entities\n"); + entJs = json::parse(defaultMapEntsString); + } + else + { + entJs = json::parse(*entFile.m_stream); } - json entJs = json::parse(*entFile.m_stream); parseMapEntsJSON(entJs["entities"], entityString); const auto spawnFile = m_search_path.Open("custom_map/spawns.json"); json spawnJs; if (!spawnFile.IsOpen()) { - printf("WARN: no spawn points given, setting spawns to 0 0 0\n"); + printf("WARN: cant find custom_map/spawns.json, setting spawns to 0 0 0\n"); spawnJs = json::parse(defaultSpawnpointString); } else