Fix gruntwork paths not saving targeted types

This commit is contained in:
gsemaj 2021-05-05 13:36:53 -04:00 committed by Gent Semaj
parent 917407f164
commit d41122157f

View File

@ -727,6 +727,7 @@ static void loadGruntworkPre(json& gruntwork, int32_t* nextId) {
auto path = _path.value(); auto path = _path.value();
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<Vec3> pathPoints; std::vector<Vec3> pathPoints;
int speed = (int)path["iBaseSpeed"]; int speed = (int)path["iBaseSpeed"];
int taskID = (int)path["iTaskID"]; int taskID = (int)path["iTaskID"];
@ -735,6 +736,9 @@ static void loadGruntworkPre(json& gruntwork, int32_t* nextId) {
// 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++)
targetIDs.push_back(_tID.value()); targetIDs.push_back(_tID.value());
// target types
for (json::iterator _tType = path["aNPCTypes"].begin(); _tType != path["aNPCTypes"].end(); _tType++)
targetTypes.push_back(_tType.value());
// points // points
for (json::iterator _point = path["aPoints"].begin(); _point != path["aPoints"].end(); _point++) { for (json::iterator _point = path["aPoints"].begin(); _point != path["aPoints"].end(); _point++) {
json point = _point.value(); json point = _point.value();
@ -744,12 +748,14 @@ static void loadGruntworkPre(json& gruntwork, int32_t* nextId) {
NPCPath pathTemplate; NPCPath pathTemplate;
pathTemplate.targetIDs = targetIDs; pathTemplate.targetIDs = targetIDs;
pathTemplate.targetTypes = targetTypes;
pathTemplate.points = pathPoints; pathTemplate.points = pathPoints;
pathTemplate.speed = speed; pathTemplate.speed = speed;
pathTemplate.isRelative = relative; pathTemplate.isRelative = relative;
pathTemplate.escortTaskID = taskID; pathTemplate.escortTaskID = taskID;
Transport::NPCPaths.push_back(pathTemplate); Transport::NPCPaths.push_back(pathTemplate);
TableData::FinishedNPCPaths.push_back(pathTemplate); // keep in gruntwork
} }
std::cout << "[INFO] Loaded gruntwork.json (pre)" << std::endl; std::cout << "[INFO] Loaded gruntwork.json (pre)" << std::endl;
@ -1325,7 +1331,8 @@ void TableData::flush() {
for (auto& path : FinishedNPCPaths) { for (auto& path : FinishedNPCPaths) {
json pathObj; json pathObj;
json points; json points;
json targets; json targetIDs;
json targetTypes;
for (Vec3& coord : path.points) { for (Vec3& coord : path.points) {
json point; json point;
@ -1337,13 +1344,20 @@ void TableData::flush() {
} }
for (int32_t tID : path.targetIDs) for (int32_t tID : path.targetIDs)
targets.push_back(tID); targetIDs.push_back(tID);
for (int32_t tType : path.targetTypes)
targetTypes.push_back(tType);
pathObj["iBaseSpeed"] = path.speed; pathObj["iBaseSpeed"] = path.speed;
pathObj["iTaskID"] = path.escortTaskID; pathObj["iTaskID"] = path.escortTaskID;
pathObj["bRelative"] = path.isRelative; pathObj["bRelative"] = path.isRelative;
pathObj["aPoints"] = points; pathObj["aPoints"] = points;
pathObj["aNPCIDs"] = targets;
// don't write 'null' if there aren't any targets
if(targetIDs.size() > 0)
pathObj["aNPCIDs"] = targetIDs;
if (targetTypes.size() > 0)
pathObj["aNPCTypes"] = targetTypes;
gruntwork["paths"].push_back(pathObj); gruntwork["paths"].push_back(pathObj);
} }