27#import "MyOpenGLView.h"
98#if OO_LOCALIZATION_TOOLS
103#include <espeak/speak_lib.h>
113#define DEMO2_VANISHING_DISTANCE 650.0
114#define DEMO2_FLY_IN_STAGE_TIME 0.4
117#define MAX_NUMBER_OF_ENTITIES 200
118#define STANDARD_STATION_ROLL 0.4
120#define LANE_WIDTH 51200.0
131 1.0f, 1.0f, 1.0f, 1.0f,
132 1.0f, -1.0f, 1.0f, 0.0f,
133 -1.0f, -1.0f, 0.0f, 0.0f,
134 -1.0f, 1.0f, 0.0f, 1.0f
155#undef CACHE_ROUTE_FROM_SYSTEM_RESULTS
165+ (instancetype) elementWithLocation:(
OOSystemID) location parent:(
OOSystemID)parent cost:(
double) cost distance:(
double) distance time:(
double) time jumps:(
int) jumps;
177+ (instancetype) elementWithLocation:(
OOSystemID) location parent:(
OOSystemID) parent cost:(
double) cost distance:(
double) distance time:(
double) time jumps:(
int) jumps
188 return [
r autorelease];
177+ (instancetype) elementWithLocation:(
OOSystemID) location parent:(
OOSystemID) parent cost:(
double) cost distance:(
double) distance time:(
double) time jumps:(
int) jumps {
…}
201@interface Universe (OOPrivate)
203- (void) initTargetFramebufferWithViewSize:(NSSize)viewSize;
205- (void) resizeTargetFramebufferWithViewSize:(NSSize)viewSize;
209- (BOOL) doRemoveEntity:(
Entity *)entity;
212- (HPVector) fractionalPositionFrom:(HPVector)point0 to:(HPVector)point1 withFraction:(
double)routeFraction;
216- (NSString *)chooseStringForKey:(NSString *)key inDictionary:(NSDictionary *)dictionary;
218#if OO_LOCALIZATION_TOOLS
220- (void) dumpDebugGraphViz;
221- (void) dumpSystemDescriptionGraphViz;
223- (void) addNumericRefsInString:(NSString *)string toGraphViz:(NSMutableString *)graphViz fromNode:(NSString *)fromNode nodeCount:(NSUInteger)nodeCount;
233- (void) prunePreloadingPlanetMaterials;
239- (void) setFirstBeacon:(
Entity <OOBeaconEntity> *)beacon;
240- (void) setLastBeacon:(
Entity <OOBeaconEntity> *)beacon;
248- (Vector) randomPlaceWithinScannerFrom:(Vector)pos alongRoute:(Vector)route withOffset:(
double)offset;
267static GLfloat
sun_off[4] = {0.0, 0.0, 0.0, 1.0};
270#define DOCKED_AMBIENT_LEVEL 0.2f
271#define DOCKED_ILLUM_LEVEL 0.7f
278#define SUN_AMBIENT_INFLUENCE 0.75
280#define SKY_AMBIENT_ADJUSTMENT 0.0625
287- (void) setBloom: (BOOL)newBloom
287- (void) setBloom: (BOOL)newBloom {
…}
297- (void) setCurrentPostFX: (
int) newCurrentPostFX
297- (void) setCurrentPostFX: (
int) newCurrentPostFX {
…}
313- (void) terminatePostFX:(
int)postFX
313- (void) terminatePostFX:(
int)postFX {
…}
321- (
int) nextColorblindMode:(
int) index
321- (
int) nextColorblindMode:(
int) index {
…}
329- (
int) prevColorblindMode:(
int) index
329- (
int) prevColorblindMode:(
int) index {
…}
342- (void) initTargetFramebufferWithViewSize:(NSSize)viewSize
345 OOGL(glClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE));
346 OOGL(glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE));
347 OOGL(glClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE));
350 OOGL(glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &defaultDrawFBO));
352 GLint previousProgramID;
353 OOGL(glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgramID));
354 GLint previousTextureID;
355 OOGL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureID));
357 OOGL(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &previousVAO));
358 GLint previousArrayBuffer;
359 OOGL(glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &previousArrayBuffer));
360 GLint previousElementBuffer;
361 OOGL(glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &previousElementBuffer));
364 OOGL(glGenFramebuffers(1, &msaaFramebufferID));
365 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, msaaFramebufferID));
368 OOGL(glGenTextures(1, &msaaTextureID));
369 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID));
370 OOGL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, GL_TRUE));
371 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
372 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID, 0));
375 OOGL(glGenRenderbuffers(1, &msaaDepthBufferID));
376 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaDepthBufferID));
377 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
378 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
379 OOGL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, msaaDepthBufferID));
381 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
383 OOLogERR(
@"initTargetFramebufferWithViewSize.result",
@"%@",
@"***** Error: Multisample framebuffer not complete");
387 OOGL(glGenFramebuffers(1, &targetFramebufferID));
388 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, targetFramebufferID));
391 OOGL(glGenTextures(1, &targetTextureID));
392 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
393 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
394 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
395 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
398 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTextureID, 0));
401 OOGL(glGenRenderbuffers(1, &targetDepthBufferID));
402 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, targetDepthBufferID));
403 OOGL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
404 OOGL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, targetDepthBufferID));
406 GLenum attachment[1] = { GL_COLOR_ATTACHMENT0 };
407 OOGL(glDrawBuffers(1, attachment));
409 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
411 OOLogERR(
@"initTargetFramebufferWithViewSize.result",
@"%@",
@"***** Error: Framebuffer not complete");
414 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
416 targetFramebufferSize = viewSize;
424 OOGL(glGenFramebuffers(1, &passthroughFramebufferID));
425 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, passthroughFramebufferID));
428 OOGL(glGenTextures(2, passthroughTextureID));
429 for (
unsigned int i = 0; i < 2; i++)
431 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[i]));
432 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
433 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
434 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
437 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, passthroughTextureID[i], 0));
440 GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
441 OOGL(glDrawBuffers(2, attachments));
443 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
445 OOLogERR(
@"initTargetFramebufferWithViewSize.result",
@"%@",
@"***** Error: Passthrough framebuffer not complete");
447 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
450 OOGL(glGenFramebuffers(2, pingpongFBO));
451 OOGL(glGenTextures(2, pingpongColorbuffers));
452 for (
unsigned int i = 0; i < 2; i++)
454 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i]));
455 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]));
456 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
457 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
458 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
461 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongColorbuffers[i], 0));
463 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
465 OOLogERR(
@"initTargetFramebufferWithViewSize.result",
@"%@",
@"***** Error: Pingpong framebuffers not complete");
468 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))));
523 OOGL(glUseProgram(previousProgramID));
524 OOGL(glBindTexture(GL_TEXTURE_2D, previousTextureID));
525 OOGL(glBindVertexArray(previousVAO));
526 OOGL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, previousElementBuffer));
527 OOGL(glBindBuffer(GL_ARRAY_BUFFER, previousArrayBuffer));
342- (void) initTargetFramebufferWithViewSize:(NSSize)viewSize {
…}
534 OOGL(glDeleteTextures(1, &msaaTextureID));
535 OOGL(glDeleteTextures(1, &targetTextureID));
536 OOGL(glDeleteTextures(2, passthroughTextureID));
537 OOGL(glDeleteTextures(2, pingpongColorbuffers));
538 OOGL(glDeleteRenderbuffers(1, &msaaDepthBufferID));
539 OOGL(glDeleteRenderbuffers(1, &targetDepthBufferID));
540 OOGL(glDeleteFramebuffers(1, &msaaFramebufferID));
541 OOGL(glDeleteFramebuffers(1, &targetFramebufferID));
542 OOGL(glDeleteFramebuffers(2, pingpongFBO));
543 OOGL(glDeleteFramebuffers(1, &passthroughFramebufferID));
544 OOGL(glDeleteVertexArrays(1, &quadTextureVAO));
545 OOGL(glDeleteBuffers(1, &quadTextureVBO));
546 OOGL(glDeleteBuffers(1, &quadTextureEBO));
553- (void) resizeTargetFramebufferWithViewSize:(NSSize)viewSize
557 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID));
558 OOGL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, GL_TRUE));
559 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
562 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaDepthBufferID));
563 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
564 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
567 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
568 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
569 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
571 for (i = 0; i < 2; i++)
573 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]));
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));
578 for (i = 0; i < 2; i++)
580 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[i]));
581 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
582 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
586 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, targetDepthBufferID));
587 OOGL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
588 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
590 targetFramebufferSize.width = viewSize.width;
591 targetFramebufferSize.height = viewSize.height;
553- (void) resizeTargetFramebufferWithViewSize:(NSSize)viewSize {
…}
599 OOGL(glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &previousFBO));
600 GLint previousProgramID;
601 OOGL(glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgramID));
602 GLint previousTextureID;
603 OOGL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureID));
605 OOGL(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &previousVAO));
606 GLint previousActiveTexture;
607 OOGL(glGetIntegerv(GL_ACTIVE_TEXTURE, &previousActiveTexture));
609 OOGL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
611 OOGL(glDisable(GL_BLEND));
616 NSSize viewSize = [
gameView viewSize];
617 float fboResolution[2] = {viewSize.width, viewSize.height};
619 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, passthroughFramebufferID));
620 OOGL(glClear(GL_COLOR_BUFFER_BIT));
622 OOGL(glUseProgram(program));
623 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
624 OOGL(glUniform1i(glGetUniformLocation(program,
"image"), 0));
627 OOGL(glBindVertexArray(quadTextureVAO));
628 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
629 OOGL(glBindVertexArray(0));
631 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
634 BOOL horizontal = YES, firstIteration = YES;
635 unsigned int amount = [
self bloom] ? 10 : 0;
636 OOGL(glUseProgram(blur));
637 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([blurProgram program],
"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));
654 OOGL(glUseProgram(
final));
656 OOGL(glActiveTexture(GL_TEXTURE0));
657 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[0]));
658 OOGL(glUniform1i(glGetUniformLocation(
final,
"scene"), 0));
659 OOGL(glUniform1i(glGetUniformLocation(
final,
"bloom"), [
self bloom]));
660 OOGL(glUniform1f(glGetUniformLocation(
final,
"uTime"), [
self getTime]));
661 OOGL(glUniform2fv(glGetUniformLocation(
final,
"uResolution"), 1, fboResolution));
662 OOGL(glUniform1i(glGetUniformLocation(
final,
"uPostFX"), [
self currentPostFX]));
664 if([gameView hdrOutput])
666 OOGL(glUniform1f(glGetUniformLocation(
final,
"uMaxBrightness"), [gameView hdrMaxBrightness]));
667 OOGL(glUniform1f(glGetUniformLocation(
final,
"uPaperWhiteBrightness"), [gameView hdrPaperWhiteBrightness]));
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));
697 [
NSException raise:NSInternalInconsistencyException format:@"%s: expected only one Universe to exist at a time.", __PRETTY_FUNCTION__];
703 if (
self ==
nil)
return nil;
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];
755 OOLog(
@"MSAA.setup",
@"Multisample anti-aliasing %@requested.", [inGameView msaa] ?
@"" :
@"not ");
762#if OOLITE_SPEECH_SYNTH
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.");
781 espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 100, NULL, 0);
782 espeak_SetParameter(espeakPUNCTUATION, espeakPUNCT_NONE, 0);
783 espeak_SetParameter(espeakVOLUME, volume, 0);
784 espeak_voices = espeak_ListVoices(NULL);
785 for (espeak_voice_count = 0;
787 ++espeak_voice_count)
846#if OO_LOCALIZATION_TOOLS
849 [
self dumpDebugGraphViz];
864 [currentMessage release];
874 [_descriptions release];
875 [characters release];
876 [customSounds release];
877 [globalSettings release];
879 [missiontext release];
880 [equipmentData release];
881 [equipmentDataOutfitting release];
882 [demo_ships release];
884 [screenBackgrounds release];
886 [populatorSettings release];
887 [system_repopulator release];
888 [allPlanets release];
889 [allStations release];
890 [explosionSettings release];
892 [activeWormholes release];
893 [characterPool release];
904 [entitiesDeadThisUpdate release];
908#if OOLITE_SPEECH_SYNTH
909 [speechArray release];
911 [speechSynthesizer release];
916 [conditionScripts release];
942- (void) setDoProcedurallyTexturedPlanets:(BOOL) value
945 [[
NSUserDefaults standardUserDefaults] setBool:doProcedurallyTexturedPlanets forKey:@"procedurally-textured-planets"];
942- (void) setDoProcedurallyTexturedPlanets:(BOOL) value {
…}
955- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame
955- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame {
…}
961- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame forceReinit:(BOOL)force
963 if (!force && [newUse isEqualToString:
useAddOns])
961- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame forceReinit:(BOOL)force {
…}
977 return [entities count];
992 for (i = 0; i < show_count; i++)
994 OOLog(
@"universe.objectDump",
@"Ent:%4u %@", i, [
sortedEntities[i] descriptionForObjDump]);
1000 OOLog(
@"universe.objectDump",
@"entities = %@", [
entities description]);
1007 return [
NSArray arrayWithArray:entities];
1018 NSString *pauseKey = [PLAYER keyBindingDescription2:@"key_pausebutton"];
1020 if ([player status] == STATUS_DOCKED)
1022 if ([
gui setForegroundTextureKey:
@"paused_docked_overlay"])
1034 if ([player guiScreen] != GUI_SCREEN_MAIN && [
gui setForegroundTextureKey:
@"paused_overlay"])
1059 ShipScriptEvent(context, player,
"shipWillEnterWitchspace", STRING_TO_JSVAL(JS_InternString(context, [[player jumpCause] UTF8String])), INT_TO_JSVAL(dest));
1074 if (![wormhole withMisjump])
1097 [UNIVERSE setSkyColorRed:0.0f
1125 if (dockedStation && !interstel)
1133 Entity *ent = [entities objectAtIndex:index];
1134 if ((ent != player)&&(ent != dockedStation))
1151 if (!dockedStation || !interstel)
1157 if ([dockedStation maxFlightSpeed] > 0)
1160 HPVector pos = [UNIVERSE getWitchspaceExitPosition];
1164 if (abs((
int)d1) < 2750)
1166 d1 += ((d1 > 0.0)? 2750.0f: -2750.0f);
1187 [UNIVERSE setSkyColorRed:0.0f
1212 player = [PLAYER retain];
1248 player = [PLAYER retain];
1290 thing = [[
SkyEntity alloc] initWithColors:col1:col2 andSystemInfo: systeminfo];
1310 NSString *populator = [
systeminfo oo_stringForKey:@"populator" defaultValue:@"interstellarSpaceWillPopulate"];
1311 [system_repopulator release];
1314 [PLAYER doWorldScriptEvent:OOJSIDFromString(populator) inContext:context withArguments:NULL count:0 timeLimit:kOOJSLongTimeLimit];
1319 NSArray *script_actions = [
systeminfo oo_arrayForKey:@"script_actions"];
1320 if (script_actions !=
nil)
1322 OOStandardsDeprecated([NSString stringWithFormat:
@"The script_actions system info key is deprecated for %@.",override_key]);
1345 [
planetDict oo_setBool:YES forKey:@"mainForLocalSystem"];
1346 OOPlanetEntity *a_planet = [[
OOPlanetEntity alloc] initFromDictionary:planetDict withAtmosphere:[
planetDict oo_boolForKey:@"has_atmosphere" defaultValue:YES] andSeed:systemSeed forSystem:systemID];
1348 double planet_zpos = [
planetDict oo_floatForKey:@"planet_distance" defaultValue:500000];
1349 planet_zpos *= [
planetDict oo_floatForKey:@"planet_distance_multiplier" defaultValue:1.0];
1351#ifdef OO_DUMP_PLANETINFO
1352 OOLog(
@"planetinfo.record",
@"planet zpos = %f",planet_zpos);
1359 OOPlanetEntity *tmp=[allPlanets objectAtIndex:0];
1361 [allPlanets removeObject:a_planet];
1363 [allPlanets replaceObjectAtIndex:0 withObject:a_planet];
1382 OOPlanetEntity *a_planet;
1384 HPVector stationPos;
1390 unsigned techlevel = [
systeminfo oo_unsignedIntForKey:KEY_TECHLEVEL];
1391 NSString *stationDesc =
nil, *defaultStationDesc =
nil;
1400 sunGoneNova = [
systeminfo oo_boolForKey:@"sun_gone_nova" defaultValue:NO];
1412#ifdef OO_DUMP_PLANETINFO
1413 OOLog(
@"planetinfo.record",
@"seed = %d %d %d %d",system_seed.c,system_seed.d,system_seed.e,system_seed.f);
1414 OOLog(
@"planetinfo.record",
@"coordinates = %d %d",system_seed.d,system_seed.b);
1416#define SPROP(PROP) OOLog(@"planetinfo.record",@#PROP " = \"%@\";",[systeminfo oo_stringForKey:@"" #PROP]);
1417#define IPROP(PROP) OOLog(@"planetinfo.record",@#PROP " = %d;",[systeminfo oo_intForKey:@#PROP]);
1418#define FPROP(PROP) OOLog(@"planetinfo.record",@#PROP " = %f;",[systeminfo oo_floatForKey:@"" #PROP]);
1423 IPROP(productivity);
1436 float h2 = h1 + 1.0 / (1.0 + (
Ranrot() % 5));
1442 thing = [[
SkyEntity alloc] initWithColors:col1:col2 andSystemInfo: systeminfo];
1457 dict_object=[
systeminfo objectForKey:@"sun_color"];
1458 if (dict_object!=
nil)
1479 float defaultSunFlare =
randf()*0.1;
1480 float defaultSunHues = 0.5+
randf()*0.5;
1487 double planet_radius = [
a_planet radius];
1496 double sun_distance;
1497 double sunDistanceModifier;
1498 double safeDistance;
1501 sunDistanceModifier = [
systeminfo oo_nonNegativeDoubleForKey:@"sun_distance_modifier" defaultValue:0.0];
1502 if (sunDistanceModifier < 6.0)
1504 sun_distance = [
systeminfo oo_nonNegativeDoubleForKey:@"sun_distance" defaultValue:(planet_radius*20)];
1506 sun_distance *= [
systeminfo oo_nonNegativeDoubleForKey:@"sun_distance_multiplier" defaultValue:1];
1510 sun_distance = planet_radius * sunDistanceModifier;
1513 sun_radius = [
systeminfo oo_nonNegativeDoubleForKey:@"sun_radius" defaultValue:2.5 * planet_radius];
1515 if ((sun_radius < 1000.0) || (sun_radius > sun_distance / 2 && !sunGoneNova))
1517 OOLogWARN(
@"universe.setup.badSun",
@"Sun radius of %f is not valid for this system",sun_radius);
1518 sun_radius = sun_radius < 1000.0 ? 1000.0 : (sun_distance / 2);
1520#ifdef OO_DUMP_PLANETINFO
1521 OOLog(
@"planetinfo.record",
@"sun_radius = %f",sun_radius);
1523 safeDistance=36 * sun_radius * sun_radius;
1527 HPVector sun_dir = [
systeminfo oo_hpvectorForKey:@"sun_vector"];
1528 sun_distance /= 2.0;
1531 sun_distance *= 2.0;
1532 sunPos = HPvector_subtract([a_planet position],
1533 HPvector_multiply_scalar(sun_dir,sun_distance));
1537 while (HPmagnitude2(sunPos) < safeDistance);
1541 [
a_planet setOrientation:quaternion_rotation_betweenHP(sun_dir,make_HPvector(1.0,0.0,0.0))];
1543#ifdef OO_DUMP_PLANETINFO
1544 OOLog(
@"planetinfo.record",
@"sun_vector = %.3f %.3f %.3f",vf.x,vf.y,vf.z);
1545 OOLog(
@"planetinfo.record",
@"sun_distance = %.0f",sun_distance);
1551 [
sun_dict setObject:[
NSNumber numberWithDouble:sun_radius] forKey:@"sun_radius"];
1552 dict_object=[
systeminfo objectForKey: @"corona_shimmer"];
1553 if (dict_object!=
nil) [
sun_dict setObject:dict_object forKey:@"corona_shimmer"];
1554 dict_object=[
systeminfo objectForKey: @"corona_hues"];
1555 if (dict_object!=
nil)
1557 [
sun_dict setObject:dict_object forKey:@"corona_hues"];
1561 [
sun_dict setObject:[
NSNumber numberWithFloat:defaultSunHues] forKey:@"corona_hues"];
1563 dict_object=[
systeminfo objectForKey: @"corona_flare"];
1564 if (dict_object!=
nil)
1566 [
sun_dict setObject:dict_object forKey:@"corona_flare"];
1570 [
sun_dict setObject:[
NSNumber numberWithFloat:defaultSunFlare] forKey:@"corona_flare"];
1572 dict_object=[
systeminfo objectForKey:KEY_SUNNAME];
1573 if (dict_object!=
nil)
1575 [
sun_dict setObject:dict_object forKey:KEY_SUNNAME];
1577#ifdef OO_DUMP_PLANETINFO
1578 OOLog(
@"planetinfo.record",
@"corona_flare = %f",[sun_dict oo_floatForKey:
@"corona_flare"]);
1579 OOLog(
@"planetinfo.record",
@"corona_hues = %f",[sun_dict oo_floatForKey:
@"corona_hues"]);
1580 OOLog(
@"planetinfo.record",
@"sun_color = %@",[bgcolor descriptionComponents]);
1582 a_sun = [[
OOSunEntity alloc] initSunWithColor:bgcolor andDictionary:sun_dict];
1604 vf = [
systeminfo oo_vectorForKey:@"station_vector"];
1605#ifdef OO_DUMP_PLANETINFO
1606 OOLog(
@"planetinfo.record",
@"station_vector = %.3f %.3f %.3f",vf.x,vf.y,vf.z);
1608 stationPos = HPvector_subtract(stationPos, vectorToHPVector(vector_multiply_scalar(vf, 2.0 * planet_radius)));
1612 stationDesc = [
systeminfo oo_stringForKey:@"station" defaultValue:@"coriolis"];
1613#ifdef OO_DUMP_PLANETINFO
1614 OOLog(
@"planetinfo.record",
@"station = %@",stationDesc);
1617 a_station = (
StationEntity *)[
self newShipWithRole:stationDesc];
1629 if (![a_station isStation] || ![a_station validForAddToUniverse])
1631 if (a_station ==
nil)
1634 OOLog(
@"universe.setup.badStation",
@"Failed to set up a ship for role \"%@\
" as system station, trying again with \"%@\".", stationDesc, defaultStationDesc);
1638 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);
1641 stationDesc = defaultStationDesc;
1642 a_station = (
StationEntity *)[
self newShipWithRole:stationDesc];
1644 if (![a_station isStation] || ![a_station validForAddToUniverse])
1646 if (a_station ==
nil)
1648 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);
1652 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);
1656 a_station = (
StationEntity *)[
self newShipWithName:
@"coriolis-station"];
1657 if (![a_station isStation] || ![a_station validForAddToUniverse])
1659 OOLog(
@"universe.setup.badStation",
@"%@",
@"Could not create built-in Coriolis station! Generating a stationless system.");
1665 if (a_station !=
nil)
1700 BOOL sunGoneNova = [
systeminfo oo_boolForKey:@"sun_gone_nova"];
1706 HPVector v0 = make_HPvector(0,0,34567.89);
1707 double min_safe_dist2 = 6000000.0 * 6000000.0;
1709 while (HPmagnitude2(
cachedSun->position) < min_safe_dist2)
1713 sunPos = HPvector_add(sunPos, v0);
1728 if ([
PLAYER status] != STATUS_START_GAME)
1730 NSString *populator = [
systeminfo oo_stringForKey:@"populator" defaultValue:(sunGoneNova)?@"novaSystemWillPopulate":@"systemWillPopulate"];
1731 [system_repopulator release];
1732 system_repopulator = [[
systeminfo oo_stringForKey:@"repopulator" defaultValue:(sunGoneNova)?@"novaSystemWillRepopulate":@"systemWillRepopulate"] retain];
1735 [PLAYER doWorldScriptEvent:OOJSIDFromString(populator) inContext:context withArguments:NULL count:0 timeLimit:kOOJSLongTimeLimit];
1743 NSArray *script_actions = [
systeminfo oo_arrayForKey:@"script_actions"];
1744 if (script_actions !=
nil)
1746 OOStandardsDeprecated([NSString stringWithFormat:
@"The script_actions system info key is deprecated for %@.",[
self getSystemName:
systemID]]);
1750 [PLAYER runUnsanitizedScriptActions:script_actions
1751 allowingAIMethods:NO
1752 withContextName:@"<system script_actions>"
1764 [populatorSettings release];
1775- (void) setPopulatorSetting:(NSString *)key to:(NSDictionary *)setting
1779 [populatorSettings removeObjectForKey:key];
1783 [populatorSettings setObject:setting forKey:key];
1775- (void) setPopulatorSetting:(NSString *)key to:(NSDictionary *)setting {
…}
1794- (void) populateSystemFromDictionariesWithSun:(
OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet
1797 NSArray *blocks = [populatorSettings allValues];
1798 NSEnumerator *enumerator = [[
blocks sortedArrayUsingFunction:populatorPrioritySort context:nil] objectEnumerator];
1799 NSDictionary *populator =
nil;
1801 uint32_t i, locationSeed, groupCount, rndvalue;
1804 NSString *locationCode =
nil;
1806 while ((populator = [enumerator nextObject]))
1815 locationSeed = [
populator oo_unsignedIntForKey:@"locationSeed" defaultValue:0];
1816 groupCount = [
populator oo_unsignedIntForKey:@"groupCount" defaultValue:1];
1818 for (i = 0; i < groupCount; i++)
1820 locationCode = [
populator oo_stringForKey:@"location" defaultValue:@"COORDINATES"];
1821 if ([locationCode isEqualToString:
@"COORDINATES"])
1823 location = [
populator oo_hpvectorForKey:@"coordinates" defaultValue:kZeroHPVector];
1827 if (locationSeed != 0)
1854 if(locationSeed != 0)
1861 pdef = [
populator objectForKey:@"callbackObj"];
1794- (void) populateSystemFromDictionariesWithSun:(
OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet {
…}
1884- (HPVector) locationByCode:(NSString *)code withSun:(
OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet
1887 if ([code isEqualToString:
@"WITCHPOINT"] ||
sun ==
nil ||
planet ==
nil || [
sun goneNova])
1894 if ([code isEqualToString:
@"LANE_WPS"])
1897 double l1 = HPmagnitude([
planet position]);
1898 double l2 = HPmagnitude(HPvector_subtract([
sun position],[
planet position]));
1899 double l3 = HPmagnitude([
sun position]);
1900 double total = l1+l2+l3;
1901 float choice =
randf();
1902 if (choice < l1/total)
1906 else if (choice < (l1+l2)/total)
1915 else if ([code isEqualToString:
@"LANE_WP"])
1919 else if ([code isEqualToString:
@"LANE_WS"])
1923 else if ([code isEqualToString:
@"LANE_PS"])
1927 else if ([code isEqualToString:
@"STATION_AEGIS"])
1935 else if ([code isEqualToString:
@"PLANET_ORBIT_LOW"])
1939 else if ([code isEqualToString:
@"PLANET_ORBIT"])
1943 else if ([code isEqualToString:
@"PLANET_ORBIT_HIGH"])
1947 else if ([code isEqualToString:
@"STAR_ORBIT_LOW"])
1951 else if ([code isEqualToString:
@"STAR_ORBIT"])
1955 else if ([code isEqualToString:
@"STAR_ORBIT_HIGH"])
1959 else if ([code isEqualToString:
@"TRIANGLE"])
1972 result = HPvector_add(HPvector_multiply_scalar([
planet position],r),HPvector_multiply_scalar([
sun position],s));
1977 else if ([code isEqualToString:
@"INNER_SYSTEM"])
1984 }
while (HPdistance2(result,[
sun position]) < [
sun radius]*[
sun radius]*9.0);
1986 else if ([code isEqualToString:
@"INNER_SYSTEM_OFFPLANE"])
1990 else if ([code isEqualToString:
@"OUTER_SYSTEM"])
1996 else if ([code isEqualToString:
@"OUTER_SYSTEM_OFFPLANE"])
1884- (HPVector) locationByCode:(NSString *)code withSun:(
OOSunEntity *)sun andPlanet:(OOPlanetEntity *)planet {
…}
2010- (void) setAmbientLightLevel:(
float)newValue
2012 NSAssert(
UNIVERSE !=
nil,
@"Attempt to set ambient light level with a non yet existent universe.");
2010- (void) setAmbientLightLevel:(
float)newValue {
…}
2045 GLfloat sun_pos[] = {0.0, 0.0, 0.0, 1.0};
2046 GLfloat sun_ambient[] = {0.0, 0.0, 0.0, 1.0};
2057 OOGL(glLightfv(GL_LIGHT1, GL_AMBIENT, sun_ambient));
2070 OOGL(glLightfv(GL_LIGHT1, GL_AMBIENT, sun_ambient));
2075 OOGL(glLightfv(GL_LIGHT1, GL_POSITION, sun_pos));
2108- (void) setMainLightPosition: (Vector) sunPos
2108- (void) setMainLightPosition: (Vector) sunPos {
…}
2117- (
ShipEntity *) addShipWithRole:(NSString *)desc launchPos:(HPVector)launchPos rfactor:(GLfloat)rfactor
2122 launchPos.x += 2 * rfactor * (
randf() - 0.5);
2123 launchPos.y += 2 * rfactor * (
randf() - 0.5);
2124 launchPos.z += 2 * rfactor * (
randf() - 0.5);
2137 if (![ship crew] && ![ship isUnpiloted])
2142 if ([ship scanClass] == CLASS_NOT_SET)
2117- (
ShipEntity *) addShipWithRole:(NSString *)desc launchPos:(HPVector)launchPos rfactor:(GLfloat)rfactor {
…}
2154- (void) addShipWithRole:(NSString *) desc nearRouteOneAt:(
double) route_fraction
2154- (void) addShipWithRole:(NSString *) desc nearRouteOneAt:(
double) route_fraction {
…}
2170- (HPVector) coordinatesForPosition:(HPVector) pos withCoordinateSystem:(NSString *) system returningScalar:(GLfloat*) my_scalar
2207 NSString* l_sys = [
system lowercaseString];
2208 if ([l_sys length] != 3)
2210 OOPlanetEntity* the_planet = [
self planet];
2212 if (the_planet ==
nil || the_sun ==
nil || [l_sys isEqualToString:
@"abs"])
2214 if (my_scalar) *my_scalar = 1.0;
2218 HPVector p_pos = the_planet->
position;
2219 HPVector s_pos = the_sun->
position;
2221 const char* c_sys = [
l_sys UTF8String];
2222 HPVector p0, p1, p2;
2231 p1 = p_pos; p2 = s_pos;
break;
2233 p1 = s_pos; p2 = p_pos;
break;
2243 p1 = w_pos; p2 = s_pos;
break;
2245 p1 = s_pos; p2 = w_pos;
break;
2255 p1 = w_pos; p2 = p_pos;
break;
2257 p1 = p_pos; p2 = w_pos;
break;
2265 HPVector k = HPvector_normal_or_zbasis(HPvector_subtract(p1, p0));
2266 HPVector v = HPvector_normal_or_xbasis(HPvector_subtract(p2, p0));
2268 HPVector j = HPcross_product(k, v);
2269 HPVector i = HPcross_product(j, k);
2271 GLfloat scale = 1.0;
2283 scale = HPmagnitude(HPvector_subtract(p1, p0));
2297 HPVector result = p0;
2298 result.x += scale * (pos.x * i.x + pos.y * j.x + pos.z * k.x);
2299 result.y += scale * (pos.x * i.y + pos.y * j.y + pos.z * k.y);
2300 result.z += scale * (pos.x * i.z + pos.y * j.z + pos.z * k.z);
2170- (HPVector) coordinatesForPosition:(HPVector) pos withCoordinateSystem:(NSString *) system returningScalar:(GLfloat*) my_scalar {
…}
2306- (NSString *) expressPosition:(HPVector) pos inCoordinateSystem:(NSString *) system
2309 return [
NSString stringWithFormat:@"%@ %.2f %.2f %.2f", system, result.x, result.y, result.z];
2306- (NSString *) expressPosition:(HPVector) pos inCoordinateSystem:(NSString *) system {
…}
2313- (HPVector) legacyPositionFrom:(HPVector) pos asCoordinateSystem:(NSString *) system
2315 NSString* l_sys = [
system lowercaseString];
2316 if ([l_sys length] != 3)
2318 OOPlanetEntity* the_planet = [
self planet];
2320 if (the_planet ==
nil || the_sun ==
nil || [l_sys isEqualToString:
@"abs"])
2325 HPVector p_pos = the_planet->
position;
2326 HPVector s_pos = the_sun->
position;
2328 const char* c_sys = [
l_sys UTF8String];
2329 HPVector p0, p1, p2;
2338 p1 = p_pos; p2 = s_pos;
break;
2340 p1 = s_pos; p2 = p_pos;
break;
2350 p1 = w_pos; p2 = s_pos;
break;
2352 p1 = s_pos; p2 = w_pos;
break;
2362 p1 = w_pos; p2 = p_pos;
break;
2364 p1 = p_pos; p2 = w_pos;
break;
2372 HPVector k = HPvector_normal_or_zbasis(HPvector_subtract(p1, p0));
2373 HPVector v = HPvector_normal_or_xbasis(HPvector_subtract(p2, p0));
2375 HPVector j = HPcross_product(k, v);
2376 HPVector i = HPcross_product(j, k);
2378 GLfloat scale = 1.0;
2393 scale = 1.0f / HPdistance(p1, p0);
2405 HPVector r_pos = HPvector_subtract(pos, p0);
2406 HPVector result = make_HPvector(scale * (r_pos.x * i.x + r_pos.y * i.y + r_pos.z * i.z),
2407 scale * (r_pos.x * j.x + r_pos.y * j.y + r_pos.z * j.z),
2408 scale * (r_pos.x * k.x + r_pos.y * k.y + r_pos.z * k.z) );
2313- (HPVector) legacyPositionFrom:(HPVector) pos asCoordinateSystem:(NSString *) system {
…}
2414- (HPVector) coordinatesFromCoordinateSystemString:(NSString *) system_x_y_z
2417 if ([tokens
count] != 4)
2420 return make_HPvector(0,0,0);
2414- (HPVector) coordinatesFromCoordinateSystemString:(NSString *) system_x_y_z {
…}
2427- (BOOL) addShipWithRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system
2430 GLfloat scalar = 1.0;
2433 GLfloat rfactor = scalar;
2439 return ([
self addShipWithRole:desc launchPos:launchPos rfactor:rfactor] !=
nil);
2427- (BOOL) addShipWithRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system {
…}
2443- (BOOL) addShips:(
int) howMany withRole:(NSString *) desc atPosition:(HPVector) pos withCoordinateSystem:(NSString *) system
2446 GLfloat scalar = 1.0;
2448 GLfloat distance_from_center = 0.0;
2449 HPVector v_from_center, ship_pos;
2450 HPVector ship_positions[
howMany];
2452 int scale_up_after = 0;
2453 int current_shell = 0;
2454 GLfloat walk_factor = 2.0;
2458 if (ship ==
nil)
return NO;
2464 int limit_count = 8;
2471 v_from_center.x += walk_factor * (
randf() - 0.5);
2472 v_from_center.y += walk_factor * (
randf() - 0.5);
2473 v_from_center.z += walk_factor * (
randf() - 0.5);
2474 }
while ((v_from_center.x == 0.0)&&(v_from_center.y == 0.0)&&(v_from_center.z == 0.0));
2475 v_from_center = HPvector_normal(v_from_center);
2477 ship_pos = make_HPvector( launchPos.x + distance_from_center * v_from_center.x,
2478 launchPos.y + distance_from_center * v_from_center.y,
2479 launchPos.z + distance_from_center * v_from_center.z);
2484 while (safe && (j >= current_shell))
2486 safe = (safe && (HPdistance2(ship_pos, ship_positions[j]) > safe_distance2));
2495 distance_from_center += sqrt(safe_distance2);
2502 [
ship setScanClass:scanClass == CLASS_NOT_SET ? CLASS_NEUTRAL : scanClass];
2510 ship_positions[
i] = ship_pos;
2512 if (i > scale_up_after)
2515 scale_up_after += 1 + 2 * i;
2516 distance_from_center += sqrt(safe_distance2);
2443- (BOOL) addShips:(
int) howMany withRole:(NSString *) desc atPosition:(HPVector) pos withCoordinateSystem:(NSString *) system {
…}
2523- (BOOL) addShips:(
int) howMany withRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system
2526 GLfloat scalar = 1.0;
2528 GLfloat rfactor = scalar;
2533 BoundingBox launch_bbox;
2534 bounding_box_reset_to_vector(&launch_bbox, make_vector(launchPos.x - rfactor, launchPos.y - rfactor, launchPos.z - rfactor));
2535 bounding_box_add_xyz(&launch_bbox, launchPos.x + rfactor, launchPos.y + rfactor, launchPos.z + rfactor);
2523- (BOOL) addShips:(
int) howMany withRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system {
…}
2541- (BOOL) addShips:(
int) howMany withRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system withinRadius:(GLfloat) radius
2544 GLfloat scalar = 1.0;
2546 GLfloat rfactor = radius;
2549 BoundingBox launch_bbox;
2550 bounding_box_reset_to_vector(&launch_bbox, make_vector(launchPos.x - rfactor, launchPos.y - rfactor, launchPos.z - rfactor));
2551 bounding_box_add_xyz(&launch_bbox, launchPos.x + rfactor, launchPos.y + rfactor, launchPos.z + rfactor);
2541- (BOOL) addShips:(
int) howMany withRole:(NSString *) desc nearPosition:(HPVector) pos withCoordinateSystem:(NSString *) system withinRadius:(GLfloat) radius {
…}
2557- (BOOL) addShips:(
int) howMany withRole:(NSString *) desc intoBoundingBox:(BoundingBox) bbox
2564 int h0 = howMany / 2;
2565 int h1 = howMany - h0;
2567 GLfloat lx = bbox.max.x - bbox.min.x;
2568 GLfloat ly = bbox.max.y - bbox.min.y;
2569 GLfloat lz = bbox.max.z - bbox.min.z;
2570 BoundingBox bbox0 = bbox;
2571 BoundingBox bbox1 = bbox;
2572 if ((lx > lz)&&(lx > ly))
2574 bbox0.min.x += 0.5 * lx;
2575 bbox1.max.x -= 0.5 * lx;
2581 bbox0.min.y += 0.5 * ly;
2582 bbox1.max.y -= 0.5 * ly;
2586 bbox0.min.z += 0.5 * lz;
2587 bbox1.max.z -= 0.5 * lz;
2591 return ([
self addShips: h0 withRole: desc intoBoundingBox: bbox0] && [
self addShips: h1 withRole: desc intoBoundingBox: bbox1]);
2595 HPVector pos = make_HPvector(bbox.min.x, bbox.min.y, bbox.min.z);
2596 pos.x += 0.5 * (
randf() +
randf()) * (bbox.max.x - bbox.min.x);
2597 pos.y += 0.5 * (
randf() +
randf()) * (bbox.max.y - bbox.min.y);
2598 pos.z += 0.5 * (
randf() +
randf()) * (bbox.max.z - bbox.min.z);
2600 return ([
self addShipWithRole:desc launchPos:pos rfactor:0.0] !=
nil);
2557- (BOOL) addShips:(
int) howMany withRole:(NSString *) desc intoBoundingBox:(BoundingBox) bbox {
…}
2604- (BOOL) spawnShip:(NSString *) shipdesc
2608 OOStandardsDeprecated([NSString stringWithFormat:
@"'spawn' via legacy script is deprecated as a way of adding ships for %@",shipdesc]);
2611 NSDictionary *shipdict =
nil;
2614 if (shipdict ==
nil)
return NO;
2618 if (ship ==
nil)
return NO;
2621 NSDictionary *spawndict = [
shipdict oo_dictionaryForKey:@"spawn"];
2622 HPVector pos, rpos, spos;
2623 NSString *positionString =
nil;
2626 positionString = [
spawndict oo_stringForKey:@"position"];
2627 if (positionString !=
nil)
2629 if([positionString hasPrefix:
@"abs "] && ([
self planet] !=
nil || [
self sun] !=
nil))
2631 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);
2640 OOLogERR(
@"universe.spawnShip.error",
@"***** ERROR: failed to find a spawn position for ship %@.", shipdesc);
2645 positionString = [
spawndict oo_stringForKey:@"facing_position"];
2646 if (positionString !=
nil)
2648 if([positionString hasPrefix:
@"abs "] && ([
self planet] !=
nil || [
self sun] !=
nil))
2650 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);
2656 rpos = HPvector_subtract(rpos, spos);
2660 rpos = HPvector_normal(rpos);
2669 q1 = make_quaternion(0,1,0,0);
2604- (BOOL) spawnShip:(NSString *) shipdesc {
…}
2684- (void) witchspaceShipWithPrimaryRole:(NSString *)role
2688 NSDictionary *systeminfo =
nil;
2692 government = [
systeminfo oo_unsignedCharForKey:KEY_GOVERNMENT];
2697 if (ship && [ship hasRole:
@"cargopod"])
2704 if (([ship scanClass] == CLASS_NO_DRAW)||([ship scanClass] == CLASS_NOT_SET))
2706 if ([role isEqual:
@"trader"])
2709 if ([ship hasRole:
@"sunskim-trader"] &&
randf() < 0.25)
2719 if (([ship pendingEscortCount] > 0)&&((
Ranrot() % 7) < government))
2722 [
ship setPendingEscortCount:(nx > 0) ? nx : 0];
2725 if ([role isEqual:
@"pirate"])
2728 [
ship setBounty: (Ranrot() & 7) + (Ranrot() & 7) + ((randf() < 0.05)? 63 : 23)
withReason:kOOLegalStatusReasonSetup];
2730 if ([ship crew] ==
nil && ![ship isUnpiloted])
2684- (void) witchspaceShipWithPrimaryRole:(NSString *)role {
…}
2744 if (entity ==
nil)
return nil;
2771 [
vis setPosition:pos];
2772 [
vis setOrientation:OORandomQuaternion()];
2784- (
ShipEntity *) addShipAt:(HPVector)pos withRole:(NSString *)role withinRadius:(GLfloat)radius
2789 if (radius == NSNotFound)
2791 GLfloat scalar = 1.0;
2794 GLfloat rfactor = scalar;
2816 if (scanClass == CLASS_NOT_SET)
2818 scanClass = CLASS_NEUTRAL;
2822 if ([ship crew] ==
nil && ![ship isUnpiloted])
2831 BOOL trader = [
role isEqualToString:@"trader"];
2841 if (pendingEscortCount > 0)
2844 if ((
Ranrot() % 7) < government)
2846 int nx = pendingEscortCount - 2 * (1 + (
Ranrot() & 3));
2847 [
ship setPendingEscortCount:(nx > 0) ? nx : 0];
2862 if ([ship hasRole:
@"sunskim-trader"] &&
randf() < 0.25)
2872 else if ([role isEqual:
@"pirate"])
2874 [
ship setBounty:(Ranrot() & 7) + (Ranrot() & 7) + ((randf() < 0.05)? 63 : 23)
withReason:kOOLegalStatusReasonSetup];
2784- (
ShipEntity *) addShipAt:(HPVector)pos withRole:(NSString *)role withinRadius:(GLfloat)radius {
…}
2891- (NSArray *) addShipsAt:(HPVector)pos withRole:(NSString *)role quantity:(
unsigned)count withinRadius:(GLfloat)radius asGroup:(BOOL)isGroup
2895 NSMutableArray *ships = [
NSMutableArray arrayWithCapacity:count];
2911 [
ships addObject:ship];
2915 if ([ships
count] == 0)
return nil;
2917 return [[
ships copy] autorelease];
2891- (NSArray *) addShipsAt:(HPVector)pos withRole:(NSString *)role quantity:(
unsigned)count withinRadius:(GLfloat)radius asGroup:(BOOL)isGroup {
…}
2923- (NSArray *) addShipsToRoute:(NSString *)route withRole:(NSString *)role quantity:(
unsigned)count routeFraction:(
double)routeFraction asGroup:(BOOL)isGroup
2925 NSMutableArray *ships = [
NSMutableArray arrayWithCapacity:count];
2931 if ([route isEqualToString:
@"pw"] || [route isEqualToString:
@"sw"] || [route isEqualToString:
@"ps"])
2933 routeFraction = 1.0f - routeFraction;
2937 if ([route isEqualTo:
@"wp"] || [route isEqualTo:
@"pw"])
2941 if (entity ==
nil)
return nil;
2943 radius = [
entity radius];
2945 else if ([route isEqualTo:
@"ws"] || [route isEqualTo:
@"sw"])
2948 entity = [
self sun];
2949 if (entity ==
nil)
return nil;
2951 radius = [
entity radius];
2953 else if ([route isEqualTo:
@"sp"] || [route isEqualTo:
@"ps"])
2955 entity = [
self sun];
2956 if (entity ==
nil)
return nil;
2958 double radius0 = [
entity radius];
2961 if (entity ==
nil)
return nil;
2963 radius = [
entity radius];
2966 direction = HPvector_normal(HPvector_subtract(point0, point1));
2967 point0 = HPvector_subtract(point0, HPvector_multiply_scalar(direction, radius0 +
SCANNER_MAX_RANGE * 1.1f));
2969 else if ([route isEqualTo:
@"st"])
2979 direction = HPvector_normal(HPvector_subtract(point1, point0));
2980 point1 = HPvector_subtract(point1, HPvector_multiply_scalar(direction, radius +
SCANNER_MAX_RANGE * 1.1f));
2992 if (ship !=
nil) [
ships addObject:ship];
2996 if ([ships
count] == 0)
return nil;
2999 return [[
ships copy] autorelease];
2923- (NSArray *) addShipsToRoute:(NSString *)route withRole:(NSString *)role quantity:(
unsigned)count routeFraction:(
double)routeFraction asGroup:(BOOL)isGroup {
…}
3003- (BOOL) roleIsPirateVictim:(NSString *)role
3003- (BOOL) roleIsPirateVictim:(NSString *)role {
…}
3009- (BOOL) role:(NSString *)role isInCategory:(NSString *)category
3011 NSSet *categoryInfo = [roleCategories objectForKey:category];
3012 if (categoryInfo ==
nil)
3009- (BOOL) role:(NSString *)role isInCategory:(NSString *)category {
…}
3030 if ([my_target isWormhole])
3034 else if ([[[my_ship getAI] state] isEqualToString:
@"ENTER_WORMHOLE"])
3046 if ([
PLAYER status] != STATUS_ENTERING_WITCHSPACE && [
PLAYER status] != STATUS_EXITING_WITCHSPACE)
3059 if ([e2 isShip] && [(
ShipEntity*)e2 hasPrimaryRole:
@"buoy-witchpoint"])
3068- (void) setUpBreakPattern:(HPVector) pos orientation:(Quaternion) q forDocking:(BOOL) forDocking
3087 colorDesc = [[
self globalSettings] objectForKey:@"hyperspace_tunnel_color_1"];
3088 if (colorDesc !=
nil)
3091 if (color !=
nil) col1 = color;
3092 else OOLogWARN(
@"hyperspaceTunnel.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
3095 colorDesc = [[
self globalSettings] objectForKey:@"hyperspace_tunnel_color_2"];
3096 if (colorDesc !=
nil)
3099 if (color !=
nil) col2 = color;
3100 else OOLogWARN(
@"hyperspaceTunnel.fromDict",
@"could not interpret \"%@\
" as a colour.", colorDesc);
3104 GLfloat startAngle = 0;
3105 GLfloat aspectRatio = 1;
3109 NSDictionary *info = [[PLAYER dockedStation] shipInfoDictionary];
3110 sides = [
info oo_unsignedIntForKey:@"tunnel_corners" defaultValue:4];
3111 startAngle = [
info oo_floatForKey:@"tunnel_start_angle" defaultValue:45.0f];
3112 aspectRatio = [
info oo_floatForKey:@"tunnel_aspect_ratio" defaultValue:2.67f];
3115 for (i = 1; i < 11; i++)
3131 if (forDocking && ![[
PLAYER dockedStation] hasBreakPattern])
3068- (void) setUpBreakPattern:(HPVector) pos orientation:(Quaternion) q forDocking:(BOOL) forDocking {
…}
3151- (void) setWitchspaceBreakPattern:(BOOL)newValue
3151- (void) setWitchspaceBreakPattern:(BOOL)newValue {
…}
3163- (void) setDockingClearanceProtocolActive:(BOOL)newValue
3166 NSEnumerator *statEnum = [allStations objectEnumerator];
3174 while ((
station = [statEnum nextObject]))
3177 if (![[[registry shipInfoForKey:stationKey] allKeys] containsObject:
@"requires_docking_clearance"])
3163- (void) setDockingClearanceProtocolActive:(BOOL)newValue {
…}
3200- (void) setupIntroFirstGo:(BOOL)justCobra
3204 Quaternion q2 = { 0.0f, 0.0f, 1.0f, 0.0f };
3235 NSArray *subList =
nil;
3238 if ([[[subList oo_dictionaryAtIndex:0] oo_stringForKey:
kOODemoShipClass] isEqualToString:
@"ship"])
3241 NSDictionary *shipEntry =
nil;
3242 foreach (shipEntry, subList)
3244 if ([[shipEntry oo_stringForKey:
kOODemoShipKey] isEqualToString:
@"cobra3-trader"])
3266 [
ship setPositionX:0.0f
y:0.0f
z:DEMO2_VANISHING_DISTANCE * ship->collision_radius * 0.01];
3200- (void) setupIntroFirstGo:(BOOL)justCobra {
…}
3304 return [[
demo_ships oo_arrayAtIndex:demo_ship_index] oo_dictionaryAtIndex:demo_ship_subindex];
3314 [
gui setTabStops:tab_stops];
3323 NSString *field1 =
nil;
3324 NSString *field2 =
nil;
3325 NSString *field3 =
nil;
3326 NSString *
override =
nil;
3329 for (NSUInteger i=1;i<=26;i++)
3331 [
gui setText:@"" forRow:i];
3335 override = [
librarySettings oo_stringForKey:kOODemoShipClass defaultValue:@"ship"];
3342 override = [
librarySettings oo_stringForKey:kOODemoShipSummary defaultValue:nil];
3343 if (
override !=
nil)
3351 [
gui setArray:[
NSArray arrayWithObjects:field1,field2,field3,nil] forRow:1];
3363 override = [
librarySettings oo_stringForKey:kOODemoShipSpeed defaultValue:nil];
3364 if (
override !=
nil)
3366 if ([
override length] == 0)
3372 field1 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-speed-custom"),OOExpand(override)];
3381 override = [
librarySettings oo_stringForKey:kOODemoShipTurnRate defaultValue:nil];
3382 if (
override !=
nil)
3384 if ([
override length] == 0)
3390 field2 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-turn-custom"),OOExpand(override)];
3399 override = [
librarySettings oo_stringForKey:kOODemoShipCargo defaultValue:nil];
3400 if (
override !=
nil)
3402 if ([
override length] == 0)
3408 field3 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-cargo-custom"),OOExpand(override)];
3417 [
gui setArray:[
NSArray arrayWithObjects:field1,field2,field3,nil] forRow:3];
3420 override = [
librarySettings oo_stringForKey:kOODemoShipGenerator defaultValue:nil];
3421 if (
override !=
nil)
3423 if ([
override length] == 0)
3429 field1 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-generator-custom"),OOExpand(override)];
3438 override = [
librarySettings oo_stringForKey:kOODemoShipShields defaultValue:nil];
3439 if (
override !=
nil)
3441 if ([
override length] == 0)
3447 field2 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-shields-custom"),OOExpand(override)];
3456 override = [
librarySettings oo_stringForKey:kOODemoShipWitchspace defaultValue:nil];
3457 if (
override !=
nil)
3459 if ([
override length] == 0)
3465 field3 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-witchspace-custom"),OOExpand(override)];
3474 [
gui setArray:[
NSArray arrayWithObjects:field1,field2,field3,nil] forRow:4];
3478 override = [
librarySettings oo_stringForKey:kOODemoShipWeapons defaultValue:nil];
3479 if (
override !=
nil)
3481 if ([
override length] == 0)
3487 field1 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-weapons-custom"),OOExpand(override)];
3495 override = [
librarySettings oo_stringForKey:kOODemoShipTurrets defaultValue:nil];
3496 if (
override !=
nil)
3498 if ([
override length] == 0)
3504 field2 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-turrets-custom"),OOExpand(override)];
3512 override = [
librarySettings oo_stringForKey:kOODemoShipSize defaultValue:nil];
3513 if (
override !=
nil)
3515 if ([
override length] == 0)
3521 field3 = [
NSString stringWithFormat:DESC(@"oolite-ship-library-size-custom"),OOExpand(override)];
3529 [
gui setArray:[
NSArray arrayWithObjects:field1,field2,field3,nil] forRow:5];
3532 override = [
librarySettings oo_stringForKey:kOODemoShipDescription defaultValue:nil];
3533 if (
override !=
nil)
3535 [
gui addLongText:OOExpand(override) startingAtRow:descRow align:GUI_ALIGN_LEFT];
3540 field1 = [
NSString stringWithFormat:@"<-- %@",OOShipLibraryCategoryPlural([[[
demo_ships objectAtIndex:((demo_ship_index+[
demo_ships count]-1)%[
demo_ships count])] objectAtIndex:0] oo_stringForKey:kOODemoShipClass])];
3542 field3 = [
NSString stringWithFormat:@"%@ -->",OOShipLibraryCategoryPlural([[[
demo_ships objectAtIndex:((demo_ship_index+1)%[
demo_ships count])] objectAtIndex:0] oo_stringForKey:kOODemoShipClass])];
3544 [
gui setArray:[
NSArray arrayWithObjects:field1,field2,field3,nil] forRow:19];
3548 NSArray *subList = [
demo_ships objectAtIndex:demo_ship_index];
3549 NSUInteger i,start = demo_ship_subindex - (demo_ship_subindex%5);
3550 NSUInteger end = start + 4;
3551 if (end >= [subList
count])
3558 for (i = start ; i <= end ; i++)
3560 field2 = [[
subList objectAtIndex:i] oo_stringForKey:kOODemoShipName];
3561 [
gui setArray:[
NSArray arrayWithObjects:field1,field2,field3,nil] forRow:row];
3562 if (i == demo_ship_subindex)
3576 [
gui setArray:[
NSArray arrayWithObjects:field1,field2,field3,nil] forRow:20];
3579 if (end < [subList
count]-1)
3581 [
gui setArray:[
NSArray arrayWithObjects:field1,field2,field3,nil] forRow:26];
3591 NSUInteger subcount = [[demo_ships objectAtIndex:demo_ship_index] count];
3645- (
StationEntity *) stationWithRole:(NSString *)role andPosition:(HPVector)position
3647 if ([role isEqualToString:
@""])
3652 float range = 1000000;
3658 if (HPdistance2(position,[
station position]) < range)
3660 if ([[
station primaryRole] isEqualToString:role])
3645- (
StationEntity *) stationWithRole:(NSString *)role andPosition:(HPVector)position {
…}
3706 return [allStations allObjects];
3728 if (playerStatus == STATUS_START_GAME)
return;
3738 Entity <OOBeaconEntity> *beaconShip = [
self firstBeacon], *next =
nil;
3758- (void) setFirstBeacon:(
Entity <OOBeaconEntity> *)beacon
3760 if (beacon != [
self firstBeacon])
3762 [
beacon setPrevBeacon:nil];
3766 _firstBeacon = [
beacon weakRetain];
3758- (void) setFirstBeacon:(
Entity <OOBeaconEntity> *)beacon {
…}
3777- (void) setLastBeacon:(
Entity <OOBeaconEntity> *)beacon
3779 if (beacon != [
self lastBeacon])
3781 [
beacon setNextBeacon:nil];
3785 _lastBeacon = [
beacon weakRetain];
3777- (void) setLastBeacon:(
Entity <OOBeaconEntity> *)beacon {
…}
3790- (void) setNextBeacon:(
Entity <OOBeaconEntity> *) beaconShip
3792 if ([beaconShip isBeacon])
3799 OOLog(
@"universe.beacon.error",
@"***** ERROR: Universe setNextBeacon '%@'. The ship has no beacon code set.", beaconShip);
3790- (void) setNextBeacon:(
Entity <OOBeaconEntity> *) beaconShip {
…}
3804- (void) clearBeacon:(
Entity <OOBeaconEntity> *) beaconShip
3806 Entity <OOBeaconEntity> *tmp =
nil;
3808 if ([beaconShip isBeacon])
3804- (void) clearBeacon:(
Entity <OOBeaconEntity> *) beaconShip {
…}
3838- (void) defineWaypoint:(NSDictionary *)definition forKey:(NSString *)key
3841 BOOL preserveCompass = NO;
3842 waypoint = [waypoints objectForKey:key];
3843 if (waypoint !=
nil)
3845 if ([
PLAYER compassTarget] == waypoint)
3847 preserveCompass = YES;
3850 [waypoints removeObjectForKey:key];
3852 if (definition !=
nil)
3855 if (waypoint !=
nil)
3858 [waypoints setObject:waypoint forKey:key];
3859 if (preserveCompass)
3861 [PLAYER setCompassTarget:waypoint];
3862 [PLAYER setNextBeacon:waypoint];
3838- (void) defineWaypoint:(NSDictionary *)definition forKey:(NSString *)key {
…}
3875- (void) setSkyColorRed:(GLfloat)red green:(GLfloat)green blue:(GLfloat)blue alpha:(GLfloat)alpha
3875- (void) setSkyColorRed:(GLfloat)red green:(GLfloat)green blue:(GLfloat)blue alpha:(GLfloat)alpha {
…}
3898#define PROFILE_SHIP_SELECTION 0
3901- (BOOL) canInstantiateShip:(NSString *)shipKey
3903 NSDictionary *shipInfo =
nil;
3904 NSArray *conditions =
nil;
3905 NSString *condition_script =
nil;
3908 condition_script = [
shipInfo oo_stringForKey:@"condition_script"];
3909 if (condition_script !=
nil)
3912 if (condScript !=
nil)
3916 JSBool allow_instantiation;
3925 if (OK) OK = JS_ValueToBoolean(context, result, &allow_instantiation);
3929 if (OK && !allow_instantiation)
3939 conditions = [
shipInfo oo_arrayForKey:@"conditions"];
3940 if (conditions ==
nil)
return YES;
3943 return [PLAYER scriptTestConditions:conditions];
3901- (BOOL) canInstantiateShip:(NSString *)shipKey {
…}
3947- (NSString *) randomShipKeyForRoleRespectingConditions:(NSString *)role
3952 NSString *shipKey =
nil;
3955#if PROFILE_SHIP_SELECTION
3956 static unsigned long profTotal = 0, profSlowPath = 0;
3962 if ([
self canInstantiateShip:shipKey])
return shipKey;
3971#if PROFILE_SHIP_SELECTION
3973 if ((profSlowPath % 10) == 0)
3975 OOLog(
@"shipRegistry.selection.profile",
@"Hit slow path in ship selection for role \"%@\
", having selected ship \"%@\". Now %lu of %lu on slow path (%f%%).", role, shipKey, profSlowPath, profTotal, ((
double)profSlowPath)/((
double)profTotal) * 100.0f);
3981 while ([pset
count] > 0)
3985 if ([
self canInstantiateShip:shipKey])
return shipKey;
3947- (NSString *) randomShipKeyForRoleRespectingConditions:(NSString *)role {
…}
4003 NSString *shipKey =
nil;
4004 NSDictionary *shipInfo =
nil;
4005 NSString *autoAI =
nil;
4016 if ([shipInfo oo_fuzzyBooleanForKey:
@"auto_ai" defaultValue:YES])
4025 if ([role isEqualToString:
@"pirate"]) [
ship setBounty:20 + randf() * 50
withReason:kOOLegalStatusReasonSetup];
4028 if ([role isEqualToString:
@"interceptor"])
4034 if ([role isEqualToString:
@"thargoid"]) [
ship setScanClass: CLASS_THARGOID];
4049 NSDictionary *effectDict =
nil;
4053 if (effectDict ==
nil)
return nil;
4059 @catch (NSException *exception)
4063 OOLog(
kOOLogException,
@"***** Oolite Exception : '%@' in [Universe newVisualEffectWithName: %@ ] *****", [exception reason], effectKey);
4065 else @throw exception;
4074- (
ShipEntity *) newSubentityWithName:(NSString *)shipKey andScaleFactor:(
float)scale
4074- (
ShipEntity *) newSubentityWithName:(NSString *)shipKey andScaleFactor:(
float)scale {
…}
4080- (
ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy
4080- (
ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy {
…}
4085- (
ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity
4085- (
ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity {
…}
4090- (
ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity andScaleFactor:(
float)scale
4094 NSDictionary *shipDict =
nil;
4098 if (shipDict ==
nil)
return nil;
4100 volatile Class shipClass =
nil;
4108 if (usePlayerProxy && shipClass == [
ShipEntity class])
4118 NSMutableDictionary *mShipDict = [
shipDict mutableCopy];
4119 [
mShipDict setObject:[
NSNumber numberWithFloat:scale] forKey:@"model_scale_factor"];
4120 shipDict = [
NSDictionary dictionaryWithDictionary:mShipDict];
4123 ship = [[
shipClass alloc] initWithKey:shipKey definition:shipDict];
4125 @catch (NSException *exception)
4129 OOLog(
kOOLogException,
@"***** Oolite Exception : '%@' in [Universe newShipWithName: %@ ] *****", [exception reason], shipKey);
4131 else @throw exception;
4090- (
ShipEntity *) newShipWithName:(NSString *)shipKey usePlayerProxy:(BOOL)usePlayerProxy isSubentity:(BOOL)isSubentity andScaleFactor:(
float)scale {
…}
4144- (
DockEntity *) newDockWithName:(NSString *)shipDataKey andScaleFactor:(
float)scale
4148 NSDictionary *shipDict =
nil;
4152 if (shipDict ==
nil)
return nil;
4158 NSMutableDictionary *mShipDict = [
shipDict mutableCopy];
4159 [
mShipDict setObject:[
NSNumber numberWithFloat:scale] forKey:@"model_scale_factor"];
4160 shipDict = [
NSDictionary dictionaryWithDictionary:mShipDict];
4163 dock = [[
DockEntity alloc] initWithKey:shipDataKey definition:shipDict];
4165 @catch (NSException *exception)
4169 OOLog(
kOOLogException,
@"***** Oolite Exception : '%@' in [Universe newDockWithName: %@ ] *****", [exception reason], shipDataKey);
4171 else @throw exception;
4144- (
DockEntity *) newDockWithName:(NSString *)shipDataKey andScaleFactor:(
float)scale {
…}
4190- (Class) shipClassForShipDictionary:(NSDictionary *)dict
4194 if (dict ==
nil)
return Nil;
4196 BOOL isStation = NO;
4197 NSString *shipRoles = [
dict oo_stringForKey:@"roles"];
4199 if (shipRoles !=
nil)
4201 isStation = [
shipRoles rangeOfString:@"station"].location != NSNotFound ||
4202 [
shipRoles rangeOfString:@"carrier"].location != NSNotFound;
4206 isStation = [
dict oo_boolForKey:@"isCarrier" defaultValue:isStation];
4207 isStation = [
dict oo_boolForKey:@"is_carrier" defaultValue:isStation];
4190- (Class) shipClassForShipDictionary:(NSDictionary *)dict {
…}
4216- (NSString *)defaultAIForRole:(NSString *)role
4218 return [autoAIMap oo_stringForKey:role];
4216- (NSString *)defaultAIForRole:(NSString *)role {
…}
4235 NSString *itemType = [
itemData oo_stringAtIndex:EQUIPMENT_KEY_INDEX];
4237 if ([itemType isEqual:eq_key])
4239 return [
itemData oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
4255 if ([cargoObj isTemplateCargoPod])
4257 return [UNIVERSE cargoPodFromTemplate:cargoObj];
4271 OOCargoQuantity co_amount = [UNIVERSE getRandomAmountOfCommodity:co_type];
4274 container = [UNIVERSE newShipWithRole:co_type];
4276 if (container ==
nil)
4278 container = [UNIVERSE newShipWithRole:@"cargopod"];
4285- (NSArray *) getContainersOfGoods:(
OOCargoQuantity)how_many scarce:(BOOL)scarce legal:(BOOL)legal
4291 NSMutableArray *accumulator = [
NSMutableArray arrayWithCapacity:how_many];
4297 NSString *goodsKey =
nil;
4299 foreach (goodsKey, goodsKeys)
4304 if (q < 64) q = 64 - q;
4315 quantities[
i++] = q;
4316 total_quantity += q;
4319 for (i = 0; i < how_many; i++)
4321 NSUInteger co_type = 0;
4326 qr = 1+(
Ranrot() % total_quantity);
4330 NSAssert((NSUInteger)co_type < commodityCount,
@"Commodity type index out of range.");
4338 if (container !=
nil)
4344 OOLog(
@"universe.createContainer.failed",
@"***** ERROR: failed to find a container to fill with %@ (%ld).", [goodsKeys oo_stringAtIndex:co_type], co_type);
4348 return [
NSArray arrayWithArray:accumulator];
4285- (NSArray *) getContainersOfGoods:(
OOCargoQuantity)how_many scarce:(BOOL)scarce legal:(BOOL)legal {
…}
4354 NSMutableArray *accumulator = [
NSMutableArray arrayWithCapacity:how_much];
4360 ShipEntity *container = [cargoPods objectForKey:commodity_name];
4361 while (how_much > 0)
4369 OOLog(
@"universe.createContainer.failed",
@"***** ERROR: failed to find a container to fill with %@", commodity_name);
4374 return [
NSArray arrayWithArray:accumulator];
4380 if (cargopod ==
nil || ![cargopod hasRole:
@"cargopod"] || [cargopod cargoType] ==
CARGO_SCRIPTED_ITEM)
return;
4382 if ([cargopod commodityType] ==
nil || ![cargopod commodityAmount])
4401 if (co_type ==
nil) {
4415 OOLog(
@"universe.commodityAmount.warning",
@"Commodity %@ has an unrecognised mass unit, assuming tonnes",co_type);
4435 NSString *unitDesc =
nil, *typeDesc =
nil;
4438 if (commodity ==
nil)
return @"";
4446 unitDesc =
DESC(
@"cargo-kilogram");
4449 unitDesc =
DESC(
@"cargo-gram");
4453 unitDesc =
DESC(
@"cargo-ton");
4462 unitDesc =
DESC(
@"cargo-kilograms");
4465 unitDesc =
DESC(
@"cargo-grams");
4469 unitDesc =
DESC(
@"cargo-tons");
4476 return [
NSString stringWithFormat:@"%d %@ %@",co_amount, unitDesc, typeDesc];
4508 [
result oo_setInteger:[PLAYER isSpeechOn] forKey:@"speechOn"];
4509 [
result oo_setBool:autoSave forKey:@"autosave"];
4510 [
result oo_setBool:wireframeGraphics forKey:@"wireframeGraphics"];
4511 [
result oo_setBool:doProcedurallyTexturedPlanets forKey:@"procedurallyTexturedPlanets"];
4521 [
result oo_setFloat:[
gameView hdrMaxBrightness] forKey:@"hdr-max-brightness"];
4522 [
result oo_setFloat:[
gameView hdrPaperWhiteBrightness] forKey:@"hdr-paperwhite-brightness"];
4526 [
result setObject:OOStringFromGraphicsDetail([
self detailLevel]) forKey:@"detailLevel"];
4528 NSString *desc =
@"UNDEFINED";
4535 [
result setObject:desc forKey:@"musicMode"];
4537 NSDictionary *gameWindow = [
NSDictionary dictionaryWithObjectsAndKeys:
4542 [
result setObject:gameWindow forKey:@"gameWindow"];
4544 [
result setObject:[PLAYER keyConfig] forKey:@"keyConfig"];
4546 return [[
result copy] autorelease];
4550- (void) useGUILightSource:(BOOL)GUILight
4558 OOGL(glEnable(GL_LIGHT0));
4559 OOGL(glDisable(GL_LIGHT1));
4563 OOGL(glEnable(GL_LIGHT1));
4564 OOGL(glDisable(GL_LIGHT0));
4573 else OOGL(glEnable(GL_LIGHT1));
4550- (void) useGUILightSource:(BOOL)GUILight {
…}
4580- (void) lightForEntity:(BOOL)isLit
4601 if (isLit)
OOGL(glEnable(GL_LIGHT1));
4602 else OOGL(glDisable(GL_LIGHT1));
4607 OOGL(glEnable(GL_LIGHT0));
4580- (void) lightForEntity:(BOOL)isLit {
…}
4623 { 1.0f, 0.0f, 0.0f, 0.0f },
4624 { 0.0f, 1.0f, 0.0f, 0.0f },
4625 { 0.0f, 0.0f, 1.0f, 0.0f },
4626 { 0.0f, 0.0f, 0.0f, 1.0f }
4630 {-1.0f, 0.0f, 0.0f, 0.0f },
4631 { 0.0f, 1.0f, 0.0f, 0.0f },
4632 { 0.0f, 0.0f, -1.0f, 0.0f },
4633 { 0.0f, 0.0f, 0.0f, 1.0f }
4637 { 0.0f, 0.0f, -1.0f, 0.0f },
4638 { 0.0f, 1.0f, 0.0f, 0.0f },
4639 { 1.0f, 0.0f, 0.0f, 0.0f },
4640 { 0.0f, 0.0f, 0.0f, 1.0f }
4644 { 0.0f, 0.0f, 1.0f, 0.0f },
4645 { 0.0f, 1.0f, 0.0f, 0.0f },
4646 {-1.0f, 0.0f, 0.0f, 0.0f },
4647 { 0.0f, 0.0f, 0.0f, 1.0f }
4651- (void) getActiveViewMatrix:(OOMatrix *)outMatrix forwardVector:(Vector *)outForward upVector:(Vector *)outUp
4653 assert(outMatrix != NULL && outForward != NULL && outUp != NULL);
4671 case VIEW_STARBOARD:
4686 case VIEW_GUI_DISPLAY:
4687 case VIEW_BREAK_PATTERN:
4651- (void) getActiveViewMatrix:(OOMatrix *)outMatrix forwardVector:(Vector *)outForward upVector:(Vector *)outUp {
…}
4720 frustum[0][0] = clip.m[0][3] - clip.m[0][0];
4721 frustum[0][1] = clip.m[1][3] - clip.m[1][0];
4722 frustum[0][2] = clip.m[2][3] - clip.m[2][0];
4723 frustum[0][3] = clip.m[3][3] - clip.m[3][0];
4733 frustum[1][0] = clip.m[0][3] + clip.m[0][0];
4734 frustum[1][1] = clip.m[1][3] + clip.m[1][0];
4735 frustum[1][2] = clip.m[2][3] + clip.m[2][0];
4736 frustum[1][3] = clip.m[3][3] + clip.m[3][0];
4746 frustum[2][0] = clip.m[0][3] + clip.m[0][1];
4747 frustum[2][1] = clip.m[1][3] + clip.m[1][1];
4748 frustum[2][2] = clip.m[2][3] + clip.m[2][1];
4749 frustum[2][3] = clip.m[3][3] + clip.m[3][1];
4759 frustum[3][0] = clip.m[0][3] - clip.m[0][1];
4760 frustum[3][1] = clip.m[1][3] - clip.m[1][1];
4761 frustum[3][2] = clip.m[2][3] - clip.m[2][1];
4762 frustum[3][3] = clip.m[3][3] - clip.m[3][1];
4772 frustum[4][0] = clip.m[0][3] - clip.m[0][2];
4773 frustum[4][1] = clip.m[1][3] - clip.m[1][2];
4774 frustum[4][2] = clip.m[2][3] - clip.m[2][2];
4775 frustum[4][3] = clip.m[3][3] - clip.m[3][2];
4785 frustum[5][0] = clip.m[0][3] + clip.m[0][2];
4786 frustum[5][1] = clip.m[1][3] + clip.m[1][2];
4787 frustum[5][2] = clip.m[2][3] + clip.m[2][2];
4788 frustum[5][3] = clip.m[3][3] + clip.m[3][2];
4799- (BOOL) viewFrustumIntersectsSphereAt:(Vector)position withRadius:(GLfloat)radius
4803 for (p = 0; p < 6; p++)
4799- (BOOL) viewFrustumIntersectsSphereAt:(Vector)position withRadius:(GLfloat)radius {
…}
4819 OOLog(
@"universe.profile.draw",
@"%@",
@"Begin draw");
4843 int i, v_status, vdist;
4844 Vector view_dir, view_up;
4845 OOMatrix view_matrix;
4853 float aspect = viewSize.height/viewSize.width;
4859 else [UNIVERSE setMainLightPosition:kZeroVector];
4863 for (i = 0; i < ent_count; i++)
4873 my_entities[
draw_count++] = [[
e retain] autorelease];
4883 OOGL(glClear(GL_COLOR_BUFFER_BIT));
4891 OOGL(glClearColor(0.0, 0.0, 0.0, 0.0));
4901 for (vdist=0;vdist<=1;vdist++)
4910 OOGLFrustum(-ratio, ratio, -aspect*ratio, aspect*ratio, nearPlane, farPlane);
4914 OOGLFrustum(-3*ratio/aspect/4, 3*ratio/aspect/4, -3*ratio/4, 3*ratio/4, nearPlane, farPlane);
4949 OOGL(glClear(GL_DEPTH_BUFFER_BIT));
4954 flipMatrix.m[2][2] = -1;
4962 if (
EXPECT(!demoShipMode))
4991 OOGL([
self useGUILightSource:demoShipMode]);
4996 int furthest = draw_count - 1;
5000 double fog_scale, half_scale;
5001 GLfloat flat_ambdiff[4] = {1.0, 1.0, 1.0, 1.0};
5002 GLfloat mat_no[4] = {0.0, 0.0, 0.0, 1.0};
5011 OOLog(
@"universe.profile.draw",
@"%@",
@"Begin opaque pass");
5015 for (i = furthest; i >= nearest; i--)
5017 drawthing = my_entities[
i];
5021 if (vdist == 1 && [drawthing cameraRangeFront] > farPlane*1.5)
continue;
5022 if (vdist == 0 && [drawthing cameraRangeBack] < nearPlane)
continue;
5025 if (!((d_status == STATUS_COCKPIT_DISPLAY) ^ demoShipMode))
5029 OOGL(glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, flat_ambdiff));
5030 OOGL(glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_no));
5033 if (
EXPECT(drawthing != player))
5056 half_scale = fog_scale * 0.50;
5057 OOGL(glEnable(GL_FOG));
5058 OOGL(glFogi(GL_FOG_MODE, GL_LINEAR));
5060 OOGL(glFogf(GL_FOG_START, half_scale));
5061 OOGL(glFogf(GL_FOG_END, fog_scale));
5062 fog_blend = OOClamp_0_1_f((magnitude([drawthing cameraRelativePosition]) - half_scale)/half_scale);
5077 OOGL(glDisable(GL_FOG));
5082 if (!((d_status == STATUS_COCKPIT_DISPLAY) ^ demoShipMode))
5085 if (
EXPECT(drawthing != player))
5108 half_scale = fog_scale * 0.50;
5109 OOGL(glEnable(GL_FOG));
5110 OOGL(glFogi(GL_FOG_MODE, GL_LINEAR));
5112 OOGL(glFogf(GL_FOG_START, half_scale));
5113 OOGL(glFogf(GL_FOG_END, fog_scale));
5114 fog_blend = OOClamp_0_1_f((magnitude([drawthing cameraRelativePosition]) - half_scale)/half_scale);
5125 OOGL(glDisable(GL_FOG));
5150 if (hudSeparateRenderPass)
5158 OOLog(
@"universe.profile.secondPassDraw",
@"%@",
@"Begin second pass draw");
5160 OOCheckOpenGLErrors(
@"Universe after drawing from custom framebuffer to screen framebuffer");
5161 OOLog(
@"universe.profile.secondPassDraw",
@"%@",
@"End second pass drawing");
5163 OOLog(
@"universe.profile.drawHUD",
@"%@",
@"Begin HUD drawing");
5168 OOLog(
@"universe.profile.draw",
@"%@",
@"Begin HUD");
5171 if (lineWidth < 1.0) lineWidth = 1.0;
5172 if (lineWidth > 1.5) lineWidth = 1.5;
5179 if ([theHUD deferredHudName] !=
nil)
5188 static float sPrevHudAlpha = -1.0f;
5189 if ([theHUD isHidden])
5191 if (sPrevHudAlpha < 0.0f)
5197 else if (sPrevHudAlpha >= 0.0f)
5200 sPrevHudAlpha = -1.0f;
5205 case STATUS_ESCAPE_SEQUENCE:
5206 case STATUS_START_GAME:
5210 switch ([player guiScreen])
5224#if (defined (SNAPSHOT_BUILD) && defined (OOLITE_SNAPSHOT_VERSION))
5228 OOLog(
@"universe.profile.drawHUD",
@"%@",
@"End HUD drawing");
5242 @catch (NSException *exception)
5246 if ([[exception name] hasPrefix:
@"Oolite"])
5252 OOLog(
kOOLogException,
@"***** Exception: %@ : %@ *****",[exception name], [exception reason]);
5258 OOLog(
@"universe.profile.draw",
@"%@",
@"End drawing");
5261 if(!hudSeparateRenderPass)
5268 OOLog(
@"universe.profile.secondPassDraw",
@"%@",
@"Begin second pass draw");
5270 OOLog(
@"universe.profile.secondPassDraw",
@"%@",
@"End second pass drawing");
5278 NSSize viewSize = [
gameView viewSize];
5279 if([
self useShaders])
5281 if ([gameView msaa])
5284 OOGL(glBindFramebuffer(GL_READ_FRAMEBUFFER, msaaFramebufferID));
5285 OOGL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFramebufferID));
5286 OOGL(glBlitFramebuffer(0, 0, (GLint)viewSize.width, (GLint)viewSize.height, 0, 0, (GLint)viewSize.width, (GLint)viewSize.height, GL_COLOR_BUFFER_BIT, GL_NEAREST));
5314 OOGL(glDisable(GL_TEXTURE_2D));
5316 float overallAlpha = [[PLAYER hud] overallAlpha];
5336- (void) drawWatermarkString:(NSString *) watermarkString
5338 NSSize watermarkStringSize =
OORectFromString(watermarkString, 0.0f, 0.0f, NSMakeSize(10, 10)).size;
5340 OOGL(glColor4f(0.0, 1.0, 0.0, 1.0));
5336- (void) drawWatermarkString:(NSString *) watermarkString {
…}
5354 OOLog(
@"universe.badUID",
@"Attempt to retrieve entity for out-of-range UID %u. (This is an internal programming error, please report it.)", u_id);
5367 if ([ent status] == STATUS_DEAD || [ent status] == STATUS_DOCKED)
5378 NSCParameterAssert(uni != NULL);
5391 while ((n--)&&(checkEnt))
5394 checkEnt = checkEnt->
x_next;
5396 if ((checkEnt)||(n > 0))
5404 while ((n--)&&(checkEnt)) checkEnt = checkEnt->
x_previous;
5405 if ((checkEnt)||(n > 0))
5416 checkEnt = checkEnt->
x_next;
5424 while ((n--)&&(checkEnt))
5427 checkEnt = checkEnt->
y_next;
5429 if ((checkEnt)||(n > 0))
5437 while ((n--)&&(checkEnt)) checkEnt = checkEnt->
y_previous;
5438 if ((checkEnt)||(n > 0))
5449 checkEnt = checkEnt->
y_next;
5457 while ((n--)&&(checkEnt))
5460 checkEnt = checkEnt->
z_next;
5462 if ((checkEnt)||(n > 0))
5470 while ((n--)&&(checkEnt)) checkEnt = checkEnt->
z_previous;
5471 if ((checkEnt)||(n > 0))
5478 NSCAssert(checkEnt !=
nil,
@"Expected z-list to be non-empty.");
5483 checkEnt = checkEnt->
z_next;
5493 NSArray *allEntities = uni->
entities;
5499 foreach (ent, allEntities)
5523 if (![entity validForAddToUniverse])
return NO;
5526 if ([
entities containsObject:entity])
5539 if (![entity isEffect])
5552 OOLog(
@"universe.addEntity.failed",
@"***** Universe cannot addEntity:%@ -- Could not find free slot for entity.", entity);
5556 [
entity setUniversalID:next_universal_id];
5558 if ([entity isShip])
5570 double stationRoll = 0.0;
5574 if (definedRoll !=
nil)
5580 stationRoll = [[
self currentSystemData] oo_doubleForKey:@"station_roll" defaultValue:STANDARD_STATION_ROLL];
5593 if ([se status] != STATUS_COCKPIT_DISPLAY)
5601 [
entity setUniversalID:NO_TARGET];
5602 if ([entity isVisualEffect])
5610 else if ([entity isWaypoint])
5621 entity->isSunlit = YES;
5625 [entities addObject:entity];
5626 [
entity wasAddedToUniverse];
5629 HPVector entity_pos = entity->position;
5630 HPVector delta = HPvector_between(entity_pos,
PLAYER->position);
5631 double z_distance = HPmagnitude2(delta);
5632 entity->zero_distance = z_distance;
5635 entity->zero_index = index;
5636 while ((index > 0)&&(z_distance <
sortedEntities[index - 1]->zero_distance))
5642 entity->zero_index = index;
5649 [
entity addToLinkedLists];
5650 if ([entity canCollide])
5655 if ([entity isWormhole])
5657 [activeWormholes addObject:entity];
5659 else if ([entity isPlanet])
5661 [allPlanets addObject:entity];
5663 else if ([entity isShip])
5667 if ([entity isStation])
5669 [allStations addObject:entity];
5681 if (entity !=
nil && ![entity isPlayer])
5687 [entitiesDeadThisUpdate addObject:entity];
5688 if ([entity isStation])
5690 [allStations removeObject:entity];
5691 if ([
PLAYER getTargetDockStation] == entity)
5693 [PLAYER setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
5702- (void) ensureEntityReallyRemoved:(
Entity *)entity
5706 OOLog(
@"universe.unremovedEntity",
@"Entity %@ dealloced without being removed from universe! (This is an internal programming error, please report it.)", entity);
5702- (void) ensureEntityReallyRemoved:(
Entity *)entity {
…}
5718 Entity* p0 = [entities objectAtIndex:0];
5727 NSMutableArray *savedWormholes = [activeWormholes mutableCopy];
5731 Entity* ent = [entities objectAtIndex:1];
5734 if (
EXPECT(![ent isVisualEffect]))
5745 [activeWormholes release];
5754 [closeSystems release];
5758 [waypoints removeAllObjects];
5771 for (i = 0; i < ent_count; i++)
5774 if ([ent status] == STATUS_COCKPIT_DISPLAY && ![ent isPlayer])
5784- (
ShipEntity *) makeDemoShipWithRole:(NSString *)role spinning:(BOOL)spinning
5790 [PLAYER setShowDemoShips: YES];
5791 Quaternion q2 = { (GLfloat)
M_SQRT1_2, (GLfloat)
M_SQRT1_2, (GLfloat)0.0, (GLfloat)0.0 };
5803 [UNIVERSE addEntity:ship];
5820 return [
ship autorelease];
5784- (
ShipEntity *) makeDemoShipWithRole:(NSString *)role spinning:(BOOL)spinning {
…}
5824- (BOOL) isVectorClearFromEntity:(
Entity *) e1 toDistance:(
double)dist fromPoint:(HPVector) p2
5832 v1.x -= p1.x; v1.y -= p1.y; v1.z -= p1.z;
5834 double nearest = sqrt(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z) - dist;
5842 for (i = 0; i < ent_count; i++)
5845 if (v1.x || v1.y || v1.z)
5846 f1 = HPvector_normal(v1);
5848 f1 = make_HPvector(0, 0, 1);
5850 for (i = 0; i < ent_count ; i++)
5853 if ((e2 != e1)&&([e2 canCollide]))
5856 epos.x -= p1.x; epos.y -= p1.y; epos.z -= p1.z;
5858 double d_forward = HPdot_product(epos,f1);
5860 if ((d_forward > 0)&&(d_forward < nearest))
5864 p0.x += d_forward * f1.x; p0.y += d_forward * f1.y; p0.z += d_forward * f1.z;
5867 p0.x -= epos.x; p0.y -= epos.y; p0.z -= epos.z;
5869 double dist2 = p0.x * p0.x + p0.y * p0.y + p0.z * p0.z;
5872 for (i = 0; i < ent_count; i++)
5873 [my_entities[i] release];
5879 for (i = 0; i < ent_count; i++)
5880 [my_entities[i] release];
5824- (BOOL) isVectorClearFromEntity:(
Entity *) e1 toDistance:(
double)dist fromPoint:(HPVector) p2 {
…}
5885- (
Entity*) hazardOnRouteFromEntity:(
Entity *) e1 toDistance:(
double)dist fromPoint:(HPVector) p2
5893 v1.x -= p1.x; v1.y -= p1.y; v1.z -= p1.z;
5895 double nearest = HPmagnitude(v1) - dist;
5904 for (i = 0; i < ent_count; i++)
5907 if (v1.x || v1.y || v1.z)
5908 f1 = HPvector_normal(v1);
5910 f1 = make_HPvector(0, 0, 1);
5912 for (i = 0; (i < ent_count) && (!result) ; i++)
5915 if ((e2 != e1)&&([e2 canCollide]))
5918 epos.x -= p1.x; epos.y -= p1.y; epos.z -= p1.z;
5920 double d_forward = HPdot_product(epos,f1);
5922 if ((d_forward > 0)&&(d_forward < nearest))
5926 p0.x += d_forward * f1.x; p0.y += d_forward * f1.y; p0.z += d_forward * f1.z;
5929 p0.x -= epos.x; p0.y -= epos.y; p0.z -= epos.z;
5931 double dist2 = HPmagnitude2(p0);
5937 for (i = 0; i < ent_count; i++)
5938 [my_entities[i] release];
5885- (
Entity*) hazardOnRouteFromEntity:(
Entity *) e1 toDistance:(
double)dist fromPoint:(HPVector) p2 {
…}
5943- (HPVector) getSafeVectorFromEntity:(
Entity *) e1 toDistance:(
double)dist fromPoint:(HPVector) p2
5954 HPVector result = p2;
5958 for (i = 0; i < ent_count; i++)
5962 v1.x -= p1.x; v1.y -= p1.y; v1.z -= p1.z;
5964 double nearest = sqrt(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z) - dist;
5966 if (v1.x || v1.y || v1.z)
5967 f1 = HPvector_normal(v1);
5969 f1 = make_HPvector(0, 0, 1);
5971 for (i = 0; i < ent_count; i++)
5974 if ((e2 != e1)&&([e2 canCollide]))
5977 epos.x -= p1.x; epos.y -= p1.y; epos.z -= p1.z;
5978 double d_forward = HPdot_product(epos,f1);
5979 if ((d_forward > 0)&&(d_forward < nearest))
5984 p0.x += d_forward * f1.x; p0.y += d_forward * f1.y; p0.z += d_forward * f1.z;
5988 p0.x -= epos.x; p0.y -= epos.y; p0.z -= epos.z;
5991 double dist2 = p0.x * p0.x + p0.y * p0.y + p0.z * p0.z;
5996 nearest = d_forward;
6002 result.x += ((
int)(
Ranrot() % 1024) - 512)/512.0;
6003 result.y += ((
int)(
Ranrot() % 1024) - 512)/512.0;
6004 result.z += ((
int)(
Ranrot() % 1024) - 512)/512.0;
6007 HPVector nearest_point = p1;
6008 nearest_point.x += d_forward * f1.x; nearest_point.y += d_forward * f1.y; nearest_point.z += d_forward * f1.z;
6011 HPVector outward = nearest_point;
6012 outward.x -= result.x; outward.y -= result.y; outward.z -= result.z;
6013 if (outward.x||outward.y||outward.z)
6014 outward = HPvector_normal(outward);
6019 HPVector backward = p1;
6020 backward.x -= result.x; backward.y -= result.y; backward.z -= result.z;
6021 if (backward.x||backward.y||backward.z)
6022 backward = HPvector_normal(backward);
6027 HPVector dd = result;
6028 dd.x -= p1.x; dd.y -= p1.y; dd.z -= p1.z;
6029 double current_distance = HPmagnitude(dd);
6032 if (current_distance < cr * 1.25)
6033 current_distance = cr * 1.25;
6034 if (current_distance > cr * 5.0)
6035 current_distance = cr * 5.0;
6039 result.x += 0.25 * (outward.x * current_distance) + 0.75 * (backward.x * current_distance);
6040 result.y += 0.25 * (outward.y * current_distance) + 0.75 * (backward.y * current_distance);
6041 result.z += 0.25 * (outward.z * current_distance) + 0.75 * (backward.z * current_distance);
6047 for (i = 0; i < ent_count; i++)
6048 [my_entities[i] release];
5943- (HPVector) getSafeVectorFromEntity:(
Entity *) e1 toDistance:(
double)dist fromPoint:(HPVector) p2 {
…}
6053- (
ShipEntity*) addWreckageFrom:(
ShipEntity *)ship withRole:(NSString *)wreckRole at:(HPVector)rpos scale:(GLfloat)scale lifetime:(GLfloat)lifetime
6055 ShipEntity* wreck = [UNIVERSE newShipWithRole:wreckRole];
6059 GLfloat expected_mass = 0.1f * [
ship mass] * (0.75 + 0.5 *
randf());
6061 GLfloat scale_factor = powf(expected_mass / wreck_mass, 0.33333333f) * scale;
6077 [UNIVERSE addEntity:wreck];
6053- (
ShipEntity*) addWreckageFrom:(
ShipEntity *)ship withRole:(NSString *)wreckRole at:(HPVector)rpos scale:(GLfloat)scale lifetime:(GLfloat)lifetime {
…}
6087- (void) addLaserHitEffectsAt:(HPVector)pos against:(
ShipEntity *)target damage:(
float)damage color:(
OOColor *)color
6090 if ([target showDamage] && [target energy] < [target maxEnergy]/2)
6092 NSString *key = (
randf() < 0.5) ?
@"oolite-hull-spark" :
@"oolite-hull-spark-b";
6093 NSDictionary *settings = [UNIVERSE explosionSetting:key];
6097 if ([target energy] *
randf() < damage)
6102 Vector direction = HPVectorToVector(HPvector_normal(HPvector_subtract(pos,[target position])));
6087- (void) addLaserHitEffectsAt:(HPVector)pos against:(
ShipEntity *)target damage:(
float)damage color:(
OOColor *)color {
…}
6116 if (srcEntity ==
nil)
return nil;
6128 HPVector midfrontplane = make_HPvector(0.5 * (bbox.max.x + bbox.min.x), 0.5 * (bbox.max.y + bbox.min.y), bbox.max.z);
6131 if ([parent isPlayer]) q1.w = -q1.w;
6140 for (i = 0; i < ent_count; i++)
6143 if (ent != srcEntity && ent != parent && [ent isShip] && [ent canCollide])
6174 HPVector p1 = HPvector_add(p0, vectorToHPVector(vector_multiply_scalar(f1, nearest)));
6176 for (i = 0; i < ship_count; i++)
6182 Vector rpos = HPVectorToVector(HPvector_subtract(e2->
position, p0));
6183 Vector v_off = make_vector(dot_product(rpos, r1), dot_product(rpos, u1), dot_product(rpos, f1));
6184 if (v_off.z > 0.0 && v_off.z < nearest + cr &&
6185 v_off.x < cr && v_off.x > -cr && v_off.y < cr && v_off.y > -cr &&
6186 v_off.x * v_off.x + v_off.y * v_off.y < cr * cr)
6189 GLfloat hit = [(
ShipEntity *)
e2 doesHitLine:p0 :p1 :&entHit];
6191 if (hit > 0.0 && hit < nearest)
6193 if ([entHit isSubEntity])
6195 hit_subentity = entHit;
6199 p1 = HPvector_add(p0, vectorToHPVector(vector_multiply_scalar(f1, nearest)));
6209 if (range_ptr != NULL)
6211 *range_ptr = nearest;
6215 for (i = 0; i < ship_count; i++) [my_entities[i] release];
6226 nearest2 *= nearest2;
6232 for (i = 0; i < ent_count; i++)
6256 case VIEW_STARBOARD :
6264 for (i = 0; i < ship_count; i++)
6267 if ([e2 canCollide] && [e2 scanClass] != CLASS_NO_DRAW)
6269 Vector rp = HPVectorToVector(HPvector_subtract([e2 position], p1));
6271 if (dist2 < nearest2)
6274 if (df > 0.0 && df * df < nearest2)
6279 if (du * du + dr * dr < cr * cr)
6289 if (hit_entity !=
nil && [hit_entity isShip])
6292 if ([ship isJammingScanning] && ![player hasMilitaryScannerFilter])
6298 for (i = 0; i < ship_count; i++)
6330 case VIEW_STARBOARD:
6345- (NSArray *) entitiesWithinRange:(
double)range ofEntity:(
Entity *)entity
6347 if (entity ==
nil)
return nil;
6345- (NSArray *) entitiesWithinRange:(
double)range ofEntity:(
Entity *)entity {
…}
6356- (unsigned) countShipsWithRole:(NSString *)role inRange:(
double)range ofEntity:(
Entity *)entity
6356- (unsigned) countShipsWithRole:(NSString *)role inRange:(
double)range ofEntity:(
Entity *)entity {
…}
6365- (unsigned) countShipsWithRole:(NSString *)role
6365- (unsigned) countShipsWithRole:(NSString *)role {
…}
6371- (unsigned) countShipsWithPrimaryRole:(NSString *)role inRange:(
double)range ofEntity:(
Entity *)entity
6371- (unsigned) countShipsWithPrimaryRole:(NSString *)role inRange:(
double)range ofEntity:(
Entity *)entity {
…}
6380- (unsigned) countShipsWithScanClass:(
OOScanClass)scanClass inRange:(
double)range ofEntity:(
Entity *)entity
6380- (unsigned) countShipsWithScanClass:(
OOScanClass)scanClass inRange:(
double)range ofEntity:(
Entity *)entity {
…}
6389- (unsigned) countShipsWithPrimaryRole:(NSString *)role
6389- (unsigned) countShipsWithPrimaryRole:(NSString *)role {
…}
6396 parameter:(
void *)parameter
6397 inRange:(
double)range
6400 unsigned i, found = 0;
6402 double distance, cr;
6412 if (e2 != e1 && predicate(e2, parameter))
6414 if (range < 0) distance = -1;
6418 distance = HPdistance2(e2->
position, p1) - cr * cr;
6432 parameter:(
void *)parameter
6433 inRange:(
double)range
6434 ofEntity:(
Entity *)entity
6436 if (predicate != NULL)
6441 predicate, parameter
6461 if (range < 0)
return YES;
6463 return HPdistance2(e2->
position,p1) < cr * cr;
6470 parameter:(
void *)parameter
6471 inRange:(
double)range
6478 NSMutableArray *result =
nil;
6495 predicate(e2, parameter))
6510 parameter:(
void *)parameter
6522 if (predicate(candidate, parameter))
return candidate;
6532 parameter:(
void *)parameter
6533 inRange:(
double)range
6534 ofEntity:(
Entity *)entity
6536 if (predicate != NULL)
6541 predicate, parameter
6560 parameter:(
void *)parameter
6561 inRange:(
double)range
6562 ofEntity:(
Entity *)entity
6564 if (predicate != NULL)
6569 predicate, parameter
6588 parameter:(
void *)parameter
6589 relativeToEntity:(
Entity *)entity
6593 float rangeSq = INFINITY;
6604 float distanceToReferenceEntitySquared = (float)HPdistance2(p1, [e2 position]);
6607 distanceToReferenceEntitySquared < rangeSq &&
6608 predicate(e2, parameter))
6611 rangeSq = distanceToReferenceEntitySquared;
6615 return [[
result retain] autorelease];
6620 parameter:(
void *)parameter
6621 relativeToEntity:(
Entity *)entity
6623 if (predicate != NULL)
6628 predicate, parameter
6699 BOOL guiSelected = NO;
6707 ms =
DESC(
@"forward-view-string");
6711 ms =
DESC(
@"aft-view-string");
6715 ms =
DESC(
@"port-view-string");
6718 case VIEW_STARBOARD:
6719 ms =
DESC(
@"starboard-view-string");
6723 ms = [PLAYER customViewDescription];
6726 case VIEW_GUI_DISPLAY:
6749 #if (ALLOW_CUSTOM_VIEWS_WHILE_PAUSED)
6752 BOOL gamePaused = NO;
6757 if (ms && !gamePaused)
6761 else if (gamePaused)
6769- (void) enterGUIViewModeWithMouseInteraction:(BOOL)mouseInteraction
6769- (void) enterGUIViewModeWithMouseInteraction:(BOOL)mouseInteraction {
…}
6783- (NSString *) soundNameForCustomSoundKey:(NSString *)key
6785 NSString *result =
nil;
6786 NSMutableSet *seen =
nil;
6787 id object = [customSounds objectForKey:key];
6789 if ([
object isKindOfClass:[NSArray
class]] && [
object count] > 0)
6791 key = [
object oo_stringAtIndex:Ranrot() % [
object count]];
6804 if (
object ==
nil || ([result hasPrefix:
@"["] && [result hasSuffix:
@"]"]))
6808 [
seen addObject:result];
6809 object = [customSounds objectForKey:result];
6810 if( [
object isKindOfClass:[NSArray
class]] && [
object count] > 0)
6812 result = [
object oo_stringAtIndex:Ranrot() % [
object count]];
6813 if ([key hasPrefix:
@"["] && [key hasSuffix:
@"]"]) key=result;
6817 if ([
object isKindOfClass:[NSString
class]])
6822 if (result ==
nil || ![result hasPrefix:
@"["] || ![result hasSuffix:
@"]"])
break;
6823 if ([seen containsObject:result])
6825 OOLogERR(
@"sound.customSounds.recursion",
@"recursion in customsounds.plist for '%@' (at '%@'), no sound will be played.", key, result);
6832 if (result ==
nil) result =
@"__oolite-no-sound";
6836 if ([result isEqualToString:
@"__oolite-no-sound"])
6838 OOLog(
@"sound.customSounds",
@"Could not resolve sound name in customsounds.plist for '%@', no sound will be played.", key);
6783- (NSString *) soundNameForCustomSoundKey:(NSString *)key {
…}
6845- (NSDictionary *) screenTextureDescriptorForKey:(NSString *)key
6847 id value = [screenBackgrounds objectForKey:key];
6848 while ([value isKindOfClass:[NSArray
class]]) value = [
value objectAtIndex:Ranrot() % [
value count]];
6850 if ([value isKindOfClass:[NSString
class]]) value = [
NSDictionary dictionaryWithObject:value forKey:@"name"];
6851 else if (![value isKindOfClass:[NSDictionary
class]]) value =
nil;
6854 if (![[
self gui] preloadGUITexture:value]) value =
nil;
6845- (NSDictionary *) screenTextureDescriptorForKey:(NSString *)key {
…}
6860- (void) setScreenTextureDescriptorForKey:(NSString *)key descriptor:(NSDictionary *)desc
6862 NSMutableDictionary *sbCopy = [screenBackgrounds mutableCopy];
6865 [
sbCopy removeObjectForKey:key];
6869 [
sbCopy setObject:desc forKey:key];
6871 [screenBackgrounds release];
6860- (void) setScreenTextureDescriptorForKey:(NSString *)key descriptor:(NSDictionary *)desc {
…}
6884- (void) setMessageGuiBackgroundColor:(
OOColor *)some_color
6884- (void) setMessageGuiBackgroundColor:(
OOColor *)some_color {
…}
6902- (void) displayCountdownMessage:(NSString *) text forCount:(
OOTimeDelta)count
6902- (void) displayCountdownMessage:(NSString *) text forCount:(
OOTimeDelta)count {
…}
6914- (void) addDelayedMessage:(NSString *)text forCount:(
OOTimeDelta)count afterDelay:(
double)delay
6917 [
msgDict setObject:text forKey:@"message"];
6918 [
msgDict setObject:[
NSNumber numberWithDouble:count] forKey:@"duration"];
6919 [
self performSelector:@selector(addDelayedMessage:) withObject:msgDict afterDelay:delay];
6914- (void) addDelayedMessage:(NSString *)text forCount:(
OOTimeDelta)count afterDelay:(
double)delay {
…}
6923- (void) addDelayedMessage:(NSDictionary *) textdict
6925 NSString *msg =
nil;
6928 msg = [
textdict oo_stringForKey:@"message"];
6929 if (msg ==
nil)
return;
6930 msg_duration = [
textdict oo_nonNegativeDoubleForKey:@"duration" defaultValue:3.0];
6923- (void) addDelayedMessage:(NSDictionary *) textdict {
…}
6942- (void) speakWithSubstitutions:(NSString *)text
6944#if OOLITE_SPEECH_SYNTH
6950 NSString *systemSaid =
nil;
6951 NSString *h_systemSaid =
nil;
6955 systemSaid = systemName;
6958 h_systemSaid = h_systemName;
6960 NSString *spokenText = text;
6963 NSEnumerator *speechEnumerator =
nil;
6964 NSArray *thePair =
nil;
6968 NSString *original_phrase = [
thePair oo_stringAtIndex:0];
6970 NSUInteger replacementIndex;
6972 replacementIndex = 1;
6974 replacementIndex = [
thePair count] > 2 ? 2 : 1;
6977 NSString *replacement_phrase = [
thePair oo_stringAtIndex:replacementIndex];
6978 if (![replacement_phrase isEqualToString:
@"_"])
6980 spokenText = [
spokenText stringByReplacingOccurrencesOfString:original_phrase withString:replacement_phrase];
6983 spokenText = [
spokenText stringByReplacingOccurrencesOfString:systemName withString:systemSaid];
6984 spokenText = [
spokenText stringByReplacingOccurrencesOfString:h_systemName withString:h_systemSaid];
6942- (void) speakWithSubstitutions:(NSString *)text {
…}
6993- (void) addMessage:(NSString *) text forCount:(
OOTimeDelta) count forceDisplay:(BOOL) forceDisplay
7004 [PLAYER doScriptEvent:OOJSID("consoleMessageReceived") withArgument:text];
7006 [currentMessage release];
6993- (void) addMessage:(NSString *) text forCount:(
OOTimeDelta) count forceDisplay:(BOOL) forceDisplay {
…}
7019- (void) addCommsMessage:(NSString *)text forCount:(
OOTimeDelta)count andShowComms:(BOOL)showComms logOnly:(BOOL)logOnly
7021 if ([
PLAYER showDemoShips])
return;
7023 NSString *expandedMessage =
OOExpand(text);
7034 NSString *format =
OOExpandKey(
@"speech-synthesis-incoming-message-@");
7040 [currentMessage release];
7019- (void) addCommsMessage:(NSString *)text forCount:(
OOTimeDelta)count andShowComms:(BOOL)showComms logOnly:(BOOL)logOnly {
…}
7059- (void) showGUIMessage:(NSString *)text withScroll:(BOOL)scroll andColor:(
OOColor *)selectedColor overDuration:(
OOTimeDelta)how_long
7059- (void) showGUIMessage:(NSString *)text withScroll:(BOOL)scroll andColor:(
OOColor *)selectedColor overDuration:(
OOTimeDelta)how_long {
…}
7080 [PLAYER doWorldScriptEvent:OOJSIDFromString(system_repopulator) inContext:context withArguments:NULL count:0 timeLimit:kOOJSLongTimeLimit];
7090 OOLog(
@"universe.profile.update",
@"%@",
@"Begin update");
7105 for (i = 0; i < ent_count; i++)
7110 NSString *
volatile update_stage =
@"initialisation";
7112 id volatile update_stage_param =
nil;
7127 if (
EXPECT_NOT([player showDemoShips] && [player guiScreen] == GUI_SCREEN_SHIPLIBRARY))
7129 update_stage =
@"demo management";
7209 update_stage =
@"update:entity";
7210 NSMutableSet *zombies =
nil;
7211 OOLog(
@"universe.profile.update",
@"%@", update_stage);
7212 for (i = 0; i < ent_count; i++)
7214 Entity *thing = my_entities[
i];
7216 update_stage_param = thing;
7217 update_stage =
@"update:entity [%@]";
7235 update_stage =
@"update:list maintenance [%@]";
7242 while (index > 0 && z_distance <
sortedEntities[index - 1]->zero_distance)
7255 update_stage =
@"update:think [%@]";
7270 update_stage_param =
nil;
7275 update_stage =
@"shootin' zombies";
7276 NSEnumerator *zombieEnum =
nil;
7278 for (zombieEnum = [zombies objectEnumerator]; (zombie = [
zombieEnum nextObject]); )
7280 OOLogERR(
@"universe.zombie",
@"Found dead entity %@ in active entity list, removing. This is an internal error, please report it.", zombie);
7286 update_stage =
@"updating linked lists";
7287 OOLog(
@"universe.profile.update",
@"%@", update_stage);
7288 for (i = 0; i < ent_count; i++)
7295 update_stage =
@"collision and shadow detection";
7296 OOLog(
@"universe.profile.update",
@"%@", update_stage);
7308 @catch (NSException *exception)
7310 if ([[exception name] hasPrefix:
@"Oolite"])
7317 if (update_stage_param !=
nil) update_stage = [
NSString stringWithFormat:update_stage, update_stage_param];
7319 OOLog(
kOOLogException,
@"***** Exception during [%@] in [Universe update:] : %@ : %@ *****", update_stage, [exception name], [exception reason]);
7325 update_stage =
@"clean up";
7326 OOLog(
@"universe.profile.update",
@"%@", update_stage);
7327 for (i = 0; i < ent_count; i++)
7339 update_stage =
@"JS Garbage Collection";
7340 OOLog(
@"universe.profile.update",
@"%@", update_stage);
7343 uint32 gcbytes1 = JS_GetGCParameter(JS_GetRuntime(context),JSGC_BYTES);
7349 uint32 gcbytes2 = JS_GetGCParameter(JS_GetRuntime(context),JSGC_BYTES);
7351 if (gcbytes2 < gcbytes1)
7353 OOLog(
@"universe.profile.jsgc",
@"Unplanned JS Garbage Collection from %d to %d",gcbytes1,gcbytes2);
7362 if ([
PLAYER status] == STATUS_DEAD) [PLAYER update:delta_t];
7365 [entitiesDeadThisUpdate autorelease];
7370 [
self prunePreloadingPlanetMaterials];
7373 OOLog(
@"universe.profile.update",
@"%@",
@"Update complete");
7384- (void) setTimeAccelerationFactor:(
double)newTimeAccelerationFactor
7384- (void) setTimeAccelerationFactor:(
double)newTimeAccelerationFactor {
…}
7393- (double) timeAccelerationFactor
7399- (void) setTimeAccelerationFactor:(
double)newTimeAccelerationFactor
7411- (void) setECMVisualFXEnabled:(BOOL)isEnabled
7411- (void) setECMVisualFXEnabled:(BOOL)isEnabled {
…}
7427 Entity *e0, *next, *prev;
7428 OOHPScalar start, finish, next_start, next_finish, prev_start, prev_finish;
7459 if (next_start < finish)
7462 while ((next)&&(next_start < finish))
7466 if (next_finish > finish)
7467 finish = next_finish;
7503 if (prev_start > finish)
7506 while ((prev)&&(prev_start > finish))
7510 if (prev_finish < finish)
7511 finish = prev_finish;
7550 if (next_start < finish)
7553 while ((next)&&(next_start < finish))
7557 if (next_finish > finish)
7558 finish = next_finish;
7594 if (prev_start > finish)
7597 while ((prev)&&(prev_start > finish))
7601 if (prev_finish < finish)
7602 finish = prev_finish;
7640 if (next_start < finish)
7643 while ((next)&&(next_start < finish))
7647 if (next_finish > finish)
7648 finish = next_finish;
7684 if (prev_start > finish)
7687 while ((prev)&&(prev_start > finish))
7691 if (prev_finish < finish)
7692 finish = prev_finish;
7730 if (next_start < finish)
7733 while ((next)&&(next_start < finish))
7737 if (next_finish > finish)
7738 finish = next_finish;
7773 if (prev_start > finish)
7776 while ((prev)&&(prev_start > finish))
7780 if (prev_finish < finish)
7781 finish = prev_finish;
7819 if (next_start < finish)
7822 while ((next)&&(next_start < finish))
7828 if (next_finish > finish)
7829 finish = next_finish;
7865 if (prev_start > finish)
7868 while ((prev)&&(prev_start > finish))
7893 OOLog(
@"general.error.inconsistentState",
@"Unexpected state in collision chain builder prev=%@, prev->c=%@, e0=%@, e0->c=%@",prev,prev->
collision_chain,e0,e0->
collision_chain);
7899 if (prev_finish < finish)
7900 finish = prev_finish;
7939 NSAutoreleasePool *pool =
nil;
7947 for (i = 0; i < 256; i++)
7951 [system_names[
i] release];
7963 NSDictionary *systemData;
7966 NSString *scriptName;
7974 economy = [
systemData oo_unsignedCharForKey:KEY_ECONOMY];
7975 scriptName = [
systemData oo_stringForKey:@"market_script" defaultValue:nil];
7995 stringByAppendingPathComponent:@"Config"]
7996 stringByAppendingPathComponent:@"descriptions.plist"]];
8004static void VerifyDesc(NSString *key,
id desc);
8009 if ([desc rangeOfString:
@"%n"].location != NSNotFound)
8011 OOLog(
@"descriptions.verify.percentN",
@"***** FATAL: descriptions.plist entry \"%@\
" contains the dangerous control sequence %%n.", key);
8020 foreach (subDesc, desc)
8029 if ([desc isKindOfClass:[NSString
class]])
8033 else if ([desc isKindOfClass:[NSArray
class]])
8037 else if ([desc isKindOfClass:[NSNumber
class]])
8043 OOLogERR(
@"descriptions.verify.badType",
@"***** FATAL: descriptions.plist entry for \"%@\
" is neither a string nor an array.", key);
8061 NSString *key =
nil;
8062 if (_descriptions ==
nil)
8064 OOLog(
@"descriptions.verify",
@"%@",
@"***** FATAL: Tried to verify descriptions, but descriptions was nil - unable to load any descriptions.plist file.");
8069 VerifyDesc(key, [_descriptions objectForKey:key]);
8082- (NSDictionary *) explosionSetting:(NSString *)explosion
8084 return [explosionSettings oo_dictionaryForKey:explosion defaultValue:nil];
8082- (NSDictionary *) explosionSetting:(NSString *)explosion {
…}
8113- (NSString *)descriptionForKey:(NSString *)key
8113- (NSString *)descriptionForKey:(NSString *)key {
…}
8119- (NSString *)descriptionForArrayKey:(NSString *)key index:(
unsigned)index
8121 NSArray *array = [[
self descriptions] oo_arrayForKey:key];
8122 if ([array
count] <= index)
return nil;
8123 return [
array objectAtIndex:index];
8119- (NSString *)descriptionForArrayKey:(NSString *)key index:(
unsigned)index {
…}
8127- (BOOL) descriptionBooleanForKey:(NSString *)key
8127- (BOOL) descriptionBooleanForKey:(NSString *)key {
…}
8141 return [
NSString stringWithFormat:@"%d %d", g, s];
8147 return [
NSString stringWithFormat:@"interstellar: %d %d %d", g, s1, s2];
8158- (NSDictionary *) generateSystemData:(
OOSystemID) s useCache:(BOOL) useCache
8165 NSString *systemKey = [
NSString stringWithFormat:@"%u %u",[PLAYER galaxyNumber],s];
8158- (NSDictionary *) generateSystemData:(
OOSystemID) s useCache:(BOOL) useCache {
…}
8183 static NSDictionary *interstellarDict =
nil;
8184 if (interstellarDict ==
nil)
8186 NSString *interstellarName =
DESC(
@"interstellar-space");
8187 NSString *notApplicable =
DESC(
@"not-applicable");
8188 NSNumber *minusOne = [
NSNumber numberWithInt:-1];
8189 NSNumber *zero = [
NSNumber numberWithInt:0];
8190 interstellarDict = [[
NSDictionary alloc] initWithObjectsAndKeys:
8191 interstellarName, KEY_NAME,
8192 minusOne, KEY_GOVERNMENT,
8193 minusOne, KEY_ECONOMY,
8194 minusOne, KEY_TECHLEVEL,
8195 zero, KEY_POPULATION,
8196 zero, KEY_PRODUCTIVITY,
8198 notApplicable, KEY_INHABITANTS,
8199 notApplicable, KEY_DESCRIPTION,
8203 return interstellarDict;
8212 return [
self sun] ==
nil;
8220- (void) setSystemDataKey:(NSString *)key value:(NSObject *)object fromManifest:(NSString *)manifest
8220- (void) setSystemDataKey:(NSString *)key value:(NSObject *)object fromManifest:(NSString *)manifest {
…}
8228 static BOOL sysdataLocked = NO;
8231 OOLogERR(
@"script.error",
@"%@",
@"System properties cannot be set during 'systemInformationChanged' events to avoid infinite loops.");
8235 BOOL sameGalaxy = (gnum == [PLAYER currentGalaxyID]);
8239 if ([key isEqualToString:
KEY_RADIUS] && sameGalaxy && sameSystem)
8241 OOLogERR(
@"script.error",
@"System property '%@' cannot be set while in the system.",key);
8245 if ([key isEqualToString:
@"coordinates"])
8247 OOLogERR(
@"script.error",
@"System property '%@' cannot be set.",key);
8252 NSString *overrideKey = [
NSString stringWithFormat:@"%u %u", gnum, pnum];
8253 NSDictionary *sysInfo =
nil;
8258 if (
object !=
nil) {
8260 if ([key isEqualToString:
KEY_NAME])
8262 object=(id)[[(NSString *)
object lowercaseString] capitalizedString];
8269 else if ([key isEqualToString:
@"sun_radius"])
8271 if ([
object doubleValue] < 1000.0 || [
object doubleValue] > 10000000.0 )
8273 object = ([
object doubleValue] < 1000.0 ? (id)
@"1000.0" : (id)
@"10000000.0");
8276 else if ([key hasPrefix:
@"corona_"])
8278 object = (id)[NSString stringWithFormat:
@"%f",OOClamp_0_1_f([
object floatValue])];
8303 else if ([key isEqualToString:
@"sun_color"] || [key isEqualToString:
@"star_count_multiplier"] ||
8304 [key isEqualToString:
@"nebula_count_multiplier"] || [key hasPrefix:
@"sky_"])
8317 if ([key isEqualToString:
@"sun_color"])
8332 else if (the_sun !=
nil && ([key hasPrefix:
@"sun_"] || [key hasPrefix:
@"corona_"]))
8336 else if ([key isEqualToString:
@"texture"])
8338 [[
self planet] setUpPlanetFromTexture:(NSString *)object];
8340 else if ([key isEqualToString:
@"texture_hsb_color"])
8342 [[
self planet] setUpPlanetFromTexture: [[
self planet] textureFileName]];
8344 else if ([key isEqualToString:
@"air_color"])
8348 else if ([key isEqualToString:
@"illumination_color"])
8352 else if ([key isEqualToString:
@"air_color_mix_ratio"])
8354 [[
self planet] setAirColorMixRatio:[
sysInfo oo_floatForKey:key]];
8358 sysdataLocked = YES;
8359 [PLAYER doScriptEvent:OOJSID("systemInformationChanged") withArguments:[
NSArray arrayWithObjects:[
NSNumber numberWithInt:gnum],[
NSNumber numberWithInt:pnum],key,object,nil]];
8409- (NSString *) getSystemInhabitants:(
OOSystemID) sys plural:(BOOL)plural
8411 NSString *ret =
nil;
8409- (NSString *) getSystemInhabitants:(
OOSystemID) sys plural:(BOOL)plural {
…}
8435 if (sysName ==
nil)
return -1;
8437 NSString *system_name =
nil;
8438 NSString *match = [
sysName lowercaseString];
8440 for (i = 0; i < 256; i++)
8442 system_name = [system_names[
i] lowercaseString];
8443 if ([system_name isEqualToString:match])
8454 OOLog(
@"deprecated.function",
@"%@",
@"findSystemAtCoords");
8459- (NSMutableArray *) nearbyDestinationsWithinRange:(
double)range
8464 NSPoint here = [PLAYER galaxy_coordinates];
8466 for (
unsigned short i = 0; i < 256; i++)
8473 [
NSNumber numberWithDouble:dist], @"distance",
8474 [
NSNumber numberWithInt:i], @"sysID",
8475 [[
self generateSystemData:i] oo_stringForKey:@"sun_gone_nova" defaultValue:@"0"], @"nova",
8459- (NSMutableArray *) nearbyDestinationsWithinRange:(
double)range {
…}
8489 double min_dist = 10000.0;
8492 BOOL connected[256];
8493 for (i = 0; i < 256; i++)
8496 for (n = 0; n < 3; n++)
8498 for (i = 0; i < 256; i++)
8501 for (j = 0; j < 256; j++)
8507 connected[
j] |= connected[
i];
8508 connected[
i] |= connected[
j];
8514 for (i = 0; i < 256; i++)
8518 if ((connected[i])&&(distance < min_dist)&&(distance != 0.0))
8520 min_dist = distance;
8536 double min_dist = 10000.0;
8539 BOOL connected[256];
8540 for (i = 0; i < 256; i++)
8543 for (n = 0; n < 3; n++)
8545 for (i = 0; i < 256; i++)
8548 for (j = 0; j < 256; j++)
8554 connected[
j] |= connected[
i];
8555 connected[
i] |= connected[
j];
8561 for (i = 0; i < 256; i++)
8565 if ((connected[i])&&(distance < min_dist))
8567 min_dist = distance;
8585 unsigned distance, dx, dy;
8587 unsigned min_dist = 10000;
8589 for (i = 0; i < 256; i++)
8593 NSInteger concealment = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
8600 dx =
ABS(coords.x - ipos.x);
8601 dy =
ABS(coords.y - ipos.y);
8603 if (dx > dy) distance = (dx + dx + dy) / 2;
8604 else distance = (dx + dy + dy) / 2;
8606 if (distance < min_dist)
8608 min_dist = distance;
8612 if ((distance == min_dist)&&(coords.y > ipos.y))
8626- (NSPoint) findSystemCoordinatesWithPrefix:(NSString *) p_fix
8626- (NSPoint) findSystemCoordinatesWithPrefix:(NSString *) p_fix {
…}
8632- (NSPoint) findSystemCoordinatesWithPrefix:(NSString *) p_fix exactMatch:(BOOL) exactMatch
8634 NSString *system_name =
nil;
8635 NSPoint system_coords = NSMakePoint(-1.0,-1.0);
8638 for (i = 0; i < 256; i++)
8641 system_name = [system_names[
i] lowercaseString];
8642 if ((exactMatch && [system_name isEqualToString:p_fix]) || (!exactMatch && [system_name hasPrefix:p_fix]))
8646 NSInteger concealment = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
8660 return system_coords;
8632- (NSPoint) findSystemCoordinatesWithPrefix:(NSString *) p_fix exactMatch:(BOOL) exactMatch {
…}
8689 if (start == -1 || goal == -1)
return nil;
8691#ifdef CACHE_ROUTE_FROM_SYSTEM_RESULTS
8693 static NSDictionary *c_route =
nil;
8697 if (c_route !=
nil && c_start == start && c_goal == goal && c_optimizeBy == optimizeBy)
8706 if (start > 255 || goal > 255)
return nil;
8708 NSArray *neighbours[256];
8709 BOOL concealed[256];
8710 for (i = 0; i < 256; i++)
8713 NSInteger concealment = [
systemInfo oo_intForKey:@"concealment" defaultValue:OO_SYSTEMCONCEALMENT_NONE];
8728 double maxCost = optimizeBy ==
OPTIMIZED_BY_TIME ? 256 * (7 * 7) : 256 * (7 * 256 + 7);
8734 while ([curr
count] != 0)
8736 for (i = 0; i < [
curr count]; i++) {
8739 for (j = 0; j < [
ns count]; j++)
8753 double lastTime = lastDistance * lastDistance;
8755 double distance = [
ce distance] + lastDistance;
8756 double time = [
ce time] + lastTime;
8760 if (cost < maxCost && (cheapest[n] ==
nil || [cheapest[n] cost] > cost)) {
8765 if (n == goal && cost < maxCost)
8770 [
curr setArray:next];
8771 [
next removeAllObjects];
8775 if (!cheapest[goal])
return nil;
8782 if ([e parent] == -1)
break;
8786#ifdef CACHE_ROUTE_FROM_SYSTEM_RESULTS
8789 c_optimizeBy = optimizeBy;
8815 [closeSystems release];
8855 [
self prunePreloadingPlanetMaterials];
8857 if ([_preloadingPlanetMaterials
count] < 3)
8859 if (_preloadingPlanetMaterials ==
nil) _preloadingPlanetMaterials = [[
NSMutableArray alloc] initWithCapacity:4];
8867 if (![surface isFinishedLoading])
8873 OOMaterial *atmo = [planet atmosphereMaterial];
8908- (NSString *) timeDescription:(
double) interval
8910 double r_time = interval;
8911 NSString* result =
@"";
8915 int days = floor(r_time / 86400);
8916 r_time -= 86400 * days;
8917 result = [
NSString stringWithFormat:@"%@ %d day%@", result, days, (days > 1) ? @"s" : @""];
8921 int hours = floor(r_time / 3600);
8922 r_time -= 3600 * hours;
8923 result = [
NSString stringWithFormat:@"%@ %d hour%@", result, hours, (hours > 1) ? @"s" : @""];
8927 int mins = floor(r_time / 60);
8928 r_time -= 60 * mins;
8929 result = [
NSString stringWithFormat:@"%@ %d minute%@", result, mins, (mins > 1) ? @"s" : @""];
8933 int secs = floor(r_time);
8934 result = [
NSString stringWithFormat:@"%@ %d second%@", result, secs, (secs > 1) ? @"s" : @""];
8908- (NSString *) timeDescription:(
double) interval {
…}
8940- (NSString *) shortTimeDescription:(
double) interval
8942 double r_time = interval;
8943 NSString* result =
@"";
8946 if (interval <= 0.0)
8947 return DESC(
@"contracts-no-time");
8951 int days = floor(r_time / 86400);
8952 r_time -= 86400 * days;
8953 result = [
NSString stringWithFormat:@"%@ %d %@", result, days, DESC_PLURAL(@"contracts-day-word", days)];
8958 int hours = floor(r_time / 3600);
8959 r_time -= 3600 * hours;
8960 result = [
NSString stringWithFormat:@"%@ %d %@", result, hours, DESC_PLURAL(@"contracts-hour-word", hours)];
8963 if (parts < 2 && r_time > 60)
8965 int mins = floor(r_time / 60);
8966 r_time -= 60 * mins;
8967 result = [
NSString stringWithFormat:@"%@ %d %@", result, mins, DESC_PLURAL(@"contracts-minute-word", mins)];
8970 if (parts < 2 && r_time > 0)
8972 int secs = floor(r_time);
8973 result = [
NSString stringWithFormat:@"%@ %d %@", result, secs, DESC_PLURAL(@"contracts-second-word", secs)];
8940- (NSString *) shortTimeDescription:(
double) interval {
…}
9007- (void) loadStationMarkets:(NSArray *)marketData
9009 if (marketData ==
nil)
9016 NSDictionary *savedMarket =
nil;
9018 foreach (savedMarket, marketData)
9020 HPVector pos = [
savedMarket oo_hpvectorForKey:@"position"];
9027 if (HPdistance2(pos,[
station position]) < 1000000)
9007- (void) loadStationMarkets:(NSArray *)marketData {
…}
9045 NSMutableDictionary *savedMarket =
nil;
9055 if (stationMarket !=
nil)
9060 [
markets addObject:savedMarket];
9076 float tech_price_boost = (ship_seed.
a + ship_seed.
b) / 256.0;
9082 for (i = 0; i < 256; i++)
9084 long long reference_time = 0x1000000 * floor(current_time / 0x1000000);
9086 long long c_time = ship_seed.
a * 0x10000 + ship_seed.
b * 0x100 + ship_seed.
c;
9087 double ship_sold_time = reference_time + c_time;
9089 if (ship_sold_time < 0)
9090 ship_sold_time += 0x1000000;
9092 double days_until_sale = (ship_sold_time - current_time) / 86400.0;
9101 NSArray *conditions = [
dict oo_arrayForKey:@"conditions"];
9103 if (![player scriptTestConditions:conditions])
9107 NSString *condition_script = [
dict oo_stringForKey:@"condition_script"];
9108 if (condition_script !=
nil)
9111 if (condScript !=
nil)
9115 JSBool allow_purchase;
9124 if (OK) OK = JS_ValueToBoolean(context, result, &allow_purchase);
9128 if (OK && !allow_purchase)
9142 if (specialTL != NSNotFound)
9145 techlevel = specialTL;
9150 techlevel = [
systemInfo oo_unsignedIntForKey:KEY_TECHLEVEL];
9152 unsigned ship_index = (ship_seed.
d * 0x100 + ship_seed.
e) % [keysForShips
count];
9153 NSString *ship_key = [
keysForShips oo_stringAtIndex:ship_index];
9160 int superRand1 = ship_seed.
a * 0x10000 + ship_seed.
c * 0x100 + ship_seed.
e;
9161 uint32_t superRand2 = ship_seed.
b * 0x10000 + ship_seed.
d * 0x100 + ship_seed.
f;
9166 if ((days_until_sale > 0.0) && (days_until_sale < 30.0) && (ship_techlevel <= techlevel) && (
randf() < chance) && (shipBaseDict !=
nil))
9168 NSMutableDictionary* shipDict = [
NSMutableDictionary dictionaryWithDictionary:shipBaseDict];
9169 NSMutableString* shortShipDescription = [
NSMutableString stringWithCapacity:256];
9170 NSString *shipName = [
shipDict oo_stringForKey:@"display_name" defaultValue:[
shipDict oo_stringForKey:KEY_NAME]];
9173 NSMutableArray* extras = [
NSMutableArray arrayWithArray:[[
ship_info oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_arrayForKey:KEY_EQUIPMENT_EXTRAS]];
9174 NSString* fwdWeaponString = [[
ship_info oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_stringForKey:KEY_EQUIPMENT_FORWARD_WEAPON];
9175 NSString* aftWeaponString = [[
ship_info oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_stringForKey:KEY_EQUIPMENT_AFT_WEAPON];
9192 if (fwdWeapon && fwdWeaponString) [
shipDict setObject:fwdWeaponString forKey:KEY_EQUIPMENT_FORWARD_WEAPON];
9193 if (aftWeapon && aftWeaponString) [
shipDict setObject:aftWeaponString forKey:KEY_EQUIPMENT_AFT_WEAPON];
9195 int passengerBerthCount = 0;
9196 BOOL customised = NO;
9197 BOOL weaponCustomized = NO;
9199 NSString *fwdWeaponDesc =
nil;
9201 NSString *shortExtrasKey =
@"shipyard-first-extra";
9206 while ((
randf() < chance) && ([options
count]))
9210 NSString *equipmentKey = [
options oo_stringAtIndex:optionIndex];
9217 NSString *eqShortDesc = [
item name];
9219 if ([item techLevel] > techlevel)
9222 eqTechLevel =
MIN(eqTechLevel, 15U);
9225 if (
randf() * (eqTechLevel - techlevel) < 1.0)
9228 eqPrice *= (tech_price_boost + eqTechLevel - techlevel) * 90 / 100;
9234 if ([item incompatibleEquipment] !=
nil && extras !=
nil)
9236 NSEnumerator *keyEnum =
nil;
9238 BOOL incompatible = NO;
9240 for (keyEnum = [[item incompatibleEquipment] objectEnumerator]; (key = [
keyEnum nextObject]); )
9242 if ([extras containsObject:key])
9244 [
options removeObject:equipmentKey];
9249 if (incompatible)
break;
9252 for (keyEnum = [[item incompatibleEquipment] objectEnumerator]; (key = [
keyEnum nextObject]); )
9254 if ([options containsObject:key])
9263 if (condition_script !=
nil)
9266 if (condScript !=
nil)
9270 JSBool allow_addition;
9279 if (OK) OK = JS_ValueToBoolean(JScontext, result, &allow_addition);
9283 if (OK && !allow_addition)
9294 if ([item requiresEquipment] !=
nil && extras !=
nil)
9296 NSEnumerator *keyEnum =
nil;
9300 for (keyEnum = [[item requiresEquipment] objectEnumerator]; (key = [
keyEnum nextObject]); )
9302 if (![extras containsObject:key])
9310 if ([item requiresAnyEquipment] !=
nil && extras !=
nil)
9312 NSEnumerator *keyEnum =
nil;
9316 for (keyEnum = [[item requiresAnyEquipment] objectEnumerator]; (key = [
keyEnum nextObject]); )
9318 if ([extras containsObject:key])
9328 if ([equipmentKey isEqualTo:
@"EQ_NAVAL_ENERGY_UNIT"])
9330 if ([extras containsObject:
@"EQ_ENERGY_UNIT"])
9332 [
options removeObject:equipmentKey];
9337 if ([equipmentKey hasPrefix:
@"EQ_WEAPON"])
9341 if (availableFacings &
WEAPON_FACING_FORWARD && [new_weapon weaponThreatAssessment] > [fwdWeapon weaponThreatAssessment])
9346 fwdWeaponString = equipmentKey;
9347 fwdWeapon = new_weapon;
9348 [
shipDict setObject:fwdWeaponString forKey:KEY_EQUIPMENT_FORWARD_WEAPON];
9349 weaponCustomized = YES;
9350 fwdWeaponDesc = eqShortDesc;
9355 if (availableFacings &
WEAPON_FACING_AFT && (
isWeaponNone(aftWeapon) || [new_weapon weaponThreatAssessment] > [aftWeapon weaponThreatAssessment]))
9359 aftWeaponString = equipmentKey;
9360 aftWeapon = new_weapon;
9361 [
shipDict setObject:aftWeaponString forKey:KEY_EQUIPMENT_AFT_WEAPON];
9365 [
options removeObject:equipmentKey];
9372 if ([equipmentKey isEqualToString:
@"EQ_PASSENGER_BERTH"])
9378 [
extras addObject:equipmentKey];
9379 passengerBerthCount++;
9385 [
options removeObject:equipmentKey];
9391 [
extras addObject:equipmentKey];
9392 if ([item isVisible])
9394 NSString *item = eqShortDesc;
9396 shortExtrasKey =
@"shipyard-additional-extra";
9399 [
options removeObject:equipmentKey];
9405 [
options removeObject:equipmentKey];
9410 BOOL lowercaseIgnore = [[
self descriptions] oo_boolForKey:@"lowercase_ignore"];
9412 if (passengerBerthCount)
9414 NSString* npb = (passengerBerthCount > 1)? [NSString stringWithFormat:
@"%d ", passengerBerthCount] : (id)
@"";
9415 NSString* ppb =
DESC_PLURAL(
@"passenger-berth", passengerBerthCount);
9416 NSString* extraPassengerBerthsDescription = [
NSString stringWithFormat:DESC(@"extra-@-@-(passenger-berths)"), npb, ppb];
9417 NSString *item = extraPassengerBerthsDescription;
9419 shortExtrasKey =
@"shipyard-additional-extra";
9427 if (weaponCustomized)
9429 NSString *weapon = (lowercaseIgnore ? fwdWeaponDesc : [
fwdWeaponDesc lowercaseString]);
9432 if (price > base_price)
9434 price = base_price +
cunningFee(price - base_price, 0.05);
9439 NSString *shipID = [
NSString stringWithFormat:@"%06x-%06x", superRand1, superRand2];
9443 NSDictionary *ship_info_dictionary = [
NSDictionary dictionaryWithObjectsAndKeys:
9444 shipID, SHIPYARD_KEY_ID,
9445 ship_key, SHIPYARD_KEY_SHIPDATA_KEY,
9446 shipDict, SHIPYARD_KEY_SHIP,
9447 shortShipDescription, KEY_SHORT_DESCRIPTION,
9448 [
NSNumber numberWithUnsignedLongLong:price], SHIPYARD_KEY_PRICE,
9449 extras, KEY_EQUIPMENT_EXTRAS,
9450 [
NSNumber numberWithUnsignedShort:personality], SHIPYARD_KEY_PERSONALITY,
9463 NSMutableArray *resultArray = [[[
resultDictionary allValues] mutableCopy] autorelease];
9464 [
resultArray sortUsingFunction:compareName context:NULL];
9469 while (i < [resultArray
count])
9471 if (
compareName([resultArray objectAtIndex:i - 1], [resultArray objectAtIndex:i],
nil) == NSOrderedSame )
9483 return [
NSArray arrayWithArray:resultArray];
9489 NSDictionary *ship1 = [(
NSDictionary *)
dict1 oo_dictionaryForKey:SHIPYARD_KEY_SHIP];
9490 NSDictionary *ship2 = [(
NSDictionary *)
dict2 oo_dictionaryForKey:SHIPYARD_KEY_SHIP];
9491 NSString *name1 = [
ship1 oo_stringForKey:KEY_NAME];
9492 NSString *name2 = [
ship2 oo_stringForKey:KEY_NAME];
9494 NSComparisonResult result = [[
name1 lowercaseString] compare:[
name2 lowercaseString]];
9495 if (result != NSOrderedSame)
9507 return [
price1 compare:price2];
9515 NSString *ship_desc = [
dict oo_stringForKey:@"ship_desc"];
9519 if (shipyard_info ==
nil)
9521 OOLogERR(
@"universe.tradeInValueForCommanderDictionary.valueCalculationError",
9522 @"Shipyard dictionary entry for ship %@ required for trade in value calculation, but does not exist. Setting ship value to 0.", ship_desc);
9526 base_price = [
shipyard_info oo_unsignedLongLongForKey:SHIPYARD_KEY_PRICE defaultValue:0ULL];
9529 if(base_price == 0ULL)
return base_price;
9537 unsigned ship_missiles = [
dict oo_unsignedIntForKey:@"missiles"];
9538 unsigned ship_max_passengers = [
dict oo_unsignedIntForKey:@"max_passengers"];
9539 NSMutableArray *ship_extra_equipment = [
NSMutableArray arrayWithArray:[[
dict oo_dictionaryForKey:@"extra_equipment"] allKeys]];
9541 NSDictionary *basic_info = [
shipyard_info oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT];
9542 unsigned base_missiles = [
basic_info oo_unsignedIntForKey:KEY_EQUIPMENT_MISSILES];
9543 OOCreditsQuantity base_missiles_value = base_missiles * [UNIVERSE getEquipmentPriceForKey:@"EQ_MISSILE"] / 10;
9544 NSString *base_weapon_key = [
basic_info oo_stringForKey:KEY_EQUIPMENT_FORWARD_WEAPON];
9545 OOCreditsQuantity base_weapons_value = [UNIVERSE getEquipmentPriceForKey:base_weapon_key] / 10;
9546 NSMutableArray *base_extra_equipment = [
NSMutableArray arrayWithArray:[
basic_info oo_arrayForKey:KEY_EQUIPMENT_EXTRAS]];
9547 NSString *weapon_key =
nil;
9550 base_weapon_key = [
basic_info oo_stringForKey:KEY_EQUIPMENT_AFT_WEAPON defaultValue:nil];
9551 if (base_weapon_key !=
nil)
9552 base_weapons_value += [UNIVERSE getEquipmentPriceForKey:base_weapon_key] / 10;
9559 NSArray *missileRoles = [
dict oo_arrayForKey:@"missile_roles"];
9560 if (missileRoles !=
nil)
9563 for (i = 0; i < ship_missiles; i++)
9565 NSString *missile_desc = [
missileRoles oo_stringAtIndex:i];
9566 if (missile_desc !=
nil && ![missile_desc isEqualToString:
@"NONE"])
9568 ship_missiles_value += [UNIVERSE getEquipmentPriceForKey:missile_desc] / 10;
9573 ship_missiles_value = ship_missiles * [UNIVERSE getEquipmentPriceForKey:@"EQ_MISSILE"] / 10;
9576 long long extra_equipment_value = ship_max_passengers * [UNIVERSE getEquipmentPriceForKey:@"EQ_PASSENGER_BERTH"]/10;
9579 extra_equipment_value += ship_missiles_value - base_missiles_value;
9582 if (ship_fwd_weapon)
9585 ship_main_weapons_value = [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
9587 if (ship_aft_weapon)
9590 if (base_weapon_key !=
nil)
9592 ship_main_weapons_value += [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
9596 ship_other_weapons_value += [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
9599 if (ship_port_weapon)
9602 ship_other_weapons_value += [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
9604 if (ship_starboard_weapon)
9607 ship_other_weapons_value += [UNIVERSE getEquipmentPriceForKey:weapon_key] / 10;
9611 extra_equipment_value += ship_other_weapons_value;
9612 extra_equipment_value += ship_main_weapons_value - base_weapons_value;
9615 NSString *eq_key =
nil;
9619 for (i = [base_extra_equipment
count]-1; i > 0;i--)
9622 if ([base_extra_equipment indexOfObject:eq_key inRange:NSMakeRange(0, i-1)] != NSNotFound)
9627 for (i = [base_extra_equipment
count]-1; i >= 0; i--)
9630 if ([ship_extra_equipment containsObject:eq_key])
9633 extra_equipment_value -= ([UNIVERSE getEquipmentPriceForKey:eq_key] / 10);
9639 for (i = [ship_extra_equipment
count]-1; i >= 0; i--)
9647 for (i = [ship_extra_equipment
count]-1; i >= 0; i--)
9648 extra_equipment_value += ([
UNIVERSE getEquipmentPriceForKey:[ship_extra_equipment oo_stringAtIndex:i]] / 10);
9651 extra_equipment_value *= extra_equipment_value < 0 ? 1.4 : 0.9;
9655 if ((
long long)scrap_value > (
long long)base_price + extra_equipment_value)
return scrap_value;
9657 return base_price + extra_equipment_value;
9661- (NSString *) brochureDescriptionWithDictionary:(NSDictionary *)dict standardEquipment:(NSArray *)extras optionalEquipment:(NSArray *)options
9663 NSMutableArray *mut_extras = [
NSMutableArray arrayWithArray:extras];
9664 NSString *allOptions = [
options componentsJoinedByString:@" "];
9666 NSMutableString *desc = [
NSMutableString stringWithFormat:@"The %@.", [
dict oo_stringForKey: KEY_NAME]];
9673 [
desc appendFormat:@" Cargo capacity %dt", max_cargo];
9674 BOOL canExpand = ([
allOptions rangeOfString:@"EQ_CARGO_BAY"].location != NSNotFound);
9676 [
desc appendFormat:@" (expandable to %dt at most starports)", max_cargo + extra_cargo];
9677 [
desc appendString:@"."];
9681 float top_speed = [
dict oo_intForKey:@"max_flight_speed"];
9682 [
desc appendFormat:@" Top speed %.3fLS.", 0.001 * top_speed];
9685 if ([mut_extras
count])
9687 unsigned n_berths = 0;
9691 NSString* item_key = [
mut_extras oo_stringAtIndex:i];
9692 if ([item_key isEqual:
@"EQ_PASSENGER_BERTH"])
9701 [
desc appendString:@" Includes luxury accomodation for a single passenger."];
9703 [
desc appendFormat:@" Includes luxury accomodation for %d passengers.", n_berths];
9708 if ([mut_extras
count])
9710 [
desc appendString:@"\nComes with"];
9714 NSString* item_key = [
mut_extras oo_stringAtIndex:i];
9715 NSString* item_desc =
nil;
9716 for (j = 0; ((j < [equipmentData count])&&(!item_desc)) ; j++)
9718 NSString *eq_type = [[equipmentData oo_arrayAtIndex:j] oo_stringAtIndex:EQUIPMENT_KEY_INDEX];
9719 if ([eq_type isEqual:item_key])
9720 item_desc = [[equipmentData oo_arrayAtIndex:j] oo_stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
9724 switch ([mut_extras
count] - i)
9727 [
desc appendFormat:@" %@ fitted as standard.", item_desc];
9730 [
desc appendFormat:@" %@ and", item_desc];
9733 [
desc appendFormat:@" %@,", item_desc];
9741 if ([options
count])
9743 [
desc appendString:@"\nCan additionally be outfitted with"];
9745 for (i = 0; i < [
options count]; i++)
9747 NSString* item_key = [
options oo_stringAtIndex:i];
9748 NSString* item_desc =
nil;
9749 for (j = 0; ((j < [equipmentData count])&&(!item_desc)) ; j++)
9751 NSString *eq_type = [[equipmentData oo_arrayAtIndex:j] oo_stringAtIndex:EQUIPMENT_KEY_INDEX];
9752 if ([eq_type isEqual:item_key])
9753 item_desc = [[equipmentData oo_arrayAtIndex:j] oo_stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX];
9757 switch ([options
count] - i)
9760 [
desc appendFormat:@" %@ at suitably equipped starports.", item_desc];
9763 [
desc appendFormat:@" %@ and/or", item_desc];
9766 [
desc appendFormat:@" %@,", item_desc];
9661- (NSString *) brochureDescriptionWithDictionary:(NSDictionary *)dict standardEquipment:(NSArray *)extras optionalEquipment:(NSArray *)options {
…}
9786 Quaternion q_result;
9796 quaternion_normalize(&q_result);
9818 v1.x -= v0.x; v1.y -= v0.y; v1.z -= v0.z;
9819 if (v1.x||v1.y||v1.z)
9820 v1 = HPvector_normal(v1);
9824 v1.x *= radius; v1.y *= radius; v1.z *= radius;
9825 v1.x += v0.x; v1.y += v0.y; v1.z += v0.z;
9847 v1.x -= v0.x; v1.y -= v0.y; v1.z -= v0.z;
9848 if (v1.x||v1.y||v1.z)
9849 v1 = HPvector_normal(v1);
9853 if (v2.x||v2.y||v2.z)
9854 v2 = HPvector_normal(v2);
9857 HPVector v3 = HPcross_product(v1, v2);
9858 if (v3.x||v3.y||v3.z)
9859 v3 = HPvector_normal(v3);
9863 v1.x *= radius; v1.y *= radius; v1.z *= radius;
9864 v1.x += v0.x; v1.y += v0.y; v1.z += v0.z;
9865 v1.x += 15000 * v3.x; v1.y += 15000 * v3.y; v1.z += 15000 * v3.z;
9866 v1.x -= v0.x; v1.y -= v0.y; v1.z -= v0.z;
9867 if (v1.x||v1.y||v1.z)
9868 v1 = HPvector_normal(v1);
9871 v1.x *= radius; v1.y *= radius; v1.z *= radius;
9872 v1.x += v0.x; v1.y += v0.y; v1.z += v0.z;
9878- (NSArray *) listBeaconsWithCode:(NSString *)code
9881 Entity <OOBeaconEntity> *beacon = [
self firstBeacon];
9883 while (beacon !=
nil)
9885 NSString *beaconCode = [
beacon beaconCode];
9886 if ([beaconCode rangeOfString:code options: NSCaseInsensitiveSearch].location != NSNotFound)
9888 [
result addObject:beacon];
9890 beacon = [
beacon nextBeacon];
9893 return [
result sortedArrayUsingSelector:@selector(compareBeaconCodeWith:)];
9878- (NSArray *) listBeaconsWithCode:(NSString *)code {
…}
9897- (void) allShipsDoScriptEvent:(jsid)event andReactToAIMessage:(NSString *)message
9903 for (i = 0; i < ent_count; i++)
9911 for (i = 0; i < ship_count; i++)
9897- (void) allShipsDoScriptEvent:(jsid)event andReactToAIMessage:(NSString *)message {
…}
9956- (void) setDisplayText:(BOOL) value
9956- (void) setDisplayText:(BOOL) value {
…}
9968- (void) setDisplayFPS:(BOOL) value
9968- (void) setDisplayFPS:(BOOL) value {
…}
9980- (void) setAutoSave:(BOOL) value
9983 [[
NSUserDefaults standardUserDefaults] setBool:autoSave forKey:@"autosave"];
9980- (void) setAutoSave:(BOOL) value {
…}
9993- (void) setAutoSaveNow:(BOOL) value
9993- (void) setAutoSaveNow:(BOOL) value {
…}
10005- (void) setWireframeGraphics:(BOOL) value
10008 [[
NSUserDefaults standardUserDefaults] setBool:wireframeGraphics forKey:@"wireframe-graphics"];
10005- (void) setWireframeGraphics:(BOOL) value {
…}
10039 detailLevel = value;
10047 [[
NSUserDefaults standardUserDefaults] setInteger:detailLevel forKey:@"detailLevel"];
10070- (void) handleOoliteException:(NSException *)exception
10072 if (exception !=
nil)
10079 OOLog(
kOOLogException,
@"***** Handling Fatal : %@ : %@ *****",[exception name], [exception reason]);
10080 NSString* exception_msg = [
NSString stringWithFormat:@"Exception : %@ : %@ Please take a screenshot and/or press esc or Q to quit.", [
exception name], [
exception reason]];
10086 OOLog(
kOOLogException,
@"***** Handling Non-fatal : %@ : %@ *****",[exception name], [exception reason]);
10070- (void) handleOoliteException:(NSException *)exception {
…}
10098- (void) setAirResistanceFactor:(GLfloat)newFactor
10098- (void) setAirResistanceFactor:(GLfloat)newFactor {
…}
10107- (void) startSpeakingString:(NSString *) text
10109 [speechSynthesizer startSpeakingString:[
NSString stringWithFormat:@"[[volm %.3f]]%@", 0.3333333f * [
OOSound masterVolume], text]];
10107- (void) startSpeakingString:(NSString *) text {
…}
10117 [speechSynthesizer stopSpeakingAtBoundary:NSSpeechWordBoundary];
10121 [speechSynthesizer stopSpeaking];
10128 return [speechSynthesizer isSpeaking];
10133- (void) startSpeakingString:(NSString *) text
10135 NSData *utf8 = [text dataUsingEncoding:NSUTF8StringEncoding];
10139 const char *stringToSay = [text UTF8String];
10140 espeak_Synth(stringToSay, strlen(stringToSay) + 1 , 0, POS_CHARACTER, 0, espeakCHARS_UTF8 | espeakPHONEMES | espeakENDPAUSE, NULL, NULL);
10145- (void) stopSpeaking
10153 return espeak_IsPlaying();
10157- (NSString *) voiceName:(
unsigned int) index
10159 if (index >= espeak_voice_count)
10161 return [NSString stringWithCString: espeak_voices[index]->name];
10165- (
unsigned int) voiceNumber:(NSString *) name
10170 const char *
const label = [name UTF8String];
10174 unsigned int index = -1;
10175 while (espeak_voices[++index] && strcmp (espeak_voices[index]->name, label))
10177 return (index < espeak_voice_count) ? index : UINT_MAX;
10181- (
unsigned int) nextVoice:(
unsigned int) index
10183 if (++index >= espeak_voice_count)
10189- (
unsigned int) prevVoice:(
unsigned int) index
10191 if (--index >= espeak_voice_count)
10192 index = espeak_voice_count - 1;
10197- (
unsigned int) setVoice:(
unsigned int) index withGenderM:(BOOL) isMale
10199 if (index == UINT_MAX)
10200 index = [
self voiceNumber:DESC(@"espeak-default-voice")];
10202 if (index < espeak_voice_count)
10204 espeak_VOICE voice = { espeak_voices[index]->name, NULL, NULL, isMale ? 1 : 2 };
10205 espeak_SetVoiceByProperties (&voice);
10213- (void) startSpeakingString:(NSString *) text {}
10215- (void) stopSpeaking {}
10230- (void) setPauseMessageVisible:(BOOL)value
10230- (void) setPauseMessageVisible:(BOOL)value {
…}
10242- (void) setPermanentMessageLog:(BOOL)value
10242- (void) setPermanentMessageLog:(BOOL)value {
…}
10254- (void) setAutoMessageLogBg:(BOOL)value
10254- (void) setAutoMessageLogBg:(BOOL)value {
…}
10266- (void) setPermanentCommLog:(BOOL)value
10266- (void) setPermanentCommLog:(BOOL)value {
…}
10272- (void) setAutoCommLog:(BOOL)value
10272- (void) setAutoCommLog:(BOOL)value {
…}
10284- (void) setBlockJSPlayerShipProps:(BOOL)value
10284- (void) setBlockJSPlayerShipProps:(BOOL)value {
…}
10313 initWithPixelSize:NSMakeSize(480, 160)
10322 initWithPixelSize:NSMakeSize(360, 120)
10339#if OOLITE_SPEECH_SYNTH
10340 [speechArray autorelease];
10350 [characters autorelease];
10353 [customSounds autorelease];
10356 [globalSettings autorelease];
10363 [screenBackgrounds autorelease];
10367 [roleCategories autorelease];
10370 [autoAIMap autorelease];
10373 [equipmentData autorelease];
10374 [equipmentDataOutfitting autorelease];
10381 [explosionSettings autorelease];
10391 foreach (type, [commodities goods])
10396 [
tmp setObject:container forKey:type];
10400 cargoPods = [[
NSDictionary alloc] initWithDictionary:tmp];
10407 NSMutableArray *badEntities =
nil;
10411 for (i = 0; i < n_entities; i++)
10413 entity = sortedEntities[
i];
10414 if ([entity sessionID] != _sessionID)
10416 OOLogERR(
@"universe.sessionIDs.verify.failed",
@"Invalid entity %@ (came from session %lu, current session is %lu).", [entity shortDescription], [entity sessionID], _sessionID);
10422 foreach (entity, badEntities)
10431- (BOOL) reinitAndShowDemo:(BOOL) showDemo
10435 assert(player !=
nil);
10461 [PLAYER setSpeed:0.0];
10466 [missiontext autorelease];
10472 [demo_ships release];
10491 if (![player setUpAndConfirmOK:YES])
10431- (BOOL) reinitAndShowDemo:(BOOL) showDemo {
…}
10554 activeWormholes = [[
NSMutableArray arrayWithCapacity:16] retain];
10556 characterPool = [[
NSMutableArray arrayWithCapacity:256] retain];
10573 [[
self currentSystemData] oo_boolForKey:@"stations_require_docking_clearance" defaultValue:YES]];
10587- (Vector) randomPlaceWithinScannerFrom:(Vector)pos alongRoute:(Vector)route withOffset:(
double)offset
10587- (Vector) randomPlaceWithinScannerFrom:(Vector)pos alongRoute:(Vector)route withOffset:(
double)offset {
…}
10597- (HPVector) fractionalPositionFrom:(HPVector)point0 to:(HPVector)point1 withFraction:(
double)routeFraction
10599 if (routeFraction == NSNotFound) routeFraction =
randf();
10601 point1 = OOHPVectorInterpolate(point0, point1, routeFraction);
10597- (HPVector) fractionalPositionFrom:(HPVector)point0 to:(HPVector)point1 withFraction:(
double)routeFraction {
…}
10614 if ([entity canCollide])
10616 doLinkedListMaintenanceThisUpdate = YES;
10634 if (sortedEntities[index] != entity)
10636 OOLog(
kOOLogInconsistentState,
@"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE RIGHT PLACE IN THE ZERO_DISTANCE SORTED LIST -- FIXING...", entity);
10639 for (i = 0; (i < n_entities)&&(index == -1); i++)
10640 if (sortedEntities[i] == entity)
10643 OOLog(
kOOLogInconsistentState,
@"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE ZERO_DISTANCE SORTED LIST -- CONTINUING...", entity);
10647 while ((
unsigned)index < n_entities)
10649 while (((
unsigned)index + n < n_entities)&&(sortedEntities[index + n] == entity))
10668 sortedEntities[
index] = sortedEntities[
index + n];
10669 if (sortedEntities[index])
10671 sortedEntities[
index]->zero_index = index;
10676 OOLog(
kOOLogInconsistentState,
@"DEBUG: Universe removeEntity: REMOVED %d EXTRA COPIES OF %@ FROM THE ZERO_DISTANCE SORTED LIST", n - 1, entity);
10687 if ([entities containsObject:entity])
10690 if ([entity isBreakPattern] && ![entity isVisualEffect])
10692 breakPatternCounter--;
10695 if ([entity isShip])
10700 if ([entity isWaypoint])
10705 if ([entity isVisualEffect])
10711 if ([entity isWormhole])
10715 else if ([entity isPlanet])
10730 if (![soundName hasPrefix:
@"["] && ![soundName hasSuffix:
@"]"])
10740 NSString *key =
nil;
10743 id object = [customSounds objectForKey:key];
10744 if([
object isKindOfClass:[NSString
class]])
10748 else if([
object isKindOfClass:[NSArray
class]] && [
object count] > 0)
10750 NSString *soundName =
nil;
10751 foreach (soundName,
object)
10753 if ([soundName isKindOfClass:[NSString
class]])
10768 NSAutoreleasePool *pool =
nil;
10770 while ([activeWormholes
count])
10778 if (![whole isScanned] &&
10779 NSEqualPoints([
PLAYER galaxy_coordinates], [whole destinationCoordinates]) )
10786 @catch (NSException *exception)
10788 OOLog(
kOOLogException,
@"Squashing exception during wormhole unpickling (%@: %@).", [exception name], [exception reason]);
10795- (NSString *)chooseStringForKey:(NSString *)key inDictionary:(NSDictionary *)dictionary
10798 if ([
object isKindOfClass:[NSString
class]])
return object;
10799 else if ([
object isKindOfClass:[NSArray
class]] && [
object count] > 0)
return [
object oo_stringAtIndex:Ranrot() % [
object count]];
10795- (NSString *)chooseStringForKey:(NSString *)key inDictionary:(NSDictionary *)dictionary {
…}
10804#if OO_LOCALIZATION_TOOLS
10807- (void) dumpDebugGraphViz
10809 if ([[NSUserDefaults standardUserDefaults] boolForKey:
@"universe-dump-debug-graphviz"])
10811 [
self dumpSystemDescriptionGraphViz];
10816- (void) dumpSystemDescriptionGraphViz
10818 NSMutableString *graphViz =
nil;
10819 NSArray *systemDescriptions =
nil;
10820 NSArray *thisDesc =
nil;
10821 NSUInteger i,
count, j, subCount;
10822 NSString *descLine =
nil;
10823 NSArray *curses =
nil;
10824 NSString *label =
nil;
10825 NSDictionary *keyMap =
nil;
10831 graphViz = [NSMutableString stringWithString:
10832 @"// System description grammar:\n\n"
10833 "digraph system_descriptions\n"
10835 "\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"
10836 "\tedge [arrowhead=dot]\n"
10837 "\tnode [shape=none height=0.2 width=3 fontname=Helvetica]\n\t\n"];
10839 systemDescriptions = [[
self descriptions] oo_arrayForKey:@"system_description"];
10840 count = [systemDescriptions count];
10843 descLine =
DESC(
@"system-description-string");
10845 [graphViz appendFormat:@"\tsystem_description_string [label=\"%@\" shape=ellipse]\n", EscapedGraphVizString(label)];
10846 [
self addNumericRefsInString:descLine
10847 toGraphViz:graphViz
10848 fromNode:@"system_description_string"
10850 [graphViz appendString:@"\t\n"];
10853 [graphViz appendString:
10854 @"\tpercent_I [label=\"%I\\nInhabitants\" shape=diamond]\n"
10855 "\tpercent_H [label=\"%H\\nSystem name\" shape=diamond]\n"
10856 "\tpercent_RN [label=\"%R/%N\\nRandom name\" shape=diamond]\n"
10857 "\tpercent_J [label=\"%J\\nNumbered system name\" shape=diamond]\n"
10858 "\tpercent_G [label=\"%G\\nNumbered system name in chart number\" shape=diamond]\n\t\n"];
10861 [graphViz appendString:@"\tsubgraph cluster_thargoid_curses\n\t{\n\t\tlabel = \"Thargoid curses\"\n"];
10862 curses = [[
self descriptions] oo_arrayForKey:@"thargoid_curses"];
10863 subCount = [curses count];
10864 for (j = 0; j < subCount; ++j)
10867 [graphViz appendFormat:@"\t\tthargoid_curse_%lu [label=\"%@\"]\n", j, EscapedGraphVizString(label)];
10869 [graphViz appendString:@"\t}\n"];
10870 for (j = 0; j < subCount; ++j)
10872 [
self addNumericRefsInString:[curses oo_stringAtIndex:j]
10873 toGraphViz:graphViz
10874 fromNode:[NSString stringWithFormat:@"thargoid_curse_%lu", j]
10877 [graphViz appendString:@"\t\n"];
10881 for (i = 0; i <
count; ++i)
10884 label = [keyMap objectForKey:[NSString stringWithFormat:@"%lu", i]];
10885 if (label ==
nil) label = [NSString stringWithFormat:
@"[%lu]", i];
10886 else label = [NSString stringWithFormat:@"[%lu] (%@)", i, label];
10888 [graphViz appendFormat:@"\tsubgraph cluster_%lu\n\t{\n\t\tlabel=\"%@\"\n", i, EscapedGraphVizString(label)];
10890 thisDesc = [systemDescriptions oo_arrayAtIndex:i];
10891 subCount = [thisDesc count];
10892 for (j = 0; j < subCount; ++j)
10895 [graphViz appendFormat:@"\t\tn%lu_%lu [label=\"\\\"%@\\\"\"]\n", i, j, EscapedGraphVizString(label)];
10898 [graphViz appendString:@"\t}\n"];
10900 [graphViz appendString:@"\t\n"];
10903 for (i = 0; i !=
count; ++i)
10905 thisDesc = [systemDescriptions oo_arrayAtIndex:i];
10906 subCount = [thisDesc count];
10907 for (j = 0; j != subCount; ++j)
10909 descLine = [thisDesc oo_stringAtIndex:j];
10910 [
self addNumericRefsInString:descLine
10911 toGraphViz:graphViz
10912 fromNode:[NSString stringWithFormat:@"n%lu_%lu", i, j]
10918 [graphViz appendString:@"\t}\n"];
10924- (void) addNumericRefsInString:(NSString *)string toGraphViz:(NSMutableString *)graphViz fromNode:(NSString *)fromNode nodeCount:(NSUInteger)nodeCount
10926 NSString *index =
nil;
10927 NSInteger start, end;
10928 NSRange remaining, subRange;
10931 remaining = NSMakeRange(0, [
string length]);
10935 subRange = [
string rangeOfString:@"[" options:NSLiteralSearch range:remaining];
10936 if (subRange.location == NSNotFound)
break;
10937 start = subRange.location + subRange.length;
10938 remaining.length -= start - remaining.location;
10939 remaining.location = start;
10941 subRange = [
string rangeOfString:@"]" options:NSLiteralSearch range:remaining];
10942 if (subRange.location == NSNotFound)
break;
10943 end = subRange.location;
10944 remaining.length -= end - remaining.location;
10945 remaining.location = end;
10947 index = [
string substringWithRange:NSMakeRange(start, end - start)];
10948 i = [
index intValue];
10951 [
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];
10954 if ([
string rangeOfString:
@"%I"].location != NSNotFound)
10956 [
graphViz appendFormat:@"\t%@ -> percent_I [color=\"0,0,0.25\"]\n", fromNode];
10958 if ([
string rangeOfString:
@"%H"].location != NSNotFound)
10960 [
graphViz appendFormat:@"\t%@ -> percent_H [color=\"0,0,0.45\"]\n", fromNode];
10962 if ([
string rangeOfString:
@"%R"].location != NSNotFound || [
string rangeOfString:
@"%N"].location != NSNotFound)
10964 [
graphViz appendFormat:@"\t%@ -> percent_RN [color=\"0,0,0.65\"]\n", fromNode];
10968 if ([
string rangeOfString:
@"%J"].location != NSNotFound)
10970 [
graphViz appendFormat:@"\t%@ -> percent_J [color=\"0,0,0.75\"]\n", fromNode];
10973 if ([
string rangeOfString:
@"%G"].location != NSNotFound)
10975 [
graphViz appendFormat:@"\t%@ -> percent_G [color=\"0,0,0.85\"]\n", fromNode];
10924- (void) addNumericRefsInString:(NSString *)string toGraphViz:(NSMutableString *)graphViz fromNode:(NSString *)fromNode nodeCount:(NSUInteger)nodeCount {
…}
10983 NSArray *arguments =
nil;
10984 NSEnumerator *argEnum =
nil;
10985 NSString *arg =
nil;
10986 BOOL compileSysDesc = NO, exportSysDesc = NO, xml = NO;
10990 for (argEnum = [arguments objectEnumerator]; (arg = [
argEnum nextObject]); )
10992 if ([arg isEqual:
@"--compile-sysdesc"]) compileSysDesc = YES;
10993 else if ([arg isEqual:
@"--export-sysdesc"]) exportSysDesc = YES;
10994 else if ([arg isEqual:
@"--xml"]) xml = YES;
10995 else if ([arg isEqual:
@"--openstep"]) xml = NO;
11006- (void) prunePreloadingPlanetMaterials
11010 NSUInteger i = [_preloadingPlanetMaterials count];
11013 if ([[_preloadingPlanetMaterials objectAtIndex:i] isFinishedLoading])
11015 [_preloadingPlanetMaterials removeObjectAtIndex:i];
11025 [conditionScripts autorelease];
11036- (void) addConditionScripts:(NSEnumerator *)scripts
11038 NSString *scriptname =
nil;
11039 while ((scriptname = [scripts nextObject]))
11046 [conditionScripts setObject:script forKey:scriptname];
11036- (void) addConditionScripts:(NSEnumerator *)scripts {
…}
11055 return [conditionScripts objectForKey:scriptname];
11061@implementation OOSound (OOCustomSounds)
11063+ (id) soundWithCustomSoundKey:(NSString *)key
11065 NSString *fileName = [UNIVERSE soundNameForCustomSoundKey:key];
11066 if (fileName ==
nil)
return nil;
11063+ (id) soundWithCustomSoundKey:(NSString *)key {
…}
11071- (id) initWithCustomSoundKey:(NSString *)key
11071- (id) initWithCustomSoundKey:(NSString *)key {
…}
11080@implementation OOSoundSource (OOCustomSounds)
11082+ (id) sourceWithCustomSoundKey:(NSString *)key
11084 return [[[
self alloc] initWithCustomSoundKey:key] autorelease];
11082+ (id) sourceWithCustomSoundKey:(NSString *)key {
…}
11088- (id) initWithCustomSoundKey:(NSString *)key
11091 if (theSound !=
nil)
11088- (id) initWithCustomSoundKey:(NSString *)key {
…}
11104- (void) playCustomSoundWithKey:(NSString *)key
11104- (void) playCustomSoundWithKey:(NSString *)key {
…}
11114 NSDictionary *one = (NSDictionary *)a;
11115 NSDictionary *two = (NSDictionary *)b;
11116 int pri_one = [one oo_intForKey:@"priority" defaultValue:100];
11117 int pri_two = [two oo_intForKey:@"priority" defaultValue:100];
11118 if (pri_one < pri_two)
return NSOrderedAscending;
11119 if (pri_one > pri_two)
return NSOrderedDescending;
11120 return NSOrderedSame;
11126 NSArray *one = (NSArray *)a;
11127 NSArray *two = (NSArray *)b;
11131 OOCreditsQuantity comp1 = [[one oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
11132 OOCreditsQuantity comp2 = [[two oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
11133 if (comp1 < comp2)
return NSOrderedAscending;
11134 if (comp1 > comp2)
return NSOrderedDescending;
11136 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11137 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11138 if (comp1 < comp2)
return NSOrderedAscending;
11139 if (comp1 > comp2)
return NSOrderedDescending;
11141 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11142 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11143 if (comp1 < comp2)
return NSOrderedAscending;
11144 if (comp1 > comp2)
return NSOrderedDescending;
11146 return NSOrderedSame;
11152 NSArray *one = (NSArray *)a;
11153 NSArray *two = (NSArray *)b;
11157 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]];
11158 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]];
11159 if (comp1 < comp2)
return NSOrderedAscending;
11160 if (comp1 > comp2)
return NSOrderedDescending;
11162 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11163 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11164 if (comp1 < comp2)
return NSOrderedAscending;
11165 if (comp1 > comp2)
return NSOrderedDescending;
11167 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11168 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11169 if (comp1 < comp2)
return NSOrderedAscending;
11170 if (comp1 > comp2)
return NSOrderedDescending;
11172 return NSOrderedSame;
11178 NSString *result = [UNIVERSE descriptionForKey:key];
11179 if (result ==
nil) result = key;
11187 NSArray *conditions = [[UNIVERSE descriptions] oo_arrayForKey:@"plural-rules"];
11190 NSString *tmp = [UNIVERSE descriptionForKey:key];
11193 static NSMutableSet *warned =
nil;
11195 if (![warned containsObject:tmp])
11197 OOLogWARN(
@"localization.plurals",
@"'%@' found in descriptions.plist, should be '%@%%0'. Localization data needs updating.",key,key);
11198 if (warned ==
nil) warned = [[NSMutableSet alloc] init];
11199 [warned addObject:tmp];
11203 if (conditions ==
nil)
11213 for (index = i = 0; i < [conditions count]; ++index, ++i)
11215 const char *cond = [[conditions oo_stringAtIndex:i] UTF8String];
11219 long int input =
count;
11222 while (isspace (*cond))
11227 while (isspace (*cond))
11230 char command = *cond++;
11242 long int param = strtol(cond, (
char **)&cond, 10);
11257 if (flag ^ (input == param))
11261 if (flag ^ (input != param))
11266 if (flag ^ (input < param))
11270 if (flag ^ (input > param))
#define INTERMEDIATE_CLEAR_DEPTH
#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 BREAK_PATTERN_RING_SPEED
#define BREAK_PATTERN_RING_SPACING
@ kOOBreakPatternMaxSides
NSInteger OOComparisonResult
#define foreachkey(VAR, DICT)
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)
void OOInitDebugSupport(void)
BOOL IsShipPredicate(Entity *entity, void *parameter)
BOOL IsVisualEffectPredicate(Entity *entity, void *parameter)
BOOL YESPredicate(Entity *entity, void *parameter)
HPVector OOHPVectorRandomRadial(OOHPScalar maxLength)
HPVector OOProjectHPVectorToPlane(HPVector point, HPVector plane, HPVector normal)
HPVector OORandomPositionInShell(HPVector centre, OOHPScalar inner, OOHPScalar outer)
const HPVector kZeroHPVector
HPVector OOHPVectorRandomSpatial(OOHPScalar maxLength)
const HPVector kBasisZHPVector
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 OOJSValueFromNativeObject(JSContext *context, id object)
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)
OOMatrix OOMatrixMultiply(OOMatrix a, OOMatrix b)
const OOMatrix kIdentityMatrix
Vector OOVectorMultiplyMatrix(Vector v, OOMatrix m)
@ 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 OOVerifyOpenGLState()
BOOL OOCheckOpenGLErrors(NSString *format,...)
void GLScaledLineWidth(GLfloat width)
#define OOSetOpenGLState(STATE)
Vector vector_forward_from_quaternion(Quaternion quat)
void basis_vectors_from_quaternion(Quaternion quat, Vector *outRight, Vector *outUp, Vector *outForward)
void quaternion_set_random(Quaternion *quat)
const Quaternion kIdentityQuaternion
Quaternion quaternion_rotation_between(Vector v0, Vector v1)
void quaternion_rotate_about_y(Quaternion *quat, OOScalar angle)
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle)
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
const Vector kBasisYVector
const Vector kBasisZVector
const Vector kBasisXVector
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 setScanClass:(OOScanClass sClass)
Vector cameraRelativePosition
void setPositionX:y:z:(OOHPScalar x,[y] OOHPScalar y,[z] OOHPScalar z)
HPVector absolutePositionForSubentityOffset:(HPVector offset)
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 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)
void setGammaValue:(float value)
float fov:(BOOL inFraction)
void setMsaa:(BOOL newMsaa)
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)
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()
BOOL doWorldEventUntilMissionScreen:(jsid message)
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 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)
void doScriptEvent:(jsid message)
NSArray * portWeaponOffset
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 setCrew:(NSArray *crewArray)
void setDemoShip:(OOScalar demoRate)
void doScriptEvent:withArgument:(jsid message,[withArgument] id argument)
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)
NSSpeechSynthesizer * speechSynthesizer
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()
void allShipsDoScriptEvent:andReactToAIMessage:(jsid event,[andReactToAIMessage] NSString *message)
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)
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)
double timeAccelerationFactor
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)
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)
NSString * keyForInterstellarOverridesForSystems:s1:inGalaxy:(OOSystemID,[s1] OOSystemID s2,[inGalaxy] OOGalaxyID g)
GameController * gameController()
NSDictionary * generateSystemData:(OOSystemID s)
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