Oolite
Loading...
Searching...
No Matches
Universe(OOPrivate) Category Reference

Instance Methods

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

Detailed Description

Definition at line 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 10753 of file Universe.m.

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

◆ chooseStringForKey:inDictionary:

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

Extends class Universe.

Definition at line 10753 of file Universe.m.

10820 :(NSString *)key inDictionary:(NSDictionary *)dictionary
10821{
10822 id object = [dictionary objectForKey:key];
10823 if ([object isKindOfClass:[NSString class]]) return object;
10824 else if ([object isKindOfClass:[NSArray class]] && [object count] > 0) return [object oo_stringAtIndex:Ranrot() % [object count]];
10825 return nil;
10826}
unsigned count
unsigned Ranrot(void)

◆ deleteOpenGLObjects

- (void) deleteOpenGLObjects

Extends class Universe.

Definition at line 270 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

◆ demoShipData

- (NSDictionary *) demoShipData

Extends class Universe.

Definition at line 270 of file Universe.m.

3312{
3313 return [[demo_ships oo_arrayAtIndex:demo_ship_index] oo_dictionaryAtIndex:demo_ship_subindex];
3314}

◆ doRemoveEntity:

- (BOOL) doRemoveEntity: (Entity *)  entity

Extends class Universe.

Definition at line 9527 of file Universe.m.

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

◆ drawTargetTextureIntoDefaultFramebuffer

- (void) drawTargetTextureIntoDefaultFramebuffer

Extends class Universe.

Definition at line 270 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 backingViewSize];
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}

◆ fractionalPositionFrom:to:withFraction:

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

Extends class Universe.

Definition at line 9527 of file Universe.m.

10622 :(HPVector)point0 to:(HPVector)point1 withFraction:(double)routeFraction
10623{
10624 if (routeFraction == NSNotFound) routeFraction = randf();
10625
10626 point1 = OOHPVectorInterpolate(point0, point1, routeFraction);
10627
10628 point1.x += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10629 point1.y += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10630 point1.z += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10631
10632 return point1;
10633}
#define SCANNER_MAX_RANGE
Definition Entity.h:51
float randf(void)

◆ initTargetFramebufferWithViewSize:

- (void) initTargetFramebufferWithViewSize: (NSSize)  viewSize

Extends class Universe.

Definition at line 270 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:90
const GLfloat framebufferQuadVertices[]
Definition Universe.m:125
const GLuint framebufferQuadIndices[]
Definition Universe.m:132

◆ loadDescriptions

- (void) loadDescriptions

Extends class Universe.

Definition at line 8055 of file Universe.m.

8103{
8104 [_descriptions autorelease];
8105 _descriptions = [[ResourceManager dictionaryFromFilesNamed:@"descriptions.plist" inFolder:@"Config" andMerge:YES] retain];
8106 [self verifyDescriptions];
8107}
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

◆ loadScenarios

- (void) loadScenarios

Extends class Universe.

Definition at line 8055 of file Universe.m.

8123{
8124 [_scenarios autorelease];
8125 _scenarios = [[ResourceManager arrayFromFilesNamed:@"scenarios.plist" inFolder:@"Config" andMerge:YES] retain];
8126}
NSArray * arrayFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

◆ populateSpaceFromActiveWormholes

- (void) populateSpaceFromActiveWormholes

Extends class Universe.

Definition at line 10753 of file Universe.m.

10792{
10793 NSAutoreleasePool *pool = nil;
10794
10795 while ([activeWormholes count])
10796 {
10797 pool = [[NSAutoreleasePool alloc] init];
10798 @try
10799 {
10800 WormholeEntity* whole = [activeWormholes objectAtIndex:0];
10801 // If the wormhole has been scanned by the player then the
10802 // PlayerEntity will take care of it
10803 if (![whole isScanned] &&
10804 NSEqualPoints([PLAYER galaxy_coordinates], [whole destinationCoordinates]) )
10805 {
10806 // this is a wormhole to this system
10807 [whole disgorgeShips];
10808 }
10809 [activeWormholes removeObjectAtIndex:0]; // empty it out
10810 }
10811 @catch (NSException *exception)
10812 {
10813 OOLog(kOOLogException, @"Squashing exception during wormhole unpickling (%@: %@).", [exception name], [exception reason]);
10814 }
10815 [pool release];
10816 }
10817}
NSString *const kOOLogException
Definition OOLogging.m:651
#define PLAYER

◆ prepareToRenderIntoDefaultFramebuffer

- (void) prepareToRenderIntoDefaultFramebuffer

Extends class Universe.

Definition at line 4651 of file Universe.m.

5307{
5308 NSSize viewSize = [gameView backingViewSize];
5309 if([self useShaders])
5310 {
5311 if ([gameView msaa])
5312 {
5313 // resolve MSAA framebuffer to target framebuffer
5314 OOGL(glBindFramebuffer(GL_READ_FRAMEBUFFER, msaaFramebufferID));
5315 OOGL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFramebufferID));
5316 OOGL(glBlitFramebuffer(0, 0, (GLint)viewSize.width, (GLint)viewSize.height, 0, 0, (GLint)viewSize.width, (GLint)viewSize.height, GL_COLOR_BUFFER_BIT, GL_NEAREST));
5317 }
5318 }
5319}

◆ randomDistanceWithinScanner

- (float) randomDistanceWithinScanner

Extends class Universe.

Definition at line 9527 of file Universe.m.

10607{
10608 return SCANNER_MAX_RANGE * ((Ranrot() & 255) / 256.0 - 0.5);
10609}

◆ randomPlaceWithinScannerFrom:alongRoute:withOffset:

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

Extends class Universe.

Definition at line 9527 of file Universe.m.

10612 :(Vector)pos alongRoute:(Vector)route withOffset:(double)offset
10613{
10614 pos.x += offset * route.x + [self randomDistanceWithinScanner];
10615 pos.y += offset * route.y + [self randomDistanceWithinScanner];
10616 pos.z += offset * route.z + [self randomDistanceWithinScanner];
10617
10618 return pos;
10619}
return self
float y
float x
float randomDistanceWithinScanner()
Definition Universe.m:10606
voidpf uLong offset
Definition ioapi.h:140

◆ resizeTargetFramebufferWithViewSize:

- (void) resizeTargetFramebufferWithViewSize: (NSSize)  viewSize

Extends class Universe.

Definition at line 270 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}

◆ setDetailLevelDirectly:

- (void) setDetailLevelDirectly: (OOGraphicsDetail value

Extends class Universe.

Definition at line 9527 of file Universe.m.

10050 :(OOGraphicsDetail)value
10051{
10052 if (value >= DETAIL_LEVEL_MAXIMUM)
10053 {
10054 value = DETAIL_LEVEL_MAXIMUM;
10055 }
10056 else if (value <= DETAIL_LEVEL_MINIMUM)
10057 {
10058 value = DETAIL_LEVEL_MINIMUM;
10059 }
10060 if (![[OOOpenGLExtensionManager sharedManager] shadersSupported])
10061 {
10062 value = DETAIL_LEVEL_MINIMUM;
10063 }
10064 detailLevel = value;
10065}
OOGraphicsDetail
Definition OOTypes.h:243
@ DETAIL_LEVEL_MAXIMUM
Definition OOTypes.h:251
@ DETAIL_LEVEL_MINIMUM
Definition OOTypes.h:244

◆ setFirstBeacon:

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

Extends class Universe.

Definition at line 3637 of file Universe.m.

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

◆ setLastBeacon:

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

Extends class Universe.

Definition at line 3637 of file Universe.m.

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

◆ setLibraryTextForDemoShip

- (void) setLibraryTextForDemoShip

Extends class Universe.

Definition at line 270 of file Universe.m.

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

◆ setShaderEffectsLevelDirectly:

- (void) setShaderEffectsLevelDirectly: (OOShaderSetting value

◆ setUpCargoPods

- (void) setUpCargoPods

Extends class Universe.

Definition at line 9527 of file Universe.m.

10413{
10414 NSMutableDictionary *tmp = [[NSMutableDictionary alloc] initWithCapacity:[commodities count]];
10415 OOCommodityType type = nil;
10416 foreach (type, [commodities goods])
10417 {
10418 ShipEntity *container = [self newShipWithRole:@"oolite-template-cargopod"];
10419 [container setScanClass:CLASS_CARGO];
10420 [container setCommodity:type andAmount:1];
10421 [tmp setObject:container forKey:type];
10422 [container release];
10423 }
10424 [cargoPods release];
10425 cargoPods = [[NSDictionary alloc] initWithDictionary:tmp];
10426 [tmp release];
10427}
NSString * OOCommodityType
Definition OOTypes.h:106
void setScanClass:(OOScanClass sClass)
Definition Entity.m:800
void setCommodity:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)

◆ setUpInitialUniverse

- (void) setUpInitialUniverse

Extends class Universe.

Definition at line 9527 of file Universe.m.

10574{
10575 PlayerEntity* player = PLAYER;
10576
10577 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Wormhole and character reset");
10578 if (activeWormholes) [activeWormholes autorelease];
10579 activeWormholes = [[NSMutableArray arrayWithCapacity:16] retain];
10580 if (characterPool) [characterPool autorelease];
10581 characterPool = [[NSMutableArray arrayWithCapacity:256] retain];
10583
10584 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Galaxy reset");
10585 [self setGalaxyTo: [player galaxyNumber] andReinit:YES];
10586 systemID = [player systemID];
10588
10589 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Player init: setUpShipFromDictionary");
10590 [player setUpShipFromDictionary:[[OOShipRegistry sharedRegistry] shipInfoForKey:[player shipDataKey]]]; // the standard cobra at this point
10591 [player baseMass]; // bootstrap the base mass used in all fuel charge calculations.
10593
10594 // Player init above finishes initialising all standard player ship properties. Now that the base mass is set, we can run setUpSpace!
10595 [self setUpSpace];
10596
10597 [self setDockingClearanceProtocolActive:
10598 [[self currentSystemData] oo_boolForKey:@"stations_require_docking_clearance" defaultValue:YES]];
10599
10600 [self enterGUIViewModeWithMouseInteraction:NO];
10601 [player setPosition:[[self station] position]];
10602 [player setOrientation:kIdentityQuaternion];
10603}
#define OO_DEBUG_POP_PROGRESS()
#define OO_DEBUG_PUSH_PROGRESS(...)
void setOrientation:(Quaternion quat)
Definition Entity.m:726
void setPosition:(HPVector posn)
Definition Entity.m:648
OOShipRegistry * sharedRegistry()
NSDictionary * shipInfoForKey:(NSString *key)
OOGalaxyID galaxyNumber()
BOOL setUpShipFromDictionary:(NSDictionary *shipDict)
OOSystemID systemID()
GLfloat baseMass()
NSString * shipDataKey()

◆ verifyDescriptions

- (void) verifyDescriptions

Extends class Universe.

Definition at line 8055 of file Universe.m.

8078{
8079 /*
8080 Ensure that no descriptions.plist entries contain the %n format code,
8081 which can be used to smash the stack and potentially call arbitrary
8082 functions.
8083
8084 %n is deliberately not supported in Foundation/CoreFoundation under
8085 Mac OS X, but unfortunately GNUstep implements it.
8086 -- Ahruman 2011-05-05
8087 */
8088
8089 NSString *key = nil;
8090 if (_descriptions == nil)
8091 {
8092 OOLog(@"descriptions.verify", @"%@", @"***** FATAL: Tried to verify descriptions, but descriptions was nil - unable to load any descriptions.plist file.");
8093 exit(EXIT_FAILURE);
8094 }
8095 foreachkey (key, _descriptions)
8096 {
8097 VerifyDesc(key, [_descriptions objectForKey:key]);
8098 }
8099}
#define foreachkey(VAR, DICT)
Definition OOCocoa.h:353

◆ verifyEntitySessionIDs

- (void) verifyEntitySessionIDs

Extends class Universe.

Definition at line 9527 of file Universe.m.

10430{
10431#ifndef NDEBUG
10432 NSMutableArray *badEntities = nil;
10433 Entity *entity = nil;
10434
10435 unsigned i;
10436 for (i = 0; i < n_entities; i++)
10437 {
10438 entity = sortedEntities[i];
10439 if ([entity sessionID] != _sessionID)
10440 {
10441 OOLogERR(@"universe.sessionIDs.verify.failed", @"Invalid entity %@ (came from session %llu, current session is %llu).", [entity shortDescription], [entity sessionID], _sessionID);
10442 if (badEntities == nil) badEntities = [NSMutableArray array];
10443 [badEntities addObject:entity];
10444 }
10445 }
10446
10447 foreach (entity, badEntities)
10448 {
10449 [self removeEntity:entity];
10450 }
10451#endif
10452}

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