Skip to content

Commit

Permalink
Expanding ship.canAwardEquipment to allow other contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
phkb committed Oct 3, 2023
1 parent c90ee13 commit 0b7c566
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Core/Scripting/OOJSShip.m
Original file line number Diff line number Diff line change
Expand Up @@ -2569,6 +2569,7 @@ static JSBool ShipCanAwardEquipment(JSContext *context, uintN argc, jsval *vp)

ShipEntity *thisEnt = nil;
NSString *key = nil;
NSString *ctx = @"scripted";
BOOL result;
BOOL exists;

Expand All @@ -2583,12 +2584,21 @@ static JSBool ShipCanAwardEquipment(JSContext *context, uintN argc, jsval *vp)

if (exists)
{
if (argc > 1)
{
ctx = OOStringFromJSValue(context, OOJS_ARGV[1]);
if (![ctx isEqualToString:@"scripted"] && ![ctx isEqualToString:@"purchase"] && ![ctx isEqualToString:@"newShip"] && ![ctx isEqualToString:@"npc"])
{
OOJSReportBadArguments(context, @"Ship", @"canAwardEquipment", MIN(argc, 2U), OOJS_ARGV, nil, @"context");
return NO;
}
}
result = YES;

// can't add fuel as equipment.
if ([key isEqualToString:@"EQ_FUEL"]) result = NO;

if (result) result = [thisEnt canAddEquipment:key inContext:@"scripted"];
if (result) result = [thisEnt canAddEquipment:key inContext:ctx];
}
else
{
Expand Down

0 comments on commit 0b7c566

Please sign in to comment.