Fixed scripted cargopods not containing cargo bug. Fixed unsigned going negative bug when trying to buy fuel without having sufficient credits.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1920 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
bc9cb5af7a
commit
9b068c9f4b
@ -5326,10 +5326,18 @@ static int last_outfitting_index;
|
||||
|
||||
if ([eqKey isEqualToString:@"EQ_FUEL"])
|
||||
{
|
||||
credits -= ([self fuelCapacity] - [self fuel]) * pricePerUnit;
|
||||
fuel = [self fuelCapacity];
|
||||
[self setGuiToEquipShipScreen:-1];
|
||||
return YES;
|
||||
OOCreditsQuantity creditsForRefuel = ([self fuelCapacity] - [self fuel]) * pricePerUnit;
|
||||
if (credits >= creditsForRefuel) // Ensure we don't overflow
|
||||
{
|
||||
credits -= creditsForRefuel;
|
||||
fuel = [self fuelCapacity];
|
||||
[self setGuiToEquipShipScreen:-1];
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
// check energy unit replacement
|
||||
|
@ -1879,11 +1879,13 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
ship = [self newShipWithRole:desc]; // retain count = 1
|
||||
|
||||
// Deal with scripted cargopods and ensure they are filled with something.
|
||||
if (ship && [ship hasPrimaryRole:@"cargopod"])
|
||||
if (ship && [ship hasRole:@"cargopod"])
|
||||
{
|
||||
NSArray *theCargopod = [self getContainersOfGoods:1 scarce:NO];
|
||||
[ship release]; // We are about to pass to cargopod an already generated object.
|
||||
ship = [theCargopod objectAtIndex:0];
|
||||
// Generating a cargopod gives it the primary role "cargopod", so we need to change it back to what was intended.
|
||||
[ship setPrimaryRole:desc];
|
||||
}
|
||||
|
||||
if (ship)
|
||||
@ -1901,7 +1903,7 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
|
||||
[ship setStatus:STATUS_IN_FLIGHT]; // or ships that were 'demo' ships become invisible!
|
||||
|
||||
if (![ship hasPrimaryRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
if (![ship hasRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
{
|
||||
[ship release];
|
||||
}
|
||||
@ -2173,11 +2175,13 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
ship = [self newShipWithRole:desc]; // retain count = 1
|
||||
|
||||
// Deal with scripted cargopods and ensure they are filled with something.
|
||||
if (ship && [ship hasPrimaryRole:@"cargopod"])
|
||||
if (ship && [ship hasRole:@"cargopod"])
|
||||
{
|
||||
NSArray *theCargopod = [self getContainersOfGoods:1 scarce:NO];
|
||||
[ship release]; // We are about to pass to cargopod an already generated object.
|
||||
ship = [theCargopod objectAtIndex:0];
|
||||
// Generating a cargopod gives it the primary role "cargopod", so we need to change it back to what was intended.
|
||||
[ship setPrimaryRole:desc];
|
||||
}
|
||||
|
||||
if (ship)
|
||||
@ -2193,7 +2197,7 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
[self addEntity:ship];
|
||||
[[ship getAI] setState:@"GLOBAL"]; // must happen after adding to the universe!
|
||||
[ship setStatus:STATUS_IN_FLIGHT]; // or ships that were 'demo' ships become invisible!
|
||||
if (![ship hasPrimaryRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
if (![ship hasRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
{
|
||||
[ship release];
|
||||
}
|
||||
@ -2224,13 +2228,15 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
return NO;
|
||||
|
||||
// Deal with scripted cargopods and ensure they are filled with something.
|
||||
if (ship && [ship hasPrimaryRole:@"cargopod"])
|
||||
if (ship && [ship hasRole:@"cargopod"])
|
||||
{
|
||||
NSArray *theCargopod = [self getContainersOfGoods:1 scarce:NO];
|
||||
[ship release];
|
||||
ship = [theCargopod objectAtIndex:0];
|
||||
if (!ship)
|
||||
return NO;
|
||||
// Generating a cargopod gives it the primary role "cargopod", so we need to change it back to what was intended.
|
||||
[ship setPrimaryRole:desc];
|
||||
}
|
||||
|
||||
if (![ship crew] && ![ship isUnpiloted] && !(ship->scanClass == CLASS_CARGO || ship->scanClass == CLASS_ROCK))
|
||||
@ -2291,7 +2297,7 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
[self addEntity:ship];
|
||||
[[ship getAI] setState:@"GLOBAL"]; // must happen after adding to the universe!
|
||||
[ship setStatus:STATUS_IN_FLIGHT]; // or ships that were 'demo' ships become invisible!
|
||||
if (![ship hasPrimaryRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
if (![ship hasRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
{
|
||||
[ship release];
|
||||
}
|
||||
@ -2391,11 +2397,13 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
ship = [self newShipWithRole:desc]; // retain count = 1
|
||||
|
||||
// Deal with scripted cargopods and ensure they are filled with something.
|
||||
if (ship && [ship hasPrimaryRole:@"cargopod"])
|
||||
if (ship && [ship hasRole:@"cargopod"])
|
||||
{
|
||||
NSArray *theCargopod = [self getContainersOfGoods:1 scarce:NO];
|
||||
[ship release]; // We are about to pass to cargopod an already generated object.
|
||||
ship = [theCargopod objectAtIndex:0];
|
||||
// Generating a cargopod gives it the primary role "cargopod", so we need to change it back to what was intended.
|
||||
[ship setPrimaryRole:desc];
|
||||
}
|
||||
|
||||
if (ship)
|
||||
@ -2411,7 +2419,7 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
[self addEntity:ship];
|
||||
[[ship getAI] setState:@"GLOBAL"]; // must happen after adding to the universe!
|
||||
[ship setStatus:STATUS_IN_FLIGHT]; // or ships that were 'demo' ships become invisible!
|
||||
if (![ship hasPrimaryRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
if (![ship hasRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
{
|
||||
[ship release];
|
||||
}
|
||||
@ -2485,11 +2493,13 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
ship = [self newShipWithRole:role]; // retain count = 1
|
||||
|
||||
// Deal with scripted cargopods and ensure they are filled with something.
|
||||
if (ship && [ship hasPrimaryRole:@"cargopod"])
|
||||
if (ship && [ship hasRole:@"cargopod"])
|
||||
{
|
||||
NSArray *theCargopod = [self getContainersOfGoods:1 scarce:NO];
|
||||
[ship release]; // We are about to pass to cargopod an already generated object.
|
||||
ship = [theCargopod objectAtIndex:0];
|
||||
// Generating a cargopod gives it the primary role "cargopod", so we need to change it back to what was intended.
|
||||
[ship setPrimaryRole:role];
|
||||
}
|
||||
|
||||
if (ship)
|
||||
@ -2518,7 +2528,7 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
[[ship getAI] setState:@"GLOBAL"]; // must happen after adding to the universe!
|
||||
[ship setStatus:STATUS_IN_FLIGHT]; // or ships may not werk rite d'uh!
|
||||
|
||||
if (![ship hasPrimaryRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
if (![ship hasRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
{
|
||||
[ship release];
|
||||
}
|
||||
@ -2542,11 +2552,13 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
ship = [self newShipWithRole:desc]; // retain count = 1
|
||||
|
||||
// Deal with scripted cargopods and ensure they are filled with something.
|
||||
if ([ship hasPrimaryRole:@"cargopod"])
|
||||
if ([ship hasRole:@"cargopod"])
|
||||
{
|
||||
NSArray *theCargopod = [self getContainersOfGoods:1 scarce:NO];
|
||||
[ship release]; // We are about to pass to cargopod an already generated object.
|
||||
ship = [[theCargopod objectAtIndex:0] retain];
|
||||
// Generating a cargopod gives it the primary role "cargopod", so we need to change it back to what was intended.
|
||||
[ship setPrimaryRole:desc];
|
||||
}
|
||||
|
||||
if (ship != nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user