Oolite
Loading...
Searching...
No Matches
OOJSStation.m
Go to the documentation of this file.
1/*
2OOJSStation.m
3
4Oolite
5Copyright (C) 2004-2013 Giles C Williams and contributors
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; either version 2
10of the License, or (at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20MA 02110-1301, USA.
21
22 */
23
24#import "OOJSStation.h"
25#import "OOJSEntity.h"
27#import "OOJSPlayer.h"
28#import "OOJSShip.h"
31
32#import "GameController.h"
34#import "OOConstToString.h"
35#import "OOEquipmentType.h"
36#import "OOShipRegistry.h"
37
38static JSObject* sStationPrototype;
39
40static BOOL JSStationGetStationEntity(JSContext* context, JSObject* stationObj, StationEntity** outEntity);
41
42static JSBool StationGetProperty(JSContext* context, JSObject* this, jsid propID, jsval* value);
43static JSBool StationSetProperty(JSContext* context, JSObject* this, jsid propID, JSBool strict, jsval* value);
44
45static JSBool StationAbortAllDockings(JSContext* context, uintN argc, jsval* vp);
46static JSBool StationAbortDockingForShip(JSContext* context, uintN argc, jsval* vp);
47static JSBool StationCanDockShip(JSContext* context, uintN argc, jsval* vp);
48static JSBool StationDockPlayer(JSContext* context, uintN argc, jsval* vp);
49static JSBool StationIncreaseAlertLevel(JSContext* context, uintN argc, jsval* vp);
50static JSBool StationDecreaseAlertLevel(JSContext* context, uintN argc, jsval* vp);
51static JSBool StationLaunchShipWithRole(JSContext* context, uintN argc, jsval* vp);
52static JSBool StationLaunchDefenseShip(JSContext* context, uintN argc, jsval* vp);
53static JSBool StationLaunchEscort(JSContext* context, uintN argc, jsval* vp);
54static JSBool StationLaunchScavenger(JSContext* context, uintN argc, jsval* vp);
55static JSBool StationLaunchMiner(JSContext* context, uintN argc, jsval* vp);
56static JSBool StationLaunchPirateShip(JSContext* context, uintN argc, jsval* vp);
57static JSBool StationLaunchShuttle(JSContext* context, uintN argc, jsval* vp);
58static JSBool StationLaunchPatrol(JSContext* context, uintN argc, jsval* vp);
59static JSBool StationLaunchPolice(JSContext* context, uintN argc, jsval* vp);
60static JSBool StationSetInterface(JSContext* context, uintN argc, jsval* vp);
61static JSBool StationSetMarketPrice(JSContext* context, uintN argc, jsval* vp);
62static JSBool StationSetMarketQuantity(JSContext* context, uintN argc, jsval* vp);
63static JSBool StationAddShipToShipyard(JSContext* context, uintN argc, jsval* vp);
64static JSBool StationRemoveShipFromShipyard(JSContext* context, uintN argc, jsval* vp);
65
66static JSClass sStationClass = {
67 "Station",
68 JSCLASS_HAS_PRIVATE,
69
70 JS_PropertyStub, // addProperty
71 JS_PropertyStub, // delProperty
72 StationGetProperty, // getProperty
73 StationSetProperty, // setProperty
74 JS_EnumerateStub, // enumerate
75 JS_ResolveStub, // resolve
76 JS_ConvertStub, // convert
77 OOJSObjectWrapperFinalize, // finalize
78 JSCLASS_NO_OPTIONAL_MEMBERS
79};
80
81enum {
82 // Property IDs
88 kStation_dockedContractors, // miners and scavengers.
95 kStation_isMainStation, // Is [UNIVERSE station], boolean, read-only
101};
102
103static JSPropertySpec sStationProperties[] = {
104 // JS name ID flags
105 { "alertCondition", kStation_alertCondition, OOJS_PROP_READWRITE_CB },
107 { "allowsAutoDocking", kStation_allowsAutoDocking, OOJS_PROP_READWRITE_CB },
108 { "allowsFastDocking", kStation_allowsFastDocking, OOJS_PROP_READWRITE_CB },
110 { "dockedContractors", kStation_dockedContractors, OOJS_PROP_READONLY_CB },
111 { "dockedDefenders", kStation_dockedDefenders, OOJS_PROP_READONLY_CB },
112 { "dockedPolice", kStation_dockedPolice, OOJS_PROP_READONLY_CB },
113 { "equipmentPriceFactor", kStation_equipmentPriceFactor, OOJS_PROP_READONLY_CB },
114 { "equivalentTechLevel", kStation_equivalentTechLevel, OOJS_PROP_READONLY_CB },
117 { "isMainStation", kStation_isMainStation, OOJS_PROP_READONLY_CB },
119 { "requiresDockingClearance", kStation_requiresDockingClearance, OOJS_PROP_READWRITE_CB },
121 { "suppressArrivalReports", kStation_suppressArrivalReports, OOJS_PROP_READWRITE_CB },
123 { 0 }
124};
125
126static JSFunctionSpec sStationMethods[] = {
127 // JS name Function min args
128 { "abortAllDockings", StationAbortAllDockings, 0 },
129 { "abortDockingForShip", StationAbortDockingForShip, 1 },
130 { "canDockShip", StationCanDockShip, 1 },
131 { "dockPlayer", StationDockPlayer, 0 },
132 { "increaseAlertLevel", StationIncreaseAlertLevel, 0 },
133 { "decreaseAlertLevel", StationDecreaseAlertLevel, 0 },
134 { "launchDefenseShip", StationLaunchDefenseShip, 0 },
135 { "launchEscort", StationLaunchEscort, 0 },
136 { "launchMiner", StationLaunchMiner, 0 },
137 { "launchPatrol", StationLaunchPatrol, 0 },
138 { "launchPirateShip", StationLaunchPirateShip, 0 },
139 { "launchPolice", StationLaunchPolice, 0 },
140 { "launchScavenger", StationLaunchScavenger, 0 },
141 { "launchShipWithRole", StationLaunchShipWithRole, 1 },
142 { "launchShuttle", StationLaunchShuttle, 0 },
143 { "setInterface", StationSetInterface, 0 },
144 { "setMarketPrice", StationSetMarketPrice, 2 },
145 { "setMarketQuantity", StationSetMarketQuantity, 2 },
146 { "addShipToShipyard", StationAddShipToShipyard, 1 },
147 { "removeShipFromShipyard", StationRemoveShipFromShipyard, 1 },
148 { 0 }
149};
150
157
158static BOOL JSStationGetStationEntity(JSContext* context, JSObject* stationObj, StationEntity** outEntity)
159{
161
162 BOOL result;
163 Entity* entity = nil;
164
165 if (outEntity == NULL)
166 return NO;
167 *outEntity = nil;
168
169 result = OOJSEntityGetEntity(context, stationObj, &entity);
170 if (!result)
171 return NO;
172
173 if (![entity isKindOfClass:[StationEntity class]])
174 return NO;
175
176 *outEntity = (StationEntity*)entity;
177 return YES;
178
180}
181
182static BOOL JSStationGetShipEntity(JSContext* context, JSObject* shipObj, ShipEntity** outEntity)
183{
185
186 BOOL result;
187 Entity* entity = nil;
188
189 if (outEntity == NULL)
190 return NO;
191 *outEntity = nil;
192
193 result = OOJSEntityGetEntity(context, shipObj, &entity);
194 if (!result)
195 return NO;
196
197 if (![entity isKindOfClass:[ShipEntity class]])
198 return NO;
199
200 *outEntity = (ShipEntity*)entity;
201 return YES;
202
204}
205
206@implementation StationEntity (OOJavaScriptExtensions)
207
208- (void)getJSClass:(JSClass**)outClass andPrototype:(JSObject**)outPrototype
209{
210 *outClass = &sStationClass;
211 *outPrototype = sStationPrototype;
212}
213
214- (NSString*)oo_jsClassName
215{
216 return @"Station";
217}
218
219@end
220
221static JSBool StationGetProperty(JSContext* context, JSObject* this, jsid propID, jsval* value)
222{
223 if (!JSID_IS_INT(propID))
224 return YES;
225
226 OOJS_NATIVE_ENTER(context)
227
228 StationEntity* entity = nil;
229
230 if (!JSStationGetStationEntity(context, this, &entity))
231 return NO;
232 if (entity == nil) {
233 *value = JSVAL_VOID;
234 return YES;
235 }
236
237 switch (JSID_TO_INT(propID)) {
239 *value = OOJSValueFromBOOL(entity == [UNIVERSE station]);
240 return YES;
241
243 *value = OOJSValueFromBOOL([entity hasNPCTraffic]);
244 return YES;
245
247 *value = OOJSValueFromBOOL([entity hasShipyard]);
248 return YES;
249
251 *value = INT_TO_JSVAL([entity alertLevel]);
252 return YES;
253
254 case kStation_allegiance: {
255 NSString* result = [entity allegiance];
256 *value = OOJSValueFromNativeObject(context, result);
257 return YES;
258 }
259
261 *value = OOJSValueFromBOOL([entity requiresDockingClearance]);
262 return YES;
263
264 case kStation_roll:
265 // same as in ship definition, but this time read/write below
266 return JS_NewNumberValue(context, [entity flightRoll], value);
267
269 *value = OOJSValueFromBOOL([entity allowsFastDocking]);
270 return YES;
271
273 *value = OOJSValueFromBOOL([entity allowsAutoDocking]);
274 return YES;
275
277 *value = INT_TO_JSVAL([entity countOfDockedContractors]);
278 return YES;
279
281 *value = INT_TO_JSVAL([entity countOfDockedPolice]);
282 return YES;
283
285 *value = INT_TO_JSVAL([entity countOfDockedDefenders]);
286 return YES;
287
289 *value = INT_TO_JSVAL((int32_t)[entity equivalentTechLevel]);
290 return YES;
291
293 return JS_NewNumberValue(context, [entity equipmentPriceFactor], value);
294
296 *value = OOJSValueFromBOOL([entity suppressArrivalReports]);
297 return YES;
298
300 *value = OOJSValueFromBOOL([entity hasBreakPattern]);
301 return YES;
302
303 case kStation_shipyard: {
304 if (![entity hasShipyard]) {
305 // return null if station has no shipyard
306 *value = OOJSValueFromNativeObject(context, nil);
307 } else {
308 if ([entity localShipyard] == nil)
309 [entity generateShipyard];
310 NSMutableArray* shipyard = [entity localShipyard];
311 *value = OOJSValueFromNativeObject(context, shipyard);
312 }
313 return YES;
314 }
315
316 case kStation_market: {
317 NSDictionary* market = [entity localMarketForScripting];
318 *value = OOJSValueFromNativeObject(context, market);
319 return YES;
320 }
321
322 default:
324 return NO;
325 }
326
328}
329
330static JSBool StationSetProperty(JSContext* context, JSObject* this, jsid propID, JSBool strict, jsval* value)
331{
332 if (!JSID_IS_INT(propID))
333 return YES;
334
335 OOJS_NATIVE_ENTER(context)
336
337 StationEntity* entity = nil;
338 JSBool bValue;
339 int32 iValue;
340 jsdouble fValue;
341 NSString* sValue = nil;
342
343 if (!JSStationGetStationEntity(context, this, &entity))
344 return NO;
345 if (entity == nil)
346 return YES;
347
348 switch (JSID_TO_INT(propID)) {
350 if (JS_ValueToBoolean(context, *value, &bValue)) {
351 [entity setHasNPCTraffic:bValue];
352 return YES;
353 }
354 break;
355
357 if (JS_ValueToInt32(context, *value, &iValue)) {
358 [entity setAlertLevel:iValue signallingScript:NO]; // Performs range checking
359 return YES;
360 }
361 break;
362
364 sValue = OOStringFromJSValue(context, *value);
365 if (sValue != nil) {
366 [entity setAllegiance:sValue];
367 return YES;
368 }
369 break;
370
372 if (JS_ValueToBoolean(context, *value, &bValue)) {
373 [entity setRequiresDockingClearance:bValue];
374 return YES;
375 }
376 break;
377
378 case kStation_roll:
379 if (JS_ValueToNumber(context, *value, &fValue)) {
380 /* if (fValue < -2.0) fValue = -2.0;
381 if (fValue > 2.0) fValue = 2.0; // clamping to -2.0...2.0 gives us ±M_PI actual maximum rotation
382 [entity setRoll:fValue]; */
383 // use setRawRoll to make the units here equal to those in kShip_roll
384 if (fValue < -M_PI)
385 fValue = -M_PI;
386 else if (fValue > M_PI)
387 fValue = M_PI;
388 [entity setRawRoll:fValue];
389 return YES;
390 }
391 break;
392
394 if (JS_ValueToBoolean(context, *value, &bValue)) {
395 [entity setAllowsFastDocking:bValue];
396 return YES;
397 }
398 break;
399
401 if (JS_ValueToBoolean(context, *value, &bValue)) {
402 [entity setAllowsAutoDocking:bValue];
403 return YES;
404 }
405 break;
406
408 if (JS_ValueToBoolean(context, *value, &bValue)) {
409 [entity setSuppressArrivalReports:bValue];
410 return YES;
411 }
412 break;
413
415 if (JS_ValueToBoolean(context, *value, &bValue)) {
416 [entity setHasBreakPattern:bValue];
417 return YES;
418 }
419 break;
420
421 default:
423 return NO;
424 }
425
426 OOJSReportBadPropertyValue(context, this, propID, sStationProperties, *value);
427 return NO;
428
430}
431
432// *** Methods ***
433
434static JSBool StationAbortAllDockings(JSContext* context, uintN argc, jsval* vp)
435{
436 OOJS_NATIVE_ENTER(context)
437
438 StationEntity* station = nil;
439 JSStationGetStationEntity(context, OOJS_THIS, &station);
440 [station abortAllDockings];
441
443
445}
446
447static JSBool StationAbortDockingForShip(JSContext* context, uintN argc, jsval* vp)
448{
449 OOJS_NATIVE_ENTER(context)
450
451 StationEntity* station = nil;
452 JSStationGetStationEntity(context, OOJS_THIS, &station);
453 if (argc == 0) {
454 OOJSReportBadArguments(context, @"Station", @"abortDockingForShip", MIN(argc, 1U), OOJS_ARGV, nil, @"ship in docking queue");
455 return NO;
456 }
457 if (!JSVAL_IS_OBJECT(OOJS_ARGV[0]))
458 return NO;
459 ShipEntity* ship = nil;
460 JSStationGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &ship);
461 if (ship != nil) {
462 [station abortDockingForShip:ship];
463 }
464
466
468}
469
470// canDockShip(shipEntity) : boolean
471// Proposed by phkb (Nick Rogers) 20161206
472static JSBool StationCanDockShip(JSContext* context, uintN argc, jsval* vp)
473{
474 OOJS_NATIVE_ENTER(context)
475
476 BOOL result = YES;
477 ShipEntity* shipToCheck = nil;
478
479 if (argc > 0) {
480 if (!JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !JSStationGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &shipToCheck)) {
481 return NO;
482 }
483 }
484 if (EXPECT_NOT(shipToCheck == nil)) {
485 OOJSReportBadArguments(context, @"Station", @"canDockShip", MIN(argc, 1U), OOJS_ARGV, nil, @"shipEntity");
486 return NO;
487 }
488
489 StationEntity* station = nil;
490 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
491 OOJS_RETURN_VOID; // stale reference, no-op
492
494 result = [station fitsInDock:shipToCheck andLogNoFit:NO];
496
497 OOJS_RETURN_BOOL(result);
499}
500
501// dockPlayer()
502// Proposed and written by Frame 20090729
503static JSBool StationDockPlayer(JSContext* context, uintN argc, jsval* vp)
504{
505 OOJS_NATIVE_ENTER(context)
506
508 GameController* gameController = [UNIVERSE gameController];
509
510 if (EXPECT_NOT([gameController isGamePaused])) {
511 /* Station.dockPlayer() was executed while the game was in pause.
512 Do we want to return an error or just unpause and continue?
513 I think unpausing is the sensible thing to do here - Nikos 20110208
514 */
515 [gameController setGamePaused:NO];
516 }
517
518 if (EXPECT(![player isDocked])) {
519 StationEntity* stationForDockingPlayer = nil;
520 JSStationGetStationEntity(context, OOJS_THIS, &stationForDockingPlayer);
521 [player setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_GRANTED];
522 [player safeAllMissiles];
523 [UNIVERSE setViewDirection:VIEW_FORWARD];
524 [player enterDock:stationForDockingPlayer];
525 }
527
529}
530
531static JSBool StationIncreaseAlertLevel(JSContext* context, uintN argc, jsval* vp)
532{
533 OOJS_NATIVE_ENTER(context)
534 StationEntity* station = nil;
535
536 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
537 OOJS_RETURN_VOID; // stale reference, no-op
538
540 if ([station alertCondition] < 3) {
541 [station increaseAlertLevel];
542 }
546}
547
548static JSBool StationDecreaseAlertLevel(JSContext* context, uintN argc, jsval* vp)
549{
550 OOJS_NATIVE_ENTER(context)
551 StationEntity* station = nil;
552
553 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
554 OOJS_RETURN_VOID; // stale reference, no-op
555
557 if ([station alertCondition] > 1) {
558 [station decreaseAlertLevel];
559 }
563}
564
565// launchShipWithRole(role : String [, abortAllDockings : boolean]) : shipEntity
566static JSBool StationLaunchShipWithRole(JSContext* context, uintN argc, jsval* vp)
567{
568 OOJS_NATIVE_ENTER(context)
569
570 NSString* shipRole = nil;
571 StationEntity* station = nil;
572 ShipEntity* result = nil;
573 JSBool abortAllDockings = NO;
574
575 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
576 OOJS_RETURN_VOID; // stale reference, no-op
577
578 if (argc > 0)
579 shipRole = OOStringFromJSValue(context, OOJS_ARGV[0]);
580 if (EXPECT_NOT(shipRole == nil)) {
581 OOJSReportBadArguments(context, @"Station", @"launchShipWithRole", MIN(argc, 1U), OOJS_ARGV, nil, @"string (role)");
582 return NO;
583 }
584
585 if (argc > 1)
586 JS_ValueToBoolean(context, OOJS_ARGV[1], &abortAllDockings);
587
589 result = [station launchIndependentShip:shipRole];
590 if (abortAllDockings)
591 [station abortAllDockings];
593
594 OOJS_RETURN_OBJECT(result);
596}
597
598static JSBool StationLaunchDefenseShip(JSContext* context, uintN argc, jsval* vp)
599{
600 OOJS_NATIVE_ENTER(context)
601
602 StationEntity* station = nil;
603 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
604 OOJS_RETURN_VOID; // stale reference, no-op
605
606 ShipEntity* launched = nil;
608 launched = [station launchDefenseShip];
610 OOJS_RETURN_OBJECT(launched);
611
613}
614
615static JSBool StationLaunchEscort(JSContext* context, uintN argc, jsval* vp)
616{
617 OOJS_NATIVE_ENTER(context)
618
619 StationEntity* station = nil;
620 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
621 OOJS_RETURN_VOID; // stale reference, no-op
622
623 ShipEntity* launched = nil;
625 launched = [station launchEscort];
627 OOJS_RETURN_OBJECT(launched);
628
630}
631
632static JSBool StationLaunchScavenger(JSContext* context, uintN argc, jsval* vp)
633{
634 OOJS_NATIVE_ENTER(context)
635
636 StationEntity* station = nil;
637 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
638 OOJS_RETURN_VOID; // stale reference, no-op
639
640 ShipEntity* launched = nil;
642 launched = [station launchScavenger];
644 OOJS_RETURN_OBJECT(launched);
645
647}
648
649static JSBool StationLaunchMiner(JSContext* context, uintN argc, jsval* vp)
650{
651 OOJS_NATIVE_ENTER(context)
652
653 StationEntity* station = nil;
654 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
655 OOJS_RETURN_VOID; // stale reference, no-op
656
657 ShipEntity* launched = nil;
659 launched = [station launchMiner];
661 OOJS_RETURN_OBJECT(launched);
663}
664
665static JSBool StationLaunchPirateShip(JSContext* context, uintN argc, jsval* vp)
666{
667 OOJS_NATIVE_ENTER(context)
668
669 StationEntity* station = nil;
670 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
671 OOJS_RETURN_VOID; // stale reference, no-op
672
673 ShipEntity* launched = nil;
675 launched = [station launchPirateShip];
677 OOJS_RETURN_OBJECT(launched);
678
680}
681
682static JSBool StationLaunchShuttle(JSContext* context, uintN argc, jsval* vp)
683{
684 OOJS_NATIVE_ENTER(context)
685
686 StationEntity* station = nil;
687 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
688 OOJS_RETURN_VOID; // stale reference, no-op
689
690 ShipEntity* launched = nil;
692 launched = [station launchShuttle];
694 OOJS_RETURN_OBJECT(launched);
696}
697
698static JSBool StationLaunchPatrol(JSContext* context, uintN argc, jsval* vp)
699{
700 OOJS_NATIVE_ENTER(context)
701
702 StationEntity* station = nil;
703 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
704 OOJS_RETURN_VOID; // stale reference, no-op
705
706 ShipEntity* launched = nil;
708 launched = [station launchPatrol];
710 OOJS_RETURN_OBJECT(launched);
712}
713
714static JSBool StationLaunchPolice(JSContext* context, uintN argc, jsval* vp)
715{
716 OOJS_NATIVE_ENTER(context)
717
718 StationEntity* station = nil;
719 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
720 OOJS_RETURN_VOID; // stale reference, no-op
721
722 NSArray* launched = nil;
724 launched = [station launchPolice];
726 OOJS_RETURN_OBJECT(launched);
728}
729
730static JSBool StationSetInterface(JSContext* context, uintN argc, jsval* vp)
731{
732 OOJS_NATIVE_ENTER(context)
733
734 StationEntity* station = nil;
735 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
736 OOJS_RETURN_VOID; // stale reference, no-op
737
738 if (argc < 1) {
739 OOJSReportBadArguments(context, @"Station", @"setInterface", MIN(argc, 1U), OOJS_ARGV, NULL, @"key [, definition]");
740 return NO;
741 }
742 NSString* key = OOStringFromJSValue(context, OOJS_ARGV[0]);
743
744 if (argc < 2 || JSVAL_IS_NULL(OOJS_ARGV[1])) {
745 [station setInterfaceDefinition:nil forKey:key];
747 }
748
749 jsval value = JSVAL_NULL;
750 jsval callback = JSVAL_NULL;
751 JSObject* callbackThis = NULL;
752 JSObject* params = NULL;
753
754 NSString* title = nil;
755 NSString* summary = nil;
756 NSString* category = nil;
757
758 if (!JS_ValueToObject(context, OOJS_ARGV[1], &params)) {
759 OOJSReportBadArguments(context, @"Station", @"setInterface", MIN(argc, 1U), OOJS_ARGV, NULL, @"key [, definition]");
760 return NO;
761 }
762
763 // get and validate title
764 if (JS_GetProperty(context, params, "title", &value) == JS_FALSE || JSVAL_IS_VOID(value)) {
765 OOJSReportBadArguments(context, @"Station", @"setInterface", MIN(argc, 1U), OOJS_ARGV, NULL, @"key [, definition]; if definition is set, it must have a 'title' property.");
766 return NO;
767 }
768 title = OOStringFromJSValue(context, value);
769 if (title == nil || [title length] == 0) {
770 OOJSReportBadArguments(context, @"Station", @"setInterface", MIN(argc, 1U), OOJS_ARGV, NULL, @"key [, definition]; if definition is set, 'title' property must be a non-empty string.");
771 return NO;
772 }
773
774 // get category with default
775 if (JS_GetProperty(context, params, "category", &value) == JS_FALSE || JSVAL_IS_VOID(value)) {
776 category = [NSString stringWithString:DESC(@"interfaces-category-uncategorised")];
777 } else {
778 category = OOStringFromJSValue(context, value);
779 if (category == nil || [category length] == 0) {
780 category = [NSString stringWithString:DESC(@"interfaces-category-uncategorised")];
781 }
782 }
783
784 // get and validate summary
785 if (JS_GetProperty(context, params, "summary", &value) == JS_FALSE || JSVAL_IS_VOID(value)) {
786 OOJSReportBadArguments(context, @"Station", @"setInterface", MIN(argc, 1U), OOJS_ARGV, NULL, @"key [, definition]; if definition is set, it must have a 'summary' property.");
787 return NO;
788 }
789 summary = OOStringFromJSValue(context, value);
790 if (summary == nil || [summary length] == 0) {
791 OOJSReportBadArguments(context, @"Station", @"setInterface", MIN(argc, 1U), OOJS_ARGV, NULL, @"key [, definition]; if definition is set, 'summary' property must be a non-empty string.");
792 return NO;
793 }
794
795 // get and validate callback
796 if (JS_GetProperty(context, params, "callback", &callback) == JS_FALSE || JSVAL_IS_VOID(callback)) {
797 OOJSReportBadArguments(context, @"Station", @"setInterface", MIN(argc, 1U), OOJS_ARGV, NULL, @"key [, definition]; if definition is set, it must have a 'callback' property.");
798 return NO;
799 }
800 if (!OOJSValueIsFunction(context, callback)) {
801 OOJSReportBadArguments(context, @"Station", @"setInterface", MIN(argc, 1U), OOJS_ARGV, NULL, @"key [, definition]; 'callback' property must be a function.");
802 return NO;
803 }
804
805 OOJSInterfaceDefinition* definition = [[OOJSInterfaceDefinition alloc] init];
806 [definition setTitle:title];
807 [definition setCategory:category];
808 [definition setSummary:summary];
809 [definition setCallback:callback];
810
811 // get callback 'this'
812 if (JS_GetProperty(context, params, "cbThis", &value) == JS_TRUE && !JSVAL_IS_VOID(value)) {
813 JS_ValueToObject(context, value, &callbackThis);
814 [definition setCallbackThis:callbackThis];
815 // can do .bind(this) for callback instead
816 }
817
818 [station setInterfaceDefinition:definition forKey:key];
819
820 [definition release];
821
823
825}
826
827static JSBool StationSetMarketPrice(JSContext* context, uintN argc, jsval* vp)
828{
829 OOJS_NATIVE_ENTER(context)
830
831 StationEntity* station = nil;
832 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
833 OOJS_RETURN_VOID; // stale reference, no-op
834
835 if (argc < 2) {
836 OOJSReportBadArguments(context, @"Station", @"setMarketPrice", MIN(argc, 2U), OOJS_ARGV, NULL, @"commodity, credits");
837 return NO;
838 }
839
840 OOCommodityType commodity = OOStringFromJSValue(context, OOJS_ARGV[0]);
841 if (EXPECT_NOT(![[UNIVERSE commodities] goodDefined:commodity])) {
842 OOJSReportBadArguments(context, @"Station", @"setMarketPrice", MIN(argc, 2U), OOJS_ARGV, NULL, @"Unrecognised commodity type");
843 return NO;
844 }
845
846 int32 price;
847 BOOL gotPrice = JS_ValueToInt32(context, OOJS_ARGV[1], &price);
848 if (EXPECT_NOT(!gotPrice || price < 0)) {
849 OOJSReportBadArguments(context, @"Station", @"setMarketPrice", MIN(argc, 2U), OOJS_ARGV, NULL, @"Price must be at least 0 decicredits");
850 return NO;
851 }
852
853 [station setPrice:(NSUInteger)price forCommodity:commodity];
854
855 if (station == [PLAYER dockedStation] && [PLAYER guiScreen] == GUI_SCREEN_MARKET) {
856 [PLAYER setGuiToMarketScreen]; // refresh screen
857 }
858
859 OOJS_RETURN_BOOL(YES);
860
862}
863
864static JSBool StationSetMarketQuantity(JSContext* context, uintN argc, jsval* vp)
865{
866 OOJS_NATIVE_ENTER(context)
867
868 StationEntity* station = nil;
869 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
870 OOJS_RETURN_VOID; // stale reference, no-op
871
872 if (argc < 2) {
873 OOJSReportBadArguments(context, @"Station", @"setMarketQuantity", MIN(argc, 2U), OOJS_ARGV, NULL, @"commodity, units");
874 return NO;
875 }
876
877 OOCommodityType commodity = OOStringFromJSValue(context, OOJS_ARGV[0]);
878 if (EXPECT_NOT(![[UNIVERSE commodities] goodDefined:commodity])) {
879 OOJSReportBadArguments(context, @"Station", @"setMarketQuantity", MIN(argc, 2U), OOJS_ARGV, NULL, @"Unrecognised commodity type");
880 return NO;
881 }
882
883 int32 quantity;
884 BOOL gotQuantity = JS_ValueToInt32(context, OOJS_ARGV[1], &quantity);
885 if (EXPECT_NOT(!gotQuantity || quantity < 0 || (OOCargoQuantity)quantity > [[station localMarket] capacityForGood:commodity])) {
886 OOJSReportBadArguments(context, @"Station", @"setMarketQuantity", MIN(argc, 2U), OOJS_ARGV, NULL, @"Quantity must be between 0 and the station market capacity");
887 return NO;
888 }
889
890 [station setQuantity:(OOCargoQuantity)quantity forCommodity:commodity];
891
892 if (station == [PLAYER dockedStation] && [PLAYER guiScreen] == GUI_SCREEN_MARKET) {
893 [PLAYER setGuiToMarketScreen]; // refresh screen
894 }
895
896 OOJS_RETURN_BOOL(YES);
897
899}
900
901static JSBool StationAddShipToShipyard(JSContext* context, uintN argc, jsval* vp)
902{
903 OOJS_NATIVE_ENTER(context)
904
905 JSObject* params = NULL;
906 StationEntity* station = nil;
907 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
908 OOJS_RETURN_VOID; // stale reference, no-op
909
910 if (argc != 1 || (!JSVAL_IS_NULL(OOJS_ARGV[0]) && !JS_ValueToObject(context, OOJS_ARGV[0], &params))) {
911 OOJSReportBadArguments(context, @"Station", @"addShipToShipyard", MIN(argc, 1U), OOJS_ARGV, NULL, @"shipyard item definition");
912 return NO;
913 }
914
915 // make sure the station has a shipyard
916 if (![station hasShipyard]) {
917 OOJSReportWarningForCaller(context, @"Station", @"removeShipFromShipyard", @"Station does not have shipyard.");
918 return NO;
919 }
920 // make sure the shipyard has been generated
921 if (![station localShipyard])
922 [station generateShipyard];
923 NSMutableArray* shipyard = [station localShipyard];
924
925 if (JSVAL_IS_NULL(OOJS_ARGV[0]))
926 OOJS_RETURN_VOID; // OK, do nothing for null ship.
927
928 NSMutableDictionary* result = [NSMutableDictionary dictionary];
929 NSDictionary* shipyardDefinition = OOJSNativeObjectFromJSObject(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]));
930 // validate each element of the dictionary
931 if (!shipyardDefinition) {
932 OOJSReportBadArguments(context, @"Station", @"addShipToShipyard", MIN(argc, 1U), OOJS_ARGV, nil, @"valid dictionary object");
933 return NO;
934 }
935 if (![shipyardDefinition objectForKey:KEY_SHORT_DESCRIPTION]) {
936 OOJSReportBadArguments(context, @"Station", @"addShipToShipyard", MIN(argc, 1U), OOJS_ARGV, nil, @"'short_description' in dictionary");
937 return NO;
938 }
939 [result setObject:[shipyardDefinition oo_stringForKey:@"short_description"] forKey:KEY_SHORT_DESCRIPTION];
940 if (![shipyardDefinition objectForKey:SHIPYARD_KEY_SHIPDATA_KEY]) {
941 OOJSReportBadArguments(context, @"Station", @"addShipToShipyard", MIN(argc, 1U), OOJS_ARGV, nil, @"'shipdata_key' in dictionary");
942 return NO;
943 }
944 // get the shipInfo and shipyardInfo for this key
945 NSString* shipKey = [shipyardDefinition oo_stringForKey:SHIPYARD_KEY_SHIPDATA_KEY defaultValue:nil];
947 NSMutableDictionary* shipInfo = [NSMutableDictionary dictionaryWithDictionary:[registry shipInfoForKey:shipKey]];
948 NSDictionary* shipyardInfo = [registry shipyardInfoForKey:shipKey];
949 if (!shipInfo) {
950 OOJSReportWarningForCaller(context, @"Station", @"addShipToShipyard", @"Invalid shipdata_key provided.");
951 return NO;
952 }
953 // make sure the ship is a player ship
954 if ([[shipInfo oo_stringForKey:@"roles"] rangeOfString:@"player"].location == NSNotFound) {
955 OOJSReportWarningForCaller(context, @"Station", @"addShipToShipyard", @"shipdata_key not suitable for player role.");
956 return NO;
957 }
958 if (!shipyardInfo) {
959 OOJSReportWarningForCaller(context, @"Station", @"addShipToShipyard", @"No shipyard information found for shipdata_key.");
960 return NO;
961 }
962 // ok, feel pretty safe to include this ship now
963 [result setObject:shipKey forKey:SHIPYARD_KEY_SHIPDATA_KEY];
964
965 // add an ID
966 Random_Seed ship_seed = [UNIVERSE marketSeed];
967 int superRand1 = ship_seed.a * 0x10000 + ship_seed.c * 0x100 + ship_seed.e;
968 uint32_t superRand2 = ship_seed.b * 0x10000 + ship_seed.d * 0x100 + ship_seed.f;
969 superRand2 &= Ranrot();
970 NSString* shipID = [NSString stringWithFormat:@"%06x-%06x", superRand1, superRand2];
971 [result setObject:shipID forKey:SHIPYARD_KEY_ID];
972
973 if (![shipyardDefinition objectForKey:SHIPYARD_KEY_PRICE]) {
974 // if not provided, get the price from the registry
975 OOCreditsQuantity price = [shipyardInfo oo_unsignedIntForKey:KEY_PRICE];
976 [result setObject:[NSNumber numberWithUnsignedLongLong:price] forKey:SHIPYARD_KEY_PRICE];
977 } else {
978 OOCreditsQuantity price = [shipyardDefinition oo_unsignedIntForKey:SHIPYARD_KEY_PRICE];
979 if (price > 0) {
980 [result setObject:[NSNumber numberWithUnsignedLongLong:price] forKey:SHIPYARD_KEY_PRICE];
981 } else {
982 OOJSReportBadArguments(context, @"Station", @"addShipToShipyard", MIN(argc, 1U), OOJS_ARGV, nil, @"'price' in dictionary");
983 return NO;
984 }
985 }
986
987 if (![shipyardDefinition objectForKey:SHIPYARD_KEY_PERSONALITY]) {
988 // default to 0 if not supplied
989 [result setObject:[NSNumber numberWithUnsignedInt:0] forKey:SHIPYARD_KEY_PERSONALITY];
990 } else {
991 [result setObject:[NSNumber numberWithUnsignedLongLong:[shipyardDefinition oo_unsignedIntForKey:SHIPYARD_KEY_PERSONALITY]] forKey:SHIPYARD_KEY_PERSONALITY];
992 }
993
994 NSArray* extras = [shipyardDefinition oo_arrayForKey:KEY_EQUIPMENT_EXTRAS];
995 if (!extras) {
996 // pick up defaults if extras not supplied
997 extras = [NSArray arrayWithArray:[[shipyardInfo oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_arrayForKey:KEY_EQUIPMENT_EXTRAS]];
998 }
999 if ([extras count] > 0) {
1000 // go looking for lasers and add them directly to our shipInfo
1001 NSString* fwdWeaponString = [[shipyardInfo oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_stringForKey:KEY_EQUIPMENT_FORWARD_WEAPON];
1002 NSString* aftWeaponString = [[shipyardInfo oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_stringForKey:KEY_EQUIPMENT_AFT_WEAPON];
1003 OOWeaponFacingSet availableFacings = [shipyardInfo oo_unsignedIntForKey:KEY_WEAPON_FACINGS defaultValue:VALID_WEAPON_FACINGS] & VALID_WEAPON_FACINGS;
1004
1005 OOWeaponType fwdWeapon = OOWeaponTypeFromEquipmentIdentifierSloppy(fwdWeaponString);
1006 OOWeaponType aftWeapon = OOWeaponTypeFromEquipmentIdentifierSloppy(aftWeaponString);
1007
1008 unsigned int i;
1009 NSString* equipmentKey = nil;
1010 for (i = 0; i < [extras count]; i++) {
1011 equipmentKey = [extras oo_stringAtIndex:i];
1012 if ([equipmentKey hasPrefix:@"EQ_WEAPON"]) {
1014 // fit best weapon forward
1015 if (availableFacings & WEAPON_FACING_FORWARD && [new_weapon weaponThreatAssessment] > [fwdWeapon weaponThreatAssessment]) {
1016 // again remember to divide price by 10 to get credits from tenths of credit
1017 fwdWeaponString = equipmentKey;
1018 fwdWeapon = new_weapon;
1019 [shipInfo setObject:fwdWeaponString forKey:KEY_EQUIPMENT_FORWARD_WEAPON];
1020 } else {
1021 // if less good than current forward, try fitting is to rear
1022 if (availableFacings & WEAPON_FACING_AFT && (isWeaponNone(aftWeapon) || [new_weapon weaponThreatAssessment] > [aftWeapon weaponThreatAssessment])) {
1023 aftWeaponString = equipmentKey;
1024 aftWeapon = new_weapon;
1025 [shipInfo setObject:aftWeaponString forKey:KEY_EQUIPMENT_AFT_WEAPON];
1026 }
1027 }
1028 }
1029 }
1030 }
1031 // add the extras
1032 [result setObject:extras forKey:KEY_EQUIPMENT_EXTRAS];
1033 // add the ship spec
1034 [result setObject:shipInfo forKey:SHIPYARD_KEY_SHIP];
1035 // add it to the station's shipyard
1036 [shipyard addObject:result];
1037
1038 // refresh the screen if the shipyard is currently being displayed
1039 if (station == [PLAYER dockedStation] && [PLAYER guiScreen] == GUI_SCREEN_SHIPYARD) {
1040 [PLAYER setGuiToShipyardScreen:0];
1041 }
1042
1043 OOJS_RETURN_BOOL(YES);
1044
1046}
1047
1048static JSBool StationRemoveShipFromShipyard(JSContext* context, uintN argc, jsval* vp)
1049{
1050 OOJS_NATIVE_ENTER(context)
1051
1052 StationEntity* station = nil;
1053 if (!JSStationGetStationEntity(context, OOJS_THIS, &station))
1054 OOJS_RETURN_VOID; // stale reference, no-op
1055
1056 // make sure the station has a shipyard
1057 if (![station hasShipyard]) {
1058 OOJSReportWarningForCaller(context, @"Station", @"removeShipFromShipyard", @"Station does not have shipyard.");
1059 return NO;
1060 }
1061 // make sure the shipyard has been generated
1062 if (![station localShipyard])
1063 [station generateShipyard];
1064 NSMutableArray* shipyard = [station localShipyard];
1065
1066 int32 shipIndex = -1;
1067 BOOL gotIndex = YES;
1068 gotIndex = JS_ValueToInt32(context, OOJS_ARGV[0], &shipIndex);
1069
1070 if (argc != 1 || (!JSVAL_IS_NULL(OOJS_ARGV[0]) && !gotIndex) || shipIndex < 0 || (shipIndex + 1) > [shipyard count]) {
1071 OOJSReportBadArguments(context, @"Station", @"removeShipFromShipyard", MIN(argc, 1U), OOJS_ARGV, NULL, @"valid ship index");
1072 return NO;
1073 }
1074
1075 [shipyard removeObjectAtIndex:shipIndex];
1076
1077 // refresh the screen if the shipyard is currently being displayed
1078 if (station == [PLAYER dockedStation] && [PLAYER guiScreen] == GUI_SCREEN_SHIPYARD) {
1079 [PLAYER setGuiToShipyardScreen:0];
1080 }
1081
1082 OOJS_RETURN_BOOL(YES);
1083
1085}
#define EXPECT_NOT(x)
#define EXPECT(x)
#define OOJS_PROFILE_EXIT
#define OOJS_END_FULL_NATIVE
#define OOJS_BEGIN_FULL_NATIVE(context)
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
#define OOJS_PROFILE_ENTER
PlayerEntity * OOPlayerForScripting(void)
Definition OOJSPlayer.m:175
JSObject * JSShipPrototype(void)
Definition OOJSShip.m:587
JSClass * JSShipClass(void)
Definition OOJSShip.m:582
static JSBool StationIncreaseAlertLevel(JSContext *context, uintN argc, jsval *vp)
static JSBool StationLaunchPolice(JSContext *context, uintN argc, jsval *vp)
static JSBool StationSetMarketQuantity(JSContext *context, uintN argc, jsval *vp)
static JSBool StationDecreaseAlertLevel(JSContext *context, uintN argc, jsval *vp)
static JSClass sStationClass
Definition OOJSStation.m:66
static JSBool StationLaunchShuttle(JSContext *context, uintN argc, jsval *vp)
static JSBool StationLaunchMiner(JSContext *context, uintN argc, jsval *vp)
static JSBool StationLaunchShipWithRole(JSContext *context, uintN argc, jsval *vp)
static JSBool StationRemoveShipFromShipyard(JSContext *context, uintN argc, jsval *vp)
static BOOL JSStationGetStationEntity(JSContext *context, JSObject *stationObj, StationEntity **outEntity)
static JSBool StationLaunchDefenseShip(JSContext *context, uintN argc, jsval *vp)
static BOOL JSStationGetShipEntity(JSContext *context, JSObject *shipObj, ShipEntity **outEntity)
static JSBool StationSetInterface(JSContext *context, uintN argc, jsval *vp)
static JSBool StationGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
void InitOOJSStation(JSContext *context, JSObject *global)
static JSBool StationSetMarketPrice(JSContext *context, uintN argc, jsval *vp)
static JSBool StationAbortDockingForShip(JSContext *context, uintN argc, jsval *vp)
static JSBool StationLaunchPirateShip(JSContext *context, uintN argc, jsval *vp)
static JSBool StationAddShipToShipyard(JSContext *context, uintN argc, jsval *vp)
static JSBool StationCanDockShip(JSContext *context, uintN argc, jsval *vp)
static JSBool StationDockPlayer(JSContext *context, uintN argc, jsval *vp)
static JSObject * sStationPrototype
Definition OOJSStation.m:38
@ kStation_isMainStation
Definition OOJSStation.m:95
@ kStation_equivalentTechLevel
Definition OOJSStation.m:92
@ kStation_hasShipyard
Definition OOJSStation.m:94
@ kStation_dockedPolice
Definition OOJSStation.m:90
@ kStation_hasNPCTraffic
Definition OOJSStation.m:93
@ kStation_allowsAutoDocking
Definition OOJSStation.m:85
@ kStation_allegiance
Definition OOJSStation.m:84
@ kStation_equipmentPriceFactor
Definition OOJSStation.m:91
@ kStation_shipyard
@ kStation_alertCondition
Definition OOJSStation.m:83
@ kStation_market
Definition OOJSStation.m:96
@ kStation_allowsFastDocking
Definition OOJSStation.m:86
@ kStation_dockedDefenders
Definition OOJSStation.m:89
@ kStation_roll
Definition OOJSStation.m:98
@ kStation_breakPattern
Definition OOJSStation.m:87
@ kStation_requiresDockingClearance
Definition OOJSStation.m:97
@ kStation_dockedContractors
Definition OOJSStation.m:88
@ kStation_suppressArrivalReports
Definition OOJSStation.m:99
static JSPropertySpec sStationProperties[]
static JSFunctionSpec sStationMethods[]
static JSBool StationLaunchScavenger(JSContext *context, uintN argc, jsval *vp)
static JSBool StationLaunchEscort(JSContext *context, uintN argc, jsval *vp)
static JSBool StationSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
static JSBool StationAbortAllDockings(JSContext *context, uintN argc, jsval *vp)
static JSBool StationLaunchPatrol(JSContext *context, uintN argc, jsval *vp)
#define OOJS_THIS
#define OOJS_PROP_READWRITE_CB
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
id OOJSNativeObjectFromJSObject(JSContext *context, JSObject *object)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)
#define OOJS_RETURN_OBJECT(o)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
void OOJSReportWarningForCaller(JSContext *context, NSString *scriptClass, NSString *function, NSString *format,...)
#define OOJS_RETURN_BOOL(v)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
OOINLINE BOOL OOJSValueIsFunction(JSContext *context, jsval value)
void OOJSRegisterSubclass(JSClass *subclass, JSClass *superclass)
#define OOJS_ARGV
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
#define OOJS_PROP_READONLY_CB
#define OOJS_RETURN_VOID
#define MIN(A, B)
Definition OOMaths.h:91
#define M_PI
Definition OOMaths.h:54
unsigned count
return nil
uint8_t OOWeaponFacingSet
Definition OOTypes.h:204
NSString * OOCommodityType
Definition OOTypes.h:97
uint64_t OOCreditsQuantity
Definition OOTypes.h:160
#define VALID_WEAPON_FACINGS
Definition OOTypes.h:206
uint32_t OOCargoQuantity
Definition OOTypes.h:155
@ WEAPON_FACING_FORWARD
Definition OOTypes.h:196
@ WEAPON_FACING_AFT
Definition OOTypes.h:197
#define PLAYER
OOEquipmentType * OOWeaponType
Definition ShipEntity.h:164
BOOL isWeaponNone(OOWeaponType weapon)
OOWeaponType OOWeaponTypeFromEquipmentIdentifierSloppy(NSString *string) PURE_FUNC
#define KEY_SHORT_DESCRIPTION
Definition Universe.h:120
#define UNIVERSE
Definition Universe.h:827
#define SHIPYARD_KEY_PRICE
Definition Universe.h:140
#define SHIPYARD_KEY_PERSONALITY
Definition Universe.h:141
#define SHIPYARD_KEY_SHIPDATA_KEY
Definition Universe.h:138
void setGamePaused:(BOOL value)
void setSummary:(NSString *summary)
void setCategory:(NSString *category)
void setCallbackThis:(JSObject *callbackthis)
NSDictionary * shipyardInfoForKey:(NSString *key)
OOShipRegistry * sharedRegistry()
NSDictionary * shipInfoForKey:(NSString *key)
void setDockingClearanceStatus:(OODockingClearanceStatus newValue)
void enterDock:(StationEntity *station)
void setRawRoll:(double amount)
void setQuantity:forCommodity:(OOCargoQuantity quantity,[forCommodity] OOCommodityType commodity)
NSArray * launchPolice()
ShipEntity * launchMiner()
ShipEntity * launchScavenger()
void setHasNPCTraffic:(BOOL flag)
void setAllowsFastDocking:(BOOL newValue)
ShipEntity * launchIndependentShip:(NSString *role)
ShipEntity * launchDefenseShip()
ShipEntity * launchPirateShip()
void setAlertLevel:signallingScript:(OOStationAlertLevel level,[signallingScript] BOOL signallingScript)
ShipEntity * launchShuttle()
NSMutableArray * localShipyard
ShipEntity * launchPatrol()
void setSuppressArrivalReports:(BOOL newValue)
void setRequiresDockingClearance:(BOOL newValue)
void setAllowsAutoDocking:(BOOL newValue)
NSDictionary * localMarketForScripting()
void setInterfaceDefinition:forKey:(OOJSInterfaceDefinition *definition,[forKey] NSString *key)
NSString * allegiance
void setHasBreakPattern:(BOOL newValue)
BOOL fitsInDock:andLogNoFit:(ShipEntity *ship,[andLogNoFit] BOOL logNoFit)
ShipEntity * launchEscort()
void setPrice:forCommodity:(OOCreditsQuantity price,[forCommodity] OOCommodityType commodity)
void setAllegiance:(NSString *newAllegiance)
void abortDockingForShip:(ShipEntity *ship)
unsigned Ranrot(void)