From 3c6afa03221d2207d4a86fec97e3c63ad7fe1c3c Mon Sep 17 00:00:00 2001 From: dongresource Date: Fri, 31 Dec 2021 02:40:32 +0100 Subject: [PATCH] Tolerate missing optional fields when loading gruntwork These are already allowed to be absent in paths.json, but the gruntwork loading logic wasn't updated accordingly. --- src/TableData.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TableData.cpp b/src/TableData.cpp index f59acac..daa5dc0 100644 --- a/src/TableData.cpp +++ b/src/TableData.cpp @@ -671,10 +671,10 @@ static void loadGruntworkPre(json& gruntwork, int32_t* nextId) { std::vector targetIDs; std::vector targetTypes; // target types are not exportable from gw, but load them anyway std::vector pathPoints; - int speed = (int)path["iBaseSpeed"]; - int taskID = (int)path["iTaskID"]; - bool relative = (bool)path["bRelative"]; - bool loop = (bool)path["bLoop"]; + int speed = path.find("iBaseSpeed") == path.end() ? NPC_DEFAULT_SPEED : (int)path["iBaseSpeed"]; + int taskID = path.find("iTaskID") == path.end() ? -1 : (int)path["iTaskID"]; + bool relative = path.find("bRelative") == path.end() ? false : (bool)path["bRelative"]; + bool loop = path.find("bLoop") == path.end() ? true : (bool)path["bLoop"]; // loop by default // target IDs for (json::iterator _tID = path["aNPCIDs"].begin(); _tID != path["aNPCIDs"].end(); _tID++)