2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-23 05:12:05 +00:00

Added a default entity string if the entity file isn't given

This commit is contained in:
LJW-Dev
2025-10-11 19:01:48 +08:00
parent 2906a9cf92
commit 15918506c3
2 changed files with 25 additions and 4 deletions

View File

@@ -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\""
"}"
"]"
"}";

View File

@@ -1817,19 +1817,23 @@ private:
std::string entityString; std::string entityString;
const auto entFile = m_search_path.Open("custom_map/entities.json"); const auto entFile = m_search_path.Open("custom_map/entities.json");
json entJs;
if (!entFile.IsOpen()) if (!entFile.IsOpen())
{ {
printf("ERROR: can't find entity json!\n"); printf("WARN: can't find entity json custom_map/entities.json, using default entities\n");
return; entJs = json::parse(defaultMapEntsString);
}
else
{
entJs = json::parse(*entFile.m_stream);
} }
json entJs = json::parse(*entFile.m_stream);
parseMapEntsJSON(entJs["entities"], entityString); parseMapEntsJSON(entJs["entities"], entityString);
const auto spawnFile = m_search_path.Open("custom_map/spawns.json"); const auto spawnFile = m_search_path.Open("custom_map/spawns.json");
json spawnJs; json spawnJs;
if (!spawnFile.IsOpen()) 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); spawnJs = json::parse(defaultSpawnpointString);
} }
else else