Fixed bug where station.shipyard generated shipyard when hasShipyard was false (#332)

This commit is contained in:
phkb 2019-04-19 19:09:13 +10:00 committed by AnotherCommander
parent 5f8a8ff80b
commit 8cad99b852

View File

@ -308,9 +308,17 @@ static JSBool StationGetProperty(JSContext *context, JSObject *this, jsid propID
case kStation_shipyard:
{
if ([entity localShipyard] == nil) [entity generateShipyard];
NSMutableArray *shipyard = [entity localShipyard];
*value = OOJSValueFromNativeObject(context, shipyard);
if (![entity hasShipyard])
{
// return null if station has no shipyard
*value = OOJSValueFromNativeObject(context, nil);
}
else
{
if ([entity localShipyard] == nil) [entity generateShipyard];
NSMutableArray *shipyard = [entity localShipyard];
*value = OOJSValueFromNativeObject(context, shipyard);
}
return YES;
}