Oolite 1.91.0.7745-260117-205bce7
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 197 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 10932 of file Universe.m.

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

References nil.

◆ chooseStringForKey:inDictionary:

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

Extends class Universe.

Definition at line 10803 of file Universe.m.

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

529{
530 OOGL(glDeleteTextures(1, &msaaTextureID));
531 OOGL(glDeleteTextures(1, &targetTextureID));
532 OOGL(glDeleteTextures(2, passthroughTextureID));
533 OOGL(glDeleteTextures(2, pingpongColorbuffers));
534 OOGL(glDeleteRenderbuffers(1, &msaaDepthBufferID));
535 OOGL(glDeleteRenderbuffers(1, &targetDepthBufferID));
536 OOGL(glDeleteFramebuffers(1, &msaaFramebufferID));
537 OOGL(glDeleteFramebuffers(1, &targetFramebufferID));
538 OOGL(glDeleteFramebuffers(2, pingpongFBO));
539 OOGL(glDeleteFramebuffers(1, &passthroughFramebufferID));
540 OOGL(glDeleteVertexArrays(1, &quadTextureVAO));
541 OOGL(glDeleteBuffers(1, &quadTextureVBO));
542 OOGL(glDeleteBuffers(1, &quadTextureEBO));
543 [textureProgram release];
544 [blurProgram release];
545 [finalProgram release];
546}
#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 3307 of file Universe.m.

3308{
3309 return [[demo_ships oo_arrayAtIndex:demo_ship_index] oo_dictionaryAtIndex:demo_ship_subindex];
3310}

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

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

592{
593 // save previous bindings state
594 GLint previousFBO;
595 OOGL(glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &previousFBO));
596 GLint previousProgramID;
597 OOGL(glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgramID));
598 GLint previousTextureID;
599 OOGL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureID));
600 GLint previousVAO;
601 OOGL(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &previousVAO));
602 GLint previousActiveTexture;
603 OOGL(glGetIntegerv(GL_ACTIVE_TEXTURE, &previousActiveTexture));
604
605 OOGL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
606 // fixes transparency issue for some reason
607 OOGL(glDisable(GL_BLEND));
608
609 GLhandleARB program = [textureProgram program];
610 GLhandleARB blur = [blurProgram program];
611 GLhandleARB final = [finalProgram program];
612 NSSize viewSize = [gameView viewSize];
613 float fboResolution[2] = {viewSize.width, viewSize.height};
614
615 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, passthroughFramebufferID));
616 OOGL(glClear(GL_COLOR_BUFFER_BIT));
617
618 OOGL(glUseProgram(program));
619 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
620 OOGL(glUniform1i(glGetUniformLocation(program, "image"), 0));
621
622
623 OOGL(glBindVertexArray(quadTextureVAO));
624 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
625 OOGL(glBindVertexArray(0));
626
627 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
628
629
630 BOOL horizontal = YES, firstIteration = YES;
631 unsigned int amount = [self bloom] ? 10 : 0; // if not blooming, why bother with the heavy calculations?
632 OOGL(glUseProgram(blur));
633 for (unsigned int i = 0; i < amount; i++)
634 {
635 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]));
636 OOGL(glUniform1i(glGetUniformLocation(blur, "horizontal"), horizontal));
637 OOGL(glActiveTexture(GL_TEXTURE0));
638 // bind texture of other framebuffer (or scene if first iteration)
639 OOGL(glBindTexture(GL_TEXTURE_2D, firstIteration ? passthroughTextureID[1] : pingpongColorbuffers[!horizontal]));
640 OOGL(glUniform1i(glGetUniformLocation([blurProgram program], "imageIn"), 0));
641 OOGL(glBindVertexArray(quadTextureVAO));
642 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
643 OOGL(glBindVertexArray(0));
644 horizontal = !horizontal;
645 firstIteration = NO;
646 }
647 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO));
648
649
650 OOGL(glUseProgram(final));
651
652 OOGL(glActiveTexture(GL_TEXTURE0));
653 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[0]));
654 OOGL(glUniform1i(glGetUniformLocation(final, "scene"), 0));
655 OOGL(glUniform1i(glGetUniformLocation(final, "bloom"), [self bloom]));
656 OOGL(glUniform1f(glGetUniformLocation(final, "uTime"), [self getTime]));
657 OOGL(glUniform2fv(glGetUniformLocation(final, "uResolution"), 1, fboResolution));
658 OOGL(glUniform1i(glGetUniformLocation(final, "uPostFX"), [self currentPostFX]));
659#if OOLITE_WINDOWS
660 if([gameView hdrOutput])
661 {
662 OOGL(glUniform1f(glGetUniformLocation(final, "uMaxBrightness"), [gameView hdrMaxBrightness]));
663 OOGL(glUniform1f(glGetUniformLocation(final, "uPaperWhiteBrightness"), [gameView hdrPaperWhiteBrightness]));
664 OOGL(glUniform1i(glGetUniformLocation(final, "uHDRToneMapper"), [gameView hdrToneMapper]));
665 }
666#endif
667 OOGL(glUniform1i(glGetUniformLocation(final, "uSDRToneMapper"), [gameView sdrToneMapper]));
668
669 OOGL(glActiveTexture(GL_TEXTURE1));
670 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[!horizontal]));
671 OOGL(glUniform1i(glGetUniformLocation(final, "bloomBlur"), 1));
672 OOGL(glUniform1f(glGetUniformLocation(final, "uSaturation"), [gameView colorSaturation]));
673
674 OOGL(glBindVertexArray(quadTextureVAO));
675 OOGL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0));
676
677 // restore GL_TEXTURE1 to 0, just in case we are returning from a
678 // DETAIL_LEVEL_NORMAL to DETAIL_LEVEL_SHADERS
679 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
680
681 // restore previous bindings
682 OOGL(glBindFramebuffer(GL_FRAMEBUFFER, previousFBO));
683 OOGL(glActiveTexture(previousActiveTexture));
684 OOGL(glBindTexture(GL_TEXTURE_2D, previousTextureID));
685 OOGL(glUseProgram(previousProgramID));
686 OOGL(glBindVertexArray(previousVAO));
687 OOGL(glEnable(GL_BLEND));
688}

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

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

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

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

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

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

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

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

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

10590{
10591 return SCANNER_MAX_RANGE * ((Ranrot() & 255) / 256.0 - 0.5);
10592}

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

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

549 :(NSSize)viewSize
550{
551 int i;
552 // resize MSAA color attachment
553 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID));
554 OOGL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, GL_TRUE));
555 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
556
557 // resize MSAA depth attachment
558 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaDepthBufferID));
559 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
560 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
561
562 // resize color attachments
563 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
564 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
565 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
566
567 for (i = 0; i < 2; i++)
568 {
569 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]));
570 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
571 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
572 }
573
574 for (i = 0; i < 2; i++)
575 {
576 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[i]));
577 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
578 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
579 }
580
581 // resize depth attachment
582 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, targetDepthBufferID));
583 OOGL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
584 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
585
586 targetFramebufferSize.width = viewSize.width;
587 targetFramebufferSize.height = viewSize.height;
588}

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

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

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

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

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

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

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

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

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

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

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

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

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: