Skip to content

Commit 0536732

Browse files
authored
Merge pull request #452 from OoliteProject/expanding_canAwardEquipment
Expanding ship.canAwardEquipment to allow other contexts
2 parents c90ee13 + 0b7c566 commit 0536732

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/Core/Scripting/OOJSShip.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2569,6 +2569,7 @@ static JSBool ShipCanAwardEquipment(JSContext *context, uintN argc, jsval *vp)
25692569

25702570
ShipEntity *thisEnt = nil;
25712571
NSString *key = nil;
2572+
NSString *ctx = @"scripted";
25722573
BOOL result;
25732574
BOOL exists;
25742575

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

25842585
if (exists)
25852586
{
2587+
if (argc > 1)
2588+
{
2589+
ctx = OOStringFromJSValue(context, OOJS_ARGV[1]);
2590+
if (![ctx isEqualToString:@"scripted"] && ![ctx isEqualToString:@"purchase"] && ![ctx isEqualToString:@"newShip"] && ![ctx isEqualToString:@"npc"])
2591+
{
2592+
OOJSReportBadArguments(context, @"Ship", @"canAwardEquipment", MIN(argc, 2U), OOJS_ARGV, nil, @"context");
2593+
return NO;
2594+
}
2595+
}
25862596
result = YES;
25872597

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

2591-
if (result) result = [thisEnt canAddEquipment:key inContext:@"scripted"];
2601+
if (result) result = [thisEnt canAddEquipment:key inContext:ctx];
25922602
}
25932603
else
25942604
{

0 commit comments

Comments
 (0)