Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Sentry crash prevention #3647

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 7 additions & 5 deletions src/order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,14 @@ void orderUpdateDroid(DROID *psDroid)
SDWORD xdiff, ydiff;
bool bAttack;
SDWORD xoffset, yoffset;

if (psDroid == nullptr || isDead(psDroid))
{
return;
}

const WEAPON_STATS *psWeapStats = psDroid->getWeaponStats(0);

// clear the target if it has died
if (psDroid->order.psObj && psDroid->order.psObj->died)
{
Expand All @@ -435,11 +442,6 @@ void orderUpdateDroid(DROID *psDroid)
// check for died objects in the list
orderCheckList(psDroid);

if (isDead(psDroid))
{
return;
}

switch (psDroid->order.type)
{
case DORDER_NONE:
Expand Down
2 changes: 1 addition & 1 deletion src/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ STRUCTURE *buildStructureDir(STRUCTURE_STATS *pStructureType, UDWORD x, UDWORD y
psTile->psObject = psBuilding;

// if it's a tall structure then flag it in the map.
if (psBuilding->sDisplay.imd->max.y > TALLOBJECT_YMAX)
if (psBuilding->sDisplay.imd && psBuilding->sDisplay.imd->max.y > TALLOBJECT_YMAX)
{
auxSetBlocking(tileX, tileY, AIR_BLOCKED);
}
Expand Down
Loading