35#import "OOConstToJSString.h"
69#import "OOJSEngineTimeManagement.h"
70#import "OOJSFrameCallbacks.h"
71#import "OOJSPopulatorDefinition.h"
96#if OO_LOCALIZATION_TOOLS
106#define DEMO2_VANISHING_DISTANCE 650.0
107#define DEMO2_FLY_IN_STAGE_TIME 0.4
109#define MAX_NUMBER_OF_ENTITIES 200
110#define STANDARD_STATION_ROLL 0.4
112#define LANE_WIDTH 51200.0
121 1.0f, 1.0f, 1.0f, 1.0f,
122 1.0f, -1.0f, 1.0f, 0.0f,
123 -1.0f, -1.0f, 0.0f, 0.0f,
124 -1.0f, 1.0f, 0.0f, 1.0f
143#undef CACHE_ROUTE_FROM_SYSTEM_RESULTS
152+ (instancetype)elementWithLocation:(
OOSystemID)location parent:(
OOSystemID)parent cost:(
double)cost distance:(
double)distance time:(
double)time jumps:(
int)jumps;
164+ (instancetype)elementWithLocation:(
OOSystemID)location parent:(
OOSystemID)parent cost:(
double)cost distance:(
double)distance time:(
double)time jumps:(
int)jumps
175 return [
r autorelease];
205@interface Universe (OOPrivate)
207- (void)initTargetFramebufferWithViewSize:(NSSize)viewSize;
209- (void)resizeTargetFramebufferWithViewSize:(NSSize)viewSize;
213- (BOOL)doRemoveEntity:(
Entity*)entity;
220- (NSString*)chooseStringForKey:(NSString*)key inDictionary:(NSDictionary*)dictionary;
222#if OO_LOCALIZATION_TOOLS
224- (void)dumpDebugGraphViz;
225- (void)dumpSystemDescriptionGraphViz;
227- (void)addNumericRefsInString:(NSString*)string toGraphViz:(NSMutableString*)graphViz fromNode:(NSString*)fromNode nodeCount:(NSUInteger)nodeCount;
237- (void)prunePreloadingPlanetMaterials;
243- (void)setFirstBeacon:(
Entity<OOBeaconEntity>*)beacon;
244- (void)setLastBeacon:(
Entity<OOBeaconEntity>*)beacon;
252- (
Vector)randomPlaceWithinScannerFrom:(
Vector)pos alongRoute:(
Vector)route withOffset:(
double)offset;
269static GLfloat
sun_off[4] = { 0.0, 0.0, 0.0, 1.0 };
272#define DOCKED_AMBIENT_LEVEL 0.2f
273#define DOCKED_ILLUM_LEVEL 0.7f
280#define SUN_AMBIENT_INFLUENCE 0.75
282#define SKY_AMBIENT_ADJUSTMENT 0.0625
289- (void)setBloom:(BOOL)newBloom
299- (void)setCurrentPostFX:(
int)newCurrentPostFX
312- (void)terminatePostFX:(
int)postFX
319- (
int)nextColorblindMode:(
int)index
327- (
int)prevColorblindMode:(
int)index
340- (void)initTargetFramebufferWithViewSize:(NSSize)viewSize
343 OOGL(glClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE));
344 OOGL(glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE));
345 OOGL(glClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE));
348 OOGL(glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &defaultDrawFBO));
350 GLint previousProgramID;
351 OOGL(glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgramID));
352 GLint previousTextureID;
353 OOGL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureID));
355 OOGL(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &previousVAO));
356 GLint previousArrayBuffer;
357 OOGL(glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &previousArrayBuffer));
358 GLint previousElementBuffer;
359 OOGL(glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &previousElementBuffer));
362 OOGL(glGenFramebuffers(1, &msaaFramebufferID));
363 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, msaaFramebufferID));
366#if OO_MSAA_COLOR_RENDERBUFFER
368 OOGL(glGenRenderbuffers(1, &msaaTextureID));
369 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaTextureID));
370 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
371 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
372 OOGL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, msaaTextureID));
374 OOGL(glGenTextures(1, &msaaTextureID));
375 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID));
376 OOGL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, GL_TRUE));
377 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
378 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID, 0));
382 OOGL(glGenRenderbuffers(1, &msaaDepthBufferID));
383 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaDepthBufferID));
384 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
385 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
386 OOGL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, msaaDepthBufferID));
388 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
389 OOLogERR(
@"initTargetFramebufferWithViewSize.result",
@"%@",
@"***** Error: Multisample framebuffer not complete");
393 OOGL(glGenFramebuffers(1, &targetFramebufferID));
394 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, targetFramebufferID));
397 OOGL(glGenTextures(1, &targetTextureID));
398 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
399 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
400 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
401 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
404 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTextureID, 0));
407 OOGL(glGenRenderbuffers(1, &targetDepthBufferID));
408 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, targetDepthBufferID));
409 OOGL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
410 OOGL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, targetDepthBufferID));
412 GLenum attachment[1] = { GL_COLOR_ATTACHMENT0 };
413 OOGL(glDrawBuffers(1, attachment));
415 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
416 OOLogERR(
@"initTargetFramebufferWithViewSize.result",
@"%@",
@"***** Error: Framebuffer not complete");
419 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
421 targetFramebufferSize = viewSize;
429 OOGL(glGenFramebuffers(1, &passthroughFramebufferID));
430 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, passthroughFramebufferID));
433 OOGL(glGenTextures(2, passthroughTextureID));
434 for (
unsigned int i = 0; i < 2; i++) {
435 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[i]));
436 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
437 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
438 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
441 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, passthroughTextureID[i], 0));
444 GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
445 OOGL(glDrawBuffers(2, attachments));
447 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
448 OOLogERR(
@"initTargetFramebufferWithViewSize.result",
@"%@",
@"***** Error: Passthrough framebuffer not complete");
450 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
453 OOGL(glGenFramebuffers(2, pingpongFBO));
454 OOGL(glGenTextures(2, pingpongColorbuffers));
455 for (
unsigned int i = 0; i < 2; i++) {
456 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i]));
457 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]));
458 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
459 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
460 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
463 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongColorbuffers[i], 0));
465 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
466 OOLogERR(
@"initTargetFramebufferWithViewSize.result",
@"%@",
@"***** Error: Pingpong framebuffers not complete");
469 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
482 textureProgram = [[
OOShaderProgram shaderProgramWithVertexShaderName:@"oolite-texture.vertex"
483 fragmentShaderName:@"oolite-texture.fragment"
484 prefix:@"#version 330\n"
487 blurProgram = [[
OOShaderProgram shaderProgramWithVertexShaderName:@"oolite-blur.vertex"
488 fragmentShaderName:@"oolite-blur.fragment"
489 prefix:@"#version 330\n"
492 finalProgram = [[
OOShaderProgram shaderProgramWithVertexShaderName:@"oolite-final.vertex"
494 fragmentShaderName:[[UNIVERSE gameView] hdrOutput] ? @"oolite-final-hdr.fragment" : @"oolite-final.fragment"
496 fragmentShaderName:@"oolite-final.fragment"
498 prefix:@"#version 330\n"
502 OOGL(glGenVertexArrays(1, &quadTextureVAO));
503 OOGL(glGenBuffers(1, &quadTextureVBO));
504 OOGL(glGenBuffers(1, &quadTextureEBO));
506 OOGL(glBindVertexArray(quadTextureVAO));
508 OOGL(glBindBuffer(GL_ARRAY_BUFFER, quadTextureVBO));
511 OOGL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quadTextureEBO));
514 OOGL(glEnableVertexAttribArray(0));
516 OOGL(glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 *
sizeof(
float), (
void*)0));
517 OOGL(glEnableVertexAttribArray(1));
519 OOGL(glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 *
sizeof(
float), (
void*)(2 *
sizeof(
float))));
522 OOGL(glUseProgram(previousProgramID));
523 OOGL(glBindTexture(GL_TEXTURE_2D, previousTextureID));
524 OOGL(glBindVertexArray(previousVAO));
525 OOGL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, previousElementBuffer));
526 OOGL(glBindBuffer(GL_ARRAY_BUFFER, previousArrayBuffer));
531#if OO_MSAA_COLOR_RENDERBUFFER
532 OOGL(glDeleteRenderbuffers(1, &msaaTextureID));
534 OOGL(glDeleteTextures(1, &msaaTextureID));
536 OOGL(glDeleteTextures(1, &targetTextureID));
537 OOGL(glDeleteTextures(2, passthroughTextureID));
538 OOGL(glDeleteTextures(2, pingpongColorbuffers));
539 OOGL(glDeleteRenderbuffers(1, &msaaDepthBufferID));
540 OOGL(glDeleteRenderbuffers(1, &targetDepthBufferID));
541 OOGL(glDeleteFramebuffers(1, &msaaFramebufferID));
542 OOGL(glDeleteFramebuffers(1, &targetFramebufferID));
543 OOGL(glDeleteFramebuffers(2, pingpongFBO));
544 OOGL(glDeleteFramebuffers(1, &passthroughFramebufferID));
545 OOGL(glDeleteVertexArrays(1, &quadTextureVAO));
546 OOGL(glDeleteBuffers(1, &quadTextureVBO));
547 OOGL(glDeleteBuffers(1, &quadTextureEBO));
553- (void)resizeTargetFramebufferWithViewSize:(NSSize)viewSize
557#if OO_MSAA_COLOR_RENDERBUFFER
558 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaTextureID));
559 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
560 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
562 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID));
563 OOGL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, GL_TRUE));
564 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
568 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaDepthBufferID));
569 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
570 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
573 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
574 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
575 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
577 for (i = 0; i < 2; i++) {
578 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]));
579 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
580 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
583 for (i = 0; i < 2; i++) {
584 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[i]));
585 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
586 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
590 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, targetDepthBufferID));
591 OOGL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
592 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
594 targetFramebufferSize.width = viewSize.width;
595 targetFramebufferSize.height = viewSize.height;
602 OOGL(glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &previousFBO));
603 GLint previousProgramID;
604 OOGL(glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgramID));
605 GLint previousTextureID;
606 OOGL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureID));
608 OOGL(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &previousVAO));
609 GLint previousActiveTexture;
610 OOGL(glGetIntegerv(GL_ACTIVE_TEXTURE, &previousActiveTexture));
612 OOGL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
614 OOGL(glDisable(GL_BLEND));
619 NSSize viewSize = [
gameView backingViewSize];
620 float fboResolution[2] = { viewSize.width, viewSize.height };
622 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, passthroughFramebufferID));
623 OOGL(glClear(GL_COLOR_BUFFER_BIT));
625 OOGL(glUseProgram(program));
626 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
627 OOGL(glUniform1i(glGetUniformLocation(program,
"image"), 0));
629 OOGL(glBindVertexArray(quadTextureVAO));
630 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
631 OOGL(glBindVertexArray(0));
633 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
635 BOOL horizontal = YES, firstIteration = YES;
636 unsigned int amount = [
self bloom] ? 10 : 0;
637 OOGL(glUseProgram(blur));
638 for (
unsigned int i = 0; i < amount; i++) {
639 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]));
640 OOGL(glUniform1i(glGetUniformLocation(blur,
"horizontal"), horizontal));
641 OOGL(glActiveTexture(GL_TEXTURE0));
643 OOGL(glBindTexture(GL_TEXTURE_2D, firstIteration ? passthroughTextureID[1] : pingpongColorbuffers[!horizontal]));
644 OOGL(glUniform1i(glGetUniformLocation(blur,
"imageIn"), 0));
645 OOGL(glBindVertexArray(quadTextureVAO));
646 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
647 OOGL(glBindVertexArray(0));
648 horizontal = !horizontal;
651 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
653 OOGL(glUseProgram(
final));
655 OOGL(glActiveTexture(GL_TEXTURE0));
656 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[0]));
657 OOGL(glUniform1i(glGetUniformLocation(
final,
"scene"), 0));
658 OOGL(glUniform1i(glGetUniformLocation(
final,
"bloom"), [
self bloom]));
659 OOGL(glUniform1f(glGetUniformLocation(
final,
"uTime"), [
self getTime]));
660 OOGL(glUniform2fv(glGetUniformLocation(
final,
"uResolution"), 1, fboResolution));
661 OOGL(glUniform1i(glGetUniformLocation(
final,
"uPostFX"), [
self currentPostFX]));
663 if ([gameView hdrOutput]) {
664 OOGL(glUniform1f(glGetUniformLocation(
final,
"uMaxBrightness"), [gameView hdrMaxBrightness]));
665 OOGL(glUniform1f(glGetUniformLocation(
final,
"uPaperWhiteBrightness"), [gameView hdrPaperWhiteBrightness]));
666 OOGL(glUniform1i(glGetUniformLocation(
final,
"uHDRToneMapper"), [gameView hdrToneMapper]));
669 OOGL(glUniform1i(glGetUniformLocation(
final,
"uSDRToneMapper"), [gameView sdrToneMapper]));
671 OOGL(glActiveTexture(GL_TEXTURE1));
672 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[!horizontal]));
673 OOGL(glUniform1i(glGetUniformLocation(
final,
"bloomBlur"), 1));
674 OOGL(glUniform1f(glGetUniformLocation(
final,
"uSaturation"), [gameView colorSaturation]));
676 OOGL(glBindVertexArray(quadTextureVAO));
677 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
681 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
684 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, previousFBO));
685 OOGL(glActiveTexture(previousActiveTexture));
686 OOGL(glBindTexture(GL_TEXTURE_2D, previousTextureID));
687 OOGL(glUseProgram(previousProgramID));
688 OOGL(glBindVertexArray(previousVAO));
689 OOGL(glEnable(GL_BLEND));
696 [
NSException raise:NSInternalInconsistencyException format:@"%s: expected only one Universe to exist at a time.", __PRETTY_FUNCTION__];
736#if OOLITE_SPEECH_SYNTH
737 OOLog(
@"speech.synthesis",
@"Spoken messages are %@.", ([prefs oo_boolForKey:
@"speech_on" defaultValue:NO] ?
@"on" :
@"off"));
750 autoSave = [
prefs oo_boolForKey:@"autosave" defaultValue:NO];
754 OOLog(
@"MSAA.setup",
@"Multisample anti-aliasing %@requested.", [inGameView msaa] ?
@"" :
@"not ");
762#if OOLITE_SPEECH_SYNTH
763#if OOLITE_MAC_COCOA_UI
764 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0),
774 OOLog(
@"speech.setup.begin",
@"Starting to set up speech synthesizer.");
776 OOLog(
@"speech.setup.end",
@"Finished setting up speech synthesizer.");
777 speechSynthesizer = synth;
781 espeak_SetParameter(espeakPUNCTUATION, espeakPUNCT_NONE, 0);
782 espeak_SetParameter(espeakVOLUME, volume, 0);
783 espeak_voices = espeak_ListVoices(NULL);
784 for (espeak_voice_count = 0;
786 ++espeak_voice_count)
845#if OO_LOCALIZATION_TOOLS
848 [
self dumpDebugGraphViz];
862 [currentMessage release];
872 [_descriptions release];
873 [characters release];
874 [customSounds release];
875 [globalSettings release];
877 [missiontext release];
878 [equipmentData release];
879 [equipmentDataOutfitting release];
880 [demo_ships release];
882 [screenBackgrounds release];
884 [populatorSettings release];
885 [system_repopulator release];
886 [allPlanets release];
887 [allStations release];
888 [explosionSettings release];
890 [activeWormholes release];
891 [characterPool release];
900 for (i = 0; i < 256; i++)
903 [entitiesDeadThisUpdate release];
907#if OOLITE_SPEECH_SYNTH
909#if OOLITE_MAC_COCOA_UI
915 [conditionScripts release];
937- (void)setDoProcedurallyTexturedPlanets:(BOOL)value
940 [[
NSUserDefaults standardUserDefaults] setBool:doProcedurallyTexturedPlanets forKey:@"procedurally-textured-planets"];
948- (BOOL)setUseAddOns:(NSString*)newUse fromSaveGame:(BOOL)saveGame
953- (BOOL)setUseAddOns:(NSString*)newUse fromSaveGame:(BOOL)saveGame forceReinit:(BOOL)force
955 if (!force && [newUse isEqualToString:
useAddOns]) {
966 return [entities count];
969#ifdef OO_DEBUG_MONITOR_ENABLED
970- (void)debugDumpEntities
973 int show_count = n_entities;
978 OOLog(
@"universe.objectDump",
@"DEBUG: Entity Dump - [entities count] = %zu,\tn_entities = %u", [entities
count], n_entities);
981 for (i = 0; i < show_count; i++) {
982 OOLog(
@"universe.objectDump",
@"Ent:%4u %@", i, [sortedEntities[i] descriptionForObjDump]);
986 if ([entities
count] != n_entities) {
987 OOLog(
@"universe.objectDump",
@"entities = %@", [entities description]);
991- (NSArray*)entityList
993 return [NSArray arrayWithArray:entities];
1003 NSString* pauseKey = [PLAYER keyBindingDescription2:@"key_pausebutton"];
1005 if ([player status] == STATUS_DOCKED) {
1006 if ([
gui setForegroundTextureKey:
@"paused_docked_overlay"]) {
1013 if ([player guiScreen] != GUI_SCREEN_MAIN && [
gui setForegroundTextureKey:
@"paused_overlay"]) {
1026 OOLog(
@"universe.quit",
@"%@",
@"Quit command received by Universe.");
1055 if (![wormhole withMisjump]) {
1062 if ([player random_factor] < 8)
1077 [UNIVERSE setSkyColorRed:0.0f
1102 if (dockedStation && !interstel) {
1108 Entity* ent = [entities objectAtIndex:index];
1109 if ((ent != player) && (ent != dockedStation)) {
1118 if (dockedStation ==
nil)
1122 if (!dockedStation || !interstel) {
1125 if (dockedStation) {
1126 if ([dockedStation maxFlightSpeed] > 0)
1129 HPVector pos = [UNIVERSE getWitchspaceExitPosition];
1133 if (abs((
int)d1) < 2750) {
1134 d1 += ((d1 > 0.0) ? 2750.0f : -2750.0f);
1156 [UNIVERSE setSkyColorRed:0.0f
1177 player = [PLAYER retain];
1189 align:GUI_ALIGN_CENTER
1213 player = [PLAYER retain];
1253 thing = [[
SkyEntity alloc] initWithColors:col1 col2:col2 andSystemInfo:systeminfo];
1273 NSString* populator = [
systeminfo oo_stringForKey:@"populator" defaultValue:@"interstellarSpaceWillPopulate"];
1274 [system_repopulator release];
1277 [PLAYER doWorldScriptEvent:OOJSIDFromString(populator) inContext:context withArguments:NULL count:0 timeLimit:kOOJSLongTimeLimit];
1282 NSArray* script_actions = [
systeminfo oo_arrayForKey:@"script_actions"];
1283 if (script_actions !=
nil) {
1284 OOStandardsDeprecated([NSString stringWithFormat:
@"The script_actions system info key is deprecated for %@.", override_key]);
1305 [
planetDict oo_setBool:YES forKey:@"mainForLocalSystem"];
1306 OOPlanetEntity* a_planet = [[
OOPlanetEntity alloc] initFromDictionary:planetDict withAtmosphere:[
planetDict oo_boolForKey:@"has_atmosphere" defaultValue:YES] andSeed:systemSeed forSystem:systemID];
1308 double planet_zpos = [
planetDict oo_floatForKey:@"planet_distance" defaultValue:500000];
1309 planet_zpos *= [
planetDict oo_floatForKey:@"planet_distance_multiplier" defaultValue:1.0];
1311#ifdef OO_DUMP_PLANETINFO
1312 OOLog(
@"planetinfo.record",
@"planet zpos = %f", planet_zpos);
1319 OOPlanetEntity* tmp = [allPlanets objectAtIndex:0];
1321 [allPlanets removeObject:a_planet];
1323 [allPlanets replaceObjectAtIndex:0 withObject:a_planet];
1340 OOPlanetEntity* a_planet;
1348 unsigned techlevel = [
systeminfo oo_unsignedIntForKey:KEY_TECHLEVEL];
1349 NSString *stationDesc =
nil, *defaultStationDesc =
nil;
1358 sunGoneNova = [
systeminfo oo_boolForKey:@"sun_gone_nova" defaultValue:NO];
1369#ifdef OO_DUMP_PLANETINFO
1370 OOLog(
@"planetinfo.record",
@"seed = %d %d %d %d", system_seed.c, system_seed.d, system_seed.e, system_seed.f);
1371 OOLog(
@"planetinfo.record",
@"coordinates = %d %d", system_seed.d, system_seed.b);
1373#define SPROP(PROP) OOLog(@"planetinfo.record", @ #PROP " = \"%@\";", [systeminfo oo_stringForKey:@"" #PROP]);
1374#define IPROP(PROP) OOLog(@"planetinfo.record", @ #PROP " = %d;", [systeminfo oo_intForKey:@ #PROP]);
1375#define FPROP(PROP) OOLog(@"planetinfo.record", @ #PROP " = %f;", [systeminfo oo_floatForKey:@"" #PROP]);
1380 IPROP(productivity);
1393 float h2 = h1 + 1.0 / (1.0 + (
Ranrot() % 5));
1399 thing = [[
SkyEntity alloc] initWithColors:col1 col2:col2 andSystemInfo:systeminfo];
1413 dict_object = [
systeminfo objectForKey:@"sun_color"];
1414 if (dict_object !=
nil) {
1432 float defaultSunFlare =
randf() * 0.1;
1433 float defaultSunHues = 0.5 +
randf() * 0.5;
1440 double planet_radius = [
a_planet radius];
1449 double sun_distance;
1450 double sunDistanceModifier;
1451 double safeDistance;
1454 sunDistanceModifier = [
systeminfo oo_nonNegativeDoubleForKey:@"sun_distance_modifier" defaultValue:0.0];
1455 if (sunDistanceModifier < 6.0)
1457 sun_distance = [
systeminfo oo_nonNegativeDoubleForKey:@"sun_distance" defaultValue:(planet_radius * 20)];
1459 sun_distance *= [
systeminfo oo_nonNegativeDoubleForKey:@"sun_distance_multiplier" defaultValue:1];
1461 sun_distance = planet_radius * sunDistanceModifier;
1464 sun_radius = [
systeminfo oo_nonNegativeDoubleForKey:@"sun_radius" defaultValue:2.5 * planet_radius];
1466 if ((sun_radius < 1000.0) || (sun_radius > sun_distance / 2 && !sunGoneNova)) {
1467 OOLogWARN(
@"universe.setup.badSun",
@"Sun radius of %f is not valid for this system", sun_radius);
1468 sun_radius = sun_radius < 1000.0 ? 1000.0 : (sun_distance / 2);
1470#ifdef OO_DUMP_PLANETINFO
1471 OOLog(
@"planetinfo.record",
@"sun_radius = %f", sun_radius);
1473 safeDistance = 36 * sun_radius * sun_radius;
1478 sun_distance /= 2.0;
1480 sun_distance *= 2.0;
1489 [
a_planet setOrientation:quaternion_rotation_betweenHP(sun_dir, make_HPvector(1.0, 0.0, 0.0))];
1491#ifdef OO_DUMP_PLANETINFO
1492 OOLog(
@"planetinfo.record",
@"sun_vector = %.3f %.3f %.3f", vf.
x, vf.
y, vf.
z);
1493 OOLog(
@"planetinfo.record",
@"sun_distance = %.0f", sun_distance);
1497 [
sun_dict setObject:[
NSNumber numberWithDouble:sun_radius] forKey:@"sun_radius"];
1498 dict_object = [
systeminfo objectForKey:@"corona_shimmer"];
1499 if (dict_object !=
nil)
1500 [
sun_dict setObject:dict_object forKey:@"corona_shimmer"];
1501 dict_object = [
systeminfo objectForKey:@"corona_hues"];
1502 if (dict_object !=
nil) {
1503 [
sun_dict setObject:dict_object forKey:@"corona_hues"];
1505 [
sun_dict setObject:[
NSNumber numberWithFloat:defaultSunHues] forKey:@"corona_hues"];
1507 dict_object = [
systeminfo objectForKey:@"corona_flare"];
1508 if (dict_object !=
nil) {
1509 [
sun_dict setObject:dict_object forKey:@"corona_flare"];
1511 [
sun_dict setObject:[
NSNumber numberWithFloat:defaultSunFlare] forKey:@"corona_flare"];
1513 dict_object = [
systeminfo objectForKey:KEY_SUNNAME];
1514 if (dict_object !=
nil) {
1515 [
sun_dict setObject:dict_object forKey:KEY_SUNNAME];
1517#ifdef OO_DUMP_PLANETINFO
1518 OOLog(
@"planetinfo.record",
@"corona_flare = %f", [sun_dict oo_floatForKey:
@"corona_flare"]);
1519 OOLog(
@"planetinfo.record",
@"corona_hues = %f", [sun_dict oo_floatForKey:
@"corona_hues"]);
1520 OOLog(
@"planetinfo.record",
@"sun_color = %@", [bgcolor descriptionComponents]);
1522 a_sun = [[
OOSunEntity alloc] initSunWithColor:bgcolor andDictionary:sun_dict];
1543 vf = [
systeminfo oo_vectorForKey:@"station_vector"];
1544#ifdef OO_DUMP_PLANETINFO
1545 OOLog(
@"planetinfo.record",
@"station_vector = %.3f %.3f %.3f", vf.
x, vf.
y, vf.
z);
1550 stationDesc = [
systeminfo oo_stringForKey:@"station" defaultValue:@"coriolis"];
1551#ifdef OO_DUMP_PLANETINFO
1552 OOLog(
@"planetinfo.record",
@"station = %@", stationDesc);
1555 a_station = (
StationEntity*)[
self newShipWithRole:stationDesc];
1567 if (![a_station isStation] || ![a_station validForAddToUniverse]) {
1568 if (a_station ==
nil) {
1570 OOLog(
@"universe.setup.badStation",
@"Failed to set up a ship for role \"%@\
" as system station, trying again with \"%@\".", stationDesc, defaultStationDesc);
1572 OOLog(
@"universe.setup.badStation",
@"***** ERROR: Attempt to use non-station ship of type \"%@\
" for role \"%@\" as system station, trying again with \"%@\".", [a_station name], stationDesc, defaultStationDesc);
1575 stationDesc = defaultStationDesc;
1576 a_station = (
StationEntity*)[
self newShipWithRole:stationDesc];
1578 if (![a_station isStation] || ![a_station validForAddToUniverse]) {
1579 if (a_station ==
nil) {
1580 OOLog(
@"universe.setup.badStation",
@"On retry, failed to set up a ship for role \"%@\
" as system station. Trying to fall back to built-in Coriolis station.", stationDesc);
1582 OOLog(
@"universe.setup.badStation",
@"***** ERROR: On retry, rolled non-station ship of type \"%@\
" for role \"%@\". Non-station ships should not have this role! Trying to fall back to built-in Coriolis station.", [a_station name], stationDesc);
1586 a_station = (
StationEntity*)[
self newShipWithName:
@"coriolis-station"];
1587 if (![a_station isStation] || ![a_station validForAddToUniverse]) {
1588 OOLog(
@"universe.setup.badStation",
@"%@",
@"Could not create built-in Coriolis station! Generating a stationless system.");
1594 if (a_station !=
nil) {
1626 BOOL sunGoneNova = [
systeminfo oo_boolForKey:@"sun_gone_nova"];
1632 double min_safe_dist2 = 6000000.0 * 6000000.0;
1652 if ([
PLAYER status] != STATUS_START_GAME) {
1653 NSString* populator = [
systeminfo oo_stringForKey:@"populator" defaultValue:(sunGoneNova) ? @"novaSystemWillPopulate" : @"systemWillPopulate"];
1654 [system_repopulator release];
1655 system_repopulator = [[
systeminfo oo_stringForKey:@"repopulator" defaultValue:(sunGoneNova) ? @"novaSystemWillRepopulate" : @"systemWillRepopulate"] retain];
1658 [PLAYER doWorldScriptEvent:OOJSIDFromString(populator) inContext:context withArguments:NULL count:0 timeLimit:kOOJSLongTimeLimit];
1666 NSArray* script_actions = [
systeminfo oo_arrayForKey:@"script_actions"];
1667 if (script_actions !=
nil) {
1668 OOStandardsDeprecated([NSString stringWithFormat:
@"The script_actions system info key is deprecated for %@.", [
self getSystemName:
systemID]]);
1671 [PLAYER runUnsanitizedScriptActions:script_actions
1672 allowingAIMethods:NO
1673 withContextName:@"<system script_actions>"
1684 [populatorSettings release];
1693- (void)setPopulatorSetting:(NSString*)key to:(NSDictionary*)setting
1695 if (setting ==
nil) {
1696 [populatorSettings removeObjectForKey:key];
1698 [populatorSettings setObject:setting forKey:key];
1707- (void)populateSystemFromDictionariesWithSun:(
OOSunEntity*)sun andPlanet:(OOPlanetEntity*)planet
1710 NSArray* blocks = [populatorSettings allValues];
1711 NSArray* sortedBlocks = [
blocks sortedArrayUsingFunction:populatorPrioritySort context:nil];
1712 NSDictionary* populator =
nil;
1714 uint32_t i, locationSeed, groupCount, rndvalue;
1717 NSString* locationCode =
nil;
1719 foreach (populator, sortedBlocks) {
1726 locationSeed = [
populator oo_unsignedIntForKey:@"locationSeed" defaultValue:0];
1727 groupCount = [
populator oo_unsignedIntForKey:@"groupCount" defaultValue:1];
1729 for (i = 0; i < groupCount; i++) {
1730 locationCode = [
populator oo_stringForKey:@"location" defaultValue:@"COORDINATES"];
1731 if ([locationCode isEqualToString:
@"COORDINATES"]) {
1732 location = [
populator oo_hpvectorForKey:@"coordinates" defaultValue:kZeroHPVector];
1734 if (locationSeed != 0) {
1755 if (locationSeed != 0) {
1761 pdef = [
populator objectForKey:@"callbackObj"];
1786 if ([code isEqualToString:
@"WITCHPOINT"] ||
sun ==
nil ||
planet ==
nil || [
sun goneNova]) {
1791 if ([code isEqualToString:
@"LANE_WPS"]) {
1796 double total = l1 + l2 + l3;
1797 float choice =
randf();
1798 if (choice < l1 / total) {
1800 }
else if (choice < (l1 + l2) / total) {
1805 }
else if ([code isEqualToString:
@"LANE_WP"]) {
1807 }
else if ([code isEqualToString:
@"LANE_WS"]) {
1809 }
else if ([code isEqualToString:
@"LANE_PS"]) {
1811 }
else if ([code isEqualToString:
@"STATION_AEGIS"]) {
1816 }
else if ([code isEqualToString:
@"PLANET_ORBIT_LOW"]) {
1818 }
else if ([code isEqualToString:
@"PLANET_ORBIT"]) {
1820 }
else if ([code isEqualToString:
@"PLANET_ORBIT_HIGH"]) {
1822 }
else if ([code isEqualToString:
@"STAR_ORBIT_LOW"]) {
1824 }
else if ([code isEqualToString:
@"STAR_ORBIT"]) {
1826 }
else if ([code isEqualToString:
@"STAR_ORBIT_HIGH"]) {
1828 }
else if ([code isEqualToString:
@"TRIANGLE"]) {
1843 }
else if ([code isEqualToString:
@"INNER_SYSTEM"]) {
1850 }
else if ([code isEqualToString:
@"INNER_SYSTEM_OFFPLANE"]) {
1852 }
else if ([code isEqualToString:
@"OUTER_SYSTEM"]) {
1856 }
else if ([code isEqualToString:
@"OUTER_SYSTEM_OFFPLANE"]) {
1866- (void)setAmbientLightLevel:(
float)newValue
1868 NSAssert(
UNIVERSE !=
nil,
@"Attempt to set ambient light level with a non yet existent universe.");
1899 GLfloat sun_pos[] = { 0.0, 0.0, 0.0, 1.0 };
1900 GLfloat sun_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
1910 OOGL(glLightfv(GL_LIGHT1, GL_AMBIENT, sun_ambient));
1930 OOGL(glLightfv(GL_LIGHT1, GL_AMBIENT, sun_ambient));
1935 OOGL(glLightfv(GL_LIGHT1, GL_POSITION, sun_pos));
1975 if (rfactor != 0.0) {
1977 launchPos.
x += 2 * rfactor * (
randf() - 0.5);
1978 launchPos.
y += 2 * rfactor * (
randf() - 0.5);
1979 launchPos.
z += 2 * rfactor * (
randf() - 0.5);
1988 if ([ship hasRole:
@"cargopod"])
1992 if (![ship crew] && ![ship isUnpiloted])
1997 if ([ship scanClass] == CLASS_NOT_SET) {
2007- (void)addShipWithRole:(NSString*)desc nearRouteOneAt:(
double)route_fraction
2021- (
HPVector)coordinatesForPosition:(
HPVector)pos withCoordinateSystem:(NSString*)system returningScalar:(GLfloat*)my_scalar
2058 NSString* l_sys = [
system lowercaseString];
2059 if ([l_sys length] != 3)
2061 OOPlanetEntity* the_planet = [
self planet];
2063 if (the_planet ==
nil || the_sun ==
nil || [l_sys isEqualToString:
@"abs"]) {
2069 HPVector p_pos = the_planet->position;
2072 const char* c_sys = [
l_sys UTF8String];
2130 GLfloat scale = 1.0;
2156 result.
x += scale * (pos.
x * i.
x + pos.
y * j.
x + pos.
z * k.
x);
2157 result.
y += scale * (pos.
x * i.
y + pos.
y * j.
y + pos.
z * k.
y);
2158 result.
z += scale * (pos.
x * i.
z + pos.
y * j.
z + pos.
z * k.
z);
2163- (NSString*)expressPosition:(
HPVector)pos inCoordinateSystem:(NSString*)system
2166 return [
NSString stringWithFormat:@"%@ %.2f %.2f %.2f", system, result.x, result.y, result.z];
2171 NSString* l_sys = [
system lowercaseString];
2172 if ([l_sys length] != 3)
2174 OOPlanetEntity* the_planet = [
self planet];
2176 if (the_planet ==
nil || the_sun ==
nil || [l_sys isEqualToString:
@"abs"]) {
2180 HPVector p_pos = the_planet->position;
2183 const char* c_sys = [
l_sys UTF8String];
2241 GLfloat scale = 1.0;
2267 scale * (r_pos.
x * j.
x + r_pos.
y * j.
y + r_pos.
z * j.
z),
2268 scale * (r_pos.
x * k.
x + r_pos.
y * k.
y + r_pos.
z * k.
z));
2273- (
HPVector)coordinatesFromCoordinateSystemString:(NSString*)system_x_y_z
2276 if ([tokens
count] != 4) {
2284- (BOOL)addShipWithRole:(NSString*)desc nearPosition:(
HPVector)pos withCoordinateSystem:(NSString*)system
2287 GLfloat scalar = 1.0;
2290 GLfloat rfactor = scalar;
2296 return ([
self addShipWithRole:desc launchPos:launchPos rfactor:rfactor] !=
nil);
2299- (BOOL)addShips:(
int)howMany withRole:(NSString*)desc atPosition:(
HPVector)pos withCoordinateSystem:(NSString*)system
2302 GLfloat scalar = 1.0;
2304 GLfloat distance_from_center = 0.0;
2308 int scale_up_after = 0;
2309 int current_shell = 0;
2310 GLfloat walk_factor = 2.0;
2311 while (i < howMany) {
2320 int limit_count = 8;
2325 v_from_center.
x += walk_factor * (
randf() - 0.5);
2326 v_from_center.
y += walk_factor * (
randf() - 0.5);
2327 v_from_center.
z += walk_factor * (
randf() - 0.5);
2328 }
while ((v_from_center.
x == 0.0) && (v_from_center.
y == 0.0) && (v_from_center.
z == 0.0));
2331 ship_pos =
make_HPvector(launchPos.
x + distance_from_center * v_from_center.
x,
2332 launchPos.
y + distance_from_center * v_from_center.
y,
2333 launchPos.
z + distance_from_center * v_from_center.
z);
2338 while (safe && (j >= current_shell)) {
2339 safe = (safe && (
HPdistance2(ship_pos, ship_positions[j]) > safe_distance2));
2347 distance_from_center += sqrt(safe_distance2);
2354 [
ship setScanClass:scanClass == CLASS_NOT_SET ? CLASS_NEUTRAL : scanClass];
2362 ship_positions[
i] = ship_pos;
2364 if (i > scale_up_after) {
2366 scale_up_after += 1 + 2 * i;
2367 distance_from_center += sqrt(safe_distance2);
2373- (BOOL)addShips:(
int)howMany withRole:(NSString*)desc nearPosition:(
HPVector)pos withCoordinateSystem:(NSString*)system
2376 GLfloat scalar = 1.0;
2378 GLfloat rfactor = scalar;
2390- (BOOL)addShips:(
int)howMany withRole:(NSString*)desc nearPosition:(
HPVector)pos withCoordinateSystem:(NSString*)system withinRadius:(GLfloat)radius
2393 GLfloat scalar = 1.0;
2395 GLfloat rfactor = radius;
2405- (BOOL)addShips:(
int)howMany withRole:(NSString*)desc intoBoundingBox:(
BoundingBox)bbox
2411 int h0 = howMany / 2;
2412 int h1 = howMany - h0;
2414 GLfloat lx = bbox.
max.
x - bbox.
min.
x;
2415 GLfloat ly = bbox.
max.
y - bbox.
min.
y;
2416 GLfloat lz = bbox.
max.
z - bbox.
min.
z;
2419 if ((lx > lz) && (lx > ly))
2421 bbox0.
min.
x += 0.5 * lx;
2422 bbox1.
max.
x -= 0.5 * lx;
2426 bbox0.
min.
y += 0.5 * ly;
2427 bbox1.
max.
y -= 0.5 * ly;
2430 bbox0.
min.
z += 0.5 * lz;
2431 bbox1.
max.
z -= 0.5 * lz;
2435 return ([
self addShips:h0 withRole:desc intoBoundingBox:bbox0] && [
self addShips:h1 withRole:desc intoBoundingBox:bbox1]);
2444 return ([
self addShipWithRole:desc launchPos:pos rfactor:0.0] !=
nil);
2447- (BOOL)spawnShip:(NSString*)shipdesc
2451 OOStandardsDeprecated([NSString stringWithFormat:
@"'spawn' via legacy script is deprecated as a way of adding ships for %@", shipdesc]);
2454 NSDictionary* shipdict =
nil;
2457 if (shipdict ==
nil)
2466 NSDictionary* spawndict = [
shipdict oo_dictionaryForKey:@"spawn"];
2468 NSString* positionString =
nil;
2471 positionString = [
spawndict oo_stringForKey:@"position"];
2472 if (positionString !=
nil) {
2473 if ([positionString hasPrefix:
@"abs "] && ([
self planet] !=
nil || [
self sun] !=
nil)) {
2474 OOLogWARN(
@"script.deprecated",
@"setting %@ for %@ '%@' in 'abs' inside .plists can cause compatibility issues across Oolite versions. Use coordinates relative to main system objects instead.",
@"position",
@"entity", shipdesc);
2481 OOLogERR(
@"universe.spawnShip.error",
@"***** ERROR: failed to find a spawn position for ship %@.", shipdesc);
2486 positionString = [
spawndict oo_stringForKey:@"facing_position"];
2487 if (positionString !=
nil) {
2488 if ([positionString hasPrefix:
@"abs "] && ([
self planet] !=
nil || [
self sun] !=
nil)) {
2489 OOLogWARN(
@"script.deprecated",
@"setting %@ for %@ '%@' in 'abs' inside .plists can cause compatibility issues across Oolite versions. Use coordinates relative to main system objects instead.",
@"facing_position",
@"entity", shipdesc);
2517- (void)witchspaceShipWithPrimaryRole:(NSString*)role
2521 NSDictionary* systeminfo =
nil;
2525 government = [
systeminfo oo_unsignedCharForKey:KEY_GOVERNMENT];
2530 if (ship && [ship hasRole:
@"cargopod"]) {
2535 if (([ship scanClass] == CLASS_NO_DRAW) || ([ship scanClass] == CLASS_NOT_SET))
2537 if ([role isEqual:
@"trader"]) {
2539 if ([ship hasRole:
@"sunskim-trader"] &&
randf() < 0.25)
2547 if (([ship pendingEscortCount] > 0) && ((
Ranrot() % 7) < government))
2550 [
ship setPendingEscortCount:(nx > 0) ? nx : 0];
2553 if ([role isEqual:
@"pirate"]) {
2555 [
ship setBounty:(Ranrot() & 7) + (Ranrot() & 7) + ((randf() < 0.05) ? 63 : 23)
withReason:kOOLegalStatusReasonSetup];
2557 if ([ship crew] ==
nil && ![ship isUnpiloted])
2596 [
vis setPosition:pos];
2597 [
vis setOrientation:OORandomQuaternion()];
2613 if (radius == NSNotFound) {
2614 GLfloat scalar = 1.0;
2617 GLfloat rfactor = scalar;
2634 if ([ship hasRole:
@"cargopod"])
2637 if (scanClass == CLASS_NOT_SET) {
2638 scanClass = CLASS_NEUTRAL;
2642 if ([ship crew] ==
nil && ![ship isUnpiloted]) {
2650 BOOL trader = [
role isEqualToString:@"trader"];
2653 if (
randf() > 0.5f) {
2658 if (pendingEscortCount > 0) {
2660 if ((
Ranrot() % 7) < government)
2662 int nx = pendingEscortCount - 2 * (1 + (
Ranrot() & 3));
2663 [
ship setPendingEscortCount:(nx > 0) ? nx : 0];
2675 if ([ship hasRole:
@"sunskim-trader"] &&
randf() < 0.25) {
2681 }
else if ([role isEqual:
@"pirate"]) {
2682 [
ship setBounty:(Ranrot() & 7) + (Ranrot() & 7) + ((randf() < 0.05) ? 63 : 23)
withReason:kOOLegalStatusReasonSetup];
2698- (NSArray*)addShipsAt:(
HPVector)pos withRole:(NSString*)role quantity:(
unsigned)count withinRadius:(GLfloat)radius asGroup:(BOOL)isGroup
2702 NSMutableArray* ships = [
NSMutableArray arrayWithCapacity:count];
2716 [
ships addObject:ship];
2720 if ([ships
count] == 0)
2723 return [[
ships copy] autorelease];
2728- (NSArray*)addShipsToRoute:(NSString*)route withRole:(NSString*)role quantity:(
unsigned)count routeFraction:(
double)routeFraction asGroup:(BOOL)isGroup
2730 NSMutableArray* ships = [
NSMutableArray arrayWithCapacity:count];
2736 if ([route isEqualToString:
@"pw"] || [route isEqualToString:
@"sw"] || [route isEqualToString:
@"ps"]) {
2737 routeFraction = 1.0f - routeFraction;
2741 if ([route isEqualTo:
@"wp"] || [route isEqualTo:
@"pw"]) {
2747 radius = [
entity radius];
2748 }
else if ([route isEqualTo:
@"ws"] || [route isEqualTo:
@"sw"]) {
2750 entity = [
self sun];
2754 radius = [
entity radius];
2755 }
else if ([route isEqualTo:
@"sp"] || [route isEqualTo:
@"ps"]) {
2756 entity = [
self sun];
2760 double radius0 = [
entity radius];
2766 radius = [
entity radius];
2771 }
else if ([route isEqualTo:
@"st"]) {
2791 [
ships addObject:ship];
2796 if ([ships
count] == 0)
2800 return [[
ships copy] autorelease];
2803- (BOOL)roleIsPirateVictim:(NSString*)role
2808- (BOOL)role:(NSString*)role isInCategory:(NSString*)category
2810 NSSet* categoryInfo = [roleCategories objectForKey:category];
2811 if (categoryInfo ==
nil) {
2825 if ([my_target isWormhole]) {
2827 }
else if ([[[my_ship getAI] state] isEqualToString:
@"ENTER_WORMHOLE"]) {
2837 if ([
PLAYER status] != STATUS_ENTERING_WITCHSPACE && [
PLAYER status] != STATUS_EXITING_WITCHSPACE) {
2847 if ([e2 isShip] && [(
ShipEntity*)e2 hasPrimaryRole:
@"buoy-witchpoint"]) {
2873 colorDesc = [[
self globalSettings] objectForKey:@"hyperspace_tunnel_color_1"];
2874 if (colorDesc !=
nil) {
2879 OOLogWARN(
@"hyperspaceTunnel.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
2882 colorDesc = [[
self globalSettings] objectForKey:@"hyperspace_tunnel_color_2"];
2883 if (colorDesc !=
nil) {
2888 OOLogWARN(
@"hyperspaceTunnel.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
2892 GLfloat startAngle = 0;
2893 GLfloat aspectRatio = 1;
2896 NSDictionary* info = [[PLAYER dockedStation] shipInfoDictionary];
2897 sides = [
info oo_unsignedIntForKey:@"tunnel_corners" defaultValue:4];
2898 startAngle = [
info oo_floatForKey:@"tunnel_start_angle" defaultValue:45.0f];
2899 aspectRatio = [
info oo_floatForKey:@"tunnel_aspect_ratio" defaultValue:2.67f];
2902 for (i = 1; i < 11; i++) {
2916 if (forDocking && ![[
PLAYER dockedStation] hasBreakPattern]) {
2931- (void)setWitchspaceBreakPattern:(BOOL)newValue
2941- (void)setDockingClearanceProtocolActive:(BOOL)newValue
2953 if (![[[registry shipInfoForKey:stationKey] allKeys] containsObject:
@"requires_docking_clearance"]) {
2970- (void)setupIntroFirstGo:(BOOL)justCobra
3000 NSArray* subList =
nil;
3002 if ([[[subList oo_dictionaryAtIndex:0] oo_stringForKey:
kOODemoShipClass] isEqualToString:
@"ship"]) {
3004 NSDictionary* shipEntry =
nil;
3005 foreach (shipEntry, subList) {
3006 if ([[shipEntry oo_stringForKey:
kOODemoShipKey] isEqualToString:
@"cobra3-trader"]) {
3016 ship = [
self newShipWithName:[[[demo_ships oo_arrayAtIndex:demo_ship_index] oo_dictionaryAtIndex:demo_ship_subindex] oo_stringForKey:kOODemoShipKey]
usePlayerProxy:NO];
3025 [
ship setPositionX:0.0f
y:0.0f
z:DEMO2_VANISHING_DISTANCE * ship->collision_radius * 0.01];
3035 if ([ship pendingEscortCount] > 0)
3059 return [[
demo_ships oo_arrayAtIndex:demo_ship_index] oo_dictionaryAtIndex:demo_ship_subindex];
3068 [
gui setTabStops:tab_stops];
3077 NSString* field1 =
nil;
3078 NSString* field2 =
nil;
3079 NSString* field3 =
nil;
3080 NSString*
override =
nil;
3083 for (NSUInteger i = 1; i <= 26; i++) {
3084 [
gui setText:@"" forRow:i];
3088 override = [
librarySettings oo_stringForKey:kOODemoShipClass defaultValue:@"ship"];
3093 override = [
librarySettings oo_stringForKey:kOODemoShipSummary defaultValue:nil];
3094 if (
override !=
nil) {
3099 [
gui setArray:[
NSArray arrayWithObjects:field1, field2, field3, nil] forRow:1];
3103 if (![librarySettings oo_boolForKey:
kOODemoShipShipData defaultValue:[[librarySettings oo_stringForKey:
kOODemoShipClass defaultValue:
@"ship"] isEqualToString:
@"ship"]]) {
3108 override = [
librarySettings oo_stringForKey:kOODemoShipSpeed defaultValue:nil];
3109 if (
override !=
nil) {
3110 if ([
override length] == 0) {
3113 field1 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-speed-custom"), OOExpand(override)];
3119 override = [
librarySettings oo_stringForKey:kOODemoShipTurnRate defaultValue:nil];
3120 if (
override !=
nil) {
3121 if ([
override length] == 0) {
3124 field2 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-turn-custom"), OOExpand(override)];
3130 override = [
librarySettings oo_stringForKey:kOODemoShipCargo defaultValue:nil];
3131 if (
override !=
nil) {
3132 if ([
override length] == 0) {
3135 field3 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-cargo-custom"), OOExpand(override)];
3141 [
gui setArray:[
NSArray arrayWithObjects:field1, field2, field3, nil] forRow:3];
3144 override = [
librarySettings oo_stringForKey:kOODemoShipGenerator defaultValue:nil];
3145 if (
override !=
nil) {
3146 if ([
override length] == 0) {
3149 field1 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-generator-custom"), OOExpand(override)];
3155 override = [
librarySettings oo_stringForKey:kOODemoShipShields defaultValue:nil];
3156 if (
override !=
nil) {
3157 if ([
override length] == 0) {
3160 field2 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-shields-custom"), OOExpand(override)];
3166 override = [
librarySettings oo_stringForKey:kOODemoShipWitchspace defaultValue:nil];
3167 if (
override !=
nil) {
3168 if ([
override length] == 0) {
3171 field3 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-witchspace-custom"), OOExpand(override)];
3177 [
gui setArray:[
NSArray arrayWithObjects:field1, field2, field3, nil] forRow:4];
3180 override = [
librarySettings oo_stringForKey:kOODemoShipWeapons defaultValue:nil];
3181 if (
override !=
nil) {
3182 if ([
override length] == 0) {
3185 field1 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-weapons-custom"), OOExpand(override)];
3191 override = [
librarySettings oo_stringForKey:kOODemoShipTurrets defaultValue:nil];
3192 if (
override !=
nil) {
3193 if ([
override length] == 0) {
3196 field2 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-turrets-custom"), OOExpand(override)];
3202 override = [
librarySettings oo_stringForKey:kOODemoShipSize defaultValue:nil];
3203 if (
override !=
nil) {
3204 if ([
override length] == 0) {
3207 field3 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-size-custom"), OOExpand(override)];
3213 [
gui setArray:[
NSArray arrayWithObjects:field1, field2, field3, nil] forRow:5];
3216 override = [
librarySettings oo_stringForKey:kOODemoShipDescription defaultValue:nil];
3217 if (
override !=
nil) {
3218 [
gui addLongText:OOExpand(override) startingAtRow:descRow align:GUI_ALIGN_LEFT];
3222 field1 = [
NSString stringWithFormat:@"<-- %@", OOShipLibraryCategoryPlural([[[
demo_ships objectAtIndex:((demo_ship_index + [
demo_ships count] - 1) % [
demo_ships count])] objectAtIndex:0] oo_stringForKey:kOODemoShipClass])];
3224 field3 = [
NSString stringWithFormat:@"%@ -->", OOShipLibraryCategoryPlural([[[
demo_ships objectAtIndex:((demo_ship_index + 1) % [
demo_ships count])] objectAtIndex:0] oo_stringForKey:kOODemoShipClass])];
3226 [
gui setArray:[
NSArray arrayWithObjects:field1, field2, field3, nil] forRow:19];
3230 NSArray* subList = [
demo_ships objectAtIndex:demo_ship_index];
3231 NSUInteger i, start = demo_ship_subindex - (demo_ship_subindex % 5);
3232 NSUInteger end = start + 4;
3233 if (end >= [subList
count]) {
3239 for (i = start; i <= end; i++) {
3240 field2 = [[
subList objectAtIndex:i] oo_stringForKey:kOODemoShipName];
3241 [
gui setArray:[
NSArray arrayWithObjects:field1, field2, field3, nil] forRow:row];
3242 if (i == demo_ship_subindex) {
3252 [
gui setArray:[
NSArray arrayWithObjects:field1, field2, field3, nil] forRow:20];
3255 if (end < [subList
count] - 1) {
3256 [
gui setArray:[
NSArray arrayWithObjects:field1, field2, field3, nil] forRow:26];
3264 NSUInteger subcount = [[demo_ships objectAtIndex:demo_ship_index] count];
3312 if ([role isEqualToString:
@""]) {
3316 float range = 1000000;
3322 if ([[
station primaryRole] isEqualToString:role]) {
3360 return [allStations allObjects];
3380 if (playerStatus == STATUS_START_GAME)
3384 if (theStation !=
nil)
3392 while (beaconShip) {
3408- (void)setFirstBeacon:(
Entity<OOBeaconEntity>*)beacon
3410 if (beacon != [
self firstBeacon]) {
3411 [
beacon setPrevBeacon:nil];
3415 _firstBeacon = [
beacon weakRetain];
3424- (void)setLastBeacon:(
Entity<OOBeaconEntity>*)beacon
3426 if (beacon != [
self lastBeacon]) {
3427 [
beacon setNextBeacon:nil];
3431 _lastBeacon = [
beacon weakRetain];
3435- (void)setNextBeacon:(
Entity<OOBeaconEntity>*)beaconShip
3437 if ([beaconShip isBeacon]) {
3442 OOLog(
@"universe.beacon.error",
@"***** ERROR: Universe setNextBeacon '%@'. The ship has no beacon code set.", beaconShip);
3446- (void)clearBeacon:(
Entity<OOBeaconEntity>*)beaconShip
3450 if ([beaconShip isBeacon]) {
3455 }
else if ([
self lastBeacon] == beaconShip) {
3472- (void)defineWaypoint:(NSDictionary*)definition forKey:(NSString*)key
3475 BOOL preserveCompass = NO;
3476 waypoint = [waypoints objectForKey:key];
3477 if (waypoint !=
nil) {
3478 if ([
PLAYER compassTarget] == waypoint) {
3479 preserveCompass = YES;
3482 [waypoints removeObjectForKey:key];
3484 if (definition !=
nil) {
3486 if (waypoint !=
nil) {
3488 [waypoints setObject:waypoint forKey:key];
3489 if (preserveCompass) {
3490 [PLAYER setCompassTarget:waypoint];
3491 [PLAYER setNextBeacon:waypoint];
3502- (void)setSkyColorRed:(GLfloat)red green:(GLfloat)green blue:(GLfloat)blue alpha:(GLfloat)alpha
3522#define PROFILE_SHIP_SELECTION 0
3524- (BOOL)canInstantiateShip:(NSString*)shipKey
3526 NSDictionary* shipInfo =
nil;
3527 NSArray* conditions =
nil;
3528 NSString* condition_script =
nil;
3531 condition_script = [
shipInfo oo_stringForKey:@"condition_script"];
3532 if (condition_script !=
nil) {
3534 if (condScript !=
nil)
3538 BOOL allow_instantiation = NO;
3545 count:sizeof args / sizeof *args
3555 if (OK && !allow_instantiation) {
3564 conditions = [
shipInfo oo_arrayForKey:@"conditions"];
3565 if (conditions ==
nil)
3569 return [PLAYER scriptTestConditions:conditions];
3572- (NSString*)randomShipKeyForRoleRespectingConditions:(NSString*)role
3577 NSString* shipKey =
nil;
3580#if PROFILE_SHIP_SELECTION
3581 static unsigned long profTotal = 0, profSlowPath = 0;
3587 if ([
self canInstantiateShip:shipKey])
3597#if PROFILE_SHIP_SELECTION
3599 if ((profSlowPath % 10) == 0)
3601 OOLog(
@"shipRegistry.selection.profile",
@"Hit slow path in ship selection for role \"%@\
", having selected ship \"%@\". Now %zu of %zu on slow path (%f%%).", role, shipKey, profSlowPath, profTotal, ((
double)profSlowPath) / ((
double)profTotal) * 100.0f);
3607 while ([pset
count] > 0) {
3610 if ([
self canInstantiateShip:shipKey])
3628 NSString* shipKey =
nil;
3629 NSDictionary* shipInfo =
nil;
3630 NSString* autoAI =
nil;
3633 if (shipKey !=
nil) {
3639 if ([shipInfo oo_fuzzyBooleanForKey:
@"auto_ai" defaultValue:YES]) {
3642 if (autoAI !=
nil) {
3646 if ([role isEqualToString:
@"pirate"])
3648 if ([role isEqualToString:
@"trader"])
3650 if ([role isEqualToString:
@"police"])
3652 if ([role isEqualToString:
@"interceptor"]) {
3657 if ([role isEqualToString:
@"thargoid"])
3672 NSDictionary* effectDict =
nil;
3676 if (effectDict ==
nil)
3682 @catch (NSException* exception) {
3684 OOLog(
kOOLogException,
@"***** Oolite Exception : '%@' in [Universe newVisualEffectWithName: %@ ] *****", [exception reason], effectKey);
3694- (
ShipEntity*)newSubentityWithName:(NSString*)shipKey andScaleFactor:(
float)scale
3699- (
ShipEntity*)newShipWithName:(NSString*)shipKey usePlayerProxy:(BOOL)usePlayerProxy
3704- (
ShipEntity*)newShipWithName:(NSString*)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity
3709- (
ShipEntity*)newShipWithName:(NSString*)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity andScaleFactor:(
float)scale
3713 NSDictionary* shipDict =
nil;
3717 if (shipDict ==
nil)
3720 volatile Class shipClass =
nil;
3725 if (usePlayerProxy && shipClass == [
ShipEntity class]) {
3731 if (scale != 1.0f) {
3732 NSMutableDictionary* mShipDict = [
shipDict mutableCopy];
3733 [
mShipDict setObject:[
NSNumber numberWithFloat:scale] forKey:@"model_scale_factor"];
3734 shipDict = [
NSDictionary dictionaryWithDictionary:mShipDict];
3737 ship = [[
shipClass alloc] initWithKey:shipKey definition:shipDict];
3739 @catch (NSException* exception) {
3741 OOLog(
kOOLogException,
@"***** Oolite Exception : '%@' in [Universe newShipWithName: %@ ] *****", [exception reason], shipKey);
3748 if ([ship hasRole:shipKey])
3756- (
DockEntity*)newDockWithName:(NSString*)shipDataKey andScaleFactor:(
float)scale
3760 NSDictionary* shipDict =
nil;
3764 if (shipDict ==
nil)
3768 if (scale != 1.0f) {
3769 NSMutableDictionary* mShipDict = [
shipDict mutableCopy];
3770 [
mShipDict setObject:[
NSNumber numberWithFloat:scale] forKey:@"model_scale_factor"];
3771 shipDict = [
NSDictionary dictionaryWithDictionary:mShipDict];
3774 dock = [[
DockEntity alloc] initWithKey:shipDataKey definition:shipDict];
3776 @catch (NSException* exception) {
3778 OOLog(
kOOLogException,
@"***** Oolite Exception : '%@' in [Universe newDockWithName: %@ ] *****", [exception reason], shipDataKey);
3785 if ([dock hasRole:shipDataKey])
3798- (Class)shipClassForShipDictionary:(NSDictionary*)dict
3805 BOOL isStation = NO;
3806 NSString* shipRoles = [
dict oo_stringForKey:@"roles"];
3808 if (shipRoles !=
nil) {
3809 isStation = [
shipRoles rangeOfString:@"station"].location != NSNotFound ||
3810 [
shipRoles rangeOfString:@"carrier"].location != NSNotFound;
3814 isStation = [
dict oo_boolForKey:@"isCarrier" defaultValue:isStation];
3815 isStation = [
dict oo_boolForKey:@"is_carrier" defaultValue:isStation];
3822- (NSString*)defaultAIForRole:(NSString*)role
3824 return [autoAIMap oo_stringForKey:role];
3839 NSString* itemType = [
itemData oo_stringAtIndex:EQUIPMENT_KEY_INDEX];
3841 if ([itemType isEqual:eq_key]) {
3842 return [
itemData oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
3856 if ([cargoObj isTemplateCargoPod]) {
3857 return [UNIVERSE cargoPodFromTemplate:cargoObj];
3868 OOCargoQuantity co_amount = [UNIVERSE getRandomAmountOfCommodity:co_type];
3871 container = [UNIVERSE newShipWithRole:co_type];
3873 if (container ==
nil) {
3874 container = [UNIVERSE newShipWithRole:@"cargopod"];
3880- (NSArray*)getContainersOfGoods:(
OOCargoQuantity)how_many scarce:(BOOL)scarce legal:(BOOL)legal
3886 NSMutableArray* accumulator = [
NSMutableArray arrayWithCapacity:how_many];
3892 NSString* goodsKey =
nil;
3894 foreach (goodsKey, goodsKeys) {
3911 quantities[
i++] = q;
3912 total_quantity += q;
3915 for (i = 0; i < how_many; i++) {
3916 NSUInteger co_type = 0;
3919 if (total_quantity) {
3920 qr = 1 + (
Ranrot() % total_quantity);
3923 NSAssert((NSUInteger)co_type < commodityCount,
@"Commodity type index out of range.");
3931 if (container !=
nil) {
3934 OOLog(
@"universe.createContainer.failed",
@"***** ERROR: failed to find a container to fill with %@ (%zu).", [goodsKeys oo_stringAtIndex:co_type], co_type);
3937 return [
NSArray arrayWithArray:accumulator];
3942 NSMutableArray* accumulator = [
NSMutableArray arrayWithCapacity:how_much];
3947 ShipEntity* container = [cargoPods objectForKey:commodity_name];
3948 while (how_much > 0) {
3952 OOLog(
@"universe.createContainer.failed",
@"***** ERROR: failed to find a container to fill with %@", commodity_name);
3957 return [
NSArray arrayWithArray:accumulator];
3965 if ([cargopod commodityType] ==
nil || ![cargopod commodityAmount]) {
3981 if (co_type ==
nil) {
3994 OOLog(
@"universe.commodityAmount.warning",
@"Commodity %@ has an unrecognised mass unit, assuming tonnes", co_type);
4011 NSString *unitDesc =
nil, *typeDesc =
nil;
4014 if (commodity ==
nil)
4018 if (co_amount == 1) {
4021 unitDesc =
DESC(
@"cargo-kilogram");
4024 unitDesc =
DESC(
@"cargo-gram");
4028 unitDesc =
DESC(
@"cargo-ton");
4034 unitDesc =
DESC(
@"cargo-kilograms");
4037 unitDesc =
DESC(
@"cargo-grams");
4041 unitDesc =
DESC(
@"cargo-tons");
4048 return [
NSString stringWithFormat:@"%d %@ %@", co_amount, unitDesc, typeDesc];
4077 [
result oo_setInteger:[PLAYER isSpeechOn]
4078 forKey:@"speechOn"];
4079 [
result oo_setBool:autoSave forKey:@"autosave"];
4080 [
result oo_setBool:wireframeGraphics forKey:@"wireframeGraphics"];
4081 [
result oo_setBool:doProcedurallyTexturedPlanets forKey:@"procedurallyTexturedPlanets"];
4087 [
result oo_setFloat:[
gameView hdrMaxBrightness] forKey:@"hdr-max-brightness"];
4088 [
result oo_setFloat:[
gameView hdrPaperWhiteBrightness] forKey:@"hdr-paperwhite-brightness"];
4089 [
result setObject:OOStringFromHDRToneMapper([
gameView hdrToneMapper]) forKey:@"hdr-tone-mapper"];
4094 forKey:@"sdr-tone-mapper"];
4096 [
result setObject:OOStringFromGraphicsDetail([
self detailLevel]) forKey:@"detailLevel"];
4098 NSString* desc =
@"UNDEFINED";
4101 desc =
@"MUSIC_OFF";
4107 desc =
@"MUSIC_ITUNES";
4110 [
result setObject:desc forKey:@"musicMode"];
4112 NSDictionary* gameWindow = [
NSDictionary dictionaryWithObjectsAndKeys:
4117 [
result setObject:gameWindow forKey:@"gameWindow"];
4119 [
result setObject:[PLAYER keyConfig] forKey:@"keyConfig"];
4121 return [[
result copy] autorelease];
4124- (void)useGUILightSource:(BOOL)GUILight
4129 OOGL(glEnable(GL_LIGHT0));
4130 OOGL(glDisable(GL_LIGHT1));
4132 OOGL(glEnable(GL_LIGHT1));
4133 OOGL(glDisable(GL_LIGHT0));
4143 OOGL(glEnable(GL_LIGHT1));
4149- (void)lightForEntity:(BOOL)isLit
4163 OOGL(glEnable(GL_LIGHT1));
4165 OOGL(glDisable(GL_LIGHT1));
4168 OOGL(glEnable(GL_LIGHT0));
4182 { 0.0f, 1.0f, 0.0f, 0.0f },
4183 { 0.0f, 0.0f, 1.0f, 0.0f },
4184 { 0.0f, 0.0f, 0.0f, 1.0f } } };
4186 { 0.0f, 1.0f, 0.0f, 0.0f },
4187 { 0.0f, 0.0f, -1.0f, 0.0f },
4188 { 0.0f, 0.0f, 0.0f, 1.0f } } };
4190 { 0.0f, 1.0f, 0.0f, 0.0f },
4191 { 1.0f, 0.0f, 0.0f, 0.0f },
4192 { 0.0f, 0.0f, 0.0f, 1.0f } } };
4194 { 0.0f, 1.0f, 0.0f, 0.0f },
4195 { -1.0f, 0.0f, 0.0f, 0.0f },
4196 { 0.0f, 0.0f, 0.0f, 1.0f } } };
4200 assert(outMatrix != NULL && outForward != NULL && outUp != NULL);
4217 case VIEW_STARBOARD:
4232 case VIEW_GUI_DISPLAY:
4233 case VIEW_BREAK_PATTERN:;
4263 frustum[0][0] = clip.
m[0][3] - clip.
m[0][0];
4264 frustum[0][1] = clip.
m[1][3] - clip.
m[1][0];
4265 frustum[0][2] = clip.
m[2][3] - clip.
m[2][0];
4266 frustum[0][3] = clip.
m[3][3] - clip.
m[3][0];
4276 frustum[1][0] = clip.
m[0][3] + clip.
m[0][0];
4277 frustum[1][1] = clip.
m[1][3] + clip.
m[1][0];
4278 frustum[1][2] = clip.
m[2][3] + clip.
m[2][0];
4279 frustum[1][3] = clip.
m[3][3] + clip.
m[3][0];
4289 frustum[2][0] = clip.
m[0][3] + clip.
m[0][1];
4290 frustum[2][1] = clip.
m[1][3] + clip.
m[1][1];
4291 frustum[2][2] = clip.
m[2][3] + clip.
m[2][1];
4292 frustum[2][3] = clip.
m[3][3] + clip.
m[3][1];
4302 frustum[3][0] = clip.
m[0][3] - clip.
m[0][1];
4303 frustum[3][1] = clip.
m[1][3] - clip.
m[1][1];
4304 frustum[3][2] = clip.
m[2][3] - clip.
m[2][1];
4305 frustum[3][3] = clip.
m[3][3] - clip.
m[3][1];
4315 frustum[4][0] = clip.
m[0][3] - clip.
m[0][2];
4316 frustum[4][1] = clip.
m[1][3] - clip.
m[1][2];
4317 frustum[4][2] = clip.
m[2][3] - clip.
m[2][2];
4318 frustum[4][3] = clip.
m[3][3] - clip.
m[3][2];
4328 frustum[5][0] = clip.
m[0][3] + clip.
m[0][2];
4329 frustum[5][1] = clip.
m[1][3] + clip.
m[1][2];
4330 frustum[5][2] = clip.
m[2][3] + clip.
m[2][2];
4331 frustum[5][3] = clip.
m[3][3] + clip.
m[3][2];
4341- (BOOL)viewFrustumIntersectsSphereAt:(
Vector)position withRadius:(GLfloat)radius
4345 for (p = 0; p < 6; p++) {
4358 OOLog(
@"universe.profile.draw",
@"%@",
@"Begin draw");
4375 int i, v_status, vdist;
4376 Vector view_dir, view_up;
4385 float aspect = viewSize.height / viewSize.width;
4392 [UNIVERSE setMainLightPosition:kZeroVector];
4396 for (i = 0; i < ent_count; i++) {
4403 if ([e isVisible]) {
4404 my_entities[
draw_count++] = [[
e retain] autorelease];
4414 OOGL(glClear(GL_COLOR_BUFFER_BIT));
4419 OOGL(glClearColor(0.0, 0.0, 0.0, 0.0));
4430 for (
int i = 0; i < draw_count; i++) {
4431 if ([my_entities[i] cameraRangeFront] > breakPlane) {
4434 if ([my_entities[i] cameraRangeBack] > breakPlane) {
4440 float distanceFactor = sqrt(1 + ([
gameView fov:YES] * [
gameView fov:YES] * (1.0 + 1.0 / (aspect * aspect))));
4442 for (vdist = 0; vdist <= 1; vdist++) {
4449 OOGLFrustum(-ratio, ratio, -aspect * ratio, aspect * ratio, nearPlane / distanceFactor, farPlane);
4451 OOGLFrustum(-3 * ratio / aspect / 4, 3 * ratio / aspect / 4, -3 * ratio / 4, 3 * ratio / 4, nearPlane / distanceFactor, farPlane);
4486 OOGL(glClear(GL_DEPTH_BUFFER_BIT));
4490 flipMatrix.
m[2][2] = -1;
4497 if (
EXPECT(!demoShipMode))
4520 OOGL([
self useGUILightSource:demoShipMode]);
4525 int furthest = draw_count - 1;
4529 double fog_scale, half_scale;
4530 GLfloat flat_ambdiff[4] = { 1.0, 1.0, 1.0, 1.0 };
4531 GLfloat mat_no[4] = { 0.0, 0.0, 0.0, 1.0 };
4540 OOLog(
@"universe.profile.draw",
@"%@",
@"Begin opaque pass");
4543 for (i = furthest; i >= nearest; i--) {
4544 drawthing = my_entities[
i];
4551 if (vdist == 0 && [drawthing cameraRangeFront] < nearPlane) {
4555 if (!((d_status == STATUS_COCKPIT_DISPLAY) ^ demoShipMode))
4559 OOGL(glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, flat_ambdiff));
4560 OOGL(glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_no));
4563 if (
EXPECT(drawthing != player)) {
4582 half_scale = fog_scale * 0.50;
4583 OOGL(glEnable(GL_FOG));
4584 OOGL(glFogi(GL_FOG_MODE, GL_LINEAR));
4586 OOGL(glFogf(GL_FOG_START, half_scale));
4587 OOGL(glFogf(GL_FOG_END, fog_scale));
4603 OOGL(glDisable(GL_FOG));
4607 if (!((d_status == STATUS_COCKPIT_DISPLAY) ^ demoShipMode))
4610 if (
EXPECT(drawthing != player)) {
4629 half_scale = fog_scale * 0.50;
4630 OOGL(glEnable(GL_FOG));
4631 OOGL(glFogi(GL_FOG_MODE, GL_LINEAR));
4633 OOGL(glFogf(GL_FOG_START, half_scale));
4634 OOGL(glFogf(GL_FOG_END, fog_scale));
4646 OOGL(glDisable(GL_FOG));
4669 if (hudSeparateRenderPass) {
4676 OOLog(
@"universe.profile.secondPassDraw",
@"%@",
@"Begin second pass draw");
4678 OOCheckOpenGLErrors(
@"Universe after drawing from custom framebuffer to screen framebuffer");
4679 OOLog(
@"universe.profile.secondPassDraw",
@"%@",
@"End second pass drawing");
4681 OOLog(
@"universe.profile.drawHUD",
@"%@",
@"Begin HUD drawing");
4686 OOLog(
@"universe.profile.draw",
@"%@",
@"Begin HUD");
4689 if (lineWidth < 1.0)
4691 if (lineWidth > 1.5)
4699 if ([theHUD deferredHudName] !=
nil) {
4707 static float sPrevHudAlpha = -1.0f;
4708 if ([theHUD isHidden]) {
4709 if (sPrevHudAlpha < 0.0f) {
4713 }
else if (sPrevHudAlpha >= 0.0f) {
4715 sPrevHudAlpha = -1.0f;
4720 case STATUS_ESCAPE_SEQUENCE:
4721 case STATUS_START_GAME:
4725 switch ([player guiScreen]) {
4738#if (defined(DEV_RELEASE))
4742 OOLog(
@"universe.profile.drawHUD",
@"%@",
@"End HUD drawing");
4755 @catch (NSException* exception) {
4758 if ([[exception name] hasPrefix:
@"Oolite"]) {
4761 OOLog(
kOOLogException,
@"***** Exception: %@ : %@ *****", [exception name], [exception reason]);
4767 OOLog(
@"universe.profile.draw",
@"%@",
@"End drawing");
4770 if (!hudSeparateRenderPass) {
4775 OOLog(
@"universe.profile.secondPassDraw",
@"%@",
@"Begin second pass draw");
4777 OOLog(
@"universe.profile.secondPassDraw",
@"%@",
@"End second pass drawing");
4784 NSSize viewSize = [
gameView backingViewSize];
4785 if ([
self useShaders]) {
4786 if ([gameView msaa]) {
4788 OOGL(glBindFramebuffer(GL_READ_FRAMEBUFFER, msaaFramebufferID));
4789 OOGL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFramebufferID));
4790 OOGL(glBlitFramebuffer(0, 0, (GLint)viewSize.width, (GLint)viewSize.height, 0, 0, (GLint)viewSize.width, (GLint)viewSize.height, GL_COLOR_BUFFER_BIT, GL_NEAREST));
4814 OOGL(glDisable(GL_TEXTURE_2D));
4816 float overallAlpha = [[PLAYER hud] overallAlpha];
4831- (void)drawWatermarkString:(NSString*)watermarkString
4833 NSSize watermarkStringSize =
OORectFromString(watermarkString, 0.0f, 0.0f, NSMakeSize(10, 10)).size;
4835 OOGL(glColor4f(0.0, 1.0, 0.0, 1.0));
4847 OOLog(
@"universe.badUID",
@"Attempt to retrieve entity for out-of-range UID %u. (This is an internal programming error, please report it.)", u_id);
4860 if ([ent status] == STATUS_DEAD || [ent status] == STATUS_DOCKED) {
4869 NSCParameterAssert(uni != NULL);
4881 while ((n--) && (checkEnt)) {
4883 checkEnt = checkEnt->
x_next;
4885 if ((checkEnt) || (n > 0)) {
4892 while ((n--) && (checkEnt))
4894 if ((checkEnt) || (n > 0)) {
4900 while (checkEnt->
x_next) {
4902 checkEnt = checkEnt->
x_next;
4910 while ((n--) && (checkEnt)) {
4912 checkEnt = checkEnt->
y_next;
4914 if ((checkEnt) || (n > 0)) {
4921 while ((n--) && (checkEnt))
4923 if ((checkEnt) || (n > 0)) {
4929 while (checkEnt->
y_next) {
4931 checkEnt = checkEnt->
y_next;
4939 while ((n--) && (checkEnt)) {
4941 checkEnt = checkEnt->
z_next;
4943 if ((checkEnt) || (n > 0)) {
4950 while ((n--) && (checkEnt))
4952 if ((checkEnt) || (n > 0)) {
4957 NSCAssert(checkEnt !=
nil,
@"Expected z-list to be non-empty.");
4959 while (checkEnt->
z_next) {
4961 checkEnt = checkEnt->
z_next;
4970 NSArray* allEntities = uni->
entities;
4976 foreach (ent, allEntities) {
4997 if (![entity validForAddToUniverse])
5001 if ([
entities containsObject:entity])
5009 [
self debugDumpEntities];
5014 if (![entity isEffect]) {
5022 if (limiter-- == 0) {
5024 OOLog(
@"universe.addEntity.failed",
@"***** Universe cannot addEntity:%@ -- Could not find free slot for entity.", entity);
5028 [
entity setUniversalID:next_universal_id];
5030 if ([entity isShip]) {
5032 if ([se isBeacon]) {
5035 if ([se isStation]) {
5038 double stationRoll = 0.0;
5042 if (definedRoll !=
nil) {
5045 stationRoll = [[
self currentSystemData] oo_doubleForKey:@"station_roll" defaultValue:STANDARD_STATION_ROLL];
5053 if ([se maxFlightSpeed] > 0)
5057 if ([se status] != STATUS_COCKPIT_DISPLAY) {
5062 [
entity setUniversalID:NO_TARGET];
5063 if ([entity isVisualEffect]) {
5065 if ([ve isBeacon]) {
5068 }
else if ([entity isWaypoint]) {
5070 if ([wp isBeacon]) {
5077 entity->isSunlit = YES;
5081 [entities addObject:entity];
5082 [
entity wasAddedToUniverse];
5085 HPVector entity_pos = entity->position;
5088 entity->zero_distance = z_distance;
5091 entity->zero_index = index;
5092 while ((index > 0) && (z_distance <
sortedEntities[index - 1]->zero_distance))
5098 entity->zero_index = index;
5105 [
entity addToLinkedLists];
5106 if ([entity canCollide])
5111 if ([entity isWormhole]) {
5112 [activeWormholes addObject:entity];
5113 }
else if ([entity isPlanet]) {
5114 [allPlanets addObject:entity];
5115 }
else if ([entity isShip]) {
5118 if ([entity isStation]) {
5119 [allStations addObject:entity];
5130 if (entity !=
nil && ![entity isPlayer]) {
5135 [entitiesDeadThisUpdate addObject:entity];
5136 if ([entity isStation]) {
5137 [allStations removeObject:entity];
5138 if ([
PLAYER getTargetDockStation] == entity) {
5139 [PLAYER setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
5147- (void)ensureEntityReallyRemoved:(
Entity*)entity
5149 if ([entity universalID] !=
NO_TARGET) {
5150 OOLog(
@"universe.unremovedEntity",
@"Entity %@ dealloced without being removed from universe! (This is an internal programming error, please report it.)", entity);
5161 Entity* p0 = [entities objectAtIndex:0];
5162 if (!(p0->isPlayer)) {
5169 NSMutableArray* savedWormholes = [activeWormholes mutableCopy];
5172 Entity* ent = [entities objectAtIndex:1];
5175 if (
EXPECT(![ent isVisualEffect])) {
5183 [activeWormholes release];
5192 [closeSystems release];
5196 [waypoints removeAllObjects];
5205 if (ent_count > 0) {
5207 for (i = 0; i < ent_count; i++) {
5209 if ([ent status] == STATUS_COCKPIT_DISPLAY && ![ent isPlayer]) {
5217- (
ShipEntity*)makeDemoShipWithRole:(NSString*)role spinning:(BOOL)spinning
5224 [PLAYER setShowDemoShips:YES];
5236 [UNIVERSE addEntity:ship];
5250 return [
ship autorelease];
5253- (BOOL)isVectorClearFromEntity:(
Entity*)e1 toDistance:(
double)dist fromPoint:(
HPVector)p2
5265 double nearest = sqrt(v1.
x * v1.
x + v1.
y * v1.
y + v1.
z * v1.
z) - dist;
5273 for (i = 0; i < ent_count; i++)
5276 if (v1.
x || v1.
y || v1.
z)
5281 for (i = 0; i < ent_count; i++) {
5283 if ((e2 != e1) && ([e2 canCollide])) {
5291 if ((d_forward > 0) && (d_forward < nearest)) {
5294 p0.
x += d_forward * f1.
x;
5295 p0.
y += d_forward * f1.
y;
5296 p0.
z += d_forward * f1.
z;
5303 double dist2 = p0.
x * p0.
x + p0.
y * p0.
y + p0.
z * p0.
z;
5304 if (dist2 < cr * cr) {
5305 for (i = 0; i < ent_count; i++)
5306 [my_entities[i] release];
5312 for (i = 0; i < ent_count; i++)
5313 [my_entities[i] release];
5338 for (i = 0; i < ent_count; i++)
5341 if (v1.
x || v1.
y || v1.
z)
5346 for (i = 0; (i < ent_count) && (!result); i++) {
5348 if ((e2 != e1) && ([e2 canCollide])) {
5356 if ((d_forward > 0) && (d_forward < nearest)) {
5359 p0.
x += d_forward * f1.
x;
5360 p0.
y += d_forward * f1.
y;
5361 p0.
z += d_forward * f1.
z;
5369 if (dist2 < cr * cr)
5374 for (i = 0; i < ent_count; i++)
5375 [my_entities[i] release];
5393 for (i = 0; i < ent_count; i++)
5401 double nearest = sqrt(v1.
x * v1.
x + v1.
y * v1.
y + v1.
z * v1.
z) - dist;
5403 if (v1.
x || v1.
y || v1.
z)
5408 for (i = 0; i < ent_count; i++) {
5410 if ((e2 != e1) && ([e2 canCollide])) {
5416 if ((d_forward > 0) && (d_forward < nearest)) {
5420 p0.
x += d_forward * f1.
x;
5421 p0.
y += d_forward * f1.
y;
5422 p0.
z += d_forward * f1.
z;
5431 double dist2 = p0.
x * p0.
x + p0.
y * p0.
y + p0.
z * p0.
z;
5433 if (dist2 < cr * cr) {
5435 nearest = d_forward;
5440 result.
x += ((
int)(
Ranrot() % 1024) - 512) / 512.0;
5441 result.
y += ((
int)(
Ranrot() % 1024) - 512) / 512.0;
5442 result.
z += ((
int)(
Ranrot() % 1024) - 512) / 512.0;
5446 nearest_point.
x += d_forward * f1.
x;
5447 nearest_point.
y += d_forward * f1.
y;
5448 nearest_point.
z += d_forward * f1.
z;
5452 outward.
x -= result.
x;
5453 outward.
y -= result.
y;
5454 outward.
z -= result.
z;
5455 if (outward.
x || outward.
y || outward.
z)
5462 backward.
x -= result.
x;
5463 backward.
y -= result.
y;
5464 backward.
z -= result.
z;
5465 if (backward.
x || backward.
y || backward.
z)
5478 if (current_distance < cr * 1.25)
5479 current_distance = cr * 1.25;
5480 if (current_distance > cr * 5.0)
5481 current_distance = cr * 5.0;
5485 result.
x += 0.25 * (outward.
x * current_distance) + 0.75 * (backward.
x * current_distance);
5486 result.
y += 0.25 * (outward.
y * current_distance) + 0.75 * (backward.
y * current_distance);
5487 result.
z += 0.25 * (outward.
z * current_distance) + 0.75 * (backward.
z * current_distance);
5492 for (i = 0; i < ent_count; i++)
5493 [my_entities[i] release];
5499 ShipEntity* wreck = [UNIVERSE newShipWithRole:wreckRole];
5502 GLfloat expected_mass = 0.1f * [
ship mass] * (0.75 + 0.5 *
randf());
5504 GLfloat scale_factor = powf(expected_mass / wreck_mass, 0.33333333f) * scale;
5520 [UNIVERSE addEntity:wreck];
5531 if ([target showDamage] && [target energy] < [target maxEnergy] / 2) {
5532 NSString* key = (
randf() < 0.5) ?
@"oolite-hull-spark" :
@"oolite-hull-spark-b";
5533 NSDictionary* settings = [UNIVERSE explosionSetting:key];
5537 if ([target energy] *
randf() < damage) {
5551 if (srcEntity ==
nil)
5566 if ([parent isPlayer])
5576 for (i = 0; i < ent_count; i++) {
5578 if (ent != srcEntity && ent != parent && [ent isShip] && [ent canCollide]) {
5587 switch (direction) {
5608 for (i = 0; i < ship_count; i++) {
5615 if (v_off.
z > 0.0 && v_off.
z < nearest + cr &&
5616 v_off.
x < cr && v_off.
x > -cr && v_off.
y < cr && v_off.
y > -cr &&
5617 v_off.
x * v_off.
x + v_off.
y * v_off.
y < cr * cr)
5622 if (hit > 0.0 && hit < nearest) {
5623 if ([entHit isSubEntity]) {
5624 hit_subentity = entHit;
5635 if (hit_subentity && [hit_subentity owner] == hit_entity)
5638 if (range_ptr != NULL) {
5639 *range_ptr = nearest;
5643 for (i = 0; i < ship_count; i++)
5644 [my_entities[i] release];
5654 nearest2 *= nearest2;
5660 for (i = 0; i < ent_count; i++) {
5681 case VIEW_STARBOARD:
5689 for (i = 0; i < ship_count; i++) {
5691 if ([e2 canCollide] && [e2 scanClass] != CLASS_NO_DRAW) {
5694 if (dist2 < nearest2) {
5696 if (df > 0.0 && df * df < nearest2) {
5700 if (du * du + dr * dr < cr * cr) {
5709 if (hit_entity !=
nil && [hit_entity isShip]) {
5711 if ([ship isJammingScanning] && ![player hasMilitaryScannerFilter]) {
5716 for (i = 0; i < ship_count; i++) {
5745 case VIEW_STARBOARD:
5759- (NSArray*)entitiesWithinRange:(
double)range ofEntity:(
Entity*)entity
5770- (unsigned)countShipsWithRole:(NSString*)role inRange:(
double)range ofEntity:(
Entity*)entity
5778- (unsigned)countShipsWithRole:(NSString*)role
5783- (unsigned)countShipsWithPrimaryRole:(NSString*)role inRange:(
double)range ofEntity:(
Entity*)entity
5791- (unsigned)countShipsWithScanClass:(
OOScanClass)scanClass inRange:(
double)range ofEntity:(
Entity*)entity
5799- (unsigned)countShipsWithPrimaryRole:(NSString*)role
5805 parameter:(
void*)parameter
5806 inRange:(
double)range
5809 unsigned i, found = 0;
5813 if (predicate == NULL)
5823 if (e2 != e1 && predicate(e2, parameter)) {
5840 parameter:(
void*)parameter
5841 inRange:(
double)range
5844 if (predicate != NULL) {
5847 predicate, parameter
5873 parameter:(
void*)parameter
5874 inRange:(
double)range
5881 NSMutableArray* result =
nil;
5885 if (predicate == NULL)
5898 if (e1 != e2 &&
EntityInRange(p1, e2, range) && predicate(e2, parameter)) {
5911 parameter:(
void*)parameter
5918 if (predicate == NULL)
5923 if (predicate(candidate, parameter))
5933 parameter:(
void*)parameter
5934 inRange:(
double)range
5937 if (predicate != NULL) {
5940 predicate, parameter
5956 parameter:(
void*)parameter
5957 inRange:(
double)range
5960 if (predicate != NULL) {
5963 predicate, parameter
5979 parameter:(
void*)parameter
5980 relativeToEntity:(
Entity*)entity
5984 float rangeSq = INFINITY;
5987 if (predicate == NULL)
5997 float distanceToReferenceEntitySquared = (float)
HPdistance2(p1, [e2 position]);
5999 if (entity != e2 && distanceToReferenceEntitySquared < rangeSq && predicate(e2, parameter)) {
6001 rangeSq = distanceToReferenceEntitySquared;
6005 return [[
result retain] autorelease];
6009 parameter:(
void*)parameter
6010 relativeToEntity:(
Entity*)entity
6012 if (predicate != NULL) {
6015 predicate, parameter
6077 BOOL guiSelected = NO;
6084 ms =
DESC(
@"forward-view-string");
6088 ms =
DESC(
@"aft-view-string");
6092 ms =
DESC(
@"port-view-string");
6095 case VIEW_STARBOARD:
6096 ms =
DESC(
@"starboard-view-string");
6100 ms = [PLAYER customViewDescription];
6103 case VIEW_GUI_DISPLAY:
6122#if (ALLOW_CUSTOM_VIEWS_WHILE_PAUSED)
6125 BOOL gamePaused = NO;
6130 if (ms && !gamePaused) {
6132 }
else if (gamePaused) {
6138- (void)enterGUIViewModeWithMouseInteraction:(BOOL)mouseInteraction
6151- (NSString*)soundNameForCustomSoundKey:(NSString*)key
6153 NSString* result =
nil;
6154 NSMutableSet* seen =
nil;
6155 id object = [customSounds objectForKey:key];
6157 if ([
object isKindOfClass:[NSArray
class]] && [
object count] > 0) {
6158 key = [
object oo_stringAtIndex:Ranrot() % [
object count]];
6164 if (result ==
nil) {
6168 if (
object ==
nil || ([result hasPrefix:
@"["] && [result hasSuffix:
@"]"])) {
6170 [
seen addObject:result];
6171 object = [customSounds objectForKey:result];
6172 if ([
object isKindOfClass:[NSArray
class]] && [
object count] > 0) {
6173 result = [
object oo_stringAtIndex:Ranrot() % [
object count]];
6174 if ([key hasPrefix:
@"["] && [key hasSuffix:
@"]"])
6177 if ([
object isKindOfClass:[NSString
class]])
6182 if (result ==
nil || ![result hasPrefix:
@"["] || ![result hasSuffix:
@"]"])
6184 if ([seen containsObject:result]) {
6185 OOLogERR(
@"sound.customSounds.recursion",
@"recursion in customsounds.plist for '%@' (at '%@'), no sound will be played.", key, result);
6193 result =
@"__oolite-no-sound";
6197 if ([result isEqualToString:
@"__oolite-no-sound"]) {
6198 OOLog(
@"sound.customSounds",
@"Could not resolve sound name in customsounds.plist for '%@', no sound will be played.", key);
6204- (NSDictionary*)screenTextureDescriptorForKey:(NSString*)key
6206 id value = [screenBackgrounds objectForKey:key];
6207 while ([value isKindOfClass:[NSArray
class]])
6208 value = [
value objectAtIndex:Ranrot() % [
value count]];
6210 if ([value isKindOfClass:[NSString
class]])
6211 value = [
NSDictionary dictionaryWithObject:value forKey:@"name"];
6212 else if (![value isKindOfClass:[NSDictionary
class]])
6216 if (![[
self gui] preloadGUITexture:value])
6222- (void)setScreenTextureDescriptorForKey:(NSString*)key descriptor:(NSDictionary*)desc
6224 NSMutableDictionary* sbCopy = [screenBackgrounds mutableCopy];
6226 [
sbCopy removeObjectForKey:key];
6228 [
sbCopy setObject:desc forKey:key];
6230 [screenBackgrounds release];
6238 [currentMessage release];
6242- (void)setMessageGuiBackgroundColor:(
OOColor*)some_color
6251 [currentMessage release];
6258- (void)displayCountdownMessage:(NSString*)text forCount:(
OOTimeDelta)count
6262 [currentMessage release];
6269- (void)addDelayedMessage:(NSString*)text forCount:(
OOTimeDelta)count afterDelay:(
double)delay
6272 [
msgDict setObject:text forKey:@"message"];
6273 [
msgDict setObject:[
NSNumber numberWithDouble:count] forKey:@"duration"];
6274 [
self performSelector:@selector(addDelayedMessage:) withObject:msgDict afterDelay:delay];
6277- (void)addDelayedMessage:(NSDictionary*)textdict
6279 NSString* msg =
nil;
6282 msg = [
textdict oo_stringForKey:@"message"];
6285 msg_duration = [
textdict oo_nonNegativeDoubleForKey:@"duration" defaultValue:3.0];
6295- (void)speakWithSubstitutions:(NSString*)text
6297#if OOLITE_SPEECH_SYNTH
6302 NSString* systemSaid =
nil;
6303 NSString* h_systemSaid =
nil;
6307 systemSaid = systemName;
6310 h_systemSaid = h_systemName;
6312 NSString* spokenText = text;
6313 if (speechArray !=
nil) {
6314 NSArray* thePair =
nil;
6316 foreach (thePair, speechArray) {
6317 NSString* original_phrase = [
thePair oo_stringAtIndex:0];
6319 NSUInteger replacementIndex;
6320#if OOLITE_MAC_COCOA_UI
6321 replacementIndex = 1;
6323 replacementIndex = [
thePair count] > 2 ? 2 : 1;
6326 NSString* replacement_phrase = [
thePair oo_stringAtIndex:replacementIndex];
6327 if (![replacement_phrase isEqualToString:
@"_"]) {
6328 spokenText = [
spokenText stringByReplacingOccurrencesOfString:original_phrase withString:replacement_phrase];
6331 spokenText = [
spokenText stringByReplacingOccurrencesOfString:systemName withString:systemSaid];
6332 spokenText = [
spokenText stringByReplacingOccurrencesOfString:h_systemName withString:h_systemSaid];
6340- (void)addMessage:(NSString*)text forCount:(
OOTimeDelta)count forceDisplay:(BOOL)forceDisplay
6349 [PLAYER doScriptEvent:OOJSID("consoleMessageReceived") withArgument:text];
6351 [currentMessage release];
6362- (void)addCommsMessage:(NSString*)text forCount:(
OOTimeDelta)count andShowComms:(BOOL)showComms logOnly:(BOOL)logOnly
6364 if ([
PLAYER showDemoShips])
6367 NSString* expandedMessage =
OOExpand(text);
6375 NSString* format =
OOExpandKey(
@"speech-synthesis-incoming-message-@");
6381 [currentMessage release];
6400- (void)showGUIMessage:(NSString*)text withScroll:(BOOL)scroll andColor:(
OOColor*)selectedColor overDuration:(
OOTimeDelta)how_long
6416 [PLAYER doWorldScriptEvent:OOJSIDFromString(system_repopulator) inContext:context withArguments:NULL count:0 timeLimit:kOOJSLongTimeLimit];
6425 OOLog(
@"universe.profile.update",
@"%@",
@"Begin update");
6438 for (i = 0; i < ent_count; i++) {
6442 NSString*
volatile update_stage =
@"initialisation";
6444 id volatile update_stage_param =
nil;
6458 if (
EXPECT_NOT([player showDemoShips] && [player guiScreen] == GUI_SCREEN_SHIPLIBRARY)) {
6459 update_stage =
@"demo management";
6462 if (ent_count > 1) {
6530 update_stage =
@"update:entity";
6531 NSMutableSet* zombies =
nil;
6532 OOLog(
@"universe.profile.update",
@"%@", update_stage);
6533 for (i = 0; i < ent_count; i++) {
6534 Entity* thing = my_entities[
i];
6536 update_stage_param = thing;
6537 update_stage =
@"update:entity [%@]";
6554 update_stage =
@"update:list maintenance [%@]";
6561 while (index > 0 && z_distance <
sortedEntities[index - 1]->zero_distance) {
6570 if ([thing isShip]) {
6572 update_stage =
@"update:think [%@]";
6585 update_stage_param =
nil;
6588 if (zombies !=
nil) {
6589 update_stage =
@"shootin' zombies";
6591 foreach (zombie, zombies) {
6592 OOLogERR(
@"universe.zombie",
@"Found dead entity %@ in active entity list, removing. This is an internal error, please report it.", zombie);
6598 update_stage =
@"updating linked lists";
6599 OOLog(
@"universe.profile.update",
@"%@", update_stage);
6600 for (i = 0; i < ent_count; i++) {
6606 update_stage =
@"collision and shadow detection";
6607 OOLog(
@"universe.profile.update",
@"%@", update_stage);
6618 @catch (NSException* exception) {
6619 if ([[exception name] hasPrefix:
@"Oolite"]) {
6623 if (update_stage_param !=
nil)
6624 update_stage = [
NSString stringWithFormat:update_stage, update_stage_param];
6626 OOLog(
kOOLogException,
@"***** Exception during [%@] in [Universe update:] : %@ : %@ *****", update_stage, [exception name], [exception reason]);
6632 update_stage =
@"clean up";
6633 OOLog(
@"universe.profile.update",
@"%@", update_stage);
6634 for (i = 0; i < ent_count; i++) {
6645 update_stage =
@"JS Garbage Collection";
6646 OOLog(
@"universe.profile.update",
@"%@", update_stage);
6647#if !defined(NDEBUG) && !OOJS_QUICKJS
6653 uint32 gcbytes1 = JS_GetGCParameter(JS_GetRuntime(context), JSGC_BYTES);
6657#if !defined(NDEBUG) && !OOJS_QUICKJS
6659 uint32 gcbytes2 = JS_GetGCParameter(JS_GetRuntime(context), JSGC_BYTES);
6661 if (gcbytes2 < gcbytes1) {
6662 OOLog(
@"universe.profile.jsgc",
@"Unplanned JS Garbage Collection from %d to %d", gcbytes1, gcbytes2);
6668 if ([
PLAYER status] == STATUS_DEAD)
6669 [PLAYER update:delta_t];
6672 [entitiesDeadThisUpdate autorelease];
6677 [
self prunePreloadingPlanetMaterials];
6680 OOLog(
@"universe.profile.update",
@"%@",
@"Update complete");
6683#ifdef OO_DEBUG_MONITOR_ENABLED
6684- (double)timeAccelerationFactor
6686 return timeAccelerationFactor;
6689- (void)setTimeAccelerationFactor:(
double)newTimeAccelerationFactor
6694 timeAccelerationFactor = newTimeAccelerationFactor;
6702- (void)setTimeAccelerationFactor:(
double)newTimeAccelerationFactor
6712- (void)setECMVisualFXEnabled:(BOOL)isEnabled
6727 Entity *e0, *next, *prev;
6728 OOHPScalar start, finish, next_start, next_finish, prev_start, prev_finish;
6756 if (next_start < finish) {
6758 while ((next) && (next_start < finish)) {
6761 if (next_finish > finish)
6762 finish = next_finish;
6793 if (prev_start > finish) {
6795 while ((prev) && (prev_start > finish)) {
6798 if (prev_finish < finish)
6799 finish = prev_finish;
6833 if (next_start < finish) {
6835 while ((next) && (next_start < finish)) {
6838 if (next_finish > finish)
6839 finish = next_finish;
6870 if (prev_start > finish) {
6872 while ((prev) && (prev_start > finish)) {
6875 if (prev_finish < finish)
6876 finish = prev_finish;
6909 if (next_start < finish) {
6911 while ((next) && (next_start < finish)) {
6914 if (next_finish > finish)
6915 finish = next_finish;
6946 if (prev_start > finish) {
6948 while ((prev) && (prev_start > finish)) {
6951 if (prev_finish < finish)
6952 finish = prev_finish;
6985 if (next_start < finish) {
6987 while ((next) && (next_start < finish)) {
6990 if (next_finish > finish)
6991 finish = next_finish;
7021 if (prev_start > finish) {
7023 while ((prev) && (prev_start > finish)) {
7026 if (prev_finish < finish)
7027 finish = prev_finish;
7060 if (next_start < finish) {
7062 while ((next) && (next_start < finish)) {
7067 if (next_finish > finish)
7068 finish = next_finish;
7099 if (prev_start > finish) {
7101 while ((prev) && (prev_start > finish)) {
7118 OOLog(
@"general.error.inconsistentState",
@"Unexpected state in collision chain builder prev=%@, prev->c=%@, e0=%@, e0->c=%@", prev, prev->
collision_chain, e0, e0->
collision_chain);
7124 if (prev_finish < finish)
7125 finish = prev_finish;
7159 NSAutoreleasePool* pool =
nil;
7167 for (i = 0; i < 256; i++) {
7169 [system_names[
i] release];
7179 NSDictionary* systemData;
7182 NSString* scriptName;
7190 economy = [
systemData oo_unsignedCharForKey:KEY_ECONOMY];
7191 scriptName = [
systemData oo_stringForKey:@"market_script" defaultValue:nil];
7208 stringByAppendingPathComponent:@"Config"]
7209 stringByAppendingPathComponent:@"descriptions.plist"]];
7216static void VerifyDesc(NSString* key,
id desc);
7220 if ([desc rangeOfString:
@"%n"].location != NSNotFound) {
7221 OOLog(
@"descriptions.verify.percentN",
@"***** FATAL: descriptions.plist entry \"%@\
" contains the dangerous control sequence %%n.", key);
7229 foreach (subDesc, desc) {
7236 if ([desc isKindOfClass:[NSString
class]]) {
7238 }
else if ([desc isKindOfClass:[NSArray
class]]) {
7240 }
else if ([desc isKindOfClass:[NSNumber
class]]) {
7243 OOLogERR(
@"descriptions.verify.badType",
@"***** FATAL: descriptions.plist entry for \"%@\
" is neither a string nor an array.", key);
7260 NSString* key =
nil;
7261 if (_descriptions ==
nil) {
7262 OOLog(
@"descriptions.verify",
@"%@",
@"***** FATAL: Tried to verify descriptions, but descriptions was nil - unable to load any descriptions.plist file.");
7267 VerifyDesc(key, [_descriptions objectForKey:key]);
7278- (NSDictionary*)explosionSetting:(NSString*)explosion
7280 return [explosionSettings oo_dictionaryForKey:explosion defaultValue:nil];
7304- (NSString*)descriptionForKey:(NSString*)key
7309- (NSString*)descriptionForArrayKey:(NSString*)key index:(
unsigned)index
7311 NSArray* array = [[
self descriptions] oo_arrayForKey:key];
7312 if ([array
count] <= index)
7314 return [
array objectAtIndex:index];
7317- (BOOL)descriptionBooleanForKey:(NSString*)key
7329 return [
NSString stringWithFormat:@"%d %d", g, s];
7334 return [
NSString stringWithFormat:@"interstellar: %d %d %d", g, s1, s2];
7343- (NSDictionary*)generateSystemData:(
OOSystemID)s useCache:(BOOL)useCache
7350 NSString* systemKey = [
NSString stringWithFormat:@"%u %u", [PLAYER galaxyNumber], s];
7364 static NSDictionary* interstellarDict =
nil;
7365 if (interstellarDict ==
nil) {
7366 NSString* interstellarName =
DESC(
@"interstellar-space");
7367 NSString* notApplicable =
DESC(
@"not-applicable");
7368 NSNumber* minusOne = [
NSNumber numberWithInt:-1];
7369 NSNumber* zero = [
NSNumber numberWithInt:0];
7370 interstellarDict = [[
NSDictionary alloc] initWithObjectsAndKeys:
7371 interstellarName, KEY_NAME,
7372 minusOne, KEY_GOVERNMENT,
7373 minusOne, KEY_ECONOMY,
7374 minusOne, KEY_TECHLEVEL,
7375 zero, KEY_POPULATION,
7376 zero, KEY_PRODUCTIVITY,
7378 notApplicable, KEY_INHABITANTS,
7379 notApplicable, KEY_DESCRIPTION,
7383 return interstellarDict;
7391 return [
self sun] ==
nil;
7396- (void)setSystemDataKey:(NSString*)key value:(NSObject*)object fromManifest:(NSString*)manifest
7403 static BOOL sysdataLocked = NO;
7404 if (sysdataLocked) {
7405 OOLogERR(
@"script.error",
@"%@",
@"System properties cannot be set during 'systemInformationChanged' events to avoid infinite loops.");
7409 BOOL sameGalaxy = (gnum == [PLAYER currentGalaxyID]);
7413 if ([key isEqualToString:
KEY_RADIUS] && sameGalaxy && sameSystem)
7415 OOLogERR(
@"script.error",
@"System property '%@' cannot be set while in the system.", key);
7419 if ([key isEqualToString:
@"coordinates"])
7421 OOLogERR(
@"script.error",
@"System property '%@' cannot be set.", key);
7425 NSString* overrideKey = [
NSString stringWithFormat:@"%u %u", gnum, pnum];
7426 NSDictionary* sysInfo =
nil;
7431 if (
object !=
nil) {
7433 if ([key isEqualToString:
KEY_NAME]) {
7434 object = (id)[[(NSString*)
object lowercaseString] capitalizedString];
7437 [system_names[
pnum] release];
7440 }
else if ([key isEqualToString:
@"sun_radius"]) {
7441 if ([
object doubleValue] < 1000.0 || [
object doubleValue] > 10000000.0) {
7442 object = ([
object doubleValue] < 1000.0 ? (id)
@"1000.0" : (id)
@"10000000.0");
7444 }
else if ([key hasPrefix:
@"corona_"]) {
7445 object = (id)[NSString stringWithFormat:
@"%f",
OOClamp_0_1_f([
object floatValue])];
7465 atTime:[PLAYER clockTime]]];
7467 }
else if ([key isEqualToString:
@"sun_color"] || [key isEqualToString:
@"star_count_multiplier"] ||
7468 [key isEqualToString:
@"nebula_count_multiplier"] || [key hasPrefix:
@"sky_"]) {
7476 if (the_sky !=
nil) {
7479 if ([key isEqualToString:
@"sun_color"]) {
7481 if (the_sun !=
nil) {
7491 }
else if (the_sun !=
nil && ([key hasPrefix:
@"sun_"] || [key hasPrefix:
@"corona_"])) {
7493 }
else if ([key isEqualToString:
@"texture"]) {
7494 [[
self planet] setUpPlanetFromTexture:(NSString*)object];
7495 }
else if ([key isEqualToString:
@"texture_hsb_color"]) {
7496 [[
self planet] setUpPlanetFromTexture:[[
self planet] textureFileName]];
7497 }
else if ([key isEqualToString:
@"air_color"]) {
7499 }
else if ([key isEqualToString:
@"illumination_color"]) {
7501 }
else if ([key isEqualToString:
@"air_color_mix_ratio"]) {
7502 [[
self planet] setAirColorMixRatio:[
sysInfo oo_floatForKey:key]];
7506 sysdataLocked = YES;
7507 [PLAYER doScriptEvent:OOJSID("systemInformationChanged") withArguments:[
NSArray arrayWithObjects:[
NSNumber numberWithInt:gnum], [
NSNumber numberWithInt:pnum], key, object, nil]];
7548- (NSString*)getSystemInhabitants:(
OOSystemID)sys plural:(BOOL)plural
7550 NSString* ret =
nil;
7572 NSString* system_name =
nil;
7573 NSString* match = [
sysName lowercaseString];
7575 for (i = 0; i < 256; i++) {
7576 system_name = [system_names[
i] lowercaseString];
7577 if ([system_name isEqualToString:match]) {
7586 OOLog(
@"deprecated.function",
@"%@",
@"findSystemAtCoords");
7590- (NSMutableArray*)nearbyDestinationsWithinRange:(
double)range
7595 NSPoint here = [PLAYER galaxy_coordinates];
7597 for (
unsigned short i = 0; i < 256; i++) {
7603 [
NSNumber numberWithDouble:dist], @"distance",
7604 [
NSNumber numberWithInt:i], @"sysID",
7620 double min_dist = 10000.0;
7623 BOOL connected[256];
7624 for (i = 0; i < 256; i++)
7627 for (n = 0; n < 3; n++)
7629 for (i = 0; i < 256; i++)
7632 for (j = 0; j < 256; j++) {
7636 connected[
j] |= connected[
i];
7637 connected[
i] |= connected[
j];
7643 for (i = 0; i < 256; i++) {
7662 double min_dist = 10000.0;
7665 BOOL connected[256];
7666 for (i = 0; i < 256; i++)
7669 for (n = 0; n < 3; n++)
7671 for (i = 0; i < 256; i++)
7674 for (j = 0; j < 256; j++) {
7678 connected[
j] |= connected[
i];
7679 connected[
i] |= connected[
j];
7685 for (i = 0; i < 256; i++) {
7688 if ((connected[i]) && (
distance < min_dist)) {
7708 unsigned min_dist = 10000;
7710 for (i = 0; i < 256; i++) {
7713 NSInteger concealment = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
7720 dx =
ABS(coords.x - ipos.x);
7721 dy =
ABS(coords.y - ipos.y);
7733 if ((
distance == min_dist) && (coords.y > ipos.y)) {
7744- (NSPoint)findSystemCoordinatesWithPrefix:(NSString*)p_fix
7749- (NSPoint)findSystemCoordinatesWithPrefix:(NSString*)p_fix exactMatch:(BOOL)exactMatch
7751 NSString* system_name =
nil;
7752 NSPoint system_coords = NSMakePoint(-1.0, -1.0);
7755 for (i = 0; i < 256; i++) {
7757 system_name = [system_names[
i] lowercaseString];
7758 if ((exactMatch && [system_name isEqualToString:p_fix]) || (!exactMatch && [system_name hasPrefix:p_fix])) {
7761 NSInteger concealment = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
7774 return system_coords;
7800 if (start == -1 || goal == -1)
7803#ifdef CACHE_ROUTE_FROM_SYSTEM_RESULTS
7805 static NSDictionary* c_route =
nil;
7809 if (c_route !=
nil && c_start == start && c_goal == goal && c_optimizeBy == optimizeBy) {
7817 if (start > 255 || goal > 255)
7820 NSArray* neighbours[256];
7821 BOOL concealed[256];
7822 for (i = 0; i < 256; i++) {
7824 NSInteger concealment = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
7837 double maxCost = optimizeBy ==
OPTIMIZED_BY_TIME ? 256 * (7 * 7) : 256 * (7 * 256 + 7);
7843 while ([curr
count] != 0) {
7844 for (i = 0; i < [
curr count]; i++) {
7847 for (j = 0; j < [
ns count]; j++) {
7859 double lastTime = lastDistance * lastDistance;
7862 double time = [
ce time] + lastTime;
7866 if (cost < maxCost && (cheapest[n] ==
nil || [cheapest[n] cost] > cost)) {
7871 if (n == goal && cost < maxCost)
7876 [
curr setArray:next];
7877 [
next removeAllObjects];
7880 if (!cheapest[goal])
7887 if ([e parent] == -1)
7892#ifdef CACHE_ROUTE_FROM_SYSTEM_RESULTS
7895 c_optimizeBy = optimizeBy;
7918 [closeSystems release];
7957 [
self prunePreloadingPlanetMaterials];
7959 if ([_preloadingPlanetMaterials
count] < 3)
7961 if (_preloadingPlanetMaterials ==
nil) _preloadingPlanetMaterials = [[
NSMutableArray alloc] initWithCapacity:4];
7969 if (![surface isFinishedLoading])
7975 OOMaterial *atmo = [planet atmosphereMaterial];
8005- (NSString*)timeDescription:(
double)interval
8007 double r_time = interval;
8008 NSString* result =
@"";
8010 if (r_time > 86400) {
8011 int days = floor(r_time / 86400);
8012 r_time -= 86400 * days;
8013 result = [
NSString stringWithFormat:@"%@ %d day%@", result, days, (days > 1) ? @"s" : @""];
8015 if (r_time > 3600) {
8016 int hours = floor(r_time / 3600);
8017 r_time -= 3600 * hours;
8018 result = [
NSString stringWithFormat:@"%@ %d hour%@", result, hours, (hours > 1) ? @"s" : @""];
8021 int mins = floor(r_time / 60);
8022 r_time -= 60 * mins;
8023 result = [
NSString stringWithFormat:@"%@ %d minute%@", result, mins, (mins > 1) ? @"s" : @""];
8026 int secs = floor(r_time);
8027 result = [
NSString stringWithFormat:@"%@ %d second%@", result, secs, (secs > 1) ? @"s" : @""];
8032- (NSString*)shortTimeDescription:(
double)interval
8034 double r_time = interval;
8035 NSString* result =
@"";
8038 if (interval <= 0.0)
8039 return DESC(
@"contracts-no-time");
8041 if (r_time > 86400) {
8042 int days = floor(r_time / 86400);
8043 r_time -= 86400 * days;
8044 result = [
NSString stringWithFormat:@"%@ %d %@", result, days, DESC_PLURAL(@"contracts-day-word", days)];
8047 if (r_time > 3600) {
8048 int hours = floor(r_time / 3600);
8049 r_time -= 3600 * hours;
8050 result = [
NSString stringWithFormat:@"%@ %d %@", result, hours, DESC_PLURAL(@"contracts-hour-word", hours)];
8053 if (parts < 2 && r_time > 60) {
8054 int mins = floor(r_time / 60);
8055 r_time -= 60 * mins;
8056 result = [
NSString stringWithFormat:@"%@ %d %@", result, mins, DESC_PLURAL(@"contracts-minute-word", mins)];
8059 if (parts < 2 && r_time > 0) {
8060 int secs = floor(r_time);
8061 result = [
NSString stringWithFormat:@"%@ %d %@", result, secs, DESC_PLURAL(@"contracts-second-word", secs)];
8073 if ([ship heatInsulation] < minInsulation)
8094- (void)loadStationMarkets:(NSArray*)marketData
8096 if (marketData ==
nil) {
8102 NSDictionary* savedMarket =
nil;
8104 foreach (savedMarket, marketData) {
8125 NSMutableDictionary* savedMarket =
nil;
8133 if (stationMarket !=
nil) {
8137 [
markets addObject:savedMarket];
8152 float tech_price_boost = (ship_seed.
a + ship_seed.
b) / 256.0;
8158 for (i = 0; i < 256; i++) {
8159 long long reference_time = 0x1000000 * floor(current_time / 0x1000000);
8161 long long c_time = ship_seed.
a * 0x10000 + ship_seed.
b * 0x100 + ship_seed.
c;
8162 double ship_sold_time = reference_time + c_time;
8164 if (ship_sold_time < 0)
8165 ship_sold_time += 0x1000000;
8167 double days_until_sale = (ship_sold_time - current_time) / 86400.0;
8175 NSArray* conditions = [
dict oo_arrayForKey:@"conditions"];
8177 if (![player scriptTestConditions:conditions]) {
8180 NSString* condition_script = [
dict oo_stringForKey:@"condition_script"];
8181 if (condition_script !=
nil) {
8183 if (condScript !=
nil)
8187 BOOL allow_purchase = NO;
8194 count:sizeof args / sizeof *args
8204 if (OK && !allow_purchase) {
8216 if (specialTL != NSNotFound) {
8218 techlevel = specialTL;
8221 techlevel = [
systemInfo oo_unsignedIntForKey:KEY_TECHLEVEL];
8223 unsigned ship_index = (ship_seed.
d * 0x100 + ship_seed.
e) % [keysForShips
count];
8224 NSString* ship_key = [
keysForShips oo_stringAtIndex:ship_index];
8231 int superRand1 = ship_seed.
a * 0x10000 + ship_seed.
c * 0x100 + ship_seed.
e;
8232 uint32_t superRand2 = ship_seed.
b * 0x10000 + ship_seed.
d * 0x100 + ship_seed.
f;
8237 if ((days_until_sale > 0.0) && (days_until_sale < 30.0) && (ship_techlevel <= techlevel) && (
randf() < chance) && (shipBaseDict !=
nil)) {
8238 NSMutableDictionary* shipDict = [
NSMutableDictionary dictionaryWithDictionary:shipBaseDict];
8239 NSMutableString* shortShipDescription = [
NSMutableString stringWithCapacity:256];
8240 NSString* shipName = [
shipDict oo_stringForKey:@"display_name" defaultValue:[
shipDict oo_stringForKey:KEY_NAME]];
8243 NSMutableArray* extras = [
NSMutableArray arrayWithArray:[[
ship_info oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_arrayForKey:KEY_EQUIPMENT_EXTRAS]];
8244 NSString* fwdWeaponString = [[
ship_info oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_stringForKey:KEY_EQUIPMENT_FORWARD_WEAPON];
8245 NSString* aftWeaponString = [[
ship_info oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_stringForKey:KEY_EQUIPMENT_AFT_WEAPON];
8262 if (fwdWeapon && fwdWeaponString)
8263 [
shipDict setObject:fwdWeaponString forKey:KEY_EQUIPMENT_FORWARD_WEAPON];
8264 if (aftWeapon && aftWeaponString)
8265 [
shipDict setObject:aftWeaponString forKey:KEY_EQUIPMENT_AFT_WEAPON];
8267 int passengerBerthCount = 0;
8268 BOOL customised = NO;
8269 BOOL weaponCustomized = NO;
8271 NSString* fwdWeaponDesc =
nil;
8273 NSString* shortExtrasKey =
@"shipyard-first-extra";
8278 while ((
randf() < chance) && ([options
count])) {
8281 NSString* equipmentKey = [
options oo_stringAtIndex:optionIndex];
8287 NSString* eqShortDesc = [
item name];
8289 if ([item techLevel] > techlevel) {
8291 eqTechLevel =
MIN(eqTechLevel, 15U);
8294 if (
randf() * (eqTechLevel - techlevel) < 1.0) {
8296 eqPrice *= (tech_price_boost + eqTechLevel - techlevel) * 90 / 100;
8301 if ([item incompatibleEquipment] !=
nil && extras !=
nil) {
8303 BOOL incompatible = NO;
8305 foreach (key, [item incompatibleEquipment]) {
8306 if ([extras containsObject:key]) {
8307 [
options removeObject:equipmentKey];
8316 foreach (key, [item incompatibleEquipment]) {
8317 if ([options containsObject:key]) {
8325 if (condition_script !=
nil) {
8327 if (condScript !=
nil)
8331 BOOL allow_addition = NO;
8338 count:sizeof args / sizeof *args
8350 if (OK && !allow_addition) {
8359 if ([item requiresEquipment] !=
nil && extras !=
nil) {
8363 foreach (key, [item requiresEquipment]) {
8364 if (![extras containsObject:key]) {
8372 if ([item requiresAnyEquipment] !=
nil && extras !=
nil) {
8376 foreach (key, [item requiresAnyEquipment]) {
8377 if ([extras containsObject:key]) {
8387 if ([equipmentKey isEqualTo:
@"EQ_NAVAL_ENERGY_UNIT"]) {
8388 if ([extras containsObject:
@"EQ_ENERGY_UNIT"]) {
8389 [
options removeObject:equipmentKey];
8394 if ([equipmentKey hasPrefix:
@"EQ_WEAPON"]) {
8397 if (availableFacings &
WEAPON_FACING_FORWARD && [new_weapon weaponThreatAssessment] > [fwdWeapon weaponThreatAssessment]) {
8401 fwdWeaponString = equipmentKey;
8402 fwdWeapon = new_weapon;
8403 [
shipDict setObject:fwdWeaponString forKey:KEY_EQUIPMENT_FORWARD_WEAPON];
8404 weaponCustomized = YES;
8405 fwdWeaponDesc = eqShortDesc;
8408 if (availableFacings &
WEAPON_FACING_AFT && (
isWeaponNone(aftWeapon) || [new_weapon weaponThreatAssessment] > [aftWeapon weaponThreatAssessment])) {
8411 aftWeaponString = equipmentKey;
8412 aftWeapon = new_weapon;
8413 [
shipDict setObject:aftWeaponString forKey:KEY_EQUIPMENT_AFT_WEAPON];
8415 [
options removeObject:equipmentKey];
8420 if ([equipmentKey isEqualToString:
@"EQ_PASSENGER_BERTH"]) {
8424 [
extras addObject:equipmentKey];
8425 passengerBerthCount++;
8429 [
options removeObject:equipmentKey];
8433 [
extras addObject:equipmentKey];
8434 if ([item isVisible]) {
8435 NSString* item = eqShortDesc;
8437 shortExtrasKey =
@"shipyard-additional-extra";
8440 [
options removeObject:equipmentKey];
8444 [
options removeObject:equipmentKey];
8449 BOOL lowercaseIgnore = [[
self descriptions] oo_boolForKey:@"lowercase_ignore"];
8451 if (passengerBerthCount) {
8452 NSString* npb = (passengerBerthCount > 1) ? [NSString stringWithFormat:
@"%d ", passengerBerthCount] : (id)
@"";
8453 NSString* ppb =
DESC_PLURAL(
@"passenger-berth", passengerBerthCount);
8454 NSString* extraPassengerBerthsDescription = [
NSString stringWithFormat:DESC(@"extra-@-@-(passenger-berths)"), npb, ppb];
8455 NSString* item = extraPassengerBerthsDescription;
8457 shortExtrasKey =
@"shipyard-additional-extra";
8464 if (weaponCustomized) {
8465 NSString* weapon = (lowercaseIgnore ? fwdWeaponDesc : [
fwdWeaponDesc lowercaseString]);
8468 if (price > base_price) {
8469 price = base_price +
cunningFee(price - base_price, 0.05);
8474 NSString* shipID = [
NSString stringWithFormat:@"%06x-%06x", superRand1, superRand2];
8478 NSDictionary* ship_info_dictionary = [
NSDictionary dictionaryWithObjectsAndKeys:
8479 shipID, SHIPYARD_KEY_ID,
8480 ship_key, SHIPYARD_KEY_SHIPDATA_KEY,
8481 shipDict, SHIPYARD_KEY_SHIP,
8482 shortShipDescription, KEY_SHORT_DESCRIPTION,
8483 [
NSNumber numberWithUnsignedLongLong:price], SHIPYARD_KEY_PRICE,
8484 extras, KEY_EQUIPMENT_EXTRAS,
8485 [
NSNumber numberWithUnsignedShort:personality], SHIPYARD_KEY_PERSONALITY,
8498 NSMutableArray* resultArray = [[[
resultDictionary allValues] mutableCopy] autorelease];
8499 [
resultArray sortUsingFunction:compareName context:NULL];
8504 while (i < [resultArray
count]) {
8505 if (
compareName([resultArray objectAtIndex:i - 1], [resultArray objectAtIndex:i],
nil) == NSOrderedSame) {
8514 return [
NSArray arrayWithArray:resultArray];
8519 NSDictionary* ship1 = [(
NSDictionary*)
dict1 oo_dictionaryForKey:SHIPYARD_KEY_SHIP];
8520 NSDictionary* ship2 = [(
NSDictionary*)
dict2 oo_dictionaryForKey:SHIPYARD_KEY_SHIP];
8521 NSString* name1 = [
ship1 oo_stringForKey:KEY_NAME];
8522 NSString* name2 = [
ship2 oo_stringForKey:KEY_NAME];
8524 NSComparisonResult result = [[
name1 lowercaseString] compare:[
name2 lowercaseString]];
8525 if (result != NSOrderedSame)
8536 return [
price1 compare:price2];
8543 NSString* ship_desc = [
dict oo_stringForKey:@"ship_desc"];
8547 if (shipyard_info ==
nil) {
8548 OOLogERR(
@"universe.tradeInValueForCommanderDictionary.valueCalculationError",
8549 @"Shipyard dictionary entry for ship %@ required for trade in value calculation, but does not exist. Setting ship value to 0.", ship_desc);
8551 base_price = [
shipyard_info oo_unsignedLongLongForKey:SHIPYARD_KEY_PRICE defaultValue:0ULL];
8554 if (base_price == 0ULL)
8563 unsigned ship_missiles = [
dict oo_unsignedIntForKey:@"missiles"];
8564 unsigned ship_max_passengers = [
dict oo_unsignedIntForKey:@"max_passengers"];
8565 NSMutableArray* ship_extra_equipment = [
NSMutableArray arrayWithArray:[[
dict oo_dictionaryForKey:@"extra_equipment"] allKeys]];
8567 NSDictionary* basic_info = [
shipyard_info oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT];
8568 unsigned base_missiles = [
basic_info oo_unsignedIntForKey:KEY_EQUIPMENT_MISSILES];
8569 OOCreditsQuantity base_missiles_value = base_missiles * [UNIVERSE getEquipmentPriceForKey:@"EQ_MISSILE"] / 10;
8570 NSString* base_weapon_key = [
basic_info oo_stringForKey:KEY_EQUIPMENT_FORWARD_WEAPON];
8571 OOCreditsQuantity base_weapons_value = [UNIVERSE getEquipmentPriceForKey:base_weapon_key] / 10;
8572 NSMutableArray* base_extra_equipment = [
NSMutableArray arrayWithArray:[
basic_info oo_arrayForKey:KEY_EQUIPMENT_EXTRAS]];
8573 NSString* weapon_key =
nil;
8576 base_weapon_key = [
basic_info oo_stringForKey:KEY_EQUIPMENT_AFT_WEAPON defaultValue:nil];
8577 if (base_weapon_key !=
nil)
8578 base_weapons_value += [UNIVERSE getEquipmentPriceForKey:base_weapon_key] / 10;
8585 NSArray* missileRoles = [
dict oo_arrayForKey:@"missile_roles"];
8586 if (missileRoles !=
nil) {
8588 for (i = 0; i < ship_missiles; i++) {
8589 NSString* missile_desc = [
missileRoles oo_stringAtIndex:i];
8590 if (missile_desc !=
nil && ![missile_desc isEqualToString:
@"NONE"]) {
8591 ship_missiles_value += [UNIVERSE getEquipmentPriceForKey:missile_desc] / 10;
8595 ship_missiles_value = ship_missiles * [UNIVERSE getEquipmentPriceForKey:@"EQ_MISSILE"] / 10;
8598 long long extra_equipment_value = ship_max_passengers * [UNIVERSE getEquipmentPriceForKey:@"EQ_PASSENGER_BERTH"] / 10;
8601 extra_equipment_value += ship_missiles_value - base_missiles_value;
8604 if (ship_fwd_weapon) {
8606 ship_main_weapons_value = [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
8608 if (ship_aft_weapon) {
8610 if (base_weapon_key !=
nil)
8612 ship_main_weapons_value += [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
8614 ship_other_weapons_value += [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
8617 if (ship_port_weapon) {
8619 ship_other_weapons_value += [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
8621 if (ship_starboard_weapon) {
8623 ship_other_weapons_value += [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
8627 extra_equipment_value += ship_other_weapons_value;
8628 extra_equipment_value += ship_main_weapons_value - base_weapons_value;
8631 NSString* eq_key =
nil;
8635 for (i = [base_extra_equipment
count] - 1; i > 0; i--) {
8637 if ([base_extra_equipment indexOfObject:eq_key inRange:NSMakeRange(0, i - 1)] != NSNotFound)
8642 for (i = [base_extra_equipment
count] - 1; i >= 0; i--) {
8644 if ([ship_extra_equipment containsObject:eq_key])
8647 extra_equipment_value -= ([UNIVERSE getEquipmentPriceForKey:eq_key] / 10);
8653 for (i = [ship_extra_equipment
count] - 1; i >= 0; i--) {
8656 if ([item isPortableBetweenShips])
8661 for (i = [ship_extra_equipment
count] - 1; i >= 0; i--)
8662 extra_equipment_value += ([
UNIVERSE getEquipmentPriceForKey:[ship_extra_equipment oo_stringAtIndex:i]] / 10);
8665 extra_equipment_value *= extra_equipment_value < 0 ? 1.4 : 0.9;
8669 if ((
long long)scrap_value > (
long long)base_price + extra_equipment_value)
8672 return base_price + extra_equipment_value;
8675- (NSString*)brochureDescriptionWithDictionary:(NSDictionary*)dict standardEquipment:(NSArray*)extras optionalEquipment:(NSArray*)options
8677 NSMutableArray* mut_extras = [
NSMutableArray arrayWithArray:extras];
8678 NSString* allOptions = [
options componentsJoinedByString:@" "];
8680 NSMutableString* desc = [
NSMutableString stringWithFormat:@"The %@.", [
dict oo_stringForKey:KEY_NAME]];
8686 [
desc appendFormat:@" Cargo capacity %dt", max_cargo];
8687 BOOL canExpand = ([
allOptions rangeOfString:@"EQ_CARGO_BAY"].location != NSNotFound);
8689 [
desc appendFormat:@" (expandable to %dt at most starports)", max_cargo + extra_cargo];
8690 [
desc appendString:@"."];
8694 float top_speed = [
dict oo_intForKey:@"max_flight_speed"];
8695 [
desc appendFormat:@" Top speed %.3fLS.", 0.001 * top_speed];
8698 if ([mut_extras
count]) {
8699 unsigned n_berths = 0;
8702 NSString* item_key = [
mut_extras oo_stringAtIndex:i];
8703 if ([item_key isEqual:
@"EQ_PASSENGER_BERTH"]) {
8710 [
desc appendString:@" Includes luxury accomodation for a single passenger."];
8712 [
desc appendFormat:@" Includes luxury accomodation for %d passengers.", n_berths];
8717 if ([mut_extras
count]) {
8718 [
desc appendString:@"\nComes with"];
8721 NSString* item_key = [
mut_extras oo_stringAtIndex:i];
8722 NSString* item_desc =
nil;
8723 for (j = 0; ((j < [equipmentData count]) && (!item_desc)); j++) {
8724 NSString* eq_type = [[equipmentData oo_arrayAtIndex:j] oo_stringAtIndex:EQUIPMENT_KEY_INDEX];
8725 if ([eq_type isEqual:item_key])
8726 item_desc = [[equipmentData oo_arrayAtIndex:j] oo_stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
8729 switch ([mut_extras
count] - i) {
8731 [
desc appendFormat:@" %@ fitted as standard.", item_desc];
8734 [
desc appendFormat:@" %@ and", item_desc];
8737 [
desc appendFormat:@" %@,", item_desc];
8745 if ([options
count]) {
8746 [
desc appendString:@"\nCan additionally be outfitted with"];
8748 for (i = 0; i < [
options count]; i++) {
8749 NSString* item_key = [
options oo_stringAtIndex:i];
8750 NSString* item_desc =
nil;
8751 for (j = 0; ((j < [equipmentData count]) && (!item_desc)); j++) {
8752 NSString* eq_type = [[equipmentData oo_arrayAtIndex:j] oo_stringAtIndex:EQUIPMENT_KEY_INDEX];
8753 if ([eq_type isEqual:item_key])
8754 item_desc = [[equipmentData oo_arrayAtIndex:j] oo_stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
8757 switch ([options
count] - i) {
8759 [
desc appendFormat:@" %@ at suitably equipped starports.", item_desc];
8762 [
desc appendFormat:@" %@ and/or", item_desc];
8765 [
desc appendFormat:@" %@,", item_desc];
8816 if (v1.
x || v1.
y || v1.
z)
8849 if (v1.
x || v1.
y || v1.
z)
8854 if (v2.
x || v2.
y || v2.
z)
8859 if (v3.
x || v3.
y || v3.
z)
8870 v1.
x += 15000 * v3.
x;
8871 v1.
y += 15000 * v3.
y;
8872 v1.
z += 15000 * v3.
z;
8876 if (v1.
x || v1.
y || v1.
z)
8890- (NSArray*)listBeaconsWithCode:(NSString*)code
8895 while (beacon !=
nil) {
8896 NSString* beaconCode = [
beacon beaconCode];
8897 if ([beaconCode rangeOfString:code options:NSCaseInsensitiveSearch].location != NSNotFound) {
8898 [
result addObject:beacon];
8900 beacon = [
beacon nextBeacon];
8903 return [
result sortedArrayUsingSelector:@selector(compareBeaconCodeWith:)];
8906- (void)allShipsDoScriptEvent:(
OOJSPropID)event andReactToAIMessage:(NSString*)message
8912 for (i = 0; i < ent_count; i++) {
8918 for (i = 0; i < ship_count; i++) {
8950 align:GUI_ALIGN_CENTER
8962- (void)setDisplayText:(BOOL)value
8972- (void)setDisplayFPS:(BOOL)value
8982- (void)setAutoSave:(BOOL)value
8985 [[
NSUserDefaults standardUserDefaults] setBool:autoSave forKey:@"autosave"];
8993- (void)setAutoSaveNow:(BOOL)value
9003- (void)setWireframeGraphics:(BOOL)value
9006 [[
NSUserDefaults standardUserDefaults] setBool:wireframeGraphics forKey:@"wireframe-graphics"];
9030 detailLevel = value;
9037 [[
NSUserDefaults standardUserDefaults] setInteger:detailLevel forKey:@"detailLevel"];
9056- (void)handleOoliteException:(NSException*)exception
9058 if (exception !=
nil) {
9063 OOLog(
kOOLogException,
@"***** Handling Fatal : %@ : %@ *****", [exception name], [exception reason]);
9064 NSString* exception_msg = [
NSString stringWithFormat:@"Exception : %@ : %@ Please take a screenshot and/or press esc or Q to quit.", [
exception name], [
exception reason]];
9068 OOLog(
kOOLogException,
@"***** Handling Non-fatal : %@ : %@ *****", [exception name], [exception reason]);
9078- (void)setAirResistanceFactor:(GLfloat)newFactor
9084#if OOLITE_MAC_COCOA_UI
9086- (void)startSpeakingString:(NSString*)text
9093 if ([speechSynthesizer respondsToSelector:
@selector(stopSpeakingAtBoundary:)]) {
9107- (void)startSpeakingString:(NSString*)text
9109 NSData* utf8 = [text dataUsingEncoding:NSUTF8StringEncoding];
9113 const char* stringToSay = [text UTF8String];
9114 espeak_Synth(stringToSay, strlen(stringToSay) + 1 , 0, POS_CHARACTER, 0, espeakCHARS_UTF8 | espeakPHONEMES | espeakENDPAUSE, NULL, NULL);
9125 return espeak_IsPlaying();
9128- (NSString*)voiceName:(
unsigned int)index
9130 if (index >= espeak_voice_count)
9132 return [NSString stringWithCString:espeak_voices[index]->name];
9135- (
unsigned int)voiceNumber:(NSString*)name
9140 const char*
const label = [name UTF8String];
9144 unsigned int index = -1;
9145 while (espeak_voices[++index] && strcmp(espeak_voices[index]->name, label))
9147 return (index < espeak_voice_count) ? index : UINT_MAX;
9150- (
unsigned int)nextVoice:(
unsigned int)index
9152 if (++index >= espeak_voice_count)
9157- (
unsigned int)prevVoice:(
unsigned int)index
9159 if (--index >= espeak_voice_count)
9160 index = espeak_voice_count - 1;
9164- (
unsigned int)setVoice:(
unsigned int)index withGenderM:(BOOL)isMale
9166 if (index == UINT_MAX)
9167 index = [
self voiceNumber:DESC(@"espeak-default-voice")];
9169 if (index < espeak_voice_count) {
9170 espeak_VOICE voice = { espeak_voices[index]->name, NULL, NULL, isMale ? 1 : 2 };
9171 espeak_SetVoiceByProperties(&voice);
9179- (void)startSpeakingString:(NSString*)text
9198- (void)setPauseMessageVisible:(BOOL)value
9208- (void)setPermanentMessageLog:(BOOL)value
9218- (void)setAutoMessageLogBg:(BOOL)value
9228- (void)setPermanentCommLog:(BOOL)value
9233- (void)setAutoCommLog:(BOOL)value
9243- (void)setBlockJSPlayerShipProps:(BOOL)value
9268 initWithPixelSize:NSMakeSize(480, 160)
9277 initWithPixelSize:NSMakeSize(360, 120)
9287#ifdef OO_DEBUG_MONITOR_ENABLED
9294#if OOLITE_SPEECH_SYNTH
9304 [characters autorelease];
9307 [customSounds autorelease];
9310 [globalSettings autorelease];
9316 [screenBackgrounds autorelease];
9320 [roleCategories autorelease];
9323 [autoAIMap autorelease];
9326 [equipmentData autorelease];
9327 [equipmentDataOutfitting autorelease];
9334 [explosionSettings autorelease];
9342 foreach (type, [commodities goods]) {
9346 [
tmp setObject:container forKey:type];
9350 cargoPods = [[
NSDictionary alloc] initWithDictionary:tmp];
9357 NSMutableArray* badEntities =
nil;
9361 for (i = 0; i < n_entities; i++) {
9362 entity = sortedEntities[
i];
9363 if ([entity sessionID] != _sessionID) {
9364 OOLogERR(
@"universe.sessionIDs.verify.failed",
@"Invalid entity %@ (came from session %zu, current session is %zu).", [entity shortDescription], [entity sessionID], _sessionID);
9365 if (badEntities ==
nil)
9371 foreach (entity, badEntities) {
9378- (BOOL)reinitAndShowDemo:(BOOL)showDemo
9382 assert(player !=
nil);
9406 [PLAYER setSpeed:0.0];
9411 [missiontext autorelease];
9415 [demo_ships release];
9434 if (![player setUpAndConfirmOK:YES]) {
9487 if (activeWormholes)
9489 activeWormholes = [[
NSMutableArray arrayWithCapacity:16] retain];
9533 if (routeFraction == NSNotFound)
9534 routeFraction =
randf();
9548 if ([entity canCollide])
9550 doLinkedListMaintenanceThisUpdate = YES;
9567 if (sortedEntities[index] != entity) {
9568 OOLog(
kOOLogInconsistentState,
@"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE RIGHT PLACE IN THE ZERO_DISTANCE SORTED LIST -- FIXING...", entity);
9571 for (i = 0; (i < n_entities) && (index == -1); i++)
9572 if (sortedEntities[i] == entity)
9575 OOLog(
kOOLogInconsistentState,
@"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE ZERO_DISTANCE SORTED LIST -- CONTINUING...", entity);
9578 while ((
unsigned)index < n_entities) {
9579 while (((
unsigned)index + n < n_entities) && (sortedEntities[index + n] == entity)) {
9597 sortedEntities[
index] = sortedEntities[
index + n];
9598 if (sortedEntities[index]) {
9599 sortedEntities[
index]->zero_index = index;
9604 OOLog(
kOOLogInconsistentState,
@"DEBUG: Universe removeEntity: REMOVED %d EXTRA COPIES OF %@ FROM THE ZERO_DISTANCE SORTED LIST", n - 1, entity);
9614 if ([entities containsObject:entity]) {
9616 if ([entity isBreakPattern] && ![entity isVisualEffect]) {
9617 breakPatternCounter--;
9620 if ([entity isShip]) {
9624 if ([entity isWaypoint]) {
9628 if ([entity isVisualEffect]) {
9633 if ([entity isWormhole]) {
9635 }
else if ([entity isPlanet]) {
9648 if (![soundName hasPrefix:
@"["] && ![soundName hasSuffix:
@"]"]) {
9656 NSString* key =
nil;
9659 id object = [customSounds objectForKey:key];
9660 if ([
object isKindOfClass:[NSString
class]]) {
9662 }
else if ([
object isKindOfClass:[NSArray
class]] && [
object count] > 0) {
9663 NSString* soundName =
nil;
9664 foreach (soundName,
object) {
9665 if ([soundName isKindOfClass:[NSString
class]]) {
9678 NSAutoreleasePool* pool =
nil;
9680 while ([activeWormholes
count]) {
9686 if (![whole isScanned] && NSEqualPoints([
PLAYER galaxy_coordinates], [whole destinationCoordinates])) {
9692 @catch (NSException* exception) {
9693 OOLog(
kOOLogException,
@"Squashing exception during wormhole unpickling (%@: %@).", [exception name], [exception reason]);
9699- (NSString*)chooseStringForKey:(NSString*)key inDictionary:(NSDictionary*)dictionary
9702 if ([
object isKindOfClass:[NSString
class]])
9704 else if ([
object isKindOfClass:[NSArray
class]] && [
object count] > 0)
9705 return [
object oo_stringAtIndex:Ranrot() % [
object count]];
9709#if OO_LOCALIZATION_TOOLS
9712- (void)dumpDebugGraphViz
9714 if ([[NSUserDefaults standardUserDefaults] boolForKey:
@"universe-dump-debug-graphviz"]) {
9715 [
self dumpSystemDescriptionGraphViz];
9719- (void)dumpSystemDescriptionGraphViz
9721 NSMutableString* graphViz =
nil;
9722 NSArray* systemDescriptions =
nil;
9723 NSArray* thisDesc =
nil;
9724 NSUInteger i,
count, j, subCount;
9725 NSString* descLine =
nil;
9726 NSArray* curses =
nil;
9727 NSString* label =
nil;
9728 NSDictionary* keyMap =
nil;
9734 graphViz = [NSMutableString stringWithString:
9735 @"// System description grammar:\n\n"
9736 "digraph system_descriptions\n"
9738 "\tgraph [charset=\"UTF-8\", label=\"System description grammar\", labelloc=t, labeljust=l rankdir=LR compound=true nodesep=0.02 ranksep=1.5 concentrate=true fontname=Helvetica]\n"
9739 "\tedge [arrowhead=dot]\n"
9740 "\tnode [shape=none height=0.2 width=3 fontname=Helvetica]\n\t\n"];
9742 systemDescriptions = [[
self descriptions] oo_arrayForKey:@"system_description"];
9743 count = [systemDescriptions count];
9746 descLine =
DESC(
@"system-description-string");
9748 [graphViz appendFormat:@"\tsystem_description_string [label=\"%@\" shape=ellipse]\n", EscapedGraphVizString(label)];
9749 [
self addNumericRefsInString:descLine
9751 fromNode:@"system_description_string"
9753 [graphViz appendString:@"\t\n"];
9756 [graphViz appendString:
9757 @"\tpercent_I [label=\"%I\\nInhabitants\" shape=diamond]\n"
9758 "\tpercent_H [label=\"%H\\nSystem name\" shape=diamond]\n"
9759 "\tpercent_RN [label=\"%R/%N\\nRandom name\" shape=diamond]\n"
9760 "\tpercent_J [label=\"%J\\nNumbered system name\" shape=diamond]\n"
9761 "\tpercent_G [label=\"%G\\nNumbered system name in chart number\" shape=diamond]\n\t\n"];
9764 [graphViz appendString:@"\tsubgraph cluster_thargoid_curses\n\t{\n\t\tlabel = \"Thargoid curses\"\n"];
9765 curses = [[
self descriptions] oo_arrayForKey:@"thargoid_curses"];
9766 subCount = [curses count];
9767 for (j = 0; j < subCount; ++j) {
9769 [graphViz appendFormat:@"\t\tthargoid_curse_%zu [label=\"%@\"]\n", j, EscapedGraphVizString(label)];
9771 [graphViz appendString:@"\t}\n"];
9772 for (j = 0; j < subCount; ++j) {
9773 [
self addNumericRefsInString:[curses oo_stringAtIndex:j]
9775 fromNode:[NSString stringWithFormat:@"thargoid_curse_%zu", j]
9778 [graphViz appendString:@"\t\n"];
9782 for (i = 0; i <
count; ++i) {
9784 label = [keyMap objectForKey:[NSString stringWithFormat:@"%zu", i]];
9786 label = [NSString stringWithFormat:
@"[%zu]", i];
9788 label = [NSString stringWithFormat:@"[%zu] (%@)", i, label];
9790 [graphViz appendFormat:@"\tsubgraph cluster_%zu\n\t{\n\t\tlabel=\"%@\"\n", i, EscapedGraphVizString(label)];
9792 thisDesc = [systemDescriptions oo_arrayAtIndex:i];
9793 subCount = [thisDesc count];
9794 for (j = 0; j < subCount; ++j) {
9796 [graphViz appendFormat:@"\t\tn%zu_%zu [label=\"\\\"%@\\\"\"]\n", i, j, EscapedGraphVizString(label)];
9799 [graphViz appendString:@"\t}\n"];
9801 [graphViz appendString:@"\t\n"];
9804 for (i = 0; i !=
count; ++i) {
9805 thisDesc = [systemDescriptions oo_arrayAtIndex:i];
9806 subCount = [thisDesc count];
9807 for (j = 0; j != subCount; ++j) {
9808 descLine = [thisDesc oo_stringAtIndex:j];
9809 [
self addNumericRefsInString:descLine
9811 fromNode:[NSString stringWithFormat:@"n%zu_%zu", i, j]
9817 [graphViz appendString:@"\t}\n"];
9822- (void)addNumericRefsInString:(NSString*)string toGraphViz:(NSMutableString*)graphViz fromNode:(NSString*)fromNode nodeCount:(NSUInteger)nodeCount
9824 NSString* index =
nil;
9825 NSInteger start, end;
9826 NSRange remaining, subRange;
9829 remaining = NSMakeRange(0, [
string length]);
9832 subRange = [
string rangeOfString:@"[" options:NSLiteralSearch range:remaining];
9833 if (subRange.location == NSNotFound)
9835 start = subRange.location + subRange.length;
9836 remaining.length -= start - remaining.location;
9837 remaining.location = start;
9839 subRange = [
string rangeOfString:@"]" options:NSLiteralSearch range:remaining];
9840 if (subRange.location == NSNotFound)
9842 end = subRange.location;
9843 remaining.length -= end - remaining.location;
9844 remaining.location = end;
9846 index = [
string substringWithRange:NSMakeRange(start, end - start)];
9847 i = [
index intValue];
9850 [
graphViz appendFormat:@"\t%@ -> n%u_0 [color=\"%f,0.75,0.8\" lhead=cluster_%u]\n", fromNode, i, ((float)(i * 511 % nodeCount)) / ((float)nodeCount), i];
9853 if ([
string rangeOfString:
@"%I"].location != NSNotFound) {
9854 [
graphViz appendFormat:@"\t%@ -> percent_I [color=\"0,0,0.25\"]\n", fromNode];
9856 if ([
string rangeOfString:
@"%H"].location != NSNotFound) {
9857 [
graphViz appendFormat:@"\t%@ -> percent_H [color=\"0,0,0.45\"]\n", fromNode];
9859 if ([
string rangeOfString:
@"%R"].location != NSNotFound || [
string rangeOfString:
@"%N"].location != NSNotFound) {
9860 [
graphViz appendFormat:@"\t%@ -> percent_RN [color=\"0,0,0.65\"]\n", fromNode];
9864 if ([
string rangeOfString:
@"%J"].location != NSNotFound) {
9865 [
graphViz appendFormat:@"\t%@ -> percent_J [color=\"0,0,0.75\"]\n", fromNode];
9868 if ([
string rangeOfString:
@"%G"].location != NSNotFound) {
9869 [
graphViz appendFormat:@"\t%@ -> percent_G [color=\"0,0,0.85\"]\n", fromNode];
9877 NSArray* arguments =
nil;
9878 NSString* arg =
nil;
9879 BOOL compileSysDesc = NO, exportSysDesc = NO, xml = NO;
9883 foreach (arg, arguments) {
9884 if ([arg isEqual:
@"--compile-sysdesc"])
9885 compileSysDesc = YES;
9886 else if ([arg isEqual:
@"--export-sysdesc"])
9887 exportSysDesc = YES;
9888 else if ([arg isEqual:
@"--xml"])
9890 else if ([arg isEqual:
@"--openstep"])
9903- (void)prunePreloadingPlanetMaterials
9907 NSUInteger i = [_preloadingPlanetMaterials count];
9909 if ([[_preloadingPlanetMaterials objectAtIndex:i] isFinishedLoading]) {
9910 [_preloadingPlanetMaterials removeObjectAtIndex:i];
9918 [conditionScripts autorelease];
9928- (void)addConditionScripts:(NSEnumerator*)scripts
9930 NSString* scriptname =
nil;
9931 while ((scriptname = [scripts nextObject])) {
9934 if (script !=
nil) {
9935 [conditionScripts setObject:script forKey:scriptname];
9943 return [conditionScripts objectForKey:scriptname];
9948@implementation OOSound (OOCustomSounds)
9950+ (id)soundWithCustomSoundKey:(NSString*)key
9952 NSString* fileName = [UNIVERSE soundNameForCustomSoundKey:key];
9953 if (fileName ==
nil)
9958- (id)initWithCustomSoundKey:(NSString*)key
9966@implementation OOSoundSource (OOCustomSounds)
9968+ (id)sourceWithCustomSoundKey:(NSString*)key
9970 return [[[
self alloc] initWithCustomSoundKey:key] autorelease];
9973- (id)initWithCustomSoundKey:(NSString*)key
9976 if (theSound !=
nil) {
9985- (void)playCustomSoundWithKey:(NSString*)key
9988 if (theSound !=
nil)
9996 NSDictionary* one = (NSDictionary*)a;
9997 NSDictionary* two = (NSDictionary*)b;
9998 int pri_one = [one oo_intForKey:@"priority" defaultValue:100];
9999 int pri_two = [two oo_intForKey:@"priority" defaultValue:100];
10000 if (pri_one < pri_two)
10001 return NSOrderedAscending;
10002 if (pri_one > pri_two)
10003 return NSOrderedDescending;
10004 return NSOrderedSame;
10009 NSArray* one = (NSArray*)a;
10010 NSArray* two = (NSArray*)b;
10014 OOCreditsQuantity comp1 = [[one oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
10015 OOCreditsQuantity comp2 = [[two oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
10017 return NSOrderedAscending;
10019 return NSOrderedDescending;
10021 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
10022 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
10024 return NSOrderedAscending;
10026 return NSOrderedDescending;
10028 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
10029 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
10031 return NSOrderedAscending;
10033 return NSOrderedDescending;
10035 return NSOrderedSame;
10040 NSArray* one = (NSArray*)a;
10041 NSArray* two = (NSArray*)b;
10045 OOCreditsQuantity comp1 = [[one oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"purchase_sort_order" defaultValue:[[one oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000]];
10046 OOCreditsQuantity comp2 = [[two oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"purchase_sort_order" defaultValue:[[two oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000]];
10048 return NSOrderedAscending;
10050 return NSOrderedDescending;
10052 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
10053 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
10055 return NSOrderedAscending;
10057 return NSOrderedDescending;
10059 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
10060 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
10062 return NSOrderedAscending;
10064 return NSOrderedDescending;
10066 return NSOrderedSame;
10071 NSString* result = [UNIVERSE descriptionForKey:key];
10080 NSArray* conditions = [[UNIVERSE descriptions] oo_arrayForKey:@"plural-rules"];
10083 NSString* tmp = [UNIVERSE descriptionForKey:key];
10085 static NSMutableSet* warned =
nil;
10087 if (![warned containsObject:tmp]) {
10088 OOLogWARN(
@"localization.plurals",
@"'%@' found in descriptions.plist, should be '%@%%0'. Localization data needs updating.", key, key);
10090 warned = [[NSMutableSet alloc] init];
10091 [warned addObject:tmp];
10095 if (conditions ==
nil) {
10104 for (index = i = 0; i < [conditions count]; ++index, ++i) {
10105 const char* cond = [[conditions oo_stringAtIndex:i] UTF8String];
10109 long int input =
count;
10112 while (isspace(*cond))
10116 while (isspace(*cond))
10119 char command = *cond++;
10130 long int param = strtol(cond, (
char**)&cond, 10);
10144 if (flag ^ (input == param))
10148 if (flag ^ (input != param))
10153 if (flag ^ (input < param))
10157 if (flag ^ (input > param))
#define SCANNER_MAX_RANGE
#define SCANNER_MAX_RANGE2
static NSString *const kOOLogEntityVerificationError
#define OO_DEBUG_POP_PROGRESS()
#define OO_DEBUG_PROGRESS(...)
#define OO_DEBUG_PUSH_PROGRESS(...)
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
#define MAIN_GUI_PIXEL_WIDTH
#define MAIN_GUI_PIXEL_HEIGHT
NSRect OORectFromString(NSString *text, GLfloat x, GLfloat y, NSSize siz)
void OODrawString(NSString *text, GLfloat x, GLfloat y, GLfloat z, NSSize siz)
#define INTERMEDIATE_CLEAR_DEPTH
OOINLINE void bounding_box_reset_to_vector(BoundingBox *box, Vector vec) ALWAYS_INLINE_FUNC NONNULL_FUNC
OOINLINE void bounding_box_add_xyz(BoundingBox *box, GLfloat x, GLfloat y, GLfloat z) ALWAYS_INLINE_FUNC NONNULL_FUNC
#define BREAK_PATTERN_RING_SPEED
#define BREAK_PATTERN_RING_SPACING
@ kOOBreakPatternMaxSides
OOINLINE jsval OOJSValueFromViewID(JSContext *context, OOViewID value)
NSString * OOStringFromGraphicsDetail(OOGraphicsDetail detail)
void CompileSystemDescriptions(BOOL asXML)
void ExportSystemDescriptions(BOOL asXML)
NSString * OOStringifySystemDescriptionLine(NSString *line, NSDictionary *indicesToKeys, BOOL useFallback)
void OOStandardsDeprecated(NSString *message)
BOOL OOEnforceStandards(void)
#define OOInitDebugSupport()
BOOL IsShipPredicate(Entity *entity, void *parameter)
BOOL IsVisualEffectPredicate(Entity *entity, void *parameter)
BOOL YESPredicate(Entity *entity, void *parameter)
OOINLINE double OOClamp_0_max_d(double value, double max) INLINE_CONST_FUNC
OOINLINE float OOClamp_0_max_f(float value, float max) INLINE_CONST_FUNC
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC
NSInteger OOComparisonResult
#define foreachkey(VAR, DICT)
HPVector OOHPVectorRandomRadial(OOHPScalar maxLength)
HPVector OOProjectHPVectorToPlane(HPVector point, HPVector plane, HPVector normal)
OOINLINE HPVector HPvector_flip(HPVector v) INLINE_CONST_FUNC
HPVector OORandomPositionInShell(HPVector centre, OOHPScalar inner, OOHPScalar outer)
OOINLINE HPVector vectorToHPVector(Vector v) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdot_product(HPVector first, HPVector second) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_subtract(HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_multiply_scalar(HPVector v, OOHPScalar s) INLINE_CONST_FUNC
OOINLINE HPVector HPcross_product(HPVector first, HPVector second) INLINE_CONST_FUNC
const HPVector kZeroHPVector
OOINLINE bool HPvector_equal(HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPmagnitude(HPVector vec) INLINE_CONST_FUNC
OOINLINE Vector HPVectorToVector(HPVector v) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal_or_xbasis(HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector make_HPvector(OOHPScalar vx, OOHPScalar vy, OOHPScalar vz) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdistance2(HPVector v1, HPVector v2) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal(HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal_or_zbasis(HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_add(HPVector a, HPVector b) INLINE_CONST_FUNC
HPVector OOHPVectorRandomSpatial(OOHPScalar maxLength)
#define HPvector_between(a, b)
const HPVector kBasisZHPVector
OOINLINE OOHPScalar HPmagnitude2(HPVector vec) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdistance(HPVector v1, HPVector v2) INLINE_CONST_FUNC
OOINLINE HPVector OOHPVectorInterpolate(HPVector a, HPVector b, OOHPScalar where) INLINE_CONST_FUNC
HPVector OORandomPositionInCylinder(HPVector centre1, OOHPScalar exclusion1, HPVector centre2, OOHPScalar exclusion2, OOHPScalar radius)
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
void OOJSPauseTimeLimiter(void)
OOINLINE jsval OOJSValueFromDouble(JSContext *context, double value)
#define OOJSFreeValue(context, value)
#define OOJSUndefinedValue()
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
OOINLINE BOOL OOJSValueToBOOL(JSContext *context, jsval value)
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
void OOJSResumeTimeLimiter(void)
#define OOLogWARN(class, format,...)
#define OOLogERR(class, format,...)
NSString *const kOOLogException
NSString *const kOOLogInconsistentState
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
#define OOLogOutdentIf(class)
#define OOLog(class, format,...)
NSString *const kOOLogParameterError
#define OOLogIndentIf(class)
OOINLINE OOMatrix OOMatrixForScale(OOScalar sx, OOScalar sy, OOScalar sz) INLINE_CONST_FUNC
const OOMatrix kIdentityMatrix
OOINLINE OOMatrix OOMatrixFromBasisVectors(Vector i, Vector j, Vector k) INLINE_CONST_FUNC
Vector OOVectorMultiplyMatrix(Vector v, OOMatrix m) CONST_FUNC
OOMatrix OOMatrixMultiply(OOMatrix a, OOMatrix b) CONST_FUNC
@ MOUSE_MODE_UI_SCREEN_WITH_INTERACTION
void OOGLLoadModelView(OOMatrix matrix)
void OOGLLookAt(Vector eye, Vector center, Vector up)
OOMatrix OOGLGetModelView(void)
void OOGLPushModelView(void)
void OOGLResetModelView(void)
void OOGLTranslateModelView(Vector vector)
void OOGLFrustum(double left, double right, double bottom, double top, double near, double far)
void OOGLMultModelView(OOMatrix matrix)
OOMatrix OOGLGetModelViewProjection(void)
OOMatrix OOGLPopModelView(void)
void OOGLResetProjection(void)
#define OOGLProgramName(handle)
#define OOVerifyOpenGLState()
BOOL OOCheckOpenGLErrors(NSString *format,...)
void GLScaledLineWidth(GLfloat width)
#define OOSetOpenGLState(STATE)
Quaternion quaternion_rotation_between(Vector v0, Vector v1) CONST_FUNC
Vector vector_forward_from_quaternion(Quaternion quat) CONST_FUNC
void basis_vectors_from_quaternion(Quaternion quat, Vector *outRight, Vector *outUp, Vector *outForward)
OOINLINE Quaternion make_quaternion(OOScalar qw, OOScalar qx, OOScalar qy, OOScalar qz) INLINE_CONST_FUNC
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle) NONNULL_FUNC
const Quaternion kIdentityQuaternion
OOINLINE void quaternion_normalize(Quaternion *quat) NONNULL_FUNC ALWAYS_INLINE_FUNC
void quaternion_rotate_about_y(Quaternion *quat, OOScalar angle) NONNULL_FUNC
void quaternion_set_random(Quaternion *quat) NONNULL_FUNC
NSString * OOShipLibraryCategorySingular(NSString *category)
NSString * OOShipLibraryWitchspace(ShipEntity *demo_ship)
NSString * OOShipLibraryTurrets(ShipEntity *demo_ship)
NSString * OOShipLibraryShields(ShipEntity *demo_ship)
NSString * OOShipLibraryCargo(ShipEntity *demo_ship)
NSString * OOShipLibraryCategoryPlural(NSString *category)
static NSString *const kOODemoShipClass
NSString * OOShipLibraryGenerator(ShipEntity *demo_ship)
static NSString *const kOODemoShipShipData
NSString * OOShipLibrarySize(ShipEntity *demo_ship)
NSString * OOShipLibrarySpeed(ShipEntity *demo_ship)
static NSString *const kOODemoShipKey
NSString * OOShipLibraryWeapons(ShipEntity *demo_ship)
NSString * OOShipLibraryTurnRate(ShipEntity *demo_ship)
#define OOExpandKey(key,...)
#define OOExpand(string,...)
NSMutableArray * ScanTokensFromString(NSString *values)
@ OO_SYSTEMCONCEALMENT_NOTHING
@ OO_SYSTEMCONCEALMENT_NONAME
uint8_t OOWeaponFacingSet
NSString * OOCommodityType
uint64_t OOCreditsQuantity
#define VALID_WEAPON_FACINGS
@ WEAPON_FACING_STARBOARD
OOINLINE Vector vector_flip(Vector v) INLINE_CONST_FUNC
OOINLINE OOScalar magnitude(Vector vec) INLINE_CONST_FUNC
OOINLINE Vector make_vector(OOScalar vx, OOScalar vy, OOScalar vz) INLINE_CONST_FUNC
OOINLINE OOScalar dot_product(Vector first, Vector second) INLINE_CONST_FUNC
const Vector kBasisYVector
OOINLINE OOScalar magnitude2(Vector vec) INLINE_CONST_FUNC
const Vector kBasisZVector
const Vector kBasisXVector
OOINLINE OOScalar distance(Vector v1, Vector v2) INLINE_CONST_FUNC
OOINLINE Vector vector_multiply_scalar(Vector v, OOScalar s) INLINE_CONST_FUNC
OOEquipmentType * OOWeaponType
BOOL isWeaponNone(OOWeaponType weapon)
#define ENTITY_PERSONALITY_MAX
NSString * OOEquipmentIdentifierFromWeaponType(OOWeaponType weapon) CONST_FUNC
OOWeaponType OOWeaponTypeFromEquipmentIdentifierSloppy(NSString *string) PURE_FUNC
#define ShipScriptEvent(context, ship, event,...)
#define SUN_SKIM_RADIUS_FACTOR
@ OO_POSTFX_COLORBLINDNESS_TRITAN
#define TIME_ACCELERATION_FACTOR_DEFAULT
#define PASSENGER_BERTH_SPACE
#define MIN_DISTANCE_TO_BUOY
#define DEMO_LIGHT_POSITION
#define DESC_PLURAL(key, count)
#define OOLITE_EXCEPTION_FATAL
#define TIME_ACCELERATION_FACTOR_MAX
NSString * OOLookUpDescriptionPRIV(NSString *key)
#define SAFE_ADDITION_FACTOR2
NSString * OOLookUpPluralDescriptionPRIV(NSString *key, NSInteger count)
NSComparisonResult populatorPrioritySort(id a, id b, void *context)
NSComparisonResult equipmentSortOutfitting(id a, id b, void *context)
NSComparisonResult equipmentSort(id a, id b, void *context)
#define SYSTEM_REPOPULATION_INTERVAL
#define OOLITE_EXCEPTION_DATA_NOT_FOUND
BOOL(* EntityFilterPredicate)(Entity *entity, void *parameter)
#define DOCKED_ILLUM_LEVEL
const GLfloat framebufferQuadVertices[]
static const OOMatrix fwd_matrix
#define SKY_AMBIENT_ADJUSTMENT
static GLfloat docked_light_specular[4]
static NSString *const kOOLogUniversePopulateWitchspace
static const OOMatrix port_matrix
Universe * gSharedUniverse
static const OOMatrix starboard_matrix
#define SUN_AMBIENT_INFLUENCE
static BOOL MaintainLinkedLists(Universe *uni)
static OOComparisonResult compareName(id dict1, id dict2, void *context)
static BOOL demo_light_on
static const OOMatrix aft_matrix
static NSString *const kOOLogEntityVerificationRebuild
static BOOL object_light_on
Entity * gOOJSPlayerIfStale
static GLfloat docked_light_ambient[4]
#define DEMO2_FLY_IN_STAGE_TIME
static GLfloat sun_off[4]
static NSString *const kOOLogUniversePopulateError
#define DEMO2_VANISHING_DISTANCE
const GLuint framebufferQuadIndices[]
static GLfloat docked_light_diffuse[4]
static GLfloat demo_light_position[4]
#define DOCKED_AMBIENT_LEVEL
OOINLINE BOOL EntityInRange(HPVector p1, Entity *e2, float range)
static OOComparisonResult comparePrice(id dict1, id dict2, void *context)
NSDictionary * demoShipData()
void deleteOpenGLObjects()
void drawTargetTextureIntoDefaultFramebuffer()
void verifyEntitySessionIDs()
void setLibraryTextForDemoShip()
void prepareToRenderIntoDefaultFramebuffer()
void verifyDescriptions()
void setUpInitialUniverse()
float randomDistanceWithinScanner()
void populateSpaceFromActiveWormholes()
void setGuiToIntroFirstGo:(BOOL justCobra)
void runLocalizationTools()
void setNextThinkTime:(OOTimeAbsolute ntt)
void setOwner:(ShipEntity *ship)
OOTimeDelta thinkTimeInterval
void setState:(NSString *stateName)
OOTimeAbsolute nextThinkTime
void reactToMessage:context:(NSString *message,[context] NSString *debugContext)
NSString * collisionDescription()
void findShadowedEntities()
BOOL checkEntity:(Entity *ent)
void setDustColor:(OOColor *color)
unsigned isImmuneToBreakPatternHide
void setAtmosphereFogging:(OOColor *fogging)
void removeFromLinkedLists()
void drawImmediate:translucent:(bool immediate,[translucent] bool translucent)
void setUniversalID:(OOUniversalID uid)
OOUniversalID universalID
void setThrowSparks:(BOOL value)
void setVelocity:(Vector vel)
void updateCameraRelativePosition()
void setOrientation:(Quaternion quat)
void update:(OOTimeDelta delta_t)
unsigned collisionTestFilter
GLfloat collisionRadius()
void wasRemovedFromUniverse()
void setLastDrawCounter:(NSUInteger drawCounter)
void setScanClass:(OOScanClass sClass)
Vector cameraRelativePosition
void setPositionX:y:z:(OOHPScalar x,[y] OOHPScalar y,[z] OOHPScalar z)
HPVector absolutePositionForSubentityOffset:(HPVector offset)
GLfloat cameraRangeBack()
void setEnergy:(GLfloat amount)
Quaternion normalOrientation()
ShipEntity * parentEntity()
unsigned isExplicitlyNotMainStation
void setStatus:(OOEntityStatus stat)
void setPosition:(HPVector posn)
void setMouseInteractionModeForUIWithMouseInteraction:(BOOL interaction)
GameController * sharedController()
void setGamePaused:(BOOL value)
void logProgress:(NSString *message)
void exitAppWithContext:(NSString *context)
void setMouseInteractionModeForFlight()
void loadPlayerIfRequired()
void setPlayerFileToLoad:(NSString *filename)
void setTextColor:(OOColor *color)
void printLineNoScroll:align:color:fadeTime:key:addToArray:(NSString *str,[align] OOGUIAlignment alignment,[color] OOColor *text_color,[fadeTime] float text_fade,[key] NSString *text_key,[addToArray] NSMutableArray *text_array)
NSDictionary * userSettings()
void setBackgroundColor:(OOColor *color)
void printLongText:align:color:fadeTime:key:addToArray:(NSString *str,[align] OOGUIAlignment alignment,[color] OOColor *text_color,[fadeTime] float text_fade,[key] NSString *text_key,[addToArray] NSMutableArray *text_array)
int drawGUI:drawCursor:(GLfloat alpha,[drawCursor] BOOL drawCursor)
void setAlpha:(GLfloat an_alpha)
void fadeOutFromTime:overDuration:(OOTimeAbsolute now_time,[overDuration] OOTimeDelta duration)
void setLineWidth:(GLfloat value)
NSString * deferredHudName
void setOverallAlpha:(GLfloat newAlphaValue)
void setFov:fromFraction:(float value,[fromFraction] BOOL fromFraction)
float fov:(BOOL inFraction)
void setMsaa:(BOOL newMsaa)
OOSDRToneMapper sdrToneMapper()
GameController * gameController
void completePendingTasks()
OOAsyncWorkManager * sharedAsyncWorkManager()
void setInnerColor:outerColor:(OOColor *color1,[outerColor] OOColor *color2)
void setLifetime:(double lifetime)
instancetype breakPatternWithPolygonSides:startAngle:aspectRatio:(NSUInteger sides,[startAngle] float startAngleDegrees,[aspectRatio] float aspectRatio)
void setObject:forKey:inCache:(id inElement,[forKey] NSString *inKey,[inCache] NSString *inCacheKey)
id objectForKey:inCache:(NSString *inKey,[inCache] NSString *inCacheKey)
OOCacheManager * sharedCache()
OOCharacter * randomCharacterWithRole:andOriginalSystem:(NSString *c_role,[andOriginalSystem] OOSystemID s)
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
OOColor * brightColorWithDescription:(id description)
OOColor * colorWithDescription:(id description)
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
OOColor * colorWithHue:saturation:brightness:alpha:(float hue,[saturation] float saturation,[brightness] float brightness,[alpha] float alpha)
OOColor * blendedColorWithFraction:ofColor:(float fraction,[ofColor] OOColor *color)
NSString * getRandomCommodity()
OOCommodityMarket * generateMarketForSystemWithEconomy:andScript:(OOEconomyID economy,[andScript] NSString *scriptName)
OOMassUnit massUnitForGood:(NSString *good)
OOMassUnit massUnitForGood:(OOCommodityType good)
NSArray * saveStationAmounts()
OOCargoQuantity quantityForGood:(OOCommodityType good)
NSDictionary * definitionForGood:(OOCommodityType good)
NSString * nameForGood:(OOCommodityType good)
NSString * conditionScript()
OOTechLevelID techLevel()
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
OOCreditsQuantity price()
instancetype explosionCloudFromEntity:withSettings:(Entity *entity,[withSettings] NSDictionary *settings)
instancetype laserFlashWithPosition:velocity:color:(HPVector position,[velocity] Vector vel,[color] OOColor *color)
void resetGraphicsState()
OOGraphicsResetManager * sharedManager()
void runCallback:(HPVector location)
BOOL callMethod:inContext:withArguments:count:result:(jsid methodID,[inContext] JSContext *context,[withArguments] jsval *argv,[count] intN argc,[result] jsval *outResult)
OOJavaScriptEngine * sharedEngine()
void garbageCollectionOpportunity:(BOOL force)
void removeObject:(id object)
OOOpenGLExtensionManager * sharedManager()
OOGraphicsDetail defaultDetailLevel()
instancetype shrinkingRingFromEntity:(Entity *sourceEntity)
instancetype ringFromEntity:(Entity *sourceEntity)
id jsScriptFromFileNamed:properties:(NSString *fileName,[properties] NSDictionary *properties)
instancetype groupWithName:(NSString *name)
NSDictionary * shipyardInfoForKey:(NSString *key)
NSArray * playerShipKeys()
OOProbabilitySet * probabilitySetForRole:(NSString *role)
NSString * randomShipKeyForRole:(NSString *role)
OOShipRegistry * sharedRegistry()
NSDictionary * shipInfoForKey:(NSString *key)
NSDictionary * effectInfoForKey:(NSString *key)
id initWithSound:(OOSound *inSound)
void playSound:(OOSound *inSound)
id soundWithCustomSoundKey:(NSString *key)
void setRadius:andCorona:(GLfloat rad,[andCorona] GLfloat corona)
void drawDirectVisionSunGlare()
BOOL changeSunProperty:withDictionary:(NSString *key,[withDictionary] NSDictionary *dict)
void setPosition:(HPVector posn)
void getSpecularComponents:(GLfloat[4] components)
void getDiffuseComponents:(GLfloat[4] components)
BOOL setSunColor:(OOColor *sun_color)
Random_Seed getRandomSeedForCurrentSystem()
NSDictionary * getPropertiesForSystemKey:(NSString *key)
NSPoint getCoordinatesForSystem:inGalaxy:(OOSystemID s,[inGalaxy] OOGalaxyID g)
id getProperty:forSystem:inGalaxy:(NSString *property,[forSystem] OOSystemID s,[inGalaxy] OOGalaxyID g)
NSDictionary * getPropertiesForCurrentSystem()
void setProperty:forSystemKey:andLayer:toValue:fromManifest:(NSString *property,[forSystemKey] NSString *key,[andLayer] OOSystemLayer layer,[toValue] id value,[fromManifest] NSString *manifest)
NSArray * getNeighbourIDsForSystem:inGalaxy:(OOSystemID s,[inGalaxy] OOGalaxyID g)
NSDictionary * getPropertiesForSystem:inGalaxy:(OOSystemID s,[inGalaxy] OOGalaxyID g)
instancetype waypointWithDictionary:(NSDictionary *info)
id weakRefUnderlyingObject()
void setBounty:withReason:(OOCreditsQuantity amount, [withReason] OOLegalStatusReason reason)
void setSystemID:(OOSystemID sid)
void setGuiToStatusScreen()
void setRandom_factor:(int rf)
Vector weaponViewOffset()
OOGalaxyID galaxyNumber()
void setWormhole:(WormholeEntity *newWormhole)
BOOL setUpShipFromDictionary:(NSDictionary *shipDict)
StationEntity * dockedStation()
void setShowDemoShips:(BOOL value)
Quaternion normalOrientation()
BOOL switchHudTo:(NSString *hudFileName)
BOOL doWorldEventUntilMissionScreen:(OOJSPropID message)
void addScannedWormhole:(WormholeEntity *wormhole)
void addToAdjustTime:(double seconds)
NSPoint galaxy_coordinates
OOSystemID currentSystemID()
void setGalaxyCoordinates:(NSPoint newPosition)
void runUnsanitizedScriptActions:allowingAIMethods:withContextName:forTarget:(NSArray *unsanitizedActions,[allowingAIMethods] BOOL allowAIMethods,[withContextName] NSString *contextName,[forTarget] ShipEntity *target)
void setJumpCause:(NSString *value)
void setDockedAtMainStation()
void setPreviousSystemID:(OOSystemID sid)
OOMatrix customViewMatrix
Vector customViewUpVector
Vector customViewForwardVector
NSString * dial_clock_adjusted()
PlayerEntity * sharedPlayer()
OOSystemID targetSystemID()
OOSound * ooSoundNamed:inFolder:(NSString *fileName,[inFolder] NSString *folderName)
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)
NSArray * arrayFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)
BOOL writeDiagnosticData:toFileNamed:(NSData *data,[toFileNamed] NSString *name)
OOSystemDescriptionManager * systemDescriptionManager()
void setUseAddOns:(NSString *useAddOns)
NSDictionary * roleCategoriesDictionary()
NSDictionary * dictionaryFromFilesNamed:inFolder:mergeMode:cache:(NSString *fileName,[inFolder] NSString *folderName,[mergeMode] OOResourceMergeMode mergeMode,[cache] BOOL useCache)
instancetype elementWithLocation:parent:cost:distance:time:jumps:(OOSystemID location,[parent] OOSystemID parent,[cost] double cost,[distance] double distance,[time] double time,[jumps] int jumps)
void setDemoStartTime:(OOTimeAbsolute time)
void doScriptEvent:(OOJSPropID message)
void setIsWreckage:(BOOL isw)
void setBounty:withReason:(OOCreditsQuantity amount,[withReason] OOLegalStatusReason reason)
NSDictionary * shipInfoDictionary()
void removeEquipmentItem:(NSString *equipmentKey)
void setFuel:(OOFuelQuantity amount)
void rescaleBy:writeToCache:(GLfloat factor, [writeToCache] BOOL writeToCache)
void setStatus:(OOEntityStatus stat)
void setCargoFlag:(OOCargoFlag flag)
BOOL witchspaceLeavingEffects()
void setRoll:(double amount)
void setDestination:(HPVector dest)
void setGroup:(OOShipGroup *group)
void setSubEntityTakingDamage:(ShipEntity *sub)
NSArray * portWeaponOffset
GLfloat doesHitLine:v1:hitEntity:(HPVector v0,[v1] HPVector v1,[hitEntity] ShipEntity **hitEntity)
void setPrimaryRole:(NSString *role)
NSArray * starboardWeaponOffset
void setHeatInsulation:(GLfloat value)
void setPitch:(double amount)
BOOL isHostileTo:(Entity *entity)
void setAITo:(NSString *aiString)
void enterTargetWormhole()
NSArray * aftWeaponOffset
NSArray * forwardWeaponOffset
void setPendingEscortCount:(uint8_t count)
uint8_t pendingEscortCount()
void setTemperature:(GLfloat value)
void doScriptEvent:withArgument:(OOJSPropID message,[withArgument] id argument)
void setCrew:(NSArray *crewArray)
void setDemoShip:(OOScalar demoRate)
void switchAITo:(NSString *aiString)
void setCommodity:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)
OOCommodityType commodityType()
BOOL changeProperty:withDictionary:(NSString *key,[withDictionary] NSDictionary *dict)
OOCommodityMarket * localMarket
void setAllowsFastDocking:(BOOL newValue)
OOCommodityMarket * initialiseLocalMarket()
void setRequiresDockingClearance:(BOOL newValue)
void setEquivalentTechLevel:(OOTechLevelID value)
void setLocalMarket:(NSArray *market)
unsigned interstellarUndockingAllowed
void setPlanet:(OOPlanetEntity *planet)
void setLocalShipyard:(NSArray *market)
void setAllegiance:(NSString *newAllegiance)
BOOL role:isInCategory:(NSString *role,[isInCategory] NSString *category)
OOSystemID findSystemNumberAtCoords:withGalaxy:includingHidden:(NSPoint coords,[withGalaxy] OOGalaxyID gal,[includingHidden] BOOL hidden)
OOGraphicsDetail detailLevel
HPVector legacyPositionFrom:asCoordinateSystem:(HPVector pos,[asCoordinateSystem] NSString *system)
void setTimeAccelerationFactor:(double newTimeAccelerationFactor)
NSDictionary * commodityDataForType:(OOCommodityType type)
void populateNormalSpace()
OOWeakReference * _firstBeacon
Entity< OOBeaconEntity > * lastBeacon()
void setDetailLevelDirectly:(OOGraphicsDetail value)
NSMutableDictionary * conditionScripts
Entity * firstEntityTargetedByPlayerPrecisely()
static BOOL MaintainLinkedLists(Universe *uni)
OOTimeDelta getTimeDelta()
static OOComparisonResult compareName(id dict1, id dict2, void *context)
unsigned countShipsMatchingPredicate:parameter:inRange:ofEntity:(EntityFilterPredicate predicate,[parameter] void *parameter,[inRange] double range,[ofEntity] Entity *entity)
ShipEntity * newShipWithName:usePlayerProxy:isSubentity:(NSString *shipKey,[usePlayerProxy] BOOL usePlayerProxy,[isSubentity] BOOL OO_RETURNS_RETAINED)
void deleteOpenGLObjects()
void setUpUniverseFromWitchspace()
void resetCommsLogColor()
NSString * collisionDescription()
OOINLINE BOOL EntityInRange(HPVector p1, Entity *e2, float range)
void setDockingClearanceProtocolActive:(BOOL newValue)
NSString * system_repopulator
OOTimeAbsolute demo_start_time
OOSystemID targetSystemID
NSString * system_names[256]
unsigned countShipsWithRole:inRange:ofEntity:(NSString *role,[inRange] double range,[ofEntity] Entity *entity)
NSString * defaultAIForRole:(NSString *role)
id nearestEntityMatchingPredicate:parameter:relativeToEntity:(EntityFilterPredicate predicate,[parameter] void *parameter,[relativeToEntity] Entity *entity)
void selectIntro2Previous()
GuiDisplayGen * messageGUI()
void forceWitchspaceEntries()
NSUInteger demo_ship_index
BOOL dockingClearanceProtocolActive()
NSDictionary * customSounds
BOOL doProcedurallyTexturedPlanets
void setPauseMessageVisible:(BOOL value)
OOCreditsQuantity getEquipmentPriceForKey:(NSString *eq_key)
static void VerifyDescArray(NSString *key, NSArray *desc)
NSDictionary * currentSystemData()
NSDictionary * descriptions()
OOCommodities * commodities
void getActiveViewMatrix:forwardVector:upVector:(OOMatrix *outMatrix, [forwardVector] Vector *outForward, [upVector] Vector *outUp)
void showCommsLog:(OOTimeDelta how_long)
NSMutableSet * allStations
NSDictionary * roleCategories
GuiDisplayGen * comm_log_gui
void setAirResistanceFactor:(GLfloat newFactor)
void removeAllEntitiesExceptPlayer()
void setWitchspaceBreakPattern:(BOOL newValue)
NSUInteger demo_ship_subindex
NSDictionary * gameSettings()
BOOL doRemoveEntity:(Entity *entity)
void handleOoliteException:(NSException *ooliteException)
GLuint targetFramebufferID
NSDictionary * _descriptions
void drawWatermarkString:(NSString *watermarkString)
void speakWithSubstitutions:(NSString *text)
ShipEntity * addShipAt:withRole:withinRadius:(HPVector pos,[withRole] NSString *role,[withinRadius] GLfloat radius)
void enterGUIViewModeWithMouseInteraction:(BOOL mouseInteraction)
ShipEntity * addShipWithRole:launchPos:rfactor:(NSString *desc, [launchPos] HPVector launchPos, [rfactor] GLfloat rfactor)
ShipEntity * newShipWithName:(NSString *OO_RETURNS_RETAINED)
ShipEntity * newShipWithRole:(NSString *OO_RETURNS_RETAINED)
void drawTargetTextureIntoDefaultFramebuffer()
void resetFramesDoneThisUpdate()
void setGalaxyTo:andReinit:(OOGalaxyID g,[andReinit] BOOL forced)
HPVector coordinatesFromCoordinateSystemString:(NSString *system_x_y_z)
static void VerifyDescString(NSString *key, NSString *desc)
BOOL doLinkedListMaintenanceThisUpdate
NSArray * getStationMarkets()
NSDictionary * characters
void setMainLightPosition:(Vector sunPos)
void setDisplayText:(BOOL value)
NSMutableDictionary * waypoints
void setECMVisualFXEnabled:(BOOL isEnabled)
OOTimeAbsolute demo_stage_time
void addMessage:forCount:forceDisplay:(NSString *text,[forCount] OOTimeDelta count,[forceDisplay] BOOL forceDisplay)
void populateSystemFromDictionariesWithSun:andPlanet:(OOSunEntity *sun,[andPlanet] OOPlanetEntity *planet)
void addMessage:forCount:(NSString *text,[forCount] OOTimeDelta count)
BOOL deterministic_population
void setUpUniverseFromStation()
void verifyEntitySessionIDs()
NSMutableDictionary * populatorSettings
NSDictionary * screenBackgrounds
void unMagicMainStation()
unsigned countEntitiesMatchingPredicate:parameter:inRange:ofEntity:(EntityFilterPredicate predicate,[parameter] void *parameter,[inRange] double range,[ofEntity] Entity *entity)
void setUpWitchspaceBetweenSystem:andSystem:(OOSystemID s1,[andSystem] OOSystemID s2)
NSDictionary * globalSettings
GuiDisplayGen * message_gui
BOOL addShips:withRole:intoBoundingBox:(int howMany,[withRole] NSString *desc,[intoBoundingBox] BoundingBox bbox)
OOJSScript * getConditionScript:(NSString *scriptname)
static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
void lightForEntity:(BOOL isLit)
void allShipsDoScriptEvent:andReactToAIMessage:(OOJSPropID event,[andReactToAIMessage] NSString *message)
HPVector getWitchspaceExitPosition()
NSMutableArray * findEntitiesMatchingPredicate:parameter:inRange:ofEntity:(EntityFilterPredicate predicate,[parameter] void *parameter,[inRange] double range,[ofEntity] Entity *entity)
NSString * currentMessage
CollisionRegion * universeRegion
NSDictionary * generateSystemData:useCache:(OOSystemID s,[useCache] BOOL useCache)
void setUpUniverseFromMisjump()
NSDictionary * explosionSettings
void clearSystemPopulator()
OOPlanetEntity * cachedPlanet
OOMatrix activeViewMatrix()
NSSize targetFramebufferSize
NSDictionary * getPopulatorSettings()
NSMutableArray * activeWormholes
void setGalaxyTo:(OOGalaxyID g)
void clearPreviousMessage()
NSMutableArray * entities
NSMutableArray * findShipsMatchingPredicate:parameter:inRange:ofEntity:(EntityFilterPredicate predicate,[parameter] void *parameter,[inRange] double range,[ofEntity] Entity *entity)
void setSystemTo:(OOSystemID s)
void setUpInitialUniverse()
void populateSpaceFromActiveWormholes()
BOOL deterministicPopulation()
void prepareToRenderIntoDefaultFramebuffer()
BOOL reinitAndShowDemo:(BOOL showDemo)
OOPlanetEntity * setUpPlanet()
Entity * firstEntityTargetedByPlayer()
NSString * getSystemName:(OOSystemID sys)
OOCommodityMarket * commodityMarket
OOPlanetEntity * planet()
OOSystemDescriptionManager * systemManager
NSPoint findSystemCoordinatesWithPrefix:exactMatch:(NSString *p_fix,[exactMatch] BOOL exactMatch)
BOOL _permanentMessageLog
BOOL inInterstellarSpace()
BOOL _witchspaceBreakPattern
void loadConditionScripts()
static void PreloadOneSound(NSString *soundName)
void setViewDirection:(OOViewID vd)
ShipEntity * newShipWithName:usePlayerProxy:(NSString *shipKey,[usePlayerProxy] BOOL OO_RETURNS_RETAINED)
OOTimeDelta next_repopulation
void setSystemDataForGalaxy:planet:key:value:fromManifest:forLayer:(OOGalaxyID gnum,[planet] OOSystemID pnum,[key] NSString *key,[value] id object,[fromManifest] NSString *manifest,[forLayer] OOSystemLayer layer)
ShipEntity * addWreckageFrom:withRole:at:scale:lifetime:(ShipEntity *ship,[withRole] NSString *wreckRole,[at] HPVector rpos,[scale] GLfloat scale,[lifetime] GLfloat lifetime)
BOOL removeEntity:(Entity *entity)
void setCurrentPostFX:(int newCurrentPostFX)
NSString * getSystemInhabitants:plural:(OOSystemID sys,[plural] BOOL plural)
Entity * sortedEntities[UNIVERSE_MAX_ENTITIES+1]
GLfloat main_light_position[4]
NSArray * addShipsAt:withRole:quantity:withinRadius:asGroup:(HPVector pos,[withRole] NSString *role,[quantity] unsigned count,[withinRadius] GLfloat radius,[asGroup] BOOL isGroup)
void setSkyColorRed:green:blue:alpha:(GLfloat red,[green] GLfloat green,[blue] GLfloat blue,[alpha] GLfloat alpha)
void showGUIMessage:withScroll:andColor:overDuration:(NSString *text,[withScroll] BOOL scroll,[andColor] OOColor *selectedColor,[overDuration] OOTimeDelta how_long)
BOOL _dockingClearanceProtocolActive
BOOL setUseAddOns:fromSaveGame:forceReinit:(NSString *newUse,[fromSaveGame] BOOL saveGame,[forceReinit] BOOL force)
static BOOL IsFriendlyStationPredicate(Entity *entity, void *parameter)
ShipEntity * firstShipHitByLaserFromShip:inDirection:offset:gettingRangeFound:(ShipEntity *srcEntity,[inDirection] OOWeaponFacing direction,[offset] Vector offset,[gettingRangeFound] GLfloat *range_ptr)
ShipEntity * newShipWithName:usePlayerProxy:isSubentity:andScaleFactor:(NSString *shipKey,[usePlayerProxy] BOOL usePlayerProxy,[isSubentity] BOOL isSubentity,[andScaleFactor] float OO_RETURNS_RETAINED)
NSPoint coordinatesForSystem:(OOSystemID s)
void initTargetFramebufferWithViewSize:(NSSize viewSize)
NSArray * neighboursToSystem:(OOSystemID system_number)
OOTimeAbsolute countdown_messageRepeatTime
void setGameView:(MyOpenGLView *view)
NSMutableSet * entitiesDeadThisUpdate
NSArray * shipsForSaleForSystem:withTL:atTime:(OOSystemID s,[withTL] OOTechLevelID specialTL,[atTime] OOTimeAbsolute current_time)
HPVector locationByCode:withSun:andPlanet:(NSString *code,[withSun] OOSunEntity *sun,[andPlanet] OOPlanetEntity *planet)
NSString * getRandomCommodity()
void fillCargopodWithRandomCargo:(ShipEntity *cargopod)
void verifyDescriptions()
void startSpeakingString:(NSString *text)
GLfloat airResistanceFactor
NSString * randomShipKeyForRoleRespectingConditions:(NSString *role)
void addConditionScripts:(NSEnumerator *scripts)
double timeAccelerationFactor()
BOOL addEntity:(Entity *entity)
id findOneEntityMatchingPredicate:parameter:(EntityFilterPredicate predicate,[parameter] void *parameter)
NSDictionary * currentWaypoints()
NSString * keyForPlanetOverridesForSystem:inGalaxy:(OOSystemID s,[inGalaxy] OOGalaxyID g)
OOTimeAbsolute messageRepeatTime
NSMutableArray * allPlanets
Class shipClassForShipDictionary:(NSDictionary *dict)
NSString * chooseStringForKey:inDictionary:(NSString *key, [inDictionary] NSDictionary *dictionary)
GameController * gameController()
NSDictionary * generateSystemData:(OOSystemID s)
NSString * keyForInterstellarOverridesForSystems:s2:inGalaxy:(OOSystemID s1,[s2] OOSystemID s2,[inGalaxy] OOGalaxyID g)
void setLastBeacon:(Entity< OOBeaconEntity > *beacon)
StationEntity * station()
Entity< OOBeaconEntity > * firstBeacon()
GLfloat safeWitchspaceExitDistance()
void addCommsMessage:forCount:andShowComms:logOnly:(NSString *text,[forCount] OOTimeDelta count,[andShowComms] BOOL showComms,[logOnly] BOOL logOnly)
Quaternion getWitchspaceExitRotation()
void selectIntro2NextCategory()
BOOL blockJSPlayerShipProps()
BOOL permanentMessageLog()
void findCollisionsAndShadows()
Entity * entity_for_uid[MAX_ENTITY_UID]
BOOL pauseMessageVisible()
static void VerifyDesc(NSString *key, id desc)
float randomDistanceWithinScanner()
OOTimeAbsolute universal_time
GuiDisplayGen * commLogGUI()
void setLibraryTextForDemoShip()
void setFirstBeacon:(Entity< OOBeaconEntity > *beacon)
StationEntity * cachedStation
void clearBeacon:(Entity< OOBeaconEntity > *beaconShip)
NSString * getSystemName:forGalaxy:(OOSystemID sys,[forGalaxy] OOGalaxyID gnum)
OOWeakReference * _lastBeacon
NSDictionary * generateSystemDataForGalaxy:planet:(OOGalaxyID gnum, [planet] OOSystemID pnum)
OOSystemID currentSystemID()
OOVisualEffectEntity * newVisualEffectWithName:(NSString *OO_RETURNS_RETAINED)
HPVector fractionalPositionFrom:to:withFraction:(HPVector point0, [to] HPVector point1, [withFraction] double routeFraction)
HPVector coordinatesForPosition:withCoordinateSystem:returningScalar:(HPVector pos,[withCoordinateSystem] NSString *system,[returningScalar] GLfloat *my_scalar)
void resizeTargetFramebufferWithViewSize:(NSSize viewSize)
BOOL witchspaceBreakPattern()
void makeSunSkimmer:andSetAI:(ShipEntity *ship,[andSetAI] BOOL setAI)
void selectIntro2PreviousCategory()
NSDictionary * missiontext
static OOComparisonResult comparePrice(id dict1, id dict2, void *context)
NSDictionary * demoShipData()
unsigned countShipsWithPrimaryRole:inRange:ofEntity:(NSString *role,[inRange] double range,[ofEntity] Entity *entity)
void setNextBeacon:(Entity< OOBeaconEntity > *beaconShip)
NSArray * equipmentDataOutfitting
OOCargoQuantity getRandomAmountOfCommodity:(OOCommodityType co_type)
NSPoint destinationCoordinates()
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
RANROTSeed RanrotSeedFromRandomSeed(Random_Seed seed)
RANROTSeed RANROTGetFullSeed(void)
void ranrot_srand(uint32_t seed)
void OOInitReallyRandom(uint64_t seed)
void RANROTSetFullSeed(RANROTSeed seed)
unsigned RanrotWithSeed(RANROTSeed *ioSeed)
double cunningFee(double value, double precision)
void seed_for_planet_description(Random_Seed s_seed)
RANROTSeed MakeRanrotSeed(uint32_t seed)
void rotate_seed(Random_Seed *seed_ptr)
OOINLINE double distanceBetweenPlanetPositions(int x1, int y1, int x2, int y2) INLINE_CONST_FUNC