Oolite
Loading...
Searching...
No Matches
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 205 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 9822 of file Universe.m.

9822 :(NSString*)string toGraphViz:(NSMutableString*)graphViz fromNode:(NSString*)fromNode nodeCount:(NSUInteger)nodeCount
9823{
9824 NSString* index = nil;
9825 NSInteger start, end;
9826 NSRange remaining, subRange;
9827 unsigned i;
9828
9829 remaining = NSMakeRange(0, [string length]);
9830
9831 for (;;) {
9832 subRange = [string rangeOfString:@"[" options:NSLiteralSearch range:remaining];
9833 if (subRange.location == NSNotFound)
9834 break;
9835 start = subRange.location + subRange.length;
9836 remaining.length -= start - remaining.location;
9837 remaining.location = start;
9838
9839 subRange = [string rangeOfString:@"]" options:NSLiteralSearch range:remaining];
9840 if (subRange.location == NSNotFound)
9841 break;
9842 end = subRange.location;
9843 remaining.length -= end - remaining.location;
9844 remaining.location = end;
9845
9846 index = [string substringWithRange:NSMakeRange(start, end - start)];
9847 i = [index intValue];
9848
9849 // Each node gets a colour for its incoming edges. The multiplication and mod shuffle them to avoid adjacent nodes having similar colours.
9850 [graphViz appendFormat:@"\t%@ -> n%u_0 [color=\"%f,0.75,0.8\" lhead=cluster_%u]\n", fromNode, i, ((float)(i * 511 % nodeCount)) / ((float)nodeCount), i];
9851 }
9852
9853 if ([string rangeOfString:@"%I"].location != NSNotFound) {
9854 [graphViz appendFormat:@"\t%@ -> percent_I [color=\"0,0,0.25\"]\n", fromNode];
9855 }
9856 if ([string rangeOfString:@"%H"].location != NSNotFound) {
9857 [graphViz appendFormat:@"\t%@ -> percent_H [color=\"0,0,0.45\"]\n", fromNode];
9858 }
9859 if ([string rangeOfString:@"%R"].location != NSNotFound || [string rangeOfString:@"%N"].location != NSNotFound) {
9860 [graphViz appendFormat:@"\t%@ -> percent_RN [color=\"0,0,0.65\"]\n", fromNode];
9861 }
9862
9863 // TODO: test graphViz output for @"%Jxxx" and @"%Gxxxxxx"
9864 if ([string rangeOfString:@"%J"].location != NSNotFound) {
9865 [graphViz appendFormat:@"\t%@ -> percent_J [color=\"0,0,0.75\"]\n", fromNode];
9866 }
9867
9868 if ([string rangeOfString:@"%G"].location != NSNotFound) {
9869 [graphViz appendFormat:@"\t%@ -> percent_G [color=\"0,0,0.85\"]\n", fromNode];
9870 }
9871}
return nil

References nil.

◆ chooseStringForKey:inDictionary:

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

Extends class Universe.

Definition at line 9699 of file Universe.m.

9699 :(NSString*)key inDictionary:(NSDictionary*)dictionary
9700{
9701 id object = [dictionary objectForKey:key];
9702 if ([object isKindOfClass:[NSString class]])
9703 return object;
9704 else if ([object isKindOfClass:[NSArray class]] && [object count] > 0)
9705 return [object oo_stringAtIndex:Ranrot() % [object count]];
9706 return nil;
9707}
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 529 of file Universe.m.

530{
531#if OO_MSAA_COLOR_RENDERBUFFER
532 OOGL(glDeleteRenderbuffers(1, &msaaTextureID));
533#else
534 OOGL(glDeleteTextures(1, &msaaTextureID));
535#endif
536 OOGL(glDeleteTextures(1, &targetTextureID));
537 OOGL(glDeleteTextures(2, passthroughTextureID));
538 OOGL(glDeleteTextures(2, pingpongColorbuffers));
539 OOGL(glDeleteRenderbuffers(1, &msaaDepthBufferID));
540 OOGL(glDeleteRenderbuffers(1, &targetDepthBufferID));
541 OOGL(glDeleteFramebuffers(1, &msaaFramebufferID));
542 OOGL(glDeleteFramebuffers(1, &targetFramebufferID));
543 OOGL(glDeleteFramebuffers(2, pingpongFBO));
544 OOGL(glDeleteFramebuffers(1, &passthroughFramebufferID));
545 OOGL(glDeleteVertexArrays(1, &quadTextureVAO));
546 OOGL(glDeleteBuffers(1, &quadTextureVBO));
547 OOGL(glDeleteBuffers(1, &quadTextureEBO));
548 [textureProgram release];
549 [blurProgram release];
550 [finalProgram release];
551}
#define OOGL(statement)
Definition OOOpenGL.h:262

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 3057 of file Universe.m.

3058{
3059 return [[demo_ships oo_arrayAtIndex:demo_ship_index] oo_dictionaryAtIndex:demo_ship_subindex];
3060}

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 9545 of file Universe.m.

9545 :(Entity*)entity
9546{
9547 // remove reference to entity in linked lists
9548 if ([entity canCollide]) // filter only collidables disappearing
9549 {
9550 doLinkedListMaintenanceThisUpdate = YES;
9551 }
9552
9553 [entity removeFromLinkedLists];
9554
9555 // moved forward ^^
9556 // remove from the reference dictionary
9557 int old_id = [entity universalID];
9558 entity_for_uid[old_id] = nil;
9559 [entity setUniversalID:NO_TARGET];
9560 [entity wasRemovedFromUniverse];
9561
9562 // maintain sorted lists
9563 int index = entity->zero_index;
9564
9565 int n = 1;
9566 if (index >= 0) {
9567 if (sortedEntities[index] != entity) {
9568 OOLog(kOOLogInconsistentState, @"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE RIGHT PLACE IN THE ZERO_DISTANCE SORTED LIST -- FIXING...", entity);
9569 unsigned i;
9570 index = -1;
9571 for (i = 0; (i < n_entities) && (index == -1); i++)
9572 if (sortedEntities[i] == entity)
9573 index = i;
9574 if (index == -1)
9575 OOLog(kOOLogInconsistentState, @"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE ZERO_DISTANCE SORTED LIST -- CONTINUING...", entity);
9576 }
9577 if (index != -1) {
9578 while ((unsigned)index < n_entities) {
9579 while (((unsigned)index + n < n_entities) && (sortedEntities[index + n] == entity)) {
9580 n++; // ie there's a duplicate entry for this entity
9581 }
9582
9583 /*
9584 BUG: when n_entities == UNIVERSE_MAX_ENTITIES, this read
9585 off the end of the array and copied (Entity *)n_entities =
9586 0x800 into the list. The subsequent update of zero_index
9587 derferenced 0x800 and crashed.
9588 FIX: add an extra unused slot to sortedEntities, which is
9589 always nil.
9590 EFFICIENCY CONCERNS: this could have been an alignment
9591 issue since UNIVERSE_MAX_ENTITIES == 2048, but it isn't
9592 really. sortedEntities is part of the object, not malloced,
9593 it isn't aligned, and the end of it is only live in
9594 degenerate cases.
9595 -- Ahruman 2012-07-11
9596 */
9597 sortedEntities[index] = sortedEntities[index + n]; // copy entity[index + n] -> entity[index] (preserves sort order)
9598 if (sortedEntities[index]) {
9599 sortedEntities[index]->zero_index = index; // give it its correct position
9600 }
9601 index++;
9602 }
9603 if (n > 1)
9604 OOLog(kOOLogInconsistentState, @"DEBUG: Universe removeEntity: REMOVED %d EXTRA COPIES OF %@ FROM THE ZERO_DISTANCE SORTED LIST", n - 1, entity);
9605 while (n--) {
9606 n_entities--;
9607 sortedEntities[n_entities] = nil;
9608 }
9609 }
9610 entity->zero_index = -1; // it's GONE!
9611 }
9612
9613 // remove from the definitive list
9614 if ([entities containsObject:entity]) {
9615 // FIXME: better approach needed for core break patterns - CIM
9616 if ([entity isBreakPattern] && ![entity isVisualEffect]) {
9617 breakPatternCounter--;
9618 }
9619
9620 if ([entity isShip]) {
9621 ShipEntity* se = (ShipEntity*)entity;
9622 [self clearBeacon:se];
9623 }
9624 if ([entity isWaypoint]) {
9625 OOWaypointEntity* wp = (OOWaypointEntity*)entity;
9626 [self clearBeacon:wp];
9627 }
9628 if ([entity isVisualEffect]) {
9629 OOVisualEffectEntity* ve = (OOVisualEffectEntity*)entity;
9630 [self clearBeacon:ve];
9631 }
9632
9633 if ([entity isWormhole]) {
9634 [activeWormholes removeObject:entity];
9635 } else if ([entity isPlanet]) {
9636 [allPlanets removeObject:entity];
9637 }
9638
9639 [entities removeObject:entity];
9640 return YES;
9641 }
9642
9643 return NO;
9644}
NSString *const kOOLogInconsistentState
Definition OOLogging.m:599
#define OOLog(class, format,...)
Definition OOLogging.h:84
void removeFromLinkedLists()
Definition Entity.m:269
void setUniversalID:(OOUniversalID uid)
Definition Entity.m:517
OOUniversalID universalID
Definition Entity.m:522
int zero_index
Definition Entity.h:113
void wasRemovedFromUniverse()
Definition Entity.m:494

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 598 of file Universe.m.

599{
600 // save previous bindings state
601 GLint previousFBO;
602 OOGL(glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &previousFBO));
603 GLint previousProgramID;
604 OOGL(glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgramID));
605 GLint previousTextureID;
606 OOGL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureID));
607 GLint previousVAO;
608 OOGL(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &previousVAO));
609 GLint previousActiveTexture;
610 OOGL(glGetIntegerv(GL_ACTIVE_TEXTURE, &previousActiveTexture));
611
612 OOGL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
613 // fixes transparency issue for some reason
614 OOGL(glDisable(GL_BLEND));
615
616 GLuint program = OOGLProgramName([textureProgram program]);
617 GLuint blur = OOGLProgramName([blurProgram program]);
618 GLuint final = OOGLProgramName([finalProgram program]);
619 NSSize viewSize = [gameView backingViewSize];
620 float fboResolution[2] = { viewSize.width, viewSize.height };
621
622 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, passthroughFramebufferID));
623 OOGL(glClear(GL_COLOR_BUFFER_BIT));
624
625 OOGL(glUseProgram(program));
626 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
627 OOGL(glUniform1i(glGetUniformLocation(program, "image"), 0));
628
629 OOGL(glBindVertexArray(quadTextureVAO));
630 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
631 OOGL(glBindVertexArray(0));
632
633 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
634
635 BOOL horizontal = YES, firstIteration = YES;
636 unsigned int amount = [self bloom] ? 10 : 0; // if not blooming, why bother with the heavy calculations?
637 OOGL(glUseProgram(blur));
638 for (unsigned int i = 0; i < amount; i++) {
639 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]));
640 OOGL(glUniform1i(glGetUniformLocation(blur, "horizontal"), horizontal));
641 OOGL(glActiveTexture(GL_TEXTURE0));
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(blur, "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 OOGL(glUseProgram(final));
654
655 OOGL(glActiveTexture(GL_TEXTURE0));
656 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[0]));
657 OOGL(glUniform1i(glGetUniformLocation(final, "scene"), 0));
658 OOGL(glUniform1i(glGetUniformLocation(final, "bloom"), [self bloom]));
659 OOGL(glUniform1f(glGetUniformLocation(final, "uTime"), [self getTime]));
660 OOGL(glUniform2fv(glGetUniformLocation(final, "uResolution"), 1, fboResolution));
661 OOGL(glUniform1i(glGetUniformLocation(final, "uPostFX"), [self currentPostFX]));
662#if OOLITE_WINDOWS
663 if ([gameView hdrOutput]) {
664 OOGL(glUniform1f(glGetUniformLocation(final, "uMaxBrightness"), [gameView hdrMaxBrightness]));
665 OOGL(glUniform1f(glGetUniformLocation(final, "uPaperWhiteBrightness"), [gameView hdrPaperWhiteBrightness]));
666 OOGL(glUniform1i(glGetUniformLocation(final, "uHDRToneMapper"), [gameView hdrToneMapper]));
667 }
668#endif
669 OOGL(glUniform1i(glGetUniformLocation(final, "uSDRToneMapper"), [gameView sdrToneMapper]));
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}
#define OOGLProgramName(handle)
Definition OOOpenGL.h:44

References Universe::bloom, drawTargetTextureIntoDefaultFramebuffer, OOGL, and OOGLProgramName.

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 9531 of file Universe.m.

9531 :(HPVector)point0 to:(HPVector)point1 withFraction:(double)routeFraction
9532{
9533 if (routeFraction == NSNotFound)
9534 routeFraction = randf();
9535
9536 point1 = OOHPVectorInterpolate(point0, point1, routeFraction);
9537
9538 point1.x += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
9539 point1.y += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
9540 point1.z += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
9541
9542 return point1;
9543}
#define SCANNER_MAX_RANGE
Definition Entity.h:53
struct HPVector HPVector
OOINLINE HPVector OOHPVectorInterpolate(HPVector a, HPVector b, OOHPScalar where) INLINE_CONST_FUNC
Definition OOHPVector.h:222
float randf(void)
OOHPScalar x
Definition OOHPVector.h:36
OOHPScalar y
Definition OOHPVector.h:37
OOHPScalar z
Definition OOHPVector.h:38

References OOHPVectorInterpolate(), randf(), SCANNER_MAX_RANGE, HPVector::x, HPVector::y, and HPVector::z.

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 340 of file Universe.m.

340 :(NSSize)viewSize
341{
342 // liberate us from the 0.0 to 1.0 rgb range!
343 OOGL(glClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE));
344 OOGL(glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE));
345 OOGL(glClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE));
346
347 // have to do this because on my machine the default framebuffer is not zero
348 OOGL(glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &defaultDrawFBO));
349
350 GLint previousProgramID;
351 OOGL(glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgramID));
352 GLint previousTextureID;
353 OOGL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureID));
354 GLint previousVAO;
355 OOGL(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &previousVAO));
356 GLint previousArrayBuffer;
357 OOGL(glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &previousArrayBuffer));
358 GLint previousElementBuffer;
359 OOGL(glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &previousElementBuffer));
360
361 // create MSAA framebuffer and attach MSAA texture and depth buffer to framebuffer
362 OOGL(glGenFramebuffers(1, &msaaFramebufferID));
363 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, msaaFramebufferID));
364
365 // creating MSAA texture that should be rendered into
366#if OO_MSAA_COLOR_RENDERBUFFER
367 // No multisample textures in the macOS legacy context; a multisample renderbuffer resolves the same way.
368 OOGL(glGenRenderbuffers(1, &msaaTextureID));
369 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaTextureID));
370 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
371 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
372 OOGL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, msaaTextureID));
373#else
374 OOGL(glGenTextures(1, &msaaTextureID));
375 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID));
376 OOGL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, GL_TRUE));
377 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
378 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID, 0));
379#endif
380
381 // create necessary MSAA depth render buffer
382 OOGL(glGenRenderbuffers(1, &msaaDepthBufferID));
383 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaDepthBufferID));
384 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
385 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
386 OOGL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, msaaDepthBufferID));
387
388 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
389 OOLogERR(@"initTargetFramebufferWithViewSize.result", @"%@", @"***** Error: Multisample framebuffer not complete");
390 }
391
392 // create framebuffer and attach texture and depth buffer to framebuffer
393 OOGL(glGenFramebuffers(1, &targetFramebufferID));
394 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, targetFramebufferID));
395
396 // creating texture that should be rendered into
397 OOGL(glGenTextures(1, &targetTextureID));
398 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
399 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
400 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
401 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
402 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
403 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
404 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTextureID, 0));
405
406 // create necessary depth render buffer
407 OOGL(glGenRenderbuffers(1, &targetDepthBufferID));
408 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, targetDepthBufferID));
409 OOGL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
410 OOGL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, targetDepthBufferID));
411
412 GLenum attachment[1] = { GL_COLOR_ATTACHMENT0 };
413 OOGL(glDrawBuffers(1, attachment));
414
415 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
416 OOLogERR(@"initTargetFramebufferWithViewSize.result", @"%@", @"***** Error: Framebuffer not complete");
417 }
418
419 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
420
421 targetFramebufferSize = viewSize;
422
423 // passthrough buffer
424 // This is a framebuffer whose sole purpose is to pass on the texture rendered from the game to the blur and the final bloom
425 // shaders. We need it in order to be able to use the OpenGL 3.3 layout (location = x) out vec4 outVector; construct, which allows
426 // us to perform multiple render target operations needed for bloom. The alternative would be to not use this and change all our
427 // shaders to be OpenGL 3.3 compatible, but given how Oolite synthesizes them and the work needed to port them over, well yeah no,
428 // not doing it at this time - Nikos 20220814.
429 OOGL(glGenFramebuffers(1, &passthroughFramebufferID));
430 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, passthroughFramebufferID));
431
432 // creating textures that should be rendered into
433 OOGL(glGenTextures(2, passthroughTextureID));
434 for (unsigned int i = 0; i < 2; i++) {
435 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[i]));
436 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
437 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
438 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
439 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
440 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
441 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, passthroughTextureID[i], 0));
442 }
443
444 GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
445 OOGL(glDrawBuffers(2, attachments));
446
447 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
448 OOLogERR(@"initTargetFramebufferWithViewSize.result", @"%@", @"***** Error: Passthrough framebuffer not complete");
449 }
450 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
451
452 // ping-pong-framebuffer for blurring
453 OOGL(glGenFramebuffers(2, pingpongFBO));
454 OOGL(glGenTextures(2, pingpongColorbuffers));
455 for (unsigned int i = 0; i < 2; i++) {
456 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i]));
457 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]));
458 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
459 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
460 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
461 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!
462 OOGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
463 OOGL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongColorbuffers[i], 0));
464 // check if framebuffers are complete (no need for depth buffer)
465 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
466 OOLogERR(@"initTargetFramebufferWithViewSize.result", @"%@", @"***** Error: Pingpong framebuffers not complete");
467 }
468 }
469 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
470
471 _bloom = [self detailLevel] >= DETAIL_LEVEL_EXTRAS;
472 _currentPostFX = _colorblindMode = OO_POSTFX_NONE;
473
474 /* TODO: in OOEnvironmentCubeMap.m call these bind functions not with 0 but with "previousXxxID"s:
475 - OOGL(glBindTexture(GL_TEXTURE_CUBE_MAP, 0));
476 - OOGL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
477 - OOGL(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0));
478 */
479
480 // shader for drawing a textured quad on the passthrough framebuffer and preparing it for bloom using MRT
481 if (![[OOOpenGLExtensionManager sharedManager] shadersForceDisabled]) {
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 // restoring previous bindings
522 OOGL(glUseProgram(previousProgramID));
523 OOGL(glBindTexture(GL_TEXTURE_2D, previousTextureID));
524 OOGL(glBindVertexArray(previousVAO));
525 OOGL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, previousElementBuffer));
526 OOGL(glBindBuffer(GL_ARRAY_BUFFER, previousArrayBuffer));
527}
#define OOLogERR(class, format,...)
Definition OOLogging.h:125
#define GL_CLAMP_TO_EDGE
@ DETAIL_LEVEL_EXTRAS
Definition OOTypes.h:212
@ OO_POSTFX_NONE
Definition Universe.h:83
const GLfloat framebufferQuadVertices[]
Definition Universe.m:119
const GLuint framebufferQuadIndices[]
Definition Universe.m:126

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 7271 of file Universe.m.

7272{
7273 [_descriptions autorelease];
7274 _descriptions = [[ResourceManager dictionaryFromFilesNamed:@"descriptions.plist" inFolder:@"Config" andMerge:YES] retain];
7275 [self verifyDescriptions];
7276}
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 7288 of file Universe.m.

7289{
7290 [_scenarios autorelease];
7291 _scenarios = [[ResourceManager arrayFromFilesNamed:@"scenarios.plist" inFolder:@"Config" andMerge:YES] retain];
7292}
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 9676 of file Universe.m.

9677{
9678 NSAutoreleasePool* pool = nil;
9679
9680 while ([activeWormholes count]) {
9681 pool = [[NSAutoreleasePool alloc] init];
9682 @try {
9683 WormholeEntity* whole = [activeWormholes objectAtIndex:0];
9684 // If the wormhole has been scanned by the player then the
9685 // PlayerEntity will take care of it
9686 if (![whole isScanned] && NSEqualPoints([PLAYER galaxy_coordinates], [whole destinationCoordinates])) {
9687 // this is a wormhole to this system
9688 [whole disgorgeShips];
9689 }
9690 [activeWormholes removeObjectAtIndex:0]; // empty it out
9691 }
9692 @catch (NSException* exception) {
9693 OOLog(kOOLogException, @"Squashing exception during wormhole unpickling (%@: %@).", [exception name], [exception reason]);
9694 }
9695 [pool release];
9696 }
9697}
NSString *const kOOLogException
Definition OOLogging.m:600
#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 4782 of file Universe.m.

4783{
4784 NSSize viewSize = [gameView backingViewSize];
4785 if ([self useShaders]) {
4786 if ([gameView msaa]) {
4787 // resolve MSAA framebuffer to target framebuffer
4788 OOGL(glBindFramebuffer(GL_READ_FRAMEBUFFER, msaaFramebufferID));
4789 OOGL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFramebufferID));
4790 OOGL(glBlitFramebuffer(0, 0, (GLint)viewSize.width, (GLint)viewSize.height, 0, 0, (GLint)viewSize.width, (GLint)viewSize.height, GL_COLOR_BUFFER_BIT, GL_NEAREST));
4791 }
4792 }
4793}

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 9517 of file Universe.m.

9518{
9519 return SCANNER_MAX_RANGE * ((Ranrot() & 255) / 256.0 - 0.5);
9520}

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 9522 of file Universe.m.

9522 :(Vector)pos alongRoute:(Vector)route withOffset:(double)offset
9523{
9524 pos.x += offset * route.x + [self randomDistanceWithinScanner];
9525 pos.y += offset * route.y + [self randomDistanceWithinScanner];
9526 pos.z += offset * route.z + [self randomDistanceWithinScanner];
9527
9528 return pos;
9529}
return self
float y
float x
struct Vector Vector
float randomDistanceWithinScanner()
Definition Universe.m:9517
voidpf uLong offset
Definition ioapi.h:132
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33
OOScalar z
Definition OOVector.h:34

References Universe::randomDistanceWithinScanner, Vector::x, Vector::y, and Vector::z.

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#if OO_MSAA_COLOR_RENDERBUFFER
558 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaTextureID));
559 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
560 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
561#else
562 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID));
563 OOGL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, GL_TRUE));
564 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
565#endif
566
567 // resize MSAA depth attachment
568 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaDepthBufferID));
569 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
570 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
571
572 // resize color attachments
573 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
574 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
575 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
576
577 for (i = 0; i < 2; i++) {
578 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]));
579 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
580 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
581 }
582
583 for (i = 0; i < 2; i++) {
584 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[i]));
585 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
586 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
587 }
588
589 // resize depth attachment
590 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, targetDepthBufferID));
591 OOGL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
592 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
593
594 targetFramebufferSize.width = viewSize.width;
595 targetFramebufferSize.height = viewSize.height;
596}

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 9020 of file Universe.m.

9020 :(OOGraphicsDetail)value
9021{
9022 if (value >= DETAIL_LEVEL_MAXIMUM) {
9023 value = DETAIL_LEVEL_MAXIMUM;
9024 } else if (value <= DETAIL_LEVEL_MINIMUM) {
9025 value = DETAIL_LEVEL_MINIMUM;
9026 }
9027 if (![[OOOpenGLExtensionManager sharedManager] shadersSupported]) {
9028 value = DETAIL_LEVEL_MINIMUM;
9029 }
9030 detailLevel = value;
9031}
OOGraphicsDetail
Definition OOTypes.h:208
@ DETAIL_LEVEL_MAXIMUM
Definition OOTypes.h:214
@ DETAIL_LEVEL_MINIMUM
Definition OOTypes.h:209

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 3408 of file Universe.m.

3408 :(Entity<OOBeaconEntity>*)beacon
3409{
3410 if (beacon != [self firstBeacon]) {
3411 [beacon setPrevBeacon:nil];
3412 [beacon setNextBeacon:[self firstBeacon]];
3413 [[self firstBeacon] setPrevBeacon:beacon];
3414 [_firstBeacon release];
3415 _firstBeacon = [beacon weakRetain];
3416 }
3417}

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 3424 of file Universe.m.

3424 :(Entity<OOBeaconEntity>*)beacon
3425{
3426 if (beacon != [self lastBeacon]) {
3427 [beacon setNextBeacon:nil];
3428 [beacon setPrevBeacon:[self lastBeacon]];
3429 [[self lastBeacon] setNextBeacon:beacon];
3430 [_lastBeacon release];
3431 _lastBeacon = [beacon weakRetain];
3432 }
3433}

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 3062 of file Universe.m.

3063{
3064 OOGUITabSettings tab_stops;
3065 tab_stops[0] = 0;
3066 tab_stops[1] = 170;
3067 tab_stops[2] = 340;
3068 [gui setTabStops:tab_stops];
3069
3070 /* [gui setText:[demo_ship displayName] forRow:19 align:GUI_ALIGN_CENTER];
3071 [gui setColor:[OOColor whiteColor] forRow:19]; */
3072
3073 NSDictionary* librarySettings = [self demoShipData];
3074
3075 OOGUIRow descRow = 7;
3076
3077 NSString* field1 = nil;
3078 NSString* field2 = nil;
3079 NSString* field3 = nil;
3080 NSString* override = nil;
3081
3082 // clear rows
3083 for (NSUInteger i = 1; i <= 26; i++) {
3084 [gui setText:@"" forRow:i];
3085 }
3086
3087 /* Row 1: ScanClass, Name, Summary */
3088 override = [librarySettings oo_stringForKey:kOODemoShipClass defaultValue:@"ship"];
3089 field1 = OOShipLibraryCategorySingular(override);
3090
3091 field2 = [demo_ship shipClassName];
3092
3093 override = [librarySettings oo_stringForKey:kOODemoShipSummary defaultValue:nil];
3094 if (override != nil) {
3095 field3 = OOExpand(override);
3096 } else {
3097 field3 = @"";
3098 }
3099 [gui setArray:[NSArray arrayWithObjects:field1, field2, field3, nil] forRow:1];
3100 [gui setColor:[OOColor greenColor] forRow:1];
3101
3102 // ship_data defaults to true for "ship" class, false for everything else
3103 if (![librarySettings oo_boolForKey:kOODemoShipShipData defaultValue:[[librarySettings oo_stringForKey:kOODemoShipClass defaultValue:@"ship"] isEqualToString:@"ship"]]) {
3104 descRow = 3;
3105 } else {
3106 /* Row 2: Speed, Turn Rate, Cargo */
3107
3108 override = [librarySettings oo_stringForKey:kOODemoShipSpeed defaultValue:nil];
3109 if (override != nil) {
3110 if ([override length] == 0) {
3111 field1 = @"";
3112 } else {
3113 field1 = [NSString stringWithFormat:DESC(@"oolite-ship-library-speed-custom"), OOExpand(override)];
3114 }
3115 } else {
3116 field1 = OOShipLibrarySpeed(demo_ship);
3117 }
3118
3119 override = [librarySettings oo_stringForKey:kOODemoShipTurnRate defaultValue:nil];
3120 if (override != nil) {
3121 if ([override length] == 0) {
3122 field2 = @"";
3123 } else {
3124 field2 = [NSString stringWithFormat:DESC(@"oolite-ship-library-turn-custom"), OOExpand(override)];
3125 }
3126 } else {
3127 field2 = OOShipLibraryTurnRate(demo_ship);
3128 }
3129
3130 override = [librarySettings oo_stringForKey:kOODemoShipCargo defaultValue:nil];
3131 if (override != nil) {
3132 if ([override length] == 0) {
3133 field3 = @"";
3134 } else {
3135 field3 = [NSString stringWithFormat:DESC(@"oolite-ship-library-cargo-custom"), OOExpand(override)];
3136 }
3137 } else {
3138 field3 = OOShipLibraryCargo(demo_ship);
3139 }
3140
3141 [gui setArray:[NSArray arrayWithObjects:field1, field2, field3, nil] forRow:3];
3142
3143 /* Row 3: recharge rate, energy banks, witchspace */
3144 override = [librarySettings oo_stringForKey:kOODemoShipGenerator defaultValue:nil];
3145 if (override != nil) {
3146 if ([override length] == 0) {
3147 field1 = @"";
3148 } else {
3149 field1 = [NSString stringWithFormat:DESC(@"oolite-ship-library-generator-custom"), OOExpand(override)];
3150 }
3151 } else {
3152 field1 = OOShipLibraryGenerator(demo_ship);
3153 }
3154
3155 override = [librarySettings oo_stringForKey:kOODemoShipShields defaultValue:nil];
3156 if (override != nil) {
3157 if ([override length] == 0) {
3158 field2 = @"";
3159 } else {
3160 field2 = [NSString stringWithFormat:DESC(@"oolite-ship-library-shields-custom"), OOExpand(override)];
3161 }
3162 } else {
3163 field2 = OOShipLibraryShields(demo_ship);
3164 }
3165
3166 override = [librarySettings oo_stringForKey:kOODemoShipWitchspace defaultValue:nil];
3167 if (override != nil) {
3168 if ([override length] == 0) {
3169 field3 = @"";
3170 } else {
3171 field3 = [NSString stringWithFormat:DESC(@"oolite-ship-library-witchspace-custom"), OOExpand(override)];
3172 }
3173 } else {
3174 field3 = OOShipLibraryWitchspace(demo_ship);
3175 }
3176
3177 [gui setArray:[NSArray arrayWithObjects:field1, field2, field3, nil] forRow:4];
3178
3179 /* Row 4: weapons, turrets, size */
3180 override = [librarySettings oo_stringForKey:kOODemoShipWeapons defaultValue:nil];
3181 if (override != nil) {
3182 if ([override length] == 0) {
3183 field1 = @"";
3184 } else {
3185 field1 = [NSString stringWithFormat:DESC(@"oolite-ship-library-weapons-custom"), OOExpand(override)];
3186 }
3187 } else {
3188 field1 = OOShipLibraryWeapons(demo_ship);
3189 }
3190
3191 override = [librarySettings oo_stringForKey:kOODemoShipTurrets defaultValue:nil];
3192 if (override != nil) {
3193 if ([override length] == 0) {
3194 field2 = @"";
3195 } else {
3196 field2 = [NSString stringWithFormat:DESC(@"oolite-ship-library-turrets-custom"), OOExpand(override)];
3197 }
3198 } else {
3199 field2 = OOShipLibraryTurrets(demo_ship);
3200 }
3201
3202 override = [librarySettings oo_stringForKey:kOODemoShipSize defaultValue:nil];
3203 if (override != nil) {
3204 if ([override length] == 0) {
3205 field3 = @"";
3206 } else {
3207 field3 = [NSString stringWithFormat:DESC(@"oolite-ship-library-size-custom"), OOExpand(override)];
3208 }
3209 } else {
3210 field3 = OOShipLibrarySize(demo_ship);
3211 }
3212
3213 [gui setArray:[NSArray arrayWithObjects:field1, field2, field3, nil] forRow:5];
3214 }
3215
3216 override = [librarySettings oo_stringForKey:kOODemoShipDescription defaultValue:nil];
3217 if (override != nil) {
3218 [gui addLongText:OOExpand(override) startingAtRow:descRow align:GUI_ALIGN_LEFT];
3219 }
3220
3221 // line 19: ship categories
3222 field1 = [NSString stringWithFormat:@"<-- %@", OOShipLibraryCategoryPlural([[[demo_ships objectAtIndex:((demo_ship_index + [demo_ships count] - 1) % [demo_ships count])] objectAtIndex:0] oo_stringForKey:kOODemoShipClass])];
3223 field2 = OOShipLibraryCategoryPlural([[[demo_ships objectAtIndex:demo_ship_index] objectAtIndex:0] oo_stringForKey:kOODemoShipClass]);
3224 field3 = [NSString stringWithFormat:@"%@ -->", OOShipLibraryCategoryPlural([[[demo_ships objectAtIndex:((demo_ship_index + 1) % [demo_ships count])] objectAtIndex:0] oo_stringForKey:kOODemoShipClass])];
3225
3226 [gui setArray:[NSArray arrayWithObjects:field1, field2, field3, nil] forRow:19];
3227 [gui setColor:[OOColor greenColor] forRow:19];
3228
3229 // lines 21-25: ship names
3230 NSArray* subList = [demo_ships objectAtIndex:demo_ship_index];
3231 NSUInteger i, start = demo_ship_subindex - (demo_ship_subindex % 5);
3232 NSUInteger end = start + 4;
3233 if (end >= [subList count]) {
3234 end = [subList count] - 1;
3235 }
3236 OOGUIRow row = 21;
3237 field1 = @"";
3238 field3 = @"";
3239 for (i = start; i <= end; i++) {
3240 field2 = [[subList objectAtIndex:i] oo_stringForKey:kOODemoShipName];
3241 [gui setArray:[NSArray arrayWithObjects:field1, field2, field3, nil] forRow:row];
3242 if (i == demo_ship_subindex) {
3243 [gui setColor:[OOColor yellowColor] forRow:row];
3244 } else {
3245 [gui setColor:[OOColor whiteColor] forRow:row];
3246 }
3247 row++;
3248 }
3249
3250 field2 = @"...";
3251 if (start > 0) {
3252 [gui setArray:[NSArray arrayWithObjects:field1, field2, field3, nil] forRow:20];
3253 [gui setColor:[OOColor whiteColor] forRow:20];
3254 }
3255 if (end < [subList count] - 1) {
3256 [gui setArray:[NSArray arrayWithObjects:field1, field2, field3, nil] forRow:26];
3257 [gui setColor:[OOColor whiteColor] forRow:26];
3258 }
3259}
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:264
OOColor * whiteColor()
Definition OOColor.m:249
OOColor * yellowColor()
Definition OOColor.m:279

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 9338 of file Universe.m.

9339{
9340 NSMutableDictionary* tmp = [[NSMutableDictionary alloc] initWithCapacity:[commodities count]];
9341 OOCommodityType type = nil;
9342 foreach (type, [commodities goods]) {
9343 ShipEntity* container = [self newShipWithRole:@"oolite-template-cargopod"];
9344 [container setScanClass:CLASS_CARGO];
9345 [container setCommodity:type andAmount:1];
9346 [tmp setObject:container forKey:type];
9347 [container release];
9348 }
9349 [cargoPods release];
9350 cargoPods = [[NSDictionary alloc] initWithDictionary:tmp];
9351 [tmp release];
9352}
NSString * OOCommodityType
Definition OOTypes.h:97
void setScanClass:(OOScanClass sClass)
Definition Entity.m:738
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 9482 of file Universe.m.

9483{
9484 PlayerEntity* player = PLAYER;
9485
9486 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Wormhole and character reset");
9487 if (activeWormholes)
9488 [activeWormholes autorelease];
9489 activeWormholes = [[NSMutableArray arrayWithCapacity:16] retain];
9490 if (characterPool)
9491 [characterPool autorelease];
9492 characterPool = [[NSMutableArray arrayWithCapacity:256] retain];
9494
9495 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Galaxy reset");
9496 [self setGalaxyTo:[player galaxyNumber] andReinit:YES];
9497 systemID = [player systemID];
9499
9500 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Player init: setUpShipFromDictionary");
9501 [player setUpShipFromDictionary:[[OOShipRegistry sharedRegistry] shipInfoForKey:[player shipDataKey]]]; // the standard cobra at this point
9502 [player baseMass]; // bootstrap the base mass used in all fuel charge calculations.
9504
9505 // Player init above finishes initialising all standard player ship properties. Now that the base mass is set, we can run setUpSpace!
9506 [self setUpSpace];
9507
9508 [self setDockingClearanceProtocolActive:
9509 [[self currentSystemData] oo_boolForKey:@"stations_require_docking_clearance"
9510 defaultValue:YES]];
9511
9512 [self enterGUIViewModeWithMouseInteraction:NO];
9513 [player setPosition:[[self station] position]];
9514 [player setOrientation:kIdentityQuaternion];
9515}
#define OO_DEBUG_POP_PROGRESS()
#define OO_DEBUG_PUSH_PROGRESS(...)
void setOrientation:(Quaternion quat)
Definition Entity.m:676
void setPosition:(HPVector posn)
Definition Entity.m:608
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 7248 of file Universe.m.

7249{
7250 /*
7251 Ensure that no descriptions.plist entries contain the %n format code,
7252 which can be used to smash the stack and potentially call arbitrary
7253 functions.
7254
7255 %n is deliberately not supported in Foundation/CoreFoundation under
7256 Mac OS X, but unfortunately GNUstep implements it.
7257 -- Ahruman 2011-05-05
7258 */
7259
7260 NSString* key = nil;
7261 if (_descriptions == nil) {
7262 OOLog(@"descriptions.verify", @"%@", @"***** FATAL: Tried to verify descriptions, but descriptions was nil - unable to load any descriptions.plist file.");
7263 exit(EXIT_FAILURE);
7264 }
7265 foreachkey(key, _descriptions)
7266 {
7267 VerifyDesc(key, [_descriptions objectForKey:key]);
7268 }
7269}
#define foreachkey(VAR, DICT)

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 9354 of file Universe.m.

9355{
9356#ifndef NDEBUG
9357 NSMutableArray* badEntities = nil;
9358 Entity* entity = nil;
9359
9360 unsigned i;
9361 for (i = 0; i < n_entities; i++) {
9362 entity = sortedEntities[i];
9363 if ([entity sessionID] != _sessionID) {
9364 OOLogERR(@"universe.sessionIDs.verify.failed", @"Invalid entity %@ (came from session %zu, current session is %zu).", [entity shortDescription], [entity sessionID], _sessionID);
9365 if (badEntities == nil)
9366 badEntities = [NSMutableArray array];
9367 [badEntities addObject:entity];
9368 }
9369 }
9370
9371 foreach (entity, badEntities) {
9372 [self removeEntity:entity];
9373 }
9374#endif
9375}

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: