Minor cleanup:

- changed strings returned by the new playerWillSaveGame event for consistency with the other Oolite specific strings: 'autoSave' is now 'AUTO_SAVE', etc...
- tidier / simpler to read fuel calculation code, made fuel price slightly more variable...
- rewrote a very misleading (wrong as per r3972) comment.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3973 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Marc 2011-01-03 15:34:28 +00:00
parent 9f8b0d3b1a
commit 36e064d1ee
4 changed files with 14 additions and 30 deletions

View File

@ -297,7 +297,7 @@
script.javaScript.stackTrace.timeLimit = yes; // ...for time limiter
script.javaScript.stackTrace.warning = inherit; // ...for warnings
script.javaScript.warning.uselessExpr = no; // A bug in SpiderMonkey causes this warning to be raised when "use strict" is seen in pedantic mode, even though "use strict" is respected. https://bugzilla.mozilla.org/show_bug.cgi?id=559402
script.javaScript.warning.uselessExpr = yes; // A bug in SpiderMonkey causes this warning to be raised when "use strict" is seen in pedantic mode, even though "use strict" is respected. https://bugzilla.mozilla.org/show_bug.cgi?id=559402
script.load = no;
script.load.badName = $scriptError;

View File

@ -4462,16 +4462,14 @@ static bool minShieldLevelPercentageInitialised = false;
[self suppressTargetLost]; // No target lost messages when dead.
[self setStatus:STATUS_DEAD];
[self playGameOver];
// Let event scripts check for specific equipment on board when the player dies.
// Let event scripts know the player died.
if (whom == nil) whom = (id)[NSNull null];
[self doScriptEvent:@"shipDied" withArguments:[NSArray arrayWithObjects:whom, why, nil]];
[self setStatus:STATUS_DEAD]; // set dead again in case a script managed to revive the player.
// Then remove the equipment. This should avoid accidental scooping / equipment damage when dead.
[self removeAllEquipment];
[self removeAllEquipment]; // No scooping / equipment damage when dead.
[self loseTargetStatus];
[self showGameOver];
}

View File

@ -3,7 +3,7 @@
PlayerEntityLoadSave.m
Oolite
Copyright (C) 2004-2010 Giles C Williams and contributors
Copyright (C) 2004-2011 Giles C Williams and contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -142,7 +142,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
tmp_name = player_name;
tmp_path = save_path;
[self doScriptEvent:@"playerWillSaveGame" withArgument:@"autoSave"];
[self doScriptEvent:@"playerWillSaveGame" withArgument:@"AUTO_SAVE"];
NSString *saveName = player_name;
if (![player_name hasSuffix:DESC(@"autosave-commander-suffix")])
@ -182,7 +182,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
format:@"ERROR no file name returned by [[gameView gameController] playerFileToLoad]"];
}
[self doScriptEvent:@"playerWillSaveGame" withArgument:@"quickSave"];
[self doScriptEvent:@"playerWillSaveGame" withArgument:@"QUICK_SAVE"];
[self writePlayerToPath:path];
[[UNIVERSE gameView] supressKeysUntilKeyUp];
@ -581,7 +581,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
NSArray* path_components = [[sp filename] pathComponents];
NSString* new_name = [[path_components objectAtIndex:[path_components count]-1] stringByDeletingPathExtension];
[self doScriptEvent:@"playerWillSaveGame" withArgument:@"standardSave"];
[self doScriptEvent:@"playerWillSaveGame" withArgument:@"STANDARD_SAVE"];
[player_name release];
player_name = [new_name copy];
@ -636,7 +636,7 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
NSString* dir = [[UNIVERSE gameController] playerFileDirectory];
NSString *savePath = [dir stringByAppendingPathComponent:[cdrName stringByAppendingPathExtension:@"oolite-save"]];
[self doScriptEvent:@"playerWillSaveGame" withArgument:@"standardSave"];
[self doScriptEvent:@"playerWillSaveGame" withArgument:@"STANDARD_SAVE"];
[player_name release];
player_name = [cdrName copy];

View File

@ -100,27 +100,13 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
#if MASS_DEPENDENT_FUEL_PRICES
static GLfloat calcFuelChargeRate (GLfloat my_mass, GLfloat base_mass)
{
static const GLfloat massCharge = 0.65; // the closer to 1 this number is, the more the fuel price changes from ship to ship.
static const GLfloat baseCharge = 1.0 - massCharge; // proportion of price that doesn't change with ship's mass.
// if anything is wrong, default to cobra3 value.
if (my_mass == 0.0 || base_mass == 0.0) return 1.0;
if (my_mass <= 0.0 || base_mass <= 0.0) return 1.0;
GLfloat x = my_mass / base_mass;
static const GLfloat b = 0.6;
static const GLfloat c = 0.4;
/*
static const GLfloat a = 0.0;
static const GLfloat n = 1.0;
// ax+bx+c, where x is mass(player)/mass(base)
// result is normalised so that player==base gives 1.0
// base is normally the default player ship
GLfloat result = (a * powf (x, n) + b * x + c) / (a + b + c);
*/
// given the const values above, we can use a simpler alternative to get the same result:
GLfloat result = b * x + c;
GLfloat result = (massCharge * my_mass / base_mass) + baseCharge;
// round the result to the second decimal digit.
return (roundf ((float) (result * 100.0)) / 100.0);