Oolite
Loading...
Searching...
No Matches
Universe.h
Go to the documentation of this file.
1/*
2
3Universe.h
4
5Manages a lot of stuff that isn't managed somewhere else.
6
7Oolite
8Copyright (C) 2004-2013 Giles C Williams and contributors
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23MA 02110-1301, USA.
24
25*/
26
27#import "OOCocoa.h"
28#import "OOOpenGL.h"
29#import "OOShaderProgram.h"
30#import "legacy_random.h"
31#import "OOMaths.h"
32#import "OOColor.h"
33#import "OOWeakReference.h"
34#import "OOTypes.h"
35#import "OOSound.h"
36#import "OOJSPropID.h"
37#import "OOStellarBody.h"
39#import "OOCommodities.h"
41
42#if OOLITE_ESPEAK
43#include <espeak-ng/speak_lib.h>
44#endif
45
50
51
52typedef BOOL (*EntityFilterPredicate)(Entity *entity, void *parameter);
53
54#ifndef OO_SCANCLASS_TYPE
55#define OO_SCANCLASS_TYPE
57#endif
58
59
60#define CROSSHAIR_SIZE 32.0
61
62enum
63{
73 MARKET_UNITS = 9
74};
75
76
77enum
78{
85};
86
87
88enum
89{
99 OO_POSTFX_ENDOFLIST // keep this for last
101
102
103#define SHADERS_MIN SHADERS_OFF
104
105
106#define MAX_MESSAGES 5
107
108#define PROXIMITY_WARN_DISTANCE 4 // Eric 2010-10-17: old value was 20.0
109#define PROXIMITY_WARN_DISTANCE2 (PROXIMITY_WARN_DISTANCE * PROXIMITY_WARN_DISTANCE)
110#define PROXIMITY_AVOID_DISTANCE_FACTOR 10.0
111#define SAFE_ADDITION_FACTOR2 800 // Eric 2010-10-17: used to be "2 * PROXIMITY_WARN_DISTANCE2"
112
113#define SUN_SKIM_RADIUS_FACTOR 1.15470053838 // 2 sqrt(3) / 3. Why? I have no idea. -- Ahruman 2009-10-04
114#define SUN_SPARKS_RADIUS_FACTOR 2.0
115
116#define KEY_TECHLEVEL @"techlevel"
117#define KEY_ECONOMY @"economy"
118#define KEY_ECONOMY_DESC @"economy_description"
119#define KEY_GOVERNMENT @"government"
120#define KEY_GOVERNMENT_DESC @"government_description"
121#define KEY_POPULATION @"population"
122#define KEY_POPULATION_DESC @"population_description"
123#define KEY_PRODUCTIVITY @"productivity"
124#define KEY_RADIUS @"radius"
125#define KEY_NAME @"name"
126#define KEY_INHABITANT @"inhabitant"
127#define KEY_INHABITANTS @"inhabitants"
128#define KEY_DESCRIPTION @"description"
129#define KEY_SHORT_DESCRIPTION @"short_description"
130#define KEY_PLANETNAME @"planet_name"
131#define KEY_SUNNAME @"sun_name"
132
133#define KEY_CHANCE @"chance"
134#define KEY_PRICE @"price"
135#define KEY_OPTIONAL_EQUIPMENT @"optional_equipment"
136#define KEY_STANDARD_EQUIPMENT @"standard_equipment"
137#define KEY_EQUIPMENT_MISSILES @"missiles"
138#define KEY_EQUIPMENT_FORWARD_WEAPON @"forward_weapon_type"
139#define KEY_EQUIPMENT_AFT_WEAPON @"aft_weapon_type"
140#define KEY_EQUIPMENT_PORT_WEAPON @"port_weapon_type"
141#define KEY_EQUIPMENT_STARBOARD_WEAPON @"starboard_weapon_type"
142#define KEY_EQUIPMENT_EXTRAS @"extras"
143#define KEY_WEAPON_FACINGS @"weapon_facings"
144#define KEY_RENOVATION_MULTIPLIER @"renovation_multiplier"
145
146#define SHIPYARD_KEY_ID @"id"
147#define SHIPYARD_KEY_SHIPDATA_KEY @"shipdata_key"
148#define SHIPYARD_KEY_SHIP @"ship"
149#define SHIPYARD_KEY_PRICE @"price"
150#define SHIPYARD_KEY_PERSONALITY @"personality"
151// default passenger berth required space
152#define PASSENGER_BERTH_SPACE 5
153
154#define PLANETINFO_UNIVERSAL_KEY @"universal"
155#define PLANETINFO_INTERSTELLAR_KEY @"interstellar space"
156
157#define OOLITE_EXCEPTION_LOOPING @"OoliteLoopingException"
158#define OOLITE_EXCEPTION_DATA_NOT_FOUND @"OoliteDataNotFoundException"
159#define OOLITE_EXCEPTION_FATAL @"OoliteFatalException"
160
161// the distance the sky backdrop is from the camera
162// though it appears at infinity
163#define BILLBOARD_DEPTH 75000.0
164
165#define TIME_ACCELERATION_FACTOR_MIN 0.0625f
166#define TIME_ACCELERATION_FACTOR_DEFAULT 1.0f
167#define TIME_ACCELERATION_FACTOR_MAX 16.0f
168
169#define DEMO_LIGHT_POSITION 5000.0f, 25000.0f, -10000.0f
170
171#define MIN_DISTANCE_TO_BUOY 750.0f // don't add ships within this distance
172#define MIN_DISTANCE_TO_BUOY2 (MIN_DISTANCE_TO_BUOY * MIN_DISTANCE_TO_BUOY)
173
174// if this is changed, also change oolite-populator.js
175// once this number has been in a stable release, cannot easily be changed
176#define SYSTEM_REPOPULATION_INTERVAL 20.0f;
177
178#ifndef OO_LOCALIZATION_TOOLS
179#define OO_LOCALIZATION_TOOLS 1
180#endif
181
182#ifndef MASS_DEPENDENT_FUEL_PRICES
183#define MASS_DEPENDENT_FUEL_PRICES 1
184#endif
185
186
188{
189@public
190 // use a sorted list for drawing and other activities
191 Entity *sortedEntities[UNIVERSE_MAX_ENTITIES + 1]; // One extra for padding; see -doRemoveEntity:.
192 unsigned n_entities;
193
195
196 // collision optimisation sorted lists
198
199 GLfloat stars_ambient[4];
200
201@private
202 NSUInteger _sessionID;
203
204 // colors
205 GLfloat sun_diffuse[4];
206 GLfloat sun_specular[4];
207
209
210 OOMatrix viewMatrix;
211
213
215
217 Entity *entity_for_uid[MAX_ENTITY_UID];
218
219 NSMutableArray *entities;
220
223 NSMutableDictionary *waypoints;
224
225 GLfloat skyClearColor[4];
226
227 NSString *currentMessage;
229 OOTimeAbsolute countdown_messageRepeatTime; // Getafix(4/Aug/2010) - Quickfix countdown messages colliding with weapon overheat messages.
230 // For proper handling of message dispatching, code refactoring is needed.
234
237
242// Above entry replaces these two
243// BOOL reducedDetail;
244// OOShaderSetting shaderEffectsLevel;
245
247
250
255 NSUInteger demo_ship_index;
257 NSArray *demo_ships;
258
260
262
265
266
267 NSDictionary *_descriptions; // holds descriptive text for lots of stuff, loaded at initialisation
268 NSDictionary *customSounds; // holds descriptive audio for lots of stuff, loaded at initialisation
269 NSDictionary *characters; // holds descriptons of characters
270 NSArray *_scenarios; // game start scenarios
271 NSDictionary *globalSettings; // miscellaneous global game settings
272 OOSystemDescriptionManager *systemManager; // planetinfo data manager
273 NSDictionary *missiontext; // holds descriptive text for missions, loaded at initialisation
274 NSArray *equipmentData; // holds data on available equipment, loaded at initialisation
276// NSSet *pirateVictimRoles; // Roles listed in pirateVictimRoles.plist.
277 NSDictionary *roleCategories; // Categories for roles from role-categories.plist, extending the old pirate-victim-roles.plist
278 NSDictionary *autoAIMap; // Default AIs for roles from autoAImap.plist.
279 NSDictionary *screenBackgrounds; // holds filenames for various screens backgrounds, loaded at initialisation
280 NSDictionary *explosionSettings; // explosion settings from explosions.plist
281
282 NSDictionary *cargoPods; // template cargo pods
283
287
288 NSString *system_names[256]; // hold pregenerated universe info
289 BOOL system_found[256]; // holds matches for input strings
290
292
294
298 NSMutableArray *allPlanets;
299 NSMutableSet *allStations;
300
302
303 NSMutableDictionary *populatorSettings;
307
308 NSArray *closeSystems;
309
310 NSString *useAddOns;
311
313
314#ifndef NDEBUG
316#endif
317
319
320 NSMutableArray *activeWormholes;
321
322 NSMutableArray *characterPool;
323
325
326 // check and maintain linked lists occasionally
328
331 NSUInteger drawCounter;
332
333#if OOLITE_SPEECH_SYNTH
334#if OOLITE_MAC_OS_X
335 NSSpeechSynthesizer *speechSynthesizer;
336#elif OOLITE_ESPEAK
337 const espeak_VOICE **espeak_voices;
338 unsigned int espeak_voice_count;
339#endif
340 NSArray *speechArray;
341#endif
342
343#if NEW_PLANETS
344 NSMutableArray *_preloadingPlanetMaterials;
345#endif
347
348 GLfloat frustum[6][4];
349
350 NSMutableDictionary *conditionScripts;
351
360
370 OOShaderProgram *textureProgram;
371 OOShaderProgram *blurProgram;
372 OOShaderProgram *finalProgram;
375 GLuint pingpongFBO[2];
377 BOOL _bloom;
380}
381
382- (BOOL) bloom;
383- (void) setBloom: (BOOL)newBloom;
384
385- (int) currentPostFX;
386- (void) setCurrentPostFX: (int) newCurrentPostFX;
387- (void) terminatePostFX:(int) postFX;
388
389- (id)initWithGameView:(MyOpenGLView *)gameView;
390
391// SessionID: a value that's incremented when the game is reset.
392- (NSUInteger) sessionID;
393
394- (BOOL) doProcedurallyTexturedPlanets;
395- (void) setDoProcedurallyTexturedPlanets:(BOOL) value;
396
397- (NSString *) useAddOns;
398- (BOOL) setUseAddOns:(NSString *)newUse fromSaveGame: (BOOL)saveGame;
399- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame forceReinit:(BOOL)force;
400
401- (void) setUpSettings;
402
403- (BOOL) reinitAndShowDemo:(BOOL)showDemo;
404
405- (BOOL) doingStartUp; // True during initial game startup (not reset).
406
407- (NSUInteger) entityCount;
408#ifndef NDEBUG
409- (void) debugDumpEntities;
410- (NSArray *) entityList;
411#endif
412
413- (void) pauseGame;
414- (void) quitGame;
415
416- (void) carryPlayerOn:(StationEntity*)carrier inWormhole:(WormholeEntity*)wormhole;
417- (void) setUpUniverseFromStation;
418- (void) setUpUniverseFromWitchspace;
419- (void) setUpUniverseFromMisjump;
420- (void) setUpWitchspace;
421- (void) setUpWitchspaceBetweenSystem:(OOSystemID)s1 andSystem:(OOSystemID)s2;
422- (void) setUpSpace;
423- (void) populateNormalSpace;
424- (void) clearSystemPopulator;
425- (BOOL) deterministicPopulation;
426- (void) populateSystemFromDictionariesWithSun:(OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet;
427- (NSDictionary *) getPopulatorSettings;
428- (void) setPopulatorSetting:(NSString *)key to:(NSDictionary *)setting;
429- (HPVector) locationByCode:(NSString *)code withSun:(OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet;
430- (void) setAmbientLightLevel:(float)newValue;
431- (float) ambientLightLevel;
432- (void) setLighting;
433- (void) forceLightSwitch;
434- (void) setMainLightPosition: (Vector) sunPos;
435- (OOPlanetEntity *) setUpPlanet;
436
437- (void) makeSunSkimmer:(ShipEntity *) ship andSetAI:(BOOL)setAI;
438- (void) addShipWithRole:(NSString *) desc nearRouteOneAt:(double) route_fraction;
439- (HPVector) coordinatesForPosition:(HPVector) pos withCoordinateSystem:(NSString *) system returningScalar:(GLfloat*) my_scalar;
440- (NSString *) expressPosition:(HPVector) pos inCoordinateSystem:(NSString *) system;
441- (HPVector) legacyPositionFrom:(HPVector) pos asCoordinateSystem:(NSString *) system;
442- (HPVector) coordinatesFromCoordinateSystemString:(NSString *) system_x_y_z;
443- (BOOL) addShipWithRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system;
444- (BOOL) addShips:(int) howMany withRole:(NSString *) desc atPosition:(HPVector) pos withCoordinateSystem:(NSString *) system;
445- (BOOL) addShips:(int) howMany withRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system;
446- (BOOL) addShips:(int) howMany withRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system withinRadius:(GLfloat) radius;
447- (BOOL) addShips:(int) howMany withRole:(NSString *) desc intoBoundingBox:(BoundingBox) bbox;
448- (BOOL) spawnShip:(NSString *) shipdesc;
449- (void) witchspaceShipWithPrimaryRole:(NSString *)role;
450- (ShipEntity *) spawnShipWithRole:(NSString *) desc near:(Entity *) entity;
451
452- (OOVisualEffectEntity *) addVisualEffectAt:(HPVector)pos withKey:(NSString *)key;
453- (ShipEntity *) addShipAt:(HPVector)pos withRole:(NSString *)role withinRadius:(GLfloat)radius;
454- (NSArray *) addShipsAt:(HPVector)pos withRole:(NSString *)role quantity:(unsigned)count withinRadius:(GLfloat)radius asGroup:(BOOL)isGroup;
455- (NSArray *) addShipsToRoute:(NSString *)route withRole:(NSString *)role quantity:(unsigned)count routeFraction:(double)routeFraction asGroup:(BOOL)isGroup;
456
457- (BOOL) roleIsPirateVictim:(NSString *)role;
458- (BOOL) role:(NSString *)role isInCategory:(NSString *)category;
459
460- (void) forceWitchspaceEntries;
461- (void) addWitchspaceJumpEffectForShip:(ShipEntity *)ship;
462- (GLfloat) safeWitchspaceExitDistance;
463
464- (void) setUpBreakPattern:(HPVector)pos orientation:(Quaternion)q forDocking:(BOOL)forDocking;
465- (BOOL) witchspaceBreakPattern;
466- (void) setWitchspaceBreakPattern:(BOOL)newValue;
467
468- (BOOL) dockingClearanceProtocolActive;
469- (void) setDockingClearanceProtocolActive:(BOOL)newValue;
470
471- (void) handleGameOver;
472
473- (void) setupIntroFirstGo:(BOOL)justCobra;
474- (void) selectIntro2Previous;
475- (void) selectIntro2Next;
476- (void) selectIntro2PreviousCategory;
477- (void) selectIntro2NextCategory;
478
479- (StationEntity *) station;
480- (OOPlanetEntity *) planet;
481- (OOSunEntity *) sun;
482- (NSArray *) planets; // Note: does not include sun.
483- (NSArray *) stations; // includes main station
484- (NSArray *) wormholes;
485- (StationEntity *) stationWithRole:(NSString *)role andPosition:(HPVector)position;
486
487// Turn main station into just another station, for blowUpStation.
488- (void) unMagicMainStation;
489// find a valid station in interstellar space
490- (StationEntity *) stationFriendlyTo:(ShipEntity *) ship;
491
492- (void) resetBeacons;
493- (Entity <OOBeaconEntity> *) firstBeacon;
494- (Entity <OOBeaconEntity> *) lastBeacon;
495- (void) setNextBeacon:(Entity <OOBeaconEntity> *) beaconShip;
496- (void) clearBeacon:(Entity <OOBeaconEntity> *) beaconShip;
497
498- (NSDictionary *) currentWaypoints;
499- (void) defineWaypoint:(NSDictionary *)definition forKey:(NSString *)key;
500
501- (GLfloat *) skyClearColor;
502// Note: the alpha value is also air resistance!
503- (void) setSkyColorRed:(GLfloat)red green:(GLfloat)green blue:(GLfloat)blue alpha:(GLfloat)alpha;
504
505- (BOOL) breakPatternOver;
506- (BOOL) breakPatternHide;
507
508- (NSString *) randomShipKeyForRoleRespectingConditions:(NSString *)role;
509- (ShipEntity *) newShipWithRole:(NSString *)role OO_RETURNS_RETAINED; // Selects ship using role weights, applies auto_ai, respects conditions
510- (ShipEntity *) newShipWithName:(NSString *)shipKey OO_RETURNS_RETAINED; // Does not apply auto_ai or respect conditions
511- (ShipEntity *) newSubentityWithName:(NSString *)shipKey andScaleFactor:(float)scale OO_RETURNS_RETAINED; // Does not apply auto_ai or respect conditions
512- (OOVisualEffectEntity *) newVisualEffectWithName:(NSString *)effectKey OO_RETURNS_RETAINED;
513- (DockEntity *) newDockWithName:(NSString *)shipKey andScaleFactor:(float)scale OO_RETURNS_RETAINED; // Does not apply auto_ai or respect conditions
514- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy OO_RETURNS_RETAINED; // If usePlayerProxy, non-carriers are instantiated as ProxyPlayerEntity.
515- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity OO_RETURNS_RETAINED;
516- (ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity andScaleFactor:(float)scale OO_RETURNS_RETAINED;
517
518- (Class) shipClassForShipDictionary:(NSDictionary *)dict;
519
520- (NSString *)defaultAIForRole:(NSString *)role; // autoAImap.plist lookup
521
522- (OOCargoQuantity) maxCargoForShip:(NSString *) desc;
523
524- (OOCreditsQuantity) getEquipmentPriceForKey:(NSString *) eq_key;
525
526- (OOCommodities *) commodities;
527
528- (ShipEntity *) reifyCargoPod:(ShipEntity *)cargoObj;
529- (ShipEntity *) cargoPodFromTemplate:(ShipEntity *)cargoObj;
530- (NSArray *) getContainersOfGoods:(OOCargoQuantity)how_many scarce:(BOOL)scarce legal:(BOOL)legal;
531- (NSArray *) getContainersOfCommodity:(OOCommodityType) commodity_name :(OOCargoQuantity) how_many;
532- (void) fillCargopodWithRandomCargo:(ShipEntity *)cargopod;
533
534- (NSString *) getRandomCommodity;
535- (OOCargoQuantity) getRandomAmountOfCommodity:(OOCommodityType) co_type;
536
537- (NSDictionary *) commodityDataForType:(OOCommodityType)type;
538- (NSString *) displayNameForCommodity:(OOCommodityType)co_type;
539- (NSString *) describeCommodity:(OOCommodityType)co_type amount:(OOCargoQuantity) co_amount;
540
541- (void) setGameView:(MyOpenGLView *)view;
542- (MyOpenGLView *) gameView;
543- (GameController *) gameController;
544- (NSDictionary *) gameSettings;
545
546- (void) useGUILightSource:(BOOL)GUILight;
547
548- (void) drawUniverse;
549
550- (void) defineFrustum;
551- (BOOL) viewFrustumIntersectsSphereAt:(Vector)position withRadius:(GLfloat)radius;
552
553- (void) drawMessage;
554
555- (void) drawWatermarkString:(NSString *)watermarkString;
556
557// Used to draw subentities. Should be getting this from camera.
558- (OOMatrix) viewMatrix;
559
560- (id) entityForUniversalID:(OOUniversalID)u_id;
561
562- (BOOL) addEntity:(Entity *) entity;
563- (BOOL) removeEntity:(Entity *) entity;
564- (void) ensureEntityReallyRemoved:(Entity *)entity;
565- (void) removeAllEntitiesExceptPlayer;
566- (void) removeDemoShips;
567
568- (ShipEntity *) makeDemoShipWithRole:(NSString *)role spinning:(BOOL)spinning;
569
570- (BOOL) isVectorClearFromEntity:(Entity *) e1 toDistance:(double)dist fromPoint:(HPVector) p2;
571- (Entity*) hazardOnRouteFromEntity:(Entity *) e1 toDistance:(double)dist fromPoint:(HPVector) p2;
572- (HPVector) getSafeVectorFromEntity:(Entity *) e1 toDistance:(double)dist fromPoint:(HPVector) p2;
573
574- (ShipEntity *) addWreckageFrom:(ShipEntity *)ship withRole:(NSString *)wreckRole at:(HPVector)rpos scale:(GLfloat)scale lifetime:(GLfloat)lifetime;
575- (void) addLaserHitEffectsAt:(HPVector)pos against:(ShipEntity *)target damage:(float)damage color:(OOColor *)color;
576- (ShipEntity *) firstShipHitByLaserFromShip:(ShipEntity *)srcEntity inDirection:(OOWeaponFacing)direction offset:(Vector)offset gettingRangeFound:(GLfloat*)range_ptr;
577- (Entity *) firstEntityTargetedByPlayer;
578- (Entity *) firstEntityTargetedByPlayerPrecisely;
579
580- (NSArray *) entitiesWithinRange:(double)range ofEntity:(Entity *)entity;
581- (unsigned) countShipsWithRole:(NSString *)role inRange:(double)range ofEntity:(Entity *)entity;
582- (unsigned) countShipsWithRole:(NSString *)role;
583- (unsigned) countShipsWithPrimaryRole:(NSString *)role inRange:(double)range ofEntity:(Entity *)entity;
584- (unsigned) countShipsWithPrimaryRole:(NSString *)role;
585- (unsigned) countShipsWithScanClass:(OOScanClass)scanClass inRange:(double)range ofEntity:(Entity *)entity;
586
587
588// General count/search methods. Pass range of -1 and entity of nil to search all of system.
589- (unsigned) countEntitiesMatchingPredicate:(EntityFilterPredicate)predicate
590 parameter:(void *)parameter
591 inRange:(double)range
592 ofEntity:(Entity *)entity;
593- (unsigned) countShipsMatchingPredicate:(EntityFilterPredicate)predicate
594 parameter:(void *)parameter
595 inRange:(double)range
596 ofEntity:(Entity *)entity;
597- (NSMutableArray *) findEntitiesMatchingPredicate:(EntityFilterPredicate)predicate
598 parameter:(void *)parameter
599 inRange:(double)range
600 ofEntity:(Entity *)entity;
601- (id) findOneEntityMatchingPredicate:(EntityFilterPredicate)predicate
602 parameter:(void *)parameter;
603- (NSMutableArray *) findShipsMatchingPredicate:(EntityFilterPredicate)predicate
604 parameter:(void *)parameter
605 inRange:(double)range
606 ofEntity:(Entity *)entity;
607- (NSMutableArray *) findVisualEffectsMatchingPredicate:(EntityFilterPredicate)predicate
608 parameter:(void *)parameter
609 inRange:(double)range
610 ofEntity:(Entity *)entity;
611- (id) nearestEntityMatchingPredicate:(EntityFilterPredicate)predicate
612 parameter:(void *)parameter
613 relativeToEntity:(Entity *)entity;
614- (id) nearestShipMatchingPredicate:(EntityFilterPredicate)predicate
615 parameter:(void *)parameter
616 relativeToEntity:(Entity *)entity;
617
618
619- (OOTimeAbsolute) getTime;
620- (OOTimeDelta) getTimeDelta;
621
622- (void) findCollisionsAndShadows;
623- (NSString*) collisionDescription;
624- (void) dumpCollisions;
625
626- (OOViewID) viewDirection;
627- (void) setViewDirection:(OOViewID)vd;
628- (void) enterGUIViewModeWithMouseInteraction:(BOOL)mouseInteraction; // Use instead of setViewDirection:VIEW_GUI_DISPLAY
629
630- (NSString *) soundNameForCustomSoundKey:(NSString *)key;
631- (NSDictionary *) screenTextureDescriptorForKey:(NSString *)key;
632- (void) setScreenTextureDescriptorForKey:(NSString *) key descriptor:(NSDictionary *)desc;
633
634- (void) clearPreviousMessage;
635- (void) setMessageGuiBackgroundColor:(OOColor *) some_color;
636- (void) displayMessage:(NSString *) text forCount:(OOTimeDelta) count;
637- (void) displayCountdownMessage:(NSString *) text forCount:(OOTimeDelta) count;
638- (void) addDelayedMessage:(NSString *) text forCount:(OOTimeDelta) count afterDelay:(OOTimeDelta) delay;
639- (void) addDelayedMessage:(NSDictionary *) textdict;
640- (void) addMessage:(NSString *) text forCount:(OOTimeDelta) count;
641- (void) addMessage:(NSString *) text forCount:(OOTimeDelta) count forceDisplay:(BOOL) forceDisplay;
642- (void) addCommsMessage:(NSString *) text forCount:(OOTimeDelta) count;
643- (void) addCommsMessage:(NSString *) text forCount:(OOTimeDelta) count andShowComms:(BOOL)showComms logOnly:(BOOL)logOnly;
644- (void) showCommsLog:(OOTimeDelta) how_long;
645- (void) showGUIMessage:(NSString *)text withScroll:(BOOL)scroll andColor:(OOColor *)selectedColor overDuration:(OOTimeDelta)how_long;
646
647- (void) update:(OOTimeDelta)delta_t;
648
649// Time Acelleration Factor. In deployment builds, this is always 1.0 and -setTimeAccelerationFactor: does nothing.
650- (double) timeAccelerationFactor;
651- (void) setTimeAccelerationFactor:(double)newTimeAccelerationFactor;
652
653- (BOOL) ECMVisualFXEnabled;
654- (void) setECMVisualFXEnabled:(BOOL)isEnabled;
655
656- (void) filterSortedLists;
657
659
660- (void) setGalaxyTo:(OOGalaxyID) g;
661- (void) setGalaxyTo:(OOGalaxyID) g andReinit:(BOOL) forced;
662
663- (void) setSystemTo:(OOSystemID) s;
664
665- (OOSystemID) currentSystemID;
666
667- (NSDictionary *) descriptions;
668- (NSDictionary *) characters;
669- (NSDictionary *) missiontext;
670- (NSArray *) scenarios;
671- (NSDictionary *) explosionSetting:(NSString *)explosion;
672
673- (OOSystemDescriptionManager *) systemManager;
674
675- (NSString *)descriptionForKey:(NSString *)key; // String, or random item from array
676- (NSString *)descriptionForArrayKey:(NSString *)key index:(unsigned)index; // Indexed item from array
677- (BOOL) descriptionBooleanForKey:(NSString *)key; // Boolean from descriptions.plist, for configuration.
678
679- (NSString *) keyForPlanetOverridesForSystem:(OOSystemID) s inGalaxy:(OOGalaxyID) g;
680- (NSString *) keyForInterstellarOverridesForSystems:(OOSystemID) s1 :(OOSystemID) s2 inGalaxy:(OOGalaxyID) g;
681- (NSDictionary *) generateSystemData:(OOSystemID) s;
682- (NSDictionary *) generateSystemData:(OOSystemID) s useCache:(BOOL) useCache;
683- (NSDictionary *) currentSystemData; // Same as generateSystemData:systemSeed unless in interstellar space.
684
685- (BOOL) inInterstellarSpace;
686
687- (void) setSystemDataKey:(NSString*) key value:(NSObject*) object fromManifest:(NSString *)manifest;
688- (void) setSystemDataForGalaxy:(OOGalaxyID) gnum planet:(OOSystemID) pnum key:(NSString *)key value:(id)object fromManifest:(NSString *)manifest forLayer:(OOSystemLayer)layer;
689- (id) systemDataForGalaxy:(OOGalaxyID) gnum planet:(OOSystemID) pnum key:(NSString *)key;
690- (NSArray *) systemDataKeysForGalaxy:(OOGalaxyID)gnum planet:(OOSystemID)pnum;
691- (NSString *) getSystemName:(OOSystemID) sys;
692- (NSString *) getSystemName:(OOSystemID) sys forGalaxy:(OOGalaxyID) gnum;
693- (OOGovernmentID) getSystemGovernment:(OOSystemID) sys;
694- (NSString *) getSystemInhabitants:(OOSystemID) sys;
695- (NSString *) getSystemInhabitants:(OOSystemID) sys plural:(BOOL)plural;
696
697- (NSPoint) coordinatesForSystem:(OOSystemID)s;
698- (OOSystemID) findSystemFromName:(NSString *) sysName;
699
703- (NSMutableArray *) nearbyDestinationsWithinRange:(double) range;
704
705- (OOSystemID) findNeighbouringSystemToCoords:(NSPoint) coords withGalaxy:(OOGalaxyID) gal;
706- (OOSystemID) findConnectedSystemAtCoords:(NSPoint) coords withGalaxy:(OOGalaxyID) gal;
707// old alias for findSystemNumberAtCoords
708- (OOSystemID) findSystemAtCoords:(NSPoint) coords withGalaxy:(OOGalaxyID) gal;
709- (OOSystemID) findSystemNumberAtCoords:(NSPoint) coords withGalaxy:(OOGalaxyID) gal includingHidden:(BOOL)hidden;
710- (NSPoint) findSystemCoordinatesWithPrefix:(NSString *) p_fix;
711- (NSPoint) findSystemCoordinatesWithPrefix:(NSString *) p_fix exactMatch:(BOOL) exactMatch;
712- (BOOL*) systemsFound;
713- (NSString*) systemNameIndex:(OOSystemID) index;
714- (NSDictionary *) routeFromSystem:(OOSystemID) start toSystem:(OOSystemID) goal optimizedBy:(OORouteType) optimizeBy;
715- (NSArray *) neighboursToSystem:(OOSystemID) system_number;
716
717- (void) preloadPlanetTexturesForSystem:(OOSystemID)system;
718- (void) preloadSounds;
719
720- (NSDictionary *) globalSettings;
721
722- (NSArray *) equipmentData;
723- (NSArray *) equipmentDataOutfitting;
724- (OOCommodityMarket *) commodityMarket;
725- (Random_Seed) marketSeed;
726
727- (NSString *) timeDescription:(OOTimeDelta) interval;
728- (NSString *) shortTimeDescription:(OOTimeDelta) interval;
729
730- (void) loadStationMarkets:(NSArray *)marketData;
731- (NSArray *) getStationMarkets;
732
733- (NSArray *) shipsForSaleForSystem:(OOSystemID) s withTL:(OOTechLevelID) specialTL atTime:(OOTimeAbsolute) current_time;
734
735/* Calculate base cost, before depreciation */
736- (OOCreditsQuantity) tradeInValueForCommanderDictionary:(NSDictionary*) cmdr_dict;
737
738- (NSString*) brochureDescriptionWithDictionary:(NSDictionary*) dict standardEquipment:(NSArray*) extras optionalEquipment:(NSArray*) options;
739
740- (HPVector) getWitchspaceExitPosition;
741- (Quaternion) getWitchspaceExitRotation;
742
743- (HPVector) getSunSkimStartPositionForShip:(ShipEntity*) ship;
744- (HPVector) getSunSkimEndPositionForShip:(ShipEntity*) ship;
745
746- (NSArray*) listBeaconsWithCode:(NSString*) code;
747
748- (void) allShipsDoScriptEvent:(jsid)event andReactToAIMessage:(NSString *)message;
749
751
752- (void) clearGUIs;
753
754- (GuiDisplayGen *) gui;
755- (GuiDisplayGen *) commLogGUI;
756- (GuiDisplayGen *) messageGUI;
757
758- (void) resetCommsLogColor;
759
760- (void) setDisplayText:(BOOL) value;
761- (BOOL) displayGUI;
762
763- (void) setDisplayFPS:(BOOL) value;
764- (BOOL) displayFPS;
765
766- (void) setAutoSave:(BOOL) value;
767- (BOOL) autoSave;
768
769- (void) setWireframeGraphics:(BOOL) value;
770- (BOOL) wireframeGraphics;
771
772- (BOOL) reducedDetail;
773- (void) setDetailLevel:(OOGraphicsDetail)value;
774- (OOGraphicsDetail) detailLevel;
775- (BOOL) useShaders;
776
777- (void) handleOoliteException:(NSException *)ooliteException;
778
779- (GLfloat)airResistanceFactor;
780- (void) setAirResistanceFactor:(GLfloat)newFactor;
781
782// speech routines
783//
784- (void) startSpeakingString:(NSString *) text;
785//
786- (void) stopSpeaking;
787//
788- (BOOL) isSpeaking;
789//
790#if OOLITE_ESPEAK
791- (NSString *) voiceName:(unsigned int) index;
792- (unsigned int) voiceNumber:(NSString *) name;
793- (unsigned int) nextVoice:(unsigned int) index;
794- (unsigned int) prevVoice:(unsigned int) index;
795- (unsigned int) setVoice:(unsigned int) index withGenderM:(BOOL) isMale;
796#endif
797- (int) nextColorblindMode:(int) index;
798- (int) prevColorblindMode:(int) index;
799- (int) colorblindMode;
800//
802
803//autosave
804- (void) setAutoSaveNow:(BOOL) value;
805- (BOOL) autoSaveNow;
806
807- (int) framesDoneThisUpdate;
808- (void) resetFramesDoneThisUpdate;
809
810// True if textual pause message (as opposed to overlay) is being shown.
811- (BOOL) pauseMessageVisible;
812- (void) setPauseMessageVisible:(BOOL)value;
813
814- (BOOL) permanentCommLog;
815- (void) setPermanentCommLog:(BOOL)value;
816- (void) setAutoCommLog:(BOOL)value;
817- (BOOL) permanentMessageLog;
818- (void) setPermanentMessageLog:(BOOL)value;
819- (BOOL) autoMessageLogBg;
820- (void) setAutoMessageLogBg:(BOOL)value;
821
822- (BOOL) blockJSPlayerShipProps;
823- (void) setBlockJSPlayerShipProps:(BOOL)value;
824
825- (void) loadConditionScripts;
826- (void) addConditionScripts:(NSEnumerator *)scripts;
827- (OOJSScript *) getConditionScript:(NSString *)scriptname;
828
829@end
830
831
832/* Use UNIVERSE to refer to the global universe object.
833 The purpose of this is that it makes UNIVERSE essentially a read-only
834 global with zero overhead.
835*/
838{
840 return gSharedUniverse;
841}
842#define UNIVERSE OOGetUniverse()
843
844
845// Only for use with string literals, and only for looking up strings.
846// DESC() is deprecated in favour of OOExpandKey() except in known performance-
847// critical contexts.
848#define DESC(key) (OOLookUpDescriptionPRIV(key ""))
849#define DESC_PLURAL(key,count) (OOLookUpPluralDescriptionPRIV(key "", count))
850
851// Not for direct use.
852NSComparisonResult populatorPrioritySort(id a, id b, void *context);
853NSComparisonResult equipmentSort(id a, id b, void *context);
854NSComparisonResult equipmentSortOutfitting(id a, id b, void *context);
855NSString *OOLookUpDescriptionPRIV(NSString *key);
856NSString *OOLookUpPluralDescriptionPRIV(NSString *key, NSInteger count);
857
858@interface OOSound (OOCustomSounds)
859
860+ (id) soundWithCustomSoundKey:(NSString *)key;
861- (id) initWithCustomSoundKey:(NSString *)key;
862
863@end
864
865
866@interface OOSoundSource (OOCustomSounds)
867
868+ (id) sourceWithCustomSoundKey:(NSString *)key;
869- (id) initWithCustomSoundKey:(NSString *)key;
870
871- (void) playCustomSoundWithKey:(NSString *)key;
872
873@end
874
875
OOScanClass
Definition Entity.h:71
NSString * OODisplayStringFromEconomyID(OOEconomyID economy)
NSString * OODisplayStringFromGovernmentID(OOGovernmentID government)
#define INLINE_CONST_FUNC
#define OOINLINE
unsigned count
NSString * OOCommodityType
Definition OOTypes.h:106
OORouteType
Definition OOTypes.h:33
OOGraphicsDetail
Definition OOTypes.h:243
OOViewID
Definition OOTypes.h:43
uint64_t OOCreditsQuantity
Definition OOTypes.h:182
uint16_t OOUniversalID
Definition OOTypes.h:189
NSUInteger OOTechLevelID
Definition OOTypes.h:204
int16_t OOSystemID
Definition OOTypes.h:211
uint8_t OOGalaxyID
Definition OOTypes.h:210
uint32_t OOCargoQuantity
Definition OOTypes.h:176
double OOTimeDelta
Definition OOTypes.h:224
uint8_t OOGovernmentID
Definition OOTypes.h:206
double OOTimeAbsolute
Definition OOTypes.h:223
OOWeaponFacing
Definition OOTypes.h:228
uint8_t OOEconomyID
Definition OOTypes.h:207
OOINLINE Universe * OOGetUniverse(void) INLINE_CONST_FUNC
Definition Universe.h:837
@ EQUIPMENT_SHORT_DESC_INDEX
Definition Universe.h:81
@ EQUIPMENT_LONG_DESC_INDEX
Definition Universe.h:83
@ EQUIPMENT_TECH_LEVEL_INDEX
Definition Universe.h:79
@ EQUIPMENT_KEY_INDEX
Definition Universe.h:82
@ EQUIPMENT_PRICE_INDEX
Definition Universe.h:80
@ EQUIPMENT_EXTRA_INFO_INDEX
Definition Universe.h:84
NSString * OOLookUpDescriptionPRIV(NSString *key)
Definition Universe.m:11200
@ OO_POSTFX_COLORBLINDNESS_PROTAN
Definition Universe.h:91
@ OO_POSTFX_ENDOFLIST
Definition Universe.h:99
@ OO_POSTFX_COLORBLINDNESS_TRITAN
Definition Universe.h:93
@ OO_POSTFX_CRT
Definition Universe.h:97
@ OO_POSTFX_COLORBLINDNESS_DEUTER
Definition Universe.h:92
@ OO_POSTFX_GRAYSCALE
Definition Universe.h:95
@ OO_POSTFX_OLDMOVIE
Definition Universe.h:96
@ OO_POSTFX_NONE
Definition Universe.h:90
@ OO_POSTFX_CRTBADSIGNAL
Definition Universe.h:98
@ OO_POSTFX_CLOAK
Definition Universe.h:94
NSString * OOLookUpPluralDescriptionPRIV(NSString *key, NSInteger count)
Definition Universe.m:11209
NSComparisonResult populatorPrioritySort(id a, id b, void *context)
Definition Universe.m:11136
NSComparisonResult equipmentSortOutfitting(id a, id b, void *context)
Definition Universe.m:11174
NSComparisonResult equipmentSort(id a, id b, void *context)
Definition Universe.m:11148
enum OOScanClass OOScanClass
Definition Universe.h:56
@ MARKET_QUANTITY
Definition Universe.h:65
@ MARKET_ECO_ADJUST_QUANTITY
Definition Universe.h:69
@ MARKET_MASK_PRICE
Definition Universe.h:71
@ MARKET_ECO_ADJUST_PRICE
Definition Universe.h:68
@ MARKET_NAME
Definition Universe.h:64
@ MARKET_UNITS
Definition Universe.h:73
@ MARKET_BASE_PRICE
Definition Universe.h:67
@ MARKET_BASE_QUANTITY
Definition Universe.h:70
@ MARKET_PRICE
Definition Universe.h:66
@ MARKET_MASK_QUANTITY
Definition Universe.h:72
BOOL(* EntityFilterPredicate)(Entity *entity, void *parameter)
Definition Universe.h:52
Universe * gSharedUniverse
Definition Universe.m:138
GLuint targetDepthBufferID
Definition Universe.h:367
NSArray * speechArray
Definition Universe.h:340
NSSpeechSynthesizer * speechSynthesizer
Definition Universe.h:335
OOGraphicsDetail detailLevel
Definition Universe.h:241
GLuint pingpongColorbuffers[2]
Definition Universe.h:376
unsigned n_entities
Definition Universe.h:192
GLuint msaaDepthBufferID
Definition Universe.h:366
OOShaderProgram * finalProgram
Definition Universe.h:372
OOWeakReference * _firstBeacon
Definition Universe.h:221
NSMutableDictionary * conditionScripts
Definition Universe.h:350
OOGalaxyID galaxyID
Definition Universe.h:284
NSArray * demo_ships
Definition Universe.h:257
BOOL _autoMessageLogBg
Definition Universe.h:355
OOSystemID systemID
Definition Universe.h:285
BOOL autoSaveNow
Definition Universe.h:238
BOOL _doingStartUp
Definition Universe.h:359
GLuint msaaTextureID
Definition Universe.h:361
NSString * system_repopulator
Definition Universe.h:305
OOTimeAbsolute demo_start_time
Definition Universe.h:252
OOSystemID targetSystemID
Definition Universe.h:286
GLuint quadTextureVAO
Definition Universe.h:373
BOOL ECMVisualFXEnabled
Definition Universe.h:318
NSString * system_names[256]
Definition Universe.h:288
NSString * useAddOns
Definition Universe.h:310
GLfloat sun_diffuse[4]
Definition Universe.h:205
NSUInteger demo_ship_index
Definition Universe.h:255
Entity * y_list_start
Definition Universe.h:197
NSDictionary * customSounds
Definition Universe.h:268
BOOL doProcedurallyTexturedPlanets
Definition Universe.h:346
OOCommodities * commodities
Definition Universe.h:263
OOShaderProgram * blurProgram
Definition Universe.h:371
NSMutableSet * allStations
Definition Universe.h:299
NSDictionary * roleCategories
Definition Universe.h:277
GuiDisplayGen * comm_log_gui
Definition Universe.h:233
GLfloat sun_specular[4]
Definition Universe.h:206
NSUInteger demo_ship_subindex
Definition Universe.h:256
GLuint targetFramebufferID
Definition Universe.h:368
NSDictionary * _descriptions
Definition Universe.h:267
NSDictionary * cargoPods
Definition Universe.h:282
NSArray * equipmentData
Definition Universe.h:274
int cursor_row
Definition Universe.h:194
int demo_stage
Definition Universe.h:254
BOOL doLinkedListMaintenanceThisUpdate
Definition Universe.h:327
NSDictionary * characters
Definition Universe.h:269
NSMutableDictionary * waypoints
Definition Universe.h:223
OOShaderProgram * textureProgram
Definition Universe.h:370
int next_universal_id
Definition Universe.h:216
BOOL wasDisplayGUI
Definition Universe.h:236
OOTimeAbsolute demo_stage_time
Definition Universe.h:251
BOOL _pauseMessage
Definition Universe.h:352
BOOL no_update
Definition Universe.h:312
OOViewID viewDirection
Definition Universe.h:208
BOOL deterministic_population
Definition Universe.h:306
BOOL _autoCommLog
Definition Universe.h:353
OOMatrix viewMatrix
Definition Universe.h:210
NSMutableDictionary * populatorSettings
Definition Universe.h:303
NSDictionary * screenBackgrounds
Definition Universe.h:279
GLuint pingpongFBO[2]
Definition Universe.h:375
NSDictionary * globalSettings
Definition Universe.h:271
GuiDisplayGen * message_gui
Definition Universe.h:232
OOSunEntity * cachedSun
Definition Universe.h:297
NSUInteger _sessionID
Definition Universe.h:202
BOOL system_found[256]
Definition Universe.h:289
NSString * currentMessage
Definition Universe.h:227
CollisionRegion * universeRegion
Definition Universe.h:324
NSUInteger drawCounter
Definition Universe.h:331
NSDictionary * explosionSettings
Definition Universe.h:280
OOPlanetEntity * cachedPlanet
Definition Universe.h:296
NSSize targetFramebufferSize
Definition Universe.h:364
NSMutableArray * activeWormholes
Definition Universe.h:320
ShipEntity * demo_ship
Definition Universe.h:293
NSMutableArray * entities
Definition Universe.h:219
GLfloat skyClearColor[4]
Definition Universe.h:225
OOCommodityMarket * commodityMarket
Definition Universe.h:264
OOSystemDescriptionManager * systemManager
Definition Universe.h:272
BOOL _permanentMessageLog
Definition Universe.h:356
GLuint passthroughTextureID[2]
Definition Universe.h:363
BOOL _witchspaceBreakPattern
Definition Universe.h:357
NSArray * closeSystems
Definition Universe.h:308
GLuint passthroughFramebufferID
Definition Universe.h:369
NSArray * _scenarios
Definition Universe.h:270
OOTimeDelta next_repopulation
Definition Universe.h:304
GLuint msaaFramebufferID
Definition Universe.h:365
BOOL _bloom
Definition Universe.h:377
double timeAccelerationFactor
Definition Universe.h:315
OOTimeDelta time_delta
Definition Universe.h:249
BOOL dumpCollisionInfo
Definition Universe.h:261
Entity * sortedEntities[UNIVERSE_MAX_ENTITIES+1]
Definition Universe.h:191
GLfloat main_light_position[4]
Definition Universe.h:259
BOOL _dockingClearanceProtocolActive
Definition Universe.h:358
BOOL displayFPS
Definition Universe.h:246
BOOL autoSave
Definition Universe.h:239
int breakPatternCounter
Definition Universe.h:291
OOTimeAbsolute countdown_messageRepeatTime
Definition Universe.h:229
BOOL _permanentCommLog
Definition Universe.h:354
NSMutableSet * entitiesDeadThisUpdate
Definition Universe.h:329
GLfloat stars_ambient[4]
Definition Universe.h:199
NSMutableArray * characterPool
Definition Universe.h:322
MyOpenGLView * gameView
Definition Universe.h:214
GLfloat airResistanceFactor
Definition Universe.h:212
NSDictionary * autoAIMap
Definition Universe.h:278
GLuint quadTextureVBO
Definition Universe.h:373
OOTimeAbsolute messageRepeatTime
Definition Universe.h:228
NSMutableArray * allPlanets
Definition Universe.h:298
GLfloat demo_start_z
Definition Universe.h:253
GLuint targetTextureID
Definition Universe.h:362
GLint defaultDrawFBO
Definition Universe.h:374
Entity * z_list_start
Definition Universe.h:197
BOOL displayGUI
Definition Universe.h:235
GLfloat frustum[6][4]
Definition Universe.h:348
int framesDoneThisUpdate
Definition Universe.h:330
Entity * entity_for_uid[MAX_ENTITY_UID]
Definition Universe.h:217
BOOL wireframeGraphics
Definition Universe.h:240
OOTimeAbsolute universal_time
Definition Universe.h:248
StationEntity * cachedStation
Definition Universe.h:295
GLuint quadTextureEBO
Definition Universe.h:373
OOWeakReference * _lastBeacon
Definition Universe.h:222
Entity * x_list_start
Definition Universe.h:197
int _currentPostFX
Definition Universe.h:378
NSDictionary * missiontext
Definition Universe.h:273
float ambientLightLevel
Definition Universe.h:301
int _colorblindMode
Definition Universe.h:379
NSArray * equipmentDataOutfitting
Definition Universe.h:275
GuiDisplayGen * gui
Definition Universe.h:231
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque