Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOCheckEquipmentPListVerifierStage Class Reference

#include <OOCheckEquipmentPListVerifierStage.h>

+ Inheritance diagram for OOCheckEquipmentPListVerifierStage:
+ Collaboration diagram for OOCheckEquipmentPListVerifierStage:

Instance Methods

(NSString *) - name [implementation]
 
(BOOL) - shouldRun [implementation]
 
(void) - run [implementation]
 
(void) - runCheckWithEquipment: [implementation]
 
- Instance Methods inherited from OOFileHandlingVerifierStage
(NSSet *) - dependencies [implementation]
 
(NSSet *) - dependents [implementation]
 
- Instance Methods inherited from OOOXPVerifierStage
(OOOXPVerifier *) - verifier
 
(BOOL) - completed
 
(id) - init [implementation]
 
(void) - dealloc [implementation]
 
(id) - description [implementation]
 
(void) - setVerifier: [implementation]
 
(BOOL) - isDependentOf: [implementation]
 
(void) - registerDependency: [implementation]
 
(void) - dependencyRegistrationComplete [implementation]
 
(BOOL) - canRun [implementation]
 
(void) - performRun [implementation]
 
(void) - noteSkipped [implementation]
 
(NSSet *) - resolvedDependencies [implementation]
 
(NSSet *) - resolvedDependents [implementation]
 
(void) - registerDepedent: [implementation]
 
(void) - dependencyCompleted: [implementation]
 

Detailed Description

Definition at line 32 of file OOCheckEquipmentPListVerifierStage.h.

Method Documentation

◆ name

- (NSString *) name
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 34 of file OOCheckEquipmentPListVerifierStage.m.

47{
48 return kStageName;
49}
static NSString *const kStageName

◆ run

- (void) run
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 34 of file OOCheckEquipmentPListVerifierStage.m.

65{
66 OOFileScannerVerifierStage *fileScanner = nil;
67 NSArray *equipmentPList = nil;
68
69 fileScanner = [[self verifier] fileScannerStage];
70
71 equipmentPList = [fileScanner plistNamed:@"equipment.plist"
72 inFolder:@"Config"
74 checkBuiltIn:NO];
75
76 if (equipmentPList == nil) return;
77
78 // Check that it's an array
79 if (![equipmentPList isKindOfClass:[NSArray class]])
80 {
81 OOLog(@"verifyOXP.equipmentPList.notArray", @"%@", @"***** ERROR: equipment.plist is not an array.");
82 return;
83 }
84
85
86 [self runCheckWithEquipment:equipmentPList];
87}
#define OOLog(class, format,...)
Definition OOLogging.h:88
return nil
id plistNamed:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)

◆ runCheckWithEquipment:

- (void) runCheckWithEquipment: (NSArray *) equipmentPList
implementation

Provided by category OOCheckEquipmentPListVerifierStage(OOPrivate).

Definition at line 34 of file OOCheckEquipmentPListVerifierStage.m.

94 :(NSArray *)equipmentPList
95{
96 NSEnumerator *entryEnum = nil;
97 NSArray *entry = nil;
98 unsigned entryIndex = 0;
99 NSUInteger elemCount;
100 NSString *name = nil;
101 NSString *entryDesc = nil;
102
103 for (entryEnum = [equipmentPList objectEnumerator]; (entry = [entryEnum nextObject]); )
104 {
105 ++entryIndex;
106
107 // Entries should be arrays.
108 if (![entry isKindOfClass:[NSArray class]])
109 {
110 OOLog(@"verifyOXP.equipmentPList.entryNotArray", @"***** ERROR: equipment.plist entry %u of equipment.plist is not an array.", entryIndex);
111 continue;
112 }
113
114 elemCount = [entry count];
115
116 // Make a name for entry for display purposes.
117 if (EQUIPMENT_KEY_INDEX < elemCount) name = [entry oo_stringAtIndex:EQUIPMENT_KEY_INDEX];
118 else name = nil;
119
120 if (name != nil) entryDesc = [NSString stringWithFormat:@"%u (\"%@\")", entryIndex, name];
121 else entryDesc = [NSString stringWithFormat:@"%u", entryIndex];
122
123 // Check that the entry has an acceptable number of elements.
124 if (elemCount < 5)
125 {
126 OOLog(@"verifyOXP.equipmentPList.badEntrySize", @"***** ERROR: equipment.plist entry %@ has too few elements (%lu, should be 5 or 6).", entryDesc, elemCount);
127 continue;
128 }
129 if (6 < elemCount)
130 {
131 OOLog(@"verifyOXP.equipmentPList.badEntrySize", @"----- WARNING: equipment.plist entry %@ has too many elements (%lu, should be 5 or 6).", entryDesc, elemCount);
132 }
133
134 /* Check element types. The numbers are required to be unsigned
135 integers; the use of a negative default will catch both negative
136 values and unconvertable values.
137 */
138 if ([entry oo_longAtIndex:EQUIPMENT_TECH_LEVEL_INDEX defaultValue:-1] < 0)
139 {
140 OOLog(@"verifyOXP.equipmentPList.badElementType", @"***** ERROR: tech level for entry %@ of equipment.plist is not a positive integer.", entryDesc);
141 }
142 if ([entry oo_longAtIndex:EQUIPMENT_PRICE_INDEX defaultValue:-1] < 0)
143 {
144 OOLog(@"verifyOXP.equipmentPList.badElementType", @"***** ERROR: price for entry %@ of equipment.plist is not a positive integer.", entryDesc);
145 }
146 if ([entry oo_stringAtIndex:EQUIPMENT_SHORT_DESC_INDEX] == nil)
147 {
148 OOLog(@"verifyOXP.equipmentPList.badElementType", @"***** ERROR: short description for entry %@ of equipment.plist is not a string.", entryDesc);
149 }
150 if ([entry oo_stringAtIndex:EQUIPMENT_KEY_INDEX] == nil)
151 {
152 OOLog(@"verifyOXP.equipmentPList.badElementType", @"***** ERROR: key for entry %@ of equipment.plist is not a string.", entryDesc);
153 }
154 if ([entry oo_stringAtIndex:EQUIPMENT_LONG_DESC_INDEX] == nil)
155 {
156 OOLog(@"verifyOXP.equipmentPList.badElementType", @"***** ERROR: long description for entry %@ of equipment.plist is not a string.", entryDesc);
157 }
158
159 if (5 < elemCount)
160 {
161 if ([entry oo_dictionaryAtIndex:EQUIPMENT_EXTRA_INFO_INDEX] == nil)
162 {
163 OOLog(@"verifyOXP.equipmentPList.badElementType", @"***** ERROR: equipment.plist entry %@'s extra information dictionary is not a dictionary.", entryDesc);
164 }
165 // TODO: verify contents of extra info dictionary.
166 }
167 }
168}
@ EQUIPMENT_SHORT_DESC_INDEX
Definition Universe.h:81
@ EQUIPMENT_LONG_DESC_INDEX
Definition Universe.h:83
@ EQUIPMENT_TECH_LEVEL_INDEX
Definition Universe.h:79
@ EQUIPMENT_KEY_INDEX
Definition Universe.h:82
@ EQUIPMENT_PRICE_INDEX
Definition Universe.h:80
@ EQUIPMENT_EXTRA_INFO_INDEX
Definition Universe.h:84

◆ shouldRun

- (BOOL) shouldRun
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 34 of file OOCheckEquipmentPListVerifierStage.m.

53{
54 OOFileScannerVerifierStage *fileScanner = nil;
55
56 fileScanner = [[self verifier] fileScannerStage];
57 return [fileScanner fileExists:@"equipment.plist"
58 inFolder:@"Config"
60 checkBuiltIn:NO];
61}
BOOL fileExists:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)

The documentation for this class was generated from the following files: