Shipyard code now uses OOShipRegistry. Simplified some code by using OOEquipmentItem instead of fiddling with arrays; should do more of that.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1691 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2008-07-11 20:25:09 +00:00
parent 717e72ffae
commit fb3b2b7ebe
9 changed files with 144 additions and 188 deletions

View File

@ -779,7 +779,7 @@
"equipment-port-weapon-@" = "Port %@";
"equipment-single-pass-berth-@" = "1 Passenger Berth";
"equipment-multiple-pass-berth-@" = "%d Passenger Berths";
"equipment-not-available" = " (N/A)";
"equipment-@-not-available" = "%@ (N/A)";
"manifest-cargo-quantity-format" = "%d %@ × %@"; // $count $units × $commodityName
// Short Range Chart Screen

View File

@ -295,6 +295,8 @@
ship.escort.reject = no;
shipData.load.shipyard.unknown = no; // Warning for when shipyard.plist entries do not have matching shipdata.plist entry, disabled by default for Realistic Shipyards OXP.
shipData.load.begin = yes;
shipData.load.done = no;
sky.setup = no;

View File

@ -2680,9 +2680,7 @@ double scoopSoundPlayTime = 0.0;
start.x += (float)mcr * v_eject.x; start.y += (float)mcr * v_eject.y; start.z += (float)mcr * v_eject.z;
}
vel.x = (flightSpeed + throw_speed) * v_forward.x;
vel.y = (flightSpeed + throw_speed) * v_forward.y;
vel.z = (flightSpeed + throw_speed) * v_forward.z;
vel = vector_multiply_scalar(v_forward, flightSpeed + throw_speed);
origin.x = position.x + v_right.x * start.x + v_up.x * start.y + v_forward.x * start.z;
origin.y = position.y + v_right.y * start.x + v_up.y * start.y + v_forward.y * start.z;
@ -3352,21 +3350,15 @@ double scoopSoundPlayTime = 0.0;
// equipment damage
if (damage_to < [self equipmentCount])
{
NSArray* systems = [[self equipmentEnumerator] allObjects];
NSString* system_key = [systems objectAtIndex:damage_to];
NSString* system_name = nil;
if (([system_key hasSuffix:@"MISSILE"])||([system_key hasSuffix:@"MINE"])||([system_key isEqual:@"EQ_CARGO_BAY"]))
return;
NSArray* eq = [UNIVERSE equipmentData];
unsigned i;
for (i = 0; (i < [eq count])&&(!system_name); i++)
{
NSArray* eqd = [eq arrayAtIndex:i];
if ([system_key isEqual:[eqd objectAtIndex:EQUIPMENT_KEY_INDEX]])
system_name = [eqd stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
}
if (!system_name)
return;
NSArray *systems = [[self equipmentEnumerator] allObjects];
NSString *system_key = [systems objectAtIndex:damage_to];
NSString *system_name = nil;
if ([system_key hasSuffix:@"MISSILE"] || [system_key hasSuffix:@"MINE"] || [system_key isEqual:@"EQ_CARGO_BAY"]) return;
system_name = [[OOEquipmentType equipmentTypeWithIdentifier:system_key] name];
if (system_name == nil) return;
// set the following so removeEquipment works on the right entity
[self setScriptTarget:self];
[UNIVERSE clearPreviousMessage];
@ -4000,24 +3992,23 @@ double scoopSoundPlayTime = 0.0;
- (NSArray *) equipmentList
{
NSMutableArray *quip = [NSMutableArray array];
unsigned i;
NSArray *equipmentinfo = [UNIVERSE equipmentData];
NSArray *eqTypes = [OOEquipmentType allEquipmentTypes];
NSMutableArray *quip = [NSMutableArray arrayWithCapacity:[eqTypes count]];
NSEnumerator *eqTypeEnum = nil;
OOEquipmentType *eqType = nil;
for (i =0; i < [equipmentinfo count]; i++)
for (eqTypeEnum = [eqTypes objectEnumerator]; (eqType = [eqTypeEnum nextObject]); )
{
NSString *w_key = [[equipmentinfo arrayAtIndex:i] stringAtIndex:EQUIPMENT_KEY_INDEX];
NSString *w_key_damaged = [NSString stringWithFormat:@"%@_DAMAGED", w_key];
if ([self hasEquipmentItem:w_key])
if ([self hasEquipmentItem:[eqType identifier]])
{
[quip addObject:[[equipmentinfo arrayAtIndex:i] stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX]];
[quip addObject:[eqType name]];
}
if (![UNIVERSE strict])
else if (![UNIVERSE strict])
{
if ([self hasEquipmentItem:w_key_damaged])
// Check for damaged version
if ([self hasEquipmentItem:[[eqType identifier] stringByAppendingString:@"_DAMAGED"]])
{
[quip addObject:[[[equipmentinfo arrayAtIndex:i] stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX] stringByAppendingString:DESC(@"equipment-not-available")]];
[quip addObject:[NSString stringWithFormat:DESC(@"equipment-@-not-available"), [eqType name]]];
}
}
}
@ -4631,14 +4622,16 @@ static int last_outfitting_index;
NSMutableArray* equipment_allowed = [NSMutableArray array];
// find options that agree with this ship
NSMutableArray* options = [NSMutableArray arrayWithArray:[(NSDictionary *)[[UNIVERSE shipyard] objectForKey:ship_desc] objectForKey:KEY_OPTIONAL_EQUIPMENT]];
OOShipRegistry *registry = [OOShipRegistry sharedRegistry];
NSDictionary *shipyardInfo = [registry shipyardInfoForKey:ship_desc];
NSMutableArray *options = [NSMutableArray arrayWithArray:[shipyardInfo arrayForKey:KEY_OPTIONAL_EQUIPMENT]];
// add standard items too!
[options addObjectsFromArray:[(NSDictionary *)[(NSDictionary *)[[UNIVERSE shipyard] objectForKey:ship_desc] objectForKey:KEY_STANDARD_EQUIPMENT] objectForKey:KEY_EQUIPMENT_EXTRAS]];
[options addObjectsFromArray:[[[registry shipyardInfoForKey:ship_desc] dictionaryForKey:KEY_STANDARD_EQUIPMENT] arrayForKey:KEY_EQUIPMENT_EXTRAS]];
unsigned i,j;
for (i = 0; i < [equipdata count]; i++)
{
NSString *eq_key = (NSString*)[(NSArray*)[equipdata objectAtIndex:i] objectAtIndex:EQUIPMENT_KEY_INDEX];
NSString *eq_key = [[equipdata arrayAtIndex:i] stringAtIndex:EQUIPMENT_KEY_INDEX];
NSString *eq_key_damaged = [NSString stringWithFormat:@"%@_DAMAGED", eq_key];
OOTechLevelID min_techlevel = [[equipdata arrayAtIndex:i] unsignedIntAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
@ -4703,7 +4696,7 @@ static int last_outfitting_index;
if ((int)i == itemForSelectFacing)
{
skip = [equipment_allowed count] - 1; // skip to this upgrade
unsigned available_facings = [[[UNIVERSE shipyard] dictionaryForKey:ship_desc] unsignedIntForKey:KEY_WEAPON_FACINGS];
unsigned available_facings = [shipyardInfo unsignedIntForKey:KEY_WEAPON_FACINGS];
if (available_facings & WEAPON_FACING_FORWARD)
[equipment_allowed addUnsignedInteger:i];
if (available_facings & WEAPON_FACING_AFT)

View File

@ -37,6 +37,7 @@ MA 02110-1301, USA.
#import "MyOpenGLView.h"
#import "NSStringOOExtensions.h"
#import "OOShipRegistry.h"
#import "OOEquipmentType.h"
static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showShipyardModel";
@ -1323,14 +1324,12 @@ static NSMutableDictionary* currentShipyard = nil;
if (!dockedStation)
return;
Quaternion q2 = { (GLfloat)0.707, (GLfloat)0.707, (GLfloat)0.0, (GLfloat)0.0};
ship = [[ShipEntity alloc] init]; //retained
Quaternion q2 = { (GLfloat)0.707f, (GLfloat)0.707f, (GLfloat)0.0f, (GLfloat)0.0f };
ship = [[ShipEntity alloc] initWithDictionary:shipDict];
[ship wasAddedToUniverse];
[ship setUpShipFromDictionary:shipDict];
GLfloat cr = ship->collision_radius;
GLfloat cr = [ship collisionRadius];
OOLog(kOOLogNoteShowShipyardModel, @"::::: showShipyardModel:'%@'.", [ship name]);
[ship setOrientation: q2];
@ -1447,28 +1446,15 @@ static NSMutableDictionary* currentShipyard = nil;
// keep track of portable equipment..
NSArray *equipment = [UNIVERSE equipmentData];
NSMutableSet *portable_equipment = [NSMutableSet set];
NSEnumerator *eqEnum = nil;
NSString *eq_desc = nil;
OOEquipmentType *item = nil;
for (eqEnum = [self equipmentEnumerator]; (eq_desc = [eqEnum nextObject]);)
{
NSDictionary* eq_dict = nil;
for (i = 0; (i < [equipment count])&&(!eq_dict); i++)
{
NSArray* eq_info = [equipment objectAtIndex:i];
if ([eq_desc isEqual:[eq_info stringAtIndex:EQUIPMENT_KEY_INDEX]] &&
[eq_info count] > EQUIPMENT_EXTRA_INFO_INDEX)
{
eq_dict = [eq_info dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX];
break;
}
}
if ([eq_dict boolForKey:@"portable_between_ships"])
{
[portable_equipment addObject:eq_desc];
}
item = [OOEquipmentType equipmentTypeWithIdentifier:eq_desc];
if ([item isPortableBetweenShips]) [portable_equipment addObject:eq_desc];
}
// remove ALL

View File

@ -63,8 +63,8 @@ static NSString * const kCacheKeyCaches = @"caches";
enum
{
kEndianTagValue = 0x12345678UL,
kFormatVersionValue = 19
kEndianTagValue = 0x0123456789ABCDEFULL,
kFormatVersionValue = 20
};
@ -304,7 +304,7 @@ static OOCacheManager *sSingleton = nil;
NSData *endianTag = nil;
NSNumber *formatVersion = nil;
BOOL accept = YES;
uint32_t endianTagValue = 0;
uint64_t endianTagValue = 0;
ooliteVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:kCacheKeyVersion];
@ -341,7 +341,7 @@ static OOCacheManager *sSingleton = nil;
}
else
{
endianTagValue = *(const uint32_t *)[endianTag bytes];
endianTagValue = *(const uint64_t *)[endianTag bytes];
if (endianTagValue != kEndianTagValue)
{
OOLog(kOOLogDataCacheRebuild, @"Data cache endianness is inappropriate for this system, rebuilding cache.");
@ -376,7 +376,7 @@ static OOCacheManager *sSingleton = nil;
NSData *endianTag = nil;
NSNumber *formatVersion = nil;
NSDictionary *pListRep = nil;
uint32_t endianTagValue = kEndianTagValue;
uint64_t endianTagValue = kEndianTagValue;
if (_caches == nil) return;

View File

@ -57,17 +57,18 @@ SOFTWARE.
{
NSDictionary *_shipData;
NSArray *_demoShips;
NSSet *_playerShips;
NSArray *_playerShips;
NSDictionary *_probabilitySets;
}
+ (OOShipRegistry *) sharedRegistry;
- (NSDictionary *) shipInfoForKey:(NSString *)key;
- (NSDictionary *) shipyardInfoForKey:(NSString *)key;
- (OOProbabilitySet *) probabilitySetForRole:(NSString *)role;
- (NSArray *) demoShipKeys;
- (NSSet *) playerShipKeys;
- (NSArray *) playerShipKeys;
@end

View File

@ -103,7 +103,7 @@ static NSString * const kDefaultDemoShip = @"coriolis-station";
OOCacheManager *cache = [OOCacheManager sharedCache];
_shipData = [[cache objectForKey:kShipDataCacheKey inCache:kShipRegistryCacheName] retain];
_playerShips = [[NSSet setWithArray:[cache objectForKey:kPlayerShipsCacheKey inCache:kShipRegistryCacheName]] retain];
_playerShips = [[cache objectForKey:kPlayerShipsCacheKey inCache:kShipRegistryCacheName] retain];
if ([_shipData count] == 0) // Don't accept nil or empty
{
[self loadShipData];
@ -160,6 +160,12 @@ static NSString * const kDefaultDemoShip = @"coriolis-station";
}
- (NSDictionary *) shipyardInfoForKey:(NSString *)key
{
return [[self shipInfoForKey:key] objectForKey:@"shipyard"];
}
- (OOProbabilitySet *) probabilitySetForRole:(NSString *)role
{
if (role == nil) return nil;
@ -173,7 +179,7 @@ static NSString * const kDefaultDemoShip = @"coriolis-station";
}
- (NSSet *) playerShipKeys
- (NSArray *) playerShipKeys
{
return _playerShips;
}
@ -216,6 +222,9 @@ static NSString * const kDefaultDemoShip = @"coriolis-station";
NSString *key = nil;
NSDictionary *immutableResult = nil;
OOLog(@"shipData.load.begin", @"Loading ship data...");
OOLogIndentIf(@"shipData.load.begin");
[_shipData release];
_shipData = nil;
[_playerShips release];
@ -254,6 +263,9 @@ static NSString * const kDefaultDemoShip = @"coriolis-station";
_shipData = [immutableResult retain];
[[OOCacheManager sharedCache] setObject:_shipData forKey:kShipDataCacheKey inCache:kShipRegistryCacheName];
OOLogOutdentIf(@"shipData.load.begin");
OOLog(@"shipData.load.done", @"Ship data loaded.");
}
@ -513,7 +525,7 @@ static NSString * const kDefaultDemoShip = @"coriolis-station";
mergeMode:MERGE_SMART
cache:NO];
playerShips = [NSMutableSet setWithCapacity:[shipyard count]];
playerShips = [NSMutableArray arrayWithCapacity:[shipyard count]];
// Insert merged shipyard and shipyardOverrides entries.
for (enumerator = [shipyard keyEnumerator]; (key = [enumerator nextObject]); )
@ -537,7 +549,7 @@ static NSString * const kDefaultDemoShip = @"coriolis-station";
}
_playerShips = [playerShips copy];
[[OOCacheManager sharedCache] setObject:[_playerShips allObjects] forKey:kPlayerShipsCacheKey inCache:kShipRegistryCacheName];
[[OOCacheManager sharedCache] setObject:_playerShips forKey:kPlayerShipsCacheKey inCache:kShipRegistryCacheName];
return YES;
}

View File

@ -189,8 +189,6 @@ enum
BOOL dumpCollisionInfo;
NSDictionary *shipyard; // holds data on all ships for sale, loaded at initialisation
NSDictionary *commodityLists; // holds data on commodities for various types of station, loaded at initialisation
NSArray *commodityData; // holds data on commodities extracted from commodityLists
@ -451,7 +449,6 @@ enum
- (OOSystemID) systemIDForSystemSeed:(Random_Seed)seed;
- (OOSystemID) currentSystemID;
- (NSDictionary *) shipyard;
- (NSDictionary *) descriptions;
- (NSDictionary *) characters;
- (NSDictionary *) missiontext;

View File

@ -212,8 +212,6 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
time_delta = 0.0;
universal_time = 0.0;
shipyard = [[ResourceManager dictionaryFromFilesNamed:@"shipyard.plist" inFolder:@"Config" andMerge:YES] retain];
commodityLists = [(NSDictionary *)[ResourceManager dictionaryFromFilesNamed:@"commodities.plist" inFolder:@"Config" andMerge:YES] retain];
commodityData = [[NSArray arrayWithArray:[commodityLists arrayForKey:@"default"]] retain];
@ -309,7 +307,6 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
[comm_log_gui release];
[entities release];
[shipyard release];
[commodityLists release];
[commodityData release];
@ -452,9 +449,6 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
time_delta = 0.0;
universal_time = 0.0;
[shipyard autorelease];
shipyard = [[ResourceManager dictionaryFromFilesNamed:@"shipyard.plist" inFolder:@"Config" andMerge:YES] retain];
[commodityLists autorelease];
commodityLists = [[ResourceManager dictionaryFromFilesNamed:@"commodities.plist" inFolder:@"Config" andMerge:YES] retain];
@ -5765,12 +5759,6 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
}
- (NSDictionary *) shipyard
{
return shipyard;
}
- (NSDictionary *) descriptions
{
if (descriptions == nil)
@ -7084,6 +7072,8 @@ double estimatedTimeForJourney(double distance, int hops)
float tech_price_boost = (ship_seed.a + ship_seed.b) / 256.0;
unsigned i;
PlayerEntity *player = [PlayerEntity sharedPlayer];
OOShipRegistry *registry = [OOShipRegistry sharedRegistry];
for (i = 0; i < 256; i++)
{
@ -7097,32 +7087,28 @@ double estimatedTimeForJourney(double distance, int hops)
double days_until_sale = (ship_sold_time - current_time) / 86400.0;
NSMutableArray *keysForShips = [NSMutableArray arrayWithArray:[shipyard allKeys]];
NSMutableArray *keysForShips = [NSMutableArray arrayWithArray:[registry playerShipKeys]];
unsigned si;
for (si = 0; si < [keysForShips count]; si++)
{
//eliminate any ships that fail a 'conditions test'
NSString *key = [keysForShips stringAtIndex: si];
NSDictionary *dict = [shipyard dictionaryForKey: key];
NSString *key = [keysForShips stringAtIndex:si];
NSDictionary *dict = [registry shipyardInfoForKey:key];
if ([dict objectForKey:@"conditions"])
{
PlayerEntity* player = [PlayerEntity sharedPlayer];
if ((player) && (player->isPlayer) && (![player checkCouplet: dict onEntity: player]))
[keysForShips removeObjectAtIndex: si--];
if (![player checkCouplet:dict onEntity:player])
[keysForShips removeObjectAtIndex:si--];
}
}
NSDictionary *systemInfo = [self generateSystemData:system_seed];
OOTechLevelID techlevel = [systemInfo unsignedIntForKey:KEY_TECHLEVEL];
NSDictionary* systemInfo = [self generateSystemData:system_seed];
unsigned techlevel = [systemInfo unsignedIntForKey:KEY_TECHLEVEL];
if (specialTL != NSNotFound)
techlevel = specialTL;
if (specialTL != NSNotFound) techlevel = specialTL;
unsigned ship_index = (ship_seed.d * 0x100 + ship_seed.e) % [keysForShips count];
NSString* ship_key = [keysForShips stringAtIndex:ship_index];
NSDictionary* ship_info = [shipyard dictionaryForKey:ship_key];
NSString *ship_key = [keysForShips stringAtIndex:ship_index];
NSDictionary *ship_info = [registry shipyardInfoForKey:ship_key];
OOTechLevelID ship_techlevel = [ship_info intForKey:KEY_TECHLEVEL];
double chance = 1.0 - pow(1.0 - [ship_info doubleForKey:KEY_CHANCE], OOMax_f(1, techlevel - ship_techlevel));
@ -7178,87 +7164,46 @@ double estimatedTimeForJourney(double distance, int hops)
{
chance *= chance; //decrease the chance of a further customisation
int option_index = Ranrot() % [options count];
NSString* equipment = [options stringAtIndex:option_index];
int eq_index = NSNotFound;
unsigned q;
for (q = 0; (q < [equipmentData count])&&(eq_index == NSNotFound) ; q++)
{
if ([equipment isEqual:[[equipmentData arrayAtIndex:q] stringAtIndex:EQUIPMENT_KEY_INDEX]])
eq_index = q;
}
if (eq_index != NSNotFound)
{
NSArray* equipment_info = [equipmentData arrayAtIndex:eq_index];
//all amounts are x/10 due to being represented in tenths of credits
OOCreditsQuantity eq_price = [equipment_info unsignedIntAtIndex:EQUIPMENT_PRICE_INDEX] / 10;
unsigned eq_techlevel = [equipment_info unsignedIntAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
NSString* eq_short_desc = [equipment_info stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
NSString* eq_long_desc = [equipment_info stringAtIndex:EQUIPMENT_LONG_DESC_INDEX];
NSString *equipmentKey = [options stringAtIndex:option_index];
OOEquipmentType *item = [OOEquipmentType equipmentTypeWithIdentifier:equipmentKey];
if (eq_techlevel > techlevel)
if (item != nil)
{
// cap maximum tech level
if (eq_techlevel > 15)
eq_techlevel = 15;
// higher tech items are rarer!
if (randf() * (eq_techlevel - techlevel) < 1.0)
OOTechLevelID eqTechLevel = [item techLevel];
OOCreditsQuantity eqPrice = [item price] / 10; // all amounts are x/10 due to being represented in tenths of credits.
NSString *eqShortDesc = [item name];
NSString *eqLongDesc = [item descriptiveText];
if ([item techLevel] > techlevel)
{
eq_price *= (tech_price_boost + eq_techlevel - techlevel) * 90 / 100; //all equip has a 10% disocount
}
else
{
eq_price = 0; // bar this upgrade
// Cap maximum tech level.
eqTechLevel = MAX(eqTechLevel, 15U);
// Higher tech items are rarer!
if (randf() * (eqTechLevel - techlevel) < 1.0)
{
// All included equip has a 10% discount.
eqPrice *= (tech_price_boost + eqTechLevel - techlevel) * 90 / 100;
}
else eqPrice = 0; // Bar this upgrade.
}
if (eq_price > 0)
if (eqPrice > 0)
{
if (![equipment hasPrefix:@"EQ_WEAPON"])
if ([equipmentKey hasPrefix:@"EQ_WEAPON"])
{
if ([equipment isEqual:@"EQ_PASSENGER_BERTH"])
{
if ((max_cargo >= 5) && (randf() < chance))
{
max_cargo -= 5;
price += eq_price;
[extras addObject:equipment];
if (passenger_berths == 0)
{
// This will be needed to construct the description for passenger berths.
passengerBerthLongDesc = [NSString stringWithFormat:@"%@", [eq_long_desc lowercaseString]];
}
passenger_berths++;
customised = YES;
}
else
{
[options removeObject:equipment]; // remove the option if there's no space left
}
}
else
{
price += eq_price;
[extras addObject:equipment];
[description appendFormat:DESC(@"extra-@-@"), eq_short_desc, [eq_long_desc lowercaseString]];
[short_description appendFormat:short_extras_string, eq_short_desc];
short_extras_string = @" %@.";
customised = YES;
}
}
else
{
OOWeaponType new_weapon = EquipmentStringToWeaponType(equipment);
OOWeaponType new_weapon = EquipmentStringToWeaponType(equipmentKey);
//fit best weapon forward
if (new_weapon > fwd_weapon)
{
//again remember to divide price by 10 to get credits from tenths of credit
price -= [self getPriceForWeaponSystemWithKey:fwd_weapon_string] * 90 / 1000; // 90% credits
price += eq_price;
fwd_weapon_string = equipment;
price += eqPrice;
fwd_weapon_string = equipmentKey;
fwd_weapon = new_weapon;
[ship_dict setObject:fwd_weapon_string forKey:KEY_EQUIPMENT_FORWARD_WEAPON];
weapon_customised = YES;
fwd_weapon_desc = eq_short_desc;
fwd_weapon_desc = eqShortDesc;
}
else
{
@ -7266,30 +7211,50 @@ double estimatedTimeForJourney(double distance, int hops)
if (!aft_weapon || new_weapon > aft_weapon)
{
price -= [self getPriceForWeaponSystemWithKey:aft_weapon_string] * 90 / 1000; // 90% credits
price += eq_price;
aft_weapon_string = equipment;
price += eqPrice;
aft_weapon_string = equipmentKey;
aft_weapon = new_weapon;
[ship_dict setObject:aft_weapon_string forKey:KEY_EQUIPMENT_AFT_WEAPON];
other_weapon_added = YES;
aft_weapon_desc = eq_short_desc;
aft_weapon_desc = eqShortDesc;
}
}
}
}
}
if ([equipment hasSuffix:@"ENERGY_UNIT"]) // remove ALL the energy unit add-ons
else
{
unsigned q;
for (q = 0; q < [options count]; q++)
if ([equipmentKey isEqualToString:@"EQ_PASSENGER_BIRTH"])
{
if ([[options stringAtIndex:q] hasSuffix:@"ENERGY_UNIT"])
[options removeObjectAtIndex:q--];
if ((max_cargo >= 5) && (randf() < chance))
{
max_cargo -= 5;
price += eqPrice;
[extras addObject:equipmentKey];
if (passenger_berths == 0)
{
// This will be needed to construct the description for passenger berths.
passengerBerthLongDesc = [NSString stringWithFormat:@"%@", [eqLongDesc lowercaseString]];
}
passenger_berths++;
customised = YES;
}
else
{
// remove the option if there's no space left
[options removeObject:equipmentKey];
}
}
else
{
if (![equipment isEqual:@"EQ_PASSENGER_BERTH"]) // let this get added multiple times
[options removeObject:equipment];
price += eqPrice;
[extras addObject:equipmentKey];
[description appendFormat:DESC(@"extra-@-@"), eqShortDesc, [eqLongDesc lowercaseString]];
[short_description appendFormat:short_extras_string, eqShortDesc];
short_extras_string = @" %@.";
customised = YES;
}
}
}
}
}
// i18n: Some languages require that no conversion to lower case string takes place.
@ -7409,7 +7374,7 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
// given the ship model (from ship_desc)
// get the basic information about the standard customer model for that craft
NSDictionary *shipyard_info = [[UNIVERSE shipyard] dictionaryForKey:ship_desc];
NSDictionary *shipyard_info = [[OOShipRegistry sharedRegistry] shipyardInfoForKey:ship_desc];
NSDictionary *basic_info = [shipyard_info dictionaryForKey:KEY_STANDARD_EQUIPMENT];
OOCreditsQuantity base_price = [shipyard_info unsignedLongLongForKey:SHIPYARD_KEY_PRICE];
unsigned base_missiles = [basic_info unsignedIntForKey:KEY_EQUIPMENT_MISSILES];