Skip to content

Commit

Permalink
Fix two bugs, one regarding equipment with requires_cargo_space set w…
Browse files Browse the repository at this point in the history
…hen fully loaded with cargo and one about misreporting available cargo space when fully loaded and with equipment requiring cargo space present.
  • Loading branch information
AnotherCommander committed Jan 14, 2014
1 parent 7f5e17b commit 22da020
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Core/Entities/ShipEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -3090,7 +3090,7 @@ - (BOOL) equipmentValidToAdd:(NSString *)equipmentKey whileLoading:(BOOL)loading
// while loading, we mainly need to catch changes when the installed oxps set has changed since saving.
if ([eqType requiresEmptyPylon] && [self missileCount] >= [self missileCapacity] && !loading) return NO;
if ([eqType requiresMountedPylon] && [self missileCount] == 0 && !loading) return NO;
if ([self availableCargoSpace] < [eqType requiredCargoSpace]) return NO;
if ([self availableCargoSpace] < [eqType requiredCargoSpace] && !loading) return NO;
if ([eqType requiresEquipment] != nil && ![self hasAllEquipment:[eqType requiresEquipment] includeWeapons:YES whileLoading:loading]) return NO;
if ([eqType requiresAnyEquipment] != nil && ![self hasEquipmentItem:[eqType requiresAnyEquipment] includeWeapons:YES whileLoading:loading]) return NO;
if ([eqType incompatibleEquipment] != nil && [self hasEquipmentItem:[eqType incompatibleEquipment] includeWeapons:YES whileLoading:loading]) return NO;
Expand Down Expand Up @@ -7633,7 +7633,7 @@ - (OOCargoQuantity) maxAvailableCargoSpace
- (OOCargoQuantity) availableCargoSpace
{
// OOCargoQuantity is unsigned, we need to check for underflows.
if (EXPECT_NOT([self cargoQuantityOnBoard] + equipment_weight >= [self maxAvailableCargoSpace])) return 0;
if (EXPECT_NOT([self cargoQuantityOnBoard] + equipment_weight >= max_cargo)) return 0;
return [self maxAvailableCargoSpace] - [self cargoQuantityOnBoard];
}

Expand Down

0 comments on commit 22da020

Please sign in to comment.