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.
This commit is contained in:
dongresource 2021-12-31 02:40:32 +01:00
parent 384a2ece78
commit 3c6afa0322

View File

@ -671,10 +671,10 @@ static void loadGruntworkPre(json& gruntwork, int32_t* nextId) {
std::vector<int32_t> targetIDs; std::vector<int32_t> targetIDs;
std::vector<int32_t> targetTypes; // target types are not exportable from gw, but load them anyway std::vector<int32_t> targetTypes; // target types are not exportable from gw, but load them anyway
std::vector<Vec3> pathPoints; std::vector<Vec3> pathPoints;
int speed = (int)path["iBaseSpeed"]; int speed = path.find("iBaseSpeed") == path.end() ? NPC_DEFAULT_SPEED : (int)path["iBaseSpeed"];
int taskID = (int)path["iTaskID"]; int taskID = path.find("iTaskID") == path.end() ? -1 : (int)path["iTaskID"];
bool relative = (bool)path["bRelative"]; bool relative = path.find("bRelative") == path.end() ? false : (bool)path["bRelative"];
bool loop = (bool)path["bLoop"]; bool loop = path.find("bLoop") == path.end() ? true : (bool)path["bLoop"]; // loop by default
// target IDs // target IDs
for (json::iterator _tID = path["aNPCIDs"].begin(); _tID != path["aNPCIDs"].end(); _tID++) for (json::iterator _tID = path["aNPCIDs"].begin(); _tID != path["aNPCIDs"].end(); _tID++)