Fixed max_cargo going negative when max_passengers was set to a value that resulted in more cargo required than available on player ship.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4590 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
c053277bbb
commit
bd49699af7
@ -866,7 +866,18 @@ static GLfloat sBaseMass = 0.0;
|
||||
unsigned original_hold_size = [UNIVERSE maxCargoForShip:[self shipDataKey]];
|
||||
max_cargo = [dict oo_intForKey:@"max_cargo" defaultValue:max_cargo];
|
||||
if (max_cargo > original_hold_size) [self addEquipmentItem:@"EQ_CARGO_BAY"];
|
||||
max_cargo = original_hold_size + ([self hasExpandedCargoBay] ? extra_cargo : 0) - max_passengers * 5;
|
||||
max_cargo = original_hold_size + ([self hasExpandedCargoBay] ? extra_cargo : 0);
|
||||
if (max_cargo >= max_passengers * 5)
|
||||
{
|
||||
max_cargo -= max_passengers * 5;
|
||||
}
|
||||
else // Handle case where something went wrong. Possibly the save file was hacked to contain more passenger cabins than the available cargo space would allow - Nikos 20110731
|
||||
{
|
||||
unsigned originalMaxPassengers = max_passengers;
|
||||
max_passengers = (unsigned)(max_cargo / 5); // we should really make the magic number 5 a constant - something like PASSENGER_BERTH_REQUIRED_SPACE or similar
|
||||
OOLogWARN(@"setCommanderDataFromDictionary.max_cargo.isNegative", @"max_cargo for player ship %@ gone negative, probably due to max_passengers (%u) being set to a value that requires more cargo space than it is available on player ship. Resetting max_passengers to %u to compensate.", [self name], originalMaxPassengers, max_passengers);
|
||||
}
|
||||
|
||||
credits = OODeciCreditsFromObject([dict objectForKey:@"credits"]);
|
||||
|
||||
fuel = [dict oo_unsignedIntForKey:@"fuel" defaultValue:fuel];
|
||||
|
Loading…
x
Reference in New Issue
Block a user