Skip to content

Commit

Permalink
Make object died hack a little more obvious
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
KJeff01 committed Feb 21, 2024
1 parent 7156675 commit 03bbbba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 03bbbba

Please sign in to comment.