Oolite
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 "OOConstToJSString.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 110 of file Universe.m.

◆ DEMO2_VANISHING_DISTANCE

#define DEMO2_VANISHING_DISTANCE   650.0

Definition at line 109 of file Universe.m.

◆ DOCKED_AMBIENT_LEVEL

#define DOCKED_AMBIENT_LEVEL   0.2f

Definition at line 266 of file Universe.m.

◆ DOCKED_ILLUM_LEVEL

#define DOCKED_ILLUM_LEVEL   0.7f

Definition at line 267 of file Universe.m.

◆ LANE_WIDTH

#define LANE_WIDTH   51200.0

Definition at line 116 of file Universe.m.

◆ MAX_NUMBER_OF_ENTITIES

#define MAX_NUMBER_OF_ENTITIES   200

Definition at line 113 of file Universe.m.

◆ PROFILE_SHIP_SELECTION

#define PROFILE_SHIP_SELECTION   0

Definition at line 3907 of file Universe.m.

◆ SKY_AMBIENT_ADJUSTMENT

#define SKY_AMBIENT_ADJUSTMENT   0.0625

Definition at line 276 of file Universe.m.

◆ STANDARD_STATION_ROLL

#define STANDARD_STATION_ROLL   0.4

Definition at line 114 of file Universe.m.

◆ SUN_AMBIENT_INFLUENCE

#define SUN_AMBIENT_INFLUENCE   0.75

Definition at line 274 of file Universe.m.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DEMO_FLY_IN 
DEMO_SHOW_THING 
DEMO_FLY_OUT 

Definition at line 102 of file Universe.m.

103{
104 DEMO_FLY_IN = 101,
107};
@ DEMO_FLY_IN
Definition Universe.m:104
@ DEMO_FLY_OUT
Definition Universe.m:106
@ DEMO_SHOW_THING
Definition Universe.m:105

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

11149{
11150 NSArray *one = (NSArray *)a;
11151 NSArray *two = (NSArray *)b;
11152
11153 /* Sort by explicit sort_order, then tech level, then price */
11154
11155 OOCreditsQuantity comp1 = [[one oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
11156 OOCreditsQuantity comp2 = [[two oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] oo_unsignedLongLongForKey:@"sort_order" defaultValue:1000];
11157 if (comp1 < comp2) return NSOrderedAscending;
11158 if (comp1 > comp2) return NSOrderedDescending;
11159
11160 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11161 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11162 if (comp1 < comp2) return NSOrderedAscending;
11163 if (comp1 > comp2) return NSOrderedDescending;
11164
11165 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11166 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11167 if (comp1 < comp2) return NSOrderedAscending;
11168 if (comp1 > comp2) return NSOrderedDescending;
11169
11170 return NSOrderedSame;
11171}
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 11174 of file Universe.m.

11175{
11176 NSArray *one = (NSArray *)a;
11177 NSArray *two = (NSArray *)b;
11178
11179 /* Sort by explicit sort_order, then tech level, then price */
11180
11181 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]];
11182 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]];
11183 if (comp1 < comp2) return NSOrderedAscending;
11184 if (comp1 > comp2) return NSOrderedDescending;
11185
11186 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11187 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_TECH_LEVEL_INDEX];
11188 if (comp1 < comp2) return NSOrderedAscending;
11189 if (comp1 > comp2) return NSOrderedDescending;
11190
11191 comp1 = [one oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11192 comp2 = [two oo_unsignedLongLongAtIndex:EQUIPMENT_PRICE_INDEX];
11193 if (comp1 < comp2) return NSOrderedAscending;
11194 if (comp1 > comp2) return NSOrderedDescending;
11195
11196 return NSOrderedSame;
11197}

◆ MaintainLinkedLists()

static BOOL MaintainLinkedLists ( Universe uni)
static

◆ OOLookUpDescriptionPRIV()

NSString * OOLookUpDescriptionPRIV ( NSString *  key)

Definition at line 11200 of file Universe.m.

11201{
11202 NSString *result = [UNIVERSE descriptionForKey:key];
11203 if (result == nil) result = key;
11204 return result;
11205}
return nil
#define UNIVERSE
Definition Universe.h:842

References nil.

Referenced by OOLookUpPluralDescriptionPRIV().

+ Here is the caller graph for this function:

◆ OOLookUpPluralDescriptionPRIV()

NSString * OOLookUpPluralDescriptionPRIV ( NSString *  key,
NSInteger  count 
)

Definition at line 11209 of file Universe.m.

11210{
11211 NSArray *conditions = [[UNIVERSE descriptions] oo_arrayForKey:@"plural-rules"];
11212
11213 // are we using an older descriptions.plist (1.72.x) ?
11214 NSString *tmp = [UNIVERSE descriptionForKey:key];
11215 if (tmp != nil)
11216 {
11217 static NSMutableSet *warned = nil;
11218
11219 if (![warned containsObject:tmp])
11220 {
11221 OOLogWARN(@"localization.plurals", @"'%@' found in descriptions.plist, should be '%@%%0'. Localization data needs updating.",key,key);
11222 if (warned == nil) warned = [[NSMutableSet alloc] init];
11223 [warned addObject:tmp];
11224 }
11225 }
11226
11227 if (conditions == nil)
11228 {
11229 if (tmp == nil) // this should mean that descriptions.plist is from 1.73 or above.
11230 return OOLookUpDescriptionPRIV([NSString stringWithFormat:@"%@%%%d", key, count != 1]);
11231 // still using an older descriptions.plist
11232 return tmp;
11233 }
11234 int unsigned i;
11235 long int index;
11236
11237 for (index = i = 0; i < [conditions count]; ++index, ++i)
11238 {
11239 const char *cond = [[conditions oo_stringAtIndex:i] UTF8String];
11240 if (!cond)
11241 break;
11242
11243 long int input = count;
11244 BOOL flag = NO; // we XOR test results with this
11245
11246 while (isspace (*cond))
11247 ++cond;
11248
11249 for (;;)
11250 {
11251 while (isspace (*cond))
11252 ++cond;
11253
11254 char command = *cond++;
11255
11256 switch (command)
11257 {
11258 case 0:
11259 goto passed; // end of string
11260
11261 case '~':
11262 flag = !flag;
11263 continue;
11264 }
11265
11266 long int param = strtol(cond, (char **)&cond, 10);
11267
11268 switch (command)
11269 {
11270 case '#':
11271 index = param;
11272 continue;
11273
11274 case '%':
11275 if (param < 2)
11276 break; // ouch - fail this!
11277 input %= param;
11278 continue;
11279
11280 case '=':
11281 if (flag ^ (input == param))
11282 continue;
11283 break;
11284 case '!':
11285 if (flag ^ (input != param))
11286 continue;
11287 break;
11288
11289 case '<':
11290 if (flag ^ (input < param))
11291 continue;
11292 break;
11293 case '>':
11294 if (flag ^ (input > param))
11295 continue;
11296 break;
11297 }
11298 // if we arrive here, we have an unknown test or a test has failed
11299 break;
11300 }
11301 }
11302
11303passed:
11304 return OOLookUpDescriptionPRIV([NSString stringWithFormat:@"%@%%%ld", key, index]);
11305}
#define OOLogWARN(class, format,...)
Definition OOLogging.h:113
unsigned count
NSString * OOLookUpDescriptionPRIV(NSString *key)
Definition Universe.m:11200

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

11137{
11138 NSDictionary *one = (NSDictionary *)a;
11139 NSDictionary *two = (NSDictionary *)b;
11140 int pri_one = [one oo_intForKey:@"priority" defaultValue:100];
11141 int pri_two = [two oo_intForKey:@"priority" defaultValue:100];
11142 if (pri_one < pri_two) return NSOrderedAscending;
11143 if (pri_one > pri_two) return NSOrderedDescending;
11144 return NSOrderedSame;
11145}

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

4638 {{
4639 {-1.0f, 0.0f, 0.0f, 0.0f },
4640 { 0.0f, 1.0f, 0.0f, 0.0f },
4641 { 0.0f, 0.0f, -1.0f, 0.0f },
4642 { 0.0f, 0.0f, 0.0f, 1.0f }
4643 }};

◆ demo_light_on

BOOL demo_light_on = NO
static

Definition at line 262 of file Universe.m.

◆ demo_light_position

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

Definition at line 264 of file Universe.m.

264{ 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 268 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 269 of file Universe.m.

#define DOCKED_ILLUM_LEVEL
Definition Universe.m:267

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

270{ 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 132 of file Universe.m.

132 {
133 0, 1, 3, // first triangle
134 1, 2, 3 // second triangle
135};

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

125 {
126 // positions // texture coords
127 1.0f, 1.0f, 1.0f, 1.0f, // top right
128 1.0f, -1.0f, 1.0f, 0.0f, // bottom right
129 -1.0f, -1.0f, 0.0f, 0.0f, // bottom left
130 -1.0f, 1.0f, 0.0f, 1.0f // top left
131};

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

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

◆ gOOJSPlayerIfStale

Entity * gOOJSPlayerIfStale = nil

Definition at line 141 of file Universe.m.

Referenced by OOIsPlayerStale(), and OOIsStaleEntity().

◆ gSharedUniverse

Universe* gSharedUniverse = nil

Definition at line 138 of file Universe.m.

Referenced by OOGetUniverse().

◆ JSResetFlags

int JSResetFlags = 0
static

Definition at line 257 of file Universe.m.

◆ kOOLogEntityVerificationError

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

Definition at line 120 of file Universe.m.

Referenced by Universe::addEntity:.

◆ kOOLogEntityVerificationRebuild

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

Definition at line 121 of file Universe.m.

Referenced by Universe::addEntity:.

◆ kOOLogUniversePopulateError

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

Definition at line 118 of file Universe.m.

◆ kOOLogUniversePopulateWitchspace

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

Definition at line 119 of file Universe.m.

◆ object_light_on

BOOL object_light_on = NO
static

Definition at line 261 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 4644 of file Universe.m.

4645 {{
4646 { 0.0f, 0.0f, -1.0f, 0.0f },
4647 { 0.0f, 1.0f, 0.0f, 0.0f },
4648 { 1.0f, 0.0f, 0.0f, 0.0f },
4649 { 0.0f, 0.0f, 0.0f, 1.0f }
4650 }};

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

4652 {{
4653 { 0.0f, 0.0f, 1.0f, 0.0f },
4654 { 0.0f, 1.0f, 0.0f, 0.0f },
4655 {-1.0f, 0.0f, 0.0f, 0.0f },
4656 { 0.0f, 0.0f, 0.0f, 1.0f }
4657 }};

◆ sun_off

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

Definition at line 263 of file Universe.m.

263{0.0, 0.0, 0.0, 1.0};