Oolite 1.91.0.7646-241128-10e222e
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 200 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 10720 of file Universe.m.

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

◆ chooseStringForKey:inDictionary:

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

Extends class Universe.

Definition at line 10720 of file Universe.m.

10787 :(NSString *)key inDictionary:(NSDictionary *)dictionary
10788{
10789 id object = [dictionary objectForKey:key];
10790 if ([object isKindOfClass:[NSString class]]) return object;
10791 else if ([object isKindOfClass:[NSArray class]] && [object count] > 0) return [object oo_stringAtIndex:Ranrot() % [object count]];
10792 return nil;
10793}
unsigned count
unsigned Ranrot(void)

◆ deleteOpenGLObjects

- (void) deleteOpenGLObjects

Extends class Universe.

Definition at line 273 of file Universe.m.

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

◆ demoShipData

- (NSDictionary *) demoShipData

Extends class Universe.

Definition at line 273 of file Universe.m.

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

◆ doRemoveEntity:

- (BOOL) doRemoveEntity: (Entity *) entity

Extends class Universe.

Definition at line 9494 of file Universe.m.

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

◆ drawTargetTextureIntoDefaultFramebuffer

- (void) drawTargetTextureIntoDefaultFramebuffer

Extends class Universe.

Definition at line 273 of file Universe.m.

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

◆ fractionalPositionFrom:to:withFraction:

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

Extends class Universe.

Definition at line 9494 of file Universe.m.

10589 :(HPVector)point0 to:(HPVector)point1 withFraction:(double)routeFraction
10590{
10591 if (routeFraction == NSNotFound) routeFraction = randf();
10592
10593 point1 = OOHPVectorInterpolate(point0, point1, routeFraction);
10594
10595 point1.x += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10596 point1.y += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10597 point1.z += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10598
10599 return point1;
10600}
#define SCANNER_MAX_RANGE
Definition Entity.h:51
float randf(void)

◆ initTargetFramebufferWithViewSize:

- (void) initTargetFramebufferWithViewSize: (NSSize) viewSize

Extends class Universe.

Definition at line 273 of file Universe.m.

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

◆ loadDescriptions

- (void) loadDescriptions

Extends class Universe.

Definition at line 8019 of file Universe.m.

8067{
8068 [_descriptions autorelease];
8069 _descriptions = [[ResourceManager dictionaryFromFilesNamed:@"descriptions.plist" inFolder:@"Config" andMerge:YES] retain];
8070 [self verifyDescriptions];
8071}
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

◆ loadScenarios

- (void) loadScenarios

Extends class Universe.

Definition at line 8019 of file Universe.m.

8087{
8088 [_scenarios autorelease];
8089 _scenarios = [[ResourceManager arrayFromFilesNamed:@"scenarios.plist" inFolder:@"Config" andMerge:YES] retain];
8090}
NSArray * arrayFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

◆ populateSpaceFromActiveWormholes

- (void) populateSpaceFromActiveWormholes

Extends class Universe.

Definition at line 10720 of file Universe.m.

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

◆ prepareToRenderIntoDefaultFramebuffer

- (void) prepareToRenderIntoDefaultFramebuffer

Extends class Universe.

Definition at line 4641 of file Universe.m.

5276{
5277 NSSize viewSize = [gameView viewSize];
5278 if([self useShaders])
5279 {
5280 if ([gameView msaa])
5281 {
5282 // resolve MSAA framebuffer to target framebuffer
5283 OOGL(glBindFramebuffer(GL_READ_FRAMEBUFFER, msaaFramebufferID));
5284 OOGL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFramebufferID));
5285 OOGL(glBlitFramebuffer(0, 0, (GLint)viewSize.width, (GLint)viewSize.height, 0, 0, (GLint)viewSize.width, (GLint)viewSize.height, GL_COLOR_BUFFER_BIT, GL_NEAREST));
5286 }
5287 }
5288}

◆ randomDistanceWithinScanner

- (float) randomDistanceWithinScanner

Extends class Universe.

Definition at line 9494 of file Universe.m.

10574{
10575 return SCANNER_MAX_RANGE * ((Ranrot() & 255) / 256.0 - 0.5);
10576}

◆ randomPlaceWithinScannerFrom:alongRoute:withOffset:

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

Extends class Universe.

Definition at line 9494 of file Universe.m.

10579 :(Vector)pos alongRoute:(Vector)route withOffset:(double)offset
10580{
10581 pos.x += offset * route.x + [self randomDistanceWithinScanner];
10582 pos.y += offset * route.y + [self randomDistanceWithinScanner];
10583 pos.z += offset * route.z + [self randomDistanceWithinScanner];
10584
10585 return pos;
10586}
return self
float y
float x
float randomDistanceWithinScanner()
Definition Universe.m:10573
voidpf uLong offset
Definition ioapi.h:140

◆ resizeTargetFramebufferWithViewSize:

- (void) resizeTargetFramebufferWithViewSize: (NSSize) viewSize

Extends class Universe.

Definition at line 273 of file Universe.m.

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

◆ setDetailLevelDirectly:

- (void) setDetailLevelDirectly: (OOGraphicsDetail) value

Extends class Universe.

Definition at line 9494 of file Universe.m.

10017 :(OOGraphicsDetail)value
10018{
10019 if (value >= DETAIL_LEVEL_MAXIMUM)
10020 {
10021 value = DETAIL_LEVEL_MAXIMUM;
10022 }
10023 else if (value <= DETAIL_LEVEL_MINIMUM)
10024 {
10025 value = DETAIL_LEVEL_MINIMUM;
10026 }
10027 if (![[OOOpenGLExtensionManager sharedManager] shadersSupported])
10028 {
10029 value = DETAIL_LEVEL_MINIMUM;
10030 }
10031 detailLevel = value;
10032}
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 3627 of file Universe.m.

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

◆ setLastBeacon:

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

Extends class Universe.

Definition at line 3627 of file Universe.m.

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

◆ setLibraryTextForDemoShip

- (void) setLibraryTextForDemoShip

Extends class Universe.

Definition at line 273 of file Universe.m.

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

Extends class Universe.

◆ setUpCargoPods

- (void) setUpCargoPods

Extends class Universe.

Definition at line 9494 of file Universe.m.

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

◆ setUpInitialUniverse

- (void) setUpInitialUniverse

Extends class Universe.

Definition at line 9494 of file Universe.m.

10541{
10542 PlayerEntity* player = PLAYER;
10543
10544 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Wormhole and character reset");
10545 if (activeWormholes) [activeWormholes autorelease];
10546 activeWormholes = [[NSMutableArray arrayWithCapacity:16] retain];
10547 if (characterPool) [characterPool autorelease];
10548 characterPool = [[NSMutableArray arrayWithCapacity:256] retain];
10550
10551 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Galaxy reset");
10552 [self setGalaxyTo: [player galaxyNumber] andReinit:YES];
10553 systemID = [player systemID];
10555
10556 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Player init: setUpShipFromDictionary");
10557 [player setUpShipFromDictionary:[[OOShipRegistry sharedRegistry] shipInfoForKey:[player shipDataKey]]]; // the standard cobra at this point
10558 [player baseMass]; // bootstrap the base mass used in all fuel charge calculations.
10560
10561 // Player init above finishes initialising all standard player ship properties. Now that the base mass is set, we can run setUpSpace!
10562 [self setUpSpace];
10563
10564 [self setDockingClearanceProtocolActive:
10565 [[self currentSystemData] oo_boolForKey:@"stations_require_docking_clearance" defaultValue:YES]];
10566
10567 [self enterGUIViewModeWithMouseInteraction:NO];
10568 [player setPosition:[[self station] position]];
10569 [player setOrientation:kIdentityQuaternion];
10570}
#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()

◆ verifyDescriptions

- (void) verifyDescriptions

Extends class Universe.

Definition at line 8019 of file Universe.m.

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

◆ verifyEntitySessionIDs

- (void) verifyEntitySessionIDs

Extends class Universe.

Definition at line 9494 of file Universe.m.

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

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