Fix for constant exceptions when there are planets in witchspace (backported). Removed a bunch of cruft from Universe, and scanForNonThargoid debug messages.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1634 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2008-05-13 17:44:36 +00:00
parent 3ead8a420d
commit a04e4dcb37
4 changed files with 26 additions and 44 deletions

View File

@ -3442,11 +3442,9 @@ NSComparisonResult planetSort(id i1, id i2, void* context)
NSMutableArray *planets = nil;
NSArray *sortedPlanets = nil;
planets = (NSMutableArray *)[UNIVERSE planets];
planets = [UNIVERSE planetsAndSun];
if ([planets count] == 0) return nil;
[planets addObject:[UNIVERSE sun]];
PlanetEntity* the_planet = [planets objectAtIndex:0];
if ([planets count] >1)
{

View File

@ -953,12 +953,7 @@ WormholeEntity* whole;
}
}
if (found_target != NO_TARGET)
{
OOLog(@"ai.scanForNonThargoid.debug", @"scanForNonThargoid found target ship %@", [UNIVERSE entityForUniversalID:found_target]);
[shipAI message:@"TARGET_FOUND"];
}
if (found_target != NO_TARGET) [shipAI message:@"TARGET_FOUND"];
else [shipAI message:@"NOTHING_FOUND"];
}

View File

@ -154,10 +154,6 @@ enum
NSMutableArray *entities;
OOUniversalID station;
OOUniversalID sun;
OOUniversalID planet;
OOUniversalID firstBeacon, lastBeacon;
GLfloat skyClearColor[4];
@ -312,7 +308,8 @@ enum
- (StationEntity *) station;
- (PlanetEntity *) planet;
- (PlanetEntity *) sun;
- (NSArray *) planets; // Note: does not include sun.
- (NSMutableArray *) planets; // Note: does not include sun.
- (NSMutableArray *) planetsAndSun;
// Turn main station into just another station, for blowUpStation.
- (void) unMagicMainStation;

View File

@ -245,10 +245,6 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
cachedPlanet = nil;
cachedStation = nil;
station = NO_TARGET;
planet = NO_TARGET;
sun = NO_TARGET;
player = [[PlayerEntity alloc] init]; // alloc retains!
[self addEntity:player];
[player release];
@ -503,10 +499,6 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
cachedPlanet = nil;
cachedStation = nil;
station = NO_TARGET;
planet = NO_TARGET;
sun = NO_TARGET;
if (player == nil)
player = [[PlayerEntity alloc] init];
else
@ -640,9 +632,6 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
[self setUpSpace]; // first launch
}
station = [[self station] universalID];
planet = [[self planet] universalID];
sun = [[self sun] universalID];
[self setViewDirection:VIEW_FORWARD];
displayGUI = NO;
@ -767,18 +756,13 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
[thing setOrientation:randomQ];
[self addEntity:thing];
[thing release];
/*--*/
/*- the dust particle system -*/
thing = [[DustEntity alloc] init];
[thing setScanClass: CLASS_NO_DRAW];
[self addEntity:thing];
[thing release];
/*--*/
sun = NO_TARGET;
station = NO_TARGET;
planet = NO_TARGET;
sun_center_position[0] = 0.0;
sun_center_position[1] = 0.0;
sun_center_position[2] = 0.0;
@ -914,10 +898,7 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
[a_planet setPositionX:0 y:0 z:planet_zpos];
[a_planet setScanClass: CLASS_NO_DRAW];
[a_planet setEnergy: 1000000.0];
[self addEntity:a_planet]; // [entities addObject:a_planet];
planet = [a_planet universalID];
/*--*/
[self addEntity:a_planet];
// set the system seed for random number generation
seed_for_planet_description(system_seed);
@ -957,8 +938,7 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
[a_sun setRadius:sun_radius]; // 2.5 pr
[a_sun setScanClass: CLASS_NO_DRAW];
[a_sun setEnergy: 1000000.0];
[self addEntity:a_sun]; // [entities addObject:a_sun];
sun = [a_sun universalID];
[self addEntity:a_sun];
if (sunGoneNova)
{
@ -1026,10 +1006,9 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
[a_station setPosition: stationPos];
[a_station setPitch: 0.0];
[a_station setScanClass: CLASS_STATION];
[a_station setPlanet:[self entityForUniversalID:planet]];
[a_station setPlanet:[self planet]];
[a_station setEquivalentTechLevel:techlevel];
[self addEntity:a_station];
station = [a_station universalID];
}
cachedSun = a_sun;
@ -2729,7 +2708,7 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
}
- (NSArray *) planets
- (NSMutableArray *) planets
{
return [self findEntitiesMatchingPredicate:IsPlanetPredicate
parameter:NULL
@ -2738,6 +2717,19 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
}
- (NSMutableArray *) planetsAndSun
{
NSMutableArray *result = [self planets];
PlanetEntity *sun = [self sun];
if (sun != nil)
{
if (result != nil) [result addObject:sun];
else result = [NSMutableArray arrayWithObject:sun];
}
return result;
}
- (void) unMagicMainStation
{
StationEntity *theStation = [self station];
@ -5702,7 +5694,7 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
systemData = [self generateSystemData:target_system_seed];
economy = [systemData unsignedCharForKey:KEY_ECONOMY];
[self generateEconomicDataWithEconomy:economy andRandomFactor:([player random_factor] ^ station)&0xff];
[self generateEconomicDataWithEconomy:economy andRandomFactor:[player random_factor] & 0xff];
}