Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
Universe.m File Reference
import "Universe.h"
import "MyOpenGLView.h"
import "GameController.h"
import "ResourceManager.h"
import "AI.h"
import "GuiDisplayGen.h"
import "HeadUpDisplay.h"
import "OOSound.h"
import "OOColor.h"
import "OOCacheManager.h"
import "OOStringExpander.h"
import "OOStringParsing.h"
import "OOCollectionExtractors.h"
import "OOConstToString.h"
import "OOOpenGLExtensionManager.h"
import "OOOpenGLMatrixManager.h"
import "OOCPUInfo.h"
import "OOMaterial.h"
import "OOTexture.h"
import "OORoleSet.h"
import "OOShipGroup.h"
import "OODebugSupport.h"
import "Octree.h"
import "CollisionRegion.h"
import "OOGraphicsResetManager.h"
import "OOEntityFilterPredicate.h"
import "OOCharacter.h"
import "OOShipRegistry.h"
import "OOProbabilitySet.h"
import "OOEquipmentType.h"
import "OOShipLibraryDescriptions.h"
import "PlayerEntity.h"
import "PlayerEntityContracts.h"
import "PlayerEntityControls.h"
import "PlayerEntityScriptMethods.h"
import "StationEntity.h"
import "DockEntity.h"
import "SkyEntity.h"
import "DustEntity.h"
import "OOPlanetEntity.h"
import "OOVisualEffectEntity.h"
import "OOWaypointEntity.h"
import "OOSunEntity.h"
import "WormholeEntity.h"
import "OOBreakPatternEntity.h"
import "ShipEntityAI.h"
import "ProxyPlayerEntity.h"
import "OORingEffectEntity.h"
import "OOLightParticleEntity.h"
import "OOFlashEffectEntity.h"
import "OOExplosionCloudEntity.h"
import "OOSystemDescriptionManager.h"
import "OOMusicController.h"
import "OOAsyncWorkManager.h"
import "OODebugFlags.h"
import "OODebugStandards.h"
import "OOLoggingExtended.h"
import "OOJSEngineTimeManagement.h"
import "OOJoystickManager.h"
import "OOScriptTimer.h"
import "OOJSScript.h"
import "OOJSFrameCallbacks.h"
import "OOJSPopulatorDefinition.h"
import "OOOpenGL.h"
import "OOShaderProgram.h"
import "OOConvertSystemDescriptions.h"
+ Include dependency graph for Universe.m:

Go to the source code of this file.

Classes

class  RouteElement
 
category  Universe(OOPrivate)
 

Macros

#define DEMO2_VANISHING_DISTANCE   650.0
 
#define DEMO2_FLY_IN_STAGE_TIME   0.4
 
#define MAX_NUMBER_OF_ENTITIES   200
 
#define STANDARD_STATION_ROLL   0.4
 
#define LANE_WIDTH   51200.0
 
#define DOCKED_AMBIENT_LEVEL   0.2f
 
#define DOCKED_ILLUM_LEVEL   0.7f
 
#define SUN_AMBIENT_INFLUENCE   0.75
 
#define SKY_AMBIENT_ADJUSTMENT   0.0625
 
#define PROFILE_SHIP_SELECTION   0
 

Enumerations

enum  { DEMO_FLY_IN = 101 , DEMO_SHOW_THING , DEMO_FLY_OUT }
 

Functions

static BOOL MaintainLinkedLists (Universe *uni)
 
OOINLINE BOOL EntityInRange (HPVector p1, Entity *e2, float range)
 
static OOComparisonResult compareName (id dict1, id dict2, void *context)
 
static OOComparisonResult comparePrice (id dict1, id dict2, void *context)
 
NSComparisonResult populatorPrioritySort (id a, id b, void *context)
 
NSComparisonResult equipmentSort (id a, id b, void *context)
 
NSComparisonResult equipmentSortOutfitting (id a, id b, void *context)
 
NSString * OOLookUpDescriptionPRIV (NSString *key)
 
NSString * OOLookUpPluralDescriptionPRIV (NSString *key, NSInteger count)
 

Variables

static NSString *const kOOLogUniversePopulateError = @"universe.populate.error"
 
static NSString *const kOOLogUniversePopulateWitchspace = @"universe.populate.witchspace"
 
static NSString *const kOOLogEntityVerificationError = @"entity.linkedList.verify.error"
 
static NSString *const kOOLogEntityVerificationRebuild = @"entity.linkedList.verify.rebuild"
 
const GLfloat framebufferQuadVertices []
 
const GLuint framebufferQuadIndices []
 
UniversegSharedUniverse = nil
 
EntitygOOJSPlayerIfStale = nil
 
static int JSResetFlags = 0
 
static BOOL object_light_on = NO
 
static BOOL demo_light_on = NO
 
static GLfloat sun_off [4] = {0.0, 0.0, 0.0, 1.0}
 
static GLfloat demo_light_position [4] = { DEMO_LIGHT_POSITION, 1.0 }
 
static GLfloat docked_light_ambient [4] = { DOCKED_AMBIENT_LEVEL, DOCKED_AMBIENT_LEVEL, DOCKED_AMBIENT_LEVEL, 1.0f }
 
static GLfloat docked_light_diffuse [4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, 1.0f }
 
static GLfloat docked_light_specular [4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL * 0.75f, (GLfloat) 1.0f }
 
static const OOMatrix fwd_matrix
 
static const OOMatrix aft_matrix
 
static const OOMatrix port_matrix
 
static const OOMatrix starboard_matrix
 

Macro Definition Documentation

◆ DEMO2_FLY_IN_STAGE_TIME

#define DEMO2_FLY_IN_STAGE_TIME   0.4

Definition at line 113 of file Universe.m.

◆ DEMO2_VANISHING_DISTANCE

#define DEMO2_VANISHING_DISTANCE   650.0

Definition at line 112 of file Universe.m.

◆ DOCKED_AMBIENT_LEVEL

#define DOCKED_AMBIENT_LEVEL   0.2f

Definition at line 269 of file Universe.m.

◆ DOCKED_ILLUM_LEVEL

#define DOCKED_ILLUM_LEVEL   0.7f

Definition at line 270 of file Universe.m.

Referenced by Universe::addShipAt:withRole:withinRadius:.

◆ LANE_WIDTH

#define LANE_WIDTH   51200.0

Definition at line 119 of file Universe.m.

◆ MAX_NUMBER_OF_ENTITIES

#define MAX_NUMBER_OF_ENTITIES   200

Definition at line 116 of file Universe.m.

◆ PROFILE_SHIP_SELECTION

#define PROFILE_SHIP_SELECTION   0

Definition at line 3897 of file Universe.m.

◆ SKY_AMBIENT_ADJUSTMENT

#define SKY_AMBIENT_ADJUSTMENT   0.0625

Definition at line 279 of file Universe.m.

◆ STANDARD_STATION_ROLL

#define STANDARD_STATION_ROLL   0.4

Definition at line 117 of file Universe.m.

◆ SUN_AMBIENT_INFLUENCE

#define SUN_AMBIENT_INFLUENCE   0.75

Definition at line 277 of file Universe.m.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DEMO_FLY_IN 
DEMO_SHOW_THING 
DEMO_FLY_OUT 

Definition at line 105 of file Universe.m.

106{
107 DEMO_FLY_IN = 101,
110};
@ DEMO_FLY_IN
Definition Universe.m:107
@ DEMO_FLY_OUT
Definition Universe.m:109
@ DEMO_SHOW_THING
Definition Universe.m:108

Function Documentation

◆ compareName()

static OOComparisonResult compareName ( id dict1,
id dict2,
void * context )
static

◆ comparePrice()

static OOComparisonResult comparePrice ( id dict1,
id dict2,
void * context )
static

Referenced by Universe::compareName.

+ Here is the caller graph for this function:

◆ EntityInRange()

OOINLINE BOOL EntityInRange ( HPVector p1,
Entity * e2,
float range )

◆ equipmentSort()

NSComparisonResult equipmentSort ( id a,
id b,
void * context )

Definition at line 11116 of file Universe.m.

11117{
11118 NSArray *one = (NSArray *)a;
11119 NSArray *two = (NSArray *)b;
11120
11121 /* Sort by explicit sort_order, then tech level, then price */
11122
11123 OOCreditsQuantity comp1 = [[one oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
11124 OOCreditsQuantity comp2 = [[two oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
11125 if (comp1 < comp2) return NSOrderedAscending;
11126 if (comp1 > comp2) return NSOrderedDescending;
11127
11128 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11129 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11130 if (comp1 < comp2) return NSOrderedAscending;
11131 if (comp1 > comp2) return NSOrderedDescending;
11132
11133 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11134 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11135 if (comp1 < comp2) return NSOrderedAscending;
11136 if (comp1 > comp2) return NSOrderedDescending;
11137
11138 return NSOrderedSame;
11139}
uint64_t OOCreditsQuantity
Definition OOTypes.h:182
@ EQUIPMENT_TECH_LEVEL_INDEX
Definition Universe.h:79
@ EQUIPMENT_PRICE_INDEX
Definition Universe.h:80
@ EQUIPMENT_EXTRA_INFO_INDEX
Definition Universe.h:84

◆ equipmentSortOutfitting()

NSComparisonResult equipmentSortOutfitting ( id a,
id b,
void * context )

Definition at line 11142 of file Universe.m.

11143{
11144 NSArray *one = (NSArray *)a;
11145 NSArray *two = (NSArray *)b;
11146
11147 /* Sort by explicit sort_order, then tech level, then price */
11148
11149 OOCreditsQuantity comp1 = [[one oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"purchase_sort_order" defaultValue:[[one oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000]];
11150 OOCreditsQuantity comp2 = [[two oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"purchase_sort_order" defaultValue:[[two oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000]];
11151 if (comp1 < comp2) return NSOrderedAscending;
11152 if (comp1 > comp2) return NSOrderedDescending;
11153
11154 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11155 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11156 if (comp1 < comp2) return NSOrderedAscending;
11157 if (comp1 > comp2) return NSOrderedDescending;
11158
11159 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11160 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11161 if (comp1 < comp2) return NSOrderedAscending;
11162 if (comp1 > comp2) return NSOrderedDescending;
11163
11164 return NSOrderedSame;
11165}

◆ MaintainLinkedLists()

static BOOL MaintainLinkedLists ( Universe * uni)
static

◆ OOLookUpDescriptionPRIV()

NSString * OOLookUpDescriptionPRIV ( NSString * key)

Definition at line 11168 of file Universe.m.

11169{
11170 NSString *result = [UNIVERSE descriptionForKey:key];
11171 if (result == nil) result = key;
11172 return result;
11173}
return nil
#define UNIVERSE
Definition Universe.h:840

References nil.

Referenced by OOLookUpPluralDescriptionPRIV().

+ Here is the caller graph for this function:

◆ OOLookUpPluralDescriptionPRIV()

NSString * OOLookUpPluralDescriptionPRIV ( NSString * key,
NSInteger count )

Definition at line 11177 of file Universe.m.

11178{
11179 NSArray *conditions = [[UNIVERSE descriptions] oo_arrayForKey:@"plural-rules"];
11180
11181 // are we using an older descriptions.plist (1.72.x) ?
11182 NSString *tmp = [UNIVERSE descriptionForKey:key];
11183 if (tmp != nil)
11184 {
11185 static NSMutableSet *warned = nil;
11186
11187 if (![warned containsObject:tmp])
11188 {
11189 OOLogWARN(@"localization.plurals", @"'%@' found in descriptions.plist, should be '%@%%0'. Localization data needs updating.",key,key);
11190 if (warned == nil) warned = [[NSMutableSet alloc] init];
11191 [warned addObject:tmp];
11192 }
11193 }
11194
11195 if (conditions == nil)
11196 {
11197 if (tmp == nil) // this should mean that descriptions.plist is from 1.73 or above.
11198 return OOLookUpDescriptionPRIV([NSString stringWithFormat:@"%@%%%d", key, count != 1]);
11199 // still using an older descriptions.plist
11200 return tmp;
11201 }
11202 int unsigned i;
11203 long int index;
11204
11205 for (index = i = 0; i < [conditions count]; ++index, ++i)
11206 {
11207 const char *cond = [[conditions oo_stringAtIndex:i] UTF8String];
11208 if (!cond)
11209 break;
11210
11211 long int input = count;
11212 BOOL flag = NO; // we XOR test results with this
11213
11214 while (isspace (*cond))
11215 ++cond;
11216
11217 for (;;)
11218 {
11219 while (isspace (*cond))
11220 ++cond;
11221
11222 char command = *cond++;
11223
11224 switch (command)
11225 {
11226 case 0:
11227 goto passed; // end of string
11228
11229 case '~':
11230 flag = !flag;
11231 continue;
11232 }
11233
11234 long int param = strtol(cond, (char **)&cond, 10);
11235
11236 switch (command)
11237 {
11238 case '#':
11239 index = param;
11240 continue;
11241
11242 case '%':
11243 if (param < 2)
11244 break; // ouch - fail this!
11245 input %= param;
11246 continue;
11247
11248 case '=':
11249 if (flag ^ (input == param))
11250 continue;
11251 break;
11252 case '!':
11253 if (flag ^ (input != param))
11254 continue;
11255 break;
11256
11257 case '<':
11258 if (flag ^ (input < param))
11259 continue;
11260 break;
11261 case '>':
11262 if (flag ^ (input > param))
11263 continue;
11264 break;
11265 }
11266 // if we arrive here, we have an unknown test or a test has failed
11267 break;
11268 }
11269 }
11270
11271passed:
11272 return OOLookUpDescriptionPRIV([NSString stringWithFormat:@"%@%%%ld", key, index]);
11273}
#define OOLogWARN(class, format,...)
Definition OOLogging.h:113
unsigned count
NSString * OOLookUpDescriptionPRIV(NSString *key)
Definition Universe.m:11168

References count, nil, OOLogWARN, and OOLookUpDescriptionPRIV().

+ Here is the call graph for this function:

◆ populatorPrioritySort()

NSComparisonResult populatorPrioritySort ( id a,
id b,
void * context )

Definition at line 11104 of file Universe.m.

11105{
11106 NSDictionary *one = (NSDictionary *)a;
11107 NSDictionary *two = (NSDictionary *)b;
11108 int pri_one = [one oo_intForKey:@"priority" defaultValue:100];
11109 int pri_two = [two oo_intForKey:@"priority" defaultValue:100];
11110 if (pri_one < pri_two) return NSOrderedAscending;
11111 if (pri_one > pri_two) return NSOrderedDescending;
11112 return NSOrderedSame;
11113}

Variable Documentation

◆ aft_matrix

const OOMatrix aft_matrix
static
Initial value:
=
{{
{-1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, -1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
}}

Definition at line 4627 of file Universe.m.

4628 {{
4629 {-1.0f, 0.0f, 0.0f, 0.0f },
4630 { 0.0f, 1.0f, 0.0f, 0.0f },
4631 { 0.0f, 0.0f, -1.0f, 0.0f },
4632 { 0.0f, 0.0f, 0.0f, 1.0f }
4633 }};

◆ demo_light_on

BOOL demo_light_on = NO
static

Definition at line 265 of file Universe.m.

◆ demo_light_position

GLfloat demo_light_position[4] = { DEMO_LIGHT_POSITION, 1.0 }
static

Definition at line 267 of file Universe.m.

267{ DEMO_LIGHT_POSITION, 1.0 };
#define DEMO_LIGHT_POSITION
Definition Universe.h:169

◆ docked_light_ambient

GLfloat docked_light_ambient[4] = { DOCKED_AMBIENT_LEVEL, DOCKED_AMBIENT_LEVEL, DOCKED_AMBIENT_LEVEL, 1.0f }
static

Definition at line 271 of file Universe.m.

◆ docked_light_diffuse

GLfloat docked_light_diffuse[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, 1.0f }
static

Definition at line 272 of file Universe.m.

#define DOCKED_ILLUM_LEVEL
Definition Universe.m:270

◆ docked_light_specular

GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL * 0.75f, (GLfloat) 1.0f }
static

Definition at line 273 of file Universe.m.

273{ DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL * 0.75f, (GLfloat) 1.0f }; // yellow-white

◆ framebufferQuadIndices

const GLuint framebufferQuadIndices[]
Initial value:
= {
0, 1, 3,
1, 2, 3
}

Definition at line 135 of file Universe.m.

135 {
136 0, 1, 3, // first triangle
137 1, 2, 3 // second triangle
138};

◆ framebufferQuadVertices

const GLfloat framebufferQuadVertices[]
Initial value:
= {
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, -1.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f
}

Definition at line 128 of file Universe.m.

128 {
129 // positions // texture coords
130 1.0f, 1.0f, 1.0f, 1.0f, // top right
131 1.0f, -1.0f, 1.0f, 0.0f, // bottom right
132 -1.0f, -1.0f, 0.0f, 0.0f, // bottom left
133 -1.0f, 1.0f, 0.0f, 1.0f // top left
134};

◆ fwd_matrix

const OOMatrix fwd_matrix
static
Initial value:
=
{{
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
}}

Definition at line 4620 of file Universe.m.

4621 {{
4622 { 1.0f, 0.0f, 0.0f, 0.0f },
4623 { 0.0f, 1.0f, 0.0f, 0.0f },
4624 { 0.0f, 0.0f, 1.0f, 0.0f },
4625 { 0.0f, 0.0f, 0.0f, 1.0f }
4626 }};

◆ gOOJSPlayerIfStale

Entity * gOOJSPlayerIfStale = nil

Definition at line 144 of file Universe.m.

Referenced by OOIsPlayerStale(), and OOIsStaleEntity().

◆ gSharedUniverse

Universe* gSharedUniverse = nil

Definition at line 141 of file Universe.m.

Referenced by OOGetUniverse().

◆ JSResetFlags

int JSResetFlags = 0
static

Definition at line 260 of file Universe.m.

◆ kOOLogEntityVerificationError

NSString* const kOOLogEntityVerificationError = @"entity.linkedList.verify.error"
static

Definition at line 123 of file Universe.m.

Referenced by Universe::addEntity:.

◆ kOOLogEntityVerificationRebuild

NSString* const kOOLogEntityVerificationRebuild = @"entity.linkedList.verify.rebuild"
static

Definition at line 124 of file Universe.m.

Referenced by Universe::addEntity:.

◆ kOOLogUniversePopulateError

NSString* const kOOLogUniversePopulateError = @"universe.populate.error"
static

Definition at line 121 of file Universe.m.

◆ kOOLogUniversePopulateWitchspace

NSString* const kOOLogUniversePopulateWitchspace = @"universe.populate.witchspace"
static

Definition at line 122 of file Universe.m.

◆ object_light_on

BOOL object_light_on = NO
static

Definition at line 264 of file Universe.m.

◆ port_matrix

const OOMatrix port_matrix
static
Initial value:
=
{{
{ 0.0f, 0.0f, -1.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
}}

Definition at line 4634 of file Universe.m.

4635 {{
4636 { 0.0f, 0.0f, -1.0f, 0.0f },
4637 { 0.0f, 1.0f, 0.0f, 0.0f },
4638 { 1.0f, 0.0f, 0.0f, 0.0f },
4639 { 0.0f, 0.0f, 0.0f, 1.0f }
4640 }};

◆ starboard_matrix

const OOMatrix starboard_matrix
static
Initial value:
=
{{
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{-1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
}}

Definition at line 4641 of file Universe.m.

4642 {{
4643 { 0.0f, 0.0f, 1.0f, 0.0f },
4644 { 0.0f, 1.0f, 0.0f, 0.0f },
4645 {-1.0f, 0.0f, 0.0f, 0.0f },
4646 { 0.0f, 0.0f, 0.0f, 1.0f }
4647 }};

◆ sun_off

GLfloat sun_off[4] = {0.0, 0.0, 0.0, 1.0}
static

Definition at line 266 of file Universe.m.

266{0.0, 0.0, 0.0, 1.0};