Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions | Variables
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 3883 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 11090 of file Universe.m.

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

◆ MaintainLinkedLists()

static BOOL MaintainLinkedLists ( Universe * uni)
static

◆ OOLookUpDescriptionPRIV()

NSString * OOLookUpDescriptionPRIV ( NSString * key)

Definition at line 11142 of file Universe.m.

11143{
11144 NSString *result = [UNIVERSE descriptionForKey:key];
11145 if (result == nil) result = key;
11146 return result;
11147}
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 11151 of file Universe.m.

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

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

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

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

4614 {{
4615 {-1.0f, 0.0f, 0.0f, 0.0f },
4616 { 0.0f, 1.0f, 0.0f, 0.0f },
4617 { 0.0f, 0.0f, -1.0f, 0.0f },
4618 { 0.0f, 0.0f, 0.0f, 1.0f }
4619 }};

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

4607 {{
4608 { 1.0f, 0.0f, 0.0f, 0.0f },
4609 { 0.0f, 1.0f, 0.0f, 0.0f },
4610 { 0.0f, 0.0f, 1.0f, 0.0f },
4611 { 0.0f, 0.0f, 0.0f, 1.0f }
4612 }};

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

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

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

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

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