From c65c43d95f9faeb54a24514a74a5b5af504bef71 Mon Sep 17 00:00:00 2001 From: KJeff01 Date: Mon, 19 Feb 2024 17:20:47 -0600 Subject: [PATCH] Make object died hack a little more obvious Died can actually mean three things: 1. If = 0, alive. 2. If = 1 (NOT_CURRENT_LIST), not in the current list (mission swapping or went into a transporter). 3. If > 1, dead. Replacing some values with NOT_CURRENT_LIST explicitly so this doesn't bite anyone attempting to change that. --- src/game.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 24596f2ef48..e8f13e320a8 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2401,7 +2401,7 @@ static void getIniDroidOrder(WzConfig &ini, WzString const &key, DroidOrder &ord static void setIniBaseObject(nlohmann::json &json, WzString const &key, BASE_OBJECT const *object) { - if (object != nullptr && object->died <= 1) + if (object != nullptr && object->died <= NOT_CURRENT_LIST) { const auto& keyStr = key.toStdString(); json[keyStr + "/id"] = object->id; @@ -5470,7 +5470,7 @@ static void writeSaveObject(WzConfig &ini, const BASE_OBJECT *psObj) ini.setValue("periodicalDamage", psObj->periodicalDamage); } ini.setValue("born", psObj->born); - if (psObj->died > 0) + if (psObj->died >= NOT_CURRENT_LIST) { ini.setValue("died", psObj->died); } @@ -5520,7 +5520,7 @@ static void writeSaveObjectJSON(nlohmann::json &jsonObj, const BASE_OBJECT *psOb jsonObj["periodicalDamage"] = psObj->periodicalDamage; } jsonObj["born"] = psObj->born; - if (psObj->died > 0) + if (psObj->died >= NOT_CURRENT_LIST) { jsonObj["died"] = psObj->died; } @@ -5868,7 +5868,7 @@ static nlohmann::json writeDroid(const DROID *psCurr, bool onMission, int &count droidObj["aigroup/type"] = psCurr->psGroup->type; } droidObj["group"] = psCurr->group; // different kind of group. of course. - if (hasCommander(psCurr) && psCurr->psGroup->psCommander->died <= 1) + if (hasCommander(psCurr) && psCurr->psGroup->psCommander->died <= NOT_CURRENT_LIST) { droidObj["commander"] = psCurr->psGroup->psCommander->id; }