Oolite 1.91.0.7644-241112-7f5034b
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 10697 of file Universe.m.

10893 :(NSString *)string toGraphViz:(NSMutableString *)graphViz fromNode:(NSString *)fromNode nodeCount:(NSUInteger)nodeCount
10894{
10895 NSString *index = nil;
10896 NSInteger start, end;
10897 NSRange remaining, subRange;
10898 unsigned i;
10899
10900 remaining = NSMakeRange(0, [string length]);
10901
10902 for (;;)
10903 {
10904 subRange = [string rangeOfString:@"[" options:NSLiteralSearch range:remaining];
10905 if (subRange.location == NSNotFound) break;
10906 start = subRange.location + subRange.length;
10907 remaining.length -= start - remaining.location;
10908 remaining.location = start;
10909
10910 subRange = [string rangeOfString:@"]" options:NSLiteralSearch range:remaining];
10911 if (subRange.location == NSNotFound) break;
10912 end = subRange.location;
10913 remaining.length -= end - remaining.location;
10914 remaining.location = end;
10915
10916 index = [string substringWithRange:NSMakeRange(start, end - start)];
10917 i = [index intValue];
10918
10919 // Each node gets a colour for its incoming edges. The multiplication and mod shuffle them to avoid adjacent nodes having similar colours.
10920 [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];
10921 }
10922
10923 if ([string rangeOfString:@"%I"].location != NSNotFound)
10924 {
10925 [graphViz appendFormat:@"\t%@ -> percent_I [color=\"0,0,0.25\"]\n", fromNode];
10926 }
10927 if ([string rangeOfString:@"%H"].location != NSNotFound)
10928 {
10929 [graphViz appendFormat:@"\t%@ -> percent_H [color=\"0,0,0.45\"]\n", fromNode];
10930 }
10931 if ([string rangeOfString:@"%R"].location != NSNotFound || [string rangeOfString:@"%N"].location != NSNotFound)
10932 {
10933 [graphViz appendFormat:@"\t%@ -> percent_RN [color=\"0,0,0.65\"]\n", fromNode];
10934 }
10935
10936 // TODO: test graphViz output for @"%Jxxx" and @"%Gxxxxxx"
10937 if ([string rangeOfString:@"%J"].location != NSNotFound)
10938 {
10939 [graphViz appendFormat:@"\t%@ -> percent_J [color=\"0,0,0.75\"]\n", fromNode];
10940 }
10941
10942 if ([string rangeOfString:@"%G"].location != NSNotFound)
10943 {
10944 [graphViz appendFormat:@"\t%@ -> percent_G [color=\"0,0,0.85\"]\n", fromNode];
10945 }
10946}
return nil

◆ chooseStringForKey:inDictionary:

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

Extends class Universe.

Definition at line 10697 of file Universe.m.

10764 :(NSString *)key inDictionary:(NSDictionary *)dictionary
10765{
10766 id object = [dictionary objectForKey:key];
10767 if ([object isKindOfClass:[NSString class]]) return object;
10768 else if ([object isKindOfClass:[NSArray class]] && [object count] > 0) return [object oo_stringAtIndex:Ranrot() % [object count]];
10769 return nil;
10770}
unsigned count
unsigned Ranrot(void)

◆ deleteOpenGLObjects

- (void) deleteOpenGLObjects

Extends class Universe.

Definition at line 273 of file Universe.m.

523{
524 OOGL(glDeleteTextures(1, &msaaTextureID));
525 OOGL(glDeleteTextures(1, &targetTextureID));
526 OOGL(glDeleteTextures(2, passthroughTextureID));
527 OOGL(glDeleteTextures(2, pingpongColorbuffers));
528 OOGL(glDeleteRenderbuffers(1, &msaaDepthBufferID));
529 OOGL(glDeleteRenderbuffers(1, &targetDepthBufferID));
530 OOGL(glDeleteFramebuffers(1, &msaaFramebufferID));
531 OOGL(glDeleteFramebuffers(1, &targetFramebufferID));
532 OOGL(glDeleteFramebuffers(2, pingpongFBO));
533 OOGL(glDeleteFramebuffers(1, &passthroughFramebufferID));
534 OOGL(glDeleteVertexArrays(1, &quadTextureVAO));
535 OOGL(glDeleteBuffers(1, &quadTextureVBO));
536 OOGL(glDeleteBuffers(1, &quadTextureEBO));
537 [textureProgram release];
538 [blurProgram release];
539 [finalProgram release];
540}
#define OOGL(statement)
Definition OOOpenGL.h:251

◆ demoShipData

- (NSDictionary *) demoShipData

Extends class Universe.

Definition at line 273 of file Universe.m.

3291{
3292 return [[demo_ships oo_arrayAtIndex:demo_ship_index] oo_dictionaryAtIndex:demo_ship_subindex];
3293}

◆ doRemoveEntity:

- (BOOL) doRemoveEntity: (Entity *) entity

Extends class Universe.

Definition at line 9471 of file Universe.m.

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

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

◆ fractionalPositionFrom:to:withFraction:

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

Extends class Universe.

Definition at line 9471 of file Universe.m.

10566 :(HPVector)point0 to:(HPVector)point1 withFraction:(double)routeFraction
10567{
10568 if (routeFraction == NSNotFound) routeFraction = randf();
10569
10570 point1 = OOHPVectorInterpolate(point0, point1, routeFraction);
10571
10572 point1.x += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10573 point1.y += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10574 point1.z += 2 * SCANNER_MAX_RANGE * (randf() - 0.5);
10575
10576 return point1;
10577}
#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.

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

8044{
8045 [_descriptions autorelease];
8046 _descriptions = [[ResourceManager dictionaryFromFilesNamed:@"descriptions.plist" inFolder:@"Config" andMerge:YES] retain];
8047 [self verifyDescriptions];
8048}
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

◆ loadScenarios

- (void) loadScenarios

Extends class Universe.

Definition at line 7996 of file Universe.m.

8064{
8065 [_scenarios autorelease];
8066 _scenarios = [[ResourceManager arrayFromFilesNamed:@"scenarios.plist" inFolder:@"Config" andMerge:YES] retain];
8067}
NSArray * arrayFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

◆ populateSpaceFromActiveWormholes

- (void) populateSpaceFromActiveWormholes

Extends class Universe.

Definition at line 10697 of file Universe.m.

10736{
10737 NSAutoreleasePool *pool = nil;
10738
10739 while ([activeWormholes count])
10740 {
10741 pool = [[NSAutoreleasePool alloc] init];
10742 @try
10743 {
10744 WormholeEntity* whole = [activeWormholes objectAtIndex:0];
10745 // If the wormhole has been scanned by the player then the
10746 // PlayerEntity will take care of it
10747 if (![whole isScanned] &&
10748 NSEqualPoints([PLAYER galaxy_coordinates], [whole destinationCoordinates]) )
10749 {
10750 // this is a wormhole to this system
10751 [whole disgorgeShips];
10752 }
10753 [activeWormholes removeObjectAtIndex:0]; // empty it out
10754 }
10755 @catch (NSException *exception)
10756 {
10757 OOLog(kOOLogException, @"Squashing exception during wormhole unpickling (%@: %@).", [exception name], [exception reason]);
10758 }
10759 [pool release];
10760 }
10761}
NSString *const kOOLogException
Definition OOLogging.m:651
#define PLAYER

◆ prepareToRenderIntoDefaultFramebuffer

- (void) prepareToRenderIntoDefaultFramebuffer

Extends class Universe.

Definition at line 4630 of file Universe.m.

5265{
5266 NSSize viewSize = [gameView viewSize];
5267 if([self useShaders])
5268 {
5269 if ([gameView msaa])
5270 {
5271 // resolve MSAA framebuffer to target framebuffer
5272 OOGL(glBindFramebuffer(GL_READ_FRAMEBUFFER, msaaFramebufferID));
5273 OOGL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFramebufferID));
5274 OOGL(glBlitFramebuffer(0, 0, (GLint)viewSize.width, (GLint)viewSize.height, 0, 0, (GLint)viewSize.width, (GLint)viewSize.height, GL_COLOR_BUFFER_BIT, GL_NEAREST));
5275 }
5276 }
5277}

◆ randomDistanceWithinScanner

- (float) randomDistanceWithinScanner

Extends class Universe.

Definition at line 9471 of file Universe.m.

10551{
10552 return SCANNER_MAX_RANGE * ((Ranrot() & 255) / 256.0 - 0.5);
10553}

◆ randomPlaceWithinScannerFrom:alongRoute:withOffset:

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

Extends class Universe.

Definition at line 9471 of file Universe.m.

10556 :(Vector)pos alongRoute:(Vector)route withOffset:(double)offset
10557{
10558 pos.x += offset * route.x + [self randomDistanceWithinScanner];
10559 pos.y += offset * route.y + [self randomDistanceWithinScanner];
10560 pos.z += offset * route.z + [self randomDistanceWithinScanner];
10561
10562 return pos;
10563}
return self
float y
float x
float randomDistanceWithinScanner()
Definition Universe.m:10550
voidpf uLong offset
Definition ioapi.h:140

◆ resizeTargetFramebufferWithViewSize:

- (void) resizeTargetFramebufferWithViewSize: (NSSize) viewSize

Extends class Universe.

Definition at line 273 of file Universe.m.

543 :(NSSize)viewSize
544{
545 int i;
546 // resize MSAA color attachment
547 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msaaTextureID));
548 OOGL(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, GL_TRUE));
549 OOGL(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
550
551 // resize MSAA depth attachment
552 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, msaaDepthBufferID));
553 OOGL(glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
554 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
555
556 // resize color attachments
557 OOGL(glBindTexture(GL_TEXTURE_2D, targetTextureID));
558 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
559 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
560
561 for (i = 0; i < 2; i++)
562 {
563 OOGL(glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]));
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
568 for (i = 0; i < 2; i++)
569 {
570 OOGL(glBindTexture(GL_TEXTURE_2D, passthroughTextureID[i]));
571 OOGL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL));
572 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
573 }
574
575 // resize depth attachment
576 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, targetDepthBufferID));
577 OOGL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, (GLsizei)viewSize.width, (GLsizei)viewSize.height));
578 OOGL(glBindRenderbuffer(GL_RENDERBUFFER, 0));
579
580 targetFramebufferSize.width = viewSize.width;
581 targetFramebufferSize.height = viewSize.height;
582}

◆ setDetailLevelDirectly:

- (void) setDetailLevelDirectly: (OOGraphicsDetail) value

Extends class Universe.

Definition at line 9471 of file Universe.m.

9994 :(OOGraphicsDetail)value
9995{
9996 if (value >= DETAIL_LEVEL_MAXIMUM)
9997 {
9998 value = DETAIL_LEVEL_MAXIMUM;
9999 }
10000 else if (value <= DETAIL_LEVEL_MINIMUM)
10001 {
10002 value = DETAIL_LEVEL_MINIMUM;
10003 }
10004 if (![[OOOpenGLExtensionManager sharedManager] shadersSupported])
10005 {
10006 value = DETAIL_LEVEL_MINIMUM;
10007 }
10008 detailLevel = value;
10009}
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 3616 of file Universe.m.

3746 :(Entity <OOBeaconEntity> *)beacon
3747{
3748 if (beacon != [self firstBeacon])
3749 {
3750 [beacon setPrevBeacon:nil];
3751 [beacon setNextBeacon:[self firstBeacon]];
3752 [[self firstBeacon] setPrevBeacon:beacon];
3753 [_firstBeacon release];
3754 _firstBeacon = [beacon weakRetain];
3755 }
3756}

◆ setLastBeacon:

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

Extends class Universe.

Definition at line 3616 of file Universe.m.

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

◆ setLibraryTextForDemoShip

- (void) setLibraryTextForDemoShip

Extends class Universe.

Definition at line 273 of file Universe.m.

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

10357{
10358 NSMutableDictionary *tmp = [[NSMutableDictionary alloc] initWithCapacity:[commodities count]];
10359 OOCommodityType type = nil;
10360 foreach (type, [commodities goods])
10361 {
10362 ShipEntity *container = [self newShipWithRole:@"oolite-template-cargopod"];
10363 [container setScanClass:CLASS_CARGO];
10364 [container setCommodity:type andAmount:1];
10365 [tmp setObject:container forKey:type];
10366 [container release];
10367 }
10368 [cargoPods release];
10369 cargoPods = [[NSDictionary alloc] initWithDictionary:tmp];
10370 [tmp release];
10371}
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 9471 of file Universe.m.

10518{
10519 PlayerEntity* player = PLAYER;
10520
10521 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Wormhole and character reset");
10522 if (activeWormholes) [activeWormholes autorelease];
10523 activeWormholes = [[NSMutableArray arrayWithCapacity:16] retain];
10524 if (characterPool) [characterPool autorelease];
10525 characterPool = [[NSMutableArray arrayWithCapacity:256] retain];
10527
10528 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Galaxy reset");
10529 [self setGalaxyTo: [player galaxyNumber] andReinit:YES];
10530 systemID = [player systemID];
10532
10533 OO_DEBUG_PUSH_PROGRESS(@"%@", @"Player init: setUpShipFromDictionary");
10534 [player setUpShipFromDictionary:[[OOShipRegistry sharedRegistry] shipInfoForKey:[player shipDataKey]]]; // the standard cobra at this point
10535 [player baseMass]; // bootstrap the base mass used in all fuel charge calculations.
10537
10538 // Player init above finishes initialising all standard player ship properties. Now that the base mass is set, we can run setUpSpace!
10539 [self setUpSpace];
10540
10541 [self setDockingClearanceProtocolActive:
10542 [[self currentSystemData] oo_boolForKey:@"stations_require_docking_clearance" defaultValue:YES]];
10543
10544 [self enterGUIViewModeWithMouseInteraction:NO];
10545 [player setPosition:[[self station] position]];
10546 [player setOrientation:kIdentityQuaternion];
10547}
#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 7996 of file Universe.m.

8019{
8020 /*
8021 Ensure that no descriptions.plist entries contain the %n format code,
8022 which can be used to smash the stack and potentially call arbitrary
8023 functions.
8024
8025 %n is deliberately not supported in Foundation/CoreFoundation under
8026 Mac OS X, but unfortunately GNUstep implements it.
8027 -- Ahruman 2011-05-05
8028 */
8029
8030 NSString *key = nil;
8031 if (_descriptions == nil)
8032 {
8033 OOLog(@"descriptions.verify", @"%@", @"***** FATAL: Tried to verify descriptions, but descriptions was nil - unable to load any descriptions.plist file.");
8034 exit(EXIT_FAILURE);
8035 }
8036 foreachkey (key, _descriptions)
8037 {
8038 VerifyDesc(key, [_descriptions objectForKey:key]);
8039 }
8040}
#define foreachkey(VAR, DICT)
Definition OOCocoa.h:366

◆ verifyEntitySessionIDs

- (void) verifyEntitySessionIDs

Extends class Universe.

Definition at line 9471 of file Universe.m.

10374{
10375#ifndef NDEBUG
10376 NSMutableArray *badEntities = nil;
10377 Entity *entity = nil;
10378
10379 unsigned i;
10380 for (i = 0; i < n_entities; i++)
10381 {
10382 entity = sortedEntities[i];
10383 if ([entity sessionID] != _sessionID)
10384 {
10385 OOLogERR(@"universe.sessionIDs.verify.failed", @"Invalid entity %@ (came from session %lu, current session is %lu).", [entity shortDescription], [entity sessionID], _sessionID);
10386 if (badEntities == nil) badEntities = [NSMutableArray array];
10387 [badEntities addObject:entity];
10388 }
10389 }
10390
10391 foreach (entity, badEntities)
10392 {
10393 [self removeEntity:entity];
10394 }
10395#endif
10396}

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