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
2729 static BOOL gettingInterference = NO;
2732 double external_temp = 0;
2733 GLfloat air_friction = 0.0f;
2734 air_friction = 0.5f * [UNIVERSE airResistanceFactor];
2735 if (air_friction < 0.005f)
2741 UPDATE_STAGE(
@"updating weapon temperatures and shot times");
2786 [
self deactivateCloakingDevice];
2817 [UNIVERSE addMessage:DESC(@"ecm-out-of-juice") forCount:3.0];
2832 if (!gettingInterference)
2834 [UNIVERSE setCurrentPostFX:OO_POSTFX_CRTBADSIGNAL];
2835 gettingInterference = YES;
2840 if (gettingInterference)
2842 [UNIVERSE terminatePostFX:OO_POSTFX_CRTBADSIGNAL];
2843 gettingInterference = NO;
2861 float fwdMax = [
self maxForwardShieldLevel];
2862 float aftMax = [
self maxAftShieldLevel];
2863 float shieldRechargeFwd = [
self forwardShieldRechargeRate] * delta_t;
2864 float shieldRechargeAft = [
self aftShieldRechargeRate] * delta_t;
2874 float rechargeAft =
MIN(shieldRechargeAft, aftMax -
aft_shield);
2880 float energyForShields =
energy;
2884 float minEnergyBankLevel = [[UNIVERSE globalSettings] oo_floatForKey:@"shield_charge_energybank_threshold" defaultValue:0.25];
2890 rechargeFwd =
MIN(rechargeFwd, energyForShields);
2891 rechargeAft =
MIN(rechargeAft, energyForShields - rechargeFwd);
2895 rechargeAft =
MIN(rechargeAft, energyForShields);
2896 rechargeFwd =
MIN(rechargeFwd, energyForShields - rechargeAft);
2902 energy -= rechargeFwd + rechargeAft;
2915 double alt1 = sun_cr * sun_cr / sun_zd;
2919 external_temp *= 100;
2921 if ([sun willGoNova])
2932 [
self setFuel:[
self fuel] + 1];
2934 [
self doScriptEvent:OOJSID("shipScoopedFuel")];
2936 [UNIVERSE displayCountdownMessage:DESC(@"fuel-scoop-active") forCount:1.0];
2942 if ((
status != STATUS_ESCAPE_SEQUENCE) && (
status != STATUS_ENTERING_WITCHSPACE))
2961 [
self takeHeatDamage: delta_t * ship_temperature];
2969 [
self setBounty:0 withReason:kOOLegalStatusReasonEscapePod];
2974 [
self doScriptEvent:OOJSID("escapePodSequenceOver")];
2983 [UNIVERSE setSystemTo:system_id];
2986 [UNIVERSE setUpSpace];
2988 [UNIVERSE populateNormalSpace];
2990 [
self setDockTarget:[UNIVERSE station]];
2993 [UNIVERSE setWitchspaceBreakPattern:YES];
2994 [
self doScriptEvent:OOJSID("shipWillExitWitchspace")];
2995 [
self doScriptEvent:OOJSID("shipExitedWitchspace")];
2997 [[UNIVERSE planet] update: 2.34375 * market_rnd];
2998 [[UNIVERSE station] update: 2.34375 * market_rnd];
3001 Entity *dockTargetEntity = [UNIVERSE entityForUniversalID:_dockTarget];
3006 ShipEntity *player_ship = [UNIVERSE newShipWithName:[
self shipDataKey]];
3010 [
self setMesh:[player_ship
mesh]];
3011 [player_ship release];
3013 [UNIVERSE setViewDirection:VIEW_FORWARD];
3014 [UNIVERSE setBlockJSPlayerShipProps:NO];
3015 [
self enterDock:(StationEntity *)dockTargetEntity];
3019 [
self setStatus:STATUS_DEAD];
3022 [UNIVERSE displayMessage:DESC(@"gameoverscreen-escape-pod") forCount:kDeadResetTime];
3023 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
3024 [
self showGameOver];
3048 [
self playJumpMassLocked];
3049 [UNIVERSE addMessage:DESC(@"jump-mass-locked") forCount:4.5];
3059 float abFactor = [
self afterburnerFactor];
3064 flightSpeed -= (float)(speed_delta * delta_t * abFactor);
3069 flightSpeed += (float)(speed_delta * delta_t * abFactor);
3125 double z = [hud scannerZoom];
3129 if (floor(z1) > floor(z))
3143 [hud setScannerZoom:z1];
3146 [[UNIVERSE gameView] setFov:fieldOfView fromFraction:YES];
3149 ShipEntity *primeTarget = [
self primaryTarget];
3152 [UNIVERSE addMessage:DESC(@"target-lost") forCount:3.0];
3153 [
self removeTarget:primeTarget];
3156 [
self validateCompassTarget];
3188 if (mouseWheelDelta > 0.0f)
3193 else if (mouseWheelDelta < 0.0f)
3216 [
self clearAlertFlags];
3221 int i, ent_count =
UNIVERSE->n_entities;
3223 Entity *my_entities[ent_count];
3225 for (i = 0; i < ent_count; i++)
3227 my_entities[i] = [uni_entities[i] retain];
3230 BOOL foundHostiles = NO;
3231#if OO_VARIABLE_TORUS_SPEED
3232 BOOL needHyperspeedNearest = YES;
3233 double hsnDistance = 0;
3235 for (i = 0; i < ent_count; i++)
3237 scannedEntity = my_entities[i];
3239#if OO_VARIABLE_TORUS_SPEED
3243 if (scannedEntity !=
self && [scannedEntity
canCollide] && (![scannedEntity
isShip] || ![
self collisionExceptedFor:(
ShipEntity *) scannedEntity]))
3246 needHyperspeedNearest = NO;
3255 if (thisHSN < hsnDistance)
3257 hsnDistance = thisHSN;
3264 int theirClass = [scannedEntity scanClass];
3268 if ([self massLockable] )
3270 massLocked |= [self checkEntityForMassLock:scannedEntity withScanClass:theirClass];
3272 if (theirClass != CLASS_NO_DRAW)
3276 foundHostiles = YES;
3278 else if ([scannedEntity
isShip])
3286#if OO_VARIABLE_TORUS_SPEED
3315 [
self setAlertFlag:ALERT_FLAG_MASS_LOCK to:massLocked];
3317 [
self setAlertFlag:ALERT_FLAG_HOSTILES to:foundHostiles];
3319 for (i = 0; i < ent_count; i++)
3321 [my_entities[i] release];
3324 BOOL energyCritical = NO;
3327 energyCritical = YES;
3329 [
self setAlertFlag:ALERT_FLAG_ENERGY to:energyCritical];
3331 [
self setAlertFlag:ALERT_FLAG_TEMP to:([
self hullHeatLevel] > .90)];
3333 [
self setAlertFlag:ALERT_FLAG_ALT to:([
self dialAltitude] < .10)];
3338- (void) setMaxFlightPitch:(GLfloat)new
3345- (void) setMaxFlightRoll:(GLfloat)new
3352- (void) setMaxFlightYaw:(GLfloat)new
3359- (BOOL) checkEntityForMassLock:(
Entity *)ent withScanClass:(
int)theirClass
3371 double factor = ([stellar
isSun]) ? 2.0 : 4.0;
3374 if (dist < rad*rad*factor || dist < rad*rad + 50000*rad + 625000000 )
3380 else if (theirClass != CLASS_NO_DRAW)
3384 theirClass = CLASS_NO_DRAW;
3394 if (entIsCloakedShip && ![ent isPlayer])
3404 case CLASS_VISUAL_EFFECT:
3407 case CLASS_THARGOID:
3411 case CLASS_MILITARY:
3412 case CLASS_WORMHOLE:
3425 [
self updateAlertConditionForNearbyEntities];
3473 [
self updateFuelScoopSoundWithInterval:delta_t];
3477 [
self updateFuelScoopSoundWithInterval:delta_t];
3488 unsigned prev_day = floor(
ship_clock / 86400);
3492 double fine_adjust = delta_t * 7200.0;
3494 fine_adjust = delta_t * 115200.0;
3513 unsigned now_day = floor(
ship_clock / 86400.0);
3514 while (prev_day < now_day)
3517 [
self doScriptEvent:OOJSID("dayChanged") withArgument:[NSNumber numberWithUnsignedInt:prev_day]];
3538 [UNIVERSE resetFramesDoneThisUpdate];
3547 if ([
self status] != STATUS_IN_FLIGHT)
3552 case GUI_SCREEN_MAIN:
3553 case GUI_SCREEN_INTRO1:
3554 case GUI_SCREEN_SHIPLIBRARY:
3555 case GUI_SCREEN_KEYBOARD:
3556 case GUI_SCREEN_NEWGAME:
3557 case GUI_SCREEN_OXZMANAGER:
3558 case GUI_SCREEN_MARKET:
3559 case GUI_SCREEN_MARKETINFO:
3560 case GUI_SCREEN_OPTIONS:
3561 case GUI_SCREEN_GAMEOPTIONS:
3562 case GUI_SCREEN_LOAD:
3563 case GUI_SCREEN_SAVE:
3564 case GUI_SCREEN_SAVE_OVERWRITE:
3565 case GUI_SCREEN_STICKMAPPER:
3566 case GUI_SCREEN_STICKPROFILE:
3567 case GUI_SCREEN_MISSION:
3568 case GUI_SCREEN_REPORT:
3569 case GUI_SCREEN_KEYBOARD_CONFIRMCLEAR:
3570 case GUI_SCREEN_KEYBOARD_CONFIG:
3571 case GUI_SCREEN_KEYBOARD_ENTRY:
3572 case GUI_SCREEN_KEYBOARD_LAYOUT:
3577 case GUI_SCREEN_EQUIP_SHIP:
3578 case GUI_SCREEN_INTERFACES:
3579 case GUI_SCREEN_MANIFEST:
3580 case GUI_SCREEN_SHIPYARD:
3581 case GUI_SCREEN_LONG_RANGE_CHART:
3582 case GUI_SCREEN_SHORT_RANGE_CHART:
3583 case GUI_SCREEN_STATUS:
3584 case GUI_SCREEN_SYSTEM_DATA:
3598 OOTrumble **trumbles = [
self trumbleArray];
3609- (void) performAutopilotUpdates:(
OOTimeDelta)delta_t
3611 [
self processBehaviour:delta_t];
3612 [
self applyVelocity:delta_t];
3613 [
self doBookkeeping:delta_t];
3616- (void) performDockingRequest:(
StationEntity *)stationForDocking
3618 if (stationForDocking ==
nil)
return;
3624 [
self disengageAutopilot];
3627 if (stationDockingClearanceStatus !=
nil)
3629 [
self doScriptEvent:OOJSID("playerRequestedDockingClearance") withArgument:stationDockingClearanceStatus];
3630 if ([stationDockingClearanceStatus isEqualToString:
@"DOCKING_CLEARANCE_GRANTED"])
3632 [
self doScriptEvent:OOJSID("playerDockingClearanceGranted")];
3637- (void) requestDockingClearance:(
StationEntity *)stationForDocking
3641 [
self performDockingRequest:stationForDocking];
3645- (void) cancelDockingRequest:(
StationEntity *)stationForDocking
3647 if (stationForDocking ==
nil)
return;
3653 [
self disengageAutopilot];
3658 if (stationDockingClearanceStatus !=
nil && [stationDockingClearanceStatus isEqualToString:
@"DOCKING_CLEARANCE_CANCELLED"])
3660 [
self doScriptEvent:OOJSID("playerDockingClearanceCancelled")];
3665- (BOOL) engageAutopilotToStation:(
StationEntity *)stationForDocking
3667 if (stationForDocking ==
nil)
return NO;
3675 [
self setTargetStation:stationForDocking];
3679 [
self safeAllMissiles];
3681 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN) [
self cancelWitchspaceCountdown];
3682 [
self setStatus:STATUS_AUTOPILOT_ENGAGED];
3683 [
self resetAutopilotAI];
3684 [shipAI setState:@"BEGIN_DOCKING"];
3685 [
self playAutopilotOn];
3687 [
self doScriptEvent:OOJSID("playerStartedAutoPilot") withArgument:stationForDocking];
3688 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_GRANTED];
3704 [
self abortDocking];
3709 [
self setTargetStation:nil];
3710 [
self setStatus:STATUS_IN_FLIGHT];
3711 [
self playAutopilotOff];
3712 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
3714 [
self doScriptEvent:OOJSID("playerCancelledAutoPilot")];
3716 [
self resetAutopilotAI];
3723 AI *myAI = [
self getAI];
3727 [
self setAITo:PLAYER_DOCKING_AI_NAME ];
3736#define VELOCITY_CLEANUP_MIN 2000.0f
3737#define VELOCITY_CLEANUP_FULL 5000.0f
3738#define VELOCITY_CLEANUP_RATE 0.001f
3741#if OO_VARIABLE_TORUS_SPEED
3761- (void) performInFlightUpdates:(
OOTimeDelta)delta_t
3770 [
self applyVelocity:delta_t];
3772 GLfloat thrust_factor = 1.0;
3777 thrust_factor = [
self afterburnerFactor];
3786 GLfloat velmag = magnitude(
velocity);
3787 GLfloat velmag2 = velmag - (float)delta_t *
thrust * thrust_factor;
3798 velmag2 -= velmag * rate;
3806 [
self applyRoll:(float)delta_t*flightRoll andClimb:(float)delta_t*flightPitch];
3809 [
self applyYaw:(float)delta_t*flightYaw];
3813 [
self moveForward:delta_t*flightSpeed];
3816 [
self updateTargeting];
3822- (void) performWitchspaceCountdownUpdates:(
OOTimeDelta)delta_t
3827 [
self doBookkeeping:delta_t];
3839 [
self setStatus:STATUS_IN_FLIGHT];
3840 [
self playHyperspaceAborted];
3848 [UNIVERSE displayCountdownMessage:OOExpandKey(@"witch-galactic-in-x-seconds", seconds) forCount:1.0];
3852 NSString *
destination = [UNIVERSE getSystemName:[
self nextHopTargetSystemID]];
3853 [UNIVERSE displayCountdownMessage:OOExpandKey(@"witch-to-x-in-y-seconds", seconds, destination) forCount:1.0];
3869 [UNIVERSE preloadPlanetTexturesForSystem:target_system_id];
3878 else [
self enterWitchspace];
3886- (void) performWitchspaceExitUpdates:(
OOTimeDelta)delta_t
3890 [
self resetExhaustPlumes];
3894 [
self resetScriptTimer];
3899 [UNIVERSE addMessage:[NSString stringWithFormat:@" %@. ",[UNIVERSE getSystemName:system_id]] forCount:3.0];
3901 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_COMPASS"])
3908 if ([
UNIVERSE inInterstellarSpace]) [UNIVERSE addMessage:DESC(@"witch-engine-malfunction") forCount:3.0];
3911 [
self setStatus:STATUS_IN_FLIGHT];
3918 [
self setScriptedMisjumpRange:0.5];
3920 [
self doScriptEvent:OOJSID("shipExitedWitchspace") withArgument:[
self jumpCause]];
3922 [
self doBookkeeping:delta_t];
3929- (void) performLaunchingUpdates:(
OOTimeDelta)delta_t
3934 [
self doBookkeeping:delta_t];
3943 [
self setStatus:STATUS_IN_FLIGHT];
3945 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
3946 StationEntity *stationLaunchedFrom = [UNIVERSE nearestEntityMatchingPredicate:IsStationPredicate parameter:NULL relativeToEntity:self];
3947 [
self doScriptEvent:OOJSID("shipLaunchedFromStation") withArgument:stationLaunchedFrom];
3952- (void) performDockingUpdates:(
OOTimeDelta)delta_t
3960 [UNIVERSE terminatePostFX:OO_POSTFX_CLOAK];
3961 if ([
UNIVERSE ECMVisualFXEnabled]) [UNIVERSE terminatePostFX:OO_POSTFX_CRTBADSIGNAL];
3967 [UNIVERSE terminatePostFX:OO_POSTFX_CLOAK];
3968 if ([
UNIVERSE ECMVisualFXEnabled]) [UNIVERSE terminatePostFX:OO_POSTFX_CRTBADSIGNAL];
3970 [
self gameOverFadeToBW];
3975 [UNIVERSE handleGameOver];
3983 float secondsToBWFadeOut = [[NSUserDefaults standardUserDefaults] oo_floatForKey:@"gameover-seconds-to-bw-fadeout" defaultValue:5.0f];
3987 static float originalColorSaturation = -1.0f;
3988 if (originalColorSaturation == -1.0f) originalColorSaturation = [gameView
colorSaturation];
3989 if ([
self shotTime] < secondsToBWFadeOut)
3995 [gameView
adjustColorSaturation:-(originalColorSaturation * (1.0f / secondsToBWFadeOut) * [UNIVERSE timeAccelerationFactor] / fps_counter)];
4005 originalColorSaturation = -1.0f;
4014- (BOOL)isValidTarget:(
Entity*)target
4034 if (tstatus == STATUS_ENTERING_WITCHSPACE || tstatus == STATUS_IN_HOLD || tstatus == STATUS_DOCKED)
4043 [
self hasEquipmentItemProviding:
@"EQ_WORMHOLE_SCANNER"] &&
ident_engaged)
4055 [hud resetGuis:[NSDictionary dictionaryWithObject:[NSDictionary dictionary] forKey:@"message_gui"]];
4056 NSString *scoreMS = [NSString stringWithFormat:OOExpandKey(@"gameoverscreen-score-@"),
4057 KillCountToRatingAndKillString(ship_kills)];
4059 [UNIVERSE displayMessage:OOExpandKey(@"gameoverscreen-game-over") forCount:kDeadResetTime];
4060 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
4061 [UNIVERSE displayMessage:scoreMS forCount:kDeadResetTime];
4062 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
4063 [UNIVERSE displayMessage:OOExpandKey(@"gameoverscreen-press-space") forCount:kDeadResetTime];
4064 [UNIVERSE displayMessage:@" " forCount:kDeadResetTime];
4065 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
4066 [
self resetShotTime];
4070- (void) showShipModelWithKey:(NSString *)shipKey shipData:(NSDictionary *)shipData personality:(uint16_t)personality factorX:(GLfloat)factorX factorY:(GLfloat)factorY factorZ:(GLfloat)factorZ inContext:(NSString *)context
4072 if (shipKey ==
nil)
return;
4074 if (shipData ==
nil)
return;
4076 Quaternion q2 = { (GLfloat)
M_SQRT1_2, (GLfloat)
M_SQRT1_2, (GLfloat)0.0f, (GLfloat)0.0f };
4080 q2 = [demoShip orientation];
4089 if (context)
OOLog(
@"script.debug.note.showShipModel",
@"::::: showShipModel:'%@' in context: %@.", [ship
name], context);
4098 [ship
setAITo: @"nullAI.plist"];
4099 id subEntStatus = [shipData objectForKey:@"subentities_status"];
4102 [UNIVERSE addEntity: ship];
4106 [ship
setStatus: STATUS_COCKPIT_DISPLAY];
4119 case GUI_SCREEN_GAMEOPTIONS:
4121 [
self setGuiToGameOptionsScreen];
4123 case GUI_SCREEN_STATUS:
4126 [
self setGuiToStatusScreen];
4133 [hud resetGuiPositions];
4155 [UNIVERSE addMessage:DESC(@"target-lost") forCount:3.0];
4156 [
self playTargetLost];
4157 [
self noteLostTarget];
4178 [UNIVERSE addMessage:DESC(@"target-lost") forCount:3.0];
4179 [
self playTargetLost];
4180 [missile_entity[i] removeTarget:nil];
4183 [
self noteLostTarget];
4198 ([
self status] == STATUS_IN_FLIGHT || [
self status] == STATUS_WITCHSPACE_COUNTDOWN))
4200 Entity *target = [UNIVERSE firstEntityTargetedByPlayer];
4201 if ([
self isValidTarget:target])
4203 [
self addTarget:target];
4209 UPDATE_STAGE(
@"checking for additional wormhole information");
4213 switch ([wh scanInfo])
4238 [UNIVERSE addCommsMessage:[NSString stringWithFormat:DESC(@"wormhole-arrival-time-computed-@"),
4246 [UNIVERSE addCommsMessage:[NSString stringWithFormat:DESC(@"wormhole-destination-computed-@"),
4247 [UNIVERSE getSystemName:[wh
destination]]] forCount:5.0];
4278- (void) applyAttitudeChanges:(
double) delta_t
4280 [
self applyRoll:flightRoll*delta_t andClimb:flightPitch*delta_t];
4281 [
self applyYaw:flightYaw*delta_t];
4285- (void) applyRoll:(GLfloat) roll1 andClimb:(GLfloat) climb1
4287 if (roll1 == 0.0 && climb1 == 0.0 &&
hasRotated == NO)
4310 [
self orientationChanged];
4318- (void) applyYaw:(GLfloat) yaw
4322 [
self orientationChanged];
4336 return OOMatrixTranslate(result, HPVectorToVector(
position));
4346- (void) setNormalOrientation:(Quaternion) quat
4348 [
self setOrientation:make_quaternion(-quat.w, quat.x, quat.y, quat.z)];
4352- (void) moveForward:(
double) amount
4355 [
self setPosition:HPvector_add(position, vectorToHPVector(vector_multiply_scalar(v_forward, (float)amount)))];
4379 case VIEW_STARBOARD:
4424 Vector
offset = [
self viewpointOffset];
4429 viewpoint.x +=
offset.
x * r.m[0][0]; viewpoint.y +=
offset.
x * r.m[1][0]; viewpoint.z +=
offset.
x * r.m[2][0];
4430 viewpoint.x +=
offset.
y * r.m[0][1]; viewpoint.y +=
offset.
y * r.m[1][1]; viewpoint.z +=
offset.
y * r.m[2][1];
4431 viewpoint.x +=
offset.z * r.m[0][2]; viewpoint.y +=
offset.z * r.m[1][2]; viewpoint.z +=
offset.z * r.m[2][2];
4437- (void) drawImmediate:(
bool)immediate translucent:(
bool)translucent
4442 case STATUS_COCKPIT_DISPLAY:
4444 case STATUS_START_GAME:
4448 if ([
UNIVERSE breakPatternHide])
return;
4451 [
super drawImmediate:immediate translucent:translucent];
4455- (void) setMassLockable:(BOOL)newValue
4458 [
self updateAlertCondition];
4486- (void) setOcclusionLevel:(
float)level
4494 [
self setDockedStation:[UNIVERSE station]];
4501 return [_dockedStation weakRefUnderlyingObject];
4507 [_dockedStation release];
4534 NSString *hud_desc = [shipDict oo_stringForKey:@"hud" defaultValue:@"hud.plist"];
4535 if (![
self switchHudTo:hud_desc]) [
self switchHudTo:@"hud.plist"];
4539- (BOOL) switchHudTo:(NSString *)hudFileName
4541 NSDictionary *hudDict =
nil;
4542 BOOL wasHidden = NO;
4543 BOOL wasCompassActive = YES;
4544 double scannerZoom = 1.0;
4545 NSUInteger lastMFD = 0;
4548 if (!hudFileName)
return NO;
4553 [hud setDeferredHudName:hudFileName];
4561 OOLog(
@"PlayerEntity.switchHudTo.failed",
@"HUD dictionary file %@ to switch to not found or invalid.", hudFileName);
4568 wasHidden = [hud isHidden];
4569 wasCompassActive = [hud isCompassActive];
4570 scannerZoom = [hud scannerZoom];
4577 [hud setHidden:YES];
4579 hud = [[
HeadUpDisplay alloc] initWithDictionary:hudDict inFile:hudFileName];
4580 [hud resetGuis:hudDict];
4582 [hud setScannerZoom:scannerZoom];
4583 [hud setCompassActive:wasCompassActive];
4584 [hud setHidden:wasHidden];
4586 NSArray *savedMFDs = [NSArray arrayWithArray:multiFunctionDisplaySettings];
4587 [multiFunctionDisplaySettings removeAllObjects];
4588 for (i = 0; i < [hud mfdCount] ; i++)
4590 if ([savedMFDs
count] > i)
4592 [multiFunctionDisplaySettings addObject:[savedMFDs objectAtIndex:i]];
4596 [multiFunctionDisplaySettings addObject:[NSNull null]];
4606- (float) dialCustomFloat:(NSString *)dialKey
4608 return [customDialSettings oo_floatForKey:dialKey defaultValue:0.0];
4612- (NSString *) dialCustomString:(NSString *)dialKey
4614 return [customDialSettings oo_stringForKey:dialKey defaultValue:@""];
4618- (
OOColor *) dialCustomColor:(NSString *)dialKey
4624- (void) setDialCustom:(
id)value forKey:(NSString *)dialKey
4626 [customDialSettings setObject:value forKey:dialKey];
4630- (void) setShowDemoShips:(BOOL)value
4666- (void) setMaxForwardShieldLevel:(
float)new
4672- (void) setMaxAftShieldLevel:(
float)new
4678- (void) setForwardShieldRechargeRate:(
float)new
4684- (void) setAftShieldRechargeRate:(
float)new
4702- (void) setForwardShieldLevel:(GLfloat)level
4708- (void) setAftShieldLevel:(GLfloat)level
4730 if ((result < 1.0f)&&(result > -1.0f))
4741 if ((result < 1.0f)&&(result > -1.0f))
4752 if ((result < 1.0f)&&(result > -1.0f))
4763 return OOClamp_0_1_f(result);
4780 return OOClamp_0_1_f(result);
4790 GLfloat result =
aft_shield / [
self maxAftShieldLevel];
4791 return OOClamp_0_1_f(result);
4798 return OOClamp_0_1_f(result);
4828 return OOClamp_0_1_f(result);
4835 return OOClamp_0_1_f(result);
4843 return OOClamp_0_1_f(result);
4850 return OOClamp_0_1_f(result);
4857 return OOClamp_0_1_f(result);
4870 Entity *nearestPlanet = [
self findNearestStellarBody];
4871 if (nearestPlanet ==
nil)
return 1.0f;
4875 GLfloat alt = sqrt(zd) - cr;
4899- (void) addToAdjustTime:(
double)seconds
4911- (void) setEscapePodRescueTime:(
double)seconds
4931 return [NSString stringWithFormat:@"FPS: %3d", fpsVal];
4937 NSString *result = [NSString stringWithFormat:@"Entities: %3ld", [UNIVERSE entityCount]];
4939 result = [NSString stringWithFormat:@"%@ (%d, %zu KiB, avg %lu bytes)", result, gLiveEntityCount, gTotalEntityMemory >> 10, gTotalEntityMemory / gLiveEntityCount];
4948 unsigned n_missiles = 0;
4970 OOLogERR(
@"player.missilesUnsafe",
@"%@",
@"Missile state is not SAFE when weapons are offline. This is a bug, please report it.");
4971 [
self safeAllMissiles];
4981 return [
super canScoop:other];
5010- (void) setFuelLeakRate:(
float)value
5022 NSUInteger
count = [commLog count];
5025 [commLog removeObjectsInRange:NSMakeRange(0, count - kCommLogTrimSize)];
5030 commLog = [[NSMutableArray alloc] init];
5043- (void) addRoleForAggression:(
ShipEntity *)victim
5049 NSString *role =
nil;
5050 if ([[victim
primaryRole] isEqualToString:
@"escape-capsule"])
5052 role =
@"assassin-player";
5054 else if ([victim
bounty] > 0)
5064 role =
@"pirate-interceptor";
5070 NSUInteger times = [roleWeightFlags oo_intForKey:role defaultValue:0];
5072 [roleWeightFlags setObject:[NSNumber numberWithUnsignedInteger:times] forKey:role];
5073 if ((times & (times-1)) == 0)
5075 [
self addRoleToPlayer:role];
5082 NSString *role =
@"miner";
5083 NSUInteger times = [roleWeightFlags oo_intForKey:role defaultValue:0];
5085 [roleWeightFlags setObject:[NSNumber numberWithUnsignedInteger:times] forKey:role];
5086 if ((times & (times-1)) == 0)
5088 [
self addRoleToPlayer:role];
5093- (void) addRoleToPlayer:(NSString *)role
5095 NSUInteger slot =
Ranrot() & ([
self maxPlayerRoles]-1);
5096 [
self addRoleToPlayer:role inSlot:slot];
5100- (void) addRoleToPlayer:(NSString *)role inSlot:(NSUInteger)slot
5104 slot = [
self maxPlayerRoles]-1;
5108 [roleWeights addObject:role];
5112 [roleWeights replaceObjectAtIndex:slot withObject:role];
5117- (void) clearRoleFromPlayer:(BOOL)includingLongRange
5119 NSUInteger slot =
Ranrot() % [roleWeights count];
5120 if (!includingLongRange)
5122 NSString *role = [roleWeights objectAtIndex:slot];
5124 if ([role hasSuffix:
@"+"] &&
randf() > 0.5)
5129 [roleWeights replaceObjectAtIndex:slot withObject:@"player-unknown"];
5133- (void) clearRolesFromPlayer:(
float)chance
5135 NSUInteger i,
count=[roleWeights count];
5136 for (i = 0; i <
count; i++)
5138 if (
randf() < chance)
5140 [roleWeights replaceObjectAtIndex:i withObject:@"player-unknown"];
5170 NSUInteger memory = 4;
5185 [roleSystemList removeObjectAtIndex:0];
5187 [roleSystemList addObject:[NSNumber numberWithInt:sys]];
5193 Entity *result = [compassTarget weakRefUnderlyingObject];
5203- (void) setCompassTarget:(
Entity *)value
5205 [compassTarget release];
5213 OOPlanetEntity *the_planet = [UNIVERSE planet];
5215 Entity *the_target = [
self primaryTarget];
5216 Entity <OOBeaconEntity> *beacon = [
self nextBeacon];
5217 if ([
self isInSpace] && the_sun && the_planet
5218 && ![the_sun goneNova])
5225 case COMPASS_MODE_INACTIVE:
5228 case COMPASS_MODE_BASIC:
5231 new_target = the_station;
5235 new_target = the_planet;
5239 case COMPASS_MODE_PLANET:
5240 new_target = the_planet;
5243 case COMPASS_MODE_STATION:
5244 new_target = the_station;
5247 case COMPASS_MODE_SUN:
5248 new_target = the_sun;
5251 case COMPASS_MODE_TARGET:
5252 new_target = the_target;
5255 case COMPASS_MODE_BEACONS:
5256 new_target = beacon;
5260 if (new_target ==
nil || [new_target
status] < STATUS_ACTIVE || [new_target
status] == STATUS_IN_HOLD)
5262 [
self setCompassMode:COMPASS_MODE_PLANET];
5263 new_target = the_planet;
5268 [
self setCompassTarget:new_target];
5269 [
self doScriptEvent:OOJSID("compassTargetChanged") withArguments:[NSArray arrayWithObjects:new_target, OOStringFromCompassMode([
self compassMode]), nil]];
5279 case COMPASS_MODE_INACTIVE:
5281 case COMPASS_MODE_BASIC:
5283 case COMPASS_MODE_BEACONS:
5285 Entity *target = [
self compassTarget];
5292 case COMPASS_MODE_PLANET:
5293 return [[UNIVERSE planet] name];
5294 case COMPASS_MODE_SUN:
5295 return [[UNIVERSE sun] name];
5296 case COMPASS_MODE_STATION:
5297 return [[UNIVERSE station] displayName];
5298 case COMPASS_MODE_TARGET:
5299 return DESC(
@"oolite-beacon-label-target");
5320 Entity <OOBeaconEntity> *beacon =
nil;
5324 case COMPASS_MODE_INACTIVE:
5325 case COMPASS_MODE_BASIC:
5326 case COMPASS_MODE_PLANET:
5327 beacon = [UNIVERSE lastBeacon];
5330 beacon = [beacon prevBeacon];
5332 [
self setNextBeacon:beacon];
5336 [
self setCompassMode:COMPASS_MODE_BEACONS];
5341 case COMPASS_MODE_BEACONS:
5342 beacon = [
self nextBeacon];
5345 beacon = [beacon prevBeacon];
5347 [
self setNextBeacon:beacon];
5353 [
self setCompassMode:COMPASS_MODE_TARGET];
5357 [
self setCompassMode:COMPASS_MODE_SUN];
5363 case COMPASS_MODE_TARGET:
5364 [
self setCompassMode:COMPASS_MODE_SUN];
5367 case COMPASS_MODE_SUN:
5368 aegis = [
self checkForAegis];
5371 [
self setCompassMode:COMPASS_MODE_STATION];
5375 [
self setCompassMode:COMPASS_MODE_PLANET];
5379 case COMPASS_MODE_STATION:
5380 [
self setCompassMode:COMPASS_MODE_PLANET];
5389 Entity <OOBeaconEntity> *beacon =
nil;
5393 case COMPASS_MODE_INACTIVE:
5394 case COMPASS_MODE_BASIC:
5395 case COMPASS_MODE_PLANET:
5396 aegis = [
self checkForAegis];
5399 [
self setCompassMode:COMPASS_MODE_STATION];
5403 [
self setCompassMode:COMPASS_MODE_SUN];
5407 case COMPASS_MODE_STATION:
5408 [
self setCompassMode:COMPASS_MODE_SUN];
5411 case COMPASS_MODE_SUN:
5414 [
self setCompassMode:COMPASS_MODE_TARGET];
5419 case COMPASS_MODE_TARGET:
5420 beacon = [UNIVERSE firstBeacon];
5423 beacon = [beacon nextBeacon];
5425 [
self setNextBeacon:beacon];
5427 if (beacon !=
nil) [
self setCompassMode:COMPASS_MODE_BEACONS];
5428 else [
self setCompassMode:COMPASS_MODE_PLANET];
5431 case COMPASS_MODE_BEACONS:
5432 beacon = [
self nextBeacon];
5435 beacon = [beacon nextBeacon];
5437 [
self setNextBeacon:beacon];
5441 [
self setCompassMode:COMPASS_MODE_PLANET];
5454- (void) setActiveMissile:(NSUInteger)value
5472- (void) setDialIdentEngaged:(BOOL)newValue
5486 Entity *target_entity = [
self primaryTarget];
5487 NSString *result =
nil;
5489 if (target_entity ==
nil)
5491 result =
DESC(
@"no-target-string");
5494 if ([target_entity respondsToSelector:
@selector(identFromShip:)])
5499 if (result ==
nil) result =
DESC(
@"unknown-target");
5511- (NSString *) multiFunctionText:(NSUInteger)i
5513 NSString *key = [multiFunctionDisplaySettings oo_stringAtIndex:i defaultValue:nil];
5518 NSString *text = [multiFunctionDisplayText oo_stringForKey:key defaultValue:nil];
5523- (void) setMultiFunctionText:(NSString *)text forKey:(NSString *)key
5527 [multiFunctionDisplayText setObject:text forKey:key];
5529 else if (key !=
nil)
5531 [multiFunctionDisplayText removeObjectForKey:key];
5536 [multiFunctionDisplaySettings replaceObjectAtIndex:index withObject:[NSNull null]];
5542- (BOOL) setMultiFunctionDisplay:(NSUInteger)index toKey:(NSString *)key
5544 if (index >= [
hud mfdCount])
5547 index = [multiFunctionDisplaySettings indexOfObject:[NSNull null]];
5548 if (index == NSNotFound)
5554 if (index < [
hud mfdCount])
5558 [multiFunctionDisplaySettings replaceObjectAtIndex:index withObject:[NSNull null]];
5562 [multiFunctionDisplaySettings replaceObjectAtIndex:index withObject:key];
5573- (void) cycleNextMultiFunctionDisplay:(NSUInteger) index
5575 if ([[
self hud] mfdCount] == 0)
return;
5576 NSArray *keys = [multiFunctionDisplayText allKeys];
5577 NSString *key =
nil;
5578 if ([keys
count] == 0)
5580 [
self setMultiFunctionDisplay:index toKey:nil];
5583 id current = [multiFunctionDisplaySettings objectAtIndex:index];
5584 if (current == [NSNull
null])
5586 key = [keys objectAtIndex:0];
5587 [
self setMultiFunctionDisplay:index toKey:key];
5591 NSUInteger cIndex = [keys indexOfObject:current];
5592 if (cIndex == NSNotFound || cIndex + 1 >= [keys
count])
5595 [
self setMultiFunctionDisplay:index toKey:nil];
5599 key = [keys objectAtIndex:(cIndex+1)];
5600 [
self setMultiFunctionDisplay:index toKey:key];
5610- (void) cyclePreviousMultiFunctionDisplay:(NSUInteger) index
5612 if ([[
self hud] mfdCount] == 0)
return;
5613 NSArray *keys = [multiFunctionDisplayText allKeys];
5614 NSString *key =
nil;
5615 if ([keys
count] == 0)
5617 [
self setMultiFunctionDisplay:index toKey:nil];
5620 id current = [multiFunctionDisplaySettings objectAtIndex:index];
5621 if (current == [NSNull
null])
5623 key = [keys objectAtIndex:([keys count]-1)];
5624 [
self setMultiFunctionDisplay:index toKey:key];
5628 NSUInteger cIndex = [keys indexOfObject:current];
5629 if (cIndex == NSNotFound || cIndex == 0)
5632 [
self setMultiFunctionDisplay:index toKey:nil];
5636 key = [keys objectAtIndex:(cIndex-1)];
5637 [
self setMultiFunctionDisplay:index toKey:key];
5649 if ([[
self hud] mfdCount] == 0)
return;
5652 [UNIVERSE addMessage:OOExpandKey(@"mfd-N-selected", mfdID) forCount:3.0 ];
5661 if ([[
self hud] mfdCount] == 0)
return;
5664 activeMFD = ([[
self hud] mfdCount] - 1);
5671 [UNIVERSE addMessage:OOExpandKey(@"mfd-N-selected", mfdID) forCount:3.0 ];
5684- (
ShipEntity *) missileForPylon:(NSUInteger)value
5745 [missile_entity[activeMissile] removeTarget:nil];
5749 [
self setActiveMissile:next_missile];
5758 if( [
self hasEquipmentItemProviding:
@"EQ_MULTI_TARGET"] &&
5762 [
self addTarget:[missile_entity[next_missile] primaryTarget]];
5771 if([
self hasEquipmentItemProviding:
@"EQ_MULTI_TARGET"] && !
launchingMissile)
5773 [
self noteLostTarget];
5778 [missile_entity[activeMissile] addTarget:[
self primaryTarget]];
5802- (void) setAlertFlag:(
int)flag to:(BOOL)value
5819 return [
self alertCondition];
5828 [
self setAlertFlag:ALERT_FLAG_DOCKED to:[
self status] == STATUS_DOCKED];
5847 [
self playAlertConditionRed];
5862- (void) interpretAIMessage:(NSString *)ms
5864 if ([ms isEqual:
@"HOLD_FULL"])
5866 [
self playHoldFull];
5867 [UNIVERSE addMessage:DESC(@"hold-full") forCount:4.5];
5870 if ([ms isEqual:
@"INCOMING_MISSILE"])
5874 [
self playIncomingMissile:HPVectorToVector([[
self primaryAggressor] position])];
5878 [
self playIncomingMissile:kZeroVector];
5880 [UNIVERSE addMessage:DESC(@"incoming-missile") forCount:4.5];
5883 if ([ms isEqual:
@"ENERGY_LOW"])
5885 [UNIVERSE addMessage:DESC(@"energy-low") forCount:6.0];
5890 if ([ms isEqual:
@"DOCKING_REFUSED"] && [
self status] == STATUS_AUTOPILOT_ENGAGED)
5892 [
self playDockingDenied];
5893 [UNIVERSE addMessage:DESC(@"autopilot-denied") forCount:4.5];
5895 [
self resetAutopilotAI];
5897 [
self setStatus:STATUS_IN_FLIGHT];
5899 [
self doScriptEvent:OOJSID("playerDockingRefused")];
5905 if ([ms isEqual:
@"AEGIS_CLOSE_TO_MAIN_PLANET"]&&(
compassMode == COMPASS_MODE_PLANET))
5907 [
self playAegisCloseToPlanet];
5908 [
self setCompassMode:COMPASS_MODE_STATION];
5910 if ([ms isEqual:
@"AEGIS_IN_DOCKING_RANGE"]&&(
compassMode == COMPASS_MODE_PLANET))
5912 [
self playAegisCloseToStation];
5913 [
self setCompassMode:COMPASS_MODE_STATION];
5915 if ([ms isEqual:
@"AEGIS_NONE"]&&(
compassMode == COMPASS_MODE_STATION))
5917 [
self setCompassMode:COMPASS_MODE_PLANET];
5925 if (missile ==
nil)
return NO;
5935 if (
missiles == 1) [
self setActiveMissile:0];
5944- (BOOL) mountMissileWithRole:(NSString *)role
5947 return [
self mountMissile:[[UNIVERSE newShipWithRole:role] autorelease]];
5957 if (missile ==
nil)
return nil;
5971 firedMissile = [
self launchMine:missile];
5973 if (firedMissile !=
nil) [
self playMineLaunched:[
self missileLaunchPosition] weaponIdentifier:identifier];
5979 firedMissile = [
self fireMissileWithIdentifier:identifier andTarget:[missile
primaryTarget]];
5981 if (firedMissile !=
nil)
5984 [
self playMissileLaunched:[
self missileLaunchPosition] weaponIdentifier:identifier];
5993 [
self deactivateCloakingDevice];
5999 return firedMissile;
6013 [
self dumpItem: mine];
6016 float mine_speed = 500.0f;
6017 Vector mvel = vector_subtract([mine
velocity], vector_multiply_scalar(
v_forward, mine_speed));
6019 [
self doScriptEvent:OOJSID("shipReleasedEquipment") withArgument:mine];
6024- (BOOL) assignToActivePylon:(NSString *)equipmentKey
6030 if ([equipmentKey hasSuffix:
@"_DAMAGED"])
6045 ShipEntity *amiss = [UNIVERSE newShipWithRole:equipmentKey];
6047 if (!amiss)
return NO;
6050 [missile_entity[activeMissile] release];
6057 [
self selectNextMissile];
6071 [UNIVERSE setCurrentPostFX:OO_POSTFX_CLOAK];
6072 [UNIVERSE addMessage:DESC(@"cloak-on") forCount:2];
6073 [
self playCloakingDeviceOn];
6078 [UNIVERSE addMessage:DESC(@"cloak-low-juice") forCount:3];
6079 [
self playCloakingDeviceInsufficientEnergy];
6089 [
super deactivateCloakingDevice];
6090 [UNIVERSE terminatePostFX:OO_POSTFX_CLOAK];
6091 [UNIVERSE addMessage:DESC(@"cloak-off") forCount:2];
6092 [
self playCloakingDeviceOff];
6162 [
self setWeaponDataFromType:currentWeapon];
6172- (void) setWeaponsOnline:(BOOL)newValue
6181 return [
self laserPortOffset:currentWeaponFacing];
6187 OOWeaponType weapon_to_be_fired = [
self currentWeapon];
6196 [
self playWeaponOverheated:[[
self currentLaserOffset] oo_vectorAtIndex:0]];
6197 [UNIVERSE addMessage:DESC(@"weapon-overheat") forCount:3.0];
6206 [
self currentWeaponStats];
6208 NSUInteger multiplier = 1;
6212 multiplier = [[
self laserPortOffset:currentWeaponFacing] count];
6217 [UNIVERSE addMessage:DESC(@"weapon-out-of-juice") forCount:3.0];
6251 BOOL weaponFired = NO;
6254 if (![weapon_to_be_fired isTurretLaser])
6256 [
self fireLaserShotInDirection:currentWeaponFacing weaponIdentifier:[[
self currentWeapon] identifier]];
6267 [
self deactivateCloakingDevice];
6299 return [
self weaponForFacing:currentWeaponFacing];
6306- (GLfloat) doesHitLine:(HPVector)v0 :(HPVector)v1 :(
ShipEntity **)hitEntity
6310 Vector u0 = HPVectorToVector(HPvector_between(
position, v0));
6311 Vector u1 = HPVectorToVector(HPvector_between(
position, v1));
6312 Vector w0 = make_vector(dot_product(u0,
v_right), dot_product(u0,
v_up), dot_product(u0,
v_forward));
6313 Vector w1 = make_vector(dot_product(u1,
v_right), dot_product(u1,
v_up), dot_product(u1,
v_forward));
6314 GLfloat hit_distance = [octree isHitByLine:w0 :w1];
6318 hitEntity[0] =
self;
6321 bool shields =
false;
6327 NSEnumerator *subEnum =
nil;
6333 u0 = HPVectorToVector(HPvector_between(p0, v0));
6334 u1 = HPVectorToVector(HPvector_between(p0, v1));
6335 w0 = resolveVectorInIJK(u0, ijk);
6336 w1 = resolveVectorInIJK(u1, ijk);
6338 GLfloat hitSub = [se->octree isHitByLine:w0 :w1];
6339 if (hitSub && (hit_distance == 0 || hit_distance > hitSub))
6341 hit_distance = hitSub;
6342 if (hitEntity && !shields)
6349 return hit_distance;
6354- (void) takeEnergyDamage:(
double)amount from:(
Entity *)ent becauseOf:(
Entity *)other weaponIdentifier:(NSString *)weaponIdentifier
6358 BOOL internal_damage = NO;
6360 OOLog(
@"player.ship.damage",
@"Player took damage from %@ becauseOf %@", ent, other);
6362 if ([
self status] == STATUS_DEAD)
return;
6363 if ([
self status] == STATUS_ESCAPE_SEQUENCE)
return;
6364 if (amount == 0.0)
return;
6367 BOOL cascading = NO;
6370 cascading = [
self cascadeIfAppropriateWithDamageAmount:amount cascadeOwner:[ent
owner]];
6376 [[ent retain] autorelease];
6377 [[other retain] autorelease];
6380 rel_pos = HPvector_subtract(rel_pos,
position);
6382 [
self doScriptEvent:OOJSID("shipBeingAttacked") withArgument:ent];
6383 if ([ent
isShip]) [(
ShipEntity *)
ent doScriptEvent:OOJSID("shipAttackedOther") withArgument:self];
6385 d_forward = dot_product(HPVectorToVector(rel_pos),
v_forward);
6386 d_right = dot_product(HPVectorToVector(rel_pos),
v_right);
6387 d_up = dot_product(HPVectorToVector(rel_pos),
v_up);
6388 Vector relative = make_vector(d_right,d_up,d_forward);
6390 [
self playShieldHit:relative weaponIdentifier:weaponIdentifier];
6395 [
self broadcastHitByLaserFrom:(ShipEntity*) other];
6425 OOShipDamageType damageType = cascadeWeapon ? kOODamageTypeCascadeWeapon : kOODamageTypeEnergy;
6430 [
self playDirectHit:relative weaponIdentifier:weaponIdentifier];
6443 [
self noteTakingDamage:amount from:other type:damageType];
6444 if (cascading)
energy = 0.0;
6453 [
self getDestroyedBy:other damageType:damageType];
6457 while (amount > 0.0)
6460 if (internal_damage)
6462 [
self takeInternalDamage];
6470- (void) takeScrapeDamage:(
double) amount from:(
Entity *) ent
6474 BOOL internal_damage = NO;
6476 if ([
self status] == STATUS_DEAD)
return;
6480 OOLog(
@"player.ship.damage",
@"Player took negative scrape damage %.3f so we made it positive", amount);
6483 OOLog(
@"player.ship.damage",
@"Player took %.3f scrape damage from %@", amount, ent);
6485 [[ent retain] autorelease];
6487 rel_pos = HPvector_subtract(rel_pos,
position);
6489 d_forward = dot_product(HPVectorToVector(rel_pos),
v_forward);
6490 d_right = dot_product(HPVectorToVector(rel_pos),
v_right);
6491 d_up = dot_product(HPVectorToVector(rel_pos),
v_up);
6492 Vector relative = make_vector(d_right,d_up,d_forward);
6494 [
self playScrapeDamage:relative];
6522 [
super takeScrapeDamage:amount from:ent];
6524 while (amount > 0.0)
6527 if (internal_damage)
6529 [
self takeInternalDamage];
6536- (void) takeHeatDamage:(
double) amount
6538 if ([
self status] == STATUS_DEAD || amount < 0)
return;
6541 float fwd_amount = (float)(0.5 * amount);
6542 float aft_amount = (float)(0.5 * amount);
6566 double residual_amount = fwd_amount + aft_amount;
6568 [
super takeHeatDamage:residual_amount];
6582 [result
setSpeed:[
self flightSpeed]];
6600 if ([
UNIVERSE displayGUI]) [
self switchToMainView];
6601 [UNIVERSE setViewDirection:VIEW_FORWARD];
6603 if ([
self status] == STATUS_DEAD)
return nil;
6610 [UNIVERSE setBlockJSPlayerShipProps:YES];
6625 doppelganger = [
self createDoppelganger];
6628 [doppelganger
setVelocity:vector_multiply_scalar(v_forward, flightSpeed)];
6631 [doppelganger
setRoll:0.2 * (randf() - 0.5)];
6634 [UNIVERSE addEntity:doppelganger];
6637 [
self setFoundTarget:doppelganger];
6638 [
self setStatus:STATUS_ESCAPE_SEQUENCE];
6643 position = HPvector_subtract(
position, vectorToHPVector(vector_multiply_scalar(
v_up, sheight)));
6648 escapePod = [UNIVERSE newShipWithName:@"escape-capsule"];
6649 if (escapePod !=
nil)
6652 [
self setMesh:[escapePod
mesh]];
6671 Vector launchVector = vector_add([doppelganger
velocity],
6672 vector_add(vector_multiply_scalar(
v_up, 15.0f),
6673 vector_multiply_scalar(
v_forward, -90.0f)));
6674 [
self setVelocity:launchVector];
6679 [
self removeEquipmentItem:[
self equipmentItemProviding:@"EQ_ESCAPE_POD"]];
6685 [
self setDockTarget:[UNIVERSE station]];
6687 [
self doScriptEvent:OOJSID("shipLaunchedEscapePod") withArgument:escapePod];
6690 [
self setBounty:0 withReason:kOOLegalStatusReasonEscapePod];
6696 [
self clearRolesFromPlayer:0.1];
6700 [
self clearRolesFromPlayer:0.25];
6704 [
self clearRolesFromPlayer:0.5];
6711 [cargo removeAllObjects];
6714 [UNIVERSE addMessage:DESC(@"escape-sequence") forCount:4.5];
6715 [
self resetShotTime];
6724 [escapePod release];
6726 return doppelganger;
6734 [UNIVERSE addMessage:OOExpandKey(@"hold-locked") forCount:3.0];
6741 NSString *commodity = [UNIVERSE displayNameForCommodity:result];
6742 [UNIVERSE addMessage:OOExpandKey(@"commodity-ejected", commodity) forCount:3.0 forceDisplay:YES];
6743 [
self playCargoJettisioned];
6751 NSInteger i, n_cargo = [cargo count];
6752 if (n_cargo == 0)
return;
6757 NSInteger rotates = 0;
6761 [cargo removeObjectAtIndex:0];
6762 [cargo addObject:pod];
6767 }
while ([contents isEqualToString:current_contents]&&(rotates < n_cargo));
6770 NSString *commodity = [UNIVERSE displayNameForCommodity:contents];
6771 [UNIVERSE addMessage:OOExpandKey(@"ready-to-eject-commodity", commodity) forCount:3.0];
6775 for (i = 1; i < (n_cargo - rotates); i++)
6777 pod = [cargo objectAtIndex:i];
6781 [cargo removeObjectAtIndex:i--];
6782 [cargo addObject:pod];
6792 [
self setBounty:amount withReason:kOOLegalStatusReasonUnknown];
6799 [
self setBounty:amount withReasonAsString:nReason];
6803- (void) setBounty:(
OOCreditsQuantity)amount withReasonAsString:(NSString *)reason
6807 jsval amountVal = JSVAL_VOID;
6809 JS_NewNumberValue(context, amountVal2, &amountVal);
6815 ShipScriptEvent(context,
self,
"shipBountyChanged", amountVal, reasonVal);
6833- (void) markAsOffender:(
int)offence_value
6835 [
self markAsOffender:offence_value withReason:kOOLegalStatusReasonUnknown];
6845 jsval amountVal = JSVAL_VOID;
6847 JS_NewNumberValue(context, amountVal2, &amountVal);
6853 ShipScriptEvent(context,
self,
"shipBountyChanged", amountVal, reasonVal);
6863 if ([
self status] == STATUS_DEAD)
return;
6887 [
self markAsOffender:64 withReason:kOOLegalStatusReasonAttackedPolice];
6890 BOOL killIsCargo = ((killClass == CLASS_CARGO) && ([other
commodityAmount] > 0) && ![other
isHulk]);
6891 if ((killIsCargo) || (killClass == CLASS_BUOY) || (killClass == CLASS_ROCK))
6894 if (![other hasRole:
@"tharglet"])
6906 [UNIVERSE addDelayedMessage:bonusMessage forCount:6 afterDelay:0.15];
6915 [UNIVERSE addDelayedMessage:DESC(@"right-on-commander") forCount:4 afterDelay:0.2];
6923 unsigned n_cargo = [
self maxAvailableCargoSpace];
6924 unsigned n_mass = [
self mass] / 10000;
6926 unsigned damage_to = n_considered ? (
ranrot_rand() % n_considered) : 0;
6932 NSString* cargo_desc = [UNIVERSE displayNameForCommodity:[pod
commodityType]];
6935 [UNIVERSE clearPreviousMessage];
6936 [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"@-destroyed"), cargo_desc] forCount:4.5];
6937 [cargo removeObject:pod];
6942 damage_to = n_considered - (damage_to + 1);
6945 NSEnumerator *eqEnum = [
self equipmentEnumerator];
6947 NSString *system_key;
6948 unsigned damageableCounter = 0;
6949 GLfloat damageableOdds = 0.0;
6950 while ((system_key = [eqEnum nextObject]) !=
nil)
6953 if ([eqType canBeDamaged])
6955 damageableCounter++;
6956 damageableOdds += [eqType damageProbability];
6960 if (damage_to < damageableCounter)
6962 GLfloat target =
randf() * damageableOdds;
6963 GLfloat accumulator = 0.0;
6964 eqEnum = [
self equipmentEnumerator];
6965 while ((system_key = [eqEnum nextObject]) !=
nil)
6968 accumulator += [eqType damageProbability];
6969 if (accumulator > target)
6971 [system_key retain];
6975 if (system_key ==
nil)
6977 [system_key release];
6981 NSString *system_name = [eqType
name];
6982 if (![eqType canBeDamaged] || system_name ==
nil)
6984 [system_key release];
6989 [
self setScriptTarget:self];
6990 [UNIVERSE clearPreviousMessage];
6991 [
self removeEquipmentItem:system_key];
6993 NSString *damagedKey = [NSString stringWithFormat:@"%@_DAMAGED", system_key];
6994 [
self addEquipmentItem:damagedKey withValidation: NO inContext:@"damage"];
6995 [
self doScriptEvent:OOJSID("equipmentDamaged") withArgument:system_key];
6997 if (![
self hasEquipmentItem:system_name] && [
self hasEquipmentItem:damagedKey])
7005 [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"@-damaged"), system_name] forCount:4.5];
7011 [system_key release];
7030 if (![[
UNIVERSE gameController] playerFileToLoad])
7032 [[UNIVERSE gameController] setPlayerFileToLoad: save_path];
7037 [
self disengageAutopilot];
7039 [UNIVERSE setDisplayText:NO];
7040 [UNIVERSE setViewDirection:VIEW_AFT];
7043 [
self noteKilledBy:whom damageType:type];
7045 [
self becomeLargeExplosion:4.0];
7046 [
self moveForward:100.0];
7053 [[UNIVERSE messageGUI] clear];
7054 [
self suppressTargetLost];
7055 [
self playGameOver];
7056 [UNIVERSE setBlockJSPlayerShipProps:YES];
7057 [
self removeAllEquipment];
7058 [
self loseTargetStatus];
7059 [
self showGameOver];
7067 int ent_count =
UNIVERSE->n_entities;
7069 Entity* my_entities[ent_count];
7071 for (i = 0; i < ent_count; i++)
7072 my_entities[i] = [uni_entities[i] retain];
7073 for (i = 0; i < ent_count ; i++)
7075 Entity* thing = my_entities[i];
7078 ShipEntity* ship = (ShipEntity *)thing;
7079 if (self == [ship primaryTarget])
7081 [ship noteLostTarget];
7085 for (i = 0; i < ent_count; i++)
7087 [my_entities[i] release];
7092- (BOOL) endScenario:(NSString *)key
7096 [
self setStatus:STATUS_RESTART_GAME];
7105 NSParameterAssert(station !=
nil);
7106 if ([
self status] == STATUS_DEAD)
return;
7108 [
self setStatus:STATUS_DOCKING];
7109 [
self setDockedStation:station];
7110 [
self doScriptEvent:OOJSID("shipWillDockWithStation") withArgument:station];
7112 if (![
hud nonlinearScanner])
7114 [hud setScannerZoom: 1.0];
7119 [
self resetAutopilotAI];
7124 [
self safeAllMissiles];
7126 [
self clearTargetMemory];
7129 [UNIVERSE setDisplayText:NO];
7130 [[UNIVERSE gameController] setMouseInteractionModeForFlight];
7131 if ([
self status] == STATUS_LAUNCHING)
return;
7133 [
self setOrientation: kIdentityQuaternion];
7134 [UNIVERSE setUpBreakPattern:[
self breakPatternPosition] orientation:orientation forDocking:YES];
7135 [
self playDockWithStation];
7138 [[UNIVERSE gameView] clearKeys];
7147 [
self setStatus:STATUS_IN_FLIGHT];
7151 [
self setStatus:STATUS_DOCKED];
7152 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
7154 [
self loseTargetStatus];
7156 [
self setPosition:[dockedStation
position]];
7157 [
self setOrientation:kIdentityQuaternion];
7173 [
self setAlertFlag:ALERT_FLAG_DOCKED to:YES];
7180 NSString *escapepodReport = [
self processEscapePods];
7181 [
self addMessageToReport:escapepodReport];
7183 [
self unloadCargoPods];
7190 [
self markAsOffender:[dockedStation
legalStatusOfManifest:shipCommodityData
export:NO] withReason:kOOLegalStatusReasonIllegalImports];
7191 if ([
self bounty] > oldbounty)
7193 [
self addRoleToPlayer:@"trader-smuggler"];
7198 NSString *passengerAndCargoReport = [
self checkPassengerContracts];
7199 [
self addMessageToReport:passengerAndCargoReport];
7201 [UNIVERSE setDisplayText:YES];
7211 [
self penaltyForUnauthorizedDocking];
7223 if (
gui_screen != GUI_SCREEN_MISSION) [
self checkScript];
7226 [
self doScriptEvent:OOJSID("shipDockedWithStation") withArgument:dockedStation];
7228 if ([
self status] == STATUS_LAUNCHING)
return;
7233 [
self setGuiToStatusScreen];
7239 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenOpportunity")];
7245 if (station ==
nil)
return;
7249 [[UNIVERSE gameView] allowStringInput: NO];
7253 [[UNIVERSE gui] clearBackground];
7256 [
self doMissionCallback];
7259 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenEnded")];
7262 if ([station marketMonitored])
7267 if ([
self bounty] > oldbounty)
7269 [
self addRoleToPlayer:@"trader-smuggler"];
7274 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
7276 if (![
hud nonlinearScanner])
7278 [hud setScannerZoom: 1.0];
7280 [
self loadCargoPods];
7290 [
self clearAlertFlags];
7291 [
self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
7295 [
self currentWeaponStats];
7305 [
self clearTargetMemory];
7306 [
self setShowDemoShips:NO];
7307 [UNIVERSE setDisplayText:NO];
7308 [[UNIVERSE gameController] setMouseInteractionModeForFlight];
7310 [[UNIVERSE gameView] clearKeys];
7314 [[UNIVERSE gameView] resetMouse];
7319 [UNIVERSE forceWitchspaceEntries];
7327 [UNIVERSE setUpBreakPattern:[
self breakPatternPosition] orientation:orientation forDocking:YES];
7329 [
self setDockedStation:nil];
7332 [
self checkForAegis];
7336 [UNIVERSE removeDemoShips];
7341 [
self playLaunchFromStation];
7351 if (![
hud nonlinearScanner])
7353 [hud setScannerZoom: 1.0];
7355 [
self safeAllMissiles];
7357 OOViewID previousViewDirection = [UNIVERSE viewDirection];
7358 [UNIVERSE setViewDirection:VIEW_FORWARD];
7359 [
self noteSwitchToView:VIEW_FORWARD fromView:previousViewDirection];
7362 [
self currentWeaponStats];
7364 [
self transitionToAegisNone];
7370 [
self noteLostTarget];
7375 [UNIVERSE setDisplayText:NO];
7381 [UNIVERSE allShipsDoScriptEvent:OOJSID("playerWillEnterWitchspace") andReactToAIMessage:@"PLAYER WITCHSPACE"];
7392 [UNIVERSE setSystemTo:system_id];
7393 galaxy_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:system_id inGalaxy:galaxy_number];
7395 [UNIVERSE setUpUniverseFromWitchspace];
7396 [[UNIVERSE planet] update: 2.34375 * market_rnd];
7397 [[UNIVERSE station] update: 2.34375 * market_rnd];
7404- (BOOL) witchJumpChecklist:(BOOL)isGalacticJump
7407 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
7411 ShipEntity* blocker = [UNIVERSE entityForUniversalID:[
self checkShipsInVicinityForWitchJumpExit]];
7414 [UNIVERSE clearPreviousMessage];
7415 NSString *blockerName = [blocker
name];
7416 [UNIVERSE addMessage:OOExpandKey(@"witch-blocked", blockerName) forCount:4.5];
7417 [
self playWitchjumpBlocked];
7418 [
self setStatus:STATUS_IN_FLIGHT];
7435 [UNIVERSE clearPreviousMessage];
7436 [UNIVERSE addMessage:OOExpandKey(@"witch-no-target") forCount: 4.5];
7437 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
7439 [
self playWitchjumpInsufficientFuel];
7440 [
self setStatus:STATUS_IN_FLIGHT];
7443 else [
self playHyperspaceNoTarget];
7451 [UNIVERSE clearPreviousMessage];
7452 [UNIVERSE addMessage:DESC(@"witch-too-far") forCount: 4.5];
7453 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
7455 [
self playWitchjumpDistanceTooGreat];
7456 [
self setStatus:STATUS_IN_FLIGHT];
7459 else [
self playHyperspaceDistanceTooGreat];
7467 [UNIVERSE clearPreviousMessage];
7468 [UNIVERSE addMessage:DESC(@"witch-no-fuel") forCount: 4.5];
7469 if ([
self status] == STATUS_WITCHSPACE_COUNTDOWN)
7471 [
self playWitchjumpInsufficientFuel];
7472 [
self setStatus:STATUS_IN_FLIGHT];
7475 else [
self playHyperspaceNoFuel];
7484- (void) setJumpType:(BOOL)isGalacticJump
7513 return fuel >= [
self fuelRequiredForJump];
7519 if ([[
self hud] isCompassActive])
7524 ShipScriptEvent(context,
self,
"compassTargetChanged", JSVAL_VOID, jsmode);
7527 [[
self hud] setCompassActive:NO];
7534 if (![
self witchJumpChecklist:
true])
7545 [
self setStatus:STATUS_ENTERING_WITCHSPACE];
7547 [
self setJumpCause:@"galactic jump"];
7548 [
self setPreviousSystemID:[
self currentSystemID]];
7549 ShipScriptEvent(context,
self,
"shipWillEnterWitchspace", STRING_TO_JSVAL(JS_InternString(context, [[
self jumpCause] UTF8String])), INT_TO_JSVAL(destGalaxy));
7552 [
self noteCompassLostTarget];
7556 [UNIVERSE removeAllEntitiesExceptPlayer];
7560 [contracts removeAllObjects];
7563 [parcels removeAllObjects];
7567 [missionDestinations removeAllObjects];
7573 for (i = 0; i < [passengers count]; i++)
7576 NSMutableDictionary* passenger_info = [NSMutableDictionary dictionaryWithDictionary:[passengers oo_dictionaryAtIndex:i]];
7577 [passenger_info setObject:[NSNumber numberWithDouble:ship_clock] forKey:CONTRACT_KEY_ARRIVAL_TIME];
7578 [passengers replaceObjectAtIndex:i withObject:passenger_info];
7585 [
self clearRolesFromPlayer:0.25];
7589 [
self clearRolesFromPlayer:0.5];
7593 [
self clearRolesFromPlayer:0.9];
7595 [roleWeightFlags removeAllObjects];
7596 [roleSystemList removeAllObjects];
7599 [
self removeEquipmentItem:[
self equipmentItemProviding:@"EQ_GAL_DRIVE"]];
7603 [UNIVERSE setGalaxyTo:galaxy_number];
7612 case GALACTIC_HYPERSPACE_BEHAVIOUR_FIXED_COORDINATES:
7613 system_id = [UNIVERSE findSystemNumberAtCoords:galacticHyperspaceFixedCoords withGalaxy:galaxy_number includingHidden:YES];
7615 case GALACTIC_HYPERSPACE_BEHAVIOUR_ALL_SYSTEMS_REACHABLE:
7616 system_id = [UNIVERSE findSystemNumberAtCoords:galaxy_coordinates withGalaxy:galaxy_number includingHidden:YES];
7618 case GALACTIC_HYPERSPACE_BEHAVIOUR_STANDARD:
7621 system_id = [UNIVERSE findConnectedSystemAtCoords:galaxy_coordinates withGalaxy:galaxy_number];
7627 [
self setBounty:0 withReason:kOOLegalStatusReasonNewGalaxy];
7638 if ([
self status] == STATUS_ENTERING_WITCHSPACE
7639 || [
self status] == STATUS_EXITING_WITCHSPACE)
7645 [
self addScannedWormhole:wormhole];
7646 [
self setStatus:STATUS_ENTERING_WITCHSPACE];
7648 [
self setJumpCause:@"wormhole"];
7649 [
self setPreviousSystemID:[
self currentSystemID]];
7656#ifdef OO_DUMP_PLANETINFO
7663 [
self witchJumpTo:[w_hole
destination] misjump:misjump];
7669 if (![
self witchJumpChecklist:
false])
return;
7671 OOSystemID jumpTarget = [
self nextHopTargetSystemID];
7674 unsigned malfunc_chance = 253;
7681 malfunc_chance = 256;
7684#ifdef OO_DUMP_PLANETINFO
7687 BOOL malfunc = ((
ranrot_rand() & 0xff) > malfunc_chance);
7691 if (malfunc && !misjump)
7696 [
self playWitchjumpFailure];
7697 [
self setStatus:STATUS_IN_FLIGHT];
7703 [
self setFuelLeak:[NSString stringWithFormat:@"%f", (randf() + randf()) * 5.0]];
7715 [UNIVERSE addEntity:wormhole];
7716 [
self addScannedWormhole:wormhole];
7718 [
self setStatus:STATUS_ENTERING_WITCHSPACE];
7720 [
self setJumpCause:@"standard jump"];
7721 [
self setPreviousSystemID:[
self currentSystemID]];
7722 ShipScriptEvent(context,
self,
"shipWillEnterWitchspace", STRING_TO_JSVAL(JS_InternString(context, [[
self jumpCause] UTF8String])), INT_TO_JSVAL(jumpTarget));
7725 [
self updateSystemMemory];
7726 NSUInteger legality = [
self legalStatusOfCargoList];
7731 if (maxSpace != availSpace)
7733 [
self addRoleToPlayer:@"trader"];
7734 if (maxSpace - availSpace > 20 || availSpace == 0)
7738 [
self addRoleToPlayer:@"trader"];
7745 if (maxSpace != availSpace && legality > 0)
7747 [
self addRoleToPlayer:@"trader-smuggler"];
7748 if (maxSpace - availSpace > 20 || availSpace == 0)
7750 if (legality >= 20 || legality >= maxSpace)
7752 [
self addRoleToPlayer:@"trader-smuggler"];
7757 [roleWeightFlags removeAllObjects];
7759 [
self noteCompassLostTarget];
7766 [wormhole setMisjumpWithRange:[
self scriptedMisjumpRange]];
7768 [
self witchJumpTo:jumpTarget misjump:misjump];
7772- (void) witchJumpTo:(
OOSystemID)sTo misjump:(BOOL)misjump
7777 [
self setInfoSystemID: sTo moveChart: YES];
7783 [
self adjustTradeInFactorBy:-(1 + (market_rnd & 3))];
7792 if (theSun && [theSun goneNova])
7797 [UNIVERSE removeAllEntitiesExceptPlayer];
7801 [
self setSystemID:sTo];
7802 [
self setBounty:(legalStatus/2) withReason:kOOLegalStatusReasonNewSystem];
7810 if (
randf() < 0.1) [
self erodeReputation];
7812 [wormhole setMisjump];
7817 NSPoint dest = [wormhole destinationCoordinates];
7823 [
self playWitchjumpMisjump];
7824 [UNIVERSE setUpUniverseFromMisjump];
7832 HPVector pos = [UNIVERSE getWitchspaceExitPosition];
7834 HPVector whpos, exitpos;
7836 double min_d1 = [UNIVERSE safeWitchspaceExitDistance];
7838 if (abs((
int)d1) < min_d1)
7840 d1 += ((d1 > 0.0)? min_d1: -min_d1);
7843 exitpos = HPvector_add(pos, HPvector_multiply_scalar(v1, d1));
7845 [
self setOrientation:[UNIVERSE getWitchspaceExitRotation]];
7856 double wh_arrival_time = ([PLAYER clockTimeAdjusted] - [
wormhole arrivalTime]);
7857 if (wh_arrival_time > 0)
7860 whpos = HPvector_add(exitpos, vectorToHPVector(vector_multiply_scalar([
self forwardVector], 1000.0f)));
7861 [wormhole setContainsPlayer:YES];
7866 whpos = HPvector_add(exitpos, vectorToHPVector(vector_multiply_scalar([
self forwardVector], -500.0f)));
7868 [wormhole setExitSpeed:maxFlightSpeed*WORMHOLE_LEADER_SPEED_FACTOR];
7871 HPVector distance = HPvector_subtract(whpos, pos);
7872 if (HPmagnitude2(distance) < min_d1*min_d1 )
7876 distance = HPvector_multiply_scalar(HPvector_normal(distance), min_d1);
7877 whpos = HPvector_add(whpos, distance);
7880 [wormhole setExitPosition: whpos];
7885 [wormhole setExitSpeed:maxFlightSpeed*WORMHOLE_LEADER_SPEED_FACTOR];
7901 [
self setStatus:STATUS_EXITING_WITCHSPACE];
7904 [
self clearTargetMemory];
7905 [
self setShowDemoShips:NO];
7906 [[UNIVERSE gameController] setMouseInteractionModeForFlight];
7907 [UNIVERSE setDisplayText:NO];
7908 [UNIVERSE setWitchspaceBreakPattern:YES];
7909 [
self playExitWitchspace];
7915 [
self clearRoleFromPlayer:NO];
7921 [
self doScriptEvent:OOJSID("playerEnteredNewGalaxy") withArgument:[NSNumber numberWithUnsignedInt:galaxy_number]];
7924 [
self doScriptEvent:OOJSID("shipWillExitWitchspace") withArgument:[
self jumpCause]];
7925 [UNIVERSE setUpBreakPattern:[
self breakPatternPosition] orientation:orientation forDocking:NO];
7933 NSString *systemName =
nil;
7934 NSString *targetSystemName =
nil;
7935 NSString *text =
nil;
7939 if (oldScreen != GUI_SCREEN_STATUS)
7941 [
self noteGUIWillChangeTo:GUI_SCREEN_STATUS];
7947 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
7951 systemName = [UNIVERSE inInterstellarSpace] ?
DESC(
@"interstellar-space") : [
UNIVERSE getSystemName:
system_id];
7954 systemName = [NSString stringWithFormat:@"%@ : %@", systemName, [[
self dockedStation] displayName]];
7957 targetSystemName = [UNIVERSE getSystemName:target_system_id];
7958 NSDictionary *systemInfo = [[UNIVERSE systemManager] getPropertiesForSystem:target_system_id inGalaxy:galaxy_number];
7959 NSInteger concealment = [systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
7962 OOSystemID nextHop = [
self nextHopTargetSystemID];
7964 NSString *nextHopSystemName = [UNIVERSE getSystemName:nextHop];
7965 systemInfo = [[UNIVERSE systemManager] getPropertiesForSystem:nextHop inGalaxy:galaxy_number];
7966 concealment = [systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
7968 targetSystemName =
OOExpandKey(
@"status-hyperspace-system-multi", targetSystemName, nextHopSystemName);
7973 NSString *shipName = [
self displayName];
7974 NSString *legal_desc =
nil, *rating_desc =
nil,
7975 *alert_desc =
nil, *fuel_desc =
nil,
7976 *credits_desc =
nil;
7986 NSString *lightYearsDesc =
DESC(
@"status-light-years-desc");
7991 fuel_desc = [NSString stringWithFormat:@"%.1f %@", fuel/10.0, lightYearsDesc];
7995 text =
DESC(
@"status-commander-@");
7996 [gui
setTitle:[NSString stringWithFormat:text, [
self commanderName]]];
8000 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-present-system"), systemName, nil]
forRow:1];
8002 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-condition"), alert_desc, nil]
forRow:3];
8003 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-fuel"), fuel_desc, nil]
forRow:4];
8004 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-cash"), credits_desc, nil]
forRow:5];
8005 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-legal-status"), legal_desc, nil]
forRow:6];
8006 [gui
setArray:[NSArray arrayWithObjects:DESC(@"status-rating"), rating_desc, nil]
forRow:7];
8010 for (i = 1 ; i <= 7 ; ++i)
8026 [lastTextKey release];
8030 [[UNIVERSE gameView] clearMouse];
8033 if (
EXPECT_NOT([[NSUserDefaults standardUserDefaults] boolForKey:
@"show-ship-model-in-status-screen"]))
8035 [UNIVERSE removeDemoShips];
8036 [
self showShipModelWithKey:[
self shipDataKey] shipData:nil personality:[
self entityPersonalityInt]
8037 factorX:2.5 factorY:1.7 factorZ:8.0 inContext:@"GUI_SCREEN_STATUS"];
8038 [
self setShowDemoShips:YES];
8042 [
self setShowDemoShips:NO];
8045 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
8049 NSDictionary *fgDescriptor =
nil, *bgDescriptor =
nil;
8050 if ([
self status] == STATUS_DOCKED)
8052 fgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"docked_overlay"];
8053 bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"status_docked"];
8057 fgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"overlay"];
8059 else bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"status_in_flight"];
8064 if (bgDescriptor ==
nil) bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"status"];
8068 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
8076 NSMutableArray *quip1 = [NSMutableArray array];
8077 NSMutableArray *quip2 = [NSMutableArray array];
8078 NSEnumerator *eqTypeEnum =
nil;
8080 NSString *desc =
nil;
8081 NSString *alldesc =
nil;
8083 BOOL prioritiseDamaged = [[gui
userSettings] oo_boolForKey:kGuiStatusPrioritiseDamaged defaultValue:YES];
8085 for (eqTypeEnum = [
OOEquipmentType reverseEquipmentEnumerator]; (eqType = [eqTypeEnum nextObject]); )
8089 if ([eqType canCarryMultiple] && ![eqType isMissileOrMine])
8091 NSString *damagedIdentifier = [[eqType
identifier] stringByAppendingString:@"_DAMAGED"];
8092 NSUInteger
count = 0, okcount = 0;
8093 okcount = [
self countEquipmentItem:[eqType
identifier]];
8094 count = okcount + [
self countEquipmentItem:damagedIdentifier];
8100 else if (
count == okcount)
8105 [quip2 addObject:[NSArray arrayWithObjects:[eqType
name], [NSNumber numberWithBool:YES], [eqType
displayColor], nil]];
8110 NSString *equipmentName = [eqType
name];
8112 [quip2 addObject:[NSArray arrayWithObjects:alldesc, [NSNumber numberWithBool:YES], [eqType
displayColor], nil]];
8116 else if (
count == 1 && okcount == 0)
8118 desc = [NSString stringWithFormat:DESC(@"equipment-@-not-available"), [eqType
name]];
8119 if (prioritiseDamaged)
8121 [quip1 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8125 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8131 NSString *equipmentName = [eqType
name];
8132 alldesc =
OOExpandKey(
@"equipment-plural-some-na", okcount,
count, equipmentName);
8133 if (prioritiseDamaged)
8135 [quip1 addObject:[NSArray arrayWithObjects:alldesc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8139 [quip2 addObject:[NSArray arrayWithObjects:alldesc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8143 else if ([
self hasEquipmentItem:[eqType identifier]])
8145 [quip2 addObject:[NSArray arrayWithObjects:[eqType
name], [NSNumber numberWithBool:YES], [eqType
displayColor], nil]];
8150 if ([
self hasEquipmentItem:[[eqType identifier] stringByAppendingString:
@"_DAMAGED"]])
8152 desc = [NSString stringWithFormat:DESC(@"equipment-@-not-available"), [eqType
name]];
8154 if (prioritiseDamaged)
8156 [quip1 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8161 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:NO], [eqType
displayColor], nil]];
8170 desc = [NSString stringWithFormat:DESC_PLURAL(@"equipment-pass-berth-@", max_passengers), max_passengers];
8176 desc = [NSString stringWithFormat:DESC(@"equipment-fwd-weapon-@"),[forward_weapon_type name]];
8177 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], [forward_weapon_type displayColor], nil]];
8181 desc = [NSString stringWithFormat:DESC(@"equipment-aft-weapon-@"),[aft_weapon_type name]];
8182 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], [aft_weapon_type displayColor], nil]];
8186 desc = [NSString stringWithFormat:DESC(@"equipment-port-weapon-@"),[port_weapon_type name]];
8187 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], [port_weapon_type displayColor], nil]];
8191 desc = [NSString stringWithFormat:DESC(@"equipment-stb-weapon-@"),[starboard_weapon_type name]];
8192 [quip2 addObject:[NSArray arrayWithObjects:desc, [NSNumber numberWithBool:YES], [starboard_weapon_type displayColor], nil]];
8196 [quip1 addObjectsFromArray:quip2];
8203 return [eqScripts count];
8207- (NSString *) primedEquipmentName:(NSInteger)offset
8209 NSUInteger c = [
self primedEquipmentCount];
8213 return DESC(
@"equipment-primed-none-hud-label");
8224 NSString *result =
@"";
8225 NSUInteger c = [eqScripts count];
8228 result = [[eqScripts oo_arrayAtIndex:primedEquipment] oo_stringAtIndex:0];
8234- (BOOL) setPrimedEquipment:(NSString *)eqKey showMessage:(BOOL)showMsg
8236 NSUInteger c = [eqScripts count];
8239 BOOL unprimeEq = [eqKey isEqualToString:@""];
8252 [UNIVERSE addMessage:unprimeEq ? OOExpandKey(@"equipment-primed-none") : OOExpandKey(@"equipment-primed", equipmentName) forCount:2.0];
8264 OOJSScript *eqScript = [[eqScripts oo_arrayAtIndex:index] objectAtIndex:1];
8295- (void) setFastEquipmentA:(NSString *)eqKey
8297 [_fastEquipmentA release];
8302- (void) setFastEquipmentB:(NSString *)eqKey
8304 [_fastEquipmentB release];
8341 [
self tidyMissilePylons];
8342 return [
super missilesList];
8348 NSMutableArray *manifest = [NSMutableArray array];
8349 NSArray *list = [
self cargoListForScripting];
8350 NSEnumerator *cargoEnum =
nil;
8351 NSDictionary *commodity;
8355 for (cargoEnum = [list objectEnumerator]; (commodity = [cargoEnum nextObject]); )
8357 NSInteger quantity = [commodity oo_integerForKey:@"quantity"];
8358 NSString *units = [commodity oo_stringForKey:@"unit"];
8359 NSString *commodityName = [commodity oo_stringForKey:@"displayName"];
8360 NSInteger containers = [commodity oo_intForKey:@"containers"];
8361 BOOL extended = ![units isEqualToString:DESC(@"cargo-tons-symbol")] && containers > 0;
8364 [manifest addObject:OOExpandKey(@"manifest-cargo-quantity-extended", quantity, units, commodityName, containers)];
8366 [manifest addObject:OOExpandKey(@"manifest-cargo-quantity", quantity, units, commodityName)];
8376 NSMutableArray *list = [NSMutableArray array];
8378 NSUInteger i, j, commodityCount = [shipCommodityData count];
8381 NSArray *goods = [shipCommodityData goods];
8384 for (i = 0; i < commodityCount; i++)
8386 quantityInHold[i] = [shipCommodityData quantityForGood:[goods oo_stringAtIndex:i]];
8387 containersInHold[i] = 0;
8389 for (i = 0; i < [cargo count]; i++)
8391 ShipEntity *container = [cargo objectAtIndex:i];
8394 ++containersInHold[j];
8397 for (i = 0; i < commodityCount; i++)
8399 if (quantityInHold[i] > 0)
8401 NSMutableDictionary *commodity = [NSMutableDictionary dictionaryWithCapacity:4];
8402 NSString *symName = [goods oo_stringAtIndex:i];
8404 [commodity setObject:symName forKey:@"commodity"];
8405 [commodity setObject:[NSNumber numberWithUnsignedInt:quantityInHold[i]] forKey:@"quantity"];
8406 [commodity setObject:[NSNumber numberWithUnsignedInt:containersInHold[i]] forKey:@"containers"];
8407 [commodity setObject:[shipCommodityData nameForGood:symName] forKey:@"displayName"];
8408 [commodity setObject:DisplayStringForMassUnitForCommodity(symName) forKey:@"unit"];
8409 [list addObject:commodity];
8413 return [[list copy] autorelease];
8420 NSString *good =
nil;
8422 unsigned penalty = 0;
8426 amount = [shipCommodityData quantityForGood:good];
8433- (NSArray*) contractsListForScriptingFromArray:(NSArray *) contracts_array forCargo:(BOOL)forCargo
8435 NSMutableArray *result = [NSMutableArray array];
8438 for (i = 0; i < [contracts_array count]; i++)
8440 NSMutableDictionary *contract = [NSMutableDictionary dictionaryWithCapacity:10];
8441 NSDictionary *dict = [contracts_array oo_dictionaryAtIndex:i];
8445 [contract setObject:[dict oo_stringForKey:CARGO_KEY_TYPE] forKey:@"commodity"];
8446 [contract setObject:[NSNumber numberWithUnsignedInt:[dict oo_intForKey:CARGO_KEY_AMOUNT]] forKey:@"quantity"];
8447 [contract setObject:[dict oo_stringForKey:CARGO_KEY_DESCRIPTION] forKey:@"description"];
8451 [contract setObject:[dict oo_stringForKey:PASSENGER_KEY_NAME] forKey:PASSENGER_KEY_NAME];
8452 [contract setObject:[NSNumber numberWithUnsignedInt:[dict oo_unsignedIntForKey:CONTRACT_KEY_RISK]] forKey:CONTRACT_KEY_RISK];
8455 OOSystemID planet = [dict oo_intForKey:CONTRACT_KEY_DESTINATION];
8456 NSString *planetName = [UNIVERSE getSystemName:planet];
8457 [contract setObject:[NSNumber numberWithUnsignedInt:planet] forKey:CONTRACT_KEY_DESTINATION];
8458 [contract setObject:planetName forKey:@"destinationName"];
8459 planet = [dict oo_intForKey:CONTRACT_KEY_START];
8460 planetName = [UNIVERSE getSystemName: planet];
8461 [contract setObject:[NSNumber numberWithUnsignedInt:planet] forKey:CONTRACT_KEY_START];
8462 [contract setObject:planetName forKey:@"startName"];
8464 int dest_eta = [dict oo_doubleForKey:CONTRACT_KEY_ARRIVAL_TIME] -
ship_clock;
8465 [contract setObject:[NSNumber numberWithInt:dest_eta] forKey:@"eta"];
8466 [contract setObject:[UNIVERSE shortTimeDescription:dest_eta] forKey:@"etaDescription"];
8467 [contract setObject:[NSNumber numberWithInt:[dict oo_intForKey:CONTRACT_KEY_PREMIUM]] forKey:CONTRACT_KEY_PREMIUM];
8468 [contract setObject:[NSNumber numberWithInt:[dict oo_intForKey:CONTRACT_KEY_FEE]] forKey:CONTRACT_KEY_FEE];
8469 [result addObject:contract];
8472 return [[result copy] autorelease];
8478 return [
self contractsListForScriptingFromArray:passengers forCargo:NO];
8484 return [
self contractsListForScriptingFromArray:parcels forCargo:NO];
8490 return [
self contractsListForScriptingFromArray:contracts forCargo:YES];
8495 [
self setGuiToSystemDataScreenRefreshBackground: NO];
8498- (void) setGuiToSystemDataScreenRefreshBackground: (BOOL) refreshBackground
8500 NSDictionary *infoSystemData;
8501 NSString *infoSystemName;
8503 infoSystemData = [[UNIVERSE generateSystemData:info_system_id] retain];
8504 NSInteger concealment = [infoSystemData oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
8505 infoSystemName = [infoSystemData oo_stringForKey:KEY_NAME];
8507 BOOL sunGoneNova = ([infoSystemData oo_boolForKey:@"sun_gone_nova"]);
8514 Random_Seed infoSystemRandomSeed = [[UNIVERSE systemManager] getRandomSeedForSystem:info_system_id
8515 inGalaxy:[
self galaxyNumber]];
8517 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
8528 NSUInteger techLevel = [infoSystemData oo_intForKey:KEY_TECHLEVEL] + 1;
8529 int population = [infoSystemData oo_intForKey:KEY_POPULATION];
8530 int productivity = [infoSystemData oo_intForKey:KEY_PRODUCTIVITY];
8531 int radius = [infoSystemData oo_intForKey:KEY_RADIUS];
8533 NSString *government_desc = [infoSystemData oo_stringForKey:KEY_GOVERNMENT_DESC
8534 defaultValue:OODisplayStringFromGovernmentID([infoSystemData oo_intForKey:KEY_GOVERNMENT])];
8535 NSString *economy_desc = [infoSystemData oo_stringForKey:KEY_ECONOMY_DESC
8536 defaultValue:OODisplayStringFromEconomyID([infoSystemData oo_intForKey:KEY_ECONOMY])];
8537 NSString *inhabitants = [infoSystemData oo_stringForKey:KEY_INHABITANTS];
8538 NSString *system_desc = [infoSystemData oo_stringForKey:KEY_DESCRIPTION];
8540 NSString *populationDesc = [infoSystemData oo_stringForKey:KEY_POPULATION_DESC
8541 defaultValue:OOExpandKeyWithSeed(kNilRandomSeed, @"sysdata-pop-value", population)];
8554 NSString *system = infoSystemName;
8555 system_desc =
OOExpandKeyWithSeed(infoSystemRandomSeed,
@"nova-system-description", system);
8557 populationDesc =
OOExpandKeyWithSeed(infoSystemRandomSeed,
@"sysdata-pop-value", population);
8562 [UNIVERSE removeDemoShips];
8566 NSString *system = infoSystemName;
8567 [gui
setTitle:OOExpandKeyWithSeed(infoSystemRandomSeed, @"sysdata-data-on-system", system)];
8571 [gui
setTitle:OOExpandKey(@"sysdata-data-on-system-no-name")];
8578 for (i-- ; i > 14 ; --i)
8585 NSPoint infoSystemCoordinates = [[UNIVERSE systemManager] getCoordinatesForSystem: info_system_id inGalaxy: galaxy_number];
8591 NSString *distanceInfo = [NSString stringWithFormat: @"%.1f ly", distance];
8594 NSDictionary *routeInfo =
nil;
8595 routeInfo = [UNIVERSE routeFromSystem: system_id toSystem: info_system_id optimizedBy: ANA_mode];
8596 if (routeInfo !=
nil)
8598 double routeDistance = [[routeInfo objectForKey: @"distance"] doubleValue];
8599 double routeTime = [[routeInfo objectForKey: @"time"] doubleValue];
8600 int routeJumps = [[routeInfo objectForKey: @"jumps"] intValue];
8602 routeDistance = 0.1;
8606 distanceInfo = [NSString stringWithFormat: @"%.1f ly / %.1f %@ / %d %@",
8610 routeTime > 1.05 || routeTime < 0.95 ? DESC(@"sysdata-route-hours%1") : DESC(@"sysdata-route-hours%0"),
8612 DESC_PLURAL(@"sysdata-route-jumps", routeJumps)];
8618 for (i = 1; i <= 16; i++) {
8619 NSString *ln = [NSString stringWithFormat:@"sysdata-line-%ld", (long)i];
8620 NSString *line =
OOExpandKeyWithSeed(infoSystemRandomSeed, ln, economy_desc, government_desc, techLevel, populationDesc, inhabitants, productivity, radius, distanceInfo);
8621 if (![line isEqualToString:
@""])
8623 NSArray *lines = [line componentsSeparatedByString:@"\t"];
8624 if ([lines
count] == 1)
8626 [gui
setArray:[NSArray arrayWithObjects:[lines objectAtIndex:0],
8630 if ([lines
count] == 2)
8632 [gui
setArray:[NSArray arrayWithObjects:[lines objectAtIndex:0],
8633 [lines objectAtIndex:1],
8637 if ([lines
count] == 3)
8639 if ([[lines objectAtIndex:2] isEqualToString:
@""])
8641 [gui
setArray:[NSArray arrayWithObjects:[lines objectAtIndex:0],
8642 [lines objectAtIndex:1],
8648 [gui
setArray:[NSArray arrayWithObjects:[lines objectAtIndex:0],
8649 [lines objectAtIndex:1],
8650 [lines objectAtIndex:2],
8658 [gui
setArray:[NSArray arrayWithObjects:@"",
8667 for (i-- ; i > 16 ; --i)
8671 for (i = 1 ; i <= 14 ; ++i)
8682 [lastTextKey release];
8685 [[UNIVERSE gameView] clearMouse];
8687 [infoSystemData release];
8689 [
self setShowDemoShips:NO];
8690 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
8702 [
self setBackgroundFromDescriptionsKey:@"gui-scene-show-local-planet"];
8706 [
self setBackgroundFromDescriptionsKey:@"gui-scene-show-planet"];
8713 if (refreshBackground || guiChanged)
8718 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen refresh: refreshBackground];
8724- (void) prepareMarkedDestination:(NSMutableDictionary *)markers :(NSDictionary *)marker
8726 NSNumber *key = [NSNumber numberWithInt:[marker oo_intForKey:@"system"]];
8727 NSMutableArray *list = [markers objectForKey:key];
8730 list = [NSMutableArray arrayWithObject:marker];
8734 [list addObject:marker];
8736 [markers setObject:list forKey:key];
8743 NSMutableDictionary *destinations = [NSMutableDictionary dictionaryWithCapacity:256];
8746 NSDictionary *marker;
8748 for (i = 0; i < [passengers count]; i++)
8750 sysid = [[passengers oo_dictionaryAtIndex:i] oo_unsignedCharForKey:CONTRACT_KEY_DESTINATION];
8751 marker = [
self passengerContractMarker:sysid];
8752 [
self prepareMarkedDestination:destinations:marker];
8754 for (i = 0; i < [parcels count]; i++)
8756 sysid = [[parcels oo_dictionaryAtIndex:i] oo_unsignedCharForKey:CONTRACT_KEY_DESTINATION];
8757 marker = [
self parcelContractMarker:sysid];
8758 [
self prepareMarkedDestination:destinations:marker];
8760 for (i = 0; i < [contracts count]; i++)
8762 sysid = [[contracts oo_dictionaryAtIndex:i] oo_unsignedCharForKey:CONTRACT_KEY_DESTINATION];
8763 marker = [
self cargoContractMarker:sysid];
8764 [
self prepareMarkedDestination:destinations:marker];
8767 NSEnumerator *keyEnum =
nil;
8768 NSString *key =
nil;
8772 marker = [missionDestinations objectForKey:key];
8773 [
self prepareMarkedDestination:destinations:marker];
8776 return destinations;
8785 [
self setMissionBackgroundSpecial: nil];
8788 [
self setGuiToChartScreenFrom: oldScreen];
8797 [
self setMissionBackgroundSpecial: nil];
8799 [
self setGuiToChartScreenFrom: oldScreen];
8808 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
8810 target_system_id = [UNIVERSE findSystemNumberAtCoords:cursor_coordinates withGalaxy:galaxy_number includingHidden:NO];
8812 [UNIVERSE preloadPlanetTexturesForSystem:target_system_id];
8830 if (
gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
8832 NSString *displaySearchString =
planetSearchString ? [planetSearchString capitalizedString] : (NSString *)
@"";
8833 [gui
setText:[NSString stringWithFormat:DESC(@"long-range-chart-find-planet-@"), displaySearchString]
forRow:GUI_ROW_PLANET_FINDER];
8845 [
self setShowDemoShips:NO];
8846 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
8855 [UNIVERSE findSystemCoordinatesWithPrefix:[[UNIVERSE getSystemName:found_system_id] lowercaseString] exactMatch:YES];
8857 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
8864 NSString *filledSlider = [@"|||||||||||||||||||||||||" substringToIndex:amountIn20ths];
8865 NSString *emptySlider = [@"........................." substringToIndex:20 - amountIn20ths];
8866 return [NSString stringWithFormat:@"%@%@", filledSlider, emptySlider];
8874 [[UNIVERSE gameView] clearMouse];
8875 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
8879 #define OO_SETACCESSCONDITIONFORROW(condition, row) \
8883 [gui setKey:GUI_KEY_OK forRow:(row)]; \
8887 [gui setColor:[OOColor grayColor] forRow:(row)]; \
8890 BOOL startingGame = [
self status] == STATUS_START_GAME;
8897 [gui
setTitle:[NSString stringWithFormat:DESC(@"status-commander-@"), [
self commanderName]]];
8899#if OO_RESOLUTION_OPTION
8903 if (displayModeIndex == NSNotFound)
8905 OOLogWARN(
@"display.currentMode.notFound",
@"%@",
@"couldn't find current fullscreen setting, switching to default.");
8906 displayModeIndex = 0;
8911 if ([modeList
count])
8913 mode = [modeList objectAtIndex:displayModeIndex];
8917 unsigned modeWidth = [mode oo_unsignedIntForKey:kOODisplayWidth];
8918 unsigned modeHeight = [mode oo_unsignedIntForKey:kOODisplayHeight];
8919 float modeRefresh = [mode oo_floatForKey:kOODisplayRefreshRate];
8923 if (!runningOnPrimaryDisplayDevice)
8925 MONITORINFOEX mInfo = [gameView currentMonitorInfo];
8926 modeWidth = mInfo.rcMonitor.right - mInfo.rcMonitor.left;
8927 modeHeight = mInfo.rcMonitor.bottom - mInfo.rcMonitor.top;
8931 NSString *displayModeString = [
self screenModeStringForWidth:modeWidth height:modeHeight refreshRate:modeRefresh];
8934 if (runningOnPrimaryDisplayDevice)
8946 if ([gameView hdrOutput])
8948 NSArray *brightnesses = [[UNIVERSE descriptions] oo_arrayForKey: @"hdr_maxBrightness_array"];
8949 int brightnessIdx = [brightnesses indexOfObject:[NSString stringWithFormat:@"%d", (int)[gameView hdrMaxBrightness]]];
8951 if (brightnessIdx == NSNotFound)
8953 OOLogWARN(
@"hdr.maxBrightness.notFound",
@"%@",
@"couldn't find current max brightness setting, switching to 400 nits.");
8957 int brightnessValue = [brightnesses oo_intAtIndex:brightnessIdx];
8958 NSString *maxBrightnessString =
OOExpandKey(
@"gameoptions-hdr-maxbrightness", brightnessValue);
8960 [gui
setText:maxBrightnessString
forRow:GUI_ROW(GAME,HDRMAXBRIGHTNESS)
align:GUI_ALIGN_CENTER];
8961 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,HDRMAXBRIGHTNESS)];
8967 [gui
setText:DESC(@"gameoptions-autosave-yes")
forRow:GUI_ROW(GAME,AUTOSAVE)
align:GUI_ALIGN_CENTER];
8969 [gui
setText:DESC(@"gameoptions-autosave-no")
forRow:GUI_ROW(GAME,AUTOSAVE)
align:GUI_ALIGN_CENTER];
8973 if ([
OOSound respondsToSelector:
@selector(masterVolume)] && [
OOSound isSoundOK])
8976 int vol = (
volume / 5.0 + 0.5);
8977 NSString* soundVolumeWordDesc =
DESC(
@"gameoptions-sound-volume");
8979 [gui
setText:[NSString stringWithFormat:@"%@%@ ", soundVolumeWordDesc, SliderString(vol)]
forRow:GUI_ROW(GAME,VOLUME)
align:GUI_ALIGN_CENTER];
8981 [gui
setText:DESC(@"gameoptions-sound-volume-mute")
forRow:GUI_ROW(GAME,VOLUME)
align:GUI_ALIGN_CENTER];
8986 [gui
setText:DESC(@"gameoptions-volume-external-only")
forRow:GUI_ROW(GAME,VOLUME)
align:GUI_ALIGN_CENTER];
8993 int gamma5 = (gamma * 5);
8994 NSString* gammaWordDesc =
DESC(
@"gameoptions-gamma-value");
8995 [gui
setText:[NSString stringWithFormat:@"%@%@ (%.1f) ", gammaWordDesc, SliderString(gamma5), gamma]
forRow:GUI_ROW(GAME,GAMMA)
align:GUI_ALIGN_CENTER];
9000 float fov = [gameView
fov:NO];
9002 NSString* fovWordDesc =
DESC(
@"gameoptions-fov-value");
9003 [gui
setText:[NSString stringWithFormat:@"%@%@ (%d%c) ", fovWordDesc, SliderString(fovTicks), (int)fov, 176 ]
forRow:GUI_ROW(GAME,FOV)
align:GUI_ALIGN_CENTER];
9007 int colorblindMode = [UNIVERSE colorblindMode];
9008 NSString *colorblindModeDesc = [[[UNIVERSE descriptions] oo_arrayForKey: @"colorblind_mode"] oo_stringAtIndex:[UNIVERSE useShaders] ? colorblindMode : 0];
9009 NSString *colorblindModeMsg =
OOExpandKey(
@"gameoptions-colorblind-mode", colorblindModeDesc);
9010 [gui
setText:colorblindModeMsg
forRow:GUI_ROW(GAME,COLORBLINDMODE)
align:GUI_ALIGN_CENTER];
9013 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,COLORBLINDMODE)];
9020#if OOLITE_SPEECH_SYNTH
9025 [gui
setText:DESC(@"gameoptions-spoken-messages-no")
forRow:GUI_ROW(GAME,SPEECH)
align:GUI_ALIGN_CENTER];
9028 [gui
setText:DESC(@"gameoptions-spoken-messages-comms")
forRow:GUI_ROW(GAME,SPEECH)
align:GUI_ALIGN_CENTER];
9031 [gui
setText:DESC(@"gameoptions-spoken-messages-yes")
forRow:GUI_ROW(GAME,SPEECH)
align:GUI_ALIGN_CENTER];
9038 NSString *voiceName = [UNIVERSE voiceName:voice_no];
9039 NSString *message =
OOExpandKey(
@"gameoptions-voice-name", voiceName);
9043 message = [NSString stringWithFormat:DESC(voice_gender_m ? @"gameoptions-voice-M" : @"gameoptions-voice-F")];
9051 if([gameView inFullScreenMode])
9053 [gui
setText:DESC(@"gameoptions-play-in-window")
forRow:GUI_ROW(GAME,DISPLAYSTYLE)
align:GUI_ALIGN_CENTER];
9057 [gui
setText:DESC(@"gameoptions-play-in-fullscreen")
forRow:GUI_ROW(GAME,DISPLAYSTYLE)
align:GUI_ALIGN_CENTER];
9059 [gui
setKey: GUI_KEY_OK
forRow: GUI_ROW(GAME,DISPLAYSTYLE)];
9062 [gui
setText:DESC(@"gameoptions-joystick-configuration")
forRow: GUI_ROW(GAME,STICKMAPPER)
align: GUI_ALIGN_CENTER];
9065 [gui
setText:DESC(@"gameoptions-keyboard-configuration")
forRow: GUI_ROW(GAME,KEYMAPPER)
align: GUI_ALIGN_CENTER];
9066 [gui
setKey: GUI_KEY_OK
forRow: GUI_ROW(GAME,KEYMAPPER)];
9070 NSString *message =
OOExpandKey(
@"gameoptions-music-mode", musicMode);
9074 if (![gameView hdrOutput])
9077 [gui
setText:DESC(@"gameoptions-wireframe-graphics-yes")
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)
align:GUI_ALIGN_CENTER];
9079 [gui
setText:DESC(@"gameoptions-wireframe-graphics-no")
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)
align:GUI_ALIGN_CENTER];
9080 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,WIREFRAMEGRAPHICS)];
9085 float paperWhite = [gameView hdrPaperWhiteBrightness];
9087 NSString* paperWhiteWordDesc =
DESC(
@"gameoptions-hdr-paperwhite");
9088 [gui
setText:[NSString stringWithFormat:@"%@%@ (%d) ", paperWhiteWordDesc, SliderString(paperWhiteTicks), (int)paperWhite]
forRow:GUI_ROW(GAME,HDRPAPERWHITE)
align:GUI_ALIGN_CENTER];
9089 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,HDRPAPERWHITE)];
9094 if ([
UNIVERSE doProcedurallyTexturedPlanets])
9095 [gui
setText:DESC(@"gameoptions-procedurally-textured-planets-yes")
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)
align:GUI_ALIGN_CENTER];
9097 [gui
setText:DESC(@"gameoptions-procedurally-textured-planets-no")
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)
align:GUI_ALIGN_CENTER];
9098 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,PROCEDURALLYTEXTUREDPLANETS)];
9102 NSString *shaderEffectsOptionsString =
OOExpand(
@"gameoptions-detaillevel-[detailLevel]", detailLevel);
9103 [gui
setText:OOExpandKey(shaderEffectsOptionsString)
forRow:GUI_ROW(GAME,SHADEREFFECTS)
align:GUI_ALIGN_CENTER];
9106 [gui
setKey:GUI_KEY_OK
forRow:GUI_ROW(GAME,SHADEREFFECTS)];
9115 if ([
UNIVERSE dockingClearanceProtocolActive])
9117 [gui
setText:DESC(@"gameoptions-docking-clearance-yes")
forRow:GUI_ROW(GAME,DOCKINGCLEARANCE)
align:GUI_ALIGN_CENTER];
9121 [gui
setText:DESC(@"gameoptions-docking-clearance-no")
forRow:GUI_ROW(GAME,DOCKINGCLEARANCE)
align:GUI_ALIGN_CENTER];
9129 [gui
setSelectableRange:NSMakeRange(first_sel_row, GUI_ROW_GAMEOPTIONS_END_OF_LIST)];
9138 [
self setShowDemoShips:NO];
9141 [
self setShowDemoShips:NO];
9142 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
9148 BOOL gamePaused = [[UNIVERSE gameController] isGamePaused];
9149 BOOL canLoadOrSave = NO;
9153 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
9155 if ([
self status] == STATUS_DOCKED)
9158 canLoadOrSave = (([
self dockedStation] == [UNIVERSE station] || [[
self dockedStation] allowsSaving]) && !([[UNIVERSE sun] goneNova] || [[UNIVERSE sun] willGoNova]));
9168 int first_sel_row = (canLoadOrSave)?
GUI_ROW(,SAVE) :
GUI_ROW(,GAMEOPTIONS);
9170 first_sel_row =
GUI_ROW(,QUICKSAVE);
9173 [gui
setTitle:[NSString stringWithFormat:DESC(@"status-commander-@"), [
self commanderName]]];
9175 [gui
setText:DESC(@"options-quick-save")
forRow:GUI_ROW(,QUICKSAVE)
align:GUI_ALIGN_CENTER];
9181 [gui
setText:DESC(@"options-save-commander")
forRow:GUI_ROW(,SAVE)
align:GUI_ALIGN_CENTER];
9182 [gui
setText:DESC(@"options-load-commander")
forRow:GUI_ROW(,LOAD)
align:GUI_ALIGN_CENTER];
9194 [gui
setText:DESC(@"options-return-to-menu")
forRow:GUI_ROW(,BEGIN_NEW)
align:GUI_ALIGN_CENTER];
9197 [gui
setText:DESC(@"options-game-options")
forRow:GUI_ROW(,GAMEOPTIONS)
align:GUI_ALIGN_CENTER];
9205 [gui
setText:DESC(@"options-exit-game")
forRow:GUI_ROW(,QUIT)
align:GUI_ALIGN_CENTER];
9211 if (gamePaused || (!canLoadOrSave && [
self status] == STATUS_DOCKED))
9222 if ([gui setForegroundTextureKey:[
self status] == STATUS_DOCKED ?
@"docked_overlay" :
@"paused_overlay"] && [
UNIVERSE pauseMessageVisible])
9223 [[UNIVERSE messageGUI] clear];
9229 [[UNIVERSE gameView] clearMouse];
9231 [
self setShowDemoShips:NO];
9234 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
9238 [[UNIVERSE messageGUI] clear];
9239 NSString *pauseKey = [PLAYER keyBindingDescription2:@"key_pausebutton"];
9240 [UNIVERSE addMessage:OOExpandKey(@"game-paused-docked", pauseKey) forCount:1.0 forceDisplay:YES];
9243 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
9250- (void) highlightEquipShipScreenKey:(NSString *)key
9254 NSString *otherKey =
@"";
9256 [last_outfitting_key release];
9278 if ([otherKey isEqualToString:key])
9285 if ([otherKey hasPrefix:
@"More:"])
9287 i = [[otherKey componentsSeparatedByString:@":"] oo_intAtIndex:1];
9302 unsigned available_facings = [shipyardInfo oo_unsignedIntForKey:KEY_WEAPON_FACINGS defaultValue:[
self weaponFacings]];
9308- (void) setGuiToEquipShipScreen:(
int)skipParam selectingFacingFor:(NSString *)eqKeyForSelectFacing
9310 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
9314 NSString *showKey =
nil;
9320 searchStatus = STATUS_TEST;
9325 searchStatus = STATUS_ACTIVE;
9332 double priceFactor = 1.0;
9333 OOTechLevelID techlevel = [[UNIVERSE currentSystemData] oo_intForKey:KEY_TECHLEVEL];
9344 NSMutableArray *equipmentAllowed = [NSMutableArray array];
9349 NSMutableSet *options = [NSMutableSet setWithArray:[shipyardInfo oo_arrayForKey:KEY_OPTIONAL_EQUIPMENT]];
9352 [options addObjectsFromArray:[[shipyardInfo oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_arrayForKey:KEY_EQUIPMENT_EXTRAS]];
9355 NSEnumerator *eqEnum =
nil;
9357 unsigned available_facings = [shipyardInfo oo_unsignedIntForKey:KEY_WEAPON_FACINGS defaultValue:[
self weaponFacings]];
9360 if (eqKeyForSelectFacing !=
nil)
9364 [equipmentAllowed addObject:eqKeyForSelectFacing];
9365 [equipmentAllowed addObject:eqKeyForSelectFacing];
9366 [equipmentAllowed addObject:eqKeyForSelectFacing];
9368 else for (eqEnum = [
OOEquipmentType equipmentEnumeratorOutfitting]; (eqType = [eqEnum nextObject]); i++)
9377 if ([eqType isAvailableToAll]) [options addObject:eqKey];
9380 if (minTechLevel != 0 && [
self hasEquipmentItem:[eqType damagedIdentifier]]) minTechLevel--;
9383 if (techlevel < minTechLevel && techlevel + 3 > minTechLevel)
9385 unsigned day = i * 13 + (unsigned)floor([
UNIVERSE getTime] / 86400.0);
9386 unsigned char dayRnd = (day & 0xff) ^ (
unsigned char)
system_id;
9389 while (minTechLevel > 0 && minTechLevel > originalMinTechLevel - 3 && !(dayRnd & 7))
9391 dayRnd = dayRnd >> 2;
9397 if ([options containsObject:eqKey])
9400 [options removeObject:eqKey];
9405 if (techlevel < minTechLevel) isOK = NO;
9406 if (![
self canAddEquipment:eqKey inContext:
@"purchase"]) isOK = NO;
9407 if (available_facings == 0 && [eqType isPrimaryWeapon]) isOK = NO;
9408 if (isOK) [equipmentAllowed addObject:eqKey];
9411 if (searchStatus == STATUS_DEAD && isOK)
9414 searchStatus = STATUS_ACTIVE;
9416 if (searchStatus == STATUS_TEST)
9418 if (isOK) showKey = eqKey;
9420 searchStatus = isOK ? STATUS_ACTIVE : STATUS_DEAD;
9423 if (searchStatus != STATUS_TEST && showKey !=
nil)
9425 [last_outfitting_key release];
9434 unsigned facing_count = 0;
9435 BOOL displayRow = YES;
9436 BOOL weaponMounted = NO;
9437 BOOL guiChanged = (
gui_screen != GUI_SCREEN_EQUIP_SHIP);
9440 [gui
setTitle:DESC(@"equip-title")];
9443 [gui
setText:OOExpandKey(@"equip-cash-value", credits)
forRow:GUI_ROW_EQUIPMENT_CASH];
9447 tab_stops[1] = -360;
9448 tab_stops[2] = -480;
9453 NSUInteger
count = [equipmentAllowed count];
9461 if (
count <= n_rows || skip < n_rows)
9465 previous = skip - (n_rows - 2);
9470 if (eqKeyForSelectFacing !=
nil)
9474 [gui
setKey:[NSString stringWithFormat:@"More:%d:%@", previous, eqKeyForSelectFacing]
forRow:row];
9478 [gui
setKey:[NSString stringWithFormat:@"More:%d", previous]
forRow:row];
9481 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @"", @" <-- ", nil]
forRow:row];
9485 for (i = skip; i <
count && (row - start_row < (
OOGUIRow)n_rows); i++)
9487 NSString *eqKey = [equipmentAllowed oo_stringAtIndex:i];
9490 NSString *desc = [NSString stringWithFormat:@" %@ ", [eqInfo
name]];
9498 if ([eqKey isEqual:
@"EQ_FUEL"])
9502 else if ([eqKey isEqualToString:
@"EQ_RENOVATION"])
9504 price = [
self renovationCosts];
9509 price = pricePerUnit;
9512 price = [
self adjustPriceByScriptForEqKey:eqKey withCurrent:price];
9514 price *= priceFactor;
9517 if (installTime == 0)
9519 installTime = 600 + price;
9522 if ([
self hasEquipmentItem:eq_key_damaged])
9524 desc = [NSString stringWithFormat:DESC(@"equip-repair-@"), desc];
9527 if (installTime == 0)
9529 installTime = 600 + price;
9535 NSString *timeString = [UNIVERSE shortTimeDescription:installTime];
9536 NSString *priceString = [NSString stringWithFormat:@" %@ ", OOCredits(price)];
9538 if ([eqKeyForSelectFacing isEqualToString:eqKey])
9541 while (facing_count < 5)
9543 NSUInteger multiplier = 1;
9544 switch (facing_count)
9555 multiplier = [forwardWeaponOffset count];
9565 multiplier = [aftWeaponOffset count];
9575 multiplier = [portWeaponOffset count];
9585 multiplier = [starboardWeaponOffset count];
9601 priceString = [NSString stringWithFormat:@" %@ ", OOCredits(price*multiplier)];
9604 [gui
setArray:[NSArray arrayWithObjects:desc, (facing_count > 0 ? priceString : (NSString *)@""), timeString, nil]
forRow:row];
9615 if (![eqInfo hideValues])
9617 [gui
setArray:[NSArray arrayWithObjects:desc, priceString, timeString, nil]
forRow:row];
9632 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @"", @" --> ", nil]
forRow:row - 1];
9633 [gui
setKey:[NSString stringWithFormat:@"More:%d", i - 1]
forRow:row - 1];
9638 if ([gui selectedRow] != start_row)
9639 [gui setSelectedRow:start_row];
9641 if (eqKeyForSelectFacing !=
nil)
9644 [
self showInformationForSelectedUpgradeWithFormatString:DESC(@"@-select-where-to-install")];
9648 [
self showInformationForSelectedUpgrade];
9653 [gui
setText:DESC(@"equip-no-equipment-available-for-purchase")
forRow:GUI_ROW_NO_SHIPS
align:GUI_ALIGN_CENTER];
9658 [
self showInformationForSelectedUpgrade];
9667 NSDictionary *background = [UNIVERSE screenTextureDescriptorForKey:@"equip_ship"];
9668 [
self setEquipScreenBackgroundDescriptor:background];
9671 else if (eqKeyForSelectFacing !=
nil)
9673 NSDictionary *bgDescriptor = [UNIVERSE screenTextureDescriptorForKey:@"mount_weapon"];
9684 [
self setShowDemoShips:NO];
9687 [
self setShowDemoShips:NO];
9688 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
9692- (void) setGuiToEquipShipScreen:(
int)skip
9694 [
self setGuiToEquipShipScreen:skip selectingFacingFor:nil];
9700 [
self showInformationForSelectedUpgradeWithFormatString:nil];
9704- (void) showInformationForSelectedUpgradeWithFormatString:(NSString *)formatString
9718 if (![eqKey hasPrefix:
@"More:"])
9721 NSString* eq_key_damaged = [NSString stringWithFormat:@"%@_DAMAGED", eqKey];
9723 if ([
self hasEquipmentItem:eq_key_damaged])
9725 desc = [NSString stringWithFormat:DESC(@"upgradeinfo-@-price-is-for-repairing"), desc];
9729 if([eqKey hasSuffix:
@"ENERGY_UNIT"] && ([
self hasEquipmentItem:
@"EQ_ENERGY_UNIT_DAMAGED"] || [
self hasEquipmentItem:
@"EQ_ENERGY_UNIT"] || [
self hasEquipmentItem:
@"EQ_NAVAL_ENERGY_UNIT_DAMAGED"]))
9730 desc = [NSString stringWithFormat:DESC(@"@-will-replace-other-energy"), desc];
9731 if (weight > 0) desc = [NSString stringWithFormat:DESC(@"upgradeinfo-@-weight-d-of-equipment"), desc, weight];
9733 if (formatString) desc = [NSString stringWithFormat:formatString, desc];
9740- (void) setGuiToInterfacesScreen:(
int)skip
9742 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
9745 [
self noteGUIWillChangeTo:GUI_SCREEN_INTERFACES];
9749 NSDictionary *interfaces = [[
self dockedStation] localInterfaces];
9750 NSArray *interfaceKeys = [interfaces keysSortedByValueUsingSelector:@selector(interfaceCompare:)];
9758 BOOL guiChanged = (
gui_screen != GUI_SCREEN_INTERFACES);
9761 [gui
setTitle:DESC(@"interfaces-title")];
9766 tab_stops[1] = -480;
9771 NSUInteger
count = [interfaceKeys count];
9779 if (
count <= n_rows || skip < (NSInteger)n_rows)
9785 previous = skip - (n_rows - 2);
9792 [gui
setKey:[NSString stringWithFormat:@"More:%d", previous]
forRow:row];
9794 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil]
forRow:row];
9798 for (i = skip; i < (NSInteger)
count && (row - start_row < (
OOGUIRow)n_rows); i++)
9800 NSString *interfaceKey = [interfaceKeys objectAtIndex:i];
9810 if (i < (NSInteger)
count)
9814 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil]
forRow:row - 1];
9815 [gui
setKey:[NSString stringWithFormat:@"More:%d", i - 1]
forRow:row - 1];
9820 if ([gui selectedRow] != start_row)
9825 [
self showInformationForSelectedInterface];
9829 [gui
setText:DESC(@"interfaces-no-interfaces-available-for-use")
forRow:GUI_ROW_NO_INTERFACES
align:GUI_ALIGN_LEFT];
9839 NSString *desc = [NSString stringWithFormat:DESC(@"interfaces-for-ship-@-and-station-@"), [
self displayName], [[
self dockedStation] displayName]];
9847 NSDictionary *background = [UNIVERSE screenTextureDescriptorForKey:@"interfaces"];
9854 [
self setShowDemoShips:NO];
9858 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
9860 [
self setShowDemoShips:NO];
9861 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
9879 if (interfaceKey && ![interfaceKey hasPrefix:
@"More:"])
9881 NSDictionary *interfaces = [[
self dockedStation] localInterfaces];
9897 if ([key hasPrefix:
@"More:"])
9899 int from_item = [[key componentsSeparatedByString:@":"] oo_intAtIndex:1];
9900 [
self setGuiToInterfacesScreen:from_item];
9902 if ([gui selectedRow] < 0)
9905 [gui
setSelectedRow:GUI_ROW_INTERFACES_START + GUI_MAX_ROWS_INTERFACES - 1];
9906 [
self showInformationForSelectedInterface];
9912 NSDictionary *interfaces = [[
self dockedStation] localInterfaces];
9916 [[UNIVERSE gameView] clearKeys];
9921 OOLog(
@"interface.missingCallback",
@"Unable to find callback definition for key %@", key);
9929 NSString *text =
nil;
9931 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
9937 text =
DESC(
@"game-copyright");
9941 text =
DESC(
@"theme-music-credit");
9945 int initialRow = 22;
9946 int row = initialRow;
9948 text =
DESC(
@"oolite-start-option-1");
9951 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9955 text =
DESC(
@"oolite-start-option-2");
9958 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9962 text =
DESC(
@"oolite-start-option-3");
9965 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9969 text =
DESC(
@"oolite-start-option-4");
9972 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9976 text =
DESC(
@"oolite-start-option-5");
9979 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
9983 text =
DESC(
@"oolite-start-option-6");
9986 [gui
setKey:[NSString stringWithFormat:@"Start:%d", row]
forRow:row];
10000- (void) setGuiToIntroFirstGo:(BOOL)justCobra
10002 NSString *text =
nil;
10006 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
10007 [[UNIVERSE gameView] clearMouse];
10008 [[UNIVERSE gameView] clearKeys];
10013 [UNIVERSE removeDemoShips];
10019 [
self setupStartScreenGui];
10028 for (i-- ; i >= ms_start ; i--) [gui setColor:[OOColor redColor] forRow:i];
10034 if ([OXPsWithMessages
count] > 0)
10036 NSString *messageToDisplay =
@"";
10040 if ([OXPsWithMessages
count] < 5)
10042 NSString *messageSourceList = [OXPsWithMessages componentsJoinedByString:@", "];
10043 messageToDisplay =
OOExpandKey(
@"oxp-containing-messages-list", messageSourceList);
10045 messageToDisplay =
OOExpandKey(
@"oxp-containing-messages-found");
10050 for (i--; i >= ms_start; i--)
10058 NSArray* arguments = [[NSProcessInfo processInfo] arguments];
10060 for (i = 0; i < [arguments count]; i++)
10062 if (([[arguments objectAtIndex:i] isEqual:
@"-message"])&&(i < [arguments
count] - 1))
10065 NSString* message = [arguments oo_stringAtIndex:i + 1];
10067 for (i-- ; i >= ms_start; i--)
10072 if ([[arguments objectAtIndex:i] isEqual:
@"-showversion"])
10075 NSString *version = [NSString stringWithFormat:@"Version %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
10077 for (i-- ; i >= ms_start; i--)
10088 text =
DESC(
@"oolite-ship-library-title");
10091 text =
DESC(
@"oolite-ship-library-exit");
10098 [UNIVERSE setupIntroFirstGo: justCobra];
10102 gui_screen = justCobra ? GUI_SCREEN_INTRO1 : GUI_SCREEN_SHIPLIBRARY;
10104 if ([
self status] == STATUS_START_GAME)
10109 [
self setShowDemoShips:YES];
10118 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
10126 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
10127 [[UNIVERSE gameView] clearMouse];
10128 [UNIVERSE removeDemoShips];
10132 [[UNIVERSE gui] clearAndKeepBackground:NO];
10137 [[UNIVERSE gui] setBackgroundTextureKey:@"oxz-manager"];
10138 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
10155 [
self noteGUIDidChangeFrom: fromScreen to: toScreen refresh: NO];
10162 if (fromScreen != toScreen || refresh)
10165 switch (fromScreen)
10167 case GUI_SCREEN_SHIPYARD:
10168 case GUI_SCREEN_LOAD:
10169 case GUI_SCREEN_SAVE:
10170 [demoShip release];
10179 if (toScreen == GUI_SCREEN_SYSTEM_DATA)
10182 [[UNIVERSE sun] setSunColor:[
OOColor colorWithDescription:[[UNIVERSE systemManager] getProperty:@"sun_color" forSystem:info_system_id inGalaxy:[
self galaxyNumber]]]];
10187 [[UNIVERSE sun] setSunColor:[
OOColor colorWithDescription:[[UNIVERSE systemManager] getProperty:@"sun_color" forSystem:system_id inGalaxy:[
self galaxyNumber]]]];
10190 if (![[
UNIVERSE gameController] isGamePaused])
10202 [
self noteSwitchToView:toView fromView:fromView];
10211 if ([key hasPrefix:
@"More:"])
10213 int from_item = [[key componentsSeparatedByString:@":"] oo_intAtIndex:1];
10214 NSString *weaponKey = [[key componentsSeparatedByString:@":"] oo_stringAtIndex:2];
10216 [
self setGuiToEquipShipScreen:from_item];
10217 if (weaponKey !=
nil)
10219 [
self highlightEquipShipScreenKey:weaponKey];
10223 if ([gui selectedRow] < 0)
10225 if (from_item == 0)
10226 [gui
setSelectedRow:GUI_ROW_EQUIPMENT_START + GUI_MAX_ROWS_EQUIPMENT - 1];
10227 [
self showInformationForSelectedUpgrade];
10248 if ([
self tryBuyingItem:key])
10253 [
self playMenuNavigationDown];
10257 [
self playBuyCommodity];
10260 if(
credits != old_credits || ![key hasPrefix:
@"EQ_WEAPON_"])
10264 NSUInteger adjust = 0;
10273 double time_adjust = (old_credits >
credits) ? (old_credits -
credits) : 0.0;
10274 [UNIVERSE forceWitchspaceEntries];
10284 [
self doScriptEvent:OOJSID("playerBoughtEquipment") withArguments:[NSArray arrayWithObjects:key, [NSNumber numberWithLongLong:(old_credits - credits)], nil]];
10288 [
self setGuiToEquipShipScreen:0];
10290 [
self highlightEquipShipScreenKey:key];
10293 if ([
UNIVERSE autoSave]) [UNIVERSE setAutoSaveNow:YES];
10298 [
self playCantBuyCommodity];
10306 if (condition_script !=
nil)
10308 OOJSScript *condScript = [UNIVERSE getConditionScript:condition_script];
10309 if (condScript !=
nil)
10316 OK = JS_NewNumberValue(JScontext, price, &args[1]);
10320 OK = [condScript
callMethod:OOJSID("updateEquipmentPrice")
10328 OK = JS_ValueToInt32(JScontext, result, &newPrice);
10329 if (OK && newPrice >= 0)
10341- (BOOL) tryBuyingItem:(NSString *)eqKey
10347 double price = pricePerUnit;
10348 double priceFactor = 1.0;
10350 BOOL isRepair = NO;
10353 if ([
self hasEquipmentItem:eqKeyDamaged])
10359 if ([eqKey isEqualToString:
@"EQ_RENOVATION"])
10361 price = [
self renovationCosts];
10364 price = [
self adjustPriceByScriptForEqKey:eqKey withCurrent:price];
10372 price *= priceFactor;
10379 if ([eqType isPrimaryWeapon])
10383 [
self setGuiToEquipShipScreen:0 selectingFacingFor:eqKey];
10390 NSUInteger multiplier = 1;
10399 multiplier = [forwardWeaponOffset count];
10408 multiplier = [aftWeaponOffset count];
10417 multiplier = [portWeaponOffset count];
10426 multiplier = [starboardWeaponOffset count];
10434 price *= multiplier;
10463 if (current_weapon !=
nil)
10465 tradeIn = [UNIVERSE getEquipmentPriceForKey:OOEquipmentIdentifierFromWeaponType(current_weapon)] * multiplier;
10468 [
self doTradeIn:tradeIn forPriceFactor:priceFactor];
10470 [
self removeEquipmentItem:eqKeyDamaged];
10476 OOLog(
@"equip.buy.mounted.failed.full",
@"%@",
@"rejecting missile because already full");
10489 if ([eqKey isEqualToString:
@"EQ_FUEL"])
10491#if MASS_DEPENDENT_FUEL_PRICES
10496 if (
credits >= creditsForRefuel)
10499 fuel = [
self fuelCapacity];
10514 [
self removeEquipmentItem:@"EQ_NAVAL_ENERGY_UNIT"];
10515 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_NAVAL_ENERGY_UNIT"] / 2;
10518 [
self removeEquipmentItem:@"EQ_NAVAL_ENERGY_UNIT_DAMAGED"];
10519 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_NAVAL_ENERGY_UNIT"] / 4;
10522 [
self removeEquipmentItem:@"EQ_ENERGY_UNIT"];
10523 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_ENERGY_UNIT"] * 3 / 4;
10526 [
self removeEquipmentItem:@"EQ_ENERGY_UNIT_DAMAGED"];
10527 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_ENERGY_UNIT"] * 3 / 8;
10533 [
self doTradeIn:tradeIn forPriceFactor:priceFactor];
10537 if ([eqKey isEqualToString:
@"EQ_RENOVATION"])
10541 if (techLevel == NSNotFound) techLevel = [[UNIVERSE currentSystemData] oo_unsignedIntForKey:KEY_TECHLEVEL];
10547 [
self clearSubEntities];
10548 [
self setUpSubEntities];
10553 if ([eqKey hasSuffix:
@"MISSILE"] || [eqKey hasSuffix:
@"MINE"])
10555 ShipEntity* weapon = [[UNIVERSE newShipWithRole:eqKey] autorelease];
10559 BOOL mounted_okay = [
self mountMissile:weapon];
10563 [
self safeAllMissiles];
10564 [
self tidyMissilePylons];
10565 [
self setActiveMissile:0];
10567 return mounted_okay;
10570 if ([eqKey isEqualToString:
@"EQ_PASSENGER_BERTH"])
10572 [
self changePassengerBerths:+1];
10577 if ([eqKey isEqualToString:
@"EQ_PASSENGER_BERTH_REMOVAL"])
10579 [
self changePassengerBerths:-1];
10584 if ([eqKey isEqualToString:
@"EQ_MISSILE_REMOVAL"])
10588 [
self doTradeIn:tradeIn forPriceFactor:priceFactor];
10592 if ([
self canAddEquipment:eqKey inContext:
@"purchase"])
10595 [
self addEquipmentItem:eqKey withValidation:NO inContext:@"purchase"];
10598 [
self doScriptEvent:OOJSID("equipmentRepaired") withArgument:eqKey];
10607- (BOOL) setWeaponMount:(
OOWeaponFacing)facing toWeapon:(NSString *)eqKey
10609 return [
self setWeaponMount:facing toWeapon:eqKey inContext:@"purchase"];
10613- (BOOL) setWeaponMount:(
OOWeaponFacing)facing toWeapon:(NSString *)eqKey inContext:(NSString *) context
10617 unsigned available_facings = [shipyardInfo oo_unsignedIntForKey:KEY_WEAPON_FACINGS defaultValue:[
self weaponFacings]];
10620 if (!(available_facings & facing))
10626 if (![eqKey isEqualToString:
@"EQ_WEAPON_NONE"])
10628 if (![
self canAddEquipment:eqKey inContext:context])
10663- (BOOL) changePassengerBerths:(
int) addRemove
10665 if (addRemove == 0)
return NO;
10666 addRemove = (addRemove > 0) ? 1 : -1;
10679 [
self safeAllMissiles];
10684 NSString *weapon_key = [missile_list[i] identifier];
10686 if (weapon_key !=
nil)
10687 tradeIn += (
int)[
UNIVERSE getEquipmentPriceForKey:weapon_key];
10692 [missile_entity[i] release];
10701- (void) doTradeIn:(
OOCreditsQuantity)tradeInValue forPriceFactor:(
double)priceFactor
10715 if ([
self status] != STATUS_DOCKED)
10723 cargoItem = [cargo objectAtIndex:i];
10725 if ([co_type isEqualToString:type])
10738 OOMassUnit unit = [shipCommodityData massUnitForGood:type];
10743 BOOL inPods = ([
self status] != STATUS_DOCKED);
10746 if (unit ==
UNITS_TONS && (available + oldAmount) < amount)
10748 amount = available + oldAmount;
10756 if (safeAmount < amount) amount = (safeAmount < oldAmount) ? oldAmount : safeAmount;
10758 else if (unit ==
UNITS_GRAMS && amount > oldAmount)
10761 if (safeAmount < amount) amount = (safeAmount < oldAmount) ? oldAmount : safeAmount;
10766 if (amount > oldAmount)
10768 [
self loadCargoPodsForType:type amount:(amount - oldAmount)];
10772 [
self unloadCargoPodsForType:type amount:(oldAmount - amount)];
10777 [shipCommodityData setQuantity:amount forGood:type];
10780 [
self calculateCurrentCargo];
10781 return [shipCommodityData quantityForGood:type];
10795 return [
self maxAvailableCargoSpace];
10806 NSString *good =
nil;
10812 OOMassUnit commodityUnits = [shipCommodityData massUnitForGood:good];
10824 cargoQtyOnBoard += quantity;
10828 return cargoQtyOnBoard;
10835 if (station ==
nil)
10839 station = [
self primaryTarget];
10843 station = [UNIVERSE station];
10845 if (station ==
nil)
10861- (NSArray *) applyMarketFilter:(NSArray *)goods onMarket:(
OOCommodityMarket *)market
10867 NSMutableArray *filteredGoods = [NSMutableArray arrayWithCapacity:[goods count]];
10869 foreach (good, goods)
10875 [filteredGoods addObject:good];
10878 if ([market quantityForGood:good] > 0 || [
self cargoQuantityForType:good] > 0)
10880 [filteredGoods addObject:good];
10884 if ([
self cargoQuantityForType:good] > 0)
10886 [filteredGoods addObject:good];
10890 if ([market quantityForGood:good] > 0)
10892 [filteredGoods addObject:good];
10896 if ([market exportLegalityForGood:good] == 0 && [market importLegalityForGood:good] == 0)
10898 [filteredGoods addObject:good];
10902 if ([market exportLegalityForGood:good] > 0 || [market importLegalityForGood:good] > 0)
10904 [filteredGoods addObject:good];
10909 return [[filteredGoods copy] autorelease];
10913- (NSArray *) applyMarketSorter:(NSArray *)goods onMarket:(
OOCommodityMarket *)market
10918 return [goods sortedArrayUsingFunction:marketSorterByName context:market];
10920 return [goods sortedArrayUsingFunction:marketSorterByPrice context:market];
10922 return [goods sortedArrayUsingFunction:marketSorterByQuantity context:market];
10924 return [goods sortedArrayUsingFunction:marketSorterByQuantity context:shipCommodityData];
10926 return [goods sortedArrayUsingFunction:marketSorterByMassUnit context:market];
10940 tab_stops[1] = 137;
10941 tab_stops[2] = 187;
10942 tab_stops[3] = 267;
10943 tab_stops[4] = 321;
10944 tab_stops[5] = 431;
10949 [gui
setArray:[NSArray arrayWithObjects: DESC(@"commodity-column-title"), OOPadStringToEms(DESC(@"price-column-title"),3.5),
10950 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];
10951 [gui
setArray:[NSArray arrayWithObjects: DESC(@"commodity-column-title"), DESC(@"oolite-extras-column-title"), OOPadStringToEms(DESC(@"price-column-title"),3.5),
10952 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];
10960 NSString* desc = [NSString stringWithFormat:@" %@ ", [shipCommodityData nameForGood:good]];
10964 OOMassUnit unit = [shipCommodityData massUnitForGood:good];
10966 NSString *available =
OOPadStringToEms(((available_units > 0) ? (NSString *)[NSString stringWithFormat:
@"%d",available_units] :
DESC(
@"commodity-quantity-none")), 2.5);
10968 NSUInteger priceDecimal = pricePerUnit % 10;
10969 NSString *price = [NSString stringWithFormat:@" %@.%lu ",OOPadStringToEms([NSString stringWithFormat:@"%lu",(unsigned long)(pricePerUnit/10)],2.5),priceDecimal];
10973 NSString *owned =
OOPadStringToEms((units_in_hold > 0) ? (NSString *)[NSString stringWithFormat:
@"%d",units_in_hold] :
DESC(
@"commodity-quantity-none"), 4.5);
10975 NSString *units_available = [NSString stringWithFormat:@" %@ %@ ",available, units];
10976 NSString *units_owned = [NSString stringWithFormat:@" %@ %@ ",owned, units];
10980 NSString *legaldesc =
nil;
10981 if (import_legality == 0)
10983 if (export_legality == 0)
10985 legaldesc =
DESC(
@"oolite-legality-clear");
10989 legaldesc =
DESC(
@"oolite-legality-import");
10994 if (export_legality == 0)
10996 legaldesc =
DESC(
@"oolite-legality-export");
11000 legaldesc =
DESC(
@"oolite-legality-neither");
11003 legaldesc = [NSString stringWithFormat:@" %@ ",legaldesc];
11005 NSString *extradesc = [shipCommodityData shortCommentForGood:good];
11009 [gui
setArray:[NSArray arrayWithObjects: desc, extradesc, price, units_available, units_owned, legaldesc, nil]
forRow:row++];
11027 NSString *system =
nil;
11028 if ([
UNIVERSE sun] !=
nil) system = [UNIVERSE getSystemName:system_id];
11034 return OOExpandKey(
@"system-commodity-market", system);
11045 return OOExpandKey(
@"station-commodity-market", station);
11057 BOOL guiChanged = (oldScreen !=
gui_screen);
11060 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
11065 localMarket = [[UNIVERSE commodities] generateBlankMarket];
11069 NSArray *goods = [
self applyMarketSorter:[
self applyMarketFilter:[localMarket
goods] onMarket:localMarket] onMarket:localMarket];
11070 NSInteger maxOffset = 0;
11076 NSUInteger commodityCount = [shipCommodityData count];
11079 for (NSUInteger i = 0; i < commodityCount; i++)
11081 quantityInHold[i] = [shipCommodityData quantityForGood:[goods oo_stringAtIndex:i]];
11083 for (NSUInteger i = 0; i < [cargo count]; i++)
11085 ShipEntity *container = [cargo objectAtIndex:i];
11086 NSUInteger goodsIndex = [goods indexOfObject:[container
commodityType]];
11088 if (goodsIndex != NSNotFound)
11103 if ([goods
count] > 0)
11110 NSInteger goodsIndex = [goods indexOfObject:marketSelectedCommodity];
11115 if (goodsIndex == 0) {
11148 [gui
setTitle:[
self marketScreenTitle]];
11150 [
self showMarketScreenHeaders];
11161 if ([goods
count] > 0)
11165 foreach (good, goods)
11172 [
self showMarketScreenDataLine:row forGood:good inMarket:localMarket holdQuantity:quantityInHold[i++]];
11193 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @"", @"", @"", @" --> ", nil]
forRow:GUI_ROW_MARKET_LAST];
11203 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @"", @"", @"", @" <-- ", nil]
forRow:GUI_ROW_MARKET_START];
11210 [gui
setText:DESC(@"oolite-market-filtered-all")
forRow:GUI_ROW_MARKET_START];
11221 NSString *filterText =
OOExpandKey(
@"oolite-market-filter-line", filterMode);
11223 NSString *sorterText =
OOExpandKey(
@"oolite-market-sorter-line", sortMode);
11224 [gui
setArray:[NSArray arrayWithObjects:filterText, @"", sorterText, nil]
forRow:GUI_ROW_MARKET_END];
11228 [
self showMarketCashAndLoadLine];
11237 [[UNIVERSE gameView] clearMouse];
11239 [
self setShowDemoShips:NO];
11240 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
11246 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
11258 BOOL guiChanged = (oldScreen !=
gui_screen);
11261 [[UNIVERSE gameController] setMouseInteractionModeForUIWithMouseInteraction:YES];
11266 localMarket = [[UNIVERSE commodities] generateBlankMarket];
11270 NSArray *goods = [
self applyMarketSorter:[
self applyMarketFilter:[localMarket
goods] onMarket:localMarket] onMarket:localMarket];
11272 NSUInteger i, j, commodityCount = [shipCommodityData count];
11275 for (i = 0; i < commodityCount; i++)
11277 quantityInHold[i] = [shipCommodityData quantityForGood:[goods oo_stringAtIndex:i]];
11279 for (i = 0; i < [cargo count]; i++)
11281 ShipEntity *container = [cargo objectAtIndex:i];
11295 j = [goods indexOfObject:marketSelectedCommodity];
11297 if (j == NSNotFound)
11300 [
self setGuiToMarketScreen];
11306 [gui
setTitle:[NSString stringWithFormat:DESC(@"oolite-commodity-information-@"), [shipCommodityData nameForGood:marketSelectedCommodity]]];
11308 [
self showMarketScreenHeaders];
11309 [
self showMarketScreenDataLine:GUI_ROW_MARKET_START forGood:marketSelectedCommodity inMarket:localMarket holdQuantity:quantityInHold[j]];
11311 OOCargoQuantity contracted = [
self contractedVolumeForGood:marketSelectedCommodity];
11312 if (contracted > 0)
11314 OOMassUnit unit = [shipCommodityData massUnitForGood:marketSelectedCommodity];
11316 [gui
setText:[NSString stringWithFormat:DESC(@"oolite-commodity-contracted-d-@"), contracted, DisplayStringForMassUnit(unit)]
forRow:GUI_ROW_MARKET_START+1];
11319 NSString *info = [shipCommodityData commentForGood:marketSelectedCommodity];
11321 if (info ==
nil || [info length] == 0)
11334 [
self showMarketCashAndLoadLine];
11338 [[UNIVERSE gameView] clearMouse];
11340 [
self setShowDemoShips:NO];
11341 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
11347 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
11356 [gui
setText:OOExpandKey(@"market-cash-and-load", credits, currentCargo, cargoCapacity)
forRow:GUI_ROW_MARKET_CASH];
11368 if ([index isEqualToString:
@"<<<"] || [index isEqualToString:
@">>>"])
11384 int manifest_quantity = [shipCommodityData quantityForGood:index];
11391 int contracted = [
self contractedVolumeForGood:index];
11392 if (manifest_quantity >= contracted)
11398 purchase = contracted-manifest_quantity;
11401 if (purchase > market_quantity)
11403 purchase = market_quantity;
11405 if (purchase * pricePerUnit >
credits)
11407 purchase = floor (
credits / pricePerUnit);
11412 purchase = [
self availableCargoSpace];
11445 [shipCommodityData addQuantity:purchase forGood:index];
11446 credits -= pricePerUnit * purchase;
11448 [
self calculateCurrentCargo];
11452 [
self doScriptEvent:OOJSID("playerBoughtCargo") withArguments:[NSArray arrayWithObjects:index, [NSNumber numberWithInt:purchase], [NSNumber numberWithUnsignedLongLong:pricePerUnit], nil]];
11453 if ([
localMarket exportLegalityForGood:index] > 0)
11455 [roleWeightFlags setObject:[NSNumber numberWithInt:1] forKey:@"bought-illegal"];
11459 [roleWeightFlags setObject:[NSNumber numberWithInt:1] forKey:@"bought-legal"];
11468 if ([index isEqualToString:
@"<<<"] || [index isEqualToString:
@">>>"])
11477 int available_units = [shipCommodityData quantityForGood:index];
11480 if (available_units == 0)
return NO;
11489 int contracted = [
self contractedVolumeForGood:index];
11490 if (available_units <= contracted)
11496 sell = available_units-contracted;
11500 if (sell > available_units)
11501 sell = available_units;
11502 if (sell + market_quantity > capacity)
11503 sell = capacity - market_quantity;
11508 [shipCommodityData removeQuantity:sell forGood:index];
11509 credits += pricePerUnit * sell;
11511 [
self calculateCurrentCargo];
11515 [
self doScriptEvent:OOJSID("playerSoldCargo") withArguments:[NSArray arrayWithObjects:index, [NSNumber numberWithInt:sell], [NSNumber numberWithUnsignedLongLong: pricePerUnit], nil]];
11533- (BOOL) canAddEquipment:(NSString *)equipmentKey inContext:(NSString *)context
11536 if (![super canAddEquipment:equipmentKey inContext:context])
return NO;
11539 if (conditions !=
nil && ![
self scriptTestConditions:conditions])
return NO;
11545- (BOOL) addEquipmentItem:(NSString *)equipmentKey inContext:(NSString *)context
11547 return [
self addEquipmentItem:equipmentKey withValidation:YES inContext:context];
11551- (BOOL) addEquipmentItem:(NSString *)equipmentKey withValidation:(BOOL)validateAddition inContext:(NSString *)context
11554 if ([equipmentKey isEqualToString:
@"EQ_TRUMBLE"])
11565 [
self addTrumble:trumble[ranrot_rand() % PLAYER_MAX_TRUMBLES]];
11571 BOOL OK = [
super addEquipmentItem:equipmentKey withValidation:validateAddition inContext:context];
11575 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_COMPASS"] && [
self compassMode] == COMPASS_MODE_BASIC)
11577 [
self setCompassMode:COMPASS_MODE_PLANET];
11580 [
self addEqScriptForKey:equipmentKey];
11581 [
self addEquipmentWithScriptToCustomKeyArray:equipmentKey];
11593- (void) addEquipmentWithScriptToCustomKeyArray:(NSString *)equipmentKey
11595 NSDictionary *item;
11599 for (i = 0; i < [eqScripts count]; i++)
11601 if ([[[
eqScripts oo_arrayAtIndex:i] oo_stringAtIndex:0] isEqualToString:equipmentKey])
11604 for (j = 0; j < [customEquipActivation count]; j++) {
11605 item = [customEquipActivation objectAtIndex:j];
11611 NSMutableDictionary *customKey = [[NSMutableDictionary alloc] initWithObjectsAndKeys:equipmentKey, CUSTOMEQUIP_EQUIPKEY, [eq
name], CUSTOMEQUIP_EQUIPNAME, nil];
11616 if ((
object !=
nil && [
object count] > 0))
11620 if ((
object !=
nil && [
object count] > 0))
11623 [customEquipActivation addObject:customKey];
11624 [customKey release];
11626 [customActivatePressed addObject:[NSNumber numberWithBool:NO]];
11627 [customModePressed addObject:[NSNumber numberWithBool:NO]];
11629 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
11630 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
11641 NSString *equipmentKey;
11644 equipmentKey = [[customEquipActivation objectAtIndex:i] oo_stringForKey:CUSTOMEQUIP_EQUIPKEY];
11647 [customEquipActivation removeObjectAtIndex:i];
11648 [customActivatePressed removeObjectAtIndex:i];
11649 [customModePressed removeObjectAtIndex:i];
11654 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
11655 [defaults setObject:customEquipActivation forKey:KEYCONFIG_CUSTOMEQUIP];
11660- (void) removeEquipmentItem:(NSString *)equipmentKey
11662 if(![
self hasEquipmentItemProviding:
@"EQ_ADVANCED_COMPASS"] && [
self compassMode] != COMPASS_MODE_BASIC)
11664 [
self setCompassMode:COMPASS_MODE_BASIC];
11666 [
super removeEquipmentItem:equipmentKey];
11667 if(![
self hasEquipmentItem:equipmentKey]) {
11669 [
self removeEqScriptForKey:equipmentKey];
11674- (void) addEquipmentFromCollection:(
id)equipment
11676 NSDictionary *dict =
nil;
11677 NSEnumerator *eqEnum =
nil;
11678 NSString *eqDesc =
nil;
11679 NSUInteger i,
count;
11682 if ([equipment isKindOfClass:[NSDictionary
class]])
11685 eqEnum = [equipment keyEnumerator];
11687 else if ([equipment isKindOfClass:[NSArray
class]] || [equipment isKindOfClass:[NSSet
class]])
11689 eqEnum = [equipment objectEnumerator];
11691 else if ([equipment isKindOfClass:[NSString
class]])
11693 eqEnum = [[NSArray arrayWithObject:equipment] objectEnumerator];
11700 while ((eqDesc = [eqEnum nextObject]))
11715 if ([eqDesc isEqualToString:
@"EQ_TRUMBLE"])
continue;
11718 if (dict !=
nil && ![dict oo_boolForKey:eqDesc])
continue;
11725 count = [dict oo_unsignedIntegerForKey:eqDesc];
11726 for (i=0;i<
count;i++)
11728 [
self addEquipmentItem:eqDesc withValidation:NO inContext:@"loading"];
11733 if ([equipment isKindOfClass:[NSDictionary
class]])
11735 eqEnum = [equipment keyEnumerator];
11737 else if ([equipment isKindOfClass:[NSArray
class]] || [equipment isKindOfClass:[NSSet
class]])
11739 eqEnum = [equipment objectEnumerator];
11741 else if ([equipment isKindOfClass:[NSString
class]])
11743 eqEnum = [[NSArray arrayWithObject:equipment] objectEnumerator];
11746 while ((eqDesc = [eqEnum nextObject]))
11748 if (![
self equipmentValidToAdd:eqDesc whileLoading:YES inContext:
@"loading"])
11750 [
self removeEquipmentItem:eqDesc];
11756- (BOOL) hasOneEquipmentItem:(NSString *)itemKey includeMissiles:(BOOL)includeMissiles
11759 if ([super hasOneEquipmentItem:itemKey includeMissiles:NO whileLoading:NO])
return YES;
11762 if (includeMissiles)
11767 if ([[
self missileForPylon:i] hasPrimaryRole:itemKey])
return YES;
11771 if ([itemKey isEqualToString:
@"EQ_TRUMBLE"])
11773 return [
self trumbleCount] > 0;
11783 [[
aft_weapon_type identifier] isEqualToString:[weaponType identifier]] ||
11784 [[
port_weapon_type identifier] isEqualToString:[weaponType identifier]] ||
11790 return [
super hasPrimaryWeapon:weaponType];
11802 if ([[
self missileForPylon:i] hasPrimaryRole:identifier])
11804 [
self removeFromPylon:i];
11814- (BOOL) removeFromPylon:(NSUInteger)pylon
11820 NSString *identifier = [missile_entity[pylon] primaryRole];
11824 [missile_entity[pylon] release];
11827 [
self tidyMissilePylons];
11836 [
self selectNextMissile];
11848 return [parcels count];
11854 return [passengers count];
11866 ShipEntity *playersTarget = [
self primaryTarget];
11871- (void) receiveCommsMessage:(NSString *) message_text from:(
ShipEntity *) other
11873 if ([
self status] == STATUS_DEAD || [
self status] == STATUS_DOCKED)
11878 [UNIVERSE addCommsMessage:[NSString stringWithFormat:@"%@:\n %@", [other
displayName], message_text] forCount:4.5];
11879 [
super receiveCommsMessage:message_text from:other];
11887 OOGovernmentID local_gov = [[UNIVERSE currentSystemData] oo_intForKey:KEY_GOVERNMENT];
11888 if ([
UNIVERSE inInterstellarSpace]) local_gov = 1;
11894 [
self setBounty:(legalStatus-payback) withReason:kOOLegalStatusReasonPaidFine];
11899 [
self setBounty:0 withReason:kOOLegalStatusReasonPaidFine];
11904 NSString *fined_message = [NSString stringWithFormat:OOExpandKey(@"fined-@-credits"), OOCredits(fine)];
11905 [
self addMessageToReport:fined_message];
11906 [UNIVERSE forceWitchspaceEntries];
11911- (void) adjustTradeInFactorBy:(
int)value
11928 OOCreditsQuantity shipValue = [UNIVERSE tradeInValueForCommanderDictionary:[
self commanderDataDictionary]];
11932 costs *= [
self renovationFactor];
11941 return [shipyardInfo oo_doubleForKey:KEY_RENOVATION_MULTIPLIER defaultValue:1.0];
11962 [_customViews release];
11965 if (customViews !=
nil)
11995 NSMutableString *trumbleDigrams = [NSMutableString stringWithCapacity:256];
11996 unichar xchar = (unichar)0;
11997 unichar digramchars[2];
12004 [trumbleDigrams appendFormat:@"%@%@", commanderName, [[
self mesh] modelName]];
12008 [trumbleDigrams appendString:@"Some Random Text!"];
12014 digramchars[0] = ([trumbleDigrams characterAtIndex:i] & 0x007f) | 0x0020;
12015 digramchars[1] = (([trumbleDigrams characterAtIndex:i + 1] ^ xchar) & 0x007f) | 0x0020;
12016 xchar = digramchars[0];
12017 NSString *digramstring = [NSString stringWithCharacters:digramchars length:2];
12018 [trumble[i] release];
12024 [
self setTrumbleAppetiteAccumulator:0.0f];
12028- (void) addTrumble:(
OOTrumble *)papaTrumble
12040- (void) removeTrumble:(
OOTrumble *)deadTrumble
12046 NSUInteger trumble_index = NSNotFound;
12049 for (i = 0; (trumble_index == NSNotFound)&&(i <
trumbleCount); i++)
12051 if (
trumble[i] == deadTrumble)
12054 if (trumble_index == NSNotFound)
12056 OOLog(
@"trumble.zombie",
@"DEBUG can't get rid of inactive trumble %@", deadTrumble);
12061 trumble[trumbleCount] = deadTrumble;
12079 NSString *namekey = [NSString stringWithFormat:@"%@-humbletrash", [
self commanderName]];
12083 [
self mungChecksumWithNSString:[
self commanderName]];
12088 [[NSUserDefaults standardUserDefaults] setInteger:trumbleHash forKey:namekey];
12091 NSMutableArray *
trumbleArray = [NSMutableArray arrayWithCapacity:PLAYER_MAX_TRUMBLES];
12094 [trumbleArray addObject:[trumble[i] dictionary]];
12097 return [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInteger:trumbleCount], [NSNumber numberWithInt:trumbleHash], trumbleArray, nil];
12101- (void) setTrumbleValueFrom:(NSObject*) trumbleValue
12103 BOOL info_failed = NO;
12105 int putativeHash = 0;
12106 int putativeNTrumbles = 0;
12107 NSArray *putativeTrumbleArray =
nil;
12109 NSString *namekey = [NSString stringWithFormat:@"%@-humbletrash", [
self commanderName]];
12111 [
self setUpTrumbles];
12115 BOOL possible_cheat = NO;
12121 if ([values
count] >= 1)
12122 putativeNTrumbles = [values oo_intAtIndex:0];
12123 if ([values
count] >= 2)
12124 putativeHash = [values oo_intAtIndex:1];
12125 if ([values
count] >= 3)
12126 putativeTrumbleArray = [values oo_arrayAtIndex:2];
12130 [
self mungChecksumWithNSString:[
self commanderName]];
12135 if (putativeHash != trumbleHash)
12140 OOLog(
@"cheat.tentative",
@"%@",
@"POSSIBLE CHEAT DETECTED");
12141 possible_cheat = YES;
12148 [
self mungChecksumWithNSString:[
self commanderName]];
12152 if (putativeHash == trumbleHash)
12155 putativeNTrumbles = i;
12159 if (possible_cheat && !info_failed)
12160 OOLog(
@"cheat.verified",
@"%@",
@"CHEAT DEFEATED - that's not the way to get rid of trumbles!");
12166 OOLog(
@"cheat.tentative",
@"%@",
@"POSSIBLE CHEAT DETECTED");
12170 if (info_failed && [[NSUserDefaults standardUserDefaults] objectForKey:namekey])
12173 putativeHash = (
int)[[NSUserDefaults standardUserDefaults] integerForKey:namekey];
12177 [
self mungChecksumWithNSString:[
self commanderName]];
12181 if (putativeHash == trumbleHash)
12184 putativeNTrumbles = i;
12189 OOLog(
@"cheat.verified",
@"%@",
@"CHEAT DEFEATED - that's not the way to get rid of trumbles!");
12197 [
trumble[i] setFromDictionary:[putativeTrumbleArray oo_dictionaryAtIndex:i]];
12201 [
self mungChecksumWithNSString:[
self commanderName]];
12206 [[NSUserDefaults standardUserDefaults] setInteger:trumbleHash forKey:namekey];
12216- (void) setTrumbleAppetiteAccumulator:(
float)value
12222- (void) mungChecksumWithNSString:(NSString *)str
12224 if (str ==
nil)
return;
12226 NSUInteger i, length = [str length];
12227 for (i = 0; i < length; i++)
12234- (NSString *) screenModeStringForWidth:(
unsigned)width height:(
unsigned)height refreshRate:(
float)refreshRate
12236 if (0.0f != refreshRate)
12238 return OOExpandKey(
@"gameoptions-fullscreen-with-refresh-rate", width, height, refreshRate);
12242 return OOExpandKey(
@"gameoptions-fullscreen", width, height);
12260- (void) setFoundTarget:(
Entity *) targetEntity
12264 if ([
self status] == STATUS_ESCAPE_SEQUENCE)
12268 [_foundTarget release];
12274- (void) addTarget:(
Entity *) targetEntity
12276 if ([
self status] != STATUS_IN_FLIGHT && [
self status] != STATUS_WITCHSPACE_COUNTDOWN)
return;
12277 if (targetEntity ==
self)
return;
12279 [
super addTarget:targetEntity];
12283 assert ([
self hasEquipmentItemProviding:
@"EQ_WORMHOLE_SCANNER"]);
12284 [
self addScannedWormhole:(WormholeEntity*)targetEntity];
12287 else if ([
self hasEquipmentItemProviding:
@"EQ_TARGET_MEMORY"] && targetEntity !=
nil)
12290 NSUInteger i = [target_memory indexOfObject:targetRef];
12292 if (i != NSNotFound)
12298 i = [target_memory indexOfObject:[NSNull null]];
12300 if (i != NSNotFound)
12302 [target_memory replaceObjectAtIndex:i withObject:targetRef];
12309 [target_memory replaceObjectAtIndex:target_memory_index withObject:targetRef];
12316 [
self playIdentLockedOn];
12317 [
self printIdentLockedOnForMissile:NO];
12324 [missile_entity[activeMissile] addTarget:targetEntity];
12325 [
self playMissileLockedOn];
12326 [
self printIdentLockedOnForMissile:YES];
12331 [
self playIdentLockedOn];
12332 [
self printIdentLockedOnForMissile:NO];
12340 NSUInteger memoryCount = [target_memory count];
12343 if (i < memoryCount)
12345 [target_memory replaceObjectAtIndex:i withObject:[NSNull null]];
12349 [target_memory addObject:[NSNull null]];
12361- (BOOL) moveTargetMemoryBy:(NSInteger)delta
12371 id targ_id = [target_memory objectAtIndex:target_memory_index];
12372 if ([targ_id isProxy])
12376 if ((potential_target)&&(potential_target->
isShip)&&([potential_target
isInSpace]))
12380 [
super addTarget:potential_target];
12385 [missile_entity[activeMissile] addTarget:potential_target];
12387 [
self printIdentLockedOnForMissile:YES];
12392 [
self playIdentLockedOn];
12393 [
self printIdentLockedOnForMissile:NO];
12399 [
self printIdentLockedOnForMissile:NO];
12401 [
self playTargetSwitched];
12407 [target_memory replaceObjectAtIndex:target_memory_index withObject:[NSNull null]];
12412 [
self playNoTargetInMemory];
12417- (void) printIdentLockedOnForMissile:(BOOL)missile
12421 NSString *fmt = missile ?
@"missile-locked-onto-target" :
@"ident-locked-onto-target";
12422 NSString *target = [[
self primaryTarget] identFromShip:self];
12423 [UNIVERSE addMessage:OOExpandKey(fmt, target) forCount:4.5];
12433- (void) setCustomViewQuaternion:(Quaternion)q
12436 [
self setCustomViewData];
12452- (void) setCustomViewOffset:(Vector) offset
12464- (void) setCustomViewRotationCenter:(Vector) center
12470- (void) customViewZoomIn:(
OOScalar) rate
12483- (void) customViewZoomOut:(
OOScalar) rate
12496- (void) customViewRotateLeft:(
OOScalar) angle
12501 [
self setCustomViewData];
12508- (void) customViewRotateRight:(
OOScalar) angle
12513 [
self setCustomViewData];
12520- (void) customViewRotateUp:(
OOScalar) angle
12525 [
self setCustomViewData];
12532- (void) customViewRotateDown:(
OOScalar) angle
12537 [
self setCustomViewData];
12544- (void) customViewRollRight:(
OOScalar) angle
12549 [
self setCustomViewData];
12556- (void) customViewRollLeft:(
OOScalar) angle
12561 [
self setCustomViewData];
12568- (void) customViewPanUp:(
OOScalar) angle
12571 [
self setCustomViewData];
12576- (void) customViewPanDown:(
OOScalar) angle
12579 [
self setCustomViewData];
12584- (void) customViewPanLeft:(
OOScalar) angle
12587 [
self setCustomViewData];
12592- (void) customViewPanRight:(
OOScalar) angle
12595 [
self setCustomViewData];
12626 [
self setCustomViewDataFromDictionary:[_customViews oo_dictionaryAtIndex:_customViewIndex] withScaling:NO];
12641- (void) setCustomViewDataFromDictionary:(NSDictionary *)viewDict withScaling:(BOOL)withScaling
12645 if (viewDict ==
nil)
return;
12648 [
self setCustomViewData];
12663 NSString *facing = [[viewDict oo_stringForKey:@"weapon_facing"] lowercaseString];
12664 if ([facing isEqual:
@"aft"])
12668 else if ([facing isEqual:
@"port"])
12672 else if ([facing isEqual:
@"starboard"])
12676 else if ([facing isEqual:
@"forward"])
12699 NSDictionary *result = [
self missionOverlayDescriptor];
12704 result = [UNIVERSE screenTextureDescriptorForKey:@"mission_overlay_no_title"];
12708 result = [UNIVERSE screenTextureDescriptorForKey:@"mission_overlay_with_title"];
12716- (void) setMissionOverlayDescriptor:(NSDictionary *)descriptor
12720 [_missionOverlayDescriptor autorelease];
12734 NSDictionary *result = [
self missionBackgroundDescriptor];
12737 result = [UNIVERSE screenTextureDescriptorForKey:@"mission"];
12744- (void) setMissionBackgroundDescriptor:(NSDictionary *)descriptor
12748 [_missionBackgroundDescriptor autorelease];
12760- (void) setMissionBackgroundSpecial:(NSString *)special
12762 if (special ==
nil) {
12765 else if ([special isEqualToString:
@"SHORT_RANGE_CHART"])
12769 else if ([special isEqualToString:
@"SHORT_RANGE_CHART_SHORTEST"])
12771 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12780 else if ([special isEqualToString:
@"SHORT_RANGE_CHART_QUICKEST"])
12782 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12791 else if ([special isEqualToString:
@"CUSTOM_CHART"])
12795 else if ([special isEqualToString:
@"CUSTOM_CHART_SHORTEST"])
12797 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12806 else if ([special isEqualToString:
@"CUSTOM_CHART_QUICKEST"])
12808 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12817 else if ([special isEqualToString:
@"LONG_RANGE_CHART"])
12821 else if ([special isEqualToString:
@"LONG_RANGE_CHART_SHORTEST"])
12823 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12832 else if ([special isEqualToString:
@"LONG_RANGE_CHART_QUICKEST"])
12834 if ([
self hasEquipmentItemProviding:
@"EQ_ADVANCED_NAVIGATIONAL_ARRAY"])
12868- (void) setEquipScreenBackgroundDescriptor:(NSDictionary *)descriptor
12872 [_equipScreenBackgroundDescriptor autorelease];
12886 return [worldScripts allKeys];
12892 return [[worldScripts copy] autorelease];
12896- (
OOScript *) commodityScriptNamed:(NSString *)scriptName
12898 if (scriptName ==
nil)
12908 if (cscript !=
nil)
12911 [commodityScripts setObject:cscript forKey:scriptName];
12915 OOLog(
@"script.commodityScript.load",
@"Could not load script %@",scriptName);
12921- (void) doScriptEvent:(jsid)message inContext:(JSContext *)context withArguments:(jsval *)argv count:(uintN)argc
12923 [
super doScriptEvent:message inContext:context withArguments:argv count:argc];
12924 [
self doWorldScriptEvent:message inContext:context withArguments:argv count:argc timeLimit:0.0];
12928- (BOOL) doWorldEventUntilMissionScreen:(jsid)message
12930 NSEnumerator *scriptEnum = [worldScripts objectEnumerator];
12936 [
self setGuiToDockingReportScreen];
12937 [[UNIVERSE messageGUI] clear];
12942 while ((theScript = [scriptEnum nextObject]) &&
gui_screen != GUI_SCREEN_MISSION && [
self isDocked])
12951 [[UNIVERSE messageGUI] clear];
12959- (void) doWorldScriptEvent:(jsid)message inContext:(JSContext *)context withArguments:(jsval *)argv count:(uintN)argc timeLimit:(
OOTimeDelta)limit
12963 NSEnumerator *scriptEnum =
nil;
12966 for (scriptEnum = [
worldScripts objectEnumerator]; (theScript = [scriptEnum nextObject]); )
12990- (void) setGalacticHyperspaceFixedCoords:(NSPoint)point
12992 return [
self setGalacticHyperspaceFixedCoordsX:OOClamp_0_max_f(round(point.x), 255.0f) y:OOClamp_0_max_f(round(point.y), 255.0f)];
12996- (void) setGalacticHyperspaceFixedCoordsX:(
unsigned char)x y:(
unsigned char)y
13009- (void) setWitchspaceCountdown:(
int)spin_time
13032- (void) setScoopOverride:(BOOL)newValue
13039#if MASS_DEPENDENT_FUEL_PRICES
13042 GLfloat rate = 1.0;
13044 rate = [
super fuelChargeRate];
13072- (void) setJumpCause:(NSString *)value
13074 NSParameterAssert(value !=
nil);
13075 [_jumpCause autorelease];
13092- (void) setCommanderName:(NSString *)value
13094 NSParameterAssert(value !=
nil);
13095 [_commanderName autorelease];
13100- (void) setLastsaveName:(NSString *)value
13102 NSParameterAssert(value !=
nil);
13103 [_lastsaveName autorelease];
13110 BOOL isDockedStatus = NO;
13114 case STATUS_DOCKED:
13115 case STATUS_DOCKING:
13116 case STATUS_START_GAME:
13117 isDockedStatus = YES;
13120 case STATUS_RESTART_GAME:
13122 case STATUS_EFFECT:
13123 case STATUS_ACTIVE:
13124 case STATUS_COCKPIT_DISPLAY:
13126 case STATUS_INACTIVE:
13128 case STATUS_IN_FLIGHT:
13129 case STATUS_AUTOPILOT_ENGAGED:
13130 case STATUS_LAUNCHING:
13131 case STATUS_WITCHSPACE_COUNTDOWN:
13132 case STATUS_ENTERING_WITCHSPACE:
13133 case STATUS_EXITING_WITCHSPACE:
13134 case STATUS_ESCAPE_SEQUENCE:
13135 case STATUS_IN_HOLD:
13136 case STATUS_BEING_SCOOPED:
13137 case STATUS_HANDLING_ERROR:
13144 if (isDockedStatus)
13150 [
self setStatus:STATUS_IN_FLIGHT];
13151 isDockedStatus = NO;
13159 [
self setStatus:STATUS_DOCKED];
13160 isDockedStatus = YES;
13165 return isDockedStatus;
13212 amountToPay =
MIN(maximumFine, calculatedFine);
13214 [
self addMessageToReport:[NSString stringWithFormat:DESC(@"station-docking-clearance-fined-@-cr"), OOCredits(amountToPay)]];
13224 assert(whole !=
nil);
13227 NSEnumerator *wormholes = [scannedWormholes objectEnumerator];
13229 while ((wh = [wormholes nextObject]))
13231 if (wh == whole)
return;
13234 [scannedWormholes addObject:whole];
13247 double now = [
self clockTimeAdjusted];
13249 NSMutableArray * savedWormholes = [[NSMutableArray alloc] initWithCapacity:[scannedWormholes count]];
13250 NSEnumerator * wormholes = [scannedWormholes objectEnumerator];
13257 if ([wh arrivalTime] > now)
13259 [savedWormholes addObject:wh];
13264 if ([[wh shipsInTransit]
count] > 0)
13266 [savedWormholes addObject:wh];
13272 [scannedWormholes release];
13279 return [NSArray arrayWithArray:scannedWormholes];
13283- (void) initialiseMissionDestinations:(NSDictionary *)destinations andLegacy:(NSArray *)legacy
13285 NSEnumerator *keyEnum =
nil;
13286 NSString *key =
nil;
13291 [missionDestinations release];
13294 for (keyEnum = [destinations keyEnumerator]; (key = [keyEnum nextObject]); )
13296 value = [destinations objectForKey:key];
13299 if ([value isKindOfClass:[NSDictionary
class]])
13301 value = [value mutableCopy];
13302 [missionDestinations setObject:value forKey:key];
13311 NSNumber *legacyMarker;
13312 for (keyEnum = [legacy objectEnumerator]; (legacyMarker = [keyEnum nextObject]); )
13314 dest = [legacyMarker intValue];
13315 [
self addMissionDestinationMarker:[
self defaultMarker:dest]];
13322- (NSString *)markerKey:(NSDictionary *)marker
13324 return [NSString stringWithFormat:@"%d-%@",[marker oo_intForKey:@"system"], [marker oo_stringForKey:@"name"]];
13328- (void) addMissionDestinationMarker:(NSDictionary *)marker
13330 NSDictionary *validated = [
self validatedMarker:marker];
13331 if (validated ==
nil)
13336 [missionDestinations setObject:validated forKey:[
self markerKey:validated]];
13340- (BOOL) removeMissionDestinationMarker:(NSDictionary *)marker
13342 NSDictionary *validated = [
self validatedMarker:marker];
13343 if (validated ==
nil)
13351 [missionDestinations removeObjectForKey:[
self markerKey:validated]];
13368- (void) setLastShot:(NSArray *)shot
13376 [extraMissionKeys release];
13381- (void) setExtraMissionKeys:(NSDictionary *)keys
13383 NSString *key =
nil;
13384 NSMutableDictionary *
final = [[NSMutableDictionary alloc] init];
13385 foreach (key, [keys allKeys])
13387 [final setObject:[
self processKeyCode:[keys oo_arrayForKey:key]] forKey:key];
13394- (void) clearExtraGuiScreenKeys:(
OOGUIScreenID)gui key:(NSString *)key
13396 NSMutableArray *keydefs = [extraGuiScreenKeys objectForKey:[NSString stringWithFormat:@"%d",gui]];
13397 NSInteger i = [keydefs count];
13398 NSDictionary *def =
nil;
13401 def = [keydefs objectAtIndex:i];
13402 if (def && [[def oo_stringForKey:
@"name"] isEqualToString:key])
13404 [keydefs removeObjectAtIndex:i];
13416 NSMutableArray *newarray =
nil;
13417 NSString *key =
nil;
13418 NSMutableDictionary *
final = [[NSMutableDictionary alloc] init];
13420 NSMutableArray *checklist = [[NSMutableArray alloc] init];
13422 foreach (key, [keys allKeys])
13424 NSArray *item = [
self processKeyCode:[keys oo_arrayForKey:key]];
13425 [checklist addObject:item];
13426 [final setObject:item forKey:key];
13440 newarray = [[NSMutableArray alloc] init];
13444 newarray = [[extraGuiScreenKeys objectForKey:[NSString stringWithFormat:@"%d",gui]] mutableCopy];
13445 NSInteger i = [newarray count];
13450 def_existing = [newarray objectAtIndex:i];
13452 if (def_existing && [[def_existing
name] isEqualToString:[definition
name]])
13454 [newarray removeObjectAtIndex:i];
13460 j = [checklist count];
13461 foreach (key, [keydefs allKeys])
13465 if ([[NSString stringWithFormat:
@"%@",[keydefs objectForKey:key]] isEqualToString:[NSString stringWithFormat:
@"%@",[checklist objectAtIndex:j]]])
13468 OOLog(
kOOLogException,
@"***** Exception in setExtraGuiScreenKeys: %@ : %@ (%@)",
@"invalid key settings",
@"key already in use", key);
13475 [newarray addObject:definition];
13477 if (result) [extraGuiScreenKeys setObject:[newarray mutableCopy] forKey:[NSString stringWithFormat:@"%d",gui]];
13478 [newarray release];
13486 NSMutableArray *flags =
nil;
13487 NSString *flagsString =
nil;
13489 [
super dumpSelfState];
13502 flags = [NSMutableArray array];
13503 #define ADD_FLAG_IF_SET(x) if (x) { [flags addObject:@#x]; }
13532 flagsString = [flags count] ? [flags componentsJoinedByString:@", "] : (NSString *)
@"none";
13533 OOLog(
@"dumpState.playerEntity",
@"Flags: %@", flagsString);
13659#if OO_FOV_INFLIGHT_CONTROL_ENABLED
13660 n_key_inc_field_of_view &&
13661 n_key_dec_field_of_view &&
13703 return NSOrderedAscending;
13705 else if (result > 0)
13707 return NSOrderedDescending;
13711 return NSOrderedSame;
13722 return NSOrderedAscending;
13724 else if (result > 0)
13726 return NSOrderedDescending;
13730 return NSOrderedSame;
13741 return NSOrderedAscending;
13743 else if (result > 0)
13745 return NSOrderedDescending;
13749 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