Skip to content

Commit c9d71ce

Browse files
committed
correct shipname return type
The return type of "shipname" is a string, so if the ship can't be found, return an empty string instead of an invalid ship.
1 parent e742bd1 commit c9d71ce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

code/parse/sexp/LuaSEXP.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ luacpp::LuaValue LuaSEXP::sexpToLua(int node, int argnum) const {
174174
auto ship_entry = eval_ship(node);
175175

176176
// if this is a shipname type, we want the name of a valid ship but not the ship itself
177-
if (ship_entry && argtype.first == "shipname") {
178-
return LuaValue::createValue(_action.getLuaState(), ship_entry->name);
177+
// (if the ship is not valid, return an empty string)
178+
if (argtype.first == "shipname") {
179+
return LuaValue::createValue(_action.getLuaState(), ship_entry ? ship_entry->name : "");
179180
}
180181

181182
if (!ship_entry || ship_entry->status != ShipStatus::PRESENT) {

0 commit comments

Comments
 (0)