Oolite 1.91.0.7699-250829-cea269d
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 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 10929 of file Universe.m.

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

References nil.

◆ chooseStringForKey:inDictionary:

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

Extends class Universe.

Definition at line 10800 of file Universe.m.

10800 :(NSString *)key inDictionary:(NSDictionary *)dictionary
10801{
10802 id object = [dictionary objectForKey:key];
10803 if ([object isKindOfClass:[NSString class]]) return object;
10804 else if ([object isKindOfClass:[NSArray class]] && [object count] > 0) return [object oo_stringAtIndex:Ranrot() % [object count]];
10805 return nil;
10806}
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 3304 of file Universe.m.

3305{
3306 return [[demo_ships oo_arrayAtIndex:demo_ship_index] oo_dictionaryAtIndex:demo_ship_subindex];
3307}

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

10616 :(Entity *)entity
10617{
10618 // remove reference to entity in linked lists
10619 if ([entity canCollide]) // filter only collidables disappearing
10620 {
10621 doLinkedListMaintenanceThisUpdate = YES;
10622 }
10623
10624 [entity removeFromLinkedLists];
10625
10626 // moved forward ^^
10627 // remove from the reference dictionary
10628 int old_id = [entity universalID];
10629 entity_for_uid[old_id] = nil;
10630 [entity setUniversalID:NO_TARGET];
10631 [entity wasRemovedFromUniverse];
10632
10633 // maintain sorted lists
10634 int index = entity->zero_index;
10635
10636 int n = 1;
10637 if (index >= 0)
10638 {
10639 if (sortedEntities[index] != entity)
10640 {
10641 OOLog(kOOLogInconsistentState, @"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE RIGHT PLACE IN THE ZERO_DISTANCE SORTED LIST -- FIXING...", entity);
10642 unsigned i;
10643 index = -1;
10644 for (i = 0; (i < n_entities)&&(index == -1); i++)
10645 if (sortedEntities[i] == entity)
10646 index = i;
10647 if (index == -1)
10648 OOLog(kOOLogInconsistentState, @"DEBUG: Universe removeEntity:%@ ENTITY IS NOT IN THE ZERO_DISTANCE SORTED LIST -- CONTINUING...", entity);
10649 }
10650 if (index != -1)
10651 {
10652 while ((unsigned)index < n_entities)
10653 {
10654 while (((unsigned)index + n < n_entities)&&(sortedEntities[index + n] == entity))
10655 {
10656 n++; // ie there's a duplicate entry for this entity
10657 }
10658
10659 /*
10660 BUG: when n_entities == UNIVERSE_MAX_ENTITIES, this read
10661 off the end of the array and copied (Entity *)n_entities =
10662 0x800 into the list. The subsequent update of zero_index
10663 derferenced 0x800 and crashed.
10664 FIX: add an extra unused slot to sortedEntities, which is
10665 always nil.
10666 EFFICIENCY CONCERNS: this could have been an alignment
10667 issue since UNIVERSE_MAX_ENTITIES == 2048, but it isn't
10668 really. sortedEntities is part of the object, not malloced,
10669 it isn't aligned, and the end of it is only live in
10670 degenerate cases.
10671 -- Ahruman 2012-07-11
10672 */
10673 sortedEntities[index] = sortedEntities[index + n]; // copy entity[index + n] -> entity[index] (preserves sort order)
10674 if (sortedEntities[index])
10675 {
10676 sortedEntities[index]->zero_index = index; // give it its correct position
10677 }
10678 index++;
10679 }
10680 if (n > 1)
10681 OOLog(kOOLogInconsistentState, @"DEBUG: Universe removeEntity: REMOVED %d EXTRA COPIES OF %@ FROM THE ZERO_DISTANCE SORTED LIST", n - 1, entity);
10682 while (n--)
10683 {
10684 n_entities--;
10685 sortedEntities[n_entities] = nil;
10686 }
10687 }
10688 entity->zero_index = -1; // it's GONE!
10689 }
10690
10691 // remove from the definitive list
10692 if ([entities containsObject:entity])
10693 {
10694 // FIXME: better approach needed for core break patterns - CIM
10695 if ([entity isBreakPattern] && ![entity isVisualEffect])
10696 {
10697 breakPatternCounter--;
10698 }
10699
10700 if ([entity isShip])
10701 {
10702 ShipEntity *se = (ShipEntity*)entity;
10703 [self clearBeacon:se];
10704 }
10705 if ([entity isWaypoint])
10706 {
10707 OOWaypointEntity *wp = (OOWaypointEntity*)entity;
10708 [self clearBeacon:wp];
10709 }
10710 if ([entity isVisualEffect])
10711 {
10712 OOVisualEffectEntity *ve = (OOVisualEffectEntity*)entity;
10713 [self clearBeacon:ve];
10714 }
10715
10716 if ([entity isWormhole])
10717 {
10718 [activeWormholes removeObject:entity];
10719 }
10720 else if ([entity isPlanet])
10721 {
10722 [allPlanets removeObject:entity];
10723 }
10724
10725 [entities removeObject:entity];
10726 return YES;
10727 }
10728
10729 return NO;
10730}
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 OOGL(glUniform1i(glGetUniformLocation(final, "uHDRToneMapper"), [gameView hdrToneMapper]));
669 }
670#endif
671 OOGL(glUniform1i(glGetUniformLocation(final, "uSDRToneMapper"), [gameView sdrToneMapper]));
672
673 OOGL(glActiveTexture(GL_TEXTURE1));
674 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[!horizontal]));
675 OOGL(glUniform1i(glGetUniformLocation(final, "bloomBlur"), 1));
676 OOGL(glUniform1f(glGetUniformLocation(final, "uSaturation"), [gameView colorSaturation]));
677
678 OOGL(glBindVertexArray(quadTextureVAO));
679 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
680
681 // restore GL_TEXTURE1 to 0, just in case we are returning from a
682 // DETAIL_LEVEL_NORMAL to DETAIL_LEVEL_SHADERS
683 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
684
685 // restore previous bindings
686 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, previousFBO));
687 OOGL(glActiveTexture(previousActiveTexture));
688 OOGL(glBindTexture(GL_TEXTURE_2D, previousTextureID));
689 OOGL(glUseProgram(previousProgramID));
690 OOGL(glBindVertexArray(previousVAO));
691 OOGL(glEnable(GL_BLEND));
692}

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

10602 :(HPVector)point0 to:(HPVector)point1 withFraction:(double)routeFraction
10603{
10604 if (routeFraction == NSNotFound) routeFraction = randf();
10605
10606 point1 = OOHPVectorInterpolate(point0, point1, routeFraction);
10607
10608 point1.x += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10609 point1.y += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10610 point1.z += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10611
10612 return point1;
10613}
#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 8079 of file Universe.m.

8080{
8081 [_descriptions autorelease];
8082 _descriptions = [[ResourceManager dictionaryFromFilesNamed:@"descriptions.plist" inFolder:@"Config" andMerge:YES] retain];
8083 [self verifyDescriptions];
8084}
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 8099 of file Universe.m.

8100{
8101 [_scenarios autorelease];
8102 _scenarios = [[ResourceManager arrayFromFilesNamed:@"scenarios.plist" inFolder:@"Config" andMerge:YES] retain];
8103}
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 10771 of file Universe.m.

10772{
10773 NSAutoreleasePool *pool = nil;
10774
10775 while ([activeWormholes count])
10776 {
10777 pool = [[NSAutoreleasePool alloc] init];
10778 @try
10779 {
10780 WormholeEntity* whole = [activeWormholes objectAtIndex:0];
10781 // If the wormhole has been scanned by the player then the
10782 // PlayerEntity will take care of it
10783 if (![whole isScanned] &&
10784 NSEqualPoints([PLAYER galaxy_coordinates], [whole destinationCoordinates]) )
10785 {
10786 // this is a wormhole to this system
10787 [whole disgorgeShips];
10788 }
10789 [activeWormholes removeObjectAtIndex:0]; // empty it out
10790 }
10791 @catch (NSException *exception)
10792 {
10793 OOLog(kOOLogException, @"Squashing exception during wormhole unpickling (%@: %@).", [exception name], [exception reason]);
10794 }
10795 [pool release];
10796 }
10797}
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 5281 of file Universe.m.

5282{
5283 NSSize viewSize = [gameView viewSize];
5284 if([self useShaders])
5285 {
5286 if ([gameView msaa])
5287 {
5288 // resolve MSAA framebuffer to target framebuffer
5289 OOGL(glBindFramebuffer(GL_READ_FRAMEBUFFER, msaaFramebufferID));
5290 OOGL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFramebufferID));
5291 OOGL(glBlitFramebuffer(0, 0, (GLint)viewSize.width, (GLint)viewSize.height, 0, 0, (GLint)viewSize.width, (GLint)viewSize.height, GL_COLOR_BUFFER_BIT, GL_NEAREST));
5292 }
5293 }
5294}

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

10587{
10588 return SCANNER_MAX_RANGE * ((Ranrot() & 255) / 256.0 - 0.5);
10589}

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

10592 :(Vector)pos alongRoute:(Vector)route withOffset:(double)offset
10593{
10594 pos.x += offset * route.x + [self randomDistanceWithinScanner];
10595 pos.y += offset * route.y + [self randomDistanceWithinScanner];
10596 pos.z += offset * route.z + [self randomDistanceWithinScanner];
10597
10598 return pos;
10599}
return self
float y
float x
float randomDistanceWithinScanner()
Definition Universe.m:10586
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 10030 of file Universe.m.

10030 :(OOGraphicsDetail)value
10031{
10032 if (value >= DETAIL_LEVEL_MAXIMUM)
10033 {
10034 value = DETAIL_LEVEL_MAXIMUM;
10035 }
10036 else if (value <= DETAIL_LEVEL_MINIMUM)
10037 {
10038 value = DETAIL_LEVEL_MINIMUM;
10039 }
10040 if (![[OOOpenGLExtensionManager sharedManager] shadersSupported])
10041 {
10042 value = DETAIL_LEVEL_MINIMUM;
10043 }
10044 detailLevel = value;
10045}
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 3760 of file Universe.m.

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

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

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

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

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

10393{
10394 NSMutableDictionary *tmp = [[NSMutableDictionary alloc] initWithCapacity:[commodities count]];
10395 OOCommodityType type = nil;
10396 foreach (type, [commodities goods])
10397 {
10398 ShipEntity *container = [self newShipWithRole:@"oolite-template-cargopod"];
10399 [container setScanClass:CLASS_CARGO];
10400 [container setCommodity:type andAmount:1];
10401 [tmp setObject:container forKey:type];
10402 [container release];
10403 }
10404 [cargoPods release];
10405 cargoPods = [[NSDictionary alloc] initWithDictionary:tmp];
10406 [tmp release];
10407}
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 10553 of file Universe.m.

10554{
10555 PlayerEntity* player = PLAYER;
10556
10557 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Wormhole and character reset");
10558 if (activeWormholes) [activeWormholes autorelease];
10559 activeWormholes = [[NSMutableArray arrayWithCapacity:16] retain];
10560 if (characterPool) [characterPool autorelease];
10561 characterPool = [[NSMutableArray arrayWithCapacity:256] retain];
10563
10564 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Galaxy reset");
10565 [self setGalaxyTo: [player galaxyNumber] andReinit:YES];
10566 systemID = [player systemID];
10568
10569 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Player init: setUpShipFromDictionary");
10570 [player setUpShipFromDictionary:[[OOShipRegistry sharedRegistry] shipInfoForKey:[player shipDataKey]]]; // the standard cobra at this point
10571 [player baseMass]; // bootstrap the base mass used in all fuel charge calculations.
10573
10574 // Player init above finishes initialising all standard player ship properties. Now that the base mass is set, we can run setUpSpace!
10575 [self setUpSpace];
10576
10577 [self setDockingClearanceProtocolActive:
10578 [[self currentSystemData] oo_boolForKey:@"stations_require_docking_clearance" defaultValue:YES]];
10579
10580 [self enterGUIViewModeWithMouseInteraction:NO];
10581 [player setPosition:[[self station] position]];
10582 [player setOrientation:kIdentityQuaternion];
10583}
#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 8054 of file Universe.m.

8055{
8056 /*
8057 Ensure that no descriptions.plist entries contain the %n format code,
8058 which can be used to smash the stack and potentially call arbitrary
8059 functions.
8060
8061 %n is deliberately not supported in Foundation/CoreFoundation under
8062 Mac OS X, but unfortunately GNUstep implements it.
8063 -- Ahruman 2011-05-05
8064 */
8065
8066 NSString *key = nil;
8067 if (_descriptions == nil)
8068 {
8069 OOLog(@"descriptions.verify", @"%@", @"***** FATAL: Tried to verify descriptions, but descriptions was nil - unable to load any descriptions.plist file.");
8070 exit(EXIT_FAILURE);
8071 }
8072 foreachkey (key, _descriptions)
8073 {
8074 VerifyDesc(key, [_descriptions objectForKey:key]);
8075 }
8076}
#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 10409 of file Universe.m.

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

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: