Show number of containers used for sub-tonne commodities in flight

This commit is contained in:
cim 2014-06-03 19:50:20 +01:00
parent 279babef76
commit 2030ccf4b8
2 changed files with 19 additions and 3 deletions

View File

@ -1359,6 +1359,8 @@
"equipment-pass-berth-@%1" = "%d Passenger Berths"; "equipment-pass-berth-@%1" = "%d Passenger Berths";
"equipment-@-not-available" = "%@ (N/A)"; "equipment-@-not-available" = "%@ (N/A)";
"manifest-cargo-quantity-format" = "%d %@ × %@"; // $count $units × $commodityName "manifest-cargo-quantity-format" = "%d %@ × %@"; // $count $units × $commodityName
"oolite-manifest-cargo-quantity-format2" = "%d %@ × %@ (%d TC)"; // $count $units × $commodityName ($containers TC)
// Short and Long Range Chart Overrides // Short and Long Range Chart Overrides
"charts-distance-f" = "Distance: %.1f Light Years"; "charts-distance-f" = "Distance: %.1f Light Years";

View File

@ -7000,8 +7000,18 @@ static GLfloat sBaseMass = 0.0;
{ {
NSString *desc = [commodity oo_stringForKey:@"displayName"]; NSString *desc = [commodity oo_stringForKey:@"displayName"];
NSString *units = [commodity oo_stringForKey:@"unit"]; NSString *units = [commodity oo_stringForKey:@"unit"];
[manifest addObject:[NSString stringWithFormat:DESC(@"manifest-cargo-quantity-format"), if (EXPECT([units isEqualToString:DESC(@"cargo-tons-symbol")] || [commodity oo_intForKey:@"containers"] == 0))
[commodity oo_intForKey:@"quantity"], units, desc]]; {
// normal display
[manifest addObject:[NSString stringWithFormat:DESC(@"manifest-cargo-quantity-format"),
[commodity oo_intForKey:@"quantity"], units, desc]];
}
else
{
// if low-mass cargo is occupying containers, show how many
[manifest addObject:[NSString stringWithFormat:DESC(@"oolite-manifest-cargo-quantity-format2"),
[commodity oo_intForKey:@"quantity"], units, desc, [commodity oo_intForKey:@"containers"]]];
}
} }
return manifest; return manifest;
@ -7014,16 +7024,19 @@ static GLfloat sBaseMass = 0.0;
NSUInteger i, commodityCount = [shipCommodityData count]; NSUInteger i, commodityCount = [shipCommodityData count];
OOCargoQuantity quantityInHold[commodityCount]; OOCargoQuantity quantityInHold[commodityCount];
OOCargoQuantity containersInHold[commodityCount];
// following changed to work whether docked or not // following changed to work whether docked or not
for (i = 0; i < commodityCount; i++) for (i = 0; i < commodityCount; i++)
{ {
quantityInHold[i] = [[shipCommodityData oo_arrayAtIndex:i] oo_unsignedIntAtIndex:MARKET_QUANTITY]; quantityInHold[i] = [[shipCommodityData oo_arrayAtIndex:i] oo_unsignedIntAtIndex:MARKET_QUANTITY];
containersInHold[i] = 0;
} }
for (i = 0; i < [cargo count]; i++) for (i = 0; i < [cargo count]; i++)
{ {
ShipEntity *container = [cargo objectAtIndex:i]; ShipEntity *container = [cargo objectAtIndex:i];
quantityInHold[[container commodityType]] += [container commodityAmount]; quantityInHold[[container commodityType]] += [container commodityAmount];
++containersInHold[[container commodityType]];
} }
for (i = 0; i < commodityCount; i++) for (i = 0; i < commodityCount; i++)
@ -7035,8 +7048,9 @@ static GLfloat sBaseMass = 0.0;
// commodity, quantity - keep consistency between .manifest and .contracts // commodity, quantity - keep consistency between .manifest and .contracts
[commodity setObject:CommodityTypeToString(i) forKey:@"commodity"]; [commodity setObject:CommodityTypeToString(i) forKey:@"commodity"];
[commodity setObject:[NSNumber numberWithUnsignedInt:quantityInHold[i]] forKey:@"quantity"]; [commodity setObject:[NSNumber numberWithUnsignedInt:quantityInHold[i]] forKey:@"quantity"];
[commodity setObject:[NSNumber numberWithUnsignedInt:containersInHold[i]] forKey:@"containers"];
[commodity setObject:CommodityDisplayNameForSymbolicName(symName) forKey:@"displayName"]; [commodity setObject:CommodityDisplayNameForSymbolicName(symName) forKey:@"displayName"];
[commodity setObject:DisplayStringForMassUnitForCommodity(i)forKey:@"unit"]; [commodity setObject:DisplayStringForMassUnitForCommodity(i) forKey:@"unit"];
[list addObject:commodity]; [list addObject:commodity];
} }
} }