49#import "MyOpenGLView.h"
90#define PLAYER_DEFAULT_NAME @"Jameson"
113@interface PlayerEntity (OOPrivate)
116- (void) doTradeIn:(
OOCreditsQuantity)tradeInValue forPriceFactor:(
double)priceFactor;
125- (void) performAutopilotUpdates:(
OOTimeDelta)delta_t;
126- (void) performInFlightUpdates:(
OOTimeDelta)delta_t;
127- (void) performWitchspaceCountdownUpdates:(
OOTimeDelta)delta_t;
128- (void) performWitchspaceExitUpdates:(
OOTimeDelta)delta_t;
129- (void) performLaunchingUpdates:(
OOTimeDelta)delta_t;
130- (void) performDockingUpdates:(
OOTimeDelta)delta_t;
138- (BOOL) checkEntityForMassLock:(
Entity *)ent withScanClass:(
int)scanClass;
147- (BOOL) tryBuyingItem:(NSString *)eqKey;
150- (NSArray*) contractsListForScriptingFromArray:(NSArray *)contractsArray forCargo:(BOOL)forCargo;
153- (void) prepareMarkedDestination:(NSMutableDictionary *)markers :(NSDictionary *)marker;
156- (void) witchJumpTo:(
OOSystemID)sTo misjump:(BOOL)misjump;
170@interface ShipEntity (Hax)
172- (id) initBypassForPlayer;
189- (void) setName:(NSString *)inName
200 if ([
self mass] > 0.0)
202 OOLog(
@"fuelPrices",
@"Setting Cobra3 base mass to: %.2f ", [
self mass]);
208 OOLog(
@"fuelPrices",
@"%@",
@"Player ship not initialised properly yet, using precalculated base mass.");
219 NSInteger i, cargoCount = [cargo count];
220 if (cargoCount == 0)
return;
223 for (i = cargoCount - 1; i >= 0 ; i--)
225 ShipEntity *cargoItem = [cargo objectAtIndex:i];
227 if (commodityType ==
nil || [commodityType isEqualToString:type])
229 if ([commodityType isEqualToString:type])
236 OOLog(
@"player.badCargoPod",
@"Cargo pod %@ has bad commodity type, rejecting.", cargoItem);
239 [cargo removeObjectAtIndex:i];
247 NSInteger i, n_cargo = [cargo count];
248 if (n_cargo == 0)
return;
256 for (i = n_cargo - 1; (i >= 0 && cargoToGo > 0) ; i--)
258 cargoItem = [cargo objectAtIndex:i];
260 if (co_type ==
nil || [co_type isEqualToString:type])
262 if ([co_type isEqualToString:type])
265 if (amount <= cargoToGo)
267 [cargo removeObjectAtIndex:i];
280 OOLog(
@"player.badCargoPod",
@"Cargo pod %@ has bad commodity type (COMMODITY_UNDEFINED), rejecting.", cargoItem);
289 [shipCommodityData removeQuantity:cargoToGo forGood:type];
294- (void) unloadCargoPods
296 NSAssert([
self isDocked],
@"Cannot unload cargo pods unless docked.");
299 NSString *good =
nil;
300 foreach (good, [shipCommodityData goods])
302 [
self unloadAllCargoPodsForType:good toManifest:shipCommodityData];
305 if ([cargo
count] > 0)
307 OOLog(
@"player.unloadCargo",
@"Cargo remains in pods after unloading - %@",cargo);
311 [
self calculateCurrentCargo];
318 ShipEntity *container = [UNIVERSE newShipWithRole:@"1t-cargopod"];
324 [cargo addObject:container];
329 OOLogERR(
@"player.loadCargoPods.noContainer",
@"%@",
@"couldn't create a container in [PlayerEntity loadCargoPods]");
331 [NSException raise:OOLITE_EXCEPTION_FATAL
332 format:@"[PlayerEntity loadCargoPods] failed to create a container for cargo with role 'cargopod'"];
350 for (j = 0; j < quantity; j++)
352 [
self createCargoPodWithType:type andAmount:1];
358 OOCargoQuantity podsRequiredForQuantity, amountToLoadInCargopod, tmpQuantity;
364 tmpQuantity = quantity;
370 quantity -= tmpQuantity;
377 tmpQuantity = quantity;
383 quantity -= tmpQuantity;
389 podsRequiredForQuantity = 1 + (quantity/amountToLoadInCargopod);
392 if (quantity % amountToLoadInCargopod == 0) podsRequiredForQuantity--;
395 for (j = 0; j < podsRequiredForQuantity; j++)
397 if (amountToLoadInCargopod > quantity)
400 amountToLoadInCargopod = quantity;
402 [
self createCargoPodWithType:type andAmount:amountToLoadInCargopod];
403 quantity -= amountToLoadInCargopod;
415 OOMassUnit unit = [shipCommodityData massUnitForGood:type];
424 int smaller_quantity = 1 + ((quantity - 1) % amount_per_container);
425 if ([cargo
count] < [
self maxAvailableCargoSpace])
427 ShipEntity* container = [UNIVERSE newShipWithRole:@"1t-cargopod"];
434 [cargo addObject:container];
441 int amount = [shipCommodityData quantityForGood:type] + smaller_quantity;
445 [shipCommodityData setQuantity:amount forGood:type];
447 quantity -= smaller_quantity;
455 if ([cargo
count] < [
self maxAvailableCargoSpace])
457 ShipEntity* container = [UNIVERSE newShipWithRole:@"1t-cargopod"];
464 [cargo addObject:container];
475- (void) loadCargoPods
478 NSString *good =
nil;
479 foreach (good, [shipCommodityData goods])
481 [
self loadCargoPodsForType:good fromManifest:shipCommodityData];
483 [
self calculateCurrentCargo];
490 return shipCommodityData;
506- (void) setRandom_factor:(
int)rf
514 return galaxy_number;
518- (NSPoint) galaxy_coordinates
520 return galaxy_coordinates;
524- (void) setGalaxyCoordinates:(NSPoint)newPosition
526 galaxy_coordinates.x = newPosition.x;
527 galaxy_coordinates.y = newPosition.y;
531- (NSPoint) cursor_coordinates
533 return cursor_coordinates;
537- (NSPoint) chart_centre_coordinates
539 return chart_centre_coordinates;
561 return custom_chart_zoom;
568 return custom_chart_zoom;
571- (void) setCustomChartZoom:(
OOScalar)zoom
573 custom_chart_zoom = zoom;
577- (NSPoint) custom_chart_centre_coordinates
579 return custom_chart_centre_coordinates;
583- (void) setCustomChartCentre:(NSPoint)coords
585 custom_chart_centre_coordinates.x = coords.x;
586 custom_chart_centre_coordinates.y = coords.y;
590- (NSPoint) adjusted_chart_centre
600 return galaxy_coordinates;
606 return NSMakePoint(128.0, 128.0);
612 return custom_chart_centre_coordinates;
616 acc.x = chart_centre_coordinates.x + (128.0 - chart_centre_coordinates.
x) * (chart_zoom - 1.0) / (
CHART_MAX_ZOOM - 1.0);
617 acc.y = chart_centre_coordinates.y + (128.0 - chart_centre_coordinates.
y) * (chart_zoom - 1.0) / (
CHART_MAX_ZOOM - 1.0);
632 acc.x = ((scroll_pos-chart_focus_coordinates.
x)*ecc + chart_focus_coordinates.
x*acc.
x)/scroll_pos;
637 scroll_pos = acc.x + CHART_SCROLL_AT_X*chart_zoom;
638 ecc = 256.0 - CHART_WIDTH_AT_MAX_ZOOM*chart_zoom / 2.0;
639 if (scroll_pos >= 256.0)
645 acc.x = ((chart_focus_coordinates.x-scroll_pos)*ecc + (256.0 - chart_focus_coordinates.x)*acc.x)/(256.0 - scroll_pos);
658 acc.y = ((scroll_pos-chart_focus_coordinates.
y)*ecc + chart_focus_coordinates.
y*acc.
y)/scroll_pos;
663 scroll_pos = acc.y + CHART_SCROLL_AT_Y*chart_zoom;
664 ecc = 256.0 - CHART_HEIGHT_AT_MAX_ZOOM*chart_zoom / 2.0;
665 if (scroll_pos >= 256.0)
671 acc.y = ((chart_focus_coordinates.y-scroll_pos)*ecc + (256.0 - chart_focus_coordinates.y)*acc.y)/(256.0 - scroll_pos);
728 if (![
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
742 NSDictionary *routeInfo =
nil;
743 routeInfo = [UNIVERSE routeFromSystem:system_id toSystem:target_system_id optimizedBy:ANA_mode];
745 if (routeInfo ==
nil)
749 return [[routeInfo oo_arrayForKey:@"route"] oo_intAtIndex:1];
759- (void) setInfoSystemID: (
OOSystemID) sid moveChart: (BOOL) moveChart
771 target_chart_focus = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
778 [
self setGuiToSystemDataScreenRefreshBackground: YES];
782 chart_centre_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:info_system_id inGalaxy:galaxy_number];
798 [
self setInfoSystemID: target_system_id moveChart: YES];
801 NSArray *route = [[[UNIVERSE routeFromSystem:system_id toSystem:target_system_id optimizedBy:ANA_mode] oo_arrayForKey: @"route"] retain];
805 [
self setInfoSystemID: target_system_id moveChart: YES];
808 for (i = 0; i < [route count]; i++)
812 if (i + 1 < [route
count])
814 [
self setInfoSystemID:[[route objectAtIndex:i + 1] unsignedIntValue] moveChart: YES];
822 [
self setInfoSystemID: target_system_id moveChart: YES];
831 [
self setInfoSystemID: system_id moveChart: YES];
834 NSArray *route = [[[UNIVERSE routeFromSystem:system_id toSystem:target_system_id optimizedBy:ANA_mode] oo_arrayForKey: @"route"] retain];
838 [
self setInfoSystemID: system_id moveChart: YES];
841 for (i = 0; i < [route count]; i++)
847 [
self setInfoSystemID: [[route objectAtIndex: i - 1] unsignedIntValue] moveChart: YES];
855 [
self setInfoSystemID: system_id moveChart: YES];
862 [
self setInfoSystemID: system_id moveChart: YES];
869 [
self setInfoSystemID: target_system_id moveChart: YES];
876 NSArray *route = [[UNIVERSE routeFromSystem:system_id toSystem:target_system_id optimizedBy:ANA_mode] oo_arrayForKey: @"route"];
882 for (i = 0; i < [route count]; i++)
902 if (newWormhole !=
nil)
917 NSMutableDictionary *result = [NSMutableDictionary dictionary];
919 [result setObject:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"written_by_version"];
921 NSString *gal_id = [NSString stringWithFormat:@"%u", galaxy_number];
922 NSString *sys_id = [NSString stringWithFormat:@"%d", system_id];
923 NSString *tgt_id = [NSString stringWithFormat:@"%d", target_system_id];
924 NSString *prv_id = [NSString stringWithFormat:@"%d", previous_system_id];
930 [result setObject:gal_id forKey:@"galaxy_id"];
931 [result setObject:sys_id forKey:@"system_id"];
932 [result setObject:tgt_id forKey:@"target_id"];
933 [result setObject:prv_id forKey:@"previous_system_id"];
934 [result setObject:[NSNumber numberWithFloat:saved_chart_zoom] forKey:@"chart_zoom"];
935 [result setObject:[NSNumber numberWithInt:ANA_mode] forKey:@"chart_ana_mode"];
936 [result setObject:[NSNumber numberWithInt:longRangeChartMode] forKey:@"chart_colour_mode"];
941 NSString *found_id = [NSString stringWithFormat:@"%d", found_system_id];
942 [result setObject:found_id forKey:@"found_system_id"];
946 if (![
UNIVERSE inInterstellarSpace])
948 [result setObject:[UNIVERSE getSystemName:[
self currentSystemID]] forKey:@"current_system_name"];
949 OOGovernmentID government = [[UNIVERSE currentSystemData] oo_intForKey:KEY_GOVERNMENT];
950 OOTechLevelID techlevel = [[UNIVERSE currentSystemData] oo_intForKey:KEY_TECHLEVEL];
951 OOEconomyID economy = [[UNIVERSE currentSystemData] oo_intForKey:KEY_ECONOMY];
952 [result setObject:[NSNumber numberWithUnsignedShort:government] forKey:@"current_system_government"];
953 [result setObject:[NSNumber numberWithUnsignedInteger:techlevel] forKey:@"current_system_techlevel"];
954 [result setObject:[NSNumber numberWithUnsignedShort:economy] forKey:@"current_system_economy"];
957 [result setObject:[
self commanderName] forKey:@"player_name"];
958 [result setObject:[
self lastsaveName] forKey:@"player_save_name"];
959 [result setObject:[
self shipUniqueName] forKey:@"ship_unique_name"];
960 [result setObject:[
self shipClassName] forKey:@"ship_class_name"];
969 [result oo_setFloat:credits forKey:@"credits"];
970 [result oo_setUnsignedInteger:fuel forKey:@"fuel"];
972 [result oo_setInteger:galaxy_number forKey:@"galaxy_number"];
974 [result oo_setBool:[
self weaponsOnline] forKey:@"weapons_online"];
978 [result setObject:[forward_weapon_type identifier] forKey:@"forward_weapon"];
982 [result setObject:[aft_weapon_type identifier] forKey:@"aft_weapon"];
986 [result setObject:[port_weapon_type identifier] forKey:@"port_weapon"];
990 [result setObject:[starboard_weapon_type identifier] forKey:@"starboard_weapon"];
992 [result setObject:[
self serializeShipSubEntities] forKey:@"subentities_status"];
993 if (
hud !=
nil && [
hud nonlinearScanner])
995 [result oo_setFloat: [hud scannerZoom] forKey:@"ship_scanner_zoom"];
998 [result oo_setInteger:max_cargo + PASSENGER_BERTH_SPACE * max_passengers forKey:@"max_cargo"];
1000 [result setObject:[shipCommodityData savePlayerAmounts] forKey:@"shipCommodityData"];
1003 NSMutableArray *missileRoles = [NSMutableArray arrayWithCapacity:max_missiles];
1009 [missileRoles addObject:[missile_entity[i] primaryRole]];
1013 [missileRoles addObject:@"NONE"];
1016 [result setObject:missileRoles forKey:@"missile_roles"];
1018 [result oo_setInteger:missiles forKey:@"missiles"];
1020 [result oo_setInteger:legalStatus forKey:@"legal_status"];
1021 [result oo_setInteger:market_rnd forKey:@"market_rnd"];
1022 [result oo_setInteger:ship_kills forKey:@"ship_kills"];
1025 [result oo_setInteger:ship_trade_in_factor forKey:@"ship_trade_in_factor"];
1030 [result setObject:[NSDictionary dictionaryWithDictionary:mission_variables] forKey:@"mission_variables"];
1034 NSArray *log = [
self commLog];
1035 if (log !=
nil) [result setObject:log forKey:
@"comm_log"];
1037 [result oo_setUnsignedInteger:entity_personality forKey:@"entity_personality"];
1040 NSMutableDictionary *equipment = [NSMutableDictionary dictionary];
1041 NSEnumerator *eqEnum =
nil;
1042 NSString *eqDesc =
nil;
1045 [equipment oo_setInteger:[
self countEquipmentItem:eqDesc] forKey:eqDesc];
1047 if ([equipment
count] != 0)
1049 [result setObject:equipment forKey:@"extra_equipment"];
1053 [result setObject:[
self fastEquipmentA] forKey:@"primed_equipment_a"];
1054 [result setObject:[
self fastEquipmentB] forKey:@"primed_equipment_b"];
1057 [result setObject:roleWeights forKey:@"role_weights"];
1060 [result setObject:roleWeightFlags forKey:@"role_weight_flags"];
1063 [result setObject:roleSystemList forKey:@"role_system_memory"];
1066 [result setObject:reputation forKey:@"reputation"];
1069 int pGood = [reputation oo_intForKey:PARCEL_GOOD_KEY];
1070 int pBad = [reputation oo_intForKey:PARCEL_BAD_KEY];
1071 int pUnknown = [reputation oo_intForKey:PARCEL_UNKNOWN_KEY];
1074 [reputation oo_setInteger:0 forKey:PARCEL_GOOD_KEY];
1075 [reputation oo_setInteger:0 forKey:PARCEL_BAD_KEY];
1076 [reputation oo_setInteger:MAX_CONTRACT_REP forKey:PARCEL_UNKNOWN_KEY];
1080 [result oo_setInteger:max_passengers forKey:@"max_passengers"];
1081 [result setObject:passengers forKey:@"passengers"];
1082 [result setObject:passenger_record forKey:@"passenger_record"];
1085 [result setObject:parcels forKey:@"parcels"];
1086 [result setObject:parcel_record forKey:@"parcel_record"];
1092 [result setObject:contracts forKey:@"contracts"];
1093 [result setObject:contract_record forKey:@"contract_record"];
1095 [result setObject:missionDestinations forKey:@"mission_destinations"];
1098 [result setObject:shipyard_record forKey:@"shipyard_record"];
1101 [result setObject:[NSNumber numberWithDouble:ship_clock] forKey:@"ship_clock"];
1104 [result setObject:[NSNumber numberWithInt:isSpeechOn] forKey:@"speech_on"];
1106 [result setObject:[UNIVERSE voiceName:voice_no] forKey:@"speech_voice"];
1107 [result setObject:[NSNumber numberWithBool:voice_gender_m] forKey:@"speech_gender"];
1111 [result setObject:[NSNumber numberWithBool:[UNIVERSE dockingClearanceProtocolActive]] forKey:@"docking_clearance_protocol"];
1114 [result setObject:[
self shipDataKey] forKey:@"ship_desc"];
1115 [result setObject:[[
self shipInfoDictionary] oo_stringForKey:KEY_NAME] forKey:@"ship_name"];
1118 [result oo_setUnsignedInteger:_customViewIndex forKey:@"custom_view_index"];
1121 [result oo_setFloat:[
self escapePodRescueTime] forKey:@"escape_pod_rescue_time"];
1127 [result setObject:[UNIVERSE useAddOns] forKey:@"scenario_restriction"];
1129 [result setObject:[[UNIVERSE systemManager] exportScriptedChanges] forKey:@"scripted_planetinfo_overrides"];
1132 [result setObject:[
self trumbleValue] forKey:@"trumbles"];
1135 NSMutableArray *wormholeDicts = [NSMutableArray arrayWithCapacity:[scannedWormholes count]];
1136 NSEnumerator *wormholes = [scannedWormholes objectEnumerator];
1138 foreach(wh, wormholes)
1140 [wormholeDicts addObject:[wh
getDict]];
1142 [result setObject:wormholeDicts forKey:@"wormholes"];
1146 [result setObject:dockedStation != nil ? [dockedStation
primaryRole]:(NSString *)@"" forKey:@"docked_station_role"];
1149 HPVector dpos = [dockedStation
position];
1150 [result setObject:ArrayFromHPVector(dpos) forKey:@"docked_station_position"];
1154 [result setObject:[NSArray array] forKey:@"docked_station_position"];
1156 [result setObject:[UNIVERSE getStationMarkets] forKey:@"station_markets"];
1161 [result setObject:scenarioKey forKey:@"scenario"];
1178 if (equipment !=
nil)
1186 [result oo_setInteger:final_checksum forKey:@"checksum"];
1192- (BOOL)setCommanderDataFromDictionary:(NSDictionary *) dict
1196 [multiFunctionDisplayText release];
1199 [multiFunctionDisplaySettings release];
1202 [customDialSettings release];
1205 [[UNIVERSE gameView] resetTypedString];
1208 if ([dict oo_stringForKey:
@"ship_desc"] ==
nil)
return NO;
1210 if ([dict oo_stringForKey:
@"galaxy_seed"] ==
nil && [dict oo_stringForKey:
@"galaxy_id"] ==
nil)
return NO;
1212 if ([dict oo_stringForKey:
@"galaxy_coordinates"] ==
nil && [dict oo_stringForKey:
@"system_id"] ==
nil)
return NO;
1214 NSString *scenarioRestrict = [dict oo_stringForKey:@"scenario_restriction" defaultValue:nil];
1215 if (scenarioRestrict ==
nil)
1218 BOOL strict = [dict oo_boolForKey:@"strict" defaultValue:NO];
1229 if (![
UNIVERSE setUseAddOns:scenarioRestrict fromSaveGame:YES])
1236 [
self setShipDataKey:[dict oo_stringForKey:@"ship_desc"]];
1239 if (shipDict ==
nil)
return NO;
1240 if (![
self setUpShipFromDictionary:shipDict])
return NO;
1247 if ([dict oo_stringForKey:
@"galaxy_id"] !=
nil)
1249 galaxy_number = [dict oo_unsignedIntegerForKey:@"galaxy_id"];
1254 [UNIVERSE setGalaxyTo:galaxy_number andReinit:YES];
1256 system_id = [dict oo_intForKey:@"system_id"];
1262 [UNIVERSE setSystemTo:system_id];
1270 chart_zoom = [dict oo_floatForKey:@"chart_zoom" defaultValue:1.0];
1273 ANA_mode = [dict oo_intForKey:@"chart_ana_mode" defaultValue:OPTIMIZED_BY_NONE];
1274 longRangeChartMode = [dict oo_intForKey:@"chart_colour_mode" defaultValue:OOLRC_MODE_SUNCOLOR];
1277 target_system_id = [dict oo_intForKey:@"target_id" defaultValue:system_id];
1278 previous_system_id = [dict oo_intForKey:@"previous_system_id" defaultValue:system_id];
1287 found_system_id = [dict oo_intForKey:@"found_system_id" defaultValue:-1];
1292 galaxy_number = [dict oo_unsignedIntegerForKey:@"galaxy_number"];
1294 [UNIVERSE setGalaxyTo: galaxy_number andReinit:YES];
1307 NSString *keyStringValue = [dict oo_stringForKey:@"target_coordinates"];
1309 if (keyStringValue !=
nil)
1319 if ([dict objectForKey:
@"current_system_name"])
1321 system_id = [UNIVERSE findSystemFromName:[dict oo_stringForKey:@"current_system_name"]];
1322 if (
system_id == -1)
system_id = [UNIVERSE findSystemNumberAtCoords:galaxy_coordinates withGalaxy:galaxy_number includingHidden:YES];
1328 system_id = [UNIVERSE findSystemNumberAtCoords:galaxy_coordinates withGalaxy:galaxy_number includingHidden:YES];
1332 if ([dict objectForKey:
@"target_system_name"])
1334 target_system_id = [UNIVERSE findSystemFromName:[dict oo_stringForKey:@"target_system_name"]];
1339 target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:YES];
1345 NSString *cname = [dict oo_stringForKey:@"player_name" defaultValue:PLAYER_DEFAULT_NAME];
1346 [
self setCommanderName:cname];
1347 [
self setLastsaveName:[dict oo_stringForKey:@"player_save_name" defaultValue:cname]];
1349 [
self setShipUniqueName:[dict oo_stringForKey:@"ship_unique_name" defaultValue:@""]];
1350 [
self setShipClassName:[dict oo_stringForKey:@"ship_class_name" defaultValue:[shipDict oo_stringForKey:@"name"]]];
1352 [shipCommodityData loadPlayerAmounts:[dict oo_arrayForKey:@"shipCommodityData"]];
1355 [
self removeAllEquipment];
1356 NSMutableDictionary *equipment = [NSMutableDictionary dictionaryWithDictionary:[dict oo_dictionaryForKey:@"extra_equipment"]];
1359 if ([dict oo_boolForKey:
@"has_docking_computer"]) [equipment oo_setInteger:1 forKey:@"EQ_DOCK_COMP"];
1360 if ([dict oo_boolForKey:
@"has_galactic_hyperdrive"]) [equipment oo_setInteger:1 forKey:@"EQ_GAL_DRIVE"];
1361 if ([dict oo_boolForKey:
@"has_escape_pod"]) [equipment oo_setInteger:1 forKey:@"EQ_ESCAPE_POD"];
1362 if ([dict oo_boolForKey:
@"has_ecm"]) [equipment oo_setInteger:1 forKey:@"EQ_ECM"];
1363 if ([dict oo_boolForKey:
@"has_scoop"]) [equipment oo_setInteger:1 forKey:@"EQ_FUEL_SCOOPS"];
1364 if ([dict oo_boolForKey:
@"has_energy_bomb"]) [equipment oo_setInteger:1 forKey:@"EQ_ENERGY_BOMB"];
1365 if ([dict oo_boolForKey:
@"has_fuel_injection"]) [equipment oo_setInteger:1 forKey:@"EQ_FUEL_INJECTION"];
1371 OOEnergyUnitType eType = [dict oo_intForKey:@"energy_unit" defaultValue:ENERGY_UNIT_NORMAL];
1376 [equipment oo_setInteger:1 forKey:@"EQ_NAVAL_ENERGY_UNIT"];
1380 [equipment oo_setInteger:1 forKey:@"EQ_ENERGY_UNIT"];
1395 BOOL energyBombCompensation = NO;
1396 if ([equipment oo_boolForKey:
@"EQ_ENERGY_BOMB"] && [
OOEquipmentType equipmentTypeWithIdentifier:
@"EQ_ENERGY_BOMB"] ==
nil)
1398 energyBombCompensation = YES;
1399 [equipment removeObjectForKey:@"EQ_ENERGY_BOMB"];
1402 eqScripts = [[NSMutableArray alloc] init];
1403 [
self addEquipmentFromCollection:equipment];
1404 primedEquipment = [
self eqScriptIndexForKey:[dict oo_stringForKey:@"primed_equipment"]];
1406 [
self setFastEquipmentA:[dict oo_stringForKey:@"primed_equipment_a" defaultValue:@"EQ_CLOAKING_DEVICE"]];
1407 [
self setFastEquipmentB:[dict oo_stringForKey:@"primed_equipment_b" defaultValue:@"EQ_ENERGY_BOMB"]];
1409 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_COMPASS"])
compassMode = COMPASS_MODE_PLANET;
1414 isSpeechOn = [dict oo_intForKey:@"speech_on"];
1416 voice_gender_m = [dict oo_boolForKey:@"speech_gender" defaultValue:YES];
1417 voice_no = [UNIVERSE setVoice:[UNIVERSE voiceNumber:[dict oo_stringForKey:@"speech_voice" defaultValue:nil]] withGenderM:voice_gender_m];
1421 [reputation release];
1422 reputation = [[dict oo_dictionaryForKey:@"reputation"] mutableCopy];
1424 [
self normaliseReputation];
1428 [parcel_record release];
1429 [passengers release];
1430 [passenger_record release];
1431 [contracts release];
1432 [contract_record release];
1434 max_passengers = [dict oo_intForKey:@"max_passengers" defaultValue:0];
1435 passengers = [[dict oo_arrayForKey:@"passengers"] mutableCopy];
1436 passenger_record = [[dict oo_dictionaryForKey:@"passenger_record"] mutableCopy];
1439 contracts = [[dict oo_arrayForKey:@"contracts"] mutableCopy];
1440 NSMutableDictionary *contractInfo =
nil;
1443 for (NSInteger i = (NSInteger)[
contracts count] - 1; i >= 0; i--)
1445 contractInfo = [[[contracts oo_dictionaryAtIndex:i] mutableCopy] autorelease];
1447 if ([[contractInfo objectForKey:
CARGO_KEY_TYPE] isKindOfClass:[NSNumber
class]])
1450 NSUInteger legacy_type = [contractInfo oo_unsignedIntegerForKey:CARGO_KEY_TYPE];
1452 [contracts replaceObjectAtIndex:i withObject:[[contractInfo copy] autorelease]];
1456 OOCommodityType new_type = [contractInfo oo_stringForKey:CARGO_KEY_TYPE];
1458 if (![[
UNIVERSE commodities] goodDefined:new_type])
1460 OOLog(
@"setCommanderDataFromDictionary.warning.contract",
@"Cargo contract to deliver %@ could not be loaded from the saved game, as the commodity is no longer defined",new_type);
1461 [contracts removeObjectAtIndex:i];
1466 contract_record = [[dict oo_dictionaryForKey:@"contract_record"] mutableCopy];
1467 parcels = [[dict oo_arrayForKey:@"parcels"] mutableCopy];
1468 parcel_record = [[dict oo_dictionaryForKey:@"parcel_record"] mutableCopy];
1480 [specialCargo release];
1481 specialCargo = [[dict oo_stringForKey:@"special_cargo"] copy];
1484 NSArray *legacyDestinations = [dict oo_arrayForKey:@"missionDestinations"];
1486 NSDictionary *newDestinations = [dict oo_dictionaryForKey:@"mission_destinations"];
1487 [
self initialiseMissionDestinations:newDestinations andLegacy:legacyDestinations];
1491 shipyard_record = [[dict oo_dictionaryForKey:@"shipyard_record"] mutableCopy];
1495 unsigned original_hold_size = [UNIVERSE maxCargoForShip:[
self shipDataKey]];
1500 max_cargo = [dict oo_unsignedIntForKey:@"max_cargo" defaultValue:max_cargo];
1501 if (
max_cargo > original_hold_size) [
self addEquipmentItem:@"EQ_CARGO_BAY" inContext:@"loading"];
1508 OOLogWARN(
@"setCommanderDataFromDictionary.inconsistency.max_passengers",
@"player ship %@ had max_passengers set to a value requiring more cargo space than currently available (%u). Setting max_passengers to maximum possible value (%u).", [
self name], originalMaxPassengers,
max_passengers);
1515 OOLogWARN(
@"setCommanderDataFromDictionary.inconsistency.passengers",
@"player ship %@ had more passengers (%lu) than passenger berths (%u). Removing extra passengers.", [
self name], [
passengers count],
max_passengers);
1518 [passenger_record removeObjectForKey:[[passengers oo_dictionaryAtIndex:i] oo_stringForKey:PASSENGER_KEY_NAME]];
1519 [passengers removeObjectAtIndex:i];
1524 NSInteger excessCargo = (NSInteger)[
self cargoQuantityOnBoard] - (NSInteger)[
self maxAvailableCargoSpace];
1525 if (excessCargo > 0)
1538 units = [shipCommodityData massUnitForGood:type];
1540 oldAmount = [shipCommodityData quantityForGood:type];
1542 if (roundedTon || (units ==
UNITS_TONS && oldAmount > 0))
1547 while (remainingExcess > 0 && partAmount > 0)
1553 partAmount = oldAmount - toRemove;
1556 else if (!roundedTon)
1567 [shipCommodityData removeQuantity:toRemove forGood:type];
1574 fuel = [dict oo_unsignedIntForKey:@"fuel" defaultValue:fuel];
1578 OOWeaponFacingSet available_facings = [shipyard_info oo_unsignedIntForKey:KEY_WEAPON_FACINGS defaultValue:[
self weaponFacings]];
1600 [
self setWeaponDataFromType:forward_weapon_type];
1602 if (
hud !=
nil && [
hud nonlinearScanner])
1604 [hud setScannerZoom: [dict oo_floatForKey:@"ship_scanner_zoom" defaultValue: 1.0]];
1607 weapons_online = [dict oo_boolForKey:@"weapons_online" defaultValue:YES];
1609 legalStatus = [dict oo_intForKey:@"legal_status"];
1610 market_rnd = [dict oo_intForKey:@"market_rnd"];
1611 ship_kills = [dict oo_intForKey:@"ship_kills"];
1613 ship_clock = [dict oo_doubleForKey:@"ship_clock" defaultValue:PLAYER_SHIP_CLOCK_START];
1619 [roleWeights release];
1620 roleWeights = [[dict oo_arrayForKey:@"role_weights"] mutableCopy];
1621 NSUInteger rc = [
self maxPlayerRoles];
1624 roleWeights = [[NSMutableArray alloc] initWithCapacity:rc];
1627 [roleWeights addObject:@"player-unknown"];
1634 [roleWeights removeObjectsInRange:(NSRange) {rc,[roleWeights count]-rc}];
1638 roleWeightFlags = [[dict oo_dictionaryForKey:@"role_weight_flags"] mutableCopy];
1644 roleSystemList = [[dict oo_arrayForKey:@"role_system_memory"] mutableCopy];
1652 [mission_variables release];
1653 mission_variables = [[dict oo_dictionaryForKey:@"mission_variables"] mutableCopy];
1657 NSDictionary *planetInfoOverrides = [dict oo_dictionaryForKey:@"scripted_planetinfo_overrides"];
1658 if (planetInfoOverrides !=
nil)
1660 [[UNIVERSE systemManager] importScriptedChanges:planetInfoOverrides];
1665 planetInfoOverrides = [dict oo_dictionaryForKey:@"local_planetinfo_overrides"];
1666 if (planetInfoOverrides !=
nil)
1668 [[UNIVERSE systemManager] importLegacyScriptedChanges:planetInfoOverrides];
1674 commLog = [[NSMutableArray alloc] initWithCapacity:kCommLogTrimThreshold];
1676 NSArray *savedCommLog = [dict oo_arrayForKey:@"comm_log"];
1677 NSUInteger commCount = [savedCommLog count];
1678 for (NSUInteger i = 0; i < commCount; i++)
1680 [UNIVERSE addCommsMessage:[savedCommLog objectAtIndex:i] forCount:0 andShowComms:NO logOnly:YES];
1688 entity_personality = [dict oo_unsignedShortForKey:@"entity_personality" defaultValue:entity_personality];
1691 [
self setActiveMissile:0];
1694 [missile_entity[i] release];
1697 NSArray *missileRoles = [dict oo_arrayForKey:@"missile_roles"];
1698 if (missileRoles !=
nil)
1703 NSString *missile_desc = [missileRoles oo_stringAtIndex:roleIndex];
1704 if (missile_desc !=
nil && ![missile_desc isEqualToString:
@"NONE"])
1706 ShipEntity *amiss = [UNIVERSE newShipWithRole:missile_desc];
1715 OOLogWARN(
@"load.failed.missileNotFound",
@"couldn't find missile with role '%@' in [PlayerEntity setCommanderDataFromDictionary:], missile entry discarded.", missile_desc);
1723 for (NSUInteger i = 0; i <
missiles; i++)
1731 if (energyBombCompensation)
1738 if ([
self mountMissileWithRole:
@"EQ_QC_MINE"])
1740 OOLog(
@"load.upgrade.replacedEnergyBomb",
@"%@",
@"Replaced legacy energy bomb with Quirium cascade mine.");
1745 OOLog(
@"load.upgrade.replacedEnergyBomb",
@"%@",
@"Compensated legacy energy bomb with 900 credits.");
1749 [
self setActiveMissile:0];
1751 [
self setHeatInsulation:1.0];
1766 [
self deserializeShipSubEntitiesFrom:[dict oo_stringForKey:@"subentities_status"]];
1770 whArray = [dict objectForKey:@"wormholes"];
1771 NSEnumerator * whDicts = [whArray objectEnumerator];
1772 NSDictionary * whCurrDict;
1773 [scannedWormholes release];
1774 scannedWormholes = [[NSMutableArray alloc] initWithCapacity:[whArray count]];
1775 while ((whCurrDict = [whDicts nextObject]) !=
nil)
1778 [scannedWormholes addObject:wh];
1795 [UNIVERSE setDockingClearanceProtocolActive:[dict oo_boolForKey:@"docking_clearance_protocol" defaultValue:NO]];
1798 [
self setUpTrumbles];
1799 [
self setTrumbleValueFrom:[dict objectForKey:@"trumbles"]];
1823 NSAssert(
gOOPlayer ==
nil,
@"Expected only one PlayerEntity to exist at a time.");
1824 return [
super initBypassForPlayer];
1830 NSAssert(
gOOPlayer ==
self,
@"Expected only one PlayerEntity to exist at a time.");
1831 NSAssert([super initWithKey:
PLAYER_SHIP_DESC definition:[NSDictionary dictionary]] ==
self,
@"PlayerEntity requires -[ShipEntity initWithKey:definition:] to return unmodified self.");
1834#if OO_FOV_INFLIGHT_CONTROL_ENABLED
1844 [
self setStatus:STATUS_START_GAME];
1851 [
self setUpAndConfirmOK:NO];
1861 [hud resetGuis:[NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionary], @"message_gui",
1862 [NSDictionary dictionary], @"comm_log_gui", nil]];
1864 [
self initControls];
1868- (BOOL) setUpAndConfirmOK:(BOOL)stopOnError
1870 return [
self setUpAndConfirmOK:stopOnError saveGame:NO];
1874- (BOOL) setUpAndConfirmOK:(BOOL)stopOnError saveGame:(BOOL)saveGame
1912 [
self setDockedStation:nil];
1913 [
self setStatus:STATUS_DEAD];
1914 OOLog(
@"script.javascript.init.error",
@"%@",
@"Scheduling new JavaScript reset.");
1930 [UNIVERSE setBlockJSPlayerShipProps:NO];
1938 [UNIVERSE preloadSounds];
1941 [UNIVERSE loadConditionScripts];
1947 [UNIVERSE preloadSounds];
1952 [UNIVERSE loadConditionScripts];
1962 [
self removeAllCargo:YES];
1965 [
self setShipDataKey:PLAYER_SHIP_DESC];
1969 [UNIVERSE setAutoCommLog:YES];
1970 [UNIVERSE setPermanentCommLog:NO];
1972 [multiFunctionDisplayText release];
1975 [multiFunctionDisplaySettings release];
1978 [customDialSettings release];
1981 [
self switchHudTo:@"hud.plist"];
1985 [mission_variables release];
1988 [localVariables release];
1991 [
self setScriptTarget:nil];
1992 [
self resetMissionChoice];
1993 [[UNIVERSE gameView] resetTypedString];
1996 [reputation release];
1997 reputation = [[NSMutableDictionary alloc] initWithCapacity:6];
1998 [reputation oo_setInteger:0 forKey:CONTRACTS_GOOD_KEY];
1999 [reputation oo_setInteger:0 forKey:CONTRACTS_BAD_KEY];
2000 [reputation oo_setInteger:MAX_CONTRACT_REP forKey:CONTRACTS_UNKNOWN_KEY];
2001 [reputation oo_setInteger:0 forKey:PASSAGE_GOOD_KEY];
2002 [reputation oo_setInteger:0 forKey:PASSAGE_BAD_KEY];
2003 [reputation oo_setInteger:MAX_CONTRACT_REP forKey:PASSAGE_UNKNOWN_KEY];
2004 [reputation oo_setInteger:0 forKey:PARCEL_GOOD_KEY];
2005 [reputation oo_setInteger:0 forKey:PARCEL_BAD_KEY];
2006 [reputation oo_setInteger:MAX_CONTRACT_REP forKey:PARCEL_UNKNOWN_KEY];
2009 roleWeights = [[NSMutableArray alloc] initWithCapacity:8];
2010 for (i = 0 ; i < 8 ; i++)
2012 [roleWeights addObject:@"player-unknown"];
2042 [passengers release];
2044 [passenger_record release];
2047 [contracts release];
2048 contracts = [[NSMutableArray alloc] init];
2049 [contract_record release];
2053 parcels = [[NSMutableArray alloc] init];
2054 [parcel_record release];
2057 [missionDestinations release];
2060 [shipyard_record release];
2063 [target_memory release];
2064 target_memory = [[NSMutableArray alloc] initWithCapacity:PLAYER_TARGET_MEMORY_SIZE];
2065 [
self clearTargetMemory];
2067 [
self setMissionOverlayDescriptor:nil];
2068 [
self setMissionBackgroundDescriptor:nil];
2069 [
self setMissionBackgroundSpecial:nil];
2070 [
self setEquipScreenBackgroundDescriptor:nil];
2078 NSCalendarDate *nowDate = [NSCalendarDate calendarDate];
2089 voice_gender_m = YES;
2090 voice_no = [UNIVERSE setVoice:-1 withGenderM:voice_gender_m];
2093 [_customViews release];
2102 [
self setCommanderName:PLAYER_DEFAULT_NAME];
2103 [
self setLastsaveName:PLAYER_DEFAULT_NAME];
2131 shipCommodityData = [[[UNIVERSE commodities] generateManifestForPlayer] retain];
2137 [eqScripts release];
2138 eqScripts = [[NSMutableArray alloc] init];
2140 [
self setFastEquipmentA:@"EQ_CLOAKING_DEVICE"];
2141 [
self setFastEquipmentB:@"EQ_ENERGY_BOMB"];
2143 [
self setActiveMissile:0];
2146 [missile_entity[i] release];
2149 [
self safeAllMissiles];
2151 [
self clearSubEntities];
2183 [UNIVERSE clearGUIs];
2188 [
self setDockedStation:[UNIVERSE station]];
2193 [specialCargo release];
2204 [
self currentWeaponStats];
2206 [save_path autorelease];
2209 [scannedWormholes release];
2212 [
self setUpTrumbles];
2218 [dockingReport release];
2222 shipAI = [[
AI alloc] initWithStateMachine:PLAYER_DOCKING_AI_NAME andState:@"GLOBAL"];
2223 [
self resetAutopilotAI];
2229 [
self setSystemID:[UNIVERSE findSystemNumberAtCoords:[
self galaxy_coordinates] withGalaxy:galaxy_number includingHidden:YES]];
2230 [UNIVERSE setGalaxyTo:galaxy_number];
2231 [UNIVERSE setSystemTo:system_id];
2233 [
self setUpWeaponSounds];
2235 [
self setGalacticHyperspaceBehaviourTo:[[UNIVERSE globalSettings] oo_stringForKey:@"galactic_hyperspace_behaviour" defaultValue:@"BEHAVIOUR_STANDARD"]];
2236 [
self setGalacticHyperspaceFixedCoordsTo:[[UNIVERSE globalSettings] oo_stringForKey:@"galactic_hyperspace_fixed_coords" defaultValue:@"96 96"]];
2243 [stickProfileScreen release];
2251 [
self completeSetUpAndSetTarget:YES];
2255- (void) completeSetUpAndSetTarget:(BOOL)setTarget
2259 [
self setDockedStation:[UNIVERSE station]];
2260 [
self setLastAegisLock:[UNIVERSE planet]];
2261 [
self validateCustomEquipActivationArray];
2264 [
self doWorldScriptEvent:OOJSID("startUp") inContext:context withArguments:NULL count:0 timeLimit:MAX(0.0, [[NSUserDefaults standardUserDefaults] oo_floatForKey:@"start-script-limit-value" defaultValue:kOOJSLongTimeLimit])];
2272 [
self doWorldScriptEvent:OOJSID("startUpComplete") inContext:context withArguments:NULL count:0 timeLimit:kOOJSLongTimeLimit];
2277- (BOOL) setUpShipFromDictionary:(NSDictionary *)shipDict
2280 [UNIVERSE setBlockJSPlayerShipProps:NO];
2282 if (![super setUpFromDictionary:shipDict])
return NO;
2285 cargo = [[NSMutableArray alloc] initWithCapacity:max_cargo];
2300 [
self setPrimaryRole:@"player"];
2302 [
self removeAllEquipment];
2303 [
self addEquipmentFromCollection:[shipDict objectForKey:@"extra_equipment"]];
2317 [missile_entity[i] release];
2327 [
self safeAllMissiles];
2328 [
self setActiveMissile:0];
2331 [
self setDefaultViewOffsets];
2335 forwardViewOffset = [shipDict oo_vectorForKey:@"view_position_forward" defaultValue:forwardViewOffset];
2336 aftViewOffset = [shipDict oo_vectorForKey:@"view_position_aft" defaultValue:aftViewOffset];
2337 portViewOffset = [shipDict oo_vectorForKey:@"view_position_port" defaultValue:portViewOffset];
2338 starboardViewOffset = [shipDict oo_vectorForKey:@"view_position_starboard" defaultValue:starboardViewOffset];
2348 [
self setDefaultCustomViews];
2350 NSArray *customViews = [shipDict oo_arrayForKey:@"custom_views"];
2351 if (customViews !=
nil)
2353 [_customViews release];
2358 massLockable = [shipDict oo_boolForKey:@"mass_lockable" defaultValue:YES];
2361 [script autorelease];
2362 NSDictionary *scriptProperties = [NSDictionary dictionaryWithObject:self forKey:@"ship"];
2435 [
self destroySound];
2464 return [UNIVERSE sessionID];
2470 [
self playHostileWarning];
2478 case STATUS_START_GAME:
2479 case STATUS_DOCKING:
2482 case STATUS_ESCAPE_SEQUENCE:
2491- (NSComparisonResult) compareZeroDistance:(
Entity *)otherEntity
2493 return NSOrderedDescending;
2503- (GLfloat) lookingAtSunWithThresholdAngleCos:(GLfloat) thresholdAngleCos
2506 GLfloat measuredCos = 999.0f, measuredCosAbs;
2507 GLfloat sunBrightness = 0.0f;
2513 OOViewID vdir = [UNIVERSE viewDirection];
2515 unsigned ent_count =
UNIVERSE->n_entities;
2517 for (i = 0; i < ent_count; i++)
2522 ([uni_entities[i]
isShip] &&
2526 if (
EXPECT(vdir > VIEW_STARBOARD || ![uni_entities[i]
isPlayer]))
2528 float shadow = 1.5f;
2545 measuredCos = -dot_product(unitRelativePosition,
v_forward);
2548 measuredCos = +dot_product(unitRelativePosition,
v_forward);
2551 measuredCos = +dot_product(unitRelativePosition,
v_right);
2553 case VIEW_STARBOARD:
2554 measuredCos = -dot_product(unitRelativePosition,
v_right);
2558 Vector relativeView = [
self customViewForwardVector];
2560 measuredCos = -dot_product(unitRelativePosition, absoluteView);
2567 measuredCosAbs = fabs(measuredCos);
2574 if (thresholdAngleCos <= measuredCosAbs && measuredCosAbs <= 1.1f)
2576 sunBrightness = (measuredCos - thresholdAngleCos) / (1.0f - thresholdAngleCos);
2578 if (sunBrightness < 0.0f) sunBrightness = 0.0f;
2579 else if (sunBrightness > 1.0f) sunBrightness = 1.0f;
2582 return sunBrightness * sunBrightness * sunBrightness;
2588 GLfloat insideAtmoFrac = 0.0f;
2590 if ([
UNIVERSE airResistanceFactor] > 0.01)
2595 return insideAtmoFrac;
2600#define STAGE_TRACKING_BEGIN { \
2601 NSString * volatile updateStage = @"initialisation"; \
2603#define STAGE_TRACKING_END } \
2604 @catch (NSException *exception) \
2606 OOLog(kOOLogException, @"***** Exception during [%@] in %s : %@ : %@ *****", updateStage, __PRETTY_FUNCTION__, [exception name], [exception reason]); \
2610#define UPDATE_STAGE(x) do { updateStage = (x); } while (0)
2612#define STAGE_TRACKING_BEGIN {
2613#define STAGE_TRACKING_END }
2614#define UPDATE_STAGE(x) do { (void) (x); } while (0);
2623 [
self updateMovementFlags];
2625 [
self updateAlertCondition];
2627 [
self updateFuelScoops:delta_t];
2630 [
self updateClocks:delta_t];
2636 [
self checkScriptsIfAppropriate];
2640 [
self manageCollisions];
2643 [
self pollControls:delta_t];
2646 [
self updateTrumbles:delta_t];
2661 gui_screen != GUI_SCREEN_KEYBOARD_CONFIRMCLEAR &&
2668 [
self setGuiToIntroFirstGo:YES];
2671 if (
status == STATUS_AUTOPILOT_ENGAGED ||
status == STATUS_ESCAPE_SEQUENCE)
2674 [
self performAutopilotUpdates:delta_t];
2679 [
self performInFlightUpdates:delta_t];
2685 if (
status == STATUS_IN_FLIGHT)
2688 [
self doBookkeeping:delta_t];
2690 if (
status == STATUS_WITCHSPACE_COUNTDOWN)
2693 [
self performWitchspaceCountdownUpdates:delta_t];
2695 if (
status == STATUS_EXITING_WITCHSPACE)
2698 [
self performWitchspaceExitUpdates:delta_t];
2700 if (
status == STATUS_LAUNCHING)
2703 [
self performLaunchingUpdates:delta_t];
2705 if (
status == STATUS_DOCKING)
2708 [
self performDockingUpdates:delta_t];
2710 if (
status == STATUS_DEAD)
2713 [
self performDeadUpdates:delta_t];
2717 [
self updateWormholes];
2723- (void) doBookkeeping:(
double) delta_t
2730 double external_temp = 0;
2731 GLfloat air_friction = 0.0f;
2732 air_friction = 0.5f * [UNIVERSE airResistanceFactor];
2733 if (air_friction < 0.005f)
2739 UPDATE_STAGE(
@"updating weapon temperatures and shot times");
2784 [
self deactivateCloakingDevice];
2815 [UNIVERSE addMessage:DESC(@"ecm-out-of-juice") forCount:3.0];
2836 float fwdMax = [
self maxForwardShieldLevel];
2837 float aftMax = [
self maxAftShieldLevel];
2838 float shieldRechargeFwd = [
self forwardShieldRechargeRate] * delta_t;
2839 float shieldRechargeAft = [
self aftShieldRechargeRate] * delta_t;
2849 float rechargeAft =
MIN(shieldRechargeAft, aftMax -
aft_shield);
2855 float energyForShields =
energy;
2859 float minEnergyBankLevel = [[UNIVERSE globalSettings] oo_floatForKey:@"shield_charge_energybank_threshold" defaultValue:0.25];
2865 rechargeFwd =
MIN(rechargeFwd, energyForShields);
2866 rechargeAft =
MIN(rechargeAft, energyForShields - rechargeFwd);
2870 rechargeAft =
MIN(rechargeAft, energyForShields);
2871 rechargeFwd =
MIN(rechargeFwd, energyForShields - rechargeAft);
2877 energy -= rechargeFwd + rechargeAft;
2890 double alt1 = sun_cr * sun_cr / sun_zd;
2894 external_temp *= 100;
2896 if ([sun willGoNova])
2907 [
self setFuel:[
self fuel] + 1];
2909 [
self doScriptEvent:OOJSID("shipScoopedFuel")];
2911 [UNIVERSE displayCountdownMessage:DESC(@"fuel-scoop-active") forCount:1.0];
2917 if ((
status != STATUS_ESCAPE_SEQUENCE) && (
status != STATUS_ENTERING_WITCHSPACE))
2936 [
self takeHeatDamage: delta_t * ship_temperature];
2944 [
self setBounty:0 withReason:kOOLegalStatusReasonEscapePod];
2949 [
self doScriptEvent:OOJSID("escapePodSequenceOver")];
2958 [UNIVERSE setSystemTo:system_id];
2961 [UNIVERSE setUpSpace];
2963 [UNIVERSE populateNormalSpace];
2965 [
self setDockTarget:[UNIVERSE station]];
2968 [UNIVERSE setWitchspaceBreakPattern:YES];
2969 [
self doScriptEvent:OOJSID("shipWillExitWitchspace")];
2970 [
self doScriptEvent:OOJSID("shipExitedWitchspace")];
2972 [[UNIVERSE planet] update: 2.34375 * market_rnd];
2973 [[UNIVERSE station] update: 2.34375 * market_rnd];
2976 Entity *dockTargetEntity = [UNIVERSE entityForUniversalID:_dockTarget];
2981 ShipEntity *player_ship = [UNIVERSE newShipWithName:[
self shipDataKey]];
2985 [
self setMesh:[player_ship
mesh]];
2986 [player_ship release];
2988 [UNIVERSE setViewDirection:VIEW_FORWARD];
2989 [UNIVERSE setBlockJSPlayerShipProps:NO];
2990 [
self enterDock:(StationEntity *)dockTargetEntity];
2994 [
self setStatus:STATUS_DEAD];
2997 [UNIVERSE displayMessage:DESC(@"gameoverscreen-escape-pod") forCount:kDeadResetTime];
2998 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
2999 [
self showGameOver];
3023 [
self playJumpMassLocked];
3024 [UNIVERSE addMessage:DESC(@"jump-mass-locked") forCount:4.5];
3034 float abFactor = [
self afterburnerFactor];
3039 flightSpeed -= (float)(speed_delta * delta_t * abFactor);
3044 flightSpeed += (float)(speed_delta * delta_t * abFactor);
3100 double z = [hud scannerZoom];
3104 if (floor(z1) > floor(z))
3118 [hud setScannerZoom:z1];
3121 [[UNIVERSE gameView] setFov:fieldOfView fromFraction:YES];
3124 ShipEntity *primeTarget = [
self primaryTarget];
3127 [UNIVERSE addMessage:DESC(@"target-lost") forCount:3.0];
3128 [
self removeTarget:primeTarget];
3131 [
self validateCompassTarget];
3163 if (mouseWheelDelta > 0.0f)
3168 else if (mouseWheelDelta < 0.0f)
3191 [
self clearAlertFlags];
3196 int i, ent_count =
UNIVERSE->n_entities;
3198 Entity *my_entities[ent_count];
3200 for (i = 0; i < ent_count; i++)
3202 my_entities[i] = [uni_entities[i] retain];
3205 BOOL foundHostiles = NO;
3206#if OO_VARIABLE_TORUS_SPEED
3207 BOOL needHyperspeedNearest = YES;
3208 double hsnDistance = 0;
3210 for (i = 0; i < ent_count; i++)
3212 scannedEntity = my_entities[i];
3214#if OO_VARIABLE_TORUS_SPEED
3218 if (scannedEntity !=
self && [scannedEntity
canCollide] && (![scannedEntity
isShip] || ![
self collisionExceptedFor:(
ShipEntity *) scannedEntity]))
3221 needHyperspeedNearest = NO;
3230 if (thisHSN < hsnDistance)
3232 hsnDistance = thisHSN;
3239 int theirClass = [scannedEntity scanClass];
3243 if ([self massLockable] )
3245 massLocked |= [self checkEntityForMassLock:scannedEntity withScanClass:theirClass];
3247 if (theirClass != CLASS_NO_DRAW)
3251 foundHostiles = YES;
3253 else if ([scannedEntity
isShip])
3261#if OO_VARIABLE_TORUS_SPEED
3290 [
self setAlertFlag:ALERT_FLAG_MASS_LOCK to:massLocked];
3292 [
self setAlertFlag:ALERT_FLAG_HOSTILES to:foundHostiles];
3294 for (i = 0; i < ent_count; i++)
3296 [my_entities[i] release];
3299 BOOL energyCritical = NO;
3302 energyCritical = YES;
3304 [
self setAlertFlag:ALERT_FLAG_ENERGY to:energyCritical];
3306 [
self setAlertFlag:ALERT_FLAG_TEMP to:([
self hullHeatLevel] > .90)];
3308 [
self setAlertFlag:ALERT_FLAG_ALT to:([
self dialAltitude] < .10)];
3313- (void) setMaxFlightPitch:(GLfloat)new
3320- (void) setMaxFlightRoll:(GLfloat)new
3327- (void) setMaxFlightYaw:(GLfloat)new
3334- (BOOL) checkEntityForMassLock:(
Entity *)ent withScanClass:(
int)theirClass
3346 double factor = ([stellar
isSun]) ? 2.0 : 4.0;
3349 if (dist < rad*rad*factor || dist < rad*rad + 50000*rad + 625000000 )
3355 else if (theirClass != CLASS_NO_DRAW)
3359 theirClass = CLASS_NO_DRAW;
3369 if (entIsCloakedShip && ![ent isPlayer])
3379 case CLASS_VISUAL_EFFECT:
3382 case CLASS_THARGOID:
3386 case CLASS_MILITARY:
3387 case CLASS_WORMHOLE:
3400 [
self updateAlertConditionForNearbyEntities];
3448 [
self updateFuelScoopSoundWithInterval:delta_t];
3452 [
self updateFuelScoopSoundWithInterval:delta_t];
3463 unsigned prev_day = floor(
ship_clock / 86400);
3467 double fine_adjust = delta_t * 7200.0;
3469 fine_adjust = delta_t * 115200.0;
3488 unsigned now_day = floor(
ship_clock / 86400.0);
3489 while (prev_day < now_day)
3492 [
self doScriptEvent:OOJSID("dayChanged") withArgument:[NSNumber numberWithUnsignedInt:prev_day]];
3513 [UNIVERSE resetFramesDoneThisUpdate];
3522 if ([
self status] != STATUS_IN_FLIGHT)
3527 case GUI_SCREEN_MAIN:
3528 case GUI_SCREEN_INTRO1:
3529 case GUI_SCREEN_SHIPLIBRARY:
3530 case GUI_SCREEN_KEYBOARD:
3531 case GUI_SCREEN_NEWGAME:
3532 case GUI_SCREEN_OXZMANAGER:
3533 case GUI_SCREEN_MARKET:
3534 case GUI_SCREEN_MARKETINFO:
3535 case GUI_SCREEN_OPTIONS:
3536 case GUI_SCREEN_GAMEOPTIONS:
3537 case GUI_SCREEN_LOAD:
3538 case GUI_SCREEN_SAVE:
3539 case GUI_SCREEN_SAVE_OVERWRITE:
3540 case GUI_SCREEN_STICKMAPPER:
3541 case GUI_SCREEN_STICKPROFILE:
3542 case GUI_SCREEN_MISSION:
3543 case GUI_SCREEN_REPORT:
3544 case GUI_SCREEN_KEYBOARD_CONFIRMCLEAR:
3545 case GUI_SCREEN_KEYBOARD_CONFIG:
3546 case GUI_SCREEN_KEYBOARD_ENTRY:
3547 case GUI_SCREEN_KEYBOARD_LAYOUT:
3552 case GUI_SCREEN_EQUIP_SHIP:
3553 case GUI_SCREEN_INTERFACES:
3554 case GUI_SCREEN_MANIFEST:
3555 case GUI_SCREEN_SHIPYARD:
3556 case GUI_SCREEN_LONG_RANGE_CHART:
3557 case GUI_SCREEN_SHORT_RANGE_CHART:
3558 case GUI_SCREEN_STATUS:
3559 case GUI_SCREEN_SYSTEM_DATA:
3573 OOTrumble **trumbles = [
self trumbleArray];
3584- (void) performAutopilotUpdates:(
OOTimeDelta)delta_t
3586 [
self processBehaviour:delta_t];
3587 [
self applyVelocity:delta_t];
3588 [
self doBookkeeping:delta_t];
3591- (void) performDockingRequest:(
StationEntity *)stationForDocking
3593 if (stationForDocking ==
nil)
return;
3599 [
self disengageAutopilot];
3602 if (stationDockingClearanceStatus !=
nil)
3604 [
self doScriptEvent:OOJSID("playerRequestedDockingClearance") withArgument:stationDockingClearanceStatus];
3605 if ([stationDockingClearanceStatus isEqualToString:
@"DOCKING_CLEARANCE_GRANTED"])
3607 [
self doScriptEvent:OOJSID("playerDockingClearanceGranted")];
3612- (void) requestDockingClearance:(
StationEntity *)stationForDocking
3616 [
self performDockingRequest:stationForDocking];
3620- (void) cancelDockingRequest:(
StationEntity *)stationForDocking
3622 if (stationForDocking ==
nil)
return;
3628 [
self disengageAutopilot];
3633 if (stationDockingClearanceStatus !=
nil && [stationDockingClearanceStatus isEqualToString:
@"DOCKING_CLEARANCE_CANCELLED"])
3635 [
self doScriptEvent:OOJSID("playerDockingClearanceCancelled")];
3640- (BOOL) engageAutopilotToStation:(
StationEntity *)stationForDocking
3642 if (stationForDocking ==
nil)
return NO;
3650 [
self setTargetStation:stationForDocking];
3654 [
self safeAllMissiles];
3656 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN) [
self cancelWitchspaceCountdown];
3657 [
self setStatus:STATUS_AUTOPILOT_ENGAGED];
3658 [
self resetAutopilotAI];
3659 [shipAI setState:@"BEGIN_DOCKING"];
3660 [
self playAutopilotOn];
3662 [
self doScriptEvent:OOJSID("playerStartedAutoPilot") withArgument:stationForDocking];
3663 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_GRANTED];
3679 [
self abortDocking];
3684 [
self setTargetStation:nil];
3685 [
self setStatus:STATUS_IN_FLIGHT];
3686 [
self playAutopilotOff];
3687 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
3689 [
self doScriptEvent:OOJSID("playerCancelledAutoPilot")];
3691 [
self resetAutopilotAI];
3698 AI *myAI = [
self getAI];
3702 [
self setAITo:PLAYER_DOCKING_AI_NAME ];
3711#define VELOCITY_CLEANUP_MIN 2000.0f
3712#define VELOCITY_CLEANUP_FULL 5000.0f
3713#define VELOCITY_CLEANUP_RATE 0.001f
3716#if OO_VARIABLE_TORUS_SPEED
3736- (void) performInFlightUpdates:(
OOTimeDelta)delta_t
3745 [
self applyVelocity:delta_t];
3747 GLfloat thrust_factor = 1.0;
3752 thrust_factor = [
self afterburnerFactor];
3761 GLfloat velmag = magnitude(
velocity);
3762 GLfloat velmag2 = velmag - (float)delta_t *
thrust * thrust_factor;
3773 velmag2 -= velmag * rate;
3781 [
self applyRoll:(float)delta_t*flightRoll andClimb:(float)delta_t*flightPitch];
3784 [
self applyYaw:(float)delta_t*flightYaw];
3788 [
self moveForward:delta_t*flightSpeed];
3791 [
self updateTargeting];
3797- (void) performWitchspaceCountdownUpdates:(
OOTimeDelta)delta_t
3802 [
self doBookkeeping:delta_t];
3814 [
self setStatus:STATUS_IN_FLIGHT];
3815 [
self playHyperspaceAborted];
3823 [UNIVERSE displayCountdownMessage:OOExpandKey(@"witch-galactic-in-x-seconds", seconds) forCount:1.0];
3827 NSString *
destination = [UNIVERSE getSystemName:[
self nextHopTargetSystemID]];
3828 [UNIVERSE displayCountdownMessage:OOExpandKey(@"witch-to-x-in-y-seconds", seconds, destination) forCount:1.0];
3844 [UNIVERSE preloadPlanetTexturesForSystem:target_system_id];
3853 else [
self enterWitchspace];
3861- (void) performWitchspaceExitUpdates:(
OOTimeDelta)delta_t
3865 [
self resetExhaustPlumes];
3869 [
self resetScriptTimer];
3874 [UNIVERSE addMessage:[NSString stringWithFormat:@" %@. ",[UNIVERSE getSystemName:system_id]] forCount:3.0];
3876 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_COMPASS"])
3883 if ([
UNIVERSE inInterstellarSpace]) [UNIVERSE addMessage:DESC(@"witch-engine-malfunction") forCount:3.0];
3886 [
self setStatus:STATUS_IN_FLIGHT];
3893 [
self setScriptedMisjumpRange:0.5];
3895 [
self doScriptEvent:OOJSID("shipExitedWitchspace") withArgument:[
self jumpCause]];
3897 [
self doBookkeeping:delta_t];
3904- (void) performLaunchingUpdates:(
OOTimeDelta)delta_t
3909 [
self doBookkeeping:delta_t];
3918 [
self setStatus:STATUS_IN_FLIGHT];
3920 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
3921 StationEntity *stationLaunchedFrom = [UNIVERSE nearestEntityMatchingPredicate:IsStationPredicate parameter:NULL relativeToEntity:self];
3922 [
self doScriptEvent:OOJSID("shipLaunchedFromStation") withArgument:stationLaunchedFrom];
3927- (void) performDockingUpdates:(
OOTimeDelta)delta_t
3938 [
self gameOverFadeToBW];
3943 [UNIVERSE handleGameOver];
3951 float secondsToBWFadeOut = [[NSUserDefaults standardUserDefaults] oo_floatForKey:@"gameover-seconds-to-bw-fadeout" defaultValue:5.0f];
3955 static float originalColorSaturation = -1.0f;
3956 if (originalColorSaturation == -1.0f) originalColorSaturation = [gameView
colorSaturation];
3957 if ([
self shotTime] < secondsToBWFadeOut)
3963 [gameView
adjustColorSaturation:-(originalColorSaturation * (1.0f / secondsToBWFadeOut) * [UNIVERSE timeAccelerationFactor] / fps_counter)];
3973 originalColorSaturation = -1.0f;
3982- (BOOL)isValidTarget:(
Entity*)target
4002 if (tstatus == STATUS_ENTERING_WITCHSPACE || tstatus == STATUS_IN_HOLD || tstatus == STATUS_DOCKED)
4011 [
self hasEquipmentItemProviding:
@"EQ_WORMHOLE_SCANNER"] &&
ident_engaged)
4023 [hud resetGuis:[NSDictionary dictionaryWithObject:[NSDictionary dictionary] forKey:@"message_gui"]];
4024 NSString *scoreMS = [NSString stringWithFormat:OOExpandKey(@"gameoverscreen-score-@"),
4025 KillCountToRatingAndKillString(ship_kills)];
4027 [UNIVERSE displayMessage:OOExpandKey(@"gameoverscreen-game-over") forCount:kDeadResetTime];
4028 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
4029 [UNIVERSE displayMessage:scoreMS forCount:kDeadResetTime];
4030 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
4031 [UNIVERSE displayMessage:OOExpandKey(@"gameoverscreen-press-space") forCount:kDeadResetTime];
4032 [UNIVERSE displayMessage:@" " forCount:kDeadResetTime];
4033 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
4034 [
self resetShotTime];
4038- (void) showShipModelWithKey:(NSString *)shipKey shipData:(NSDictionary *)shipData personality:(uint16_t)personality factorX:(GLfloat)factorX factorY:(GLfloat)factorY factorZ:(GLfloat)factorZ inContext:(NSString *)context
4040 if (shipKey ==
nil)
return;
4042 if (shipData ==
nil)
return;
4044 Quaternion q2 = { (GLfloat)
M_SQRT1_2, (GLfloat)
M_SQRT1_2, (GLfloat)0.0f, (GLfloat)0.0f };
4048 q2 = [demoShip orientation];
4057 if (context)
OOLog(
@"script.debug.note.showShipModel",
@"::::: showShipModel:'%@' in context: %@.", [ship
name], context);
4066 [ship
setAITo: @"nullAI.plist"];
4067 id subEntStatus = [shipData objectForKey:@"subentities_status"];
4070 [UNIVERSE addEntity: ship];
4074 [ship
setStatus: STATUS_COCKPIT_DISPLAY];
4087 case GUI_SCREEN_GAMEOPTIONS:
4089 [
self setGuiToGameOptionsScreen];
4091 case GUI_SCREEN_STATUS:
4094 [
self setGuiToStatusScreen];
4101 [hud resetGuiPositions];
4123 [UNIVERSE addMessage:DESC(@"target-lost") forCount:3.0];
4124 [
self playTargetLost];
4125 [
self noteLostTarget];
4146 [UNIVERSE addMessage:DESC(@"target-lost") forCount:3.0];
4147 [
self playTargetLost];
4148 [missile_entity[i] removeTarget:nil];
4151 [
self noteLostTarget];
4166 ([
self status] == STATUS_IN_FLIGHT || [
self status] == STATUS_WITCHSPACE_COUNTDOWN))
4168 Entity *target = [UNIVERSE firstEntityTargetedByPlayer];
4169 if ([
self isValidTarget:target])
4171 [
self addTarget:target];
4177 UPDATE_STAGE(
@"checking for additional wormhole information");
4181 switch ([wh scanInfo])
4206 [UNIVERSE addCommsMessage:[NSString stringWithFormat:DESC(@"wormhole-arrival-time-computed-@"),
4214 [UNIVERSE addCommsMessage:[NSString stringWithFormat:DESC(@"wormhole-destination-computed-@"),
4215 [UNIVERSE getSystemName:[wh
destination]]] forCount:5.0];
4246- (void) applyAttitudeChanges:(
double) delta_t
4248 [
self applyRoll:flightRoll*delta_t andClimb:flightPitch*delta_t];
4249 [
self applyYaw:flightYaw*delta_t];
4253- (void) applyRoll:(GLfloat) roll1 andClimb:(GLfloat) climb1
4255 if (roll1 == 0.0 && climb1 == 0.0 &&
hasRotated == NO)
4278 [
self orientationChanged];
4286- (void) applyYaw:(GLfloat) yaw
4290 [
self orientationChanged];
4304 return OOMatrixTranslate(result, HPVectorToVector(
position));
4314- (void) setNormalOrientation:(Quaternion) quat
4316 [
self setOrientation:make_quaternion(-quat.w, quat.x, quat.y, quat.z)];
4320- (void) moveForward:(
double) amount
4323 [
self setPosition:HPvector_add(position, vectorToHPVector(vector_multiply_scalar(v_forward, (float)amount)))];
4347 case VIEW_STARBOARD:
4392 Vector
offset = [
self viewpointOffset];
4397 viewpoint.x +=
offset.
x * r.m[0][0]; viewpoint.y +=
offset.
x * r.m[1][0]; viewpoint.z +=
offset.
x * r.m[2][0];
4398 viewpoint.x +=
offset.
y * r.m[0][1]; viewpoint.y +=
offset.
y * r.m[1][1]; viewpoint.z +=
offset.
y * r.m[2][1];
4399 viewpoint.x +=
offset.z * r.m[0][2]; viewpoint.y +=
offset.z * r.m[1][2]; viewpoint.z +=
offset.z * r.m[2][2];
4405- (void) drawImmediate:(
bool)immediate translucent:(
bool)translucent
4410 case STATUS_COCKPIT_DISPLAY:
4412 case STATUS_START_GAME:
4416 if ([
UNIVERSE breakPatternHide])
return;
4419 [
super drawImmediate:immediate translucent:translucent];
4423- (void) setMassLockable:(BOOL)newValue
4426 [
self updateAlertCondition];
4454- (void) setOcclusionLevel:(
float)level
4462 [
self setDockedStation:[UNIVERSE station]];
4469 return [_dockedStation weakRefUnderlyingObject];
4475 [_dockedStation release];
4502 NSString *hud_desc = [shipDict oo_stringForKey:@"hud" defaultValue:@"hud.plist"];
4503 if (![
self switchHudTo:hud_desc]) [
self switchHudTo:@"hud.plist"];
4507- (BOOL) switchHudTo:(NSString *)hudFileName
4509 NSDictionary *hudDict =
nil;
4510 BOOL wasHidden = NO;
4511 BOOL wasCompassActive = YES;
4512 double scannerZoom = 1.0;
4513 NSUInteger lastMFD = 0;
4516 if (!hudFileName)
return NO;
4521 [hud setDeferredHudName:hudFileName];
4529 OOLog(
@"PlayerEntity.switchHudTo.failed",
@"HUD dictionary file %@ to switch to not found or invalid.", hudFileName);
4536 wasHidden = [hud isHidden];
4537 wasCompassActive = [hud isCompassActive];
4538 scannerZoom = [hud scannerZoom];
4545 [hud setHidden:YES];
4547 hud = [[
HeadUpDisplay alloc] initWithDictionary:hudDict inFile:hudFileName];
4548 [hud resetGuis:hudDict];
4550 [hud setScannerZoom:scannerZoom];
4551 [hud setCompassActive:wasCompassActive];
4552 [hud setHidden:wasHidden];
4554 NSArray *savedMFDs = [NSArray arrayWithArray:multiFunctionDisplaySettings];
4555 [multiFunctionDisplaySettings removeAllObjects];
4556 for (i = 0; i < [hud mfdCount] ; i++)
4558 if ([savedMFDs
count] > i)
4560 [multiFunctionDisplaySettings addObject:[savedMFDs objectAtIndex:i]];
4564 [multiFunctionDisplaySettings addObject:[NSNull null]];
4574- (float) dialCustomFloat:(NSString *)dialKey
4576 return [customDialSettings oo_floatForKey:dialKey defaultValue:0.0];
4580- (NSString *) dialCustomString:(NSString *)dialKey
4582 return [customDialSettings oo_stringForKey:dialKey defaultValue:@""];
4586- (
OOColor *) dialCustomColor:(NSString *)dialKey
4592- (void) setDialCustom:(
id)value forKey:(NSString *)dialKey
4594 [customDialSettings setObject:value forKey:dialKey];
4598- (void) setShowDemoShips:(BOOL)value
4634- (void) setMaxForwardShieldLevel:(
float)new
4640- (void) setMaxAftShieldLevel:(
float)new
4646- (void) setForwardShieldRechargeRate:(
float)new
4652- (void) setAftShieldRechargeRate:(
float)new
4670- (void) setForwardShieldLevel:(GLfloat)level
4676- (void) setAftShieldLevel:(GLfloat)level
4698 if ((result < 1.0f)&&(result > -1.0f))
4709 if ((result < 1.0f)&&(result > -1.0f))
4720 if ((result < 1.0f)&&(result > -1.0f))
4731 return OOClamp_0_1_f(result);
4748 return OOClamp_0_1_f(result);
4758 GLfloat result =
aft_shield / [
self maxAftShieldLevel];
4759 return OOClamp_0_1_f(result);
4766 return OOClamp_0_1_f(result);
4796 return OOClamp_0_1_f(result);
4803 return OOClamp_0_1_f(result);
4811 return OOClamp_0_1_f(result);
4818 return OOClamp_0_1_f(result);
4825 return OOClamp_0_1_f(result);
4838 Entity *nearestPlanet = [
self findNearestStellarBody];
4839 if (nearestPlanet ==
nil)
return 1.0f;
4843 GLfloat alt = sqrt(zd) - cr;
4867- (void) addToAdjustTime:(
double)seconds
4879- (void) setEscapePodRescueTime:(
double)seconds
4899 return [NSString stringWithFormat:@"FPS: %3d", fpsVal];
4905 NSString *result = [NSString stringWithFormat:@"Entities: %3ld", [UNIVERSE entityCount]];
4907 result = [NSString stringWithFormat:@"%@ (%d, %zu KiB, avg %lu bytes)", result, gLiveEntityCount, gTotalEntityMemory >> 10, gTotalEntityMemory / gLiveEntityCount];
4916 unsigned n_missiles = 0;
4938 OOLogERR(
@"player.missilesUnsafe",
@"%@",
@"Missile state is not SAFE when weapons are offline. This is a bug, please report it.");
4939 [
self safeAllMissiles];
4949 return [
super canScoop:other];
4978- (void) setFuelLeakRate:(
float)value
4990 NSUInteger
count = [commLog count];
4993 [commLog removeObjectsInRange:NSMakeRange(0, count - kCommLogTrimSize)];
4998 commLog = [[NSMutableArray alloc] init];
5011- (void) addRoleForAggression:(
ShipEntity *)victim
5017 NSString *role =
nil;
5018 if ([[victim
primaryRole] isEqualToString:
@"escape-capsule"])
5020 role =
@"assassin-player";
5022 else if ([victim
bounty] > 0)
5032 role =
@"pirate-interceptor";
5038 NSUInteger times = [roleWeightFlags oo_intForKey:role defaultValue:0];
5040 [roleWeightFlags setObject:[NSNumber numberWithUnsignedInteger:times] forKey:role];
5041 if ((times & (times-1)) == 0)
5043 [
self addRoleToPlayer:role];
5050 NSString *role =
@"miner";
5051 NSUInteger times = [roleWeightFlags oo_intForKey:role defaultValue:0];
5053 [roleWeightFlags setObject:[NSNumber numberWithUnsignedInteger:times] forKey:role];
5054 if ((times & (times-1)) == 0)
5056 [
self addRoleToPlayer:role];
5061- (void) addRoleToPlayer:(NSString *)role
5063 NSUInteger slot =
Ranrot() & ([
self maxPlayerRoles]-1);
5064 [
self addRoleToPlayer:role inSlot:slot];
5068- (void) addRoleToPlayer:(NSString *)role inSlot:(NSUInteger)slot
5072 slot = [
self maxPlayerRoles]-1;
5076 [roleWeights addObject:role];
5080 [roleWeights replaceObjectAtIndex:slot withObject:role];
5085- (void) clearRoleFromPlayer:(BOOL)includingLongRange
5087 NSUInteger slot =
Ranrot() % [roleWeights count];
5088 if (!includingLongRange)
5090 NSString *role = [roleWeights objectAtIndex:slot];
5092 if ([role hasSuffix:
@"+"] &&
randf() > 0.5)
5097 [roleWeights replaceObjectAtIndex:slot withObject:@"player-unknown"];
5101- (void) clearRolesFromPlayer:(
float)chance
5103 NSUInteger i,
count=[roleWeights count];
5104 for (i = 0; i <
count; i++)
5106 if (
randf() < chance)
5108 [roleWeights replaceObjectAtIndex:i withObject:@"player-unknown"];
5138 NSUInteger memory = 4;
5153 [roleSystemList removeObjectAtIndex:0];
5155 [roleSystemList addObject:[NSNumber numberWithInt:sys]];
5161 Entity *result = [compassTarget weakRefUnderlyingObject];
5171- (void) setCompassTarget:(
Entity *)value
5173 [compassTarget release];
5181 OOPlanetEntity *the_planet = [UNIVERSE planet];
5183 Entity *the_target = [
self primaryTarget];
5184 Entity <OOBeaconEntity> *beacon = [
self nextBeacon];
5185 if ([
self isInSpace] && the_sun && the_planet
5186 && ![the_sun goneNova])
5193 case COMPASS_MODE_INACTIVE:
5196 case COMPASS_MODE_BASIC:
5199 new_target = the_station;
5203 new_target = the_planet;
5207 case COMPASS_MODE_PLANET:
5208 new_target = the_planet;
5211 case COMPASS_MODE_STATION:
5212 new_target = the_station;
5215 case COMPASS_MODE_SUN:
5216 new_target = the_sun;
5219 case COMPASS_MODE_TARGET:
5220 new_target = the_target;
5223 case COMPASS_MODE_BEACONS:
5224 new_target = beacon;
5228 if (new_target ==
nil || [new_target
status] < STATUS_ACTIVE || [new_target
status] == STATUS_IN_HOLD)
5230 [
self setCompassMode:COMPASS_MODE_PLANET];
5231 new_target = the_planet;
5236 [
self setCompassTarget:new_target];
5237 [
self doScriptEvent:OOJSID("compassTargetChanged") withArguments:[NSArray arrayWithObjects:new_target, OOStringFromCompassMode([
self compassMode]), nil]];
5247 case COMPASS_MODE_INACTIVE:
5249 case COMPASS_MODE_BASIC:
5251 case COMPASS_MODE_BEACONS:
5253 Entity *target = [
self compassTarget];
5260 case COMPASS_MODE_PLANET:
5261 return [[UNIVERSE planet] name];
5262 case COMPASS_MODE_SUN:
5263 return [[UNIVERSE sun] name];
5264 case COMPASS_MODE_STATION:
5265 return [[UNIVERSE station] displayName];
5266 case COMPASS_MODE_TARGET:
5267 return DESC(
@"oolite-beacon-label-target");
5288 Entity <OOBeaconEntity> *beacon =
nil;
5292 case COMPASS_MODE_INACTIVE:
5293 case COMPASS_MODE_BASIC:
5294 case COMPASS_MODE_PLANET:
5295 beacon = [UNIVERSE lastBeacon];
5298 beacon = [beacon prevBeacon];
5300 [
self setNextBeacon:beacon];
5304 [
self setCompassMode:COMPASS_MODE_BEACONS];
5309 case COMPASS_MODE_BEACONS:
5310 beacon = [
self nextBeacon];
5313 beacon = [beacon prevBeacon];
5315 [
self setNextBeacon:beacon];
5321 [
self setCompassMode:COMPASS_MODE_TARGET];
5325 [
self setCompassMode:COMPASS_MODE_SUN];
5331 case COMPASS_MODE_TARGET:
5332 [
self setCompassMode:COMPASS_MODE_SUN];
5335 case COMPASS_MODE_SUN:
5336 aegis = [
self checkForAegis];
5339 [
self setCompassMode:COMPASS_MODE_STATION];
5343 [
self setCompassMode:COMPASS_MODE_PLANET];
5347 case COMPASS_MODE_STATION:
5348 [
self setCompassMode:COMPASS_MODE_PLANET];
5357 Entity <OOBeaconEntity> *beacon =
nil;
5361 case COMPASS_MODE_INACTIVE:
5362 case COMPASS_MODE_BASIC:
5363 case COMPASS_MODE_PLANET:
5364 aegis = [
self checkForAegis];
5367 [
self setCompassMode:COMPASS_MODE_STATION];
5371 [
self setCompassMode:COMPASS_MODE_SUN];
5375 case COMPASS_MODE_STATION:
5376 [
self setCompassMode:COMPASS_MODE_SUN];
5379 case COMPASS_MODE_SUN:
5382 [
self setCompassMode:COMPASS_MODE_TARGET];
5387 case COMPASS_MODE_TARGET:
5388 beacon = [UNIVERSE firstBeacon];
5391 beacon = [beacon nextBeacon];
5393 [
self setNextBeacon:beacon];
5395 if (beacon !=
nil) [
self setCompassMode:COMPASS_MODE_BEACONS];
5396 else [
self setCompassMode:COMPASS_MODE_PLANET];
5399 case COMPASS_MODE_BEACONS:
5400 beacon = [
self nextBeacon];
5403 beacon = [beacon nextBeacon];
5405 [
self setNextBeacon:beacon];
5409 [
self setCompassMode:COMPASS_MODE_PLANET];
5422- (void) setActiveMissile:(NSUInteger)value
5440- (void) setDialIdentEngaged:(BOOL)newValue
5454 Entity *target_entity = [
self primaryTarget];
5455 NSString *result =
nil;
5457 if (target_entity ==
nil)
5459 result =
DESC(
@"no-target-string");
5462 if ([target_entity respondsToSelector:
@selector(identFromShip:)])
5467 if (result ==
nil) result =
DESC(
@"unknown-target");
5479- (NSString *) multiFunctionText:(NSUInteger)i
5481 NSString *key = [multiFunctionDisplaySettings oo_stringAtIndex:i defaultValue:nil];
5486 NSString *text = [multiFunctionDisplayText oo_stringForKey:key defaultValue:nil];
5491- (void) setMultiFunctionText:(NSString *)text forKey:(NSString *)key
5495 [multiFunctionDisplayText setObject:text forKey:key];
5497 else if (key !=
nil)
5499 [multiFunctionDisplayText removeObjectForKey:key];
5504 [multiFunctionDisplaySettings replaceObjectAtIndex:index withObject:[NSNull null]];
5510- (BOOL) setMultiFunctionDisplay:(NSUInteger)index toKey:(NSString *)key
5512 if (index >= [
hud mfdCount])
5515 index = [multiFunctionDisplaySettings indexOfObject:[NSNull null]];
5516 if (index == NSNotFound)
5522 if (index < [
hud mfdCount])
5526 [multiFunctionDisplaySettings replaceObjectAtIndex:index withObject:[NSNull null]];
5530 [multiFunctionDisplaySettings replaceObjectAtIndex:index withObject:key];
5541- (void) cycleNextMultiFunctionDisplay:(NSUInteger) index
5543 if ([[
self hud] mfdCount] == 0)
return;
5544 NSArray *keys = [multiFunctionDisplayText allKeys];
5545 NSString *key =
nil;
5546 if ([keys
count] == 0)
5548 [
self setMultiFunctionDisplay:index toKey:nil];
5551 id current = [multiFunctionDisplaySettings objectAtIndex:index];
5552 if (current == [NSNull
null])
5554 key = [keys objectAtIndex:0];
5555 [
self setMultiFunctionDisplay:index toKey:key];
5559 NSUInteger cIndex = [keys indexOfObject:current];
5560 if (cIndex == NSNotFound || cIndex + 1 >= [keys
count])
5563 [
self setMultiFunctionDisplay:index toKey:nil];
5567 key = [keys objectAtIndex:(cIndex+1)];
5568 [
self setMultiFunctionDisplay:index toKey:key];
5578- (void) cyclePreviousMultiFunctionDisplay:(NSUInteger) index
5580 if ([[
self hud] mfdCount] == 0)
return;
5581 NSArray *keys = [multiFunctionDisplayText allKeys];
5582 NSString *key =
nil;
5583 if ([keys
count] == 0)
5585 [
self setMultiFunctionDisplay:index toKey:nil];
5588 id current = [multiFunctionDisplaySettings objectAtIndex:index];
5589 if (current == [NSNull
null])
5591 key = [keys objectAtIndex:([keys count]-1)];
5592 [
self setMultiFunctionDisplay:index toKey:key];
5596 NSUInteger cIndex = [keys indexOfObject:current];
5597 if (cIndex == NSNotFound || cIndex == 0)
5600 [
self setMultiFunctionDisplay:index toKey:nil];
5604 key = [keys objectAtIndex:(cIndex-1)];
5605 [
self setMultiFunctionDisplay:index toKey:key];
5617 if ([[
self hud] mfdCount] == 0)
return;
5620 [UNIVERSE addMessage:OOExpandKey(@"mfd-N-selected", mfdID) forCount:3.0 ];
5629 if ([[
self hud] mfdCount] == 0)
return;
5632 activeMFD = ([[
self hud] mfdCount] - 1);
5639 [UNIVERSE addMessage:OOExpandKey(@"mfd-N-selected", mfdID) forCount:3.0 ];
5652- (
ShipEntity *) missileForPylon:(NSUInteger)value
5713 [missile_entity[activeMissile] removeTarget:nil];
5717 [
self setActiveMissile:next_missile];
5726 if( [
self hasEquipmentItemProviding:
@"EQ_MULTI_TARGET"] &&
5730 [
self addTarget:[missile_entity[next_missile] primaryTarget]];
5739 if([
self hasEquipmentItemProviding:
@"EQ_MULTI_TARGET"] && !
launchingMissile)
5741 [
self noteLostTarget];
5746 [missile_entity[activeMissile] addTarget:[
self primaryTarget]];
5770- (void) setAlertFlag:(
int)flag to:(BOOL)value
5787 return [
self alertCondition];
5796 [
self setAlertFlag:ALERT_FLAG_DOCKED to:[
self status] == STATUS_DOCKED];
5815 [
self playAlertConditionRed];
5830- (void) interpretAIMessage:(NSString *)ms
5832 if ([ms isEqual:
@"HOLD_FULL"])
5834 [
self playHoldFull];
5835 [UNIVERSE addMessage:DESC(@"hold-full") forCount:4.5];
5838 if ([ms isEqual:
@"INCOMING_MISSILE"])
5842 [
self playIncomingMissile:HPVectorToVector([[
self primaryAggressor] position])];
5846 [
self playIncomingMissile:kZeroVector];
5848 [UNIVERSE addMessage:DESC(@"incoming-missile") forCount:4.5];
5851 if ([ms isEqual:
@"ENERGY_LOW"])
5853 [UNIVERSE addMessage:DESC(@"energy-low") forCount:6.0];
5858 if ([ms isEqual:
@"DOCKING_REFUSED"] && [
self status] == STATUS_AUTOPILOT_ENGAGED)
5860 [
self playDockingDenied];
5861 [UNIVERSE addMessage:DESC(@"autopilot-denied") forCount:4.5];
5863 [
self resetAutopilotAI];
5865 [
self setStatus:STATUS_IN_FLIGHT];
5867 [
self doScriptEvent:OOJSID("playerDockingRefused")];
5873 if ([ms isEqual:
@"AEGIS_CLOSE_TO_MAIN_PLANET"]&&(
compassMode == COMPASS_MODE_PLANET))
5875 [
self playAegisCloseToPlanet];
5876 [
self setCompassMode:COMPASS_MODE_STATION];
5878 if ([ms isEqual:
@"AEGIS_IN_DOCKING_RANGE"]&&(
compassMode == COMPASS_MODE_PLANET))
5880 [
self playAegisCloseToStation];
5881 [
self setCompassMode:COMPASS_MODE_STATION];
5883 if ([ms isEqual:
@"AEGIS_NONE"]&&(
compassMode == COMPASS_MODE_STATION))
5885 [
self setCompassMode:COMPASS_MODE_PLANET];
5893 if (missile ==
nil)
return NO;
5903 if (
missiles == 1) [
self setActiveMissile:0];
5912- (BOOL) mountMissileWithRole:(NSString *)role
5915 return [
self mountMissile:[[UNIVERSE newShipWithRole:role] autorelease]];
5925 if (missile ==
nil)
return nil;
5939 firedMissile = [
self launchMine:missile];
5941 if (firedMissile !=
nil) [
self playMineLaunched:[
self missileLaunchPosition] weaponIdentifier:identifier];
5947 firedMissile = [
self fireMissileWithIdentifier:identifier andTarget:[missile
primaryTarget]];
5949 if (firedMissile !=
nil)
5952 [
self playMissileLaunched:[
self missileLaunchPosition] weaponIdentifier:identifier];
5961 [
self deactivateCloakingDevice];
5967 return firedMissile;
5981 [
self dumpItem: mine];
5984 float mine_speed = 500.0f;
5985 Vector mvel = vector_subtract([mine
velocity], vector_multiply_scalar(
v_forward, mine_speed));
5987 [
self doScriptEvent:OOJSID("shipReleasedEquipment") withArgument:mine];
5992- (BOOL) assignToActivePylon:(NSString *)equipmentKey
5998 if ([equipmentKey hasSuffix:
@"_DAMAGED"])
6013 ShipEntity *amiss = [UNIVERSE newShipWithRole:equipmentKey];
6015 if (!amiss)
return NO;
6018 [missile_entity[activeMissile] release];
6025 [
self selectNextMissile];
6039 [UNIVERSE setCurrentPostFX:OO_POSTFX_CLOAK];
6040 [UNIVERSE addMessage:DESC(@"cloak-on") forCount:2];
6041 [
self playCloakingDeviceOn];
6046 [UNIVERSE addMessage:DESC(@"cloak-low-juice") forCount:3];
6047 [
self playCloakingDeviceInsufficientEnergy];
6057 [
super deactivateCloakingDevice];
6058 [UNIVERSE setCurrentPostFX:[UNIVERSE colorblindMode]];
6059 [UNIVERSE addMessage:DESC(@"cloak-off") forCount:2];
6060 [
self playCloakingDeviceOff];
6126 [
self setWeaponDataFromType:currentWeapon];
6136- (void) setWeaponsOnline:(BOOL)newValue
6145 return [
self laserPortOffset:currentWeaponFacing];
6151 OOWeaponType weapon_to_be_fired = [
self currentWeapon];
6160 [
self playWeaponOverheated:[[
self currentLaserOffset] oo_vectorAtIndex:0]];
6161 [UNIVERSE addMessage:DESC(@"weapon-overheat") forCount:3.0];
6170 [
self currentWeaponStats];
6172 NSUInteger multiplier = 1;
6176 multiplier = [[
self laserPortOffset:currentWeaponFacing] count];
6181 [UNIVERSE addMessage:DESC(@"weapon-out-of-juice") forCount:3.0];
6215 BOOL weaponFired = NO;
6218 if (![weapon_to_be_fired isTurretLaser])
6220 [
self fireLaserShotInDirection:currentWeaponFacing weaponIdentifier:[[
self currentWeapon] identifier]];
6231 [
self deactivateCloakingDevice];
6263 return [
self weaponForFacing:currentWeaponFacing];
6270- (GLfloat) doesHitLine:(HPVector)v0 :(HPVector)v1 :(
ShipEntity **)hitEntity
6274 Vector u0 = HPVectorToVector(HPvector_between(
position, v0));
6275 Vector u1 = HPVectorToVector(HPvector_between(
position, v1));
6276 Vector w0 = make_vector(dot_product(u0,
v_right), dot_product(u0,
v_up), dot_product(u0,
v_forward));
6277 Vector w1 = make_vector(dot_product(u1,
v_right), dot_product(u1,
v_up), dot_product(u1,
v_forward));
6278 GLfloat hit_distance = [octree isHitByLine:w0 :w1];
6282 hitEntity[0] =
self;
6285 bool shields =
false;
6291 NSEnumerator *subEnum =
nil;
6297 u0 = HPVectorToVector(HPvector_between(p0, v0));
6298 u1 = HPVectorToVector(HPvector_between(p0, v1));
6299 w0 = resolveVectorInIJK(u0, ijk);
6300 w1 = resolveVectorInIJK(u1, ijk);
6302 GLfloat hitSub = [se->octree isHitByLine:w0 :w1];
6303 if (hitSub && (hit_distance == 0 || hit_distance > hitSub))
6305 hit_distance = hitSub;
6306 if (hitEntity && !shields)
6313 return hit_distance;
6318- (void) takeEnergyDamage:(
double)amount from:(
Entity *)ent becauseOf:(
Entity *)other weaponIdentifier:(NSString *)weaponIdentifier
6322 BOOL internal_damage = NO;
6324 OOLog(
@"player.ship.damage",
@"Player took damage from %@ becauseOf %@", ent, other);
6326 if ([
self status] == STATUS_DEAD)
return;
6327 if ([
self status] == STATUS_ESCAPE_SEQUENCE)
return;
6328 if (amount == 0.0)
return;
6331 BOOL cascading = NO;
6334 cascading = [
self cascadeIfAppropriateWithDamageAmount:amount cascadeOwner:[ent
owner]];
6340 [[ent retain] autorelease];
6341 [[other retain] autorelease];
6344 rel_pos = HPvector_subtract(rel_pos,
position);
6346 [
self doScriptEvent:OOJSID("shipBeingAttacked") withArgument:ent];
6347 if ([ent
isShip]) [(
ShipEntity *)
ent doScriptEvent:OOJSID("shipAttackedOther") withArgument:self];
6349 d_forward = dot_product(HPVectorToVector(rel_pos),
v_forward);
6350 d_right = dot_product(HPVectorToVector(rel_pos),
v_right);
6351 d_up = dot_product(HPVectorToVector(rel_pos),
v_up);
6352 Vector relative = make_vector(d_right,d_up,d_forward);
6354 [
self playShieldHit:relative weaponIdentifier:weaponIdentifier];
6359 [
self broadcastHitByLaserFrom:(ShipEntity*) other];
6389 OOShipDamageType damageType = cascadeWeapon ? kOODamageTypeCascadeWeapon : kOODamageTypeEnergy;
6394 [
self playDirectHit:relative weaponIdentifier:weaponIdentifier];
6407 [
self noteTakingDamage:amount from:other type:damageType];
6408 if (cascading)
energy = 0.0;
6417 [
self getDestroyedBy:other damageType:damageType];
6421 while (amount > 0.0)
6424 if (internal_damage)
6426 [
self takeInternalDamage];
6434- (void) takeScrapeDamage:(
double) amount from:(
Entity *) ent
6438 BOOL internal_damage = NO;
6440 if ([
self status] == STATUS_DEAD)
return;
6444 OOLog(
@"player.ship.damage",
@"Player took negative scrape damage %.3f so we made it positive", amount);
6447 OOLog(
@"player.ship.damage",
@"Player took %.3f scrape damage from %@", amount, ent);
6449 [[ent retain] autorelease];
6451 rel_pos = HPvector_subtract(rel_pos,
position);
6453 d_forward = dot_product(HPVectorToVector(rel_pos),
v_forward);
6454 d_right = dot_product(HPVectorToVector(rel_pos),
v_right);
6455 d_up = dot_product(HPVectorToVector(rel_pos),
v_up);
6456 Vector relative = make_vector(d_right,d_up,d_forward);
6458 [
self playScrapeDamage:relative];
6486 [
super takeScrapeDamage:amount from:ent];
6488 while (amount > 0.0)
6491 if (internal_damage)
6493 [
self takeInternalDamage];
6500- (void) takeHeatDamage:(
double) amount
6502 if ([
self status] == STATUS_DEAD || amount < 0)
return;
6505 float fwd_amount = (float)(0.5 * amount);
6506 float aft_amount = (float)(0.5 * amount);
6530 double residual_amount = fwd_amount + aft_amount;
6532 [
super takeHeatDamage:residual_amount];
6546 [result
setSpeed:[
self flightSpeed]];
6564 if ([
UNIVERSE displayGUI]) [
self switchToMainView];
6565 [UNIVERSE setViewDirection:VIEW_FORWARD];
6567 if ([
self status] == STATUS_DEAD)
return nil;
6574 [UNIVERSE setBlockJSPlayerShipProps:YES];
6589 doppelganger = [
self createDoppelganger];
6592 [doppelganger
setVelocity:vector_multiply_scalar(v_forward, flightSpeed)];
6595 [doppelganger
setRoll:0.2 * (randf() - 0.5)];
6598 [UNIVERSE addEntity:doppelganger];
6601 [
self setFoundTarget:doppelganger];
6602 [
self setStatus:STATUS_ESCAPE_SEQUENCE];
6607 position = HPvector_subtract(
position, vectorToHPVector(vector_multiply_scalar(
v_up, sheight)));
6612 escapePod = [UNIVERSE newShipWithName:@"escape-capsule"];
6613 if (escapePod !=
nil)
6616 [
self setMesh:[escapePod
mesh]];
6635 Vector launchVector = vector_add([doppelganger
velocity],
6636 vector_add(vector_multiply_scalar(
v_up, 15.0f),
6637 vector_multiply_scalar(
v_forward, -90.0f)));
6638 [
self setVelocity:launchVector];
6643 [
self removeEquipmentItem:[
self equipmentItemProviding:@"EQ_ESCAPE_POD"]];
6649 [
self setDockTarget:[UNIVERSE station]];
6651 [
self doScriptEvent:OOJSID("shipLaunchedEscapePod") withArgument:escapePod];
6654 [
self setBounty:0 withReason:kOOLegalStatusReasonEscapePod];
6660 [
self clearRolesFromPlayer:0.1];
6664 [
self clearRolesFromPlayer:0.25];
6668 [
self clearRolesFromPlayer:0.5];
6675 [cargo removeAllObjects];
6678 [UNIVERSE addMessage:DESC(@"escape-sequence") forCount:4.5];
6679 [
self resetShotTime];
6688 [escapePod release];
6690 return doppelganger;
6698 [UNIVERSE addMessage:OOExpandKey(@"hold-locked") forCount:3.0];
6705 NSString *commodity = [UNIVERSE displayNameForCommodity:result];
6706 [UNIVERSE addMessage:OOExpandKey(@"commodity-ejected", commodity) forCount:3.0 forceDisplay:YES];
6707 [
self playCargoJettisioned];
6715 NSInteger i, n_cargo = [cargo count];
6716 if (n_cargo == 0)
return;
6721 NSInteger rotates = 0;
6725 [cargo removeObjectAtIndex:0];
6726 [cargo addObject:pod];
6731 }
while ([contents isEqualToString:current_contents]&&(rotates < n_cargo));
6734 NSString *commodity = [UNIVERSE displayNameForCommodity:contents];
6735 [UNIVERSE addMessage:OOExpandKey(@"ready-to-eject-commodity", commodity) forCount:3.0];
6739 for (i = 1; i < (n_cargo - rotates); i++)
6741 pod = [cargo objectAtIndex:i];
6745 [cargo removeObjectAtIndex:i--];
6746 [cargo addObject:pod];
6756 [
self setBounty:amount withReason:kOOLegalStatusReasonUnknown];
6763 [
self setBounty:amount withReasonAsString:nReason];
6767- (void) setBounty:(
OOCreditsQuantity)amount withReasonAsString:(NSString *)reason
6771 jsval amountVal = JSVAL_VOID;
6773 JS_NewNumberValue(context, amountVal2, &amountVal);
6779 ShipScriptEvent(context,
self,
"shipBountyChanged", amountVal, reasonVal);
6797- (void) markAsOffender:(
int)offence_value
6799 [
self markAsOffender:offence_value withReason:kOOLegalStatusReasonUnknown];
6809 jsval amountVal = JSVAL_VOID;
6811 JS_NewNumberValue(context, amountVal2, &amountVal);
6817 ShipScriptEvent(context,
self,
"shipBountyChanged", amountVal, reasonVal);
6827 if ([
self status] == STATUS_DEAD)
return;
6851 [
self markAsOffender:64 withReason:kOOLegalStatusReasonAttackedPolice];
6854 BOOL killIsCargo = ((killClass == CLASS_CARGO) && ([other
commodityAmount] > 0) && ![other
isHulk]);
6855 if ((killIsCargo) || (killClass == CLASS_BUOY) || (killClass == CLASS_ROCK))
6858 if (![other hasRole:
@"tharglet"])
6870 [UNIVERSE addDelayedMessage:bonusMessage forCount:6 afterDelay:0.15];
6879 [UNIVERSE addDelayedMessage:DESC(@"right-on-commander") forCount:4 afterDelay:0.2];
6887 unsigned n_cargo = [
self maxAvailableCargoSpace];
6888 unsigned n_mass = [
self mass] / 10000;
6890 unsigned damage_to = n_considered ? (
ranrot_rand() % n_considered) : 0;
6896 NSString* cargo_desc = [UNIVERSE displayNameForCommodity:[pod
commodityType]];
6899 [UNIVERSE clearPreviousMessage];
6900 [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"@-destroyed"), cargo_desc] forCount:4.5];
6901 [cargo removeObject:pod];
6906 damage_to = n_considered - (damage_to + 1);
6909 NSEnumerator *eqEnum = [
self equipmentEnumerator];
6911 NSString *system_key;
6912 unsigned damageableCounter = 0;
6913 GLfloat damageableOdds = 0.0;
6914 while ((system_key = [eqEnum nextObject]) !=
nil)
6917 if ([eqType canBeDamaged])
6919 damageableCounter++;
6920 damageableOdds += [eqType damageProbability];
6924 if (damage_to < damageableCounter)
6926 GLfloat target =
randf() * damageableOdds;
6927 GLfloat accumulator = 0.0;
6928 eqEnum = [
self equipmentEnumerator];
6929 while ((system_key = [eqEnum nextObject]) !=
nil)
6932 accumulator += [eqType damageProbability];
6933 if (accumulator > target)
6935 [system_key retain];
6939 if (system_key ==
nil)
6941 [system_key release];
6945 NSString *system_name = [eqType
name];
6946 if (![eqType canBeDamaged] || system_name ==
nil)
6948 [system_key release];
6953 [
self setScriptTarget:self];
6954 [UNIVERSE clearPreviousMessage];
6955 [
self removeEquipmentItem:system_key];
6957 NSString *damagedKey = [NSString stringWithFormat:@"%@_DAMAGED", system_key];
6958 [
self addEquipmentItem:damagedKey withValidation: NO inContext:@"damage"];
6959 [
self doScriptEvent:OOJSID("equipmentDamaged") withArgument:system_key];
6961 if (![
self hasEquipmentItem:system_name] && [
self hasEquipmentItem:damagedKey])
6969 [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"@-damaged"), system_name] forCount:4.5];
6975 [system_key release];
6994 if (![[
UNIVERSE gameController] playerFileToLoad])
6996 [[UNIVERSE gameController] setPlayerFileToLoad: save_path];
7001 [
self disengageAutopilot];
7003 [UNIVERSE setDisplayText:NO];
7004 [UNIVERSE setViewDirection:VIEW_AFT];
7007 [
self noteKilledBy:whom damageType:type];
7009 [
self becomeLargeExplosion:4.0];
7010 [
self moveForward:100.0];
7017 [[UNIVERSE messageGUI] clear];
7018 [
self suppressTargetLost];
7019 [
self playGameOver];
7020 [UNIVERSE setBlockJSPlayerShipProps:YES];
7021 [
self removeAllEquipment];
7022 [
self loseTargetStatus];
7023 [
self showGameOver];
7031 int ent_count =
UNIVERSE->n_entities;
7033 Entity* my_entities[ent_count];
7035 for (i = 0; i < ent_count; i++)
7036 my_entities[i] = [uni_entities[i] retain];
7037 for (i = 0; i < ent_count ; i++)
7039 Entity* thing = my_entities[i];
7042 ShipEntity* ship = (ShipEntity *)thing;
7043 if (self == [ship primaryTarget])
7045 [ship noteLostTarget];
7049 for (i = 0; i < ent_count; i++)
7051 [my_entities[i] release];
7056- (BOOL) endScenario:(NSString *)key
7060 [
self setStatus:STATUS_RESTART_GAME];
7069 NSParameterAssert(station !=
nil);
7070 if ([
self status] == STATUS_DEAD)
return;
7072 [
self setStatus:STATUS_DOCKING];
7073 [
self setDockedStation:station];
7074 [
self doScriptEvent:OOJSID("shipWillDockWithStation") withArgument:station];
7076 if (![
hud nonlinearScanner])
7078 [hud setScannerZoom: 1.0];
7083 [
self resetAutopilotAI];
7088 [
self safeAllMissiles];
7090 [
self clearTargetMemory];
7093 [UNIVERSE setDisplayText:NO];
7094 [[UNIVERSE gameController] setMouseInteractionModeForFlight];
7095 if ([
self status] == STATUS_LAUNCHING)
return;
7097 [
self setOrientation: kIdentityQuaternion];
7098 [UNIVERSE setUpBreakPattern:[
self breakPatternPosition] orientation:orientation forDocking:YES];
7099 [
self playDockWithStation];
7102 [[UNIVERSE gameView] clearKeys];
7111 [
self setStatus:STATUS_IN_FLIGHT];
7115 [
self setStatus:STATUS_DOCKED];
7116 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
7118 [
self loseTargetStatus];
7120 [
self setPosition:[dockedStation
position]];
7121 [
self setOrientation:kIdentityQuaternion];
7137 [
self setAlertFlag:ALERT_FLAG_DOCKED to:YES];
7144 NSString *escapepodReport = [
self processEscapePods];
7145 [
self addMessageToReport:escapepodReport];
7147 [
self unloadCargoPods];
7154 [
self markAsOffender:[dockedStation
legalStatusOfManifest:shipCommodityData
export:NO] withReason:kOOLegalStatusReasonIllegalImports];
7155 if ([
self bounty] > oldbounty)
7157 [
self addRoleToPlayer:@"trader-smuggler"];
7162 NSString *passengerAndCargoReport = [
self checkPassengerContracts];
7163 [
self addMessageToReport:passengerAndCargoReport];
7165 [UNIVERSE setDisplayText:YES];
7175 [
self penaltyForUnauthorizedDocking];
7187 if (
gui_screen != GUI_SCREEN_MISSION) [
self checkScript];
7190 [
self doScriptEvent:OOJSID("shipDockedWithStation") withArgument:dockedStation];
7192 if ([
self status] == STATUS_LAUNCHING)
return;
7197 [
self setGuiToStatusScreen];
7203 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenOpportunity")];
7209 if (station ==
nil)
return;
7213 [[UNIVERSE gameView] allowStringInput: NO];
7217 [[UNIVERSE gui] clearBackground];
7220 [
self doMissionCallback];
7223 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenEnded")];
7226 if ([station marketMonitored])
7231 if ([
self bounty] > oldbounty)
7233 [
self addRoleToPlayer:@"trader-smuggler"];
7238 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
7240 if (![
hud nonlinearScanner])
7242 [hud setScannerZoom: 1.0];
7244 [
self loadCargoPods];
7254 [
self clearAlertFlags];
7255 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
7259 [
self currentWeaponStats];
7269 [
self clearTargetMemory];
7270 [
self setShowDemoShips:NO];
7271 [UNIVERSE setDisplayText:NO];
7272 [[UNIVERSE gameController] setMouseInteractionModeForFlight];
7274 [[UNIVERSE gameView] clearKeys];
7278 [[UNIVERSE gameView] resetMouse];
7283 [UNIVERSE forceWitchspaceEntries];
7291 [UNIVERSE setUpBreakPattern:[
self breakPatternPosition] orientation:orientation forDocking:YES];
7293 [
self setDockedStation:nil];
7296 [
self checkForAegis];
7300 [UNIVERSE removeDemoShips];
7305 [
self playLaunchFromStation];
7315 if (![
hud nonlinearScanner])
7317 [hud setScannerZoom: 1.0];
7319 [
self safeAllMissiles];
7321 OOViewID previousViewDirection = [UNIVERSE viewDirection];
7322 [UNIVERSE setViewDirection:VIEW_FORWARD];
7323 [
self noteSwitchToView:VIEW_FORWARD fromView:previousViewDirection];
7326 [
self currentWeaponStats];
7328 [
self transitionToAegisNone];
7334 [
self noteLostTarget];
7339 [UNIVERSE setDisplayText:NO];
7345 [UNIVERSE allShipsDoScriptEvent:OOJSID("playerWillEnterWitchspace") andReactToAIMessage:@"PLAYER WITCHSPACE"];
7356 [UNIVERSE setSystemTo:system_id];
7357 galaxy_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:system_id inGalaxy:galaxy_number];
7359 [UNIVERSE setUpUniverseFromWitchspace];
7360 [[UNIVERSE planet] update: 2.34375 * market_rnd];
7361 [[UNIVERSE station] update: 2.34375 * market_rnd];
7368- (BOOL) witchJumpChecklist:(BOOL)isGalacticJump
7371 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
7375 ShipEntity* blocker = [UNIVERSE entityForUniversalID:[
self checkShipsInVicinityForWitchJumpExit]];
7378 [UNIVERSE clearPreviousMessage];
7379 NSString *blockerName = [blocker
name];
7380 [UNIVERSE addMessage:OOExpandKey(@"witch-blocked", blockerName) forCount:4.5];
7381 [
self playWitchjumpBlocked];
7382 [
self setStatus:STATUS_IN_FLIGHT];
7399 [UNIVERSE clearPreviousMessage];
7400 [UNIVERSE addMessage:OOExpandKey(@"witch-no-target") forCount: 4.5];
7401 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
7403 [
self playWitchjumpInsufficientFuel];
7404 [
self setStatus:STATUS_IN_FLIGHT];
7407 else [
self playHyperspaceNoTarget];
7415 [UNIVERSE clearPreviousMessage];
7416 [UNIVERSE addMessage:DESC(@"witch-too-far") forCount: 4.5];
7417 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
7419 [
self playWitchjumpDistanceTooGreat];
7420 [
self setStatus:STATUS_IN_FLIGHT];
7423 else [
self playHyperspaceDistanceTooGreat];
7431 [UNIVERSE clearPreviousMessage];
7432 [UNIVERSE addMessage:DESC(@"witch-no-fuel") forCount: 4.5];
7433 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
7435 [
self playWitchjumpInsufficientFuel];
7436 [
self setStatus:STATUS_IN_FLIGHT];
7439 else [
self playHyperspaceNoFuel];
7448- (void) setJumpType:(BOOL)isGalacticJump
7477 return fuel >= [
self fuelRequiredForJump];
7483 if ([[
self hud] isCompassActive])
7488 ShipScriptEvent(context,
self,
"compassTargetChanged", JSVAL_VOID, jsmode);
7491 [[
self hud] setCompassActive:NO];
7498 if (![
self witchJumpChecklist:
true])
7509 [
self setStatus:STATUS_ENTERING_WITCHSPACE];
7511 [
self setJumpCause:@"galactic jump"];
7512 [
self setPreviousSystemID:[
self currentSystemID]];
7513 ShipScriptEvent(context,
self,
"shipWillEnterWitchspace", STRING_TO_JSVAL(JS_InternString(context, [[
self jumpCause] UTF8String])), INT_TO_JSVAL(destGalaxy));
7516 [
self noteCompassLostTarget];
7520 [UNIVERSE removeAllEntitiesExceptPlayer];
7524 [contracts removeAllObjects];
7527 [parcels removeAllObjects];
7531 [missionDestinations removeAllObjects];
7537 for (i = 0; i < [passengers count]; i++)
7540 NSMutableDictionary* passenger_info = [NSMutableDictionary dictionaryWithDictionary:[passengers oo_dictionaryAtIndex:i]];
7541 [passenger_info setObject:[NSNumber numberWithDouble:ship_clock] forKey:CONTRACT_KEY_ARRIVAL_TIME];
7542 [passengers replaceObjectAtIndex:i withObject:passenger_info];
7549 [
self clearRolesFromPlayer:0.25];
7553 [
self clearRolesFromPlayer:0.5];
7557 [
self clearRolesFromPlayer:0.9];
7559 [roleWeightFlags removeAllObjects];
7560 [roleSystemList removeAllObjects];
7563 [
self removeEquipmentItem:[
self equipmentItemProviding:@"EQ_GAL_DRIVE"]];
7567 [UNIVERSE setGalaxyTo:galaxy_number];
7576 case GALACTIC_HYPERSPACE_BEHAVIOUR_FIXED_COORDINATES:
7577 system_id = [UNIVERSE findSystemNumberAtCoords:galacticHyperspaceFixedCoords withGalaxy:galaxy_number includingHidden:YES];
7579 case GALACTIC_HYPERSPACE_BEHAVIOUR_ALL_SYSTEMS_REACHABLE:
7580 system_id = [UNIVERSE findSystemNumberAtCoords:galaxy_coordinates withGalaxy:galaxy_number includingHidden:YES];
7582 case GALACTIC_HYPERSPACE_BEHAVIOUR_STANDARD:
7585 system_id = [UNIVERSE findConnectedSystemAtCoords:galaxy_coordinates withGalaxy:galaxy_number];
7591 [
self setBounty:0 withReason:kOOLegalStatusReasonNewGalaxy];
7602 if ([
self status] == STATUS_ENTERING_WITCHSPACE
7603 || [
self status] == STATUS_EXITING_WITCHSPACE)
7609 [
self addScannedWormhole:wormhole];
7610 [
self setStatus:STATUS_ENTERING_WITCHSPACE];
7612 [
self setJumpCause:@"wormhole"];
7613 [
self setPreviousSystemID:[
self currentSystemID]];
7620#ifdef OO_DUMP_PLANETINFO
7627 [
self witchJumpTo:[w_hole
destination] misjump:misjump];
7633 if (![
self witchJumpChecklist:
false])
return;
7635 OOSystemID jumpTarget = [
self nextHopTargetSystemID];
7638 unsigned malfunc_chance = 253;
7645 malfunc_chance = 256;
7648#ifdef OO_DUMP_PLANETINFO
7651 BOOL malfunc = ((
ranrot_rand() & 0xff) > malfunc_chance);
7655 if (malfunc && !misjump)
7660 [
self playWitchjumpFailure];
7661 [
self setStatus:STATUS_IN_FLIGHT];
7667 [
self setFuelLeak:[NSString stringWithFormat:@"%f", (randf() + randf()) * 5.0]];
7679 [UNIVERSE addEntity:wormhole];
7680 [
self addScannedWormhole:wormhole];
7682 [
self setStatus:STATUS_ENTERING_WITCHSPACE];
7684 [
self setJumpCause:@"standard jump"];
7685 [
self setPreviousSystemID:[
self currentSystemID]];
7686 ShipScriptEvent(context,
self,
"shipWillEnterWitchspace", STRING_TO_JSVAL(JS_InternString(context, [[
self jumpCause] UTF8String])), INT_TO_JSVAL(jumpTarget));
7689 [
self updateSystemMemory];
7690 NSUInteger legality = [
self legalStatusOfCargoList];
7695 if (maxSpace != availSpace)
7697 [
self addRoleToPlayer:@"trader"];
7698 if (maxSpace - availSpace > 20 || availSpace == 0)
7702 [
self addRoleToPlayer:@"trader"];
7709 if (maxSpace != availSpace && legality > 0)
7711 [
self addRoleToPlayer:@"trader-smuggler"];
7712 if (maxSpace - availSpace > 20 || availSpace == 0)
7714 if (legality >= 20 || legality >= maxSpace)
7716 [
self addRoleToPlayer:@"trader-smuggler"];
7721 [roleWeightFlags removeAllObjects];
7723 [
self noteCompassLostTarget];
7730 [wormhole setMisjumpWithRange:[
self scriptedMisjumpRange]];
7732 [
self witchJumpTo:jumpTarget misjump:misjump];
7736- (void) witchJumpTo:(
OOSystemID)sTo misjump:(BOOL)misjump
7741 [
self setInfoSystemID: sTo moveChart: YES];
7747 [
self adjustTradeInFactorBy:-(1 + (market_rnd & 3))];
7756 if (theSun && [theSun goneNova])
7761 [UNIVERSE removeAllEntitiesExceptPlayer];
7765 [
self setSystemID:sTo];
7766 [
self setBounty:(legalStatus/2) withReason:kOOLegalStatusReasonNewSystem];
7774 if (
randf() < 0.1) [
self erodeReputation];
7776 [wormhole setMisjump];
7781 NSPoint dest = [wormhole destinationCoordinates];
7787 [
self playWitchjumpMisjump];
7788 [UNIVERSE setUpUniverseFromMisjump];
7796 HPVector pos = [UNIVERSE getWitchspaceExitPosition];
7798 HPVector whpos, exitpos;
7800 double min_d1 = [UNIVERSE safeWitchspaceExitDistance];
7802 if (abs((
int)d1) < min_d1)
7804 d1 += ((d1 > 0.0)? min_d1: -min_d1);
7807 exitpos = HPvector_add(pos, HPvector_multiply_scalar(v1, d1));
7809 [
self setOrientation:[UNIVERSE getWitchspaceExitRotation]];
7820 double wh_arrival_time = ([PLAYER clockTimeAdjusted] - [
wormhole arrivalTime]);
7821 if (wh_arrival_time > 0)
7824 whpos = HPvector_add(exitpos, vectorToHPVector(vector_multiply_scalar([
self forwardVector], 1000.0f)));
7825 [wormhole setContainsPlayer:YES];
7830 whpos = HPvector_add(exitpos, vectorToHPVector(vector_multiply_scalar([
self forwardVector], -500.0f)));
7832 [wormhole setExitSpeed:maxFlightSpeed*WORMHOLE_LEADER_SPEED_FACTOR];
7835 HPVector distance = HPvector_subtract(whpos, pos);
7836 if (HPmagnitude2(distance) < min_d1*min_d1 )
7840 distance = HPvector_multiply_scalar(HPvector_normal(distance), min_d1);
7841 whpos = HPvector_add(whpos, distance);
7844 [wormhole setExitPosition: whpos];
7849 [wormhole setExitSpeed:maxFlightSpeed*WORMHOLE_LEADER_SPEED_FACTOR];
7865 [
self setStatus:STATUS_EXITING_WITCHSPACE];
7868 [
self clearTargetMemory];
7869 [
self setShowDemoShips:NO];
7870 [[UNIVERSE gameController] setMouseInteractionModeForFlight];
7871 [UNIVERSE setDisplayText:NO];
7872 [UNIVERSE setWitchspaceBreakPattern:YES];
7873 [
self playExitWitchspace];
7879 [
self clearRoleFromPlayer:NO];
7885 [
self doScriptEvent:OOJSID("playerEnteredNewGalaxy") withArgument:[NSNumber numberWithUnsignedInt:galaxy_number]];
7888 [
self doScriptEvent:OOJSID("shipWillExitWitchspace") withArgument:[
self jumpCause]];
7889 [UNIVERSE setUpBreakPattern:[
self breakPatternPosition] orientation:orientation forDocking:NO];
7897 NSString *systemName =
nil;
7898 NSString *targetSystemName =
nil;
7899 NSString *text =
nil;
7903 if (oldScreen != GUI_SCREEN_STATUS)
7905 [
self noteGUIWillChangeTo:GUI_SCREEN_STATUS];
7911 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
7915 systemName = [UNIVERSE inInterstellarSpace] ?
DESC(
@"interstellar-space") : [
UNIVERSE getSystemName:
system_id];
7918 systemName = [NSString stringWithFormat:@"%@ : %@", systemName, [[
self dockedStation] displayName]];
7921 targetSystemName = [UNIVERSE getSystemName:target_system_id];
7922 NSDictionary *systemInfo = [[UNIVERSE systemManager] getPropertiesForSystem:target_system_id inGalaxy:galaxy_number];
7923 NSInteger concealment = [systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
7926 OOSystemID nextHop = [
self nextHopTargetSystemID];
7928 NSString *nextHopSystemName = [UNIVERSE getSystemName:nextHop];
7929 systemInfo = [[UNIVERSE systemManager] getPropertiesForSystem:nextHop inGalaxy:galaxy_number];
7930 concealment = [systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
7932 targetSystemName =
OOExpandKey(
@"status-hyperspace-system-multi", targetSystemName, nextHopSystemName);
7937 NSString *shipName = [
self displayName];
7938 NSString *legal_desc =
nil, *rating_desc =
nil,
7939 *alert_desc =
nil, *fuel_desc =
nil,
7940 *credits_desc =
nil;
7950 NSString *lightYearsDesc =
DESC(
@"status-light-years-desc");
7955 fuel_desc = [NSString stringWithFormat:@"%.1f %@", fuel/10.0, lightYearsDesc];
7959 text =
DESC(
@"status-commander-@");
7960 [gui
setTitle:[NSString stringWithFormat:text, [
self commanderName]]];
7964 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-present-system"), systemName, nil]
forRow:1];
7966 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-condition"), alert_desc, nil]
forRow:3];
7967 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-fuel"), fuel_desc, nil]
forRow:4];
7968 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-cash"), credits_desc, nil]
forRow:5];
7969 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-legal-status"), legal_desc, nil]
forRow:6];
7970 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-rating"), rating_desc, nil]
forRow:7];
7974 for (i = 1 ; i <= 7 ; ++i)
7990 [lastTextKey release];
7994 [[UNIVERSE gameView] clearMouse];
7997 if (
EXPECT_NOT([[NSUserDefaults standardUserDefaults] boolForKey:
@"show-ship-model-in-status-screen"]))
7999 [UNIVERSE removeDemoShips];
8000 [
self showShipModelWithKey:[
self shipDataKey] shipData:nil personality:[
self entityPersonalityInt]
8001 factorX:2.5 factorY:1.7 factorZ:8.0 inContext:@"GUI_SCREEN_STATUS"];
8002 [
self setShowDemoShips:YES];
8006 [
self setShowDemoShips:NO];
8009 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
8013 NSDictionary *fgDescriptor =
nil, *bgDescriptor =
nil;
8014 if ([
self status] == STATUS_DOCKED)
8016 fgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"docked_overlay"];
8017 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"status_docked"];
8021 fgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"overlay"];
8023 else bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"status_in_flight"];
8028 if (bgDescriptor ==
nil) bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"status"];
8032 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
8040 NSMutableArray *quip1 = [NSMutableArray array];
8041 NSMutableArray *quip2 = [NSMutableArray array];
8042 NSEnumerator *eqTypeEnum =
nil;
8044 NSString *desc =
nil;
8045 NSString *alldesc =
nil;
8047 BOOL prioritiseDamaged = [[gui
userSettings] oo_boolForKey:kGuiStatusPrioritiseDamaged defaultValue:YES];
8049 for (eqTypeEnum = [
OOEquipmentType reverseEquipmentEnumerator]; (eqType = [eqTypeEnum nextObject]); )
8053 if ([eqType canCarryMultiple] && ![eqType isMissileOrMine])
8055 NSString *damagedIdentifier = [[eqType
identifier] stringByAppendingString:@"_DAMAGED"];
8056 NSUInteger
count = 0, okcount = 0;
8057 okcount = [
self countEquipmentItem:[eqType
identifier]];
8058 count = okcount + [
self countEquipmentItem:damagedIdentifier];
8064 else if (
count == okcount)
8069 [quip2 addObject:[NSArray arrayWithObjects:[eqType
name], [NSNumber numberWithBool:YES], [eqType
displayColor], nil]];
8074 NSString *equipmentName = [eqType
name];
8076 [quip2 addObject:[NSArray arrayWithObjects:alldesc, [NSNumber numberWithBool:YES], [eqType
displayColor], nil]];
8080 else if (
count == 1 && okcount == 0)
8082 desc = [NSString stringWithFormat:DESC(@"equipment-@-not-available"), [eqType
name]];
8083 if (prioritiseDamaged)
8085 [quip1 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8089 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8095 NSString *equipmentName = [eqType
name];
8096 alldesc =
OOExpandKey(
@"equipment-plural-some-na", okcount,
count, equipmentName);
8097 if (prioritiseDamaged)
8099 [quip1 addObject:[NSArray arrayWithObjects:alldesc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8103 [quip2 addObject:[NSArray arrayWithObjects:alldesc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8107 else if ([
self hasEquipmentItem:[eqType identifier]])
8109 [quip2 addObject:[NSArray arrayWithObjects:[eqType
name], [NSNumber numberWithBool:YES], [eqType
displayColor], nil]];
8114 if ([
self hasEquipmentItem:[[eqType identifier] stringByAppendingString:
@"_DAMAGED"]])
8116 desc = [NSString stringWithFormat:DESC(@"equipment-@-not-available"), [eqType
name]];
8118 if (prioritiseDamaged)
8120 [quip1 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8125 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8134 desc = [NSString stringWithFormat:DESC_PLURAL(@"equipment-pass-berth-@", max_passengers), max_passengers];
8140 desc = [NSString stringWithFormat:DESC(@"equipment-fwd-weapon-@"),[forward_weapon_type name]];
8141 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], [forward_weapon_type displayColor], nil]];
8145 desc = [NSString stringWithFormat:DESC(@"equipment-aft-weapon-@"),[aft_weapon_type name]];
8146 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], [aft_weapon_type displayColor], nil]];
8150 desc = [NSString stringWithFormat:DESC(@"equipment-port-weapon-@"),[port_weapon_type name]];
8151 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], [port_weapon_type displayColor], nil]];
8155 desc = [NSString stringWithFormat:DESC(@"equipment-stb-weapon-@"),[starboard_weapon_type name]];
8156 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], [starboard_weapon_type displayColor], nil]];
8160 [quip1 addObjectsFromArray:quip2];
8167 return [eqScripts count];
8171- (NSString *) primedEquipmentName:(NSInteger)offset
8173 NSUInteger c = [
self primedEquipmentCount];
8177 return DESC(
@"equipment-primed-none-hud-label");
8188 NSString *result =
@"";
8189 NSUInteger c = [eqScripts count];
8192 result = [[eqScripts oo_arrayAtIndex:primedEquipment] oo_stringAtIndex:0];
8198- (BOOL) setPrimedEquipment:(NSString *)eqKey showMessage:(BOOL)showMsg
8200 NSUInteger c = [eqScripts count];
8203 BOOL unprimeEq = [eqKey isEqualToString:@""];
8216 [UNIVERSE addMessage:unprimeEq ? OOExpandKey(@"equipment-primed-none") : OOExpandKey(@"equipment-primed", equipmentName) forCount:2.0];
8228 OOJSScript *eqScript = [[eqScripts oo_arrayAtIndex:index] objectAtIndex:1];
8259- (void) setFastEquipmentA:(NSString *)eqKey
8261 [_fastEquipmentA release];
8266- (void) setFastEquipmentB:(NSString *)eqKey
8268 [_fastEquipmentB release];
8305 [
self tidyMissilePylons];
8306 return [
super missilesList];
8312 NSMutableArray *manifest = [NSMutableArray array];
8313 NSArray *list = [
self cargoListForScripting];
8314 NSEnumerator *cargoEnum =
nil;
8315 NSDictionary *commodity;
8319 for (cargoEnum = [list objectEnumerator]; (commodity = [cargoEnum nextObject]); )
8321 NSInteger quantity = [commodity oo_integerForKey:@"quantity"];
8322 NSString *units = [commodity oo_stringForKey:@"unit"];
8323 NSString *commodityName = [commodity oo_stringForKey:@"displayName"];
8324 NSInteger containers = [commodity oo_intForKey:@"containers"];
8325 BOOL extended = ![units isEqualToString:DESC(@"cargo-tons-symbol")] && containers > 0;
8328 [manifest addObject:OOExpandKey(@"manifest-cargo-quantity-extended", quantity, units, commodityName, containers)];
8330 [manifest addObject:OOExpandKey(@"manifest-cargo-quantity", quantity, units, commodityName)];
8340 NSMutableArray *list = [NSMutableArray array];
8342 NSUInteger i, j, commodityCount = [shipCommodityData count];
8345 NSArray *goods = [shipCommodityData goods];
8348 for (i = 0; i < commodityCount; i++)
8350 quantityInHold[i] = [shipCommodityData quantityForGood:[goods oo_stringAtIndex:i]];
8351 containersInHold[i] = 0;
8353 for (i = 0; i < [cargo count]; i++)
8355 ShipEntity *container = [cargo objectAtIndex:i];
8358 ++containersInHold[j];
8361 for (i = 0; i < commodityCount; i++)
8363 if (quantityInHold[i] > 0)
8365 NSMutableDictionary *commodity = [NSMutableDictionary dictionaryWithCapacity:4];
8366 NSString *symName = [goods oo_stringAtIndex:i];
8368 [commodity setObject:symName forKey:@"commodity"];
8369 [commodity setObject:[NSNumber numberWithUnsignedInt:quantityInHold[i]] forKey:@"quantity"];
8370 [commodity setObject:[NSNumber numberWithUnsignedInt:containersInHold[i]] forKey:@"containers"];
8371 [commodity setObject:[shipCommodityData nameForGood:symName] forKey:@"displayName"];
8372 [commodity setObject:DisplayStringForMassUnitForCommodity(symName) forKey:@"unit"];
8373 [list addObject:commodity];
8377 return [[list copy] autorelease];
8384 NSString *good =
nil;
8386 unsigned penalty = 0;
8390 amount = [shipCommodityData quantityForGood:good];
8397- (NSArray*) contractsListForScriptingFromArray:(NSArray *) contracts_array forCargo:(BOOL)forCargo
8399 NSMutableArray *result = [NSMutableArray array];
8402 for (i = 0; i < [contracts_array count]; i++)
8404 NSMutableDictionary *contract = [NSMutableDictionary dictionaryWithCapacity:10];
8405 NSDictionary *dict = [contracts_array oo_dictionaryAtIndex:i];
8409 [contract setObject:[dict oo_stringForKey:CARGO_KEY_TYPE] forKey:@"commodity"];
8410 [contract setObject:[NSNumber numberWithUnsignedInt:[dict oo_intForKey:CARGO_KEY_AMOUNT]] forKey:@"quantity"];
8411 [contract setObject:[dict oo_stringForKey:CARGO_KEY_DESCRIPTION] forKey:@"description"];
8415 [contract setObject:[dict oo_stringForKey:PASSENGER_KEY_NAME] forKey:PASSENGER_KEY_NAME];
8416 [contract setObject:[NSNumber numberWithUnsignedInt:[dict oo_unsignedIntForKey:CONTRACT_KEY_RISK]] forKey:CONTRACT_KEY_RISK];
8419 OOSystemID planet = [dict oo_intForKey:CONTRACT_KEY_DESTINATION];
8420 NSString *planetName = [UNIVERSE getSystemName:planet];
8421 [contract setObject:[NSNumber numberWithUnsignedInt:planet] forKey:CONTRACT_KEY_DESTINATION];
8422 [contract setObject:planetName forKey:@"destinationName"];
8423 planet = [dict oo_intForKey:CONTRACT_KEY_START];
8424 planetName = [UNIVERSE getSystemName: planet];
8425 [contract setObject:[NSNumber numberWithUnsignedInt:planet] forKey:CONTRACT_KEY_START];
8426 [contract setObject:planetName forKey:@"startName"];
8428 int dest_eta = [dict oo_doubleForKey:CONTRACT_KEY_ARRIVAL_TIME] -
ship_clock;
8429 [contract setObject:[NSNumber numberWithInt:dest_eta] forKey:@"eta"];
8430 [contract setObject:[UNIVERSE shortTimeDescription:dest_eta] forKey:@"etaDescription"];
8431 [contract setObject:[NSNumber numberWithInt:[dict oo_intForKey:CONTRACT_KEY_PREMIUM]] forKey:CONTRACT_KEY_PREMIUM];
8432 [contract setObject:[NSNumber numberWithInt:[dict oo_intForKey:CONTRACT_KEY_FEE]] forKey:CONTRACT_KEY_FEE];
8433 [result addObject:contract];
8436 return [[result copy] autorelease];
8442 return [
self contractsListForScriptingFromArray:passengers forCargo:NO];
8448 return [
self contractsListForScriptingFromArray:parcels forCargo:NO];
8454 return [
self contractsListForScriptingFromArray:contracts forCargo:YES];
8459 [
self setGuiToSystemDataScreenRefreshBackground: NO];
8462- (void) setGuiToSystemDataScreenRefreshBackground: (BOOL) refreshBackground
8464 NSDictionary *infoSystemData;
8465 NSString *infoSystemName;
8467 infoSystemData = [[UNIVERSE generateSystemData:info_system_id] retain];
8468 NSInteger concealment = [infoSystemData oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
8469 infoSystemName = [infoSystemData oo_stringForKey:KEY_NAME];
8471 BOOL sunGoneNova = ([infoSystemData oo_boolForKey:@"sun_gone_nova"]);
8478 Random_Seed infoSystemRandomSeed = [[UNIVERSE systemManager] getRandomSeedForSystem:info_system_id
8479 inGalaxy:[
self galaxyNumber]];
8481 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
8492 NSUInteger techLevel = [infoSystemData oo_intForKey:KEY_TECHLEVEL] + 1;
8493 int population = [infoSystemData oo_intForKey:KEY_POPULATION];
8494 int productivity = [infoSystemData oo_intForKey:KEY_PRODUCTIVITY];
8495 int radius = [infoSystemData oo_intForKey:KEY_RADIUS];
8497 NSString *government_desc = [infoSystemData oo_stringForKey:KEY_GOVERNMENT_DESC
8498 defaultValue:OODisplayStringFromGovernmentID([infoSystemData oo_intForKey:KEY_GOVERNMENT])];
8499 NSString *economy_desc = [infoSystemData oo_stringForKey:KEY_ECONOMY_DESC
8500 defaultValue:OODisplayStringFromEconomyID([infoSystemData oo_intForKey:KEY_ECONOMY])];
8501 NSString *inhabitants = [infoSystemData oo_stringForKey:KEY_INHABITANTS];
8502 NSString *system_desc = [infoSystemData oo_stringForKey:KEY_DESCRIPTION];
8504 NSString *populationDesc = [infoSystemData oo_stringForKey:KEY_POPULATION_DESC
8505 defaultValue:OOExpandKeyWithSeed(kNilRandomSeed, @"sysdata-pop-value", population)];
8518 NSString *system = infoSystemName;
8519 system_desc =
OOExpandKeyWithSeed(infoSystemRandomSeed,
@"nova-system-description", system);
8521 populationDesc =
OOExpandKeyWithSeed(infoSystemRandomSeed,
@"sysdata-pop-value", population);
8526 [UNIVERSE removeDemoShips];
8530 NSString *system = infoSystemName;
8531 [gui
setTitle:OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-data-on-system", system)];
8535 [gui
setTitle:OOExpandKey(@"sysdata-data-on-system-no-name")];
8542 for (i-- ; i > 14 ; --i)
8549 NSPoint infoSystemCoordinates = [[UNIVERSE systemManager] getCoordinatesForSystem: info_system_id inGalaxy: galaxy_number];
8555 NSString *distanceInfo = [NSString stringWithFormat: @"%.1f ly", distance];
8558 NSDictionary *routeInfo =
nil;
8559 routeInfo = [UNIVERSE routeFromSystem: system_id toSystem: info_system_id optimizedBy: ANA_mode];
8560 if (routeInfo !=
nil)
8562 double routeDistance = [[routeInfo objectForKey: @"distance"] doubleValue];
8563 double routeTime = [[routeInfo objectForKey: @"time"] doubleValue];
8564 int routeJumps = [[routeInfo objectForKey: @"jumps"] intValue];
8566 routeDistance = 0.1;
8570 distanceInfo = [NSString stringWithFormat: @"%.1f ly / %.1f %@ / %d %@",
8574 routeTime > 1.05 || routeTime < 0.95 ? DESC(@"sysdata-route-hours%1") : DESC(@"sysdata-route-hours%0"),
8576 DESC_PLURAL(@"sysdata-route-jumps", routeJumps)];
8582 for (i = 1; i <= 16; i++) {
8583 NSString *ln = [NSString stringWithFormat:@"sysdata-line-%ld", (long)i];
8584 NSString *line =
OOExpandKeyWithSeed(infoSystemRandomSeed, ln, economy_desc, government_desc, techLevel, populationDesc, inhabitants, productivity, radius, distanceInfo);
8585 if (![line isEqualToString:
@""])
8587 NSArray *lines = [line componentsSeparatedByString:@"\t"];
8588 if ([lines
count] == 1)
8590 [gui
setArray:[NSArray arrayWithObjects:[lines objectAtIndex:0],
8594 if ([lines
count] == 2)
8596 [gui
setArray:[NSArray arrayWithObjects:[lines objectAtIndex:0],
8597 [lines objectAtIndex:1],
8601 if ([lines
count] == 3)
8603 if ([[lines objectAtIndex:2] isEqualToString:
@""])
8605 [gui
setArray:[NSArray arrayWithObjects:[lines objectAtIndex:0],
8606 [lines objectAtIndex:1],
8612 [gui
setArray:[NSArray arrayWithObjects:[lines objectAtIndex:0],
8613 [lines objectAtIndex:1],
8614 [lines objectAtIndex:2],
8622 [gui
setArray:[NSArray arrayWithObjects:@"",
8631 for (i-- ; i > 16 ; --i)
8635 for (i = 1 ; i <= 14 ; ++i)
8646 [lastTextKey release];
8649 [[UNIVERSE gameView] clearMouse];
8651 [infoSystemData release];
8653 [
self setShowDemoShips:NO];
8654 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
8666 [
self setBackgroundFromDescriptionsKey:@"gui-scene-show-local-planet"];
8670 [
self setBackgroundFromDescriptionsKey:@"gui-scene-show-planet"];
8677 if (refreshBackground || guiChanged)
8682 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen refresh: refreshBackground];
8688- (void) prepareMarkedDestination:(NSMutableDictionary *)markers :(NSDictionary *)marker
8690 NSNumber *key = [NSNumber numberWithInt:[marker oo_intForKey:@"system"]];
8691 NSMutableArray *list = [markers objectForKey:key];
8694 list = [NSMutableArray arrayWithObject:marker];
8698 [list addObject:marker];
8700 [markers setObject:list forKey:key];
8707 NSMutableDictionary *destinations = [NSMutableDictionary dictionaryWithCapacity:256];
8710 NSDictionary *marker;
8712 for (i = 0; i < [passengers count]; i++)
8714 sysid = [[passengers oo_dictionaryAtIndex:i] oo_unsignedCharForKey:CONTRACT_KEY_DESTINATION];
8715 marker = [
self passengerContractMarker:sysid];
8716 [
self prepareMarkedDestination:destinations:marker];
8718 for (i = 0; i < [parcels count]; i++)
8720 sysid = [[parcels oo_dictionaryAtIndex:i] oo_unsignedCharForKey:CONTRACT_KEY_DESTINATION];
8721 marker = [
self parcelContractMarker:sysid];
8722 [
self prepareMarkedDestination:destinations:marker];
8724 for (i = 0; i < [contracts count]; i++)
8726 sysid = [[contracts oo_dictionaryAtIndex:i] oo_unsignedCharForKey:CONTRACT_KEY_DESTINATION];
8727 marker = [
self cargoContractMarker:sysid];
8728 [
self prepareMarkedDestination:destinations:marker];
8731 NSEnumerator *keyEnum =
nil;
8732 NSString *key =
nil;
8736 marker = [missionDestinations objectForKey:key];
8737 [
self prepareMarkedDestination:destinations:marker];
8740 return destinations;
8749 [
self setMissionBackgroundSpecial: nil];
8752 [
self setGuiToChartScreenFrom: oldScreen];
8761 [
self setMissionBackgroundSpecial: nil];
8763 [
self setGuiToChartScreenFrom: oldScreen];
8772 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
8774 target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
8776 [UNIVERSE preloadPlanetTexturesForSystem:target_system_id];
8794 if (
gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
8796 NSString *displaySearchString =
planetSearchString ? [planetSearchString capitalizedString] : (NSString *)
@"";
8797 [gui
setText:[NSString stringWithFormat:DESC(@"long-range-chart-find-planet-@"), displaySearchString]
forRow:GUI_ROW_PLANET_FINDER];
8809 [
self setShowDemoShips:NO];
8810 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
8819 [UNIVERSE findSystemCoordinatesWithPrefix:[[UNIVERSE getSystemName:found_system_id] lowercaseString] exactMatch:YES];
8821 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
8828 NSString *filledSlider = [@"|||||||||||||||||||||||||" substringToIndex:amountIn20ths];
8829 NSString *emptySlider = [@"........................." substringToIndex:20 - amountIn20ths];
8830 return [NSString stringWithFormat:@"%@%@", filledSlider, emptySlider];
8838 [[UNIVERSE gameView] clearMouse];
8839 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
8843 #define OO_SETACCESSCONDITIONFORROW(condition, row) \
8847 [gui setKey:GUI_KEY_OK forRow:(row)]; \
8851 [gui setColor:[OOColor grayColor] forRow:(row)]; \
8854 BOOL startingGame = [
self status] == STATUS_START_GAME;
8861 [gui
setTitle:[NSString stringWithFormat:DESC(@"status-commander-@"), [
self commanderName]]];
8863#if OO_RESOLUTION_OPTION
8867 if (displayModeIndex == NSNotFound)
8869 OOLogWARN(
@"display.currentMode.notFound",
@"%@",
@"couldn't find current fullscreen setting, switching to default.");
8870 displayModeIndex = 0;
8875 if ([modeList
count])
8877 mode = [modeList objectAtIndex:displayModeIndex];
8881 unsigned modeWidth = [mode oo_unsignedIntForKey:kOODisplayWidth];
8882 unsigned modeHeight = [mode oo_unsignedIntForKey:kOODisplayHeight];
8883 float modeRefresh = [mode oo_floatForKey:kOODisplayRefreshRate];
8887 if (!runningOnPrimaryDisplayDevice)
8889 MONITORINFOEX mInfo = [gameView currentMonitorInfo];
8890 modeWidth = mInfo.rcMonitor.right - mInfo.rcMonitor.left;
8891 modeHeight = mInfo.rcMonitor.bottom - mInfo.rcMonitor.top;
8895 NSString *displayModeString = [
self screenModeStringForWidth:modeWidth height:modeHeight refreshRate:modeRefresh];
8898 if (runningOnPrimaryDisplayDevice)
8910 if ([gameView hdrOutput])
8912 NSArray *brightnesses = [[UNIVERSE descriptions] oo_arrayForKey: @"hdr_maxBrightness_array"];
8913 int brightnessIdx = [brightnesses indexOfObject:[NSString stringWithFormat:@"%d", (int)[gameView hdrMaxBrightness]]];
8915 if (brightnessIdx == NSNotFound)
8917 OOLogWARN(
@"hdr.maxBrightness.notFound",
@"%@",
@"couldn't find current max brightness setting, switching to 400 nits.");
8921 int brightnessValue = [brightnesses oo_intAtIndex:brightnessIdx];
8922 NSString *maxBrightnessString =
OOExpandKey(
@"gameoptions-hdr-maxbrightness", brightnessValue);
8924 [gui
setText:maxBrightnessString
forRow:GUI_ROW(GAME,HDRMAXBRIGHTNESS)
align:GUI_ALIGN_CENTER];
8925 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,HDRMAXBRIGHTNESS)];
8931 [gui
setText:DESC(@"gameoptions-autosave-yes")
forRow:GUI_ROW(GAME,AUTOSAVE)
align:GUI_ALIGN_CENTER];
8933 [gui
setText:DESC(@"gameoptions-autosave-no")
forRow:GUI_ROW(GAME,AUTOSAVE)
align:GUI_ALIGN_CENTER];
8937 if ([
OOSound respondsToSelector:
@selector(masterVolume)] && [
OOSound isSoundOK])
8940 int vol = (
volume / 5.0 + 0.5);
8941 NSString* soundVolumeWordDesc =
DESC(
@"gameoptions-sound-volume");
8943 [gui
setText:[NSString stringWithFormat:@"%@%@ ", soundVolumeWordDesc, SliderString(vol)]
forRow:GUI_ROW(GAME,VOLUME)
align:GUI_ALIGN_CENTER];
8945 [gui
setText:DESC(@"gameoptions-sound-volume-mute")
forRow:GUI_ROW(GAME,VOLUME)
align:GUI_ALIGN_CENTER];
8950 [gui
setText:DESC(@"gameoptions-volume-external-only")
forRow:GUI_ROW(GAME,VOLUME)
align:GUI_ALIGN_CENTER];
8957 int gamma5 = (gamma * 5);
8958 NSString* gammaWordDesc =
DESC(
@"gameoptions-gamma-value");
8959 [gui
setText:[NSString stringWithFormat:@"%@%@ (%.1f) ", gammaWordDesc, SliderString(gamma5), gamma]
forRow:GUI_ROW(GAME,GAMMA)
align:GUI_ALIGN_CENTER];
8964 float fov = [gameView
fov:NO];
8966 NSString* fovWordDesc =
DESC(
@"gameoptions-fov-value");
8967 [gui
setText:[NSString stringWithFormat:@"%@%@ (%d%c) ", fovWordDesc, SliderString(fovTicks), (int)fov, 176 ]
forRow:GUI_ROW(GAME,FOV)
align:GUI_ALIGN_CENTER];
8971 int colorblindMode = [UNIVERSE colorblindMode];
8972 NSString *colorblindModeDesc = [[[UNIVERSE descriptions] oo_arrayForKey: @"colorblind_mode"] oo_stringAtIndex:[UNIVERSE useShaders] ? colorblindMode : 0];
8973 NSString *colorblindModeMsg =
OOExpandKey(
@"gameoptions-colorblind-mode", colorblindModeDesc);
8974 [gui
setText:colorblindModeMsg
forRow:GUI_ROW(GAME,COLORBLINDMODE)
align:GUI_ALIGN_CENTER];
8977 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,COLORBLINDMODE)];
8984#if OOLITE_SPEECH_SYNTH
8989 [gui
setText:DESC(@"gameoptions-spoken-messages-no")
forRow:GUI_ROW(GAME,SPEECH)
align:GUI_ALIGN_CENTER];
8992 [gui
setText:DESC(@"gameoptions-spoken-messages-comms")
forRow:GUI_ROW(GAME,SPEECH)
align:GUI_ALIGN_CENTER];
8995 [gui
setText:DESC(@"gameoptions-spoken-messages-yes")
forRow:GUI_ROW(GAME,SPEECH)
align:GUI_ALIGN_CENTER];
9002 NSString *voiceName = [UNIVERSE voiceName:voice_no];
9003 NSString *message =
OOExpandKey(
@"gameoptions-voice-name", voiceName);
9007 message = [NSString stringWithFormat:DESC(voice_gender_m ? @"gameoptions-voice-M" : @"gameoptions-voice-F")];
9015 if([gameView inFullScreenMode])
9017 [gui
setText:DESC(@"gameoptions-play-in-window")
forRow:GUI_ROW(GAME,DISPLAYSTYLE)
align:GUI_ALIGN_CENTER];
9021 [gui
setText:DESC(@"gameoptions-play-in-fullscreen")
forRow:GUI_ROW(GAME,DISPLAYSTYLE)
align:GUI_ALIGN_CENTER];
9023 [gui
setKey: GUI_KEY_OK
forRow: GUI_ROW(GAME,DISPLAYSTYLE)];
9026 [gui
setText:DESC(@"gameoptions-joystick-configuration")
forRow: GUI_ROW(GAME,STICKMAPPER)
align: GUI_ALIGN_CENTER];
9029 [gui
setText:DESC(@"gameoptions-keyboard-configuration")
forRow: GUI_ROW(GAME,KEYMAPPER)
align: GUI_ALIGN_CENTER];
9030 [gui
setKey: GUI_KEY_OK
forRow: GUI_ROW(GAME,KEYMAPPER)];
9034 NSString *message =
OOExpandKey(
@"gameoptions-music-mode", musicMode);
9038 if (![gameView hdrOutput])
9041 [gui
setText:DESC(@"gameoptions-wireframe-graphics-yes")
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)
align:GUI_ALIGN_CENTER];
9043 [gui
setText:DESC(@"gameoptions-wireframe-graphics-no")
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)
align:GUI_ALIGN_CENTER];
9044 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)];
9049 float paperWhite = [gameView hdrPaperWhiteBrightness];
9051 NSString* paperWhiteWordDesc =
DESC(
@"gameoptions-hdr-paperwhite");
9052 [gui
setText:[NSString stringWithFormat:@"%@%@ (%d) ", paperWhiteWordDesc, SliderString(paperWhiteTicks), (int)paperWhite]
forRow:GUI_ROW(GAME,HDRPAPERWHITE)
align:GUI_ALIGN_CENTER];
9053 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,HDRPAPERWHITE)];
9058 if ([
UNIVERSE doProcedurallyTexturedPlanets])
9059 [gui
setText:DESC(@"gameoptions-procedurally-textured-planets-yes")
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)
align:GUI_ALIGN_CENTER];
9061 [gui
setText:DESC(@"gameoptions-procedurally-textured-planets-no")
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)
align:GUI_ALIGN_CENTER];
9062 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)];
9066 NSString *shaderEffectsOptionsString =
OOExpand(
@"gameoptions-detaillevel-[detailLevel]", detailLevel);
9067 [gui
setText:OOExpandKey(shaderEffectsOptionsString)
forRow:GUI_ROW(GAME,SHADEREFFECTS)
align:GUI_ALIGN_CENTER];
9070 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,SHADEREFFECTS)];
9079 if ([
UNIVERSE dockingClearanceProtocolActive])
9081 [gui
setText:DESC(@"gameoptions-docking-clearance-yes")
forRow:GUI_ROW(GAME,DOCKINGCLEARANCE)
align:GUI_ALIGN_CENTER];
9085 [gui
setText:DESC(@"gameoptions-docking-clearance-no")
forRow:GUI_ROW(GAME,DOCKINGCLEARANCE)
align:GUI_ALIGN_CENTER];
9093 [gui
setSelectableRange:NSMakeRange(first_sel_row, GUI_ROW_GAMEOPTIONS_END_OF_LIST)];
9102 [
self setShowDemoShips:NO];
9105 [
self setShowDemoShips:NO];
9106 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
9112 BOOL gamePaused = [[UNIVERSE gameController] isGamePaused];
9113 BOOL canLoadOrSave = NO;
9117 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
9119 if ([
self status] == STATUS_DOCKED)
9122 canLoadOrSave = (([
self dockedStation] == [UNIVERSE station] || [[
self dockedStation] allowsSaving]) && !([[UNIVERSE sun] goneNova] || [[UNIVERSE sun] willGoNova]));
9132 int first_sel_row = (canLoadOrSave)?
GUI_ROW(,SAVE) :
GUI_ROW(,GAMEOPTIONS);
9134 first_sel_row =
GUI_ROW(,QUICKSAVE);
9137 [gui
setTitle:[NSString stringWithFormat:DESC(@"status-commander-@"), [
self commanderName]]];
9139 [gui
setText:DESC(@"options-quick-save")
forRow:GUI_ROW(,QUICKSAVE)
align:GUI_ALIGN_CENTER];
9145 [gui
setText:DESC(@"options-save-commander")
forRow:GUI_ROW(,SAVE)
align:GUI_ALIGN_CENTER];
9146 [gui
setText:DESC(@"options-load-commander")
forRow:GUI_ROW(,LOAD)
align:GUI_ALIGN_CENTER];
9158 [gui
setText:DESC(@"options-return-to-menu")
forRow:GUI_ROW(,BEGIN_NEW)
align:GUI_ALIGN_CENTER];
9161 [gui
setText:DESC(@"options-game-options")
forRow:GUI_ROW(,GAMEOPTIONS)
align:GUI_ALIGN_CENTER];
9169 [gui
setText:DESC(@"options-exit-game")
forRow:GUI_ROW(,QUIT)
align:GUI_ALIGN_CENTER];
9175 if (gamePaused || (!canLoadOrSave && [
self status] == STATUS_DOCKED))
9186 if ([gui setForegroundTextureKey:[
self status] == STATUS_DOCKED ?
@"docked_overlay" :
@"paused_overlay"] && [
UNIVERSE pauseMessageVisible])
9187 [[UNIVERSE messageGUI] clear];
9193 [[UNIVERSE gameView] clearMouse];
9195 [
self setShowDemoShips:NO];
9198 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
9202 [[UNIVERSE messageGUI] clear];
9203 NSString *pauseKey = [PLAYER keyBindingDescription2:@"key_pausebutton"];
9204 [UNIVERSE addMessage:OOExpandKey(@"game-paused-docked", pauseKey) forCount:1.0 forceDisplay:YES];
9207 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
9214- (void) highlightEquipShipScreenKey:(NSString *)key
9218 NSString *otherKey =
@"";
9220 [last_outfitting_key release];
9242 if ([otherKey isEqualToString:key])
9249 if ([otherKey hasPrefix:
@"More:"])
9251 i = [[otherKey componentsSeparatedByString:@":"] oo_intAtIndex:1];
9266 unsigned available_facings = [shipyardInfo oo_unsignedIntForKey:KEY_WEAPON_FACINGS defaultValue:[
self weaponFacings]];
9272- (void) setGuiToEquipShipScreen:(
int)skipParam selectingFacingFor:(NSString *)eqKeyForSelectFacing
9274 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
9278 NSString *showKey =
nil;
9284 searchStatus = STATUS_TEST;
9289 searchStatus = STATUS_ACTIVE;
9296 double priceFactor = 1.0;
9297 OOTechLevelID techlevel = [[UNIVERSE currentSystemData] oo_intForKey:KEY_TECHLEVEL];
9308 NSMutableArray *equipmentAllowed = [NSMutableArray array];
9313 NSMutableSet *options = [NSMutableSet setWithArray:[shipyardInfo oo_arrayForKey:KEY_OPTIONAL_EQUIPMENT]];
9316 [options addObjectsFromArray:[[shipyardInfo oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_arrayForKey:KEY_EQUIPMENT_EXTRAS]];
9319 NSEnumerator *eqEnum =
nil;
9321 unsigned available_facings = [shipyardInfo oo_unsignedIntForKey:KEY_WEAPON_FACINGS defaultValue:[
self weaponFacings]];
9324 if (eqKeyForSelectFacing !=
nil)
9328 [equipmentAllowed addObject:eqKeyForSelectFacing];
9329 [equipmentAllowed addObject:eqKeyForSelectFacing];
9330 [equipmentAllowed addObject:eqKeyForSelectFacing];
9332 else for (eqEnum = [
OOEquipmentType equipmentEnumeratorOutfitting]; (eqType = [eqEnum nextObject]); i++)
9341 if ([eqType isAvailableToAll]) [options addObject:eqKey];
9344 if (minTechLevel != 0 && [
self hasEquipmentItem:[eqType damagedIdentifier]]) minTechLevel--;
9347 if (techlevel < minTechLevel && techlevel + 3 > minTechLevel)
9349 unsigned day = i * 13 + (unsigned)floor([
UNIVERSE getTime] / 86400.0);
9350 unsigned char dayRnd = (day & 0xff) ^ (
unsigned char)
system_id;
9353 while (minTechLevel > 0 && minTechLevel > originalMinTechLevel - 3 && !(dayRnd & 7))
9355 dayRnd = dayRnd >> 2;
9361 if ([options containsObject:eqKey])
9364 [options removeObject:eqKey];
9369 if (techlevel < minTechLevel) isOK = NO;
9370 if (![
self canAddEquipment:eqKey inContext:
@"purchase"]) isOK = NO;
9371 if (available_facings == 0 && [eqType isPrimaryWeapon]) isOK = NO;
9372 if (isOK) [equipmentAllowed addObject:eqKey];
9375 if (searchStatus == STATUS_DEAD && isOK)
9378 searchStatus = STATUS_ACTIVE;
9380 if (searchStatus == STATUS_TEST)
9382 if (isOK) showKey = eqKey;
9384 searchStatus = isOK ? STATUS_ACTIVE : STATUS_DEAD;
9387 if (searchStatus != STATUS_TEST && showKey !=
nil)
9389 [last_outfitting_key release];
9398 unsigned facing_count = 0;
9399 BOOL displayRow = YES;
9400 BOOL weaponMounted = NO;
9401 BOOL guiChanged = (
gui_screen != GUI_SCREEN_EQUIP_SHIP);
9404 [gui
setTitle:DESC(@"equip-title")];
9407 [gui
setText:OOExpandKey(@"equip-cash-value", credits)
forRow:GUI_ROW_EQUIPMENT_CASH];
9411 tab_stops[1] = -360;
9412 tab_stops[2] = -480;
9417 NSUInteger
count = [equipmentAllowed count];
9425 if (
count <= n_rows || skip < n_rows)
9429 previous = skip - (n_rows - 2);
9434 if (eqKeyForSelectFacing !=
nil)
9438 [gui
setKey:[NSString stringWithFormat:@"More:%d:%@", previous, eqKeyForSelectFacing]
forRow:row];
9442 [gui
setKey:[NSString stringWithFormat:@"More:%d", previous]
forRow:row];
9445 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @"", @" <-- ", nil]
forRow:row];
9449 for (i = skip; i <
count && (row - start_row < (
OOGUIRow)n_rows); i++)
9451 NSString *eqKey = [equipmentAllowed oo_stringAtIndex:i];
9454 NSString *desc = [NSString stringWithFormat:@" %@ ", [eqInfo
name]];
9462 if ([eqKey isEqual:
@"EQ_FUEL"])
9466 else if ([eqKey isEqualToString:
@"EQ_RENOVATION"])
9468 price = [
self renovationCosts];
9473 price = pricePerUnit;
9476 price = [
self adjustPriceByScriptForEqKey:eqKey withCurrent:price];
9478 price *= priceFactor;
9481 if (installTime == 0)
9483 installTime = 600 + price;
9486 if ([
self hasEquipmentItem:eq_key_damaged])
9488 desc = [NSString stringWithFormat:DESC(@"equip-repair-@"), desc];
9491 if (installTime == 0)
9493 installTime = 600 + price;
9499 NSString *timeString = [UNIVERSE shortTimeDescription:installTime];
9500 NSString *priceString = [NSString stringWithFormat:@" %@ ", OOCredits(price)];
9502 if ([eqKeyForSelectFacing isEqualToString:eqKey])
9505 while (facing_count < 5)
9507 NSUInteger multiplier = 1;
9508 switch (facing_count)
9519 multiplier = [forwardWeaponOffset count];
9529 multiplier = [aftWeaponOffset count];
9539 multiplier = [portWeaponOffset count];
9549 multiplier = [starboardWeaponOffset count];
9565 priceString = [NSString stringWithFormat:@" %@ ", OOCredits(price*multiplier)];
9568 [gui
setArray:[NSArray arrayWithObjects:desc, (facing_count > 0 ? priceString : (NSString *)@""), timeString, nil]
forRow:row];
9579 if (![eqInfo hideValues])
9581 [gui
setArray:[NSArray arrayWithObjects:desc, priceString, timeString, nil]
forRow:row];
9596 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @"", @" --> ", nil]
forRow:row - 1];
9597 [gui
setKey:[NSString stringWithFormat:@"More:%d", i - 1]
forRow:row - 1];
9602 if ([gui selectedRow] != start_row)
9603 [gui setSelectedRow:start_row];
9605 if (eqKeyForSelectFacing !=
nil)
9608 [
self showInformationForSelectedUpgradeWithFormatString:DESC(@"@-select-where-to-install")];
9612 [
self showInformationForSelectedUpgrade];
9617 [gui
setText:DESC(@"equip-no-equipment-available-for-purchase")
forRow:GUI_ROW_NO_SHIPS
align:GUI_ALIGN_CENTER];
9622 [
self showInformationForSelectedUpgrade];
9631 NSDictionary *background = [UNIVERSE screenTextureDescriptorForKey:@"equip_ship"];
9632 [
self setEquipScreenBackgroundDescriptor:background];
9635 else if (eqKeyForSelectFacing !=
nil)
9637 NSDictionary *bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"mount_weapon"];
9648 [
self setShowDemoShips:NO];
9651 [
self setShowDemoShips:NO];
9652 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
9656- (void) setGuiToEquipShipScreen:(
int)skip
9658 [
self setGuiToEquipShipScreen:skip selectingFacingFor:nil];
9664 [
self showInformationForSelectedUpgradeWithFormatString:nil];
9668- (void) showInformationForSelectedUpgradeWithFormatString:(NSString *)formatString
9682 if (![eqKey hasPrefix:
@"More:"])
9685 NSString* eq_key_damaged = [NSString stringWithFormat:@"%@_DAMAGED", eqKey];
9687 if ([
self hasEquipmentItem:eq_key_damaged])
9689 desc = [NSString stringWithFormat:DESC(@"upgradeinfo-@-price-is-for-repairing"), desc];
9693 if([eqKey hasSuffix:
@"ENERGY_UNIT"] && ([
self hasEquipmentItem:
@"EQ_ENERGY_UNIT_DAMAGED"] || [
self hasEquipmentItem:
@"EQ_ENERGY_UNIT"] || [
self hasEquipmentItem:
@"EQ_NAVAL_ENERGY_UNIT_DAMAGED"]))
9694 desc = [NSString stringWithFormat:DESC(@"@-will-replace-other-energy"), desc];
9695 if (weight > 0) desc = [NSString stringWithFormat:DESC(@"upgradeinfo-@-weight-d-of-equipment"), desc, weight];
9697 if (formatString) desc = [NSString stringWithFormat:formatString, desc];
9704- (void) setGuiToInterfacesScreen:(
int)skip
9706 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
9709 [
self noteGUIWillChangeTo:GUI_SCREEN_INTERFACES];
9713 NSDictionary *interfaces = [[
self dockedStation] localInterfaces];
9714 NSArray *interfaceKeys = [interfaces keysSortedByValueUsingSelector:@selector(interfaceCompare:)];
9722 BOOL guiChanged = (
gui_screen != GUI_SCREEN_INTERFACES);
9725 [gui
setTitle:DESC(@"interfaces-title")];
9730 tab_stops[1] = -480;
9735 NSUInteger
count = [interfaceKeys count];
9743 if (
count <= n_rows || skip < (NSInteger)n_rows)
9749 previous = skip - (n_rows - 2);
9756 [gui
setKey:[NSString stringWithFormat:@"More:%d", previous]
forRow:row];
9758 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil]
forRow:row];
9762 for (i = skip; i < (NSInteger)
count && (row - start_row < (
OOGUIRow)n_rows); i++)
9764 NSString *interfaceKey = [interfaceKeys objectAtIndex:i];
9774 if (i < (NSInteger)
count)
9778 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil]
forRow:row - 1];
9779 [gui
setKey:[NSString stringWithFormat:@"More:%d", i - 1]
forRow:row - 1];
9784 if ([gui selectedRow] != start_row)
9789 [
self showInformationForSelectedInterface];
9793 [gui
setText:DESC(@"interfaces-no-interfaces-available-for-use")
forRow:GUI_ROW_NO_INTERFACES
align:GUI_ALIGN_LEFT];
9803 NSString *desc = [NSString stringWithFormat:DESC(@"interfaces-for-ship-@-and-station-@"), [
self displayName], [[
self dockedStation] displayName]];
9811 NSDictionary *background = [UNIVERSE screenTextureDescriptorForKey:@"interfaces"];
9818 [
self setShowDemoShips:NO];
9822 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
9824 [
self setShowDemoShips:NO];
9825 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
9843 if (interfaceKey && ![interfaceKey hasPrefix:
@"More:"])
9845 NSDictionary *interfaces = [[
self dockedStation] localInterfaces];
9861 if ([key hasPrefix:
@"More:"])
9863 int from_item = [[key componentsSeparatedByString:@":"] oo_intAtIndex:1];
9864 [
self setGuiToInterfacesScreen:from_item];
9866 if ([gui selectedRow] < 0)
9869 [gui
setSelectedRow:GUI_ROW_INTERFACES_START + GUI_MAX_ROWS_INTERFACES - 1];
9870 [
self showInformationForSelectedInterface];
9876 NSDictionary *interfaces = [[
self dockedStation] localInterfaces];
9880 [[UNIVERSE gameView] clearKeys];
9885 OOLog(
@"interface.missingCallback",
@"Unable to find callback definition for key %@", key);
9893 NSString *text =
nil;
9895 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
9901 text =
DESC(
@"game-copyright");
9905 text =
DESC(
@"theme-music-credit");
9909 int initialRow = 22;
9910 int row = initialRow;
9912 text =
DESC(
@"oolite-start-option-1");
9915 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9919 text =
DESC(
@"oolite-start-option-2");
9922 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9926 text =
DESC(
@"oolite-start-option-3");
9929 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9933 text =
DESC(
@"oolite-start-option-4");
9936 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9940 text =
DESC(
@"oolite-start-option-5");
9943 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9947 text =
DESC(
@"oolite-start-option-6");
9950 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9964- (void) setGuiToIntroFirstGo:(BOOL)justCobra
9966 NSString *text =
nil;
9970 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
9971 [[UNIVERSE gameView] clearMouse];
9972 [[UNIVERSE gameView] clearKeys];
9977 [UNIVERSE removeDemoShips];
9983 [
self setupStartScreenGui];
9992 for (i-- ; i >= ms_start ; i--) [gui setColor:[OOColor redColor] forRow:i];
9998 if ([OXPsWithMessages
count] > 0)
10000 NSString *messageToDisplay =
@"";
10004 if ([OXPsWithMessages
count] < 5)
10006 NSString *messageSourceList = [OXPsWithMessages componentsJoinedByString:@", "];
10007 messageToDisplay =
OOExpandKey(
@"oxp-containing-messages-list", messageSourceList);
10009 messageToDisplay =
OOExpandKey(
@"oxp-containing-messages-found");
10014 for (i--; i >= ms_start; i--)
10022 NSArray* arguments = [[NSProcessInfo processInfo] arguments];
10024 for (i = 0; i < [arguments count]; i++)
10026 if (([[arguments objectAtIndex:i] isEqual:
@"-message"])&&(i < [arguments
count] - 1))
10029 NSString* message = [arguments oo_stringAtIndex:i + 1];
10031 for (i-- ; i >= ms_start; i--)
10036 if ([[arguments objectAtIndex:i] isEqual:
@"-showversion"])
10039 NSString *version = [NSString stringWithFormat:@"Version %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
10041 for (i-- ; i >= ms_start; i--)
10052 text =
DESC(
@"oolite-ship-library-title");
10055 text =
DESC(
@"oolite-ship-library-exit");
10062 [UNIVERSE setupIntroFirstGo: justCobra];
10066 gui_screen = justCobra ? GUI_SCREEN_INTRO1 : GUI_SCREEN_SHIPLIBRARY;
10068 if ([
self status] == STATUS_START_GAME)
10073 [
self setShowDemoShips:YES];
10082 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
10090 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
10091 [[UNIVERSE gameView] clearMouse];
10092 [UNIVERSE removeDemoShips];
10096 [[UNIVERSE gui] clearAndKeepBackground:NO];
10101 [[UNIVERSE gui] setBackgroundTextureKey:@"oxz-manager"];
10102 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
10119 [
self noteGUIDidChangeFrom: fromScreen to: toScreen refresh: NO];
10126 if (fromScreen != toScreen || refresh)
10129 switch (fromScreen)
10131 case GUI_SCREEN_SHIPYARD:
10132 case GUI_SCREEN_LOAD:
10133 case GUI_SCREEN_SAVE:
10134 [demoShip release];
10143 if (toScreen == GUI_SCREEN_SYSTEM_DATA)
10146 [[UNIVERSE sun] setSunColor:[
OOColor colorWithDescription:[[UNIVERSE systemManager] getProperty:@"sun_color" forSystem:info_system_id inGalaxy:[
self galaxyNumber]]]];
10151 [[UNIVERSE sun] setSunColor:[
OOColor colorWithDescription:[[UNIVERSE systemManager] getProperty:@"sun_color" forSystem:system_id inGalaxy:[
self galaxyNumber]]]];
10154 if (![[
UNIVERSE gameController] isGamePaused])
10166 [
self noteSwitchToView:toView fromView:fromView];
10175 if ([key hasPrefix:
@"More:"])
10177 int from_item = [[key componentsSeparatedByString:@":"] oo_intAtIndex:1];
10178 NSString *weaponKey = [[key componentsSeparatedByString:@":"] oo_stringAtIndex:2];
10180 [
self setGuiToEquipShipScreen:from_item];
10181 if (weaponKey !=
nil)
10183 [
self highlightEquipShipScreenKey:weaponKey];
10187 if ([gui selectedRow] < 0)
10189 if (from_item == 0)
10190 [gui
setSelectedRow:GUI_ROW_EQUIPMENT_START + GUI_MAX_ROWS_EQUIPMENT - 1];
10191 [
self showInformationForSelectedUpgrade];
10212 if ([
self tryBuyingItem:key])
10217 [
self playMenuNavigationDown];
10221 [
self playBuyCommodity];
10224 if(
credits != old_credits || ![key hasPrefix:
@"EQ_WEAPON_"])
10228 NSUInteger adjust = 0;
10237 double time_adjust = (old_credits >
credits) ? (old_credits -
credits) : 0.0;
10238 [UNIVERSE forceWitchspaceEntries];
10248 [
self doScriptEvent:OOJSID("playerBoughtEquipment") withArguments:[NSArray arrayWithObjects:key, [NSNumber numberWithLongLong:(old_credits - credits)], nil]];
10252 [
self setGuiToEquipShipScreen:0];
10254 [
self highlightEquipShipScreenKey:key];
10257 if ([
UNIVERSE autoSave]) [UNIVERSE setAutoSaveNow:YES];
10262 [
self playCantBuyCommodity];
10270 if (condition_script !=
nil)
10272 OOJSScript *condScript = [UNIVERSE getConditionScript:condition_script];
10273 if (condScript !=
nil)
10280 OK = JS_NewNumberValue(JScontext, price, &args[1]);
10284 OK = [condScript
callMethod:OOJSID("updateEquipmentPrice")
10292 OK = JS_ValueToInt32(JScontext, result, &newPrice);
10293 if (OK && newPrice >= 0)
10305- (BOOL) tryBuyingItem:(NSString *)eqKey
10311 double price = pricePerUnit;
10312 double priceFactor = 1.0;
10314 BOOL isRepair = NO;
10317 if ([
self hasEquipmentItem:eqKeyDamaged])
10323 if ([eqKey isEqualToString:
@"EQ_RENOVATION"])
10325 price = [
self renovationCosts];
10328 price = [
self adjustPriceByScriptForEqKey:eqKey withCurrent:price];
10336 price *= priceFactor;
10343 if ([eqType isPrimaryWeapon])
10347 [
self setGuiToEquipShipScreen:0 selectingFacingFor:eqKey];
10354 NSUInteger multiplier = 1;
10363 multiplier = [forwardWeaponOffset count];
10372 multiplier = [aftWeaponOffset count];
10381 multiplier = [portWeaponOffset count];
10390 multiplier = [starboardWeaponOffset count];
10398 price *= multiplier;
10427 if (current_weapon !=
nil)
10429 tradeIn = [UNIVERSE getEquipmentPriceForKey:OOEquipmentIdentifierFromWeaponType(current_weapon)] * multiplier;
10432 [
self doTradeIn:tradeIn forPriceFactor:priceFactor];
10434 [
self removeEquipmentItem:eqKeyDamaged];
10440 OOLog(
@"equip.buy.mounted.failed.full",
@"%@",
@"rejecting missile because already full");
10453 if ([eqKey isEqualToString:
@"EQ_FUEL"])
10455#if MASS_DEPENDENT_FUEL_PRICES
10460 if (
credits >= creditsForRefuel)
10463 fuel = [
self fuelCapacity];
10478 [
self removeEquipmentItem:@"EQ_NAVAL_ENERGY_UNIT"];
10479 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_NAVAL_ENERGY_UNIT"] / 2;
10482 [
self removeEquipmentItem:@"EQ_NAVAL_ENERGY_UNIT_DAMAGED"];
10483 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_NAVAL_ENERGY_UNIT"] / 4;
10486 [
self removeEquipmentItem:@"EQ_ENERGY_UNIT"];
10487 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_ENERGY_UNIT"] * 3 / 4;
10490 [
self removeEquipmentItem:@"EQ_ENERGY_UNIT_DAMAGED"];
10491 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_ENERGY_UNIT"] * 3 / 8;
10497 [
self doTradeIn:tradeIn forPriceFactor:priceFactor];
10501 if ([eqKey isEqualToString:
@"EQ_RENOVATION"])
10505 if (techLevel == NSNotFound) techLevel = [[UNIVERSE currentSystemData] oo_unsignedIntForKey:KEY_TECHLEVEL];
10511 [
self clearSubEntities];
10512 [
self setUpSubEntities];
10517 if ([eqKey hasSuffix:
@"MISSILE"] || [eqKey hasSuffix:
@"MINE"])
10519 ShipEntity* weapon = [[UNIVERSE newShipWithRole:eqKey] autorelease];
10523 BOOL mounted_okay = [
self mountMissile:weapon];
10527 [
self safeAllMissiles];
10528 [
self tidyMissilePylons];
10529 [
self setActiveMissile:0];
10531 return mounted_okay;
10534 if ([eqKey isEqualToString:
@"EQ_PASSENGER_BERTH"])
10536 [
self changePassengerBerths:+1];
10541 if ([eqKey isEqualToString:
@"EQ_PASSENGER_BERTH_REMOVAL"])
10543 [
self changePassengerBerths:-1];
10548 if ([eqKey isEqualToString:
@"EQ_MISSILE_REMOVAL"])
10552 [
self doTradeIn:tradeIn forPriceFactor:priceFactor];
10556 if ([
self canAddEquipment:eqKey inContext:
@"purchase"])
10559 [
self addEquipmentItem:eqKey withValidation:NO inContext:@"purchase"];
10562 [
self doScriptEvent:OOJSID("equipmentRepaired") withArgument:eqKey];
10571- (BOOL) setWeaponMount:(
OOWeaponFacing)facing toWeapon:(NSString *)eqKey
10573 return [
self setWeaponMount:facing toWeapon:eqKey inContext:@"purchase"];
10577- (BOOL) setWeaponMount:(
OOWeaponFacing)facing toWeapon:(NSString *)eqKey inContext:(NSString *) context
10581 unsigned available_facings = [shipyardInfo oo_unsignedIntForKey:KEY_WEAPON_FACINGS defaultValue:[
self weaponFacings]];
10584 if (!(available_facings & facing))
10590 if (![eqKey isEqualToString:
@"EQ_WEAPON_NONE"])
10592 if (![
self canAddEquipment:eqKey inContext:context])
10627- (BOOL) changePassengerBerths:(
int) addRemove
10629 if (addRemove == 0)
return NO;
10630 addRemove = (addRemove > 0) ? 1 : -1;
10643 [
self safeAllMissiles];
10648 NSString *weapon_key = [missile_list[i] identifier];
10650 if (weapon_key !=
nil)
10651 tradeIn += (
int)[
UNIVERSE getEquipmentPriceForKey:weapon_key];
10656 [missile_entity[i] release];
10665- (void) doTradeIn:(
OOCreditsQuantity)tradeInValue forPriceFactor:(
double)priceFactor
10679 if ([
self status] != STATUS_DOCKED)
10687 cargoItem = [cargo objectAtIndex:i];
10689 if ([co_type isEqualToString:type])
10702 OOMassUnit unit = [shipCommodityData massUnitForGood:type];
10707 BOOL inPods = ([
self status] != STATUS_DOCKED);
10710 if (unit ==
UNITS_TONS && (available + oldAmount) < amount)
10712 amount = available + oldAmount;
10720 if (safeAmount < amount) amount = (safeAmount < oldAmount) ? oldAmount : safeAmount;
10722 else if (unit ==
UNITS_GRAMS && amount > oldAmount)
10725 if (safeAmount < amount) amount = (safeAmount < oldAmount) ? oldAmount : safeAmount;
10730 if (amount > oldAmount)
10732 [
self loadCargoPodsForType:type amount:(amount - oldAmount)];
10736 [
self unloadCargoPodsForType:type amount:(oldAmount - amount)];
10741 [shipCommodityData setQuantity:amount forGood:type];
10744 [
self calculateCurrentCargo];
10745 return [shipCommodityData quantityForGood:type];
10759 return [
self maxAvailableCargoSpace];
10770 NSString *good =
nil;
10776 OOMassUnit commodityUnits = [shipCommodityData massUnitForGood:good];
10788 cargoQtyOnBoard += quantity;
10792 return cargoQtyOnBoard;
10799 if (station ==
nil)
10803 station = [
self primaryTarget];
10807 station = [UNIVERSE station];
10809 if (station ==
nil)
10825- (NSArray *) applyMarketFilter:(NSArray *)goods onMarket:(
OOCommodityMarket *)market
10831 NSMutableArray *filteredGoods = [NSMutableArray arrayWithCapacity:[goods count]];
10833 foreach (good, goods)
10839 [filteredGoods addObject:good];
10842 if ([market quantityForGood:good] > 0 || [
self cargoQuantityForType:good] > 0)
10844 [filteredGoods addObject:good];
10848 if ([
self cargoQuantityForType:good] > 0)
10850 [filteredGoods addObject:good];
10854 if ([market quantityForGood:good] > 0)
10856 [filteredGoods addObject:good];
10860 if ([market exportLegalityForGood:good] == 0 && [market importLegalityForGood:good] == 0)
10862 [filteredGoods addObject:good];
10866 if ([market exportLegalityForGood:good] > 0 || [market importLegalityForGood:good] > 0)
10868 [filteredGoods addObject:good];
10873 return [[filteredGoods copy] autorelease];
10877- (NSArray *) applyMarketSorter:(NSArray *)goods onMarket:(
OOCommodityMarket *)market
10882 return [goods sortedArrayUsingFunction:marketSorterByName context:market];
10884 return [goods sortedArrayUsingFunction:marketSorterByPrice context:market];
10886 return [goods sortedArrayUsingFunction:marketSorterByQuantity context:market];
10888 return [goods sortedArrayUsingFunction:marketSorterByQuantity context:shipCommodityData];
10890 return [goods sortedArrayUsingFunction:marketSorterByMassUnit context:market];
10904 tab_stops[1] = 137;
10905 tab_stops[2] = 187;
10906 tab_stops[3] = 267;
10907 tab_stops[4] = 321;
10908 tab_stops[5] = 431;
10913 [gui
setArray:[NSArray arrayWithObjects: DESC(@"commodity-column-title"), OOPadStringToEms(DESC(@"price-column-title"),3.5),
10914 OOPadStringToEms(DESC(@"for-sale-column-title"),3.75), OOPadStringToEms(DESC(@"in-hold-column-title"),5.75), DESC(@"oolite-legality-column-title"), DESC(@"oolite-extras-column-title"), nil]
forRow:GUI_ROW_MARKET_KEY];
10915 [gui
setArray:[NSArray arrayWithObjects: DESC(@"commodity-column-title"), DESC(@"oolite-extras-column-title"), OOPadStringToEms(DESC(@"price-column-title"),3.5),
10916 OOPadStringToEms(DESC(@"for-sale-column-title"),3.75), OOPadStringToEms(DESC(@"in-hold-column-title"),5.75), DESC(@"oolite-legality-column-title"), nil]
forRow:GUI_ROW_MARKET_KEY];
10924 NSString* desc = [NSString stringWithFormat:@" %@ ", [shipCommodityData nameForGood:good]];
10928 OOMassUnit unit = [shipCommodityData massUnitForGood:good];
10930 NSString *available =
OOPadStringToEms(((available_units > 0) ? (NSString *)[NSString stringWithFormat:
@"%d",available_units] :
DESC(
@"commodity-quantity-none")), 2.5);
10932 NSUInteger priceDecimal = pricePerUnit % 10;
10933 NSString *price = [NSString stringWithFormat:@" %@.%lu ",OOPadStringToEms([NSString stringWithFormat:@"%lu",(unsigned long)(pricePerUnit/10)],2.5),priceDecimal];
10937 NSString *owned =
OOPadStringToEms((units_in_hold > 0) ? (NSString *)[NSString stringWithFormat:
@"%d",units_in_hold] :
DESC(
@"commodity-quantity-none"), 4.5);
10939 NSString *units_available = [NSString stringWithFormat:@" %@ %@ ",available, units];
10940 NSString *units_owned = [NSString stringWithFormat:@" %@ %@ ",owned, units];
10944 NSString *legaldesc =
nil;
10945 if (import_legality == 0)
10947 if (export_legality == 0)
10949 legaldesc =
DESC(
@"oolite-legality-clear");
10953 legaldesc =
DESC(
@"oolite-legality-import");
10958 if (export_legality == 0)
10960 legaldesc =
DESC(
@"oolite-legality-export");
10964 legaldesc =
DESC(
@"oolite-legality-neither");
10967 legaldesc = [NSString stringWithFormat:@" %@ ",legaldesc];
10969 NSString *extradesc = [shipCommodityData shortCommentForGood:good];
10973 [gui
setArray:[NSArray arrayWithObjects: desc, extradesc, price, units_available, units_owned, legaldesc, nil]
forRow:row++];
10991 NSString *system =
nil;
10992 if ([
UNIVERSE sun] !=
nil) system = [UNIVERSE getSystemName:system_id];
10998 return OOExpandKey(
@"system-commodity-market", system);
11009 return OOExpandKey(
@"station-commodity-market", station);
11021 BOOL guiChanged = (oldScreen !=
gui_screen);
11024 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
11029 localMarket = [[UNIVERSE commodities] generateBlankMarket];
11033 NSArray *goods = [
self applyMarketSorter:[
self applyMarketFilter:[localMarket
goods] onMarket:localMarket] onMarket:localMarket];
11034 NSInteger maxOffset = 0;
11040 NSUInteger commodityCount = [shipCommodityData count];
11043 for (NSUInteger i = 0; i < commodityCount; i++)
11045 quantityInHold[i] = [shipCommodityData quantityForGood:[goods oo_stringAtIndex:i]];
11047 for (NSUInteger i = 0; i < [cargo count]; i++)
11049 ShipEntity *container = [cargo objectAtIndex:i];
11050 NSUInteger goodsIndex = [goods indexOfObject:[container
commodityType]];
11052 if (goodsIndex != NSNotFound)
11067 if ([goods
count] > 0)
11074 NSInteger goodsIndex = [goods indexOfObject:marketSelectedCommodity];
11079 if (goodsIndex == 0) {
11112 [gui
setTitle:[
self marketScreenTitle]];
11114 [
self showMarketScreenHeaders];
11125 if ([goods
count] > 0)
11129 foreach (good, goods)
11136 [
self showMarketScreenDataLine:row forGood:good inMarket:localMarket holdQuantity:quantityInHold[i++]];
11157 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @"", @"", @"", @" --> ", nil]
forRow:GUI_ROW_MARKET_LAST];
11167 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @"", @"", @"", @" <-- ", nil]
forRow:GUI_ROW_MARKET_START];
11174 [gui
setText:DESC(@"oolite-market-filtered-all")
forRow:GUI_ROW_MARKET_START];
11185 NSString *filterText =
OOExpandKey(
@"oolite-market-filter-line", filterMode);
11187 NSString *sorterText =
OOExpandKey(
@"oolite-market-sorter-line", sortMode);
11188 [gui
setArray:[NSArray arrayWithObjects:filterText, @"", sorterText, nil]
forRow:GUI_ROW_MARKET_END];
11192 [
self showMarketCashAndLoadLine];
11201 [[UNIVERSE gameView] clearMouse];
11203 [
self setShowDemoShips:NO];
11204 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
11210 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
11222 BOOL guiChanged = (oldScreen !=
gui_screen);
11225 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
11230 localMarket = [[UNIVERSE commodities] generateBlankMarket];
11234 NSArray *goods = [
self applyMarketSorter:[
self applyMarketFilter:[localMarket
goods] onMarket:localMarket] onMarket:localMarket];
11236 NSUInteger i, j, commodityCount = [shipCommodityData count];
11239 for (i = 0; i < commodityCount; i++)
11241 quantityInHold[i] = [shipCommodityData quantityForGood:[goods oo_stringAtIndex:i]];
11243 for (i = 0; i < [cargo count]; i++)
11245 ShipEntity *container = [cargo objectAtIndex:i];
11259 j = [goods indexOfObject:marketSelectedCommodity];
11261 if (j == NSNotFound)
11264 [
self setGuiToMarketScreen];
11270 [gui
setTitle:[NSString stringWithFormat:DESC(@"oolite-commodity-information-@"), [shipCommodityData nameForGood:marketSelectedCommodity]]];
11272 [
self showMarketScreenHeaders];
11273 [
self showMarketScreenDataLine:GUI_ROW_MARKET_START forGood:marketSelectedCommodity inMarket:localMarket holdQuantity:quantityInHold[j]];
11275 OOCargoQuantity contracted = [
self contractedVolumeForGood:marketSelectedCommodity];
11276 if (contracted > 0)
11278 OOMassUnit unit = [shipCommodityData massUnitForGood:marketSelectedCommodity];
11280 [gui
setText:[NSString stringWithFormat:DESC(@"oolite-commodity-contracted-d-@"), contracted, DisplayStringForMassUnit(unit)]
forRow:GUI_ROW_MARKET_START+1];
11283 NSString *info = [shipCommodityData commentForGood:marketSelectedCommodity];
11285 if (info ==
nil || [info length] == 0)
11298 [
self showMarketCashAndLoadLine];
11302 [[UNIVERSE gameView] clearMouse];
11304 [
self setShowDemoShips:NO];
11305 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
11311 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
11320 [gui
setText:OOExpandKey(@"market-cash-and-load", credits, currentCargo, cargoCapacity)
forRow:GUI_ROW_MARKET_CASH];
11332 if ([index isEqualToString:
@"<<<"] || [index isEqualToString:
@">>>"])
11348 int manifest_quantity = [shipCommodityData quantityForGood:index];
11355 int contracted = [
self contractedVolumeForGood:index];
11356 if (manifest_quantity >= contracted)
11362 purchase = contracted-manifest_quantity;
11365 if (purchase > market_quantity)
11367 purchase = market_quantity;
11369 if (purchase * pricePerUnit >
credits)
11371 purchase = floor (
credits / pricePerUnit);
11376 purchase = [
self availableCargoSpace];
11409 [shipCommodityData addQuantity:purchase forGood:index];
11410 credits -= pricePerUnit * purchase;
11412 [
self calculateCurrentCargo];
11416 [
self doScriptEvent:OOJSID("playerBoughtCargo") withArguments:[NSArray arrayWithObjects:index, [NSNumber numberWithInt:purchase], [NSNumber numberWithUnsignedLongLong:pricePerUnit], nil]];
11417 if ([
localMarket exportLegalityForGood:index] > 0)
11419 [roleWeightFlags setObject:[NSNumber numberWithInt:1] forKey:@"bought-illegal"];
11423 [roleWeightFlags setObject:[NSNumber numberWithInt:1] forKey:@"bought-legal"];
11432 if ([index isEqualToString:
@"<<<"] || [index isEqualToString:
@">>>"])
11441 int available_units = [shipCommodityData quantityForGood:index];
11444 if (available_units == 0)
return NO;
11453 int contracted = [
self contractedVolumeForGood:index];
11454 if (available_units <= contracted)
11460 sell = available_units-contracted;
11464 if (sell > available_units)
11465 sell = available_units;
11466 if (sell + market_quantity > capacity)
11467 sell = capacity - market_quantity;
11472 [shipCommodityData removeQuantity:sell forGood:index];
11473 credits += pricePerUnit * sell;
11475 [
self calculateCurrentCargo];
11479 [
self doScriptEvent:OOJSID("playerSoldCargo") withArguments:[NSArray arrayWithObjects:index, [NSNumber numberWithInt:sell], [NSNumber numberWithUnsignedLongLong: pricePerUnit], nil]];
11497- (BOOL) canAddEquipment:(NSString *)equipmentKey inContext:(NSString *)context
11500 if (![super canAddEquipment:equipmentKey inContext:context])
return NO;
11503 if (conditions !=
nil && ![
self scriptTestConditions:conditions])
return NO;
11509- (BOOL) addEquipmentItem:(NSString *)equipmentKey inContext:(NSString *)context
11511 return [
self addEquipmentItem:equipmentKey withValidation:YES inContext:context];
11515- (BOOL) addEquipmentItem:(NSString *)equipmentKey withValidation:(BOOL)validateAddition inContext:(NSString *)context
11518 if ([equipmentKey isEqualToString:
@"EQ_TRUMBLE"])
11529 [
self addTrumble:trumble[ranrot_rand() % PLAYER_MAX_TRUMBLES]];
11535 BOOL OK = [
super addEquipmentItem:equipmentKey withValidation:validateAddition inContext:context];
11539 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_COMPASS"] && [
self compassMode] == COMPASS_MODE_BASIC)
11541 [
self setCompassMode:COMPASS_MODE_PLANET];
11544 [
self addEqScriptForKey:equipmentKey];
11545 [
self addEquipmentWithScriptToCustomKeyArray:equipmentKey];
11557- (void) addEquipmentWithScriptToCustomKeyArray:(NSString *)equipmentKey
11559 NSDictionary *item;
11563 for (i = 0; i < [eqScripts count]; i++)
11565 if ([[[
eqScripts oo_arrayAtIndex:i] oo_stringAtIndex:0] isEqualToString:equipmentKey])
11568 for (j = 0; j < [customEquipActivation count]; j++) {
11569 item = [customEquipActivation objectAtIndex:j];
11575 NSMutableDictionary *customKey = [[NSMutableDictionary alloc] initWithObjectsAndKeys:equipmentKey, CUSTOMEQUIP_EQUIPKEY, [eq
name], CUSTOMEQUIP_EQUIPNAME, nil];
11580 if ((
object !=
nil && [
object count] > 0))
11584 if ((
object !=
nil && [
object count] > 0))
11587 [customEquipActivation addObject:customKey];
11588 [customKey release];
11590 [customActivatePressed addObject:[NSNumber numberWithBool:NO]];
11591 [customModePressed addObject:[NSNumber numberWithBool:NO]];
11593 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
11594 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
11605 NSString *equipmentKey;
11608 equipmentKey = [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY];
11611 [customEquipActivation removeObjectAtIndex:i];
11612 [customActivatePressed removeObjectAtIndex:i];
11613 [customModePressed removeObjectAtIndex:i];
11618 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
11619 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
11624- (void) removeEquipmentItem:(NSString *)equipmentKey
11626 if(![
self hasEquipmentItemProviding:
@"EQ_ADVANCED_COMPASS"] && [
self compassMode] != COMPASS_MODE_BASIC)
11628 [
self setCompassMode:COMPASS_MODE_BASIC];
11630 [
super removeEquipmentItem:equipmentKey];
11631 if(![
self hasEquipmentItem:equipmentKey]) {
11633 [
self removeEqScriptForKey:equipmentKey];
11638- (void) addEquipmentFromCollection:(
id)equipment
11640 NSDictionary *dict =
nil;
11641 NSEnumerator *eqEnum =
nil;
11642 NSString *eqDesc =
nil;
11643 NSUInteger i,
count;
11646 if ([equipment isKindOfClass:[NSDictionary
class]])
11649 eqEnum = [equipment keyEnumerator];
11651 else if ([equipment isKindOfClass:[NSArray
class]] || [equipment isKindOfClass:[NSSet
class]])
11653 eqEnum = [equipment objectEnumerator];
11655 else if ([equipment isKindOfClass:[NSString
class]])
11657 eqEnum = [[NSArray arrayWithObject:equipment] objectEnumerator];
11664 while ((eqDesc = [eqEnum nextObject]))
11679 if ([eqDesc isEqualToString:
@"EQ_TRUMBLE"])
continue;
11682 if (dict !=
nil && ![dict oo_boolForKey:eqDesc])
continue;
11689 count = [dict oo_unsignedIntegerForKey:eqDesc];
11690 for (i=0;i<
count;i++)
11692 [
self addEquipmentItem:eqDesc withValidation:NO inContext:@"loading"];
11697 if ([equipment isKindOfClass:[NSDictionary
class]])
11699 eqEnum = [equipment keyEnumerator];
11701 else if ([equipment isKindOfClass:[NSArray
class]] || [equipment isKindOfClass:[NSSet
class]])
11703 eqEnum = [equipment objectEnumerator];
11705 else if ([equipment isKindOfClass:[NSString
class]])
11707 eqEnum = [[NSArray arrayWithObject:equipment] objectEnumerator];
11710 while ((eqDesc = [eqEnum nextObject]))
11712 if (![
self equipmentValidToAdd:eqDesc whileLoading:YES inContext:
@"loading"])
11714 [
self removeEquipmentItem:eqDesc];
11720- (BOOL) hasOneEquipmentItem:(NSString *)itemKey includeMissiles:(BOOL)includeMissiles
11723 if ([super hasOneEquipmentItem:itemKey includeMissiles:NO whileLoading:NO])
return YES;
11726 if (includeMissiles)
11731 if ([[
self missileForPylon:i] hasPrimaryRole:itemKey])
return YES;
11735 if ([itemKey isEqualToString:
@"EQ_TRUMBLE"])
11737 return [
self trumbleCount] > 0;
11747 [[
aft_weapon_type identifier] isEqualToString:[weaponType identifier]] ||
11748 [[
port_weapon_type identifier] isEqualToString:[weaponType identifier]] ||
11754 return [
super hasPrimaryWeapon:weaponType];
11766 if ([[
self missileForPylon:i] hasPrimaryRole:identifier])
11768 [
self removeFromPylon:i];
11778- (BOOL) removeFromPylon:(NSUInteger)pylon
11784 NSString *identifier = [missile_entity[pylon] primaryRole];
11788 [missile_entity[pylon] release];
11791 [
self tidyMissilePylons];
11800 [
self selectNextMissile];
11812 return [parcels count];
11818 return [passengers count];
11830 ShipEntity *playersTarget = [
self primaryTarget];
11835- (void) receiveCommsMessage:(NSString *) message_text from:(
ShipEntity *) other
11837 if ([
self status] == STATUS_DEAD || [
self status] == STATUS_DOCKED)
11842 [UNIVERSE addCommsMessage:[NSString stringWithFormat:@"%@:\n %@", [other
displayName], message_text] forCount:4.5];
11843 [
super receiveCommsMessage:message_text from:other];
11851 OOGovernmentID local_gov = [[UNIVERSE currentSystemData] oo_intForKey:KEY_GOVERNMENT];
11852 if ([
UNIVERSE inInterstellarSpace]) local_gov = 1;
11858 [
self setBounty:(legalStatus-payback) withReason:kOOLegalStatusReasonPaidFine];
11863 [
self setBounty:0 withReason:kOOLegalStatusReasonPaidFine];
11868 NSString *fined_message = [NSString stringWithFormat:OOExpandKey(@"fined-@-credits"), OOCredits(fine)];
11869 [
self addMessageToReport:fined_message];
11870 [UNIVERSE forceWitchspaceEntries];
11875- (void) adjustTradeInFactorBy:(
int)value
11892 OOCreditsQuantity shipValue = [UNIVERSE tradeInValueForCommanderDictionary:[
self commanderDataDictionary]];
11896 costs *= [
self renovationFactor];
11905 return [shipyardInfo oo_doubleForKey:KEY_RENOVATION_MULTIPLIER defaultValue:1.0];
11926 [_customViews release];
11929 if (customViews !=
nil)
11959 NSMutableString *trumbleDigrams = [NSMutableString stringWithCapacity:256];
11960 unichar xchar = (unichar)0;
11961 unichar digramchars[2];
11968 [trumbleDigrams appendFormat:@"%@%@", commanderName, [[
self mesh] modelName]];
11972 [trumbleDigrams appendString:@"Some Random Text!"];
11978 digramchars[0] = ([trumbleDigrams characterAtIndex:i] & 0x007f) | 0x0020;
11979 digramchars[1] = (([trumbleDigrams characterAtIndex:i + 1] ^ xchar) & 0x007f) | 0x0020;
11980 xchar = digramchars[0];
11981 NSString *digramstring = [NSString stringWithCharacters:digramchars length:2];
11982 [trumble[i] release];
11988 [
self setTrumbleAppetiteAccumulator:0.0f];
11992- (void) addTrumble:(
OOTrumble *)papaTrumble
12004- (void) removeTrumble:(
OOTrumble *)deadTrumble
12010 NSUInteger trumble_index = NSNotFound;
12013 for (i = 0; (trumble_index == NSNotFound)&&(i <
trumbleCount); i++)
12015 if (
trumble[i] == deadTrumble)
12018 if (trumble_index == NSNotFound)
12020 OOLog(
@"trumble.zombie",
@"DEBUG can't get rid of inactive trumble %@", deadTrumble);
12025 trumble[trumbleCount] = deadTrumble;
12043 NSString *namekey = [NSString stringWithFormat:@"%@-humbletrash", [
self commanderName]];
12047 [
self mungChecksumWithNSString:[
self commanderName]];
12052 [[NSUserDefaults standardUserDefaults] setInteger:trumbleHash forKey:namekey];
12055 NSMutableArray *
trumbleArray = [NSMutableArray arrayWithCapacity:PLAYER_MAX_TRUMBLES];
12058 [trumbleArray addObject:[trumble[i] dictionary]];
12061 return [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInteger:trumbleCount], [NSNumber numberWithInt:trumbleHash], trumbleArray, nil];
12065- (void) setTrumbleValueFrom:(NSObject*) trumbleValue
12067 BOOL info_failed = NO;
12069 int putativeHash = 0;
12070 int putativeNTrumbles = 0;
12071 NSArray *putativeTrumbleArray =
nil;
12073 NSString *namekey = [NSString stringWithFormat:@"%@-humbletrash", [
self commanderName]];
12075 [
self setUpTrumbles];
12079 BOOL possible_cheat = NO;
12085 if ([values
count] >= 1)
12086 putativeNTrumbles = [values oo_intAtIndex:0];
12087 if ([values
count] >= 2)
12088 putativeHash = [values oo_intAtIndex:1];
12089 if ([values
count] >= 3)
12090 putativeTrumbleArray = [values oo_arrayAtIndex:2];
12094 [
self mungChecksumWithNSString:[
self commanderName]];
12099 if (putativeHash != trumbleHash)
12104 OOLog(
@"cheat.tentative",
@"%@",
@"POSSIBLE CHEAT DETECTED");
12105 possible_cheat = YES;
12112 [
self mungChecksumWithNSString:[
self commanderName]];
12116 if (putativeHash == trumbleHash)
12119 putativeNTrumbles = i;
12123 if (possible_cheat && !info_failed)
12124 OOLog(
@"cheat.verified",
@"%@",
@"CHEAT DEFEATED - that's not the way to get rid of trumbles!");
12130 OOLog(
@"cheat.tentative",
@"%@",
@"POSSIBLE CHEAT DETECTED");
12134 if (info_failed && [[NSUserDefaults standardUserDefaults] objectForKey:namekey])
12137 putativeHash = (
int)[[NSUserDefaults standardUserDefaults] integerForKey:namekey];
12141 [
self mungChecksumWithNSString:[
self commanderName]];
12145 if (putativeHash == trumbleHash)
12148 putativeNTrumbles = i;
12153 OOLog(
@"cheat.verified",
@"%@",
@"CHEAT DEFEATED - that's not the way to get rid of trumbles!");
12161 [
trumble[i] setFromDictionary:[putativeTrumbleArray oo_dictionaryAtIndex:i]];
12165 [
self mungChecksumWithNSString:[
self commanderName]];
12170 [[NSUserDefaults standardUserDefaults] setInteger:trumbleHash forKey:namekey];
12180- (void) setTrumbleAppetiteAccumulator:(
float)value
12186- (void) mungChecksumWithNSString:(NSString *)str
12188 if (str ==
nil)
return;
12190 NSUInteger i, length = [str length];
12191 for (i = 0; i < length; i++)
12198- (NSString *) screenModeStringForWidth:(
unsigned)width height:(
unsigned)height refreshRate:(
float)refreshRate
12200 if (0.0f != refreshRate)
12202 return OOExpandKey(
@"gameoptions-fullscreen-with-refresh-rate", width, height, refreshRate);
12206 return OOExpandKey(
@"gameoptions-fullscreen", width, height);
12224- (void) setFoundTarget:(
Entity *) targetEntity
12228 if ([
self status] == STATUS_ESCAPE_SEQUENCE)
12232 [_foundTarget release];
12238- (void) addTarget:(
Entity *) targetEntity
12240 if ([
self status] != STATUS_IN_FLIGHT && [
self status] != STATUS_WITCHSPACE_COUNTDOWN)
return;
12241 if (targetEntity ==
self)
return;
12243 [
super addTarget:targetEntity];
12247 assert ([
self hasEquipmentItemProviding:
@"EQ_WORMHOLE_SCANNER"]);
12248 [
self addScannedWormhole:(WormholeEntity*)targetEntity];
12251 else if ([
self hasEquipmentItemProviding:
@"EQ_TARGET_MEMORY"] && targetEntity !=
nil)
12254 NSUInteger i = [target_memory indexOfObject:targetRef];
12256 if (i != NSNotFound)
12262 i = [target_memory indexOfObject:[NSNull null]];
12264 if (i != NSNotFound)
12266 [target_memory replaceObjectAtIndex:i withObject:targetRef];
12273 [target_memory replaceObjectAtIndex:target_memory_index withObject:targetRef];
12280 [
self playIdentLockedOn];
12281 [
self printIdentLockedOnForMissile:NO];
12288 [missile_entity[activeMissile] addTarget:targetEntity];
12289 [
self playMissileLockedOn];
12290 [
self printIdentLockedOnForMissile:YES];
12295 [
self playIdentLockedOn];
12296 [
self printIdentLockedOnForMissile:NO];
12304 NSUInteger memoryCount = [target_memory count];
12307 if (i < memoryCount)
12309 [target_memory replaceObjectAtIndex:i withObject:[NSNull null]];
12313 [target_memory addObject:[NSNull null]];
12325- (BOOL) moveTargetMemoryBy:(NSInteger)delta
12335 id targ_id = [target_memory objectAtIndex:target_memory_index];
12336 if ([targ_id isProxy])
12340 if ((potential_target)&&(potential_target->
isShip)&&([potential_target
isInSpace]))
12344 [
super addTarget:potential_target];
12349 [missile_entity[activeMissile] addTarget:potential_target];
12351 [
self printIdentLockedOnForMissile:YES];
12356 [
self playIdentLockedOn];
12357 [
self printIdentLockedOnForMissile:NO];
12363 [
self printIdentLockedOnForMissile:NO];
12365 [
self playTargetSwitched];
12371 [target_memory replaceObjectAtIndex:target_memory_index withObject:[NSNull null]];
12376 [
self playNoTargetInMemory];
12381- (void) printIdentLockedOnForMissile:(BOOL)missile
12385 NSString *fmt = missile ?
@"missile-locked-onto-target" :
@"ident-locked-onto-target";
12386 NSString *target = [[
self primaryTarget] identFromShip:self];
12387 [UNIVERSE addMessage:OOExpandKey(fmt, target) forCount:4.5];
12397- (void) setCustomViewQuaternion:(Quaternion)q
12400 [
self setCustomViewData];
12416- (void) setCustomViewOffset:(Vector) offset
12428- (void) setCustomViewRotationCenter:(Vector) center
12434- (void) customViewZoomIn:(
OOScalar) rate
12447- (void) customViewZoomOut:(
OOScalar) rate
12460- (void) customViewRotateLeft:(
OOScalar) angle
12465 [
self setCustomViewData];
12472- (void) customViewRotateRight:(
OOScalar) angle
12477 [
self setCustomViewData];
12484- (void) customViewRotateUp:(
OOScalar) angle
12489 [
self setCustomViewData];
12496- (void) customViewRotateDown:(
OOScalar) angle
12501 [
self setCustomViewData];
12508- (void) customViewRollRight:(
OOScalar) angle
12513 [
self setCustomViewData];
12520- (void) customViewRollLeft:(
OOScalar) angle
12525 [
self setCustomViewData];
12532- (void) customViewPanUp:(
OOScalar) angle
12535 [
self setCustomViewData];
12540- (void) customViewPanDown:(
OOScalar) angle
12543 [
self setCustomViewData];
12548- (void) customViewPanLeft:(
OOScalar) angle
12551 [
self setCustomViewData];
12556- (void) customViewPanRight:(
OOScalar) angle
12559 [
self setCustomViewData];
12590 [
self setCustomViewDataFromDictionary:[_customViews oo_dictionaryAtIndex:_customViewIndex] withScaling:NO];
12605- (void) setCustomViewDataFromDictionary:(NSDictionary *)viewDict withScaling:(BOOL)withScaling
12609 if (viewDict ==
nil)
return;
12612 [
self setCustomViewData];
12627 NSString *facing = [[viewDict oo_stringForKey:@"weapon_facing"] lowercaseString];
12628 if ([facing isEqual:
@"aft"])
12632 else if ([facing isEqual:
@"port"])
12636 else if ([facing isEqual:
@"starboard"])
12640 else if ([facing isEqual:
@"forward"])
12663 NSDictionary *result = [
self missionOverlayDescriptor];
12668 result = [UNIVERSE screenTextureDescriptorForKey:@"mission_overlay_no_title"];
12672 result = [UNIVERSE screenTextureDescriptorForKey:@"mission_overlay_with_title"];
12680- (void) setMissionOverlayDescriptor:(NSDictionary *)descriptor
12684 [_missionOverlayDescriptor autorelease];
12698 NSDictionary *result = [
self missionBackgroundDescriptor];
12701 result = [UNIVERSE screenTextureDescriptorForKey:@"mission"];
12708- (void) setMissionBackgroundDescriptor:(NSDictionary *)descriptor
12712 [_missionBackgroundDescriptor autorelease];
12724- (void) setMissionBackgroundSpecial:(NSString *)special
12726 if (special ==
nil) {
12729 else if ([special isEqualToString:
@"SHORT_RANGE_CHART"])
12733 else if ([special isEqualToString:
@"SHORT_RANGE_CHART_SHORTEST"])
12735 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12744 else if ([special isEqualToString:
@"SHORT_RANGE_CHART_QUICKEST"])
12746 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12755 else if ([special isEqualToString:
@"CUSTOM_CHART"])
12759 else if ([special isEqualToString:
@"CUSTOM_CHART_SHORTEST"])
12761 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12770 else if ([special isEqualToString:
@"CUSTOM_CHART_QUICKEST"])
12772 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12781 else if ([special isEqualToString:
@"LONG_RANGE_CHART"])
12785 else if ([special isEqualToString:
@"LONG_RANGE_CHART_SHORTEST"])
12787 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12796 else if ([special isEqualToString:
@"LONG_RANGE_CHART_QUICKEST"])
12798 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12832- (void) setEquipScreenBackgroundDescriptor:(NSDictionary *)descriptor
12836 [_equipScreenBackgroundDescriptor autorelease];
12850 return [worldScripts allKeys];
12856 return [[worldScripts copy] autorelease];
12860- (
OOScript *) commodityScriptNamed:(NSString *)scriptName
12862 if (scriptName ==
nil)
12872 if (cscript !=
nil)
12875 [commodityScripts setObject:cscript forKey:scriptName];
12879 OOLog(
@"script.commodityScript.load",
@"Could not load script %@",scriptName);
12885- (void) doScriptEvent:(jsid)message inContext:(JSContext *)context withArguments:(jsval *)argv count:(uintN)argc
12887 [
super doScriptEvent:message inContext:context withArguments:argv count:argc];
12888 [
self doWorldScriptEvent:message inContext:context withArguments:argv count:argc timeLimit:0.0];
12892- (BOOL) doWorldEventUntilMissionScreen:(jsid)message
12894 NSEnumerator *scriptEnum = [worldScripts objectEnumerator];
12900 [
self setGuiToDockingReportScreen];
12901 [[UNIVERSE messageGUI] clear];
12906 while ((theScript = [scriptEnum nextObject]) &&
gui_screen != GUI_SCREEN_MISSION && [
self isDocked])
12915 [[UNIVERSE messageGUI] clear];
12923- (void) doWorldScriptEvent:(jsid)message inContext:(JSContext *)context withArguments:(jsval *)argv count:(uintN)argc timeLimit:(
OOTimeDelta)limit
12927 NSEnumerator *scriptEnum =
nil;
12930 for (scriptEnum = [
worldScripts objectEnumerator]; (theScript = [scriptEnum nextObject]); )
12954- (void) setGalacticHyperspaceFixedCoords:(NSPoint)point
12956 return [
self setGalacticHyperspaceFixedCoordsX:OOClamp_0_max_f(round(point.x), 255.0f) y:OOClamp_0_max_f(round(point.y), 255.0f)];
12960- (void) setGalacticHyperspaceFixedCoordsX:(
unsigned char)x y:(
unsigned char)y
12973- (void) setWitchspaceCountdown:(
int)spin_time
12996- (void) setScoopOverride:(BOOL)newValue
13003#if MASS_DEPENDENT_FUEL_PRICES
13006 GLfloat rate = 1.0;
13008 rate = [
super fuelChargeRate];
13036- (void) setJumpCause:(NSString *)value
13038 NSParameterAssert(value !=
nil);
13039 [_jumpCause autorelease];
13056- (void) setCommanderName:(NSString *)value
13058 NSParameterAssert(value !=
nil);
13059 [_commanderName autorelease];
13064- (void) setLastsaveName:(NSString *)value
13066 NSParameterAssert(value !=
nil);
13067 [_lastsaveName autorelease];
13074 BOOL isDockedStatus = NO;
13078 case STATUS_DOCKED:
13079 case STATUS_DOCKING:
13080 case STATUS_START_GAME:
13081 isDockedStatus = YES;
13084 case STATUS_RESTART_GAME:
13086 case STATUS_EFFECT:
13087 case STATUS_ACTIVE:
13088 case STATUS_COCKPIT_DISPLAY:
13090 case STATUS_INACTIVE:
13092 case STATUS_IN_FLIGHT:
13093 case STATUS_AUTOPILOT_ENGAGED:
13094 case STATUS_LAUNCHING:
13095 case STATUS_WITCHSPACE_COUNTDOWN:
13096 case STATUS_ENTERING_WITCHSPACE:
13097 case STATUS_EXITING_WITCHSPACE:
13098 case STATUS_ESCAPE_SEQUENCE:
13099 case STATUS_IN_HOLD:
13100 case STATUS_BEING_SCOOPED:
13101 case STATUS_HANDLING_ERROR:
13108 if (isDockedStatus)
13114 [
self setStatus:STATUS_IN_FLIGHT];
13115 isDockedStatus = NO;
13123 [
self setStatus:STATUS_DOCKED];
13124 isDockedStatus = YES;
13129 return isDockedStatus;
13176 amountToPay =
MIN(maximumFine, calculatedFine);
13178 [
self addMessageToReport:[NSString stringWithFormat:DESC(@"station-docking-clearance-fined-@-cr"), OOCredits(amountToPay)]];
13188 assert(whole !=
nil);
13191 NSEnumerator *wormholes = [scannedWormholes objectEnumerator];
13193 while ((wh = [wormholes nextObject]))
13195 if (wh == whole)
return;
13198 [scannedWormholes addObject:whole];
13211 double now = [
self clockTimeAdjusted];
13213 NSMutableArray * savedWormholes = [[NSMutableArray alloc] initWithCapacity:[scannedWormholes count]];
13214 NSEnumerator * wormholes = [scannedWormholes objectEnumerator];
13221 if ([wh arrivalTime] > now)
13223 [savedWormholes addObject:wh];
13228 if ([[wh shipsInTransit]
count] > 0)
13230 [savedWormholes addObject:wh];
13236 [scannedWormholes release];
13243 return [NSArray arrayWithArray:scannedWormholes];
13247- (void) initialiseMissionDestinations:(NSDictionary *)destinations andLegacy:(NSArray *)legacy
13249 NSEnumerator *keyEnum =
nil;
13250 NSString *key =
nil;
13255 [missionDestinations release];
13258 for (keyEnum = [destinations keyEnumerator]; (key = [keyEnum nextObject]); )
13260 value = [destinations objectForKey:key];
13263 if ([value isKindOfClass:[NSDictionary
class]])
13265 value = [value mutableCopy];
13266 [missionDestinations setObject:value forKey:key];
13275 NSNumber *legacyMarker;
13276 for (keyEnum = [legacy objectEnumerator]; (legacyMarker = [keyEnum nextObject]); )
13278 dest = [legacyMarker intValue];
13279 [
self addMissionDestinationMarker:[
self defaultMarker:dest]];
13286- (NSString *)markerKey:(NSDictionary *)marker
13288 return [NSString stringWithFormat:@"%d-%@",[marker oo_intForKey:@"system"], [marker oo_stringForKey:@"name"]];
13292- (void) addMissionDestinationMarker:(NSDictionary *)marker
13294 NSDictionary *validated = [
self validatedMarker:marker];
13295 if (validated ==
nil)
13300 [missionDestinations setObject:validated forKey:[
self markerKey:validated]];
13304- (BOOL) removeMissionDestinationMarker:(NSDictionary *)marker
13306 NSDictionary *validated = [
self validatedMarker:marker];
13307 if (validated ==
nil)
13315 [missionDestinations removeObjectForKey:[
self markerKey:validated]];
13332- (void) setLastShot:(NSArray *)shot
13340 [extraMissionKeys release];
13345- (void) setExtraMissionKeys:(NSDictionary *)keys
13347 NSString *key =
nil;
13348 NSMutableDictionary *
final = [[NSMutableDictionary alloc] init];
13349 foreach (key, [keys allKeys])
13351 [final setObject:[
self processKeyCode:[keys oo_arrayForKey:key]] forKey:key];
13358- (void) clearExtraGuiScreenKeys:(
OOGUIScreenID)gui key:(NSString *)key
13360 NSMutableArray *keydefs = [extraGuiScreenKeys objectForKey:[NSString stringWithFormat:@"%d",gui]];
13361 NSInteger i = [keydefs count];
13362 NSDictionary *def =
nil;
13365 def = [keydefs objectAtIndex:i];
13366 if (def && [[def oo_stringForKey:
@"name"] isEqualToString:key])
13368 [keydefs removeObjectAtIndex:i];
13380 NSMutableArray *newarray =
nil;
13381 NSString *key =
nil;
13382 NSMutableDictionary *
final = [[NSMutableDictionary alloc] init];
13384 NSMutableArray *checklist = [[NSMutableArray alloc] init];
13386 foreach (key, [keys allKeys])
13388 NSArray *item = [
self processKeyCode:[keys oo_arrayForKey:key]];
13389 [checklist addObject:item];
13390 [final setObject:item forKey:key];
13404 newarray = [[NSMutableArray alloc] init];
13408 newarray = [[extraGuiScreenKeys objectForKey:[NSString stringWithFormat:@"%d",gui]] mutableCopy];
13409 NSInteger i = [newarray count];
13414 def_existing = [newarray objectAtIndex:i];
13416 if (def_existing && [[def_existing
name] isEqualToString:[definition
name]])
13418 [newarray removeObjectAtIndex:i];
13424 j = [checklist count];
13425 foreach (key, [keydefs allKeys])
13429 if ([[NSString stringWithFormat:
@"%@",[keydefs objectForKey:key]] isEqualToString:[NSString stringWithFormat:
@"%@",[checklist objectAtIndex:j]]])
13432 OOLog(
kOOLogException,
@"***** Exception in setExtraGuiScreenKeys: %@ : %@ (%@)",
@"invalid key settings",
@"key already in use", key);
13439 [newarray addObject:definition];
13441 if (result) [extraGuiScreenKeys setObject:[newarray mutableCopy] forKey:[NSString stringWithFormat:@"%d",gui]];
13442 [newarray release];
13450 NSMutableArray *flags =
nil;
13451 NSString *flagsString =
nil;
13453 [
super dumpSelfState];
13466 flags = [NSMutableArray array];
13467 #define ADD_FLAG_IF_SET(x) if (x) { [flags addObject:@#x]; }
13496 flagsString = [flags count] ? [flags componentsJoinedByString:@", "] : (NSString *)
@"none";
13497 OOLog(
@"dumpState.playerEntity",
@"Flags: %@", flagsString);
13623#if OO_FOV_INFLIGHT_CONTROL_ENABLED
13624 n_key_inc_field_of_view &&
13625 n_key_dec_field_of_view &&
13667 return NSOrderedAscending;
13669 else if (result > 0)
13671 return NSOrderedDescending;
13675 return NSOrderedSame;
13686 return NSOrderedAscending;
13688 else if (result > 0)
13690 return NSOrderedDescending;
13694 return NSOrderedSame;
13705 return NSOrderedAscending;
13707 else if (result > 0)
13709 return NSOrderedDescending;
13713 return NSOrderedSame;
BOOL shadowAtPointOcclusionToValue(HPVector e1pos, GLfloat e1rad, Entity *e2, OOSunEntity *the_sun, float *outValue)
NSString * OOStringFromEntityStatus(OOEntityStatus status) CONST_FUNC
#define SCANNER_MAX_RANGE
#define SCANNER_MAX_RANGE2
#define ADD_FLAG_IF_SET(x)
#define MINIMUM_GAME_TICK
static NSString *const kGuiEquipmentOptionColor
@ GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_QUICKEST
@ GUI_BACKGROUND_SPECIAL_SHORT_ANA_SHORTEST
@ GUI_BACKGROUND_SPECIAL_LONG
@ GUI_BACKGROUND_SPECIAL_LONG_ANA_SHORTEST
@ GUI_BACKGROUND_SPECIAL_SHORT
@ GUI_BACKGROUND_SPECIAL_NONE
@ GUI_BACKGROUND_SPECIAL_SHORT_ANA_QUICKEST
@ GUI_BACKGROUND_SPECIAL_LONG_ANA_QUICKEST
@ GUI_BACKGROUND_SPECIAL_CUSTOM
@ GUI_BACKGROUND_SPECIAL_CUSTOM_ANA_SHORTEST
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
OOINLINE jsval OOJSValueFromLegalStatusReason(JSContext *context, OOLegalStatusReason value)
OOINLINE jsval OOJSValueFromCompassMode(JSContext *context, OOCompassMode value)
OOINLINE jsval OOJSValueFromGUIScreenID(JSContext *context, OOGUIScreenID value)
NSString * EnergyUnitTypeToString(OOEnergyUnitType unit) CONST_FUNC
NSString * DisplayStringForMassUnit(OOMassUnit unit)
NSString * OOStringFromLegalStatusReason(OOLegalStatusReason reason)
const HPVector kZeroHPVector
#define OOJSStopTimeLimiter()
#define kOOJSLongTimeLimit
#define OOJSStartTimeLimiterWithTimeLimit(limit)
#define JS_IsInRequest(context)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
#define OOLogWARN(class, format,...)
#define OOLogERR(class, format,...)
NSString *const kOOLogException
NSString *const kOOLogInconsistentState
#define OOLog(class, format,...)
const OOMatrix kIdentityMatrix
OOMatrix OOMatrixForQuaternionRotation(Quaternion orientation)
Vector vector_up_from_quaternion(Quaternion quat)
void quaternion_rotate_about_x(Quaternion *quat, OOScalar angle)
HPVector HPvector_forward_from_quaternion(Quaternion quat)
Vector vector_right_from_quaternion(Quaternion quat)
Vector vector_forward_from_quaternion(Quaternion quat)
void quaternion_rotate_about_z(Quaternion *quat, OOScalar angle)
void quaternion_set_random(Quaternion *quat)
Vector quaternion_rotate_vector(Quaternion q, Vector v)
const Quaternion kIdentityQuaternion
void quaternion_rotate_about_y(Quaternion *quat, OOScalar angle)
const Quaternion kZeroQuaternion
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle)
#define OOExpandKey(key,...)
#define OOExpandKeyWithSeed(seed, key,...)
#define OOExpand(string,...)
NSString * ClockToString(double clock, BOOL adjusting)
OOINLINE NSString * OOCredits(OOCreditsQuantity tenthsOfCredits)
NSPoint PointFromString(NSString *xyString)
NSMutableArray * ScanTokensFromString(NSString *values)
NSString * OOPadStringToEms(NSString *string, float numEms)
#define OO_GALAXIES_AVAILABLE
@ OO_SYSTEMCONCEALMENT_NODATA
@ OO_SYSTEMCONCEALMENT_NONAME
#define OO_SYSTEMS_PER_GALAXY
uint8_t OOWeaponFacingSet
NSString * OOCommodityType
@ AEGIS_CLOSE_TO_MAIN_PLANET
uint64_t OOCreditsQuantity
#define VALID_WEAPON_FACINGS
@ DOCKING_CLEARANCE_STATUS_NOT_REQUIRED
@ DOCKING_CLEARANCE_STATUS_GRANTED
@ DOCKING_CLEARANCE_STATUS_NONE
@ DOCKING_CLEARANCE_STATUS_REQUESTED
@ WEAPON_FACING_STARBOARD
@ ENERGY_UNIT_NAVAL_DAMAGED
@ ENERGY_UNIT_NORMAL_DAMAGED
OOCreditsQuantity OODeciCreditsFromObject(id object)
OOGalacticHyperspaceBehaviour
@ GALACTIC_HYPERSPACE_MAX
#define MAX_KILOGRAMS_IN_SAFE
@ GUI_ROW_EQUIPMENT_DETAIL
@ GUI_ROW_EQUIPMENT_START
@ GUI_ROW_INTERFACES_START
@ GUI_MAX_ROWS_INTERFACES
#define PLAYER_STARTING_MISSILES
@ PLAYER_FLEEING_UNLIKELY
#define ESCAPE_SEQUENCE_TIME
#define CUSTOM_VIEW_MAX_ZOOM_IN
@ OOPRIMEDEQUIP_ACTIVATED
#define CHART_WIDTH_AT_MAX_ZOOM
#define PLAYER_MAX_WEAPON_TEMP
#define PORT_FACING_STRING
#define PLAYER_INTERNAL_DAMAGE_FACTOR
@ MARKET_FILTER_MODE_HOLD
@ MARKET_FILTER_MODE_RESTRICTED
@ MARKET_FILTER_MODE_STOCK
@ MARKET_FILTER_MODE_TRADE
@ MARKET_FILTER_MODE_LEGAL
#define MAX_GRAMS_IN_SAFE
#define CUSTOMEQUIP_KEYACTIVATE
#define HYPERSPEED_FACTOR
#define KILOGRAMS_PER_POD
#define PLAYER_DIAL_MAX_ALTITUDE
#define MAX_HYPERSPEED_FACTOR
#define FORWARD_FACING_STRING
#define AFT_FACING_STRING
#define GUI_ROW_INIT(GUI)
@ SCOOP_STATUS_NOT_INSTALLED
#define CHART_HEIGHT_AT_MAX_ZOOM
#define CUSTOM_VIEW_MAX_ZOOM_OUT
#define MIN_HYPERSPEED_FACTOR
#define GUI_ROW(GROUP, ITEM)
#define STARBOARD_FACING_STRING
#define CUSTOMEQUIP_EQUIPKEY
#define CHART_SCROLL_AT_Y
#define SCANNER_ECM_FUZZINESS
@ ALERT_FLAG_YELLOW_LIMIT
#define CHART_SCROLL_AT_X
#define CUSTOMEQUIP_KEYMODE
#define SCRIPT_TIMER_INTERVAL
#define PLAYER_DOCKING_AI_NAME
@ MISSILE_STATUS_TARGET_LOCKED
@ MARKET_SORTER_MODE_PRICE
@ MARKET_SORTER_MODE_STOCK
@ MARKET_SORTER_MODE_ALPHA
@ MARKET_SORTER_MODE_UNIT
@ MARKET_SORTER_MODE_HOLD
#define ECM_ENERGY_DRAIN_FACTOR
NSString * OODisplayStringFromLegalStatus(int legalStatus)
#define GUI_FIRST_ROW(GROUP)
NSString * KillCountToRatingAndKillString(unsigned kills)
#define PLAYER_SHIP_CLOCK_START
#define PLAYER_TARGET_MEMORY_SIZE
#define PLAYER_STARTING_MAX_MISSILES
#define PLAYER_MAX_TRUMBLES
#define PLAYER_MAX_MISSILES
static NSString *const kOOLogBuyMountedOK
static NSString *const kOOLogBuyMountedFailed
#define VELOCITY_CLEANUP_MIN
#define STAGE_TRACKING_END
NSComparisonResult marketSorterByName(id a, id b, void *market)
NSComparisonResult marketSorterByPrice(id a, id b, void *market)
NSComparisonResult marketSorterByQuantity(id a, id b, void *market)
static NSString * last_outfitting_key
static float const kDeadResetTime
#define VELOCITY_CLEANUP_RATE
#define STAGE_TRACKING_BEGIN
NSComparisonResult marketSorterByMassUnit(id a, id b, void *market)
#define VELOCITY_CLEANUP_FULL
#define OO_SETACCESSCONDITIONFORROW(condition, row)
#define SCENARIO_OXP_DEFINITION_NONE
#define SCENARIO_OXP_DEFINITION_ALL
#define MIN_HDR_PAPERWHITE
#define MAX_HDR_PAPERWHITE
#define INITIAL_SHOT_TIME
BOOL isWeaponNone(OOWeaponType weapon)
#define SHIP_COOLING_FACTOR
#define CLOAKING_DEVICE_MIN_ENERGY
OOWeaponType OOWeaponTypeFromEquipmentIdentifierStrict(NSString *string) PURE_FUNC
#define ShipScriptEventNoCx(ship, event,...)
#define ENTITY_PERSONALITY_INVALID
OOWeaponType OOWeaponTypeFromEquipmentIdentifierLegacy(NSString *string)
#define SHIP_MIN_CABIN_TEMP
#define MILITARY_JAMMER_ENERGY_RATE
#define CLOAKING_DEVICE_ENERGY_RATE
#define WEAPON_COOLING_FACTOR
#define SHIP_MAX_CABIN_TEMP
#define MILITARY_JAMMER_MIN_ENERGY
NSString * OOStringFromShipDamageType(OOShipDamageType type) CONST_FUNC
NSString * OODisplayStringFromAlertCondition(OOAlertCondition alertCondition)
OOWeaponType OOWeaponTypeFromEquipmentIdentifierSloppy(NSString *string) PURE_FUNC
#define BASELINE_SHIELD_LEVEL
#define SHIP_THRUST_FACTOR
#define ShipScriptEvent(context, ship, event,...)
#define WEAPON_COOLING_CUTOUT
#define SHIP_INSULATION_FACTOR
#define SHIP_ENERGY_DAMAGE_TO_HEAT_FACTOR
#define PASSENGER_BERTH_SPACE
@ WH_SCANINFO_ARRIVAL_TIME
@ WH_SCANINFO_DESTINATION
@ WH_SCANINFO_COLLAPSE_TIME
void updateAlertConditionForNearbyEntities()
void showMarketCashAndLoadLine()
void updateMovementFlags()
void setExtraEquipmentFromFlags()
void showMarketScreenHeaders()
OOFuelQuantity fuelRequiredForJump()
void checkScriptsIfAppropriate()
void noteCompassLostTarget()
void updateAlertCondition()
double hyperspaceJumpDistance()
void setNextThinkTime:(OOTimeAbsolute ntt)
void setOwner:(ShipEntity *ship)
void setState:(NSString *stateName)
OOUniversalID universalID
HPVector absolutePositionForSubentity()
void setVelocity:(Vector vel)
void setOrientation:(Quaternion quat)
GLfloat collisionRadius()
void setScanClass:(OOScanClass sClass)
GLfloat distanceTravelled
void setPositionX:y:z:(OOHPScalar x,[y] OOHPScalar y,[z] OOHPScalar z)
Quaternion lastOrientation
Vector relativePosition()
void setPosition:(HPVector posn)
NSString * playerFileToLoad
GameController * sharedController()
void stopAnimationTimer()
void logProgress:(NSString *message)
void startAnimationTimer()
NSUInteger indexOfCurrentDisplayMode()
BOOL setBackgroundTextureKey:(NSString *key)
OOColor * colorFromSetting:defaultValue:(NSString *setting,[defaultValue] OOColor *def)
BOOL setSelectedRow:(OOGUIRow row)
OOGUIRow addLongText:startingAtRow:align:(NSString *str,[startingAtRow] OOGUIRow row,[align] OOGUIAlignment alignment)
BOOL setForegroundTextureKey:(NSString *key)
void setStatusPage:(NSInteger pageNum)
NSString * selectedRowText()
void setText:forRow:(NSString *str,[forRow] OOGUIRow row)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void clearAndKeepBackground:(BOOL keepBackground)
BOOL setForegroundTextureDescriptor:(NSDictionary *descriptor)
void overrideTabs:from:length:(OOGUITabSettings stops,[from] NSString *setting,[length] NSUInteger len)
NSDictionary * userSettings()
void setSelectableRange:(NSRange range)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
NSString * selectedRowKey()
void setTitle:(NSString *str)
void setTabStops:(OOGUITabSettings stops)
NSString * keyForRow:(OOGUIRow row)
void setShowTextCursor:(BOOL yesno)
void setCurrentRow:(OOGUIRow value)
BOOL setBackgroundTextureDescriptor:(NSDictionary *descriptor)
void setArray:forRow:(NSArray *arr,[forRow] OOGUIRow row)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
BOOL isRunningOnPrimaryDisplayDevice()
float fov:(BOOL inFraction)
void adjustColorSaturation:(float colorSaturationAdjustment)
void setMouseWheelDelta:(float newWheelDelta)
GameController * gameController
OOCacheManager * sharedCache()
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
OOColor * colorWithDescription:(id description)
OOCommodityType legacyCommodityType:(NSUInteger i)
NSUInteger exportLegalityForGood:(OOCommodityType good)
OOMassUnit massUnitForGood:(OOCommodityType good)
NSUInteger importLegalityForGood:(OOCommodityType good)
BOOL removeQuantity:forGood:(OOCargoQuantity quantity,[forGood] OOCommodityType good)
OOCargoQuantity capacityForGood:(OOCommodityType good)
BOOL setQuantity:forGood:(OOCargoQuantity quantity,[forGood] OOCommodityType good)
OOCargoQuantity quantityForGood:(OOCommodityType good)
BOOL addQuantity:forGood:(OOCargoQuantity quantity,[forGood] OOCommodityType good)
OOCreditsQuantity priceForGood:(OOCommodityType good)
NSString * nameForGood:(OOCommodityType good)
NSString * conditionScript()
NSString * damagedIdentifier()
NSArray * defaultActivateKey()
NSArray * defaultModeKey()
OOTechLevelID effectiveTechLevel()
OOCargoQuantity requiredCargoSpace()
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
OOCreditsQuantity price()
NSString * descriptiveText()
void setRegisterKeys:(NSDictionary *registerKeys)
NSDictionary * registerKeys()
void runCallback:(NSString *key)
BOOL callMethod:inContext:withArguments:count:result:(jsid methodID,[inContext] JSContext *context,[withArguments] jsval *argv,[count] intN argc,[result] jsval *outResult)
OOJavaScriptEngine * sharedEngine()
void garbageCollectionOpportunity:(BOOL force)
void update:(OOTimeDelta delta_t)
OOMusicController * sharedController()
OOOXZManager * sharedManager()
id jsScriptFromFileNamed:properties:(NSString *fileName,[properties] NSDictionary *properties)
BOOL callMethod:inContext:withArguments:count:result:(jsid methodID,[inContext] JSContext *context,[withArguments] jsval *argv,[count] intN argc,[result] jsval *outResult)
NSDictionary * shipyardInfoForKey:(NSString *key)
OOShipRegistry * sharedRegistry()
NSDictionary * shipInfoForKey:(NSString *key)
void spawnFrom:(OOTrumble *parentTrumble)
void updateTrumble:(double delta_t)
OOWeakReference * weakSelf
OOWeaponFacingSet availableFacings()
NSMutableDictionary * roleWeightFlags
OOTimeDelta forward_shot_time
NSMutableDictionary * passenger_record
NSArray * n_key_activate_equipment
void setGuiToSystemDataScreen()
unsigned mouse_control_on
NSString * dial_fpsinfo()
OOWeaponType currentWeapon()
OOScalar saved_chart_zoom
unsigned launchingMissile
NSDictionary * keyconfig2_settings
NSArray * n_key_gui_screen_interfaces
OOSystemID info_system_id
NSArray * n_key_gui_arrow_right
NSArray * n_key_scanner_zoom
NSArray * n_key_debug_shaders
unsigned autopilot_engaged
Vector viewpointOffsetAft()
NSDictionary * keyConfig()
NSArray * n_key_next_target
NSArray * n_key_docking_clearance_request
OOEnergyUnitType installedEnergyUnitType()
BOOL hasSufficientFuelForJump()
void setNextCompassMode()
void setGuiToLongRangeChartScreen()
float _trumbleAppetiteAccumulator
NSMutableDictionary * missionDestinations
NSArray * n_key_market_buy_max
void setGuiToLoadSaveScreen()
NSArray * n_key_rotate_cargo
NSArray * n_key_custom_view_rotate_left
NSArray * n_key_untarget_missile
ShipEntity * launchEscapeCapsule()
NSArray * n_key_gui_screen_status
void activateSelectedInterface()
StickProfileScreen * stickProfileScreen
void setGuiToMarketScreen()
void setGuiToGameOptionsScreen()
NSArray * n_key_oxzmanager_extract
OODockingClearanceStatus getDockingClearanceStatus()
GLfloat max_forward_shield
NSDictionary * equipScreenBackgroundDescriptor()
void deactivateCloakingDevice()
OOMarketSorterMode marketSorterMode
NSArray * n_key_map_next_system
NSArray * n_key_custom_view_pan_left
OOCargoQuantity current_cargo
NSArray * n_key_info_next_system
NSString * commanderName()
StationEntity * getTargetDockStation()
Vector starboardViewOffset
GLfloat laserHeatLevelForward()
OOPlayerFleeingStatus fleeing_status
NSArray * n_key_yaw_right
void updateMovementFlags()
NSString * missionTitle()
NSArray * n_key_custom_view_pan_down
unsigned keyboardPitchOverride
NSDictionary * worldScriptsByName()
OOAlertCondition realAlertCondition()
OOMatrix drawRotationMatrix()
OOCreditsQuantity tradeInValue()
NSMutableArray * contracts
void checkScriptsIfAppropriate()
OODockingClearanceStatus dockingClearanceStatus
void enterGalacticWitchspace()
NSArray * n_key_view_forward
GLfloat forwardShieldLevel()
NSString * _missionScreenID
OOGUIScreenID missionExitScreen()
NSMutableDictionary * localVariables
BOOL _missionAllowInterrupt
float trumbleAppetiteAccumulator()
NSInteger missingSubEntitiesAdjustment()
NSArray * n_key_debug_off
void showMarketCashAndLoadLine()
NSArray * n_key_galactic_hyperspace
NSArray * n_key_autopilot
NSArray * parcelListForScripting()
double renovationFactor()
NSArray * n_key_weapons_online_toggle
OOSystemID previousSystemID()
void setPrevCompassMode()
OOWeakReference * _dockedStation
NSArray * n_key_pausebutton
void setGuiToStatusScreen()
Vector weaponViewOffset()
NSMutableDictionary * customDialSettings
NSArray * n_key_dump_target_state
OOWeakReference * compassTarget
unsigned waitingForStickCallback
double scannerFuzziness()
NSDictionary * _missionOverlayDescriptor
NSString * _fastEquipmentB
NSArray * n_key_gui_select
void noteCompassLostTarget()
NSArray * n_key_custom_view_zoom_out
NSArray * n_key_custom_view_roll_right
NSArray * n_key_dump_entity_list
NSMutableArray * roleSystemList
void setGuiToMarketInfoScreen()
NSMutableArray * cdrDetailArray
NSArray * n_key_market_buy_one
Vector viewpointOffsetStarboard()
OOLongRangeChartMode longRangeChartMode
NSArray * n_key_roll_right
NSUInteger passengerCount()
NSMutableDictionary * contract_record
unsigned travelling_at_hyperspeed
unsigned replacingMissile
StationEntity * dockedStation()
NSMutableString * dockingReport
NSArray * n_key_cycle_next_mfd
NSMutableArray * target_memory
OOMatrix drawTransformationMatrix()
unsigned hyperspeed_engaged
void updateAlertConditionForNearbyEntities()
void penaltyForUnauthorizedDocking()
NSArray * n_key_advanced_nav_array_previous
NSArray * n_key_gui_chart_screens
NSArray * n_key_system_previous_system
Quaternion normalOrientation()
OOSystemID previous_system_id
NSMutableArray * roleWeights
OOGUIScreenID _missionExitScreen
GLfloat laserHeatLevelPort()
NSPoint custom_chart_centre_coordinates
NSUInteger dialMaxMissiles()
NSArray * n_key_gui_arrow_up
GLfloat laserHeatLevelStarboard()
NSDictionary * commanderDataDictionary()
NSArray * n_key_debug_full
NSArray * n_key_gui_arrow_down
double escapePodRescueTime()
NSArray * n_key_custom_view
OOCreditsQuantity bounty()
void clearExtraMissionKeys()
OOMarketFilterMode marketFilterMode
OOTimeDelta witchspaceCountdown
NSMutableArray * passengers
NSString * commanderNameString
NSArray * n_key_gui_page_up
OOCreditsQuantity removeMissiles()
NSArray * n_key_prev_compass_mode
NSArray * worldScriptNames()
NSArray * n_key_jumpdrive
unsigned afterburnerSoundLooping
unsigned afterburner_engaged
NSString * compassTargetLabel()
NSDictionary * extraMissionKeys
NSArray * equipmentList()
OOCommodityMarket * shipCommodityData
NSArray * n_key_cycle_previous_mfd
NSMutableDictionary * shipyardRecord()
NSArray * n_key_market_sell_max
NSMutableDictionary * reputation
NSArray * n_key_bloom_toggle
NSPoint galaxy_coordinates
NSArray * n_key_roll_left
NSString * planetSearchString
NSArray * n_key_system_home
OOAlertCondition lastScriptAlertCondition
NSMutableDictionary * commodityScripts
NSArray * n_key_custom_view_zoom_in
NSArray * n_key_chart_highlight
NSDictionary * _equipScreenBackgroundDescriptor
NSArray * n_key_mode_equipment
BOOL suppressClangStuff()
OOTrumble * trumble[PLAYER_MAX_TRUMBLES]
OOSystemID currentSystemID()
NSString * dial_objinfo()
void showMarketScreenHeaders()
void calculateCurrentCargo()
NSArray * n_key_inject_fuel
float maxForwardShieldLevel()
void setupStartScreenGui()
NSArray * n_key_hyperspace
double escape_pod_rescue_time
NSArray * n_key_custom_view_rotate_up
NSArray * n_key_increase_speed
void updateAlertCondition()
unsigned keyboardYawOverride
NSArray * n_key_system_next_system
NSUInteger target_memory_index
void validateCustomEquipActivationArray()
BOOL takeInternalDamage()
NSArray * n_key_system_end
OOFuelScoopStatus dialFuelScoopStatus()
NSArray * n_key_debug_bounding_boxes
NSArray * n_key_market_sell_one
NSString * dialTargetName()
NSPoint target_chart_focus
Vector viewpointOffsetPort()
NSArray * n_key_custom_view_rotate_right
NSMutableDictionary * getMissionDestinations()
NSArray * n_key_market_sorter_cycle
NSArray * n_key_scanner_unzoom
NSArray * n_key_gui_arrow_left
void showInformationForSelectedInterface()
OOEnergyUnitType energyUnitType()
Quaternion customViewQuaternion
NSArray * n_key_view_starboard
NSMutableArray * targetMemory()
BOOL validForAddToUniverse()
OOScalar target_chart_zoom
NSString * fastEquipmentA()
Vector customViewRightVector
void setDefaultCustomViews()
ShipEntity * missile_entity[PLAYER_MAX_MISSILES]
BOOL activateCloakingDevice()
NSArray * n_key_pitch_back
OOCommodityType dumpCargo()
NSDictionary * worldScriptsRequiringTickle
NSMutableArray * customEquipmentActivation()
NSString * _commanderName
NSMutableDictionary * mission_variables
NSString * currentPrimedEquipment()
NSMutableDictionary * parcel_record
BOOL showingLongRangeChart
NSArray * multiFunctionDisplayList()
NSArray * n_key_mouse_control_roll
NSUInteger primedEquipmentCount()
OOGUIBackgroundSpecial missionBackgroundSpecial()
void previousInfoSystem()
NSArray * n_key_launch_ship
HPVector breakPatternPosition()
NSArray * n_key_gui_market
OOCreditsQuantity credits
NSDictionary * _missionBackgroundDescriptor
OOCargoQuantity cargoQuantityOnBoard()
NSArray * passengerListForScripting()
NSArray * n_key_launch_missile
OOTimeDelta aft_shot_time
OOGalacticHyperspaceBehaviour galacticHyperspaceBehaviour
NSPoint cursor_coordinates
NSArray * n_key_gui_system_data
static NSString * SliderString(NSInteger amountIn20ths)
NSArray * n_key_gui_screen_equipship
ShipEntity * fireMissile()
NSUInteger _customViewIndex
NSArray * n_key_debug_console_connect
NSMutableArray * eqScripts
NSArray * n_key_info_previous_system
GLfloat dialForwardShield()
void setDockedAtMainStation()
NSArray * n_key_custom_view_rotate_down
Vector viewpointOffsetForward()
unsigned keyboardRollOverride
NSDictionary * missionOverlayDescriptor()
void setDefaultViewOffsets()
OOTrumble ** trumbleArray()
NSArray * n_key_prime_next_equipment
void selectPreviousMultiFunctionDisplay()
OOSystemID infoSystemID()
void doGuiScreenResizeUpdates()
NSArray * n_key_custom_view_pan_up
NSArray * n_key_ident_system
GLfloat scanner_zoom_rate
OOSpeechSettings isSpeechOn
void setGuiToShortRangeChartScreen()
NSString * fastEquipmentB()
NSArray * n_key_oxzmanager_setfilter
OOUniversalID _dockTarget
NSArray * n_key_gui_page_down
OOScalar custom_chart_zoom
NSArray * n_key_decrease_speed
void currentWeaponStats()
double hyperspaceJumpDistance()
NSMutableDictionary * multiFunctionDisplayText
NSMutableArray * multiFunctionDisplaySettings
void setGuiToOXZManager()
NSArray * n_key_target_incoming_missile
NSArray * n_key_next_missile
OOMatrix customViewMatrix
NSString * lastsaveName()
NSArray * contractListForScripting()
OOMissileStatus dialMissileStatus()
NSString * _fastEquipmentA
void disengageAutopilot()
OOSystemID found_system_id
unsigned using_mining_laser
Vector customViewUpVector
NSArray * n_key_gui_screen_options
NSArray * n_key_prime_previous_equipment
NSArray * n_key_oxzmanager_showinfo
NSArray * cargoListForScripting()
NSArray * n_key_comms_log
unsigned hyperspeed_locked
NSUInteger passengerCapacity()
OOAlertCondition alertCondition
NSArray * n_key_view_port
NSArray * n_key_market_filter_cycle
void validateCompassTarget()
NSPoint galacticHyperspaceFixedCoords
NSDictionary * markedDestinations()
NSArray * n_key_target_missile
NSArray * n_key_map_zoom_out
NSArray * n_key_switch_next_mfd
OOTimeDelta starboard_shot_time
unsigned galactic_witchjump
NSArray * n_key_advanced_nav_array_next
float forwardShieldRechargeRate()
NSString * marketScreenTitle()
NSMutableDictionary * shipyard_record
NSUInteger maxPlayerRoles()
NSArray * n_key_pitch_forward
Vector customViewForwardVector
OOGUIScreenID guiScreen()
NSArray * n_key_fire_lasers
NSMutableArray * customModePressed
HPVector viewpointPosition()
float aftShieldRechargeRate()
NSDictionary * worldScripts
OOMissileStatus missile_status
OOPlayerFleeingStatus fleeingStatus()
float maxAftShieldLevel()
GLfloat forward_shield_recharge_rate
BOOL _missionWithCallback
WormholeEntity * wormhole
GLfloat insideAtmosphereFraction()
OOSystemID nextHopTargetSystemID()
NSArray * n_key_mouse_control_yaw
NSMutableArray * scannedWormholes
NSArray * n_key_fastactivate_equipment_b
NSArray * n_key_debug_collision
unsigned legalStatusOfCargoList()
NSMutableArray * customActivatePressed
double script_time_interval
NSArray * n_key_docking_music
OOCommodityType marketSelectedCommodity
NSArray * n_key_custom_view_pan_right
NSArray * n_key_dump_cargo
GLfloat laserHeatLevelAft()
NSPoint chart_focus_coordinates
NSDictionary * missionBackgroundDescriptorOrDefault()
NSArray * n_key_launch_escapepod
NSPoint target_chart_centre
void orientationChanged()
void showInformationForSelectedUpgrade()
OOFuelQuantity fuelRequiredForJump()
NSArray * n_key_custom_view_roll_left
NSMutableArray * customEquipActivation
GLfloat aft_shield_recharge_rate
OOTimeDelta port_shot_time
OOCompassMode compassMode
void selectNextMultiFunctionDisplay()
OOGUIBackgroundSpecial _missionBackgroundSpecial
void setGuiToEquipShipScreen:(int skip)
NSString * dial_clock_adjusted()
NSUInteger primedEquipment
NSArray * n_key_map_previous_system
NSDictionary * missionOverlayDescriptorOrDefault()
OOCommodityMarket * localMarket()
unsigned suppressTargetLost
NSMutableDictionary * extraGuiScreenKeys
unsigned ecm_in_operation
double clockTimeAdjusted()
NSArray * n_key_fastactivate_equipment_a
double last_fps_check_time
NSString * customViewDescription
NSArray * n_key_hud_toggle
OOSystemID target_system_id
NSArray * n_key_switch_previous_mfd
NSArray * n_key_previous_target
OOWeaponFacing chosen_weapon_facing
NSPoint chart_centre_coordinates
Vector customViewRotationCenter
ProxyPlayerEntity * createDoppelganger()
StationEntity * targetDockStation
NSArray * n_key_map_zoom_in
OOSystemID targetSystemID()
NSArray * currentLaserOffset()
NSDictionary * missionBackgroundDescriptor()
NSArray * n_key_next_compass_mode
void updateSystemMemory()
void copyValuesFromPlayer:(PlayerEntity *player)
NSDictionary * loadScripts()
NSArray * OXPsWithMessagesFound()
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)
BOOL isExplicitlyUnpiloted()
OOTimeAbsolute last_shot_time
void setDemoStartTime:(OOTimeAbsolute time)
void deserializeShipSubEntitiesFrom:(NSString *string)
void setDesiredSpeed:(double amount)
GLfloat scriptedMisjumpRange()
OOTimeAbsolute cargo_dump_time
OOWeaponFacing currentWeaponFacing
void setStatus:(OOEntityStatus stat)
GLfloat weapon_energy_use
void setRoll:(double amount)
void setThrust:(double amount)
GLfloat _scriptedMisjumpRange
void setSpeed:(double amount)
unsigned suppressAegisMessages
NSUInteger missileCount()
OOCargoQuantity availableCargoSpace()
void wasAddedToUniverse()
Entity * primaryAggressor()
OOWeaponType aft_weapon_type
BoundingBox totalBoundingBox
OOWeakReference * _primaryTarget
NSEnumerator * equipmentEnumerator()
OOFuelQuantity fuelCapacity()
OOEquipmentType * missile_list[SHIPENTITY_MAX_MISSILES]
BOOL hasMilitaryScannerFilter()
StationEntity * targetStation()
uint16_t entity_personality
GLfloat forward_weapon_temp
NSUInteger missileCapacity()
GLfloat starboard_weapon_temp
void setAITo:(NSString *aiString)
float energyRechargeRate()
NSEnumerator * shipSubEntityEnumerator()
void setPendingEscortCount:(uint8_t count)
OOWeaponType starboard_weapon_type
unsigned scripted_misjump
void setEntityPersonalityInt:(uint16_t value)
unsigned military_jammer_active
OOCargoQuantity commodityAmount()
GLfloat weapon_shot_temperature
OOCargoQuantity maxAvailableCargoSpace()
void update:(OOTimeDelta delta_t)
uint8_t pendingEscortCount()
void setTemperature:(GLfloat value)
OOWeaponType port_weapon_type
double maxHyperspaceDistance()
OOCargoQuantity max_cargo
void setDemoShip:(OOScalar demoRate)
void setBehaviour:(OOBehaviour cond)
NSUInteger maxShipSubEntities()
void switchAITo:(NSString *aiString)
BOOL hasHyperspaceMotor()
Triangle absoluteIJKForSubentity()
void setCommodity:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)
OOWeaponType forward_weapon_type
unsigned cloaking_device_active
OOCargoQuantity extra_cargo
NSMutableArray * subEntities
OOCommodityType commodityType()
void setOwner:(Entity *who_owns_entity)
BoundingBox findSubentityBoundingBox()
BOOL hasExpandedCargoBay()
OOWeakReference * _foundTarget
OOCommodityMarket * localMarket
OOCommodityMarket * initialiseLocalMarket()
void autoDockShipsOnApproach()
OOCreditsQuantity legalStatusOfManifest:export:(OOCommodityMarket *manifest,[export] BOOL export)
void launchShip:(ShipEntity *ship)
NSString * acceptDockingClearanceRequestFrom:(ShipEntity *other)
OOTechLevelID equivalentTechLevel
void noteDockedShip:(ShipEntity *ship)
float equipmentPriceFactor
void clearDockingCorridor()
double estimatedArrivalTime()
void setMisjumpWithRange:(GLfloat range)
void setScannedAt:(double time)
void setScanInfo:(WORMHOLE_SCANINFO scanInfo)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
RANROTSeed RANROTGetFullSeed(void)
void setRandomSeed(RNG_Seed a_seed)
int16_t munge_checksum(long long value_)
RNG_Seed currentRandomSeed(void)
void RANROTSetFullSeed(RANROTSeed seed)
double cunningFee(double value, double precision)
OOINLINE double distanceBetweenPlanetPositions(int x1, int y1, int x2, int y2) INLINE_CONST_FUNC