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

11094{
11095 NSArray *one = (NSArray *)a;
11096 NSArray *two = (NSArray *)b;
11097
11098 /* Sort by explicit sort_order, then tech level, then price */
11099
11100 OOCreditsQuantity comp1 = [[one oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
11101 OOCreditsQuantity comp2 = [[two oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
11102 if (comp1 < comp2) return NSOrderedAscending;
11103 if (comp1 > comp2) return NSOrderedDescending;
11104
11105 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11106 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11107 if (comp1 < comp2) return NSOrderedAscending;
11108 if (comp1 > comp2) return NSOrderedDescending;
11109
11110 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11111 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11112 if (comp1 < comp2) return NSOrderedAscending;
11113 if (comp1 > comp2) return NSOrderedDescending;
11114
11115 return NSOrderedSame;
11116}
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 11119 of file Universe.m.

11120{
11121 NSArray *one = (NSArray *)a;
11122 NSArray *two = (NSArray *)b;
11123
11124 /* Sort by explicit sort_order, then tech level, then price */
11125
11126 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]];
11127 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]];
11128 if (comp1 < comp2) return NSOrderedAscending;
11129 if (comp1 > comp2) return NSOrderedDescending;
11130
11131 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11132 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11133 if (comp1 < comp2) return NSOrderedAscending;
11134 if (comp1 > comp2) return NSOrderedDescending;
11135
11136 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11137 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11138 if (comp1 < comp2) return NSOrderedAscending;
11139 if (comp1 > comp2) return NSOrderedDescending;
11140
11141 return NSOrderedSame;
11142}

◆ MaintainLinkedLists()

static BOOL MaintainLinkedLists ( Universe * uni)
static

◆ OOLookUpDescriptionPRIV()

NSString * OOLookUpDescriptionPRIV ( NSString * key)

Definition at line 11145 of file Universe.m.

11146{
11147 NSString *result = [UNIVERSE descriptionForKey:key];
11148 if (result == nil) result = key;
11149 return result;
11150}
return nil
#define UNIVERSE
Definition Universe.h:833

References nil.

Referenced by OOLookUpPluralDescriptionPRIV().

+ Here is the caller graph for this function:

◆ OOLookUpPluralDescriptionPRIV()

NSString * OOLookUpPluralDescriptionPRIV ( NSString * key,
NSInteger count )

Definition at line 11154 of file Universe.m.

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

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

11082{
11083 NSDictionary *one = (NSDictionary *)a;
11084 NSDictionary *two = (NSDictionary *)b;
11085 int pri_one = [one oo_intForKey:@"priority" defaultValue:100];
11086 int pri_two = [two oo_intForKey:@"priority" defaultValue:100];
11087 if (pri_one < pri_two) return NSOrderedAscending;
11088 if (pri_one > pri_two) return NSOrderedDescending;
11089 return NSOrderedSame;
11090}

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

4617 {{
4618 {-1.0f, 0.0f, 0.0f, 0.0f },
4619 { 0.0f, 1.0f, 0.0f, 0.0f },
4620 { 0.0f, 0.0f, -1.0f, 0.0f },
4621 { 0.0f, 0.0f, 0.0f, 1.0f }
4622 }};

◆ 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:168

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

4610 {{
4611 { 1.0f, 0.0f, 0.0f, 0.0f },
4612 { 0.0f, 1.0f, 0.0f, 0.0f },
4613 { 0.0f, 0.0f, 1.0f, 0.0f },
4614 { 0.0f, 0.0f, 0.0f, 1.0f }
4615 }};

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

4624 {{
4625 { 0.0f, 0.0f, -1.0f, 0.0f },
4626 { 0.0f, 1.0f, 0.0f, 0.0f },
4627 { 1.0f, 0.0f, 0.0f, 0.0f },
4628 { 0.0f, 0.0f, 0.0f, 1.0f }
4629 }};

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

4631 {{
4632 { 0.0f, 0.0f, 1.0f, 0.0f },
4633 { 0.0f, 1.0f, 0.0f, 0.0f },
4634 {-1.0f, 0.0f, 0.0f, 0.0f },
4635 { 0.0f, 0.0f, 0.0f, 1.0f }
4636 }};

◆ 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};