Skip to content

Commit 3a46ed6

Browse files
committed
additional ShipStatus fixes
Update the Lua enums to be consistent with the new ShipStatus enums. Separately, add an extra ship registry check in the event a ship doesn't exist in the ship registry.
1 parent 1812efa commit 3a46ed6

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

code/ai/aigoals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_info *aip, ai_goal *aigp, char
976976
// this goal needs some extra setup
977977
// if this doesn't work, the goal will be immediately removed
978978
auto ship_entry = ship_registry_get(aigp->target_name);
979-
if (ship_entry->shipp)
979+
if (ship_entry && ship_entry->shipp)
980980
{
981981
auto target_aip = &Ai_info[ship_entry->shipp->ai_index];
982982
target_aip->ai_flags.set(AI::AI_Flags::Awaiting_repair);

code/scripting/api/objs/enums.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ const lua_enum_def_list Enumerations[] = {
141141
{"SCORE_DEBRIEFING_AVERAGE", LE_SCORE_DEBRIEFING_AVERAGE, true},
142142
{"SCORE_DEBRIEFING_FAILURE", LE_SCORE_DEBRIEFING_FAILURE, true},
143143
{"SCORE_FICTION_VIEWER", LE_SCORE_FICTION_VIEWER, true},
144+
{"INVALID", LE_INVALID, true},
144145
{"NOT_YET_PRESENT", LE_NOT_YET_PRESENT, true},
145146
{"PRESENT", LE_PRESENT, true},
147+
{"DEATH_ROLL", LE_DEATH_ROLL, true},
146148
{"EXITED", LE_EXITED, true},
147149
{"DC_IS_HULL", LE_DC_IS_HULL, (1 << 0), true},
148150
{"DC_VAPORIZE", LE_DC_VAPORIZE, (1 << 1), true},

code/scripting/api/objs/enums.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ enum lua_enum : int32_t {
140140
LE_SCORE_DEBRIEFING_AVERAGE,
141141
LE_SCORE_DEBRIEFING_FAILURE,
142142
LE_SCORE_FICTION_VIEWER,
143-
LE_NOT_YET_PRESENT, // the sequence and offsets of these three #defines should correspond to the ShipStatus enums
143+
LE_INVALID, // the sequence and offsets of these five #defines should correspond to the ShipStatus enums
144+
LE_NOT_YET_PRESENT,
144145
LE_PRESENT,
146+
LE_DEATH_ROLL,
145147
LE_EXITED,
146148
LE_DC_IS_HULL,
147149
LE_DC_VAPORIZE,

code/scripting/api/objs/ship_registry_entry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ADE_FUNC(isValid, l_ShipRegistryEntry, nullptr, "Detects whether handle is valid
4141
return ADE_RETURN_TRUE;
4242
}
4343

44-
ADE_VIRTVAR(Status, l_ShipRegistryEntry, nullptr, "Status of ship", "enumeration", "NOT_YET_PRESENT, PRESENT, EXITED, or nil if handle is invalid")
44+
ADE_VIRTVAR(Status, l_ShipRegistryEntry, nullptr, "Status of ship", "enumeration", "INVALID, NOT_YET_PRESENT, PRESENT, DEATH_ROLL, EXITED, or nil if handle is invalid")
4545
{
4646
int idx;
4747
if (!ade_get_args(L, "o", l_ShipRegistryEntry.Get(&idx)))
@@ -53,7 +53,7 @@ ADE_VIRTVAR(Status, l_ShipRegistryEntry, nullptr, "Status of ship", "enumeration
5353
if (ADE_SETTING_VAR)
5454
LuaError(L, "This property is read only.");
5555

56-
return ade_set_args(L, "o", l_Enum.Set(enum_h(static_cast<lua_enum>(LE_NOT_YET_PRESENT + (int)Ship_registry[idx].status))));
56+
return ade_set_args(L, "o", l_Enum.Set(enum_h(static_cast<lua_enum>(LE_INVALID + (int)Ship_registry[idx].status))));
5757
}
5858

5959
ADE_FUNC(getParsedShip, l_ShipRegistryEntry, nullptr, "Return the parsed ship associated with this ship registry entry", "parse_object", "The parsed ship, or nil if handle is invalid. If this ship entry is for a ship-create'd ship, the returned handle may be invalid.")

0 commit comments

Comments
 (0)