Oolite
Loading...
Searching...
No Matches
OOJSPlayerShip.m File Reference
Include dependency graph for OOJSPlayerShip.m:

Go to the source code of this file.

Enumerations

enum  {
  kPlayerShip_activeMissile , kPlayerShip_aftShield , kPlayerShip_aftShieldRechargeRate , kPlayerShip_chartHightlightMode ,
  kPlayerShip_compassMode , kPlayerShip_compassTarget , kPlayerShip_compassType , kPlayerShip_currentWeapon ,
  kPlayerShip_crosshairs , kPlayerShip_cursorCoordinates , kPlayerShip_cursorCoordinatesInLY , kPlayerShip_docked ,
  kPlayerShip_dockedStation , kPlayerShip_fastEquipmentA , kPlayerShip_fastEquipmentB , kPlayerShip_forwardShield ,
  kPlayerShip_forwardShieldRechargeRate , kPlayerShip_fuelLeakRate , kPlayerShip_galacticHyperspaceBehaviour , kPlayerShip_galacticHyperspaceFixedCoords ,
  kPlayerShip_galacticHyperspaceFixedCoordsInLY , kPlayerShip_galaxyCoordinates , kPlayerShip_galaxyCoordinatesInLY , kPlayerShip_hud ,
  kPlayerShip_hudAllowsBigGui , kPlayerShip_hudHidden , kPlayerShip_injectorsEngaged , kPlayerShip_massLockable ,
  kPlayerShip_maxAftShield , kPlayerShip_maxForwardShield , kPlayerShip_messageGuiTextColor , kPlayerShip_messageGuiTextCommsColor ,
  kPlayerShip_multiFunctionDisplays , kPlayerShip_multiFunctionDisplayList , kPlayerShip_missilesOnline , kPlayerShip_pitch ,
  kPlayerShip_price , kPlayerShip_primedEquipment , kPlayerShip_renovationCost , kPlayerShip_reticleColorTarget ,
  kPlayerShip_reticleColorTargetSensitive , kPlayerShip_reticleColorWormhole , kPlayerShip_renovationMultiplier , kPlayerShip_reticleTargetSensitive ,
  kPlayerShip_roll , kPlayerShip_routeMode , kPlayerShip_scannerMinimalistic , kPlayerShip_scannerNonLinear ,
  kPlayerShip_scannerUltraZoom , kPlayerShip_scoopOverride , kPlayerShip_serviceLevel , kPlayerShip_specialCargo ,
  kPlayerShip_targetSystem , kPlayerShip_nextSystem , kPlayerShip_infoSystem , kPlayerShip_previousSystem ,
  kPlayerShip_torusEngaged , kPlayerShip_viewDirection , kPlayerShip_viewPositionAft , kPlayerShip_viewPositionForward ,
  kPlayerShip_viewPositionPort , kPlayerShip_viewPositionStarboard , kPlayerShip_weaponsOnline , kPlayerShip_yaw
}

Functions

static JSBool PlayerShipGetProperty (JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool PlayerShipSetProperty (JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
static JSBool PlayerShipLaunch (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemoveAllCargo (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipUseSpecialCargo (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipEngageAutopilotToStation (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipDisengageAutopilot (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRequestDockingClearance (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipCancelDockingRequest (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAwardEquipmentToCurrentPylon (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAddPassenger (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemovePassenger (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAddParcel (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemoveParcel (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAwardContract (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemoveContract (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetCustomView (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetPrimedEquipment (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipResetCustomView (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipResetScannerZoom (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipTakeInternalDamage (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipBeginHyperspaceCountdown (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipCancelHyperspaceCountdown (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipBeginGalacticHyperspaceCountdown (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetMultiFunctionDisplay (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetMultiFunctionText (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipHideHUDSelector (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipShowHUDSelector (JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetCustomHUDDial (JSContext *context, uintN argc, jsval *vp)
static BOOL ValidateContracts (JSContext *context, uintN argc, jsval *vp, BOOL isCargo, OOSystemID *start, OOSystemID *destination, double *eta, double *fee, double *premium, NSString *functionName, unsigned *risk)
void InitOOJSPlayerShip (JSContext *context, JSObject *global)
JSClass * JSPlayerShipClass (void)
JSObject * JSPlayerShipPrototype (void)
JSObject * JSPlayerShipObject (void)

Variables

static JSObject * sPlayerShipPrototype
static JSObject * sPlayerShipObject
static JSClass sPlayerShipClass
static JSPropertySpec sPlayerShipProperties []
static JSFunctionSpec sPlayerShipMethods []

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kPlayerShip_activeMissile 
kPlayerShip_aftShield 
kPlayerShip_aftShieldRechargeRate 
kPlayerShip_chartHightlightMode 
kPlayerShip_compassMode 
kPlayerShip_compassTarget 
kPlayerShip_compassType 
kPlayerShip_currentWeapon 
kPlayerShip_crosshairs 
kPlayerShip_cursorCoordinates 
kPlayerShip_cursorCoordinatesInLY 
kPlayerShip_docked 
kPlayerShip_dockedStation 
kPlayerShip_fastEquipmentA 
kPlayerShip_fastEquipmentB 
kPlayerShip_forwardShield 
kPlayerShip_forwardShieldRechargeRate 
kPlayerShip_fuelLeakRate 
kPlayerShip_galacticHyperspaceBehaviour 
kPlayerShip_galacticHyperspaceFixedCoords 
kPlayerShip_galacticHyperspaceFixedCoordsInLY 
kPlayerShip_galaxyCoordinates 
kPlayerShip_galaxyCoordinatesInLY 
kPlayerShip_hud 
kPlayerShip_hudAllowsBigGui 
kPlayerShip_hudHidden 
kPlayerShip_injectorsEngaged 
kPlayerShip_massLockable 
kPlayerShip_maxAftShield 
kPlayerShip_maxForwardShield 
kPlayerShip_messageGuiTextColor 
kPlayerShip_messageGuiTextCommsColor 
kPlayerShip_multiFunctionDisplays 
kPlayerShip_multiFunctionDisplayList 
kPlayerShip_missilesOnline 
kPlayerShip_pitch 
kPlayerShip_price 
kPlayerShip_primedEquipment 
kPlayerShip_renovationCost 
kPlayerShip_reticleColorTarget 
kPlayerShip_reticleColorTargetSensitive 
kPlayerShip_reticleColorWormhole 
kPlayerShip_renovationMultiplier 
kPlayerShip_reticleTargetSensitive 
kPlayerShip_roll 
kPlayerShip_routeMode 
kPlayerShip_scannerMinimalistic 
kPlayerShip_scannerNonLinear 
kPlayerShip_scannerUltraZoom 
kPlayerShip_scoopOverride 
kPlayerShip_serviceLevel 
kPlayerShip_specialCargo 
kPlayerShip_targetSystem 
kPlayerShip_nextSystem 
kPlayerShip_infoSystem 
kPlayerShip_previousSystem 
kPlayerShip_torusEngaged 
kPlayerShip_viewDirection 
kPlayerShip_viewPositionAft 
kPlayerShip_viewPositionForward 
kPlayerShip_viewPositionPort 
kPlayerShip_viewPositionStarboard 
kPlayerShip_weaponsOnline 
kPlayerShip_yaw 

Definition at line 99 of file OOJSPlayerShip.m.

99 {
100 // Property IDs
101 kPlayerShip_activeMissile, // index in 'missiles' array of current active missile
102 kPlayerShip_aftShield, // aft shield charge level, nonnegative float, read/write
103 kPlayerShip_aftShieldRechargeRate, // aft shield recharge rate, positive float, read-only
104 kPlayerShip_chartHightlightMode, // what type of information is being shown on the chart
105 kPlayerShip_compassMode, // compass mode, string, read/write
106 kPlayerShip_compassTarget, // object targeted by the compass, entity, read/write
107 kPlayerShip_compassType, // basic / advanced, string, read/write
108 kPlayerShip_currentWeapon, // shortcut property to _aftWeapon, etc. overrides kShip generic version
109 kPlayerShip_crosshairs, // custom plist file defining crosshairs
110 kPlayerShip_cursorCoordinates, // cursor coordinates (unscaled), Vector3D, read only
111 kPlayerShip_cursorCoordinatesInLY, // cursor coordinates (in LY), Vector3D, read only
112 kPlayerShip_docked, // docked, boolean, read-only
113 kPlayerShip_dockedStation, // docked station, entity, read-only
114 kPlayerShip_fastEquipmentA, // fast equipment A, string, read/write
115 kPlayerShip_fastEquipmentB, // fast equipment B, string, read/write
116 kPlayerShip_forwardShield, // forward shield charge level, nonnegative float, read/write
117 kPlayerShip_forwardShieldRechargeRate, // forward shield recharge rate, positive float, read-only
118 kPlayerShip_fuelLeakRate, // fuel leak rate, float, read/write
119 kPlayerShip_galacticHyperspaceBehaviour, // can be standard, all systems reachable or fixed coordinates, integer, read-only
120 kPlayerShip_galacticHyperspaceFixedCoords, // used when fixed coords behaviour is selected, Vector3D, read/write
121 kPlayerShip_galacticHyperspaceFixedCoordsInLY, // used when fixed coords behaviour is selected, Vector3D, read/write
122 kPlayerShip_galaxyCoordinates, // galaxy coordinates (unscaled), Vector3D, read only
123 kPlayerShip_galaxyCoordinatesInLY, // galaxy coordinates (in LY), Vector3D, read only
124 kPlayerShip_hud, // hud name identifier, string, read/write
125 kPlayerShip_hudAllowsBigGui, // hud big gui, string, read only
126 kPlayerShip_hudHidden, // hud visibility, boolean, read/write
127 kPlayerShip_injectorsEngaged, // injectors in use, boolean, read-only
128 kPlayerShip_massLockable, // mass-lockability of player ship, read/write
129 kPlayerShip_maxAftShield, // maximum aft shield charge level, positive float, read-only
130 kPlayerShip_maxForwardShield, // maximum forward shield charge level, positive float, read-only
131 kPlayerShip_messageGuiTextColor, // message gui standard text color, array, read/write
132 kPlayerShip_messageGuiTextCommsColor, // message gui incoming comms text color, array, read/write
133 kPlayerShip_multiFunctionDisplays, // mfd count, positive int, read-only
134 kPlayerShip_multiFunctionDisplayList, // active mfd list, array, read-only
135 kPlayerShip_missilesOnline, // bool (false for ident mode, true for missile mode)
136 kPlayerShip_pitch, // pitch (overrules Ship)
137 kPlayerShip_price, // idealised trade-in value decicredits, positive int, read-only
138 kPlayerShip_primedEquipment, // currently primed equipment, string, read/write
139 kPlayerShip_renovationCost, // int read-only current renovation cost
140 kPlayerShip_reticleColorTarget, // Reticle color for normal targets, array, read/write
141 kPlayerShip_reticleColorTargetSensitive, // Reticle color for targets picked up when sensitive mode is on, array, read/write
142 kPlayerShip_reticleColorWormhole, // REticle color for wormholes, array, read/write
143 kPlayerShip_renovationMultiplier, // float read-only multiplier for renovation costs
144 kPlayerShip_reticleTargetSensitive, // target box changes color when primary target in crosshairs, boolean, read/write
145 kPlayerShip_roll, // roll (overrules Ship)
146 kPlayerShip_routeMode, // ANA mode
147 kPlayerShip_scannerMinimalistic, // essentially scanner without gridlines
148 kPlayerShip_scannerNonLinear, // non linear scanner setting, boolean, read/write
149 kPlayerShip_scannerUltraZoom, // scanner zoom in powers of 2, boolean, read/write
150 kPlayerShip_scoopOverride, // Scooping
151 kPlayerShip_serviceLevel, // servicing level, positive int 75-100, read-only
152 kPlayerShip_specialCargo, // special cargo, string, read-only
153 kPlayerShip_targetSystem, // target system id, int, read-write
154 kPlayerShip_nextSystem, // next hop system id, read-only
155 kPlayerShip_infoSystem, // info (F7 screen) system id, int, read-write
156 kPlayerShip_previousSystem, // previous system id, read-only
157 kPlayerShip_torusEngaged, // torus in use, boolean, read-only
158 kPlayerShip_viewDirection, // view direction identifier, string, read-only
159 kPlayerShip_viewPositionAft, // view position offset, vector, read-only
160 kPlayerShip_viewPositionForward, // view position offset, vector, read-only
161 kPlayerShip_viewPositionPort, // view position offset, vector, read-only
162 kPlayerShip_viewPositionStarboard, // view position offset, vector, read-only
163 kPlayerShip_weaponsOnline, // weapons online status, boolean, read-only
164 kPlayerShip_yaw, // yaw (overrules Ship)
165};
@ kPlayerShip_docked
@ kPlayerShip_compassMode
@ kPlayerShip_serviceLevel
@ kPlayerShip_cursorCoordinates
@ kPlayerShip_reticleTargetSensitive
@ kPlayerShip_maxForwardShield
@ kPlayerShip_dockedStation
@ kPlayerShip_targetSystem
@ kPlayerShip_roll
@ kPlayerShip_massLockable
@ kPlayerShip_scannerNonLinear
@ kPlayerShip_hud
@ kPlayerShip_injectorsEngaged
@ kPlayerShip_activeMissile
@ kPlayerShip_galacticHyperspaceBehaviour
@ kPlayerShip_fuelLeakRate
@ kPlayerShip_viewPositionAft
@ kPlayerShip_cursorCoordinatesInLY
@ kPlayerShip_torusEngaged
@ kPlayerShip_reticleColorTargetSensitive
@ kPlayerShip_aftShield
@ kPlayerShip_chartHightlightMode
@ kPlayerShip_yaw
@ kPlayerShip_scoopOverride
@ kPlayerShip_currentWeapon
@ kPlayerShip_missilesOnline
@ kPlayerShip_pitch
@ kPlayerShip_fastEquipmentA
@ kPlayerShip_messageGuiTextCommsColor
@ kPlayerShip_multiFunctionDisplayList
@ kPlayerShip_price
@ kPlayerShip_viewPositionForward
@ kPlayerShip_galaxyCoordinates
@ kPlayerShip_compassType
@ kPlayerShip_compassTarget
@ kPlayerShip_galaxyCoordinatesInLY
@ kPlayerShip_infoSystem
@ kPlayerShip_multiFunctionDisplays
@ kPlayerShip_galacticHyperspaceFixedCoordsInLY
@ kPlayerShip_fastEquipmentB
@ kPlayerShip_nextSystem
@ kPlayerShip_scannerUltraZoom
@ kPlayerShip_viewPositionStarboard
@ kPlayerShip_messageGuiTextColor
@ kPlayerShip_renovationCost
@ kPlayerShip_crosshairs
@ kPlayerShip_scannerMinimalistic
@ kPlayerShip_routeMode
@ kPlayerShip_galacticHyperspaceFixedCoords
@ kPlayerShip_weaponsOnline
@ kPlayerShip_reticleColorTarget
@ kPlayerShip_maxAftShield
@ kPlayerShip_viewPositionPort
@ kPlayerShip_hudAllowsBigGui
@ kPlayerShip_specialCargo
@ kPlayerShip_forwardShieldRechargeRate
@ kPlayerShip_viewDirection
@ kPlayerShip_reticleColorWormhole
@ kPlayerShip_forwardShield
@ kPlayerShip_primedEquipment
@ kPlayerShip_aftShieldRechargeRate
@ kPlayerShip_hudHidden
@ kPlayerShip_renovationMultiplier
@ kPlayerShip_previousSystem

Function Documentation

◆ InitOOJSPlayerShip()

void InitOOJSPlayerShip ( JSContext * context,
JSObject * global )

Definition at line 269 of file OOJSPlayerShip.m.

270{
274
275 PlayerEntity* player = [PlayerEntity sharedPlayer]; // NOTE: at time of writing, this creates the player entity. Don't use PLAYER here.
276
277 // Create ship object as a property of the player object.
279 JS_SetPrivate(context, sPlayerShipObject, OOConsumeReference([player weakRetain]));
280 [player setJSSelf:sPlayerShipObject context:context];
281 // Analyzer: object leaked. [Expected, object is retained by JS object.]
282}
id OOConsumeReference(id OO_NS_CONSUMED value)
static JSFunctionSpec sPlayerShipMethods[]
static JSClass sPlayerShipClass
static JSObject * sPlayerShipObject
static JSObject * sPlayerShipPrototype
static JSPropertySpec sPlayerShipProperties[]
JSObject * JSPlayerObject(void)
Definition OOJSPlayer.m:170
JSObject * JSShipPrototype(void)
Definition OOJSShip.m:587
JSClass * JSShipClass(void)
Definition OOJSShip.m:582
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
#define OOJS_PROP_READONLY
void OOJSRegisterSubclass(JSClass *subclass, JSClass *superclass)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)
void setJSSelf:context:(JSObject *val,[context] JSContext *context)
PlayerEntity * sharedPlayer()

References JSPlayerObject(), JSShipClass(), JSShipPrototype(), OOConsumeReference(), OOJS_PROP_READONLY, OOJSBasicPrivateObjectConverter(), OOJSRegisterObjectConverter(), OOJSRegisterSubclass(), OOJSUnconstructableConstruct(), PlayerEntity::setJSSelf:context:, PlayerEntity::sharedPlayer, sPlayerShipClass, sPlayerShipMethods, sPlayerShipObject, sPlayerShipProperties, and sPlayerShipPrototype.

Referenced by OOJavaScriptEngine(Private)::createMainThreadContext.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ JSPlayerShipClass()

JSClass * JSPlayerShipClass ( void )

Definition at line 284 of file OOJSPlayerShip.m.

285{
286 return &sPlayerShipClass;
287}

References sPlayerShipClass.

◆ JSPlayerShipObject()

JSObject * JSPlayerShipObject ( void )

Definition at line 294 of file OOJSPlayerShip.m.

295{
296 return sPlayerShipObject;
297}

◆ JSPlayerShipPrototype()

JSObject * JSPlayerShipPrototype ( void )

Definition at line 289 of file OOJSPlayerShip.m.

290{
292}

References sPlayerShipPrototype.

◆ PlayerShipAddParcel()

JSBool PlayerShipAddParcel ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1231 of file OOJSPlayerShip.m.

1232{
1233 OOJS_NATIVE_ENTER(context)
1234
1236 NSString* name = nil;
1237 OOSystemID start = 0, destination = 0;
1238 jsdouble eta = 0.0, fee = 0.0, premium = 0.0;
1239 unsigned risk = 0;
1240
1241 if (argc < 5) {
1242 OOJSReportBadArguments(context, @"PlayerShip", @"addParcel", argc, OOJS_ARGV, nil, @"name, start, destination, ETA, fee");
1243 return NO;
1244 }
1245
1246 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1247 if (EXPECT_NOT(name == nil)) {
1248 OOJSReportBadArguments(context, @"PlayerShip", @"addParcel", 1, &OOJS_ARGV[0], nil, @"string");
1249 return NO;
1250 }
1251
1252 if (!ValidateContracts(context, argc, vp, NO, &start, &destination, &eta, &fee, &premium, @"addParcel", &risk))
1253 return NO; // always go through validate contracts (passenger/parcel mode)
1254
1255 // Ensure there's space.
1256
1257 BOOL OK = [player addParcel:name start:start destination:destination eta:eta fee:fee premium:premium risk:risk];
1258 OOJS_RETURN_BOOL(OK);
1259
1261}
#define EXPECT_NOT(x)
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
static BOOL ValidateContracts(JSContext *context, uintN argc, jsval *vp, BOOL isCargo, OOSystemID *start, OOSystemID *destination, double *eta, double *fee, double *premium, NSString *functionName, unsigned *risk)
PlayerEntity * OOPlayerForScripting(void)
Definition OOJSPlayer.m:175
#define OOJS_RETURN_BOOL(v)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
#define OOJS_ARGV
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
return nil
int16_t OOSystemID
Definition OOTypes.h:183

References PlayerEntity::addParcel:start:destination:eta:fee:premium:risk:, EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), and ValidateContracts().

Here is the call graph for this function:

◆ PlayerShipAddPassenger()

JSBool PlayerShipAddPassenger ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1171 of file OOJSPlayerShip.m.

1172{
1173 OOJS_NATIVE_ENTER(context)
1174
1176 NSString* name = nil;
1177 OOSystemID start = 0, destination = 0;
1178 jsdouble eta = 0.0, fee = 0.0, advance = 0.0;
1179 unsigned risk = 0;
1180
1181 if (argc < 5) {
1182 OOJSReportBadArguments(context, @"PlayerShip", @"addPassenger", argc, OOJS_ARGV, nil, @"name, start, destination, ETA, fee");
1183 return NO;
1184 }
1185
1186 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1187 if (EXPECT_NOT(name == nil)) {
1188 OOJSReportBadArguments(context, @"PlayerShip", @"addPassenger", 1, &OOJS_ARGV[0], nil, @"string");
1189 return NO;
1190 }
1191
1192 if (!ValidateContracts(context, argc, vp, NO, &start, &destination, &eta, &fee, &advance, @"addPassenger", &risk))
1193 return NO; // always go through validate contracts (passenger)
1194
1195 // Ensure there's space.
1196 if ([player passengerCount] >= [player passengerCapacity])
1197 OOJS_RETURN_BOOL(NO);
1198
1199 BOOL OK = [player addPassenger:name start:start destination:destination eta:eta fee:fee advance:advance risk:risk];
1200 OOJS_RETURN_BOOL(OK);
1201
1203}

References PlayerEntity::addPassenger:start:destination:eta:fee:advance:risk:, EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), and ValidateContracts().

Here is the call graph for this function:

◆ PlayerShipAwardContract()

JSBool PlayerShipAwardContract ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1289 of file OOJSPlayerShip.m.

1290{
1291 OOJS_NATIVE_ENTER(context)
1292
1294 NSString* key = nil;
1295 int32 qty = 0;
1296 OOSystemID start = 0, destination = 0;
1297 jsdouble eta = 0.0, fee = 0.0, premium = 0.0;
1298
1299 if (argc < 6) {
1300 OOJSReportBadArguments(context, @"PlayerShip", @"awardContract", argc, OOJS_ARGV, nil, @"quantity, commodity, start, destination, ETA, fee");
1301 return NO;
1302 }
1303
1304 if (!JS_ValueToInt32(context, OOJS_ARGV[0], &qty)) {
1305 OOJSReportBadArguments(context, @"PlayerShip", @"awardContract", 1, &OOJS_ARGV[0], nil, @"positive integer (cargo quantity)");
1306 return NO;
1307 }
1308
1309 key = OOStringFromJSValue(context, OOJS_ARGV[1]);
1310 if (EXPECT_NOT(key == nil)) {
1311 OOJSReportBadArguments(context, @"PlayerShip", @"awardContract", 1, &OOJS_ARGV[1], nil, @"string (commodity identifier)");
1312 return NO;
1313 }
1314
1315 if (!ValidateContracts(context, argc, vp, YES, &start, &destination, &eta, &fee, &premium, @"awardContract", NULL))
1316 return NO; // always go through validate contracts (cargo)
1317
1318 BOOL OK = [player awardContract:qty commodity:key start:start destination:destination eta:eta fee:fee premium:premium];
1319 OOJS_RETURN_BOOL(OK);
1320
1322}

References PlayerEntity::awardContract:commodity:start:destination:eta:fee:premium:, EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), and ValidateContracts().

Here is the call graph for this function:

◆ PlayerShipAwardEquipmentToCurrentPylon()

JSBool PlayerShipAwardEquipmentToCurrentPylon ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1145 of file OOJSPlayerShip.m.

1146{
1147 OOJS_NATIVE_ENTER(context)
1148
1151
1153 NSString* key = nil;
1154 OOEquipmentType* eqType = nil;
1155
1156 if (argc > 0)
1157 key = JSValueToEquipmentKey(context, OOJS_ARGV[0]);
1158 if (key != nil)
1160 if (EXPECT_NOT(![eqType isMissileOrMine])) {
1161 OOJSReportBadArguments(context, @"PlayerShip", @"awardEquipmentToCurrentPylon", MIN(argc, 1U), OOJS_ARGV, nil, @"equipment type (external store)");
1162 return NO;
1163 }
1164
1165 OOJS_RETURN_BOOL([player assignToActivePylon:key]);
1166
1168}
OOINLINE BOOL OOIsPlayerStale(void)
Definition OOJSEntity.h:63
NSString * JSValueToEquipmentKey(JSContext *context, jsval value)
#define OOJS_RETURN_VOID
#define MIN(A, B)
Definition OOMaths.h:91
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)

References OOEquipmentType::equipmentTypeWithIdentifier:, EXPECT_NOT, JSValueToEquipmentKey(), MIN, nil, OOIsPlayerStale(), OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJS_RETURN_VOID, OOJSReportBadArguments(), and OOPlayerForScripting().

Here is the call graph for this function:

◆ PlayerShipBeginGalacticHyperspaceCountdown()

JSBool PlayerShipBeginGalacticHyperspaceCountdown ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1508 of file OOJSPlayerShip.m.

1509{
1510 OOJS_NATIVE_ENTER(context)
1511
1513 int32 spin_time;
1514 int32 witchspaceSpinUpTime = 5;
1515 BOOL begun = NO;
1516 if (argc == 1) {
1517
1518 if (!JS_ValueToInt32(context, OOJS_ARGV[0], &spin_time) || spin_time < 5 || spin_time > 60) {
1519 OOJSReportBadArguments(context, @"PlayerShip", @"beginGalacticHyperspaceCountdown", 1, &OOJS_ARGV[0], nil, @"between 5 and 60 seconds");
1520 return NO;
1521 }
1522 if (spin_time < 5) {
1523 witchspaceSpinUpTime = 5;
1524 } else {
1525 witchspaceSpinUpTime = spin_time;
1526 }
1527 }
1528 if ([player hasEquipmentItemProviding:@"EQ_GAL_DRIVE"] && [player status] == STATUS_IN_FLIGHT && [player witchJumpChecklist:true]) {
1529 [player setJumpType:YES];
1530 [player setWitchspaceCountdown:witchspaceSpinUpTime];
1531 [player setStatus:STATUS_WITCHSPACE_COUNTDOWN];
1532 [player playGalacticHyperspace];
1533 // say it!
1534 [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"witch-galactic-in-f-seconds"), witchspaceSpinUpTime] forCount:1.0];
1535 begun = YES;
1536 }
1537 OOJS_RETURN_BOOL(begun);
1539}
void setJumpType:(BOOL isGalacticJump)
void setWitchspaceCountdown:(int spin_time)
void setStatus:(OOEntityStatus stat)

References nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), PlayerEntity::playGalacticHyperspace, PlayerEntity::setJumpType:, ShipEntity::setStatus:, and PlayerEntity::setWitchspaceCountdown:.

Here is the call graph for this function:

◆ PlayerShipBeginHyperspaceCountdown()

JSBool PlayerShipBeginHyperspaceCountdown ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1457 of file OOJSPlayerShip.m.

1458{
1459 OOJS_NATIVE_ENTER(context)
1460
1462 int32 spin_time;
1463 int32 witchspaceSpinUpTime = 0;
1464 BOOL begun = NO;
1465 if (argc < 1) {
1466 witchspaceSpinUpTime = 0;
1467#ifdef OO_DUMP_PLANETINFO
1468 // quick intersystem jumps for debugging
1469 witchspaceSpinUpTime = 1;
1470#endif
1471 } else {
1472 if (!JS_ValueToInt32(context, OOJS_ARGV[0], &spin_time) || spin_time < 5 || spin_time > 60) {
1473 OOJSReportBadArguments(context, @"PlayerShip", @"beginHyperspaceCountdown", 1, &OOJS_ARGV[0], nil, @"between 5 and 60 seconds");
1474 return NO;
1475 }
1476 if (spin_time < 5) {
1477 witchspaceSpinUpTime = 5;
1478 } else {
1479 witchspaceSpinUpTime = spin_time;
1480 }
1481 }
1482 if ([player hasHyperspaceMotor] && [player status] == STATUS_IN_FLIGHT && [player witchJumpChecklist:false]) {
1483 [player beginWitchspaceCountdown:witchspaceSpinUpTime];
1484 begun = YES;
1485 }
1486 OOJS_RETURN_BOOL(begun);
1488}
void beginWitchspaceCountdown:(int spin_time)

References PlayerEntity::beginWitchspaceCountdown:, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), and OOPlayerForScripting().

Here is the call graph for this function:

◆ PlayerShipCancelDockingRequest()

JSBool PlayerShipCancelDockingRequest ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1121 of file OOJSPlayerShip.m.

1122{
1123 OOJS_NATIVE_ENTER(context)
1124
1127
1129 StationEntity* stationForDocking = nil;
1130
1131 if (argc > 0)
1132 stationForDocking = OOJSNativeObjectOfClassFromJSValue(context, OOJS_ARGV[0], [StationEntity class]);
1133 if (stationForDocking == nil) {
1134 OOJSReportBadArguments(context, @"PlayerShip", @"cancelDockingRequest", MIN(argc, 1U), OOJS_ARGV, nil, @"station");
1135 return NO;
1136 }
1137
1138 [player cancelDockingRequest:stationForDocking];
1140
1142}
id OOJSNativeObjectOfClassFromJSValue(JSContext *context, jsval value, Class requiredClass)
void cancelDockingRequest:(StationEntity *stationForDocking)

References PlayerEntity::cancelDockingRequest:, EXPECT_NOT, MIN, nil, OOIsPlayerStale(), OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSNativeObjectOfClassFromJSValue(), OOJSReportBadArguments(), and OOPlayerForScripting().

Here is the call graph for this function:

◆ PlayerShipCancelHyperspaceCountdown()

JSBool PlayerShipCancelHyperspaceCountdown ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1491 of file OOJSPlayerShip.m.

1492{
1493 OOJS_NATIVE_ENTER(context)
1494
1496
1497 BOOL cancelled = NO;
1498 if ([player hasHyperspaceMotor] && [player status] == STATUS_WITCHSPACE_COUNTDOWN) {
1500 [player setJumpType:false];
1501 cancelled = YES;
1502 }
1503
1504 OOJS_RETURN_BOOL(cancelled);
1506}

References PlayerEntity::cancelWitchspaceCountdown, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOPlayerForScripting(), and PlayerEntity::setJumpType:.

Here is the call graph for this function:

◆ PlayerShipDisengageAutopilot()

JSBool PlayerShipDisengageAutopilot ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1085 of file OOJSPlayerShip.m.

1086{
1087 OOJS_NATIVE_ENTER(context)
1088
1091
1094
1096}
void disengageAutopilot()

References PlayerEntity::disengageAutopilot, EXPECT_NOT, OOIsPlayerStale(), OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, and OOJS_RETURN_VOID.

Here is the call graph for this function:

◆ PlayerShipEngageAutopilotToStation()

JSBool PlayerShipEngageAutopilotToStation ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1062 of file OOJSPlayerShip.m.

1063{
1064 OOJS_NATIVE_ENTER(context)
1065
1068
1070 StationEntity* stationForDocking = nil;
1071
1072 if (argc > 0)
1073 stationForDocking = OOJSNativeObjectOfClassFromJSValue(context, OOJS_ARGV[0], [StationEntity class]);
1074 if (stationForDocking == nil) {
1075 OOJSReportBadArguments(context, @"PlayerShip", @"engageAutopilot", MIN(argc, 1U), OOJS_ARGV, nil, @"station");
1076 return NO;
1077 }
1078
1079 OOJS_RETURN_BOOL([player engageAutopilotToStation:stationForDocking]);
1080
1082}

References EXPECT_NOT, MIN, nil, OOIsPlayerStale(), OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJS_RETURN_VOID, OOJSNativeObjectOfClassFromJSValue(), OOJSReportBadArguments(), and OOPlayerForScripting().

Here is the call graph for this function:

◆ PlayerShipGetProperty()

JSBool PlayerShipGetProperty ( JSContext * context,
JSObject * this,
jsid propID,
jsval * value )
static

Definition at line 334 of file OOJSPlayerShip.m.

335{
336 if (!JSID_IS_INT(propID))
337 return YES;
338
339 OOJS_NATIVE_ENTER(context)
340
342 *value = JSVAL_VOID;
343 return YES;
344 }
345
346 id result = nil;
348
349 switch (JSID_TO_INT(propID)) {
351 return JS_NewNumberValue(context, [player activeMissile], value);
352
354 return JS_NewNumberValue(context, [player fuelLeakRate], value);
355
357 *value = OOJSValueFromBOOL([player isDocked]);
358 return YES;
359
361 result = [player dockedStation];
362 break;
363
365 result = [player specialCargo];
366 break;
367
369 result = [[[player hud] reticleColorForIndex:OO_RETICLE_COLOR_TARGET] normalizedArray];
370 break;
371
373 result = [[[player hud] reticleColorForIndex:OO_RETICLE_COLOR_TARGET_SENSITIVE] normalizedArray];
374 break;
375
377 result = [[[player hud] reticleColorForIndex:OO_RETICLE_COLOR_WORMHOLE] normalizedArray];
378 break;
379
381 *value = OOJSValueFromBOOL([[player hud] reticleTargetSensitive]);
382 return YES;
383
385 *value = OOJSValueFromGalacticHyperspaceBehaviour(context, [player galacticHyperspaceBehaviour]);
386 return YES;
387
389 return NSPointToVectorJSValue(context, [player galacticHyperspaceFixedCoords], value);
390
392 return VectorToJSValue(context, OOGalacticCoordinatesFromInternal([player galacticHyperspaceFixedCoords]), value);
393
395 result = [player fastEquipmentA];
396 break;
397
399 result = [player fastEquipmentB];
400 break;
401
403 result = [player currentPrimedEquipment];
404 break;
405
407 return JS_NewNumberValue(context, [player forwardShieldLevel], value);
408
410 return JS_NewNumberValue(context, [player aftShieldLevel], value);
411
413 return JS_NewNumberValue(context, [player maxForwardShieldLevel], value);
414
416 return JS_NewNumberValue(context, [player maxAftShieldLevel], value);
417
419 // No distinction made internally
420 return JS_NewNumberValue(context, [player forwardShieldRechargeRate], value);
421
423 // No distinction made internally
424 return JS_NewNumberValue(context, [player aftShieldRechargeRate], value);
425
427 return JS_NewNumberValue(context, [[player hud] mfdCount], value);
428
430 result = [player multiFunctionDisplayList];
431 break;
432
434 *value = OOJSValueFromBOOL(![player dialIdentEngaged]);
435 return YES;
436
438 result = OOStringFromLongRangeChartMode([player longRangeChartMode]);
439 break;
440
442 return NSPointToVectorJSValue(context, [player galaxy_coordinates], value);
443
445 return VectorToJSValue(context, OOGalacticCoordinatesFromInternal([player galaxy_coordinates]), value);
446
448 return NSPointToVectorJSValue(context, [player cursor_coordinates], value);
449
451 return VectorToJSValue(context, OOGalacticCoordinatesFromInternal([player cursor_coordinates]), value);
452
454 *value = INT_TO_JSVAL([player targetSystemID]);
455 return YES;
456
458 *value = INT_TO_JSVAL([player nextHopTargetSystemID]);
459 return YES;
460
462 *value = INT_TO_JSVAL([player infoSystemID]);
463 return YES;
464
466 *value = INT_TO_JSVAL([player previousSystemID]);
467 return YES;
468
470 OORouteType route = [player ANAMode];
471 switch (route) {
473 result = @"OPTIMIZED_BY_TIME";
474 break;
476 result = @"OPTIMIZED_BY_JUMPS";
477 break;
479 result = @"OPTIMIZED_BY_NONE";
480 break;
481 }
482 break;
483 }
484
486 *value = OOJSValueFromBOOL([[player hud] minimalisticScanner]);
487 return YES;
488
490 *value = OOJSValueFromBOOL([[player hud] nonlinearScanner]);
491 return YES;
492
494 *value = OOJSValueFromBOOL([[player hud] scannerUltraZoom]);
495 return YES;
496
498 *value = OOJSValueFromBOOL([player scoopOverride]);
499 return YES;
500
502 *value = OOJSValueFromBOOL([player injectorsEngaged]);
503 return YES;
504
506 *value = OOJSValueFromBOOL([player massLockable]);
507 return YES;
508
510 *value = OOJSValueFromBOOL([player hyperspeedEngaged]);
511 return YES;
512
514 result = [player compassTarget];
515 break;
516
518 result = [OOStringFromCompassMode([player compassMode]) isEqualToString:@"COMPASS_MODE_BASIC"] ? @"OO_COMPASSTYPE_BASIC" : @"OO_COMPASSTYPE_ADVANCED";
519 break;
520
522 *value = OOJSValueFromCompassMode(context, [player compassMode]);
523 return YES;
524
525 case kPlayerShip_hud:
526 result = [[player hud] hudName];
527 break;
528
530 result = [[player hud] crosshairDefinition];
531 break;
532
534 *value = OOJSValueFromBOOL([[player hud] allowBigGui]);
535 return YES;
536
538 *value = OOJSValueFromBOOL([[player hud] isHidden]);
539 return YES;
540
542 *value = OOJSValueFromBOOL([player weaponsOnline]);
543 return YES;
544
546 *value = OOJSValueFromViewID(context, [UNIVERSE viewDirection]);
547 return YES;
548
550 return VectorToJSValue(context, [player viewpointOffsetAft], value);
551
553 return VectorToJSValue(context, [player viewpointOffsetForward], value);
554
556 return VectorToJSValue(context, [player viewpointOffsetPort], value);
557
559 return VectorToJSValue(context, [player viewpointOffsetStarboard], value);
560
562 result = [player weaponTypeForFacing:[player currentWeaponFacing] strict:NO];
563 break;
564
566 return JS_NewNumberValue(context, [UNIVERSE tradeInValueForCommanderDictionary:[player commanderDataDictionary]], value);
567
569 return JS_NewNumberValue(context, [player tradeInFactor], value);
570
572 return JS_NewNumberValue(context, [player renovationCosts], value);
573
575 return JS_NewNumberValue(context, [player renovationFactor], value);
576
577 // make roll, pitch, yaw reported to JS use same +/- convention as
578 // for NPC ships
580 return JS_NewNumberValue(context, -[player flightPitch], value);
581
582 case kPlayerShip_roll:
583 return JS_NewNumberValue(context, -[player flightRoll], value);
584
585 case kPlayerShip_yaw:
586 return JS_NewNumberValue(context, -[player flightYaw], value);
587
589 result = [[[UNIVERSE messageGUI] textColor] normalizedArray];
590 break;
591
593 result = [[[UNIVERSE messageGUI] textCommsColor] normalizedArray];
594 break;
595
596 default:
598 }
599
600 *value = OOJSValueFromNativeObject(context, result);
601 return YES;
602
604}
OOINLINE jsval OOJSValueFromGalacticHyperspaceBehaviour(JSContext *context, OOGalacticHyperspaceBehaviour value)
OOINLINE jsval OOJSValueFromViewID(JSContext *context, OOViewID value)
OOINLINE jsval OOJSValueFromCompassMode(JSContext *context, OOCompassMode value)
NSString * OOStringFromLongRangeChartMode(OOLongRangeChartMode chartMode)
BOOL NSPointToVectorJSValue(JSContext *context, NSPoint point, jsval *outValue) NONNULL_FUNC
Definition OOJSVector.m:328
BOOL VectorToJSValue(JSContext *context, Vector vector, jsval *outValue) NONNULL_FUNC
Definition OOJSVector.m:264
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
OORouteType
Definition OOTypes.h:31
@ OPTIMIZED_BY_NONE
Definition OOTypes.h:32
@ OPTIMIZED_BY_JUMPS
Definition OOTypes.h:33
@ OPTIMIZED_BY_TIME
Definition OOTypes.h:34
Vector OOGalacticCoordinatesFromInternal(NSPoint internalCoordinates)
#define UNIVERSE
Definition Universe.h:827
NSString * hudName
NSString * crosshairDefinition
OOColor * reticleColorForIndex:(NSUInteger idx)
NSArray * normalizedArray()
Definition OOColor.m:465
OOWeakReference * compassTarget
StationEntity * dockedStation()
NSString * specialCargo
OORouteType ANAMode()
NSString * fastEquipmentA()
NSString * currentPrimedEquipment()
NSArray * multiFunctionDisplayList()
HeadUpDisplay * hud
NSString * fastEquipmentB()
OOCompassMode compassMode
OOEquipmentType * weaponTypeForFacing:strict:(OOWeaponFacing facing, [strict] BOOL strict)
OOWeaponFacing currentWeaponFacing

References PlayerEntity::ANAMode, PlayerEntity::compassMode, PlayerEntity::compassTarget, HeadUpDisplay::crosshairDefinition, PlayerEntity::currentPrimedEquipment, ShipEntity::currentWeaponFacing, PlayerEntity::dockedStation, EXPECT_NOT, PlayerEntity::fastEquipmentA, PlayerEntity::fastEquipmentB, PlayerEntity::hud, HeadUpDisplay::hudName, kPlayerShip_activeMissile, kPlayerShip_aftShield, kPlayerShip_aftShieldRechargeRate, kPlayerShip_chartHightlightMode, kPlayerShip_compassMode, kPlayerShip_compassTarget, kPlayerShip_compassType, kPlayerShip_crosshairs, kPlayerShip_currentWeapon, kPlayerShip_cursorCoordinates, kPlayerShip_cursorCoordinatesInLY, kPlayerShip_docked, kPlayerShip_dockedStation, kPlayerShip_fastEquipmentA, kPlayerShip_fastEquipmentB, kPlayerShip_forwardShield, kPlayerShip_forwardShieldRechargeRate, kPlayerShip_fuelLeakRate, kPlayerShip_galacticHyperspaceBehaviour, kPlayerShip_galacticHyperspaceFixedCoords, kPlayerShip_galacticHyperspaceFixedCoordsInLY, kPlayerShip_galaxyCoordinates, kPlayerShip_galaxyCoordinatesInLY, kPlayerShip_hud, kPlayerShip_hudAllowsBigGui, kPlayerShip_hudHidden, kPlayerShip_infoSystem, kPlayerShip_injectorsEngaged, kPlayerShip_massLockable, kPlayerShip_maxAftShield, kPlayerShip_maxForwardShield, kPlayerShip_messageGuiTextColor, kPlayerShip_messageGuiTextCommsColor, kPlayerShip_missilesOnline, kPlayerShip_multiFunctionDisplayList, kPlayerShip_multiFunctionDisplays, kPlayerShip_nextSystem, kPlayerShip_pitch, kPlayerShip_previousSystem, kPlayerShip_price, kPlayerShip_primedEquipment, kPlayerShip_renovationCost, kPlayerShip_renovationMultiplier, kPlayerShip_reticleColorTarget, kPlayerShip_reticleColorTargetSensitive, kPlayerShip_reticleColorWormhole, kPlayerShip_reticleTargetSensitive, kPlayerShip_roll, kPlayerShip_routeMode, kPlayerShip_scannerMinimalistic, kPlayerShip_scannerNonLinear, kPlayerShip_scannerUltraZoom, kPlayerShip_scoopOverride, kPlayerShip_serviceLevel, kPlayerShip_specialCargo, kPlayerShip_targetSystem, kPlayerShip_torusEngaged, kPlayerShip_viewDirection, kPlayerShip_viewPositionAft, kPlayerShip_viewPositionForward, kPlayerShip_viewPositionPort, kPlayerShip_viewPositionStarboard, kPlayerShip_weaponsOnline, kPlayerShip_yaw, PlayerEntity::multiFunctionDisplayList, nil, OOColor::normalizedArray, NSPointToVectorJSValue(), OOGalacticCoordinatesFromInternal(), OOIsPlayerStale(), OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSValueFromBOOL(), OOJSValueFromCompassMode(), OOJSValueFromGalacticHyperspaceBehaviour(), OOJSValueFromNativeObject(), OOJSValueFromViewID(), OOPlayerForScripting(), OOStringFromLongRangeChartMode(), OPTIMIZED_BY_JUMPS, OPTIMIZED_BY_NONE, OPTIMIZED_BY_TIME, HeadUpDisplay::reticleColorForIndex:, PlayerEntity::specialCargo, sPlayerShipProperties, sPlayerShipPrototype, UNIVERSE, VectorToJSValue(), and PlayerEntity::weaponTypeForFacing:strict:.

Here is the call graph for this function:

◆ PlayerShipHideHUDSelector()

JSBool PlayerShipHideHUDSelector ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1662 of file OOJSPlayerShip.m.

1663{
1664 OOJS_NATIVE_ENTER(context)
1665
1666 NSString* key = nil;
1668
1669 if (argc > 0) {
1670 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1671 }
1672 if (key == nil) {
1673 OOJSReportBadArguments(context, @"PlayerShip", @"hideHUDSelector", MIN(argc, 1U), OOJS_ARGV, nil, @"string (selector)");
1674 return NO;
1675 }
1676 [[player hud] setHiddenSelector:key hidden:YES];
1677
1679
1681}
void setHiddenSelector:hidden:(NSString *selectorName,[hidden] BOOL hide)

References PlayerEntity::hud, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), and HeadUpDisplay::setHiddenSelector:hidden:.

Here is the call graph for this function:

◆ PlayerShipLaunch()

JSBool PlayerShipLaunch ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1003 of file OOJSPlayerShip.m.

References EXPECT_NOT, PlayerEntity::launchFromStation, OOIsPlayerStale(), OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, and OOJS_RETURN_VOID.

Here is the call graph for this function:

◆ PlayerShipRemoveAllCargo()

JSBool PlayerShipRemoveAllCargo ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1017 of file OOJSPlayerShip.m.

1018{
1019 OOJS_NATIVE_ENTER(context)
1020
1023
1025
1026 if ([player isDocked]) {
1027 [player removeAllCargo];
1029 } else {
1030 OOJSReportError(context, @"PlayerShip.removeAllCargo only works when docked.");
1031 return NO;
1032 }
1033
1035}
void OOJSReportError(JSContext *context, NSString *format,...)

References EXPECT_NOT, OOIsPlayerStale(), OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportError(), OOPlayerForScripting(), and PlayerEntity::removeAllCargo.

Here is the call graph for this function:

◆ PlayerShipRemoveContract()

JSBool PlayerShipRemoveContract ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1325 of file OOJSPlayerShip.m.

1326{
1327 OOJS_NATIVE_ENTER(context)
1328
1330 NSString* key = nil;
1331 int32 dest = 0;
1332
1333 if (argc < 2) {
1334 OOJSReportBadArguments(context, @"PlayerShip", @"removeContract", argc, OOJS_ARGV, nil, @"commodity, destination");
1335 return NO;
1336 }
1337
1338 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1339
1340 if (EXPECT_NOT(key == nil)) {
1341 OOJSReportBadArguments(context, @"PlayerShip", @"removeContract", 1, &OOJS_ARGV[0], nil, @"string (commodity identifier)");
1342 return NO;
1343 }
1344
1345 if (!JS_ValueToInt32(context, OOJS_ARGV[1], &dest) || dest < 0 || dest > 255) {
1346 OOJSReportBadArguments(context, @"PlayerShip", @"removeContract", 1, &OOJS_ARGV[1], nil, @"system ID");
1347 return NO;
1348 }
1349
1350 BOOL OK = [player removeContract:key destination:(unsigned)dest];
1351 OOJS_RETURN_BOOL(OK);
1352
1354}
BOOL removeContract:destination:(NSString *commodity,[destination] unsigned destination)

References EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), and PlayerEntity::removeContract:destination:.

Here is the call graph for this function:

◆ PlayerShipRemoveParcel()

JSBool PlayerShipRemoveParcel ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1264 of file OOJSPlayerShip.m.

1265{
1266 OOJS_NATIVE_ENTER(context)
1267
1269 NSString* name = nil;
1270 BOOL OK = YES;
1271
1272 if (argc > 0)
1273 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1274 if (EXPECT_NOT(name == nil)) {
1275 OOJSReportBadArguments(context, @"PlayerShip", @"removeParcel", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
1276 return NO;
1277 }
1278
1279 OK = [player parcelCount] > 0 && [name length] > 0;
1280 if (OK)
1281 OK = [player removeParcel:name];
1282
1283 OOJS_RETURN_BOOL(OK);
1284
1286}
BOOL removeParcel:(NSString *Name)
NSUInteger parcelCount()

References EXPECT_NOT, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), PlayerEntity::parcelCount, and PlayerEntity::removeParcel:.

Here is the call graph for this function:

◆ PlayerShipRemovePassenger()

JSBool PlayerShipRemovePassenger ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1206 of file OOJSPlayerShip.m.

1207{
1208 OOJS_NATIVE_ENTER(context)
1209
1211 NSString* name = nil;
1212 BOOL OK = YES;
1213
1214 if (argc > 0)
1215 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1216 if (EXPECT_NOT(name == nil)) {
1217 OOJSReportBadArguments(context, @"PlayerShip", @"removePassenger", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
1218 return NO;
1219 }
1220
1221 OK = [player passengerCount] > 0 && [name length] > 0;
1222 if (OK)
1223 OK = [player removePassenger:name];
1224
1225 OOJS_RETURN_BOOL(OK);
1226
1228}
NSUInteger passengerCount()
BOOL removePassenger:(NSString *Name)

References EXPECT_NOT, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), PlayerEntity::passengerCount, and PlayerEntity::removePassenger:.

Here is the call graph for this function:

◆ PlayerShipRequestDockingClearance()

JSBool PlayerShipRequestDockingClearance ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1098 of file OOJSPlayerShip.m.

1099{
1100 OOJS_NATIVE_ENTER(context)
1101
1104
1106 StationEntity* stationForDocking = nil;
1107
1108 if (argc > 0)
1109 stationForDocking = OOJSNativeObjectOfClassFromJSValue(context, OOJS_ARGV[0], [StationEntity class]);
1110 if (stationForDocking == nil) {
1111 OOJSReportBadArguments(context, @"PlayerShip", @"requestDockingClearance", MIN(argc, 1U), OOJS_ARGV, nil, @"station");
1112 return NO;
1113 }
1114
1115 [player requestDockingClearance:stationForDocking];
1117
1119}
void requestDockingClearance:(StationEntity *stationForDocking)

References EXPECT_NOT, MIN, nil, OOIsPlayerStale(), OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSNativeObjectOfClassFromJSValue(), OOJSReportBadArguments(), OOPlayerForScripting(), and PlayerEntity::requestDockingClearance:.

Here is the call graph for this function:

◆ PlayerShipResetCustomView()

JSBool PlayerShipResetCustomView ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1411 of file OOJSPlayerShip.m.

1412{
1413 OOJS_NATIVE_ENTER(context)
1414
1416
1417 // must be in custom view
1418 if ([UNIVERSE viewDirection] != VIEW_CUSTOM) {
1419 OOJSReportError(context, @"PlayerShip.setCustomView only works when custom view is active.");
1420 return NO;
1421 }
1422
1423 [player resetCustomView];
1424 [player noteSwitchToView:VIEW_CUSTOM fromView:VIEW_CUSTOM];
1425
1426 OOJS_RETURN_BOOL(YES);
1428}
void noteSwitchToView:fromView:(OOViewID toView,[fromView] OOViewID fromView)

References PlayerEntity::noteSwitchToView:fromView:, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportError(), OOPlayerForScripting(), PlayerEntity::resetCustomView, and UNIVERSE.

Here is the call graph for this function:

◆ PlayerShipResetScannerZoom()

JSBool PlayerShipResetScannerZoom ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1431 of file OOJSPlayerShip.m.

1432{
1433 OOJS_NATIVE_ENTER(context)
1434
1436
1437 [player resetScannerZoom];
1438
1441}

References OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOPlayerForScripting(), and PlayerEntity::resetScannerZoom.

Here is the call graph for this function:

◆ PlayerShipSetCustomHUDDial()

JSBool PlayerShipSetCustomHUDDial ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1634 of file OOJSPlayerShip.m.

1635{
1636 OOJS_NATIVE_ENTER(context)
1637
1638 NSString* key = nil;
1639 id value = nil;
1641
1642 if (argc > 0) {
1643 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1644 }
1645 if (key == nil) {
1646 OOJSReportBadArguments(context, @"PlayerShip", @"setCustomHUDDial", MIN(argc, 1U), OOJS_ARGV, nil, @"string (key), value]");
1647 return NO;
1648 }
1649 if (argc > 1) {
1650 value = OOJSNativeObjectFromJSValue(context, OOJS_ARGV[1]);
1651 } else {
1652 value = @"";
1653 }
1654
1655 [player setDialCustom:value forKey:key];
1656
1658
1660}
id OOJSNativeObjectFromJSValue(JSContext *context, jsval value)
void setDialCustom:forKey:(id value,[forKey] NSString *key)

References MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSNativeObjectFromJSValue(), OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), and PlayerEntity::setDialCustom:forKey:.

Here is the call graph for this function:

◆ PlayerShipSetCustomView()

JSBool PlayerShipSetCustomView ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1357 of file OOJSPlayerShip.m.

1358{
1359 OOJS_NATIVE_ENTER(context)
1360
1362
1363 if (argc < 2) {
1364 OOJSReportBadArguments(context, @"PlayerShip", @"setCustomView", argc, OOJS_ARGV, nil, @"position, orientiation, [weapon]");
1365 return NO;
1366 }
1367
1368 // must be in custom view
1369 if ([UNIVERSE viewDirection] != VIEW_CUSTOM) {
1370 OOJSReportError(context, @"PlayerShip.setCustomView only works when custom view is active.");
1371 return NO;
1372 }
1373
1374 NSMutableDictionary* viewData = [NSMutableDictionary dictionaryWithCapacity:3];
1375
1376 Vector position = kZeroVector;
1377 BOOL gotpos = JSValueToVector(context, OOJS_ARGV[0], &position);
1378 if (!gotpos) {
1379 OOJSReportBadArguments(context, @"PlayerShip", @"setCustomView", argc, OOJS_ARGV, nil, @"position, orientiation, [weapon]");
1380 return NO;
1381 }
1382 NSString* positionstr = [[NSString alloc] initWithFormat:@"%f %f %f", position.x, position.y, position.z];
1383
1384 Quaternion orientation = kIdentityQuaternion;
1385 BOOL gotquat = JSValueToQuaternion(context, OOJS_ARGV[1], &orientation);
1386 if (!gotquat) {
1387 OOJSReportBadArguments(context, @"PlayerShip", @"setCustomView", argc, OOJS_ARGV, nil, @"position, orientiation, [weapon]");
1388 return NO;
1389 }
1390 NSString* orientationstr = [[NSString alloc] initWithFormat:@"%f %f %f %f", orientation.w, orientation.x, orientation.y, orientation.z];
1391
1392 [viewData setObject:positionstr forKey:@"view_position"];
1393 [viewData setObject:orientationstr forKey:@"view_orientation"];
1394
1395 if (argc > 2) {
1396 NSString* facing = OOStringFromJSValue(context, OOJS_ARGV[2]);
1397 [viewData setObject:facing forKey:@"weapon_facing"];
1398 }
1399
1400 [player setCustomViewDataFromDictionary:viewData withScaling:NO];
1401 [player noteSwitchToView:VIEW_CUSTOM fromView:VIEW_CUSTOM];
1402
1403 [positionstr release];
1404 [orientationstr release];
1405
1406 OOJS_RETURN_BOOL(YES);
1408}
BOOL JSValueToQuaternion(JSContext *context, jsval value, Quaternion *outQuaternion) NONNULL_FUNC
BOOL JSValueToVector(JSContext *context, jsval value, Vector *outVector) NONNULL_FUNC
Definition OOJSVector.m:341
const Quaternion kIdentityQuaternion
const Vector kZeroVector
Definition OOVector.m:27
void setCustomViewDataFromDictionary:withScaling:(NSDictionary *viewDict,[withScaling] BOOL withScaling)

References JSValueToQuaternion(), JSValueToVector(), kIdentityQuaternion, kZeroVector, nil, PlayerEntity::noteSwitchToView:fromView:, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportError(), OOPlayerForScripting(), OOStringFromJSValue(), PlayerEntity::setCustomViewDataFromDictionary:withScaling:, and UNIVERSE.

Here is the call graph for this function:

◆ PlayerShipSetMultiFunctionDisplay()

JSBool PlayerShipSetMultiFunctionDisplay ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1542 of file OOJSPlayerShip.m.

1543{
1544 OOJS_NATIVE_ENTER(context)
1545
1546 NSString* key = nil;
1547 uint32 index = 0;
1549 BOOL OK = YES;
1550
1551 if (argc > 0) {
1552 if (!JS_ValueToECMAUint32(context, OOJS_ARGV[0], &index)) {
1553 OOJSReportBadArguments(context, @"PlayerShip", @"setMultiFunctionDisplay", MIN(argc, 1U), OOJS_ARGV, nil, @"number (index) [, string (key)]");
1554 return NO;
1555 }
1556 }
1557
1558 if (argc > 1) {
1559 key = OOStringFromJSValue(context, OOJS_ARGV[1]);
1560 }
1561
1562 OK = [player setMultiFunctionDisplay:index toKey:key];
1563
1564 OOJS_RETURN_BOOL(OK);
1565
1567}
BOOL setMultiFunctionDisplay:toKey:(NSUInteger index,[toKey] NSString *key)

References MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), and PlayerEntity::setMultiFunctionDisplay:toKey:.

Here is the call graph for this function:

◆ PlayerShipSetMultiFunctionText()

JSBool PlayerShipSetMultiFunctionText ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1570 of file OOJSPlayerShip.m.

1571{
1572 OOJS_NATIVE_ENTER(context)
1573
1574 NSString* key = nil;
1575 NSString* value = nil;
1577 JSBool reflow = NO;
1578
1579 if (argc > 0) {
1580 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1581 }
1582 if (key == nil) {
1583 OOJSReportBadArguments(context, @"PlayerShip", @"setMultiFunctionText", MIN(argc, 1U), OOJS_ARGV, nil, @"string (key) [, string (text)]");
1584 return NO;
1585 }
1586 if (argc > 1) {
1587 value = OOStringFromJSValue(context, OOJS_ARGV[1]);
1588 }
1589 if (argc > 2 && EXPECT_NOT(!JS_ValueToBoolean(context, OOJS_ARGV[2], &reflow))) {
1590 OOJSReportBadArguments(context, @"setMultiFunctionText", @"reflow", argc, OOJS_ARGV, nil, @"boolean");
1591 return NO;
1592 }
1593
1594 if (!reflow) {
1595 [player setMultiFunctionText:value forKey:key];
1596 } else {
1597 GuiDisplayGen* gui = [UNIVERSE gui];
1598 NSString* formatted = [gui reflowTextForMFD:value];
1599 [player setMultiFunctionText:formatted forKey:key];
1600 }
1601
1603
1605}
NSString * reflowTextForMFD:(NSString *input)
void setMultiFunctionText:forKey:(NSString *text,[forKey] NSString *key)

References EXPECT_NOT, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), GuiDisplayGen::reflowTextForMFD:, and PlayerEntity::setMultiFunctionText:forKey:.

Here is the call graph for this function:

◆ PlayerShipSetPrimedEquipment()

JSBool PlayerShipSetPrimedEquipment ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1608 of file OOJSPlayerShip.m.

1609{
1610 OOJS_NATIVE_ENTER(context)
1611
1612 NSString* key = nil;
1614 JSBool showMsg = YES;
1615
1616 if (argc > 0) {
1617 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1618 }
1619 if (key == nil) {
1620 OOJSReportBadArguments(context, @"PlayerShip", @"setPrimedEquipment", MIN(argc, 1U), OOJS_ARGV, nil, @"string (key)");
1621 return NO;
1622 }
1623 if (argc > 1 && EXPECT_NOT(!JS_ValueToBoolean(context, OOJS_ARGV[1], &showMsg))) {
1624 OOJSReportBadArguments(context, @"PlayerShip", @"setPrimedEquipment", MIN(argc, 2U), OOJS_ARGV, nil, @"boolean");
1625 return NO;
1626 }
1627
1628 OOJS_RETURN_BOOL([player setPrimedEquipment:key showMessage:showMsg]);
1629
1631}

References EXPECT_NOT, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ PlayerShipSetProperty()

JSBool PlayerShipSetProperty ( JSContext * context,
JSObject * this,
jsid propID,
JSBool strict,
jsval * value )
static

Definition at line 606 of file OOJSPlayerShip.m.

607{
608 if (!JSID_IS_INT(propID))
609 return YES;
610
611 OOJS_NATIVE_ENTER(context)
612
614 return YES;
615
617 jsdouble fValue;
618 JSBool bValue;
619 int32 iValue;
620 NSString* sValue = nil;
622 Vector vValue;
623 OOColor* colorForScript = nil;
624 Entity* eValue = nil;
625
626 switch (JSID_TO_INT(propID)) {
628 if (JS_ValueToNumber(context, *value, &fValue)) {
629 [player setFuelLeakRate:fValue];
630 return YES;
631 }
632 break;
633
635 if (JS_ValueToBoolean(context, *value, &bValue)) {
636 [player setMassLockable:bValue];
637 return YES;
638 }
639 break;
640
642 if (JS_ValueToBoolean(context, *value, &bValue)) {
643 [[player hud] setReticleTargetSensitive:bValue];
644 return YES;
645 }
646 break;
647
649 sValue = OOStringFromJSValue(context, *value);
650 if (sValue != nil) {
652 if (chartMode > OOLRC_MODE_UNKNOWN) {
653 [player setLongRangeChartMode:chartMode];
654 [player doScriptEvent:OOJSID("chartHighlightModeChanged") withArgument:OOStringFromLongRangeChartMode([player longRangeChartMode])];
655 return YES;
656 } else {
657 OOJSReportError(context, @"Unknown chart hightlight mode specified - must be either OOLRC_MODE_SUNCOLOR, OOLRC_MODE_ECONOMY, OOLRC_MODE_GOVERNMENT or OOLRC_MODE_TECHLEVEL.");
658 }
659 }
660 return NO; // not reachable if successfully set
661 break;
662
664 sValue = OOStringFromJSValue(context, *value);
665 if (sValue != nil) {
667 [player setCompassMode:mode];
668 [player validateCompassTarget];
669 return YES;
670 }
671 break;
672
674 sValue = OOStringFromJSValue(context, *value);
675 if (sValue != nil) {
676 if ([sValue isEqualToString:@"OO_COMPASSTYPE_BASIC"]) {
677 [player setCompassMode:COMPASS_MODE_BASIC];
678 } else if ([sValue isEqualToString:@"OO_COMPASSTYPE_ADVANCED"]) {
679 if (![player hasEquipmentItemProviding:@"EQ_ADVANCED_COMPASS"]) {
680 OOJSReportWarning(context, @"Advanced Compass type requested and set but player ship does not carry the EQ_ADVANCED_COMPASS equipment or has it damaged.");
681 }
682 [player setCompassMode:COMPASS_MODE_PLANET];
683 } else {
684 OOJSReportError(context, @"Unknown compass type specified - must be either OO_COMPASSTYPE_BASIC or OO_COMPASSTYPE_ADVANCED.");
685 return NO;
686 }
687 return YES;
688 }
689 break;
690
692 // can't change compass target in basic mode
693 if (![player hasEquipmentItemProviding:@"EQ_ADVANCED_COMPASS"]) {
694 OOJSReportError(context, @"Compass target cannot be set with a basic compass.");
695 return NO;
696 }
697 // make sure we have a valid entity
698 if (!JSVAL_IS_NULL(*value) && JSValueToEntity(context, *value, &eValue)) {
699 Entity* current = [player compassTarget];
700 [player setNextCompassMode];
701 [player validateCompassTarget];
702 // cycle the targets until we either get back to the start (entity not found) or we find the one we're looking for
703 while ([player compassTarget] != current && [player compassTarget] != eValue) {
704 [player setNextCompassMode];
705 [player validateCompassTarget];
706 }
707 return [player compassTarget] != current;
708 } else {
709 OOJSReportError(context, @"Invalid compass target entity provided.");
710 return NO;
711 }
712 break;
713
715 ghBehaviour = OOGalacticHyperspaceBehaviourFromJSValue(context, *value);
716 if (ghBehaviour != GALACTIC_HYPERSPACE_BEHAVIOUR_UNKNOWN) {
717 [player setGalacticHyperspaceBehaviour:ghBehaviour];
718 return YES;
719 }
720 break;
721
723 if (JSValueToVector(context, *value, &vValue)) {
724 NSPoint coords = { vValue.x, vValue.y };
725 [player setGalacticHyperspaceFixedCoords:coords];
726 return YES;
727 }
728 break;
729
731 if (JSValueToVector(context, *value, &vValue)) {
732 NSPoint coords = OOInternalCoordinatesFromGalactic(vValue);
733 [player setGalacticHyperspaceFixedCoords:coords];
734 return YES;
735 }
736 break;
737
739 sValue = OOStringFromJSValue(context, *value);
740 if (sValue != nil) {
741 [player setFastEquipmentA:sValue];
742 return YES;
743 }
744 break;
745
747 sValue = OOStringFromJSValue(context, *value);
748 if (sValue != nil) {
749 [player setFastEquipmentB:sValue];
750 return YES;
751 }
752 break;
753
755 sValue = OOStringFromJSValue(context, *value);
756 if (sValue != nil) {
757 return [player setPrimedEquipment:sValue showMessage:NO];
758 }
759 break;
760
762 if (JS_ValueToNumber(context, *value, &fValue)) {
763 if (!isnan(fValue)) // guard against undefined
764 {
765 [player decrease_flight_pitch:[player flightPitch] + fValue];
766 }
767 return YES;
768 }
769 break;
770
771 case kPlayerShip_roll:
772 if (JS_ValueToNumber(context, *value, &fValue)) {
773 if (!isnan(fValue)) // guard against undefined
774 {
775 [player decrease_flight_roll:[player flightRoll] + fValue];
776 }
777 return YES;
778 }
779 break;
780
781 case kPlayerShip_yaw:
782 if (JS_ValueToNumber(context, *value, &fValue)) {
783 if (!isnan(fValue)) // guard against undefined
784 {
785 [player decrease_flight_yaw:[player flightYaw] + fValue];
786 }
787 return YES;
788 }
789 break;
790
792 if (JS_ValueToNumber(context, *value, &fValue)) {
793 [player setForwardShieldLevel:fValue];
794 return YES;
795 }
796 break;
797
799 if (JS_ValueToNumber(context, *value, &fValue)) {
800 [player setAftShieldLevel:fValue];
801 return YES;
802 }
803 break;
804
806 if (JS_ValueToNumber(context, *value, &fValue)) {
807 [player setMaxForwardShieldLevel:fValue];
808 return YES;
809 }
810 break;
811
813 if (JS_ValueToNumber(context, *value, &fValue)) {
814 [player setMaxAftShieldLevel:fValue];
815 return YES;
816 }
817 break;
818
820 if (JS_ValueToNumber(context, *value, &fValue)) {
821 [player setForwardShieldRechargeRate:fValue];
822 return YES;
823 }
824 break;
825
827 if (JS_ValueToNumber(context, *value, &fValue)) {
828 [player setAftShieldRechargeRate:fValue];
829 return YES;
830 }
831 break;
832
834 if (JS_ValueToBoolean(context, *value, &bValue)) {
835 [[player hud] setMinimalisticScanner:bValue];
836 return YES;
837 }
838 break;
839
841 if (JS_ValueToBoolean(context, *value, &bValue)) {
842 [[player hud] setNonlinearScanner:bValue];
843 return YES;
844 }
845 break;
846
848 if (JS_ValueToBoolean(context, *value, &bValue)) {
849 [[player hud] setScannerUltraZoom:bValue];
850 return YES;
851 }
852 break;
853
855 if (JS_ValueToBoolean(context, *value, &bValue)) {
856 [player setScoopOverride:bValue];
857 return YES;
858 }
859 break;
860
861 case kPlayerShip_hud:
862 sValue = OOStringFromJSValue(context, *value);
863 if (sValue != nil) {
864 [player switchHudTo:sValue]; // EMMSTRAN: logged error should be a JS warning.
865 return YES;
866 } else {
867 [player resetHud];
868 return YES;
869 }
870 break;
871
873 sValue = OOStringFromJSValue(context, *value);
874 if (sValue == nil) {
875 // reset HUD back to its plist settings
876 NSString* hud = [[[player hud] hudName] retain];
877 [player switchHudTo:hud];
878 [hud release];
879 return YES;
880 } else {
881 if (![[player hud] setCrosshairDefinition:sValue]) {
882 OOJSReportWarning(context, @"Crosshair definition file %@ not found or invalid", sValue);
883 }
884 return YES;
885 }
886 break;
887
889 if (JS_ValueToBoolean(context, *value, &bValue)) {
890 [[player hud] setHidden:bValue];
891 return YES;
892 }
893 break;
894
896 if (JS_ValueToNumber(context, *value, &fValue)) {
897 int newLevel = (int)fValue;
898 [player adjustTradeInFactorBy:(newLevel - [player tradeInFactor])];
899 return YES;
900 }
901
903 BOOL exists = NO;
904 sValue = JSValueToEquipmentKeyRelaxed(context, *value, &exists);
905 if (!exists || sValue == nil) {
906 sValue = @"EQ_WEAPON_NONE";
907 }
908 [player setWeaponMount:[player currentWeaponFacing] toWeapon:sValue inContext:@"scripted"];
909 return YES;
910 }
911
913 /* This first check is essential: if removed, it would be
914 * possible to make jumps of arbitrary length - CIM */
915 if ([player status] != STATUS_ENTERING_WITCHSPACE) {
916 /* These checks though similar are less important. The
917 * consequences of allowing jump destination to be set in
918 * flight are not as severe and do not allow the 7LY limit to
919 * be broken. Nevertheless, it is not allowed. - CIM */
920 // (except when compiled in debugging mode)
921#ifndef OO_DUMP_PLANETINFO
922 if (EXPECT_NOT([player status] != STATUS_DOCKED && [player status] != STATUS_LAUNCHING)) {
923 OOJSReportError(context, @"player.ship.targetSystem is read-only unless called when docked.");
924 return NO;
925 }
926#endif
927
928 if (JS_ValueToInt32(context, *value, &iValue)) {
929 if (iValue >= 0 && iValue < OO_SYSTEMS_PER_GALAXY) {
930 [player setTargetSystemID:iValue];
931 return YES;
932 } else {
933 return NO;
934 }
935 }
936 } else {
937 OOJSReportError(context, @"player.ship.targetSystem is read-only unless called when docked.");
938 return NO;
939 }
940
942 if (JS_ValueToInt32(context, *value, &iValue)) {
943 if (iValue >= 0 && iValue < OO_SYSTEMS_PER_GALAXY) {
944 [player setInfoSystemID:iValue moveChart:YES];
945 return YES;
946 } else {
947 return NO;
948 }
949 }
950 break;
951
953 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
954 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
955 [[UNIVERSE messageGUI] setTextColor:colorForScript];
956 return YES;
957 }
958 break;
959
961 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
962 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
963 [[UNIVERSE messageGUI] setTextCommsColor:colorForScript];
964 return YES;
965 }
966 break;
967
969 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
970 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
971 return [[player hud] setReticleColorForIndex:OO_RETICLE_COLOR_TARGET toColor:colorForScript];
972 }
973 break;
974
976 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
977 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
978 return [[player hud] setReticleColorForIndex:OO_RETICLE_COLOR_TARGET_SENSITIVE toColor:colorForScript];
979 }
980 break;
981
983 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
984 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
985 return [[player hud] setReticleColorForIndex:OO_RETICLE_COLOR_WORMHOLE toColor:colorForScript];
986 }
987 break;
988
989 default:
991 return NO;
992 }
993
994 OOJSReportBadPropertyValue(context, this, propID, sPlayerShipProperties, *value);
995 return NO;
996
998}
OOINLINE OOGalacticHyperspaceBehaviour OOGalacticHyperspaceBehaviourFromJSValue(JSContext *context, jsval value)
OOINLINE OOCompassMode OOCompassModeFromJSValue(JSContext *context, jsval value)
OOLongRangeChartMode OOLongRangeChartModeFromString(NSString *string)
BOOL JSValueToEntity(JSContext *context, jsval value, Entity **outEntity)
Definition OOJSEntity.m:133
NSString * JSValueToEquipmentKeyRelaxed(JSContext *context, jsval value, BOOL *outExists)
void OOJSReportWarning(JSContext *context, NSString *format,...)
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
#define OO_SYSTEMS_PER_GALAXY
OOLongRangeChartMode
Definition OOTypes.h:45
OOCompassMode
Definition OOTypes.h:129
NSPoint OOInternalCoordinatesFromGalactic(Vector galacticCoordinates)
OOGalacticHyperspaceBehaviour
void setHidden:(BOOL newValue)
void setReticleTargetSensitive:(BOOL newReticleTargetSensitiveValue)
void setNonlinearScanner:(BOOL newValue)
void setScannerUltraZoom:(BOOL newValue)
BOOL setReticleColorForIndex:toColor:(NSUInteger idx,[toColor] OOColor *newColor)
void setMinimalisticScanner:(BOOL newValue)
OOColor * colorWithDescription:(id description)
Definition OOColor.m:135
void setNextCompassMode()
void setMaxAftShieldLevel:(float new)
void setForwardShieldLevel:(GLfloat level)
void setAftShieldRechargeRate:(float new)
void setAftShieldLevel:(GLfloat level)
OOLongRangeChartMode longRangeChartMode
void setGalacticHyperspaceFixedCoords:(NSPoint point)
BOOL switchHudTo:(NSString *hudFileName)
void setFastEquipmentA:(NSString *eqKey)
void setFastEquipmentB:(NSString *eqKey)
BOOL setWeaponMount:toWeapon:inContext:(OOWeaponFacing facing,[toWeapon] NSString *eqKey,[inContext] NSString *context)
void setInfoSystemID:moveChart:(OOSystemID sid,[moveChart] BOOL moveChart)
void setFuelLeakRate:(float value)
void setLongRangeChartMode:(OOLongRangeChartMode mode)
void setCompassMode:(OOCompassMode value)
BOOL setPrimedEquipment:showMessage:(NSString *eqKey,[showMessage] BOOL showMsg)
void setScoopOverride:(BOOL newValue)
void validateCompassTarget()
void setGalacticHyperspaceBehaviour:(OOGalacticHyperspaceBehaviour galacticHyperspaceBehaviour)
void adjustTradeInFactorBy:(int value)
void setForwardShieldRechargeRate:(float new)
void setMassLockable:(BOOL newValue)
void setTargetSystemID:(OOSystemID sid)
void setMaxForwardShieldLevel:(float new)
void decrease_flight_roll:(double delta)
void decrease_flight_yaw:(double delta)
GLfloat flightPitch
void doScriptEvent:withArgument:(OOJSPropID message,[withArgument] id argument)
void decrease_flight_pitch:(double delta)
GLfloat flightRoll
GLfloat flightYaw
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
const char int mode
Definition ioapi.h:125
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33

References PlayerEntity::adjustTradeInFactorBy:, OOColor::colorWithDescription:, PlayerEntity::compassTarget, ShipEntity::currentWeaponFacing, ShipEntity::decrease_flight_pitch:, ShipEntity::decrease_flight_roll:, ShipEntity::decrease_flight_yaw:, ShipEntity::doScriptEvent:withArgument:, EXPECT_NOT, ShipEntity::flightPitch, ShipEntity::flightRoll, ShipEntity::flightYaw, PlayerEntity::hud, HeadUpDisplay::hudName, int(), JSValueToEntity(), JSValueToEquipmentKeyRelaxed(), JSValueToVector(), kPlayerShip_aftShield, kPlayerShip_aftShieldRechargeRate, kPlayerShip_chartHightlightMode, kPlayerShip_compassMode, kPlayerShip_compassTarget, kPlayerShip_compassType, kPlayerShip_crosshairs, kPlayerShip_currentWeapon, kPlayerShip_fastEquipmentA, kPlayerShip_fastEquipmentB, kPlayerShip_forwardShield, kPlayerShip_forwardShieldRechargeRate, kPlayerShip_fuelLeakRate, kPlayerShip_galacticHyperspaceBehaviour, kPlayerShip_galacticHyperspaceFixedCoords, kPlayerShip_galacticHyperspaceFixedCoordsInLY, kPlayerShip_hud, kPlayerShip_hudHidden, kPlayerShip_infoSystem, kPlayerShip_massLockable, kPlayerShip_maxAftShield, kPlayerShip_maxForwardShield, kPlayerShip_messageGuiTextColor, kPlayerShip_messageGuiTextCommsColor, kPlayerShip_pitch, kPlayerShip_primedEquipment, kPlayerShip_reticleColorTarget, kPlayerShip_reticleColorTargetSensitive, kPlayerShip_reticleColorWormhole, kPlayerShip_reticleTargetSensitive, kPlayerShip_roll, kPlayerShip_scannerMinimalistic, kPlayerShip_scannerNonLinear, kPlayerShip_scannerUltraZoom, kPlayerShip_scoopOverride, kPlayerShip_serviceLevel, kPlayerShip_targetSystem, kPlayerShip_yaw, PlayerEntity::longRangeChartMode, nil, OO_SYSTEMS_PER_GALAXY, OOCompassModeFromJSValue(), OOGalacticHyperspaceBehaviourFromJSValue(), OOInternalCoordinatesFromGalactic(), OOIsPlayerStale(), OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSReportBadPropertyValue(), OOJSReportError(), OOJSReportWarning(), OOLongRangeChartModeFromString(), OOPlayerForScripting(), OOStringFromJSValue(), PlayerEntity::resetHud, PlayerEntity::setAftShieldLevel:, PlayerEntity::setAftShieldRechargeRate:, PlayerEntity::setCompassMode:, PlayerEntity::setFastEquipmentA:, PlayerEntity::setFastEquipmentB:, PlayerEntity::setForwardShieldLevel:, PlayerEntity::setForwardShieldRechargeRate:, PlayerEntity::setFuelLeakRate:, PlayerEntity::setGalacticHyperspaceBehaviour:, PlayerEntity::setGalacticHyperspaceFixedCoords:, HeadUpDisplay::setHidden:, PlayerEntity::setInfoSystemID:moveChart:, PlayerEntity::setLongRangeChartMode:, PlayerEntity::setMassLockable:, PlayerEntity::setMaxAftShieldLevel:, PlayerEntity::setMaxForwardShieldLevel:, HeadUpDisplay::setMinimalisticScanner:, PlayerEntity::setNextCompassMode, HeadUpDisplay::setNonlinearScanner:, PlayerEntity::setPrimedEquipment:showMessage:, HeadUpDisplay::setReticleColorForIndex:toColor:, HeadUpDisplay::setReticleTargetSensitive:, HeadUpDisplay::setScannerUltraZoom:, PlayerEntity::setScoopOverride:, PlayerEntity::setTargetSystemID:, PlayerEntity::setWeaponMount:toWeapon:inContext:, sPlayerShipProperties, PlayerEntity::switchHudTo:, PlayerEntity::tradeInFactor, PlayerEntity::validateCompassTarget, Vector::x, and Vector::y.

Here is the call graph for this function:

◆ PlayerShipShowHUDSelector()

JSBool PlayerShipShowHUDSelector ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1683 of file OOJSPlayerShip.m.

1684{
1685 OOJS_NATIVE_ENTER(context)
1686
1687 NSString* key = nil;
1689
1690 if (argc > 0) {
1691 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1692 }
1693 if (key == nil) {
1694 OOJSReportBadArguments(context, @"PlayerShip", @"hideHUDSelector", MIN(argc, 1U), OOJS_ARGV, nil, @"string (selector)");
1695 return NO;
1696 }
1697 [[player hud] setHiddenSelector:key hidden:NO];
1698
1700
1702}

References PlayerEntity::hud, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), and HeadUpDisplay::setHiddenSelector:hidden:.

Here is the call graph for this function:

◆ PlayerShipTakeInternalDamage()

JSBool PlayerShipTakeInternalDamage ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1444 of file OOJSPlayerShip.m.

1445{
1446 OOJS_NATIVE_ENTER(context)
1447
1449
1450 BOOL took = [player takeInternalDamage];
1451
1452 OOJS_RETURN_BOOL(took);
1454}
BOOL takeInternalDamage()

References OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOPlayerForScripting(), and PlayerEntity::takeInternalDamage.

Here is the call graph for this function:

◆ PlayerShipUseSpecialCargo()

JSBool PlayerShipUseSpecialCargo ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1038 of file OOJSPlayerShip.m.

1039{
1040 OOJS_NATIVE_ENTER(context)
1041
1044
1046 NSString* name = nil;
1047
1048 if (argc > 0)
1049 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1050 if (EXPECT_NOT(name == nil)) {
1051 OOJSReportBadArguments(context, @"PlayerShip", @"useSpecialCargo", MIN(argc, 1U), OOJS_ARGV, nil, @"string (special cargo description)");
1052 return NO;
1053 }
1054
1055 [player useSpecialCargo:OOStringFromJSValue(context, OOJS_ARGV[0])];
1057
1059}
void useSpecialCargo:(NSString *descriptionString)

References EXPECT_NOT, MIN, nil, OOIsPlayerStale(), OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOPlayerForScripting(), OOStringFromJSValue(), and PlayerEntity::useSpecialCargo:.

Here is the call graph for this function:

◆ ValidateContracts()

BOOL ValidateContracts ( JSContext * context,
uintN argc,
jsval * vp,
BOOL isCargo,
OOSystemID * start,
OOSystemID * destination,
double * eta,
double * fee,
double * premium,
NSString * functionName,
unsigned * risk )
static

Definition at line 1704 of file OOJSPlayerShip.m.

1705{
1707
1708 NSCParameterAssert(context != NULL && vp != NULL && start != NULL && destination != NULL && eta != NULL && fee != NULL);
1709
1710 unsigned uValue, offset = isCargo ? 2 : 1;
1711 jsdouble fValue;
1712 int32 iValue;
1713
1714 if (!JS_ValueToInt32(context, OOJS_ARGV[offset + 0], &iValue) || iValue < 0 || iValue > kOOMaximumSystemID) {
1715 OOJSReportBadArguments(context, @"PlayerShip", functionName, 1, &OOJS_ARGV[offset + 0], nil, @"system ID");
1716 return NO;
1717 }
1718 *start = iValue;
1719
1720 if (!JS_ValueToInt32(context, OOJS_ARGV[offset + 1], &iValue) || iValue < 0 || iValue > kOOMaximumSystemID) {
1721 OOJSReportBadArguments(context, @"PlayerShip", functionName, 1, &OOJS_ARGV[offset + 1], nil, @"system ID");
1722 return NO;
1723 }
1724 *destination = iValue;
1725
1726 if (!JS_ValueToNumber(context, OOJS_ARGV[offset + 2], &fValue) || !isfinite(fValue) || fValue <= [PLAYER clockTime]) {
1727 OOJSReportBadArguments(context, @"PlayerShip", functionName, 1, &OOJS_ARGV[offset + 2], nil, @"number (future time)");
1728 return NO;
1729 }
1730 *eta = fValue;
1731
1732 if (!JS_ValueToNumber(context, OOJS_ARGV[offset + 3], &fValue) || !isfinite(fValue) || fValue < 0.0) {
1733 OOJSReportBadArguments(context, @"PlayerShip", functionName, 1, &OOJS_ARGV[offset + 3], nil, @"number (credits quantity)");
1734 return NO;
1735 }
1736 *fee = fValue;
1737
1738 if (argc > offset + 4 && JS_ValueToNumber(context, OOJS_ARGV[offset + 4], &fValue) && isfinite(fValue) && fValue >= 0.0) {
1739 *premium = fValue;
1740 }
1741
1742 if (!isCargo) {
1743 if (argc > offset + 5 && JS_ValueToECMAUint32(context, OOJS_ARGV[offset + 5], &uValue) && isfinite((double)uValue)) {
1744 *risk = uValue;
1745 }
1746 }
1747
1748 return YES;
1749
1751}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
@ kOOMaximumSystemID
Definition OOTypes.h:187
#define PLAYER
voidpf uLong offset
Definition ioapi.h:132

References kOOMaximumSystemID, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJSReportBadArguments(), and PLAYER.

Referenced by PlayerShipAddParcel(), PlayerShipAddParcel(), PlayerShipAddPassenger(), PlayerShipAddPassenger(), PlayerShipAwardContract(), and PlayerShipAwardContract().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ sPlayerShipClass

JSClass sPlayerShipClass
static
Initial value:
= {
"PlayerShip",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
JSCLASS_NO_OPTIONAL_MEMBERS
}
static JSBool PlayerShipSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
static JSBool PlayerShipGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)

Definition at line 84 of file OOJSPlayerShip.m.

84 {
85 "PlayerShip",
86 JSCLASS_HAS_PRIVATE,
87
88 JS_PropertyStub, // addProperty
89 JS_PropertyStub, // delProperty
90 PlayerShipGetProperty, // getProperty
91 PlayerShipSetProperty, // setProperty
92 JS_EnumerateStub, // enumerate
93 JS_ResolveStub, // resolve
94 JS_ConvertStub, // convert
95 OOJSObjectWrapperFinalize, // finalize
96 JSCLASS_NO_OPTIONAL_MEMBERS
97};

Referenced by InitOOJSPlayerShip(), InitOOJSPlayerShip(), and JSPlayerShipClass().

◆ sPlayerShipMethods

JSFunctionSpec sPlayerShipMethods[]
static

Definition at line 237 of file OOJSPlayerShip.m.

237 {
238 // JS name Function min args
239 { "addParcel", PlayerShipAddParcel, 0 },
240 { "addPassenger", PlayerShipAddPassenger, 0 },
241 { "awardContract", PlayerShipAwardContract, 0 },
242 { "awardEquipmentToCurrentPylon", PlayerShipAwardEquipmentToCurrentPylon, 1 },
243 { "beginHyperspaceCountdown", PlayerShipBeginHyperspaceCountdown, 0 },
244 { "cancelDockingRequest", PlayerShipCancelDockingRequest, 1 },
245 { "cancelHyperspaceCountdown", PlayerShipCancelHyperspaceCountdown, 0 },
246 { "beginGalacticHyperspaceCountdown", PlayerShipBeginGalacticHyperspaceCountdown, 1 },
247 { "disengageAutopilot", PlayerShipDisengageAutopilot, 0 },
248 { "engageAutopilotToStation", PlayerShipEngageAutopilotToStation, 1 },
249 { "hideHUDSelector", PlayerShipHideHUDSelector, 1 },
250 { "launch", PlayerShipLaunch, 0 },
251 { "removeAllCargo", PlayerShipRemoveAllCargo, 0 },
252 { "removeContract", PlayerShipRemoveContract, 2 },
253 { "removeParcel", PlayerShipRemoveParcel, 1 },
254 { "removePassenger", PlayerShipRemovePassenger, 1 },
255 { "requestDockingClearance", PlayerShipRequestDockingClearance, 1 },
256 { "resetCustomView", PlayerShipResetCustomView, 0 },
257 { "resetScannerZoom", PlayerShipResetScannerZoom, 0 },
258 { "setCustomView", PlayerShipSetCustomView, 2 },
259 { "setCustomHUDDial", PlayerShipSetCustomHUDDial, 2 },
260 { "setMultiFunctionDisplay", PlayerShipSetMultiFunctionDisplay, 1 },
261 { "setMultiFunctionText", PlayerShipSetMultiFunctionText, 1 },
262 { "setPrimedEquipment", PlayerShipSetPrimedEquipment, 1 },
263 { "showHUDSelector", PlayerShipShowHUDSelector, 1 },
264 { "takeInternalDamage", PlayerShipTakeInternalDamage, 0 },
265 { "useSpecialCargo", PlayerShipUseSpecialCargo, 1 },
266 { 0 }
267};
static JSBool PlayerShipSetPrimedEquipment(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipEngageAutopilotToStation(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAddParcel(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipBeginHyperspaceCountdown(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetCustomView(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipTakeInternalDamage(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipResetScannerZoom(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipHideHUDSelector(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetCustomHUDDial(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipUseSpecialCargo(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipCancelDockingRequest(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemoveContract(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemoveAllCargo(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAddPassenger(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipResetCustomView(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAwardContract(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemoveParcel(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipDisengageAutopilot(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemovePassenger(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipShowHUDSelector(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetMultiFunctionText(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRequestDockingClearance(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipBeginGalacticHyperspaceCountdown(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetMultiFunctionDisplay(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipLaunch(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipCancelHyperspaceCountdown(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAwardEquipmentToCurrentPylon(JSContext *context, uintN argc, jsval *vp)

Referenced by InitOOJSPlayerShip(), and InitOOJSPlayerShip().

◆ sPlayerShipObject

JSObject* sPlayerShipObject
static

Definition at line 49 of file OOJSPlayerShip.m.

Referenced by InitOOJSPlayerShip(), and JSPlayerShipObject().

◆ sPlayerShipProperties

JSPropertySpec sPlayerShipProperties[]
static

Definition at line 167 of file OOJSPlayerShip.m.

167 {
168 // JS name ID flags
171 { "aftShieldRechargeRate", kPlayerShip_aftShieldRechargeRate, OOJS_PROP_READWRITE_CB },
179 { "cursorCoordinatesInLY", kPlayerShip_cursorCoordinatesInLY, OOJS_PROP_READONLY_CB },
185 { "forwardShieldRechargeRate", kPlayerShip_forwardShieldRechargeRate, OOJS_PROP_READWRITE_CB },
187 { "galacticHyperspaceBehaviour", kPlayerShip_galacticHyperspaceBehaviour, OOJS_PROP_READWRITE_CB },
188 { "galacticHyperspaceFixedCoords", kPlayerShip_galacticHyperspaceFixedCoords, OOJS_PROP_READWRITE_CB },
189 { "galacticHyperspaceFixedCoordsInLY", kPlayerShip_galacticHyperspaceFixedCoordsInLY, OOJS_PROP_READWRITE_CB },
191 { "galaxyCoordinatesInLY", kPlayerShip_galaxyCoordinatesInLY, OOJS_PROP_READONLY_CB },
197 // manifest defined in OOJSManifest.m
201 { "messageGuiTextCommsColor", kPlayerShip_messageGuiTextCommsColor, OOJS_PROP_READWRITE_CB },
203 { "multiFunctionDisplays", kPlayerShip_multiFunctionDisplays, OOJS_PROP_READONLY_CB },
204 { "multiFunctionDisplayList", kPlayerShip_multiFunctionDisplayList, OOJS_PROP_READONLY_CB },
210 { "reticleColorTargetSensitive", kPlayerShip_reticleColorTargetSensitive, OOJS_PROP_READWRITE_CB },
211 { "reticleColorWormhole", kPlayerShip_reticleColorWormhole, OOJS_PROP_READWRITE_CB },
212 { "renovationMultiplier", kPlayerShip_renovationMultiplier, OOJS_PROP_READONLY_CB },
213 { "reticleTargetSensitive", kPlayerShip_reticleTargetSensitive, OOJS_PROP_READWRITE_CB },
229 { "viewPositionForward", kPlayerShip_viewPositionForward, OOJS_PROP_READONLY_CB },
231 { "viewPositionStarboard", kPlayerShip_viewPositionStarboard, OOJS_PROP_READONLY_CB },
234 { 0 }
235};
#define OOJS_PROP_READWRITE_CB
#define OOJS_PROP_READONLY_CB

Referenced by InitOOJSPlayerShip(), InitOOJSPlayerShip(), PlayerShipGetProperty(), PlayerShipGetProperty(), PlayerShipSetProperty(), and PlayerShipSetProperty().

◆ sPlayerShipPrototype

JSObject* sPlayerShipPrototype
static