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:
parent
9f8b0d3b1a
commit
36e064d1ee
@ -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;
|
||||
|
@ -4463,15 +4463,13 @@ static bool minShieldLevelPercentageInitialised = false;
|
||||
[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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user