Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOSystemDescriptionManager(OOPrivate) Category Reference

Instance Methods

(void) - setProperties:inDescription:
 
(NSDictionary *) - calculatePropertiesForSystemKey:
 
(void) - updateCacheEntry:
 
(void) - updateCacheEntry:forProperty:
 
(id) - getProperty:forSystemKey:withUniversal:
 
(id) - getProperty:orProperty:forSystemKey:withUniversal:
 
(void) - saveScriptedChangeToProperty:forSystemKey:andLayer:toValue:fromManifest:
 

Detailed Description

Definition at line 43 of file OOSystemDescriptionManager.m.

Method Documentation

◆ calculatePropertiesForSystemKey:

- (NSDictionary *) calculatePropertiesForSystemKey: (NSString *) key

Extends class OOSystemDescriptionManager.

Definition at line 58 of file OOSystemDescriptionManager.m.

503 :(NSString *)key
504{
505 NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:OO_LIKELY_PROPERTIES_PER_SYSTEM];
506 NSString *property = nil;
507 id val = nil;
508 BOOL interstellar = [key hasPrefix:@"interstellar:"];
509 foreach (property, propertiesInUse)
510 {
511 // don't use universal properties on interstellar specific regions
512 val = [self getProperty:property forSystemKey:key withUniversal:!interstellar];
513
514 if (val != nil)
515 {
516 [dict setObject:val forKey:property];
517 }
518 else if (interstellar)
519 {
520 // interstellar is always overridden by specific regions
521 // universal properties for interstellar get picked up here
522 val = [self getProperty:property forSystemKey:@"interstellar"];
523 if (val != nil)
524 {
525 [dict setObject:val forKey:property];
526 }
527 }
528 }
529 return dict;
530}
return nil

◆ getProperty:forSystemKey:withUniversal:

- (id) getProperty: (NSString *) property
forSystemKey: (NSString *) key
withUniversal: (BOOL) universal 

Extends class OOSystemDescriptionManager.

Definition at line 58 of file OOSystemDescriptionManager.m.

394 :(NSString *)property forSystemKey:(NSString *)key withUniversal:(BOOL)universal
395{
397 if (EXPECT_NOT([key isEqualToString:@"interstellar"]))
398 {
399 desc = interstellarSpace;
400 }
401 else
402 {
403 desc = [systemDescriptions objectForKey:key];
404 }
405 if (desc == nil)
406 {
407 return nil;
408 }
409 id result = nil;
410 result = [desc getProperty:property forLayer:OO_LAYER_OXP_PRIORITY];
411 if (result == nil)
412 {
413 result = [desc getProperty:property forLayer:OO_LAYER_OXP_DYNAMIC];
414 }
415 if (result == nil)
416 {
417 result = [desc getProperty:property forLayer:OO_LAYER_OXP_STATIC];
418 }
419 if (result == nil && universal)
420 {
421 result = [universalProperties objectForKey:property];
422 }
423 if (result == nil)
424 {
425 result = [desc getProperty:property forLayer:OO_LAYER_CORE];
426 }
427 return result;
428}
#define EXPECT_NOT(x)
id getProperty:forLayer:(NSString *property,[forLayer] OOSystemLayer layer)

◆ getProperty:orProperty:forSystemKey:withUniversal:

- (id) getProperty: (NSString *) property1
orProperty: (NSString *) property2
forSystemKey: (NSString *) key
withUniversal: (BOOL) universal 

Extends class OOSystemDescriptionManager.

Definition at line 58 of file OOSystemDescriptionManager.m.

431 :(NSString *)property1 orProperty:(NSString *)property2 forSystemKey:(NSString *)key withUniversal:(BOOL)universal
432{
433 OOSystemDescriptionEntry *desc = [systemDescriptions objectForKey:key];
434 if (desc == nil)
435 {
436 return nil;
437 }
438 id result = nil;
439 result = [desc getProperty:property1 forLayer:OO_LAYER_OXP_PRIORITY];
440 if (result == nil)
441 {
442 result = [desc getProperty:property2 forLayer:OO_LAYER_OXP_PRIORITY];
443 }
444 if (result == nil)
445 {
446 result = [desc getProperty:property1 forLayer:OO_LAYER_OXP_DYNAMIC];
447 }
448 if (result == nil)
449 {
450 result = [desc getProperty:property2 forLayer:OO_LAYER_OXP_DYNAMIC];
451 }
452 if (result == nil)
453 {
454 result = [desc getProperty:property1 forLayer:OO_LAYER_OXP_STATIC];
455 }
456 if (result == nil)
457 {
458 result = [desc getProperty:property2 forLayer:OO_LAYER_OXP_STATIC];
459 }
460 if (universal)
461 {
462 if (result == nil)
463 {
464 result = [universalProperties objectForKey:property1];
465 }
466 if (result == nil)
467 {
468 result = [universalProperties objectForKey:property2];
469 }
470 }
471 if (result == nil)
472 {
473 result = [desc getProperty:property1 forLayer:OO_LAYER_CORE];
474 }
475 if (result == nil)
476 {
477 result = [desc getProperty:property2 forLayer:OO_LAYER_CORE];
478 }
479 return result;
480}

◆ saveScriptedChangeToProperty:forSystemKey:andLayer:toValue:fromManifest:

- (void) saveScriptedChangeToProperty: (NSString *) property
forSystemKey: (NSString *) key
andLayer: (OOSystemLayer) layer
toValue: (id) value
fromManifest: (NSString *) manifest 

Extends class OOSystemDescriptionManager.

Definition at line 58 of file OOSystemDescriptionManager.m.

215 :(NSString *)property forSystemKey:(NSString *)key andLayer:(OOSystemLayer)layer toValue:(id)value fromManifest:(NSString *)manifest
216{
217 // if OXP doesn't have a manifest, cancel saving the change
218 if (manifest == nil)
219 {
220 return;
221 }
222// OOLog(@"saving change",@"%@ %@ %@ %d",manifest,key,property,layer);
223 NSArray *overrideKey = [NSArray arrayWithObjects:manifest,key,property,[[NSNumber numberWithInt:layer] stringValue],nil];
224 // Obj-C copes with NSArray keys to dictionaries fine, but the
225 // plist format doesn't, so they can't be saved.
226 NSString *overrideKeyStr = [overrideKey componentsJoinedByString:kOOScriptedChangeJoiner];
227 if (value != nil)
228 {
229 [scriptedChanges setObject:value forKey:overrideKeyStr];
230 }
231 else
232 {
233 [scriptedChanges removeObjectForKey:overrideKeyStr];
234 }
235}

◆ setProperties:inDescription:

- (void) setProperties: (NSDictionary *) properties
inDescription: (OOSystemDescriptionEntry *) desc 

Extends class OOSystemDescriptionManager.

Definition at line 58 of file OOSystemDescriptionManager.m.

483 :(NSDictionary *)properties inDescription:(OOSystemDescriptionEntry *)desc
484{
485 OOSystemLayer layer = [properties oo_unsignedIntForKey:kOOSystemLayerProperty defaultValue:OO_LAYER_OXP_STATIC];
486 if (layer > OO_LAYER_OXP_PRIORITY)
487 {
488 OOLog(@"system.description.error",@"Layer %u is not a valid layer number in system information.",layer);
489 layer = OO_LAYER_OXP_PRIORITY;
490 }
491 NSString *key = nil;
492 foreachkey(key, properties)
493 {
494 if (![key isEqualToString:kOOSystemLayerProperty])
495 {
496 [propertiesInUse addObject:key];
497 [desc setProperty:key forLayer:layer toValue:[properties objectForKey:key]];
498 }
499 }
500}
#define foreachkey(VAR, DICT)
Definition OOCocoa.h:366
#define OOLog(class, format,...)
Definition OOLogging.h:88
static NSString * kOOSystemLayerProperty
void setProperty:forLayer:toValue:(NSString *property,[forLayer] OOSystemLayer layer,[toValue] id value)

◆ updateCacheEntry:

- (void) updateCacheEntry: (NSUInteger) i

Extends class OOSystemDescriptionManager.

Definition at line 58 of file OOSystemDescriptionManager.m.

533 :(NSUInteger)i
534{
535 NSAssert(i < OO_SYSTEM_CACHE_LENGTH,@"Invalid cache entry number");
536 NSString *key = [NSString stringWithFormat:@"%lu %lu",i/OO_SYSTEMS_PER_GALAXY,i%OO_SYSTEMS_PER_GALAXY];
537 NSDictionary *current = [self calculatePropertiesForSystemKey:key];
538
539 [propertyCache[i] removeAllObjects];
540 [propertyCache[i] addEntriesFromDictionary:current];
541}
#define OO_SYSTEM_CACHE_LENGTH

◆ updateCacheEntry:forProperty:

- (void) updateCacheEntry: (NSUInteger) i
forProperty: (NSString *) property 

Extends class OOSystemDescriptionManager.

Definition at line 58 of file OOSystemDescriptionManager.m.

544 :(NSUInteger)i forProperty:(NSString *)property
545{
546 NSAssert(i < OO_SYSTEM_CACHE_LENGTH,@"Invalid cache entry number");
547 NSString *key = [NSString stringWithFormat:@"%lu %lu",i/OO_SYSTEMS_PER_GALAXY,i%OO_SYSTEMS_PER_GALAXY];
548 id current = [self getProperty:property forSystemKey:key];
549 if (current == nil)
550 {
551 [propertyCache[i] removeObjectForKey:property];
552 }
553 else
554 {
555 [propertyCache[i] setObject:current forKey:property];
556 }
557}

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