Various bugfixes

- saveload and planetinfo changes
 - corona_flare now more consistent with radius of planet
 - system info during nova mission saved better
This commit is contained in:
cim 2014-12-06 15:05:37 +00:00
parent 8eebf744ed
commit 1de828017d
8 changed files with 48 additions and 25 deletions

View File

@ -152,12 +152,12 @@ this._flareTransition = function(delta)
current -= delta/10; current -= delta/10;
} }
system.info.corona_flare = current; system.info.corona_flare = current;
if (this._flareTarget > 0.375 && current > this._flareTarget) if (this._flareTarget > 0.275 && current > this._flareTarget)
{ {
removeFrameCallback(this._flareCallback); removeFrameCallback(this._flareCallback);
delete this._flareCallback; delete this._flareCallback;
} }
else if (this._flareTarget < 0.375 && current < this._flareTarget) else if (this._flareTarget < 0.275 && current < this._flareTarget)
{ {
removeFrameCallback(this._flareCallback); removeFrameCallback(this._flareCallback);
delete this._flareCallback; delete this._flareCallback;
@ -295,7 +295,11 @@ this.shipWillEnterWitchspace = function ()
if (this.willGoNova) if (this.willGoNova)
{ {
system.info.sun_gone_nova = true; system.info.sun_gone_nova = true;
system.info.sun_radius = this._novaRadius;
system.info.corona_flare = 0.3;
system.info.corona_hues = 0.05;
delete this.willGoNova; delete this.willGoNova;
delete this._novaRadius;
// did the player leave the nova system without docking at the main station? // did the player leave the nova system without docking at the main station?
if (missionVariables.nova === "TWO_HRS_TO_ZERO") if (missionVariables.nova === "TWO_HRS_TO_ZERO")
{ {
@ -316,6 +320,7 @@ this.shipWillExitWitchspace = function ()
// the populator has started the nova mission // the populator has started the nova mission
player.ship.fuelLeakRate = 25; player.ship.fuelLeakRate = 25;
this.willGoNova = true; this.willGoNova = true;
this._novaRadius = system.sun.radius + 600000;
player.consoleMessage(expandDescription("[danger-fuel-leak]"), 4.5); player.consoleMessage(expandDescription("[danger-fuel-leak]"), 4.5);
this.buoyLoaded = false; // w-bouy is not in system yet. this.buoyLoaded = false; // w-bouy is not in system yet.
if (this.novaMissionTimer) if (this.novaMissionTimer)
@ -343,6 +348,9 @@ this.systemWillPopulate = function() // call this as soon as possible so other s
{ {
missionVariables.nova = "TWO_HRS_TO_ZERO"; missionVariables.nova = "TWO_HRS_TO_ZERO";
system.sun.goNova(7200); system.sun.goNova(7200);
if (system.info.corona_flare < 0.15) {
system.info.corona_flare = 0.15;
}
/* the main populator script might have run first. If so, remove /* the main populator script might have run first. If so, remove
* the ships it added. If it runs after, it'll notice the * the ships it added. If it runs after, it'll notice the
* impending nova and not add these lines in the first place */ * impending nova and not add these lines in the first place */

View File

@ -87,7 +87,7 @@ MA 02110-1301, USA.
- (void) getDiffuseComponents:(GLfloat[4])components; - (void) getDiffuseComponents:(GLfloat[4])components;
- (void) getSpecularComponents:(GLfloat[4])components; - (void) getSpecularComponents:(GLfloat[4])components;
- (void) setRadius:(GLfloat) rad; - (void) setRadius:(GLfloat) rad andCorona:(GLfloat)corona;
- (BOOL) willGoNova; - (BOOL) willGoNova;
- (BOOL) goneNova; - (BOOL) goneNova;

View File

@ -283,6 +283,8 @@ MA 02110-1301, USA.
{ {
// This sun has now gone nova! // This sun has now gone nova!
[UNIVERSE setSystemDataKey:@"sun_gone_nova" value:[NSNumber numberWithBool:YES] fromManifest:@"org.oolite.oolite"]; [UNIVERSE setSystemDataKey:@"sun_gone_nova" value:[NSNumber numberWithBool:YES] fromManifest:@"org.oolite.oolite"];
[UNIVERSE setSystemDataKey:@"corona_flare" value:[NSNumber numberWithFloat:0.3] fromManifest:@"org.oolite.oolite"];
[UNIVERSE setSystemDataKey:@"corona_hues" value:[NSNumber numberWithFloat:0.05] fromManifest:@"org.oolite.oolite"];
// Novas are stored under the core manifest if the // Novas are stored under the core manifest if the
// player was there at the time. Default layer 2 // player was there at the time. Default layer 2
// is fine. // is fine.
@ -290,8 +292,7 @@ MA 02110-1301, USA.
} }
discColor[0] = 1.0; discColor[1] = 1.0; discColor[2] = 1.0; discColor[0] = 1.0; discColor[1] = 1.0; discColor[2] = 1.0;
_novaExpansionTimer += delta_t; _novaExpansionTimer += delta_t;
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:collision_radius + delta_t * _novaExpansionRate], @"sun_radius", [NSNumber numberWithFloat:0.3], @"corona_flare", [NSNumber numberWithFloat:0.05], @"corona_hues", nil]; [UNIVERSE setSystemDataKey:@"sun_radius" value:[NSNumber numberWithFloat:collision_radius + delta_t * _novaExpansionRate] fromManifest:@"org.oolite.oolite"];
[self changeSunProperty:@"sun_radius" withDictionary:dict];
} }
else else
{ {
@ -647,8 +648,7 @@ MA 02110-1301, USA.
if ([key isEqualToString:@"sun_radius"]) if ([key isEqualToString:@"sun_radius"])
{ {
oldRadius = [object doubleValue]; // clamp corona_flare in case planetinfo.plist / savegame contains the wrong value oldRadius = [object doubleValue]; // clamp corona_flare in case planetinfo.plist / savegame contains the wrong value
[self setRadius: oldRadius + (0.66*MAX_CORONAFLARE * OOClamp_0_1_f([dict oo_floatForKey:@"corona_flare" defaultValue:0.0f]))]; [self setRadius:oldRadius andCorona:[dict oo_floatForKey:@"corona_flare" defaultValue:0.0f]];
collision_radius = oldRadius;
} }
else if ([key isEqualToString:KEY_SUNNAME]) else if ([key isEqualToString:KEY_SUNNAME])
{ {
@ -656,9 +656,7 @@ MA 02110-1301, USA.
} }
else if ([key isEqualToString:@"corona_flare"]) else if ([key isEqualToString:@"corona_flare"])
{ {
double rad = collision_radius; [self setRadius:collision_radius andCorona:[object floatValue]];
[self setRadius: rad + (0.66*MAX_CORONAFLARE * OOClamp_0_1_f([object floatValue]))];
collision_radius = rad;
} }
else if ([key isEqualToString:@"corona_shimmer"]) else if ([key isEqualToString:@"corona_shimmer"])
{ {
@ -679,8 +677,7 @@ MA 02110-1301, USA.
{ {
[self setGoingNova:NO inTime:0]; [self setGoingNova:NO inTime:0];
// oldRadius is always the radius we had before going nova... // oldRadius is always the radius we had before going nova...
[self setRadius: oldRadius + (0.66*MAX_CORONAFLARE * OOClamp_0_1_f([dict oo_floatForKey:@"corona_flare" defaultValue:0.0f]))]; [self setRadius: oldRadius andCorona:[dict oo_floatForKey:@"corona_flare" defaultValue:0.0f]];
collision_radius = oldRadius;
} }
} }
@ -719,12 +716,17 @@ MA 02110-1301, USA.
} }
- (void) setRadius:(GLfloat) rad - (void) setRadius:(GLfloat) rad andCorona:(GLfloat)corona
{ {
collision_radius = rad; collision_radius = rad;
if (corona < 0.01f) {
cor16k = rad * rad * 16 / 10000000; corona = 0.01f;
lim16k = cor16k * cor16k* NO_DRAW_DISTANCE_FACTOR*NO_DRAW_DISTANCE_FACTOR; }
cor16k = rad * 8 * corona;
GLfloat corouter = rad * (1+(8*corona));
lim16k = corouter * corouter * NO_DRAW_DISTANCE_FACTOR*NO_DRAW_DISTANCE_FACTOR;
} }

View File

@ -2550,6 +2550,7 @@ NSComparisonResult marketSorterByMassUnit(id a, id b, void *market);
double sun_cr = sun->collision_radius; double sun_cr = sun->collision_radius;
double alt1 = sun_cr * sun_cr / sun_zd; double alt1 = sun_cr * sun_cr / sun_zd;
external_temp = SUN_TEMPERATURE * alt1; external_temp = SUN_TEMPERATURE * alt1;
if ([sun goneNova]) if ([sun goneNova])
external_temp *= 100; external_temp *= 100;
// fuel scooping during the nova mission very unlikely // fuel scooping during the nova mission very unlikely

View File

@ -642,14 +642,14 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
} }
} }
if (![UNIVERSE setUseAddOns:scenarioRestrict fromSaveGame:YES]) if (![UNIVERSE setUseAddOns:scenarioRestrict fromSaveGame:YES forceReinit:YES])
{ {
fail_reason = DESC(@"loadfailed-saved-game-failed-to-load"); fail_reason = DESC(@"loadfailed-saved-game-failed-to-load");
loadedOK = NO; loadedOK = NO;
} }
} }
if (loadedOK) if (loadedOK)
{ {
OOLog(@"load.progress",@"Creating player ship"); OOLog(@"load.progress",@"Creating player ship");

View File

@ -118,6 +118,10 @@ HPVector OORandomPositionInCylinder(HPVector centre1, OOHPScalar exclusion1, HPV
{ {
OOHPScalar exc12 = exclusion1*exclusion1; OOHPScalar exc12 = exclusion1*exclusion1;
OOHPScalar exc22 = exclusion2*exclusion2; OOHPScalar exc22 = exclusion2*exclusion2;
if (HPdistance(centre1,centre2) < (exclusion1+exclusion2)*1.2)
{
OOLog(@"position.cylinder.error",@"Trying to generate cylinder position in range %f long with exclusions %f and %f",HPdistance(centre1,centre2),exclusion1,exclusion2);
}
HPVector result; HPVector result;
do do
{ {

View File

@ -348,6 +348,9 @@ enum
- (NSString *) useAddOns; - (NSString *) useAddOns;
- (BOOL) setUseAddOns:(NSString *)newUse fromSaveGame: (BOOL)saveGame; - (BOOL) setUseAddOns:(NSString *)newUse fromSaveGame: (BOOL)saveGame;
- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame forceReinit:(BOOL)force;
- (void) setUpSettings;
- (BOOL) reinitAndShowDemo:(BOOL)showDemo; - (BOOL) reinitAndShowDemo:(BOOL)showDemo;

View File

@ -180,7 +180,6 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context);
@interface Universe (OOPrivate) @interface Universe (OOPrivate)
- (BOOL) doRemoveEntity:(Entity *)entity; - (BOOL) doRemoveEntity:(Entity *)entity;
- (void) setUpSettings;
- (void) setUpCargoPods; - (void) setUpCargoPods;
- (void) setUpInitialUniverse; - (void) setUpInitialUniverse;
- (HPVector) fractionalPositionFrom:(HPVector)point0 to:(HPVector)point1 withFraction:(double)routeFraction; - (HPVector) fractionalPositionFrom:(HPVector)point0 to:(HPVector)point1 withFraction:(double)routeFraction;
@ -506,10 +505,16 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame - (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame
{ {
if ([newUse isEqualToString:useAddOns]) return [self setUseAddOns:newUse fromSaveGame:saveGame forceReinit:NO];
}
- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame forceReinit:(BOOL)force
{
if (!force && [newUse isEqualToString:useAddOns])
{ {
return YES; return YES;
} }
DESTROY(useAddOns); DESTROY(useAddOns);
useAddOns = [newUse retain]; useAddOns = [newUse retain];
@ -1049,7 +1054,7 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
sun_radius = [systeminfo oo_nonNegativeDoubleForKey:@"sun_radius" defaultValue:2.5 * planet_radius]; sun_radius = [systeminfo oo_nonNegativeDoubleForKey:@"sun_radius" defaultValue:2.5 * planet_radius];
// clamp the sun radius // clamp the sun radius
if ((sun_radius < 1000.0) || (sun_radius > sun_distance / 2 )) if ((sun_radius < 1000.0) || (sun_radius > sun_distance / 2 && !sunGoneNova))
{ {
OOLogWARN(@"universe.setup.badSun",@"Sun radius of %f is not valid for this system",sun_radius); OOLogWARN(@"universe.setup.badSun",@"Sun radius of %f is not valid for this system",sun_radius);
sun_radius = sun_radius < 1000.0 ? 1000.0 : (sun_distance / 2); sun_radius = sun_radius < 1000.0 ? 1000.0 : (sun_distance / 2);
@ -1057,7 +1062,7 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
#ifdef OO_DUMP_PLANETINFO #ifdef OO_DUMP_PLANETINFO
OOLog(@"planetinfo.record",@"sun_radius = %f",sun_radius); OOLog(@"planetinfo.record",@"sun_radius = %f",sun_radius);
#endif #endif
safeDistance=16 * sun_radius * sun_radius; // 4 times the sun radius safeDistance=36 * sun_radius * sun_radius; // 6 times the sun radius
// here we need to check if the sun collides with (or is too close to) the witchpoint // here we need to check if the sun collides with (or is too close to) the witchpoint
// otherwise at (for example) Maregais in Galaxy 1 we go BANG! // otherwise at (for example) Maregais in Galaxy 1 we go BANG!
@ -1125,7 +1130,7 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
if (sunGoneNova) if (sunGoneNova)
{ {
[a_sun setRadius: sun_radius + MAX_CORONAFLARE]; [a_sun setRadius: sun_radius andCorona:0.3];
[a_sun setThrowSparks:YES]; [a_sun setThrowSparks:YES];
[a_sun setVelocity: kZeroVector]; [a_sun setVelocity: kZeroVector];
} }
@ -1421,7 +1426,7 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
- (HPVector) locationByCode:(NSString *)code withSun:(OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet - (HPVector) locationByCode:(NSString *)code withSun:(OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet
{ {
HPVector result = kZeroHPVector; HPVector result = kZeroHPVector;
if ([code isEqualToString:@"WITCHPOINT"] || sun == nil || planet == nil) if ([code isEqualToString:@"WITCHPOINT"] || sun == nil || planet == nil || [sun goneNova])
{ {
result = OOHPVectorRandomSpatial(SCANNER_MAX_RANGE); result = OOHPVectorRandomSpatial(SCANNER_MAX_RANGE);
} }