Skip to content

Commit 343bc17

Browse files
authored
Merge pull request scp-fs2open#7496 from Goober5000/fix/7206
fix CTD when LuaSEXP evaluates a subsystem on an absent ship
2 parents 8a174c5 + 876a1d3 commit 343bc17

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

code/parse/sexp/LuaSEXP.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,13 @@ luacpp::LuaValue LuaSEXP::sexpToLua(int node, int argnum, int parent_node) const
304304

305305
auto ship_entry = eval_ship(this_node);
306306

307-
if (!ship_entry || !ship_entry->has_shipp()) {
308-
// Name is invalid
309-
return LuaValue::createValue(_action.getLuaState(), l_Ship.Set(object_h()));
307+
if (!ship_entry || !ship_entry->has_objp()) {
308+
// Ship is not present in the mission (never arrived, destroyed, or departed)
309+
return LuaValue::createValue(_action.getLuaState(), l_Subsystem.Set(ship_subsys_h()));
310310
}
311311

312312
ship_subsys* ss = ship_get_subsys(ship_entry->shipp(), name);
313-
313+
314314
return LuaValue::createValue(_action.getLuaState(), l_Subsystem.Set(ship_subsys_h(ship_entry->objp(), ss)));
315315
}
316316
case OPF_DOCKER_POINT: {
@@ -334,7 +334,7 @@ luacpp::LuaValue LuaSEXP::sexpToLua(int node, int argnum, int parent_node) const
334334
auto ship_entry = eval_ship(this_node);
335335
if (!ship_entry || !ship_entry->has_shipp()) {
336336
// Name is invalid
337-
return LuaValue::createValue(_action.getLuaState(), l_Ship.Set(object_h()));
337+
return LuaValue::createValue(_action.getLuaState(), l_Dockingbay.Set(dockingbay_h()));
338338
}
339339

340340
auto docker_pm = model_get(Ship_info[ship_entry->shipp()->ship_info_index].model_num);

0 commit comments

Comments
 (0)