Changed OOCreditsQuantity to uint64_t.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1274 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2007-12-13 11:53:25 +00:00
parent 1dd0b50f52
commit 4919cb197e
13 changed files with 199 additions and 205 deletions

View File

@ -974,7 +974,7 @@
083325DC09DDBCDE00F5B8E4 /* OOColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOColor.m; sourceTree = "<group>"; };
083DB4D30A70E51E00B419B2 /* OOBrain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOBrain.h; sourceTree = "<group>"; };
083DB4D40A70E51E00B419B2 /* OOBrain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOBrain.m; sourceTree = "<group>"; };
0865432206B8447D000CA0AB /* OoliteDev.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OoliteDev.app; sourceTree = BUILT_PRODUCTS_DIR; };
0865432206B8447D000CA0AB /* Oolite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Oolite.app; sourceTree = BUILT_PRODUCTS_DIR; };
0878FD2F086EF845004CB752 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
1A020E0A0D020AFB00C3F51E /* changedScriptHandlers.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = changedScriptHandlers.plist; sourceTree = "<group>"; };
@ -1003,7 +1003,7 @@
1A2316E90B9CFAD700EF0852 /* missiontext.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = missiontext.plist; sourceTree = "<group>"; };
1A2316EB0B9CFAD700EF0852 /* shipdata.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = shipdata.plist; sourceTree = "<group>"; };
1A2316EC0B9CFAD700EF0852 /* shipyard.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = shipyard.plist; sourceTree = "<group>"; };
1A2316ED0B9CFAD700EF0852 /* speech_pronunciation_guide.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = speech_pronunciation_guide.plist; sourceTree = "<group>"; };
1A2316ED0B9CFAD700EF0852 /* speech_pronunciation_guide.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = speech_pronunciation_guide.plist; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.plist; };
1A2317910B9D022400EF0852 /* buoyAI.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = buoyAI.plist; sourceTree = "<group>"; };
1A2317920B9D022500EF0852 /* collectLootAI.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = collectLootAI.plist; sourceTree = "<group>"; };
1A2317930B9D022500EF0852 /* dockingAI.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = dockingAI.plist; sourceTree = "<group>"; };
@ -1605,7 +1605,7 @@
19C28FACFE9D520D11CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
0865432206B8447D000CA0AB /* OoliteDev.app */,
0865432206B8447D000CA0AB /* Oolite.app */,
1A71E6F30BCE340C00CD5C13 /* libpng.a */,
);
name = Products;
@ -2756,7 +2756,7 @@
name = Oolite;
productInstallPath = "$(HOME)/Applications";
productName = Oolite;
productReference = 0865432206B8447D000CA0AB /* OoliteDev.app */;
productReference = 0865432206B8447D000CA0AB /* Oolite.app */;
productType = "com.apple.product-type.application";
};
1A71E6F20BCE340C00CD5C13 /* libpng-custom */ = {

View File

@ -1,70 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<array>
<string>\n</string>
<string> </string>
</array>
<array>
<string>\t</string>
<string> </string>
</array>
<array>
<string>Cruiser</string><!-- must come before ' Cr' -->
<string>[[inpt PHON]]kr1UWz2AXr[[inpt TEXT]]</string>
</array>
<array>
<string> Cr</string>
<string> credits</string>
</array>
<array>
<string> s.</string>
<string> seconds</string>
</array>
<array>
<string>Purse</string>
<string>, Total </string>
</array>
<array>
<string>Mark III</string>
<string>Mach Three</string>
</array>
<array>
<string>Mark II</string>
<string>Mach Two</string>
</array>
<array>
<string>Mark I</string>
<string>Mach One</string>
</array>
<array>
<string>GalCop</string>
<string>galactic police</string>
</array>
<array>
<string>Witchspace</string>
<string>[[inpt PHON]]w1IHCsp2EYs[[inpt TEXT]]</string>
</array>
<array>
<string>Fer-de-Lance</string>
<string>[[inpt PHON]]f1&lt;EY&lt;&lt;AE=dEH=l2UXns[[inpt TEXT]]</string>
</array>
<array>
<string>Sidewinder</string>
<string>[[inpt PHON]]s1AYdw2AYndAX[[inpt TEXT]]</string>
</array>
<array>
<string>Rebel</string>
<string>[[inpt PHON]]rEHbUXl[[inpt TEXT]]</string>
</array>
<array>
<string>Metal fragment</string>
<string>metal [[inpt PHON]]fr1AEgmUHnt[[inpt TEXT]]</string>
</array>
<array>
<string>Ident</string>
<string>Identification</string>
</array>
</array>
</plist>
(
(
"\\n",
" "
),
(
"\\t",
" "
),
(
// must come before ' Cr'
Cruiser,
"[[inpt PHON]]kr1UWz2AXr[[inpt TEXT]]"
),
(
" Cr",
" credits"
),
(
" s.",
" seconds"
),
(
Purse,
", Total "
),
(
"Mark III",
"Mach Three"
),
(
"Mark II",
"Mach Two"
),
(
"Mark I",
"Mach One"
),
(
GalCop,
"[[inpt PHON]]g1AElkUXp[[inpt TEXT]]"
),
(
Witchspace,
"[[inpt PHON]]w1IHCsp2EYs[[inpt TEXT]]"
),
(
"Fer-de-Lance",
"[[inpt PHON]]f1<EY<<AE=dEH=l2UXns[[inpt TEXT]]"
),
(
Sidewinder,
"[[inpt PHON]]s1AYdw2AYndAX[[inpt TEXT]]"
),
(
Rebel,
"[[inpt PHON]]rEHbUXl[[inpt TEXT]]"
),
(
"Metal fragment",
"metal [[inpt PHON]]fr1AEgmUHnt[[inpt TEXT]]"
),
(
Ident,
Identification
)
)

View File

@ -71,7 +71,7 @@
"script.js",
"shipdata.plist",
"shipyard.plist",
"speech_pronounciation_guide.plist",
"speech_pronunciation_guide.plist",
"startextures.plist",
"world-scripts.plist"
);

View File

@ -274,8 +274,8 @@ static PlayerEntity *sSharedPlayer = nil;
[result setObject:player_name forKey:@"player_name"];
[result setObject:[NSNumber numberWithInt:credits] forKey:@"credits"];
[result setObject:[NSNumber numberWithInt:fuel] forKey:@"fuel"];
[result setObject:[NSNumber numberWithUnsignedLongLong:credits] forKey:@"credits"];
[result setObject:[NSNumber numberWithUnsignedInt:fuel] forKey:@"fuel"];
[result setObject:[NSNumber numberWithInt:galaxy_number] forKey:@"galaxy_number"];
@ -667,10 +667,8 @@ static PlayerEntity *sSharedPlayer = nil;
[self addExtraEquipment:@"EQ_CARGO_BAY"];
max_cargo -= max_passengers * 5;
if ([dict objectForKey:@"credits"])
credits = [(NSNumber *)[dict objectForKey:@"credits"] intValue];
if ([dict objectForKey:@"fuel"])
fuel = [(NSNumber *)[dict objectForKey:@"fuel"] intValue];
credits = [dict unsignedLongLongForKey:@"credits" defaultValue:credits];
fuel = [dict unsignedIntForKey:@"fuel" defaultValue:fuel];
if ([dict objectForKey:@"galaxy_number"])
galaxy_number = [(NSNumber *)[dict objectForKey:@"galaxy_number"] intValue];
@ -3422,9 +3420,9 @@ double scoopSoundPlayTime = 0.0;
{
if (!other)
return;
int score = 10 * [other bounty];
int killClass = other->scanClass; // **tgape** change (+line)
int kill_award = 1;
OOCreditsQuantity score = 10 * [other bounty];
OOScanClass killClass = other->scanClass; // **tgape** change (+line)
BOOL killAward = YES;
if ([other isPolice]) // oops, we shot a copper!
legalStatus |= 64;
@ -3437,7 +3435,7 @@ double scoopSoundPlayTime = 0.0;
if (![other hasRole:@"tharglet"]) // okay, we'll count tharglets as proper kills
{
score /= 10; // reduce bounty awarded
kill_award = 0; // don't award a kill
killAward = NO; // don't award a kill
}
}
}
@ -3456,10 +3454,9 @@ double scoopSoundPlayTime = 0.0;
}
}
while (kill_award > 0)
if (killAward)
{
ship_kills++;
kill_award--;
if ((ship_kills % 256) == 0)
{
// congratulations method needs to be delayed a fraction of a second
@ -5181,8 +5178,8 @@ static int last_outfitting_index;
{
// note this doesn't check the availability by tech-level
NSArray *equipdata = [UNIVERSE equipmentdata];
OOCreditsQuantity price_per_unit = [[[equipdata objectAtIndex:index] objectAtIndex:EQUIPMENT_PRICE_INDEX] intValue];
NSString *eq_key = [[equipdata objectAtIndex:index] objectAtIndex:EQUIPMENT_KEY_INDEX];
OOCreditsQuantity price_per_unit = [[equipdata arrayAtIndex:index] unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
NSString *eq_key = [[equipdata arrayAtIndex:index] stringAtIndex:EQUIPMENT_KEY_INDEX];
NSString *eq_key_damaged = [NSString stringWithFormat:@"%@_DAMAGED", eq_key];
double price = ([eq_key isEqual:@"EQ_FUEL"]) ? ((PLAYER_MAX_FUEL - fuel) * price_per_unit) : (price_per_unit);
double price_factor = 1.0;
@ -5414,7 +5411,7 @@ static int last_outfitting_index;
unsigned i;
for (i = 0; i < [equipdata count]; i++)
{
NSString *w_key = (NSString *)[(NSArray *)[equipdata objectAtIndex:i] objectAtIndex:EQUIPMENT_KEY_INDEX];
NSString *w_key = [[equipdata arrayAtIndex:i] stringAtIndex:EQUIPMENT_KEY_INDEX];
if (([eq_key isEqual:w_key])&&(![self hasExtraEquipment:eq_key]))
{
credits -= price;

View File

@ -1377,7 +1377,7 @@ static NSMutableDictionary* currentShipyard = nil;
// first check you can afford it!
NSDictionary* ship_info = [currentShipyard dictionaryForKey:key];
OOCreditsQuantity price = [ship_info unsignedIntForKey:SHIPYARD_KEY_PRICE];
OOCreditsQuantity price = [ship_info unsignedLongLongForKey:SHIPYARD_KEY_PRICE];
OOCreditsQuantity trade_in = [self tradeInValue];
if (credits + trade_in * 10 < price * 10)

View File

@ -872,7 +872,7 @@
NSString *shipDesc = [cdr stringForKey:@"ship_desc"];
NSString *shipName = nil;
NSDictionary *shipDict = nil;
NSString *rating;
NSString *rating = nil;
shipDict = [UNIVERSE getDictionaryForShip:shipDesc];
if(shipDict != nil)
@ -889,12 +889,12 @@
// Make a short description of the commander
NSString *legalDesc = nil;
int money;
OOCreditsQuantity money;
legalDesc = LegalStatusToString([cdr intForKey:@"legal_status"]);
rating = KillCountToRatingAndKillString([cdr unsignedIntForKey:@"ship_kills"]);
money = [cdr intForKey:@"credits"] / 10;
money = [cdr unsignedLongLongForKey:@"credits"] / 10;
// Nikos - Add some more information in the load game screen (current location, galaxy number and timestamp).
//-------------------------------------------------------------------------------------------------------------------------

View File

@ -6230,7 +6230,7 @@ BOOL class_masslocks(int some_class)
unsigned i;
for (i = 0; i < [[other crew] count]; i++)
{
OOCharacter* rescuee = (OOCharacter*)[[other crew] objectAtIndex:i];
OOCharacter *rescuee = [[other crew] objectAtIndex:i];
if ([rescuee legalStatus])
{
[UNIVERSE addMessage: [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[scoop-captured-@]"), [rescuee name]] forCount: 4.5];

View File

@ -25,7 +25,7 @@ MA 02110-1301, USA.
*/
#import <Foundation/Foundation.h>
#import "OOTypes.h"
#import "legacy_random.h"
@class OOBrain, Universe;
@ -38,7 +38,7 @@ MA 02110-1301, USA.
Random_Seed originSystemSeed;
Random_Seed genSeed;
int legalStatus;
int insuranceCredits;
OOCreditsQuantity insuranceCredits;
OOBrain *brain; // brain of character
@ -64,7 +64,7 @@ MA 02110-1301, USA.
- (Random_Seed) originSystemSeed;
- (Random_Seed) genSeed;
- (int) legalStatus;
- (int) insuranceCredits;
- (OOCreditsQuantity) insuranceCredits;
- (NSArray *) script;
- (OOBrain *) brain;
@ -74,7 +74,7 @@ MA 02110-1301, USA.
- (void) setOriginSystemSeed:(Random_Seed)value;
- (void) setGenSeed:(Random_Seed)value;
- (void) setLegalStatus:(int)value;
- (void) setInsuranceCredits: (int) value;
- (void) setInsuranceCredits:(OOCreditsQuantity)value;
- (void) setScript:(NSArray *)some_actions;
- (void) setBrain:(OOBrain *)aBrain;

View File

@ -27,14 +27,14 @@ MA 02110-1301, USA.
#import "Universe.h"
#import "OOBrain.h"
#import "OOStringParsing.h"
#import "OOCollectionExtractors.h"
#include "legacy_random.h"
@implementation OOCharacter
- (NSString *) descriptionComponents
{
return [NSString stringWithFormat:@"%@, %@. bounty: %i insurance:%i", [self name], [self shortDescription], [self legalStatus], [self insuranceCredits]];
return [NSString stringWithFormat:@"%@, %@. bounty: %i insurance: %llu", [self name], [self shortDescription], [self legalStatus], [self insuranceCredits]];
}
@ -217,9 +217,11 @@ MA 02110-1301, USA.
- (BOOL) castInRole:(NSString *) role
{
BOOL specialSetUpDone = NO;
NSString *legalDesc;
if ([[role lowercaseString] isEqual:@"pirate"])
role = [role lowercaseString];
if ([role isEqual:@"pirate"])
{
// determine legalStatus for a completely random character
int sins = 0x08 | (genSeed.a & genSeed.b);
@ -240,7 +242,7 @@ MA 02110-1301, USA.
specialSetUpDone = YES;
}
if ([[role lowercaseString] isEqual:@"trader"])
if ([role isEqual:@"trader"])
{
legalDesc = @"clean";
[self setLegalStatus: 0]; // clean
@ -263,7 +265,7 @@ MA 02110-1301, USA.
specialSetUpDone = YES;
}
if ([[role lowercaseString] isEqual:@"hunter"])
if ([role isEqual:@"hunter"])
{
legalDesc = @"clean";
[self setLegalStatus:0]; // clean
@ -273,7 +275,7 @@ MA 02110-1301, USA.
specialSetUpDone = YES;
}
if ([[role lowercaseString] isEqual:@"police"])
if ([role isEqual:@"police"])
{
legalDesc = @"clean";
[self setLegalStatus:0]; // clean
@ -281,7 +283,7 @@ MA 02110-1301, USA.
specialSetUpDone = YES;
}
if ([[role lowercaseString] isEqual:@"miner"])
if ([role isEqual:@"miner"])
{
legalDesc = @"clean";
[self setLegalStatus:0]; // clean
@ -289,7 +291,7 @@ MA 02110-1301, USA.
specialSetUpDone = YES;
}
if ([[role lowercaseString] isEqual:@"passenger"])
if ([role isEqual:@"passenger"])
{
legalDesc = @"clean";
[self setLegalStatus:0]; // clean
@ -311,7 +313,7 @@ MA 02110-1301, USA.
specialSetUpDone = YES;
}
if ([[role lowercaseString] isEqual:@"slave"])
if ([role isEqual:@"slave"])
{
legalDesc = @"clean";
[self setLegalStatus:0]; // clean
@ -362,7 +364,7 @@ MA 02110-1301, USA.
}
- (int)insuranceCredits
- (OOCreditsQuantity)insuranceCredits
{
return insuranceCredits;
}
@ -422,7 +424,7 @@ MA 02110-1301, USA.
}
- (void)setInsuranceCredits:(int)value
- (void)setInsuranceCredits:(OOCreditsQuantity)value
{
insuranceCredits = value;
}
@ -468,15 +470,14 @@ MA 02110-1301, USA.
[self basicSetUp];
}
if ([dict objectForKey:@"role"]) [self castInRole:[dict objectForKey:@"role"]];
if ([dict objectForKey:@"name"]) [self setName:[dict objectForKey:@"name"]];
if ([dict objectForKey:@"short_description"]) [self setShortDescription:[dict objectForKey:@"short_description"]];
if ([dict objectForKey:@"long_description"]) [self setLongDescription:[dict objectForKey:@"long_description"]];
if ([dict objectForKey:@"legal_status"]) [self setLegalStatus:[[dict objectForKey:@"legal_status"] intValue]];
if ([dict objectForKey:@"bounty"]) [self setLegalStatus:[[dict objectForKey:@"bounty"] intValue]];
if ([dict objectForKey:@"insurance"]) [self setInsuranceCredits:[[dict objectForKey:@"insurance"] intValue]];
if ([dict objectForKey:@"script_actions"]) [self setScript:[dict objectForKey:@"script_actions"]];
if ([dict stringForKey:@"role"]) [self castInRole:[dict stringForKey:@"role"]];
if ([dict stringForKey:@"name"]) [self setName:[dict stringForKey:@"name"]];
if ([dict stringForKey:@"short_description"]) [self setShortDescription:[dict stringForKey:@"short_description"]];
if ([dict stringForKey:@"long_description"]) [self setLongDescription:[dict stringForKey:@"long_description"]];
if ([dict objectForKey:@"legal_status"]) [self setLegalStatus:[dict intForKey:@"legal_status"]];
if ([dict objectForKey:@"bounty"]) [self setLegalStatus:[dict intForKey:@"bounty"]];
if ([dict objectForKey:@"insurance"]) [self setInsuranceCredits:[dict unsignedLongLongForKey:@"insurance"]];
if ([dict arrayForKey:@"script_actions"]) [self setScript:[dict arrayForKey:@"script_actions"]];
}
@end

View File

@ -288,7 +288,7 @@ typedef int32_t OOCargoQuantityDelta;
typedef uint16_t OOFuelQuantity;
typedef uint32_t OOCreditsQuantity;
typedef uint64_t OOCreditsQuantity;
typedef uint16_t OOKeyCode;

View File

@ -390,7 +390,6 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
#ifndef GNUSTEP
//// speech stuff
if (speechArray)
[speechArray autorelease];
speechArray = [[ResourceManager arrayFromFilesNamed:@"speech_pronunciation_guide.plist" inFolder:@"Config" andMerge:YES] retain];
@ -2951,7 +2950,7 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
if ([itemType isEqual:weapon_key])
{
return [itemData intAtIndex:EQUIPMENT_PRICE_INDEX];
return [itemData unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
}
}
return 0;
@ -7107,7 +7106,7 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
// get the basic information about the standard customer model for that craft
NSDictionary *shipyard_info = [shipyard dictionaryForKey:cmdr_ship_desc];
NSDictionary *basic_info = [shipyard_info dictionaryForKey:KEY_STANDARD_EQUIPMENT];
OOCreditsQuantity base_price = [shipyard_info unsignedIntForKey:SHIPYARD_KEY_PRICE];
OOCreditsQuantity base_price = [shipyard_info unsignedLongLongForKey:SHIPYARD_KEY_PRICE];
unsigned base_missiles = [basic_info unsignedIntForKey:KEY_EQUIPMENT_MISSILES];
OOCreditsQuantity base_missiles_value = base_missiles * [self getPriceForWeaponSystemWithKey:@"EQ_MISSILE"] / 10;
NSString *base_fwd_weapon_key = [basic_info stringForKey:KEY_EQUIPMENT_FORWARD_WEAPON];

View File

@ -58,24 +58,25 @@ int munge_checksum(int value)
// cunning price rounding routine:
//
float cunningFee(float value)
double cunningFee(double value)
{
float fee = value;
float superfee = 100000;
int rounded_fee = superfee * floor(0.5 + fee / superfee);
if (!rounded_fee)
rounded_fee = 1;
float ratio = fee / (float)rounded_fee;
while (((ratio < 0.95)||(ratio > 1.05))&&(superfee > 1))
double fee = value;
double superfee = 100000.0;
unsigned long long rounded_fee = superfee * floor(0.5 + fee / superfee);
if (rounded_fee == 0) rounded_fee = 1;
double ratio = fee / (double)rounded_fee;
while ((ratio < 0.95 || ratio > 1.05) && superfee > 1)
{
superfee /= 10;
rounded_fee = superfee * floor(0.5 + fee / superfee);
if (!rounded_fee)
rounded_fee = 1;
ratio = fee / (float)rounded_fee;
if (rounded_fee == 0) rounded_fee = 1;
ratio = fee / (double)rounded_fee;
superfee /= 10.0;
}
if ((ratio > 0.95)&&(ratio < 1.05))
if (ratio > 0.95 && ratio < 1.05)
fee = rounded_fee;
return fee;
}

View File

@ -66,8 +66,7 @@ void clear_checksum();
int munge_checksum(int value);
// cunning price rounding routine:
//
float cunningFee(float value) CONST_FUNC;
double cunningFee(double value);
// an implementation of RANROT
// pseudo random number generator