Oolite 1.91.0.7677-250528-09ed63a
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Universe(OOPrivate) Category Reference

Instance Methods

(void) - initTargetFramebufferWithViewSize:
(void) - deleteOpenGLObjects
(void) - resizeTargetFramebufferWithViewSize:
(void) - prepareToRenderIntoDefaultFramebuffer
(void) - drawTargetTextureIntoDefaultFramebuffer
(BOOL) - doRemoveEntity:
(void) - setUpCargoPods
(void) - setUpInitialUniverse
(HPVector) - fractionalPositionFrom:to:withFraction:
(void) - populateSpaceFromActiveWormholes
(NSString *) - chooseStringForKey:inDictionary:
(void) - addNumericRefsInString:toGraphViz:fromNode:nodeCount:
(void) - runLocalizationTools
(void) - setShaderEffectsLevelDirectly:
(void) - setFirstBeacon:
(void) - setLastBeacon:
(void) - verifyDescriptions
(void) - loadDescriptions
(void) - loadScenarios
(void) - verifyEntitySessionIDs
(float) - randomDistanceWithinScanner
(Vector) - randomPlaceWithinScannerFrom:alongRoute:withOffset:
(void) - setDetailLevelDirectly:
(NSDictionary *) - demoShipData
(void) - setLibraryTextForDemoShip

Detailed Description

Definition at line 201 of file Universe.m.

Method Documentation

◆ addNumericRefsInString:toGraphViz:fromNode:nodeCount:

- (void) addNumericRefsInString: (NSString *) string
toGraphViz: (NSMutableString *) graphViz
fromNode: (NSString *) fromNode
nodeCount: (NSUInteger) nodeCount 

Extends class Universe.

Definition at line 10924 of file Universe.m.

10924 :(NSString *)string toGraphViz:(NSMutableString *)graphViz fromNode:(NSString *)fromNode nodeCount:(NSUInteger)nodeCount
10925{
10926 NSString *index = nil;
10927 NSInteger start, end;
10928 NSRange remaining, subRange;
10929 unsigned i;
10930
10931 remaining = NSMakeRange(0, [string length]);
10932
10933 for (;;)
10934 {
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;
10940
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;
10946
10947 index = [string substringWithRange:NSMakeRange(start, end - start)];
10948 i = [index intValue];
10949
10950 // Each node gets a colour for its incoming edges. The multiplication and mod shuffle them to avoid adjacent nodes having similar colours.
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];
10952 }
10953
10954 if ([string rangeOfString:@"%I"].location != NSNotFound)
10955 {
10956 [graphViz appendFormat:@"\t%@ -> percent_I [color=\"0,0,0.25\"]\n", fromNode];
10957 }
10958 if ([string rangeOfString:@"%H"].location != NSNotFound)
10959 {
10960 [graphViz appendFormat:@"\t%@ -> percent_H [color=\"0,0,0.45\"]\n", fromNode];
10961 }
10962 if ([string rangeOfString:@"%R"].location != NSNotFound || [string rangeOfString:@"%N"].location != NSNotFound)
10963 {
10964 [graphViz appendFormat:@"\t%@ -> percent_RN [color=\"0,0,0.65\"]\n", fromNode];
10965 }
10966
10967 // TODO: test graphViz output for @"%Jxxx" and @"%Gxxxxxx"
10968 if ([string rangeOfString:@"%J"].location != NSNotFound)
10969 {
10970 [graphViz appendFormat:@"\t%@ -> percent_J [color=\"0,0,0.75\"]\n", fromNode];
10971 }
10972
10973 if ([string rangeOfString:@"%G"].location != NSNotFound)
10974 {
10975 [graphViz appendFormat:@"\t%@ -> percent_G [color=\"0,0,0.85\"]\n", fromNode];
10976 }
10977}
return nil

References nil.

◆ chooseStringForKey:inDictionary:

- (NSString *) chooseStringForKey: (NSString *) key
inDictionary: (NSDictionary *) dictionary 

Extends class Universe.

Definition at line 10795 of file Universe.m.

10795 :(NSString *)key inDictionary:(NSDictionary *)dictionary
10796{
10797 id object = [dictionary objectForKey:key];
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]];
10800 return nil;
10801}
unsigned count
unsigned Ranrot(void)

References count, and nil.

Referenced by Universe::descriptionForKey:.

Here is the caller graph for this function:

◆ deleteOpenGLObjects

- (void) deleteOpenGLObjects

Extends class Universe.

Definition at line 532 of file Universe.m.

533{
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));
547 [textureProgram release];
548 [blurProgram release];
549 [finalProgram release];
550}
#define OOGL(statement)
Definition OOOpenGL.h:251

References deleteOpenGLObjects, and OOGL.

Referenced by Universe::dealloc, and deleteOpenGLObjects.

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

◆ demoShipData

- (NSDictionary *) demoShipData

Extends class Universe.

Definition at line 3302 of file Universe.m.

3303{
3304 return [[demo_ships oo_arrayAtIndex:demo_ship_index] oo_dictionaryAtIndex:demo_ship_subindex];
3305}

References demoShipData.

Referenced by demoShipData, setLibraryTextForDemoShip, setShaderEffectsLevelDirectly:, and Universe::update:.

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

◆ doRemoveEntity:

- (BOOL) doRemoveEntity: (Entity *) entity

Extends class Universe.

Definition at line 10611 of file Universe.m.

10611 :(Entity *)entity
10612{
10613 // remove reference to entity in linked lists
10614 if ([entity canCollide]) // filter only collidables disappearing
10615 {
10616 doLinkedListMaintenanceThisUpdate = YES;
10617 }
10618
10619 [entity removeFromLinkedLists];
10620
10621 // moved forward ^^
10622 // remove from the reference dictionary
10623 int old_id = [entity universalID];
10624 entity_for_uid[old_id] = nil;
10625 [entity setUniversalID:NO_TARGET];
10626 [entity wasRemovedFromUniverse];
10627
10628 // maintain sorted lists
10629 int index = entity->zero_index;
10630
10631 int n = 1;
10632 if (index >= 0)
10633 {
10634 if (sortedEntities[index] != entity)
10635 {
10636 OOLog(kOOLogInconsistentState, @"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE RIGHT PLACE IN THE ZERO_DISTANCE SORTED LIST -- FIXING...", entity);
10637 unsigned i;
10638 index = -1;
10639 for (i = 0; (i < n_entities)&&(index == -1); i++)
10640 if (sortedEntities[i] == entity)
10641 index = i;
10642 if (index == -1)
10643 OOLog(kOOLogInconsistentState, @"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE ZERO_DISTANCE SORTED LIST -- CONTINUING...", entity);
10644 }
10645 if (index != -1)
10646 {
10647 while ((unsigned)index < n_entities)
10648 {
10649 while (((unsigned)index + n < n_entities)&&(sortedEntities[index + n] == entity))
10650 {
10651 n++; // ie there's a duplicate entry for this entity
10652 }
10653
10654 /*
10655 BUG: when n_entities == UNIVERSE_MAX_ENTITIES, this read
10656 off the end of the array and copied (Entity *)n_entities =
10657 0x800 into the list. The subsequent update of zero_index
10658 derferenced 0x800 and crashed.
10659 FIX: add an extra unused slot to sortedEntities, which is
10660 always nil.
10661 EFFICIENCY CONCERNS: this could have been an alignment
10662 issue since UNIVERSE_MAX_ENTITIES == 2048, but it isn't
10663 really. sortedEntities is part of the object, not malloced,
10664 it isn't aligned, and the end of it is only live in
10665 degenerate cases.
10666 -- Ahruman 2012-07-11
10667 */
10668 sortedEntities[index] = sortedEntities[index + n]; // copy entity[index + n] -> entity[index] (preserves sort order)
10669 if (sortedEntities[index])
10670 {
10671 sortedEntities[index]->zero_index = index; // give it its correct position
10672 }
10673 index++;
10674 }
10675 if (n > 1)
10676 OOLog(kOOLogInconsistentState, @"DEBUG: Universe removeEntity: REMOVED %d EXTRA COPIES OF %@ FROM THE ZERO_DISTANCE SORTED LIST", n - 1, entity);
10677 while (n--)
10678 {
10679 n_entities--;
10680 sortedEntities[n_entities] = nil;
10681 }
10682 }
10683 entity->zero_index = -1; // it's GONE!
10684 }
10685
10686 // remove from the definitive list
10687 if ([entities containsObject:entity])
10688 {
10689 // FIXME: better approach needed for core break patterns - CIM
10690 if ([entity isBreakPattern] && ![entity isVisualEffect])
10691 {
10692 breakPatternCounter--;
10693 }
10694
10695 if ([entity isShip])
10696 {
10697 ShipEntity *se = (ShipEntity*)entity;
10698 [self clearBeacon:se];
10699 }
10700 if ([entity isWaypoint])
10701 {
10702 OOWaypointEntity *wp = (OOWaypointEntity*)entity;
10703 [self clearBeacon:wp];
10704 }
10705 if ([entity isVisualEffect])
10706 {
10707 OOVisualEffectEntity *ve = (OOVisualEffectEntity*)entity;
10708 [self clearBeacon:ve];
10709 }
10710
10711 if ([entity isWormhole])
10712 {
10713 [activeWormholes removeObject:entity];
10714 }
10715 else if ([entity isPlanet])
10716 {
10717 [allPlanets removeObject:entity];
10718 }
10719
10720 [entities removeObject:entity];
10721 return YES;
10722 }
10723
10724 return NO;
10725}
NSString *const kOOLogInconsistentState
Definition OOLogging.m:650
#define OOLog(class, format,...)
Definition OOLogging.h:88
void removeFromLinkedLists()
Definition Entity.m:286
void setUniversalID:(OOUniversalID uid)
Definition Entity.m:546
OOUniversalID universalID
Definition Entity.m:552
int zero_index
Definition Entity.h:117
void wasRemovedFromUniverse()
Definition Entity.m:520

References Universe::clearBeacon:, kOOLogInconsistentState, nil, OOLog, Entity::removeFromLinkedLists, Entity::setUniversalID:, Entity::universalID, Entity::wasRemovedFromUniverse, and Entity::zero_index.

Referenced by Universe::ensureEntityReallyRemoved:, and Universe::removeEntity:.

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

◆ drawTargetTextureIntoDefaultFramebuffer

- (void) drawTargetTextureIntoDefaultFramebuffer

Extends class Universe.

Definition at line 595 of file Universe.m.

596{
597 // save previous bindings state
598 GLint previousFBO;
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));
604 GLint previousVAO;
605 OOGL(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &previousVAO));
606 GLint previousActiveTexture;
607 OOGL(glGetIntegerv(GL_ACTIVE_TEXTURE, &previousActiveTexture));
608
609 OOGL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
610 // fixes transparency issue for some reason
611 OOGL(glDisable(GL_BLEND));
612
613 GLhandleARB program = [textureProgram program];
614 GLhandleARB blur = [blurProgram program];
615 GLhandleARB final = [finalProgram program];
616 NSSize viewSize = [gameView viewSize];
617 float fboResolution[2] = {viewSize.width, viewSize.height};
618
619 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, passthroughFramebufferID));
620 OOGL(glClear(GL_COLOR_BUFFER_BIT));
621
622 OOGL(glUseProgram(program));
623 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
624 OOGL(glUniform1i(glGetUniformLocation(program, "image"), 0));
625
626
627 OOGL(glBindVertexArray(quadTextureVAO));
628 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
629 OOGL(glBindVertexArray(0));
630
631 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
632
633
634 BOOL horizontal = YES, firstIteration = YES;
635 unsigned int amount = [self bloom] ? 10 : 0; // if not blooming, why bother with the heavy calculations?
636 OOGL(glUseProgram(blur));
637 for (unsigned int i = 0; i < amount; i++)
638 {
639 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]));
640 OOGL(glUniform1i(glGetUniformLocation(blur, "horizontal"), horizontal));
641 OOGL(glActiveTexture(GL_TEXTURE0));
642 // bind texture of other framebuffer (or scene if first iteration)
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;
649 firstIteration = NO;
650 }
651 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
652
653
654 OOGL(glUseProgram(final));
655
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]));
663#if OOLITE_WINDOWS
664 if([gameView hdrOutput])
665 {
666 OOGL(glUniform1f(glGetUniformLocation(final, "uMaxBrightness"), [gameView hdrMaxBrightness]));
667 OOGL(glUniform1f(glGetUniformLocation(final, "uPaperWhiteBrightness"), [gameView hdrPaperWhiteBrightness]));
668 }
669#endif
670
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]));
675
676 OOGL(glBindVertexArray(quadTextureVAO));
677 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
678
679 // restore GL_TEXTURE1 to 0, just in case we are returning from a
680 // DETAIL_LEVEL_NORMAL to DETAIL_LEVEL_SHADERS
681 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
682
683 // restore previous bindings
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));
690}

References Universe::bloom, drawTargetTextureIntoDefaultFramebuffer, and OOGL.

Referenced by drawTargetTextureIntoDefaultFramebuffer, and Universe::drawUniverse.

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

◆ fractionalPositionFrom:to:withFraction:

- (HPVector) fractionalPositionFrom: (HPVector) point0
to: (HPVector) point1
withFraction: (double) routeFraction 

Extends class Universe.

Definition at line 10597 of file Universe.m.

10597 :(HPVector)point0 to:(HPVector)point1 withFraction:(double)routeFraction
10598{
10599 if (routeFraction == NSNotFound) routeFraction = randf();
10600
10601 point1 = OOHPVectorInterpolate(point0, point1, routeFraction);
10602
10603 point1.x += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10604 point1.y += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10605 point1.z += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10606
10607 return point1;
10608}
#define SCANNER_MAX_RANGE
Definition Entity.h:51
float randf(void)

References randf(), and SCANNER_MAX_RANGE.

Referenced by Universe::addShipsToRoute:withRole:quantity:routeFraction:asGroup:.

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

◆ initTargetFramebufferWithViewSize:

- (void) initTargetFramebufferWithViewSize: (NSSize) viewSize

Extends class Universe.

Definition at line 342 of file Universe.m.

342 :(NSSize)viewSize
343{
344 // liberate us from the 0.0 to 1.0 rgb range!
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));
348
349 // have to do this because on my machine the default framebuffer is not zero
350 OOGL(glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &defaultDrawFBO));
351
352 GLint previousProgramID;
353 OOGL(glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgramID));
354 GLint previousTextureID;
355 OOGL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureID));
356 GLint previousVAO;
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));
362
363 // create MSAA framebuffer and attach MSAA texture and depth buffer to framebuffer
364 OOGL(glGenFramebuffers(1, &msaaFramebufferID));
365 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, msaaFramebufferID));
366
367 // creating MSAA texture that should be rendered into
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));
373
374 // create necessary MSAA depth render buffer
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));
380
381 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
382 {
383 OOLogERR(@"initTargetFramebufferWithViewSize.result", @"%@", @"***** Error: Multisample framebuffer not complete");
384 }
385
386 // create framebuffer and attach texture and depth buffer to framebuffer
387 OOGL(glGenFramebuffers(1, &targetFramebufferID));
388 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, targetFramebufferID));
389
390 // creating texture that should be rendered into
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));
396 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
397 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
398 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTextureID, 0));
399
400 // create necessary depth render buffer
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));
405
406 GLenum attachment[1] = { GL_COLOR_ATTACHMENT0 };
407 OOGL(glDrawBuffers(1, attachment));
408
409 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
410 {
411 OOLogERR(@"initTargetFramebufferWithViewSize.result", @"%@", @"***** Error: Framebuffer not complete");
412 }
413
414 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
415
416 targetFramebufferSize = viewSize;
417
418 // passthrough buffer
419 // This is a framebuffer whose sole purpose is to pass on the texture rendered from the game to the blur and the final bloom
420 // shaders. We need it in order to be able to use the OpenGL 3.3 layout (location = x) out vec4 outVector; construct, which allows
421 // us to perform multiple render target operations needed for bloom. The alternative would be to not use this and change all our
422 // shaders to be OpenGL 3.3 compatible, but given how Oolite synthesizes them and the work needed to port them over, well yeah no,
423 // not doing it at this time - Nikos 20220814.
424 OOGL(glGenFramebuffers(1, &passthroughFramebufferID));
425 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, passthroughFramebufferID));
426
427 // creating textures that should be rendered into
428 OOGL(glGenTextures(2, passthroughTextureID));
429 for (unsigned int i = 0; i < 2; i++)
430 {
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));
435 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
436 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
437 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, passthroughTextureID[i], 0));
438 }
439
440 GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
441 OOGL(glDrawBuffers(2, attachments));
442
443 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
444 {
445 OOLogERR(@"initTargetFramebufferWithViewSize.result", @"%@", @"***** Error: Passthrough framebuffer not complete");
446 }
447 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
448
449 // ping-pong-framebuffer for blurring
450 OOGL(glGenFramebuffers(2, pingpongFBO));
451 OOGL(glGenTextures(2, pingpongColorbuffers));
452 for (unsigned int i = 0; i < 2; i++)
453 {
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));
459 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); // we clamp to the edge as the blur filter would otherwise sample repeated texture values!
460 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
461 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongColorbuffers[i], 0));
462 // check if framebuffers are complete (no need for depth buffer)
463 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
464 {
465 OOLogERR(@"initTargetFramebufferWithViewSize.result", @"%@", @"***** Error: Pingpong framebuffers not complete");
466 }
467 }
468 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
469
470 _bloom = [self detailLevel] >= DETAIL_LEVEL_EXTRAS;
471 _currentPostFX = _colorblindMode = OO_POSTFX_NONE;
472
473 /* TODO: in OOEnvironmentCubeMap.m call these bind functions not with 0 but with "previousXxxID"s:
474 - OOGL(glBindTexture(GL_TEXTURE_CUBE_MAP, 0));
475 - OOGL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
476 - OOGL(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0));
477 */
478
479 // shader for drawing a textured quad on the passthrough framebuffer and preparing it for bloom using MRT
480 if (![[OOOpenGLExtensionManager sharedManager] shadersForceDisabled])
481 {
482 textureProgram = [[OOShaderProgram shaderProgramWithVertexShaderName:@"oolite-texture.vertex"
483 fragmentShaderName:@"oolite-texture.fragment"
484 prefix:@"#version 330\n"
485 attributeBindings:[NSDictionary dictionary]] retain];
486 // shader for blurring the over-threshold brightness image generated from the previous step using Gaussian filter
487 blurProgram = [[OOShaderProgram shaderProgramWithVertexShaderName:@"oolite-blur.vertex"
488 fragmentShaderName:@"oolite-blur.fragment"
489 prefix:@"#version 330\n"
490 attributeBindings:[NSDictionary dictionary]] retain];
491 // shader for applying bloom and any necessary post-proc fx, tonemapping and gamma correction
492 finalProgram = [[OOShaderProgram shaderProgramWithVertexShaderName:@"oolite-final.vertex"
493#if OOLITE_WINDOWS
494 fragmentShaderName:[[UNIVERSE gameView] hdrOutput] ? @"oolite-final-hdr.fragment" : @"oolite-final.fragment"
495#else
496 fragmentShaderName:@"oolite-final.fragment"
497#endif
498 prefix:@"#version 330\n"
499 attributeBindings:[NSDictionary dictionary]] retain];
500 }
501
502 OOGL(glGenVertexArrays(1, &quadTextureVAO));
503 OOGL(glGenBuffers(1, &quadTextureVBO));
504 OOGL(glGenBuffers(1, &quadTextureEBO));
505
506 OOGL(glBindVertexArray(quadTextureVAO));
507
508 OOGL(glBindBuffer(GL_ARRAY_BUFFER, quadTextureVBO));
509 OOGL(glBufferData(GL_ARRAY_BUFFER, sizeof(framebufferQuadVertices), framebufferQuadVertices, GL_STATIC_DRAW));
510
511 OOGL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quadTextureEBO));
512 OOGL(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(framebufferQuadIndices), framebufferQuadIndices, GL_STATIC_DRAW));
513
514 OOGL(glEnableVertexAttribArray(0));
515 // position attribute
516 OOGL(glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0));
517 OOGL(glEnableVertexAttribArray(1));
518 // texture coord attribute
519 OOGL(glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float))));
520
521
522 // restoring previous bindings
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));
528
529}
#define OOLogERR(class, format,...)
Definition OOLogging.h:112
#define GL_CLAMP_TO_EDGE
@ DETAIL_LEVEL_EXTRAS
Definition OOTypes.h:247
@ OO_POSTFX_NONE
Definition Universe.h:90
const GLfloat framebufferQuadVertices[]
Definition Universe.m:129
const GLuint framebufferQuadIndices[]
Definition Universe.m:136

References DETAIL_LEVEL_EXTRAS, Universe::detailLevel, framebufferQuadIndices, framebufferQuadVertices, GL_CLAMP_TO_EDGE, OO_POSTFX_NONE, OOGL, and OOLogERR.

Referenced by Universe::initWithGameView:.

Here is the caller graph for this function:

◆ loadDescriptions

- (void) loadDescriptions

Extends class Universe.

Definition at line 8074 of file Universe.m.

8075{
8076 [_descriptions autorelease];
8077 _descriptions = [[ResourceManager dictionaryFromFilesNamed:@"descriptions.plist" inFolder:@"Config" andMerge:YES] retain];
8078 [self verifyDescriptions];
8079}
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

References ResourceManager::dictionaryFromFilesNamed:inFolder:andMerge:, loadDescriptions, and Universe::verifyDescriptions.

Referenced by Universe::initWithGameView:, loadDescriptions, Universe::reinitAndShowDemo:, setShaderEffectsLevelDirectly:, and Universe::setUpSettings.

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

◆ loadScenarios

- (void) loadScenarios

Extends class Universe.

Definition at line 8094 of file Universe.m.

8095{
8096 [_scenarios autorelease];
8097 _scenarios = [[ResourceManager arrayFromFilesNamed:@"scenarios.plist" inFolder:@"Config" andMerge:YES] retain];
8098}
NSArray * arrayFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

References ResourceManager::arrayFromFilesNamed:inFolder:andMerge:, and loadScenarios.

Referenced by Universe::initWithGameView:, loadScenarios, Universe::reinitAndShowDemo:, and setShaderEffectsLevelDirectly:.

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

◆ populateSpaceFromActiveWormholes

- (void) populateSpaceFromActiveWormholes

Extends class Universe.

Definition at line 10766 of file Universe.m.

10767{
10768 NSAutoreleasePool *pool = nil;
10769
10770 while ([activeWormholes count])
10771 {
10772 pool = [[NSAutoreleasePool alloc] init];
10773 @try
10774 {
10775 WormholeEntity* whole = [activeWormholes objectAtIndex:0];
10776 // If the wormhole has been scanned by the player then the
10777 // PlayerEntity will take care of it
10778 if (![whole isScanned] &&
10779 NSEqualPoints([PLAYER galaxy_coordinates], [whole destinationCoordinates]) )
10780 {
10781 // this is a wormhole to this system
10782 [whole disgorgeShips];
10783 }
10784 [activeWormholes removeObjectAtIndex:0]; // empty it out
10785 }
10786 @catch (NSException *exception)
10787 {
10788 OOLog(kOOLogException, @"Squashing exception during wormhole unpickling (%@: %@).", [exception name], [exception reason]);
10789 }
10790 [pool release];
10791 }
10792}
NSString *const kOOLogException
Definition OOLogging.m:651
#define PLAYER

References count, WormholeEntity::disgorgeShips, kOOLogException, nil, OOLog, PLAYER, and populateSpaceFromActiveWormholes.

Referenced by populateSpaceFromActiveWormholes, and Universe::setUpSpace.

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

◆ prepareToRenderIntoDefaultFramebuffer

- (void) prepareToRenderIntoDefaultFramebuffer

Extends class Universe.

Definition at line 5276 of file Universe.m.

5277{
5278 NSSize viewSize = [gameView viewSize];
5279 if([self useShaders])
5280 {
5281 if ([gameView msaa])
5282 {
5283 // resolve MSAA framebuffer to target framebuffer
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));
5287 }
5288 }
5289}

References OOGL, and prepareToRenderIntoDefaultFramebuffer.

Referenced by Universe::drawUniverse, and prepareToRenderIntoDefaultFramebuffer.

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

◆ randomDistanceWithinScanner

- (float) randomDistanceWithinScanner

Extends class Universe.

Definition at line 10581 of file Universe.m.

10582{
10583 return SCANNER_MAX_RANGE * ((Ranrot() & 255) / 256.0 - 0.5);
10584}

References randomDistanceWithinScanner, Ranrot(), and SCANNER_MAX_RANGE.

Referenced by randomDistanceWithinScanner, randomPlaceWithinScannerFrom:alongRoute:withOffset:, setShaderEffectsLevelDirectly:, and Universe::setUpUniverseFromStation.

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

◆ randomPlaceWithinScannerFrom:alongRoute:withOffset:

- (Vector) randomPlaceWithinScannerFrom: (Vector) pos
alongRoute: (Vector) route
withOffset: (double) offset 

Extends class Universe.

Definition at line 10587 of file Universe.m.

10587 :(Vector)pos alongRoute:(Vector)route withOffset:(double)offset
10588{
10589 pos.x += offset * route.x + [self randomDistanceWithinScanner];
10590 pos.y += offset * route.y + [self randomDistanceWithinScanner];
10591 pos.z += offset * route.z + [self randomDistanceWithinScanner];
10592
10593 return pos;
10594}
return self
float y
float x
float randomDistanceWithinScanner()
Definition Universe.m:10581
voidpf uLong offset
Definition ioapi.h:140

References Universe::randomDistanceWithinScanner.

Here is the call graph for this function:

◆ resizeTargetFramebufferWithViewSize:

- (void) resizeTargetFramebufferWithViewSize: (NSSize) viewSize

Extends class Universe.

Definition at line 553 of file Universe.m.

553 :(NSSize)viewSize
554{
555 int i;
556 // resize MSAA color attachment
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));
560
561 // resize MSAA depth attachment
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));
565
566 // resize color attachments
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));
570
571 for (i = 0; i < 2; i++)
572 {
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));
576 }
577
578 for (i = 0; i < 2; i++)
579 {
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));
583 }
584
585 // resize depth attachment
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));
589
590 targetFramebufferSize.width = viewSize.width;
591 targetFramebufferSize.height = viewSize.height;
592}

References OOGL.

Referenced by Universe::drawUniverse.

Here is the caller graph for this function:

◆ setDetailLevelDirectly:

- (void) setDetailLevelDirectly: (OOGraphicsDetail) value

Extends class Universe.

Definition at line 10025 of file Universe.m.

10025 :(OOGraphicsDetail)value
10026{
10027 if (value >= DETAIL_LEVEL_MAXIMUM)
10028 {
10029 value = DETAIL_LEVEL_MAXIMUM;
10030 }
10031 else if (value <= DETAIL_LEVEL_MINIMUM)
10032 {
10033 value = DETAIL_LEVEL_MINIMUM;
10034 }
10035 if (![[OOOpenGLExtensionManager sharedManager] shadersSupported])
10036 {
10037 value = DETAIL_LEVEL_MINIMUM;
10038 }
10039 detailLevel = value;
10040}
OOGraphicsDetail
Definition OOTypes.h:243
@ DETAIL_LEVEL_MAXIMUM
Definition OOTypes.h:251
@ DETAIL_LEVEL_MINIMUM
Definition OOTypes.h:244

References DETAIL_LEVEL_MAXIMUM, and DETAIL_LEVEL_MINIMUM.

Referenced by Universe::initWithGameView:, and Universe::setDetailLevel:.

Here is the caller graph for this function:

◆ setFirstBeacon:

- (void) setFirstBeacon: (Entity< OOBeaconEntity > *) beacon

Extends class Universe.

Definition at line 3758 of file Universe.m.

3758 :(Entity <OOBeaconEntity> *)beacon
3759{
3760 if (beacon != [self firstBeacon])
3761 {
3762 [beacon setPrevBeacon:nil];
3763 [beacon setNextBeacon:[self firstBeacon]];
3764 [[self firstBeacon] setPrevBeacon:beacon];
3765 [_firstBeacon release];
3766 _firstBeacon = [beacon weakRetain];
3767 }
3768}

References Universe::firstBeacon.

Referenced by Universe::clearBeacon:, Universe::resetBeacons, and Universe::setNextBeacon:.

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

◆ setLastBeacon:

- (void) setLastBeacon: (Entity< OOBeaconEntity > *) beacon

Extends class Universe.

Definition at line 3777 of file Universe.m.

3777 :(Entity <OOBeaconEntity> *)beacon
3778{
3779 if (beacon != [self lastBeacon])
3780 {
3781 [beacon setNextBeacon:nil];
3782 [beacon setPrevBeacon:[self lastBeacon]];
3783 [[self lastBeacon] setNextBeacon:beacon];
3784 [_lastBeacon release];
3785 _lastBeacon = [beacon weakRetain];
3786 }
3787}

References Universe::lastBeacon.

Referenced by Universe::clearBeacon:, Universe::resetBeacons, and Universe::setNextBeacon:.

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

◆ setLibraryTextForDemoShip

- (void) setLibraryTextForDemoShip

Extends class Universe.

Definition at line 3308 of file Universe.m.

3309{
3310 OOGUITabSettings tab_stops;
3311 tab_stops[0] = 0;
3312 tab_stops[1] = 170;
3313 tab_stops[2] = 340;
3314 [gui setTabStops:tab_stops];
3315
3316/* [gui setText:[demo_ship displayName] forRow:19 align:GUI_ALIGN_CENTER];
3317 [gui setColor:[OOColor whiteColor] forRow:19]; */
3318
3319 NSDictionary *librarySettings = [self demoShipData];
3320
3321 OOGUIRow descRow = 7;
3322
3323 NSString *field1 = nil;
3324 NSString *field2 = nil;
3325 NSString *field3 = nil;
3326 NSString *override = nil;
3327
3328 // clear rows
3329 for (NSUInteger i=1;i<=26;i++)
3330 {
3331 [gui setText:@"" forRow:i];
3332 }
3333
3334 /* Row 1: ScanClass, Name, Summary */
3335 override = [librarySettings oo_stringForKey:kOODemoShipClass defaultValue:@"ship"];
3336 field1 = OOShipLibraryCategorySingular(override);
3337
3338
3339 field2 = [demo_ship shipClassName];
3340
3341
3342 override = [librarySettings oo_stringForKey:kOODemoShipSummary defaultValue:nil];
3343 if (override != nil)
3344 {
3345 field3 = OOExpand(override);
3346 }
3347 else
3348 {
3349 field3 = @"";
3350 }
3351 [gui setArray:[NSArray arrayWithObjects:field1,field2,field3,nil] forRow:1];
3352 [gui setColor:[OOColor greenColor] forRow:1];
3353
3354 // ship_data defaults to true for "ship" class, false for everything else
3355 if (![librarySettings oo_boolForKey:kOODemoShipShipData defaultValue:[[librarySettings oo_stringForKey:kOODemoShipClass defaultValue:@"ship"] isEqualToString:@"ship"]])
3356 {
3357 descRow = 3;
3358 }
3359 else
3360 {
3361 /* Row 2: Speed, Turn Rate, Cargo */
3362
3363 override = [librarySettings oo_stringForKey:kOODemoShipSpeed defaultValue:nil];
3364 if (override != nil)
3365 {
3366 if ([override length] == 0)
3367 {
3368 field1 = @"";
3369 }
3370 else
3371 {
3372 field1 = [NSString stringWithFormat:DESC(@"oolite-ship-library-speed-custom"),OOExpand(override)];
3373 }
3374 }
3375 else
3376 {
3377 field1 = OOShipLibrarySpeed(demo_ship);
3378 }
3379
3380
3381 override = [librarySettings oo_stringForKey:kOODemoShipTurnRate defaultValue:nil];
3382 if (override != nil)
3383 {
3384 if ([override length] == 0)
3385 {
3386 field2 = @"";
3387 }
3388 else
3389 {
3390 field2 = [NSString stringWithFormat:DESC(@"oolite-ship-library-turn-custom"),OOExpand(override)];
3391 }
3392 }
3393 else
3394 {
3395 field2 = OOShipLibraryTurnRate(demo_ship);
3396 }
3397
3398
3399 override = [librarySettings oo_stringForKey:kOODemoShipCargo defaultValue:nil];
3400 if (override != nil)
3401 {
3402 if ([override length] == 0)
3403 {
3404 field3 = @"";
3405 }
3406 else
3407 {
3408 field3 = [NSString stringWithFormat:DESC(@"oolite-ship-library-cargo-custom"),OOExpand(override)];
3409 }
3410 }
3411 else
3412 {
3413 field3 = OOShipLibraryCargo(demo_ship);
3414 }
3415
3416
3417 [gui setArray:[NSArray arrayWithObjects:field1,field2,field3,nil] forRow:3];
3418
3419 /* Row 3: recharge rate, energy banks, witchspace */
3420 override = [librarySettings oo_stringForKey:kOODemoShipGenerator defaultValue:nil];
3421 if (override != nil)
3422 {
3423 if ([override length] == 0)
3424 {
3425 field1 = @"";
3426 }
3427 else
3428 {
3429 field1 = [NSString stringWithFormat:DESC(@"oolite-ship-library-generator-custom"),OOExpand(override)];
3430 }
3431 }
3432 else
3433 {
3434 field1 = OOShipLibraryGenerator(demo_ship);
3435 }
3436
3437
3438 override = [librarySettings oo_stringForKey:kOODemoShipShields defaultValue:nil];
3439 if (override != nil)
3440 {
3441 if ([override length] == 0)
3442 {
3443 field2 = @"";
3444 }
3445 else
3446 {
3447 field2 = [NSString stringWithFormat:DESC(@"oolite-ship-library-shields-custom"),OOExpand(override)];
3448 }
3449 }
3450 else
3451 {
3452 field2 = OOShipLibraryShields(demo_ship);
3453 }
3454
3455
3456 override = [librarySettings oo_stringForKey:kOODemoShipWitchspace defaultValue:nil];
3457 if (override != nil)
3458 {
3459 if ([override length] == 0)
3460 {
3461 field3 = @"";
3462 }
3463 else
3464 {
3465 field3 = [NSString stringWithFormat:DESC(@"oolite-ship-library-witchspace-custom"),OOExpand(override)];
3466 }
3467 }
3468 else
3469 {
3470 field3 = OOShipLibraryWitchspace(demo_ship);
3471 }
3472
3473
3474 [gui setArray:[NSArray arrayWithObjects:field1,field2,field3,nil] forRow:4];
3475
3476
3477 /* Row 4: weapons, turrets, size */
3478 override = [librarySettings oo_stringForKey:kOODemoShipWeapons defaultValue:nil];
3479 if (override != nil)
3480 {
3481 if ([override length] == 0)
3482 {
3483 field1 = @"";
3484 }
3485 else
3486 {
3487 field1 = [NSString stringWithFormat:DESC(@"oolite-ship-library-weapons-custom"),OOExpand(override)];
3488 }
3489 }
3490 else
3491 {
3492 field1 = OOShipLibraryWeapons(demo_ship);
3493 }
3494
3495 override = [librarySettings oo_stringForKey:kOODemoShipTurrets defaultValue:nil];
3496 if (override != nil)
3497 {
3498 if ([override length] == 0)
3499 {
3500 field2 = @"";
3501 }
3502 else
3503 {
3504 field2 = [NSString stringWithFormat:DESC(@"oolite-ship-library-turrets-custom"),OOExpand(override)];
3505 }
3506 }
3507 else
3508 {
3509 field2 = OOShipLibraryTurrets(demo_ship);
3510 }
3511
3512 override = [librarySettings oo_stringForKey:kOODemoShipSize defaultValue:nil];
3513 if (override != nil)
3514 {
3515 if ([override length] == 0)
3516 {
3517 field3 = @"";
3518 }
3519 else
3520 {
3521 field3 = [NSString stringWithFormat:DESC(@"oolite-ship-library-size-custom"),OOExpand(override)];
3522 }
3523 }
3524 else
3525 {
3526 field3 = OOShipLibrarySize(demo_ship);
3527 }
3528
3529 [gui setArray:[NSArray arrayWithObjects:field1,field2,field3,nil] forRow:5];
3530 }
3531
3532 override = [librarySettings oo_stringForKey:kOODemoShipDescription defaultValue:nil];
3533 if (override != nil)
3534 {
3535 [gui addLongText:OOExpand(override) startingAtRow:descRow align:GUI_ALIGN_LEFT];
3536 }
3537
3538
3539 // line 19: ship categories
3540 field1 = [NSString stringWithFormat:@"<-- %@",OOShipLibraryCategoryPlural([[[demo_ships objectAtIndex:((demo_ship_index+[demo_ships count]-1)%[demo_ships count])] objectAtIndex:0] oo_stringForKey:kOODemoShipClass])];
3541 field2 = OOShipLibraryCategoryPlural([[[demo_ships objectAtIndex:demo_ship_index] 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])];
3543
3544 [gui setArray:[NSArray arrayWithObjects:field1,field2,field3,nil] forRow:19];
3545 [gui setColor:[OOColor greenColor] forRow:19];
3546
3547 // lines 21-25: ship names
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])
3552 {
3553 end = [subList count] - 1;
3554 }
3555 OOGUIRow row = 21;
3556 field1 = @"";
3557 field3 = @"";
3558 for (i = start ; i <= end ; i++)
3559 {
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)
3563 {
3564 [gui setColor:[OOColor yellowColor] forRow:row];
3565 }
3566 else
3567 {
3568 [gui setColor:[OOColor whiteColor] forRow:row];
3569 }
3570 row++;
3571 }
3572
3573 field2 = @"...";
3574 if (start > 0)
3575 {
3576 [gui setArray:[NSArray arrayWithObjects:field1,field2,field3,nil] forRow:20];
3577 [gui setColor:[OOColor whiteColor] forRow:20];
3578 }
3579 if (end < [subList count]-1)
3580 {
3581 [gui setArray:[NSArray arrayWithObjects:field1,field2,field3,nil] forRow:26];
3582 [gui setColor:[OOColor whiteColor] forRow:26];
3583 }
3584
3585}
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
NSInteger OOGUIRow
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)
NSString * OOShipLibraryWeapons(ShipEntity *demo_ship)
NSString * OOShipLibraryTurnRate(ShipEntity *demo_ship)
#define OOExpand(string,...)
OOColor * greenColor()
Definition OOColor.m:274
OOColor * whiteColor()
Definition OOColor.m:256
OOColor * yellowColor()
Definition OOColor.m:292

References count, Universe::demoShipData, OOColor::greenColor, kOODemoShipClass, kOODemoShipShipData, nil, OOExpand, OOShipLibraryCargo(), OOShipLibraryCategoryPlural(), OOShipLibraryCategorySingular(), OOShipLibraryGenerator(), OOShipLibraryShields(), OOShipLibrarySize(), OOShipLibrarySpeed(), OOShipLibraryTurnRate(), OOShipLibraryTurrets(), OOShipLibraryWeapons(), OOShipLibraryWitchspace(), setLibraryTextForDemoShip, OOColor::whiteColor, and OOColor::yellowColor.

Referenced by setLibraryTextForDemoShip, setShaderEffectsLevelDirectly:, Universe::setupIntroFirstGo:, and Universe::update:.

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

◆ setShaderEffectsLevelDirectly:

- (void) setShaderEffectsLevelDirectly: (OOShaderSetting) value

Extends class Universe.

References demoShipData, loadDescriptions, loadScenarios, randomDistanceWithinScanner, setLibraryTextForDemoShip, verifyDescriptions, and verifyEntitySessionIDs.

Here is the call graph for this function:

◆ setUpCargoPods

- (void) setUpCargoPods

Extends class Universe.

Definition at line 10387 of file Universe.m.

10388{
10389 NSMutableDictionary *tmp = [[NSMutableDictionary alloc] initWithCapacity:[commodities count]];
10390 OOCommodityType type = nil;
10391 foreach (type, [commodities goods])
10392 {
10393 ShipEntity *container = [self newShipWithRole:@"oolite-template-cargopod"];
10394 [container setScanClass:CLASS_CARGO];
10395 [container setCommodity:type andAmount:1];
10396 [tmp setObject:container forKey:type];
10397 [container release];
10398 }
10399 [cargoPods release];
10400 cargoPods = [[NSDictionary alloc] initWithDictionary:tmp];
10401 [tmp release];
10402}
NSString * OOCommodityType
Definition OOTypes.h:106
void setScanClass:(OOScanClass sClass)
Definition Entity.m:799
void setCommodity:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)

References Universe::newShipWithRole:, nil, ShipEntity::setCommodity:andAmount:, Entity::setScanClass:, and setUpCargoPods.

Referenced by Universe::initWithGameView:, Universe::reinitAndShowDemo:, and setUpCargoPods.

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

◆ setUpInitialUniverse

- (void) setUpInitialUniverse

Extends class Universe.

Definition at line 10548 of file Universe.m.

10549{
10550 PlayerEntity* player = PLAYER;
10551
10552 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Wormhole and character reset");
10553 if (activeWormholes) [activeWormholes autorelease];
10554 activeWormholes = [[NSMutableArray arrayWithCapacity:16] retain];
10555 if (characterPool) [characterPool autorelease];
10556 characterPool = [[NSMutableArray arrayWithCapacity:256] retain];
10558
10559 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Galaxy reset");
10560 [self setGalaxyTo: [player galaxyNumber] andReinit:YES];
10561 systemID = [player systemID];
10563
10564 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Player init: setUpShipFromDictionary");
10565 [player setUpShipFromDictionary:[[OOShipRegistry sharedRegistry] shipInfoForKey:[player shipDataKey]]]; // the standard cobra at this point
10566 [player baseMass]; // bootstrap the base mass used in all fuel charge calculations.
10568
10569 // Player init above finishes initialising all standard player ship properties. Now that the base mass is set, we can run setUpSpace!
10570 [self setUpSpace];
10571
10572 [self setDockingClearanceProtocolActive:
10573 [[self currentSystemData] oo_boolForKey:@"stations_require_docking_clearance" defaultValue:YES]];
10574
10575 [self enterGUIViewModeWithMouseInteraction:NO];
10576 [player setPosition:[[self station] position]];
10577 [player setOrientation:kIdentityQuaternion];
10578}
#define OO_DEBUG_POP_PROGRESS()
#define OO_DEBUG_PUSH_PROGRESS(...)
void setOrientation:(Quaternion quat)
Definition Entity.m:725
void setPosition:(HPVector posn)
Definition Entity.m:647
OOShipRegistry * sharedRegistry()
NSDictionary * shipInfoForKey:(NSString *key)
OOGalaxyID galaxyNumber()
BOOL setUpShipFromDictionary:(NSDictionary *shipDict)
OOSystemID systemID()
GLfloat baseMass()
NSString * shipDataKey()

References PlayerEntity::baseMass, Universe::currentSystemData, Universe::enterGUIViewModeWithMouseInteraction:, PlayerEntity::galaxyNumber, OO_DEBUG_POP_PROGRESS, OO_DEBUG_PUSH_PROGRESS, PLAYER, Entity::position, Universe::setDockingClearanceProtocolActive:, Universe::setGalaxyTo:andReinit:, Entity::setOrientation:, Entity::setPosition:, setUpInitialUniverse, PlayerEntity::setUpShipFromDictionary:, Universe::setUpSpace, OOShipRegistry::sharedRegistry, ShipEntity::shipDataKey, OOShipRegistry::shipInfoForKey:, Universe::station, and PlayerEntity::systemID.

Referenced by Universe::initWithGameView:, Universe::reinitAndShowDemo:, and setUpInitialUniverse.

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

◆ verifyDescriptions

- (void) verifyDescriptions

Extends class Universe.

Definition at line 8049 of file Universe.m.

8050{
8051 /*
8052 Ensure that no descriptions.plist entries contain the %n format code,
8053 which can be used to smash the stack and potentially call arbitrary
8054 functions.
8055
8056 %n is deliberately not supported in Foundation/CoreFoundation under
8057 Mac OS X, but unfortunately GNUstep implements it.
8058 -- Ahruman 2011-05-05
8059 */
8060
8061 NSString *key = nil;
8062 if (_descriptions == nil)
8063 {
8064 OOLog(@"descriptions.verify", @"%@", @"***** FATAL: Tried to verify descriptions, but descriptions was nil - unable to load any descriptions.plist file.");
8065 exit(EXIT_FAILURE);
8066 }
8067 foreachkey (key, _descriptions)
8068 {
8069 VerifyDesc(key, [_descriptions objectForKey:key]);
8070 }
8071}
#define foreachkey(VAR, DICT)
Definition OOCocoa.h:366

References foreachkey, nil, OOLog, and verifyDescriptions.

Referenced by Universe::descriptions, loadDescriptions, setShaderEffectsLevelDirectly:, and verifyDescriptions.

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

◆ verifyEntitySessionIDs

- (void) verifyEntitySessionIDs

Extends class Universe.

Definition at line 10404 of file Universe.m.

10405{
10406#ifndef NDEBUG
10407 NSMutableArray *badEntities = nil;
10408 Entity *entity = nil;
10409
10410 unsigned i;
10411 for (i = 0; i < n_entities; i++)
10412 {
10413 entity = sortedEntities[i];
10414 if ([entity sessionID] != _sessionID)
10415 {
10416 OOLogERR(@"universe.sessionIDs.verify.failed", @"Invalid entity %@ (came from session %lu, current session is %lu).", [entity shortDescription], [entity sessionID], _sessionID);
10417 if (badEntities == nil) badEntities = [NSMutableArray array];
10418 [badEntities addObject:entity];
10419 }
10420 }
10421
10422 foreach (entity, badEntities)
10423 {
10424 [self removeEntity:entity];
10425 }
10426#endif
10427}

References nil, OOLogERR, Universe::removeEntity:, and verifyEntitySessionIDs.

Referenced by Universe::reinitAndShowDemo:, setShaderEffectsLevelDirectly:, Universe::update:, and verifyEntitySessionIDs.

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

The documentation for this category was generated from the following file: