Oolite
Loading...
Searching...
No Matches
OOCheckDemoShipsPListVerifierStage.m
Go to the documentation of this file.
1/*
2
3OOCheckDemoShipsPListVerifierStage.m
4
5
6Oolite
7Copyright (C) 2004-2013 Giles C Williams and contributors
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22MA 02110-1301, USA.
23
24*/
25
27
28#if OO_OXP_VERIFIER_ENABLED
29
31
32static NSString* const kStageName = @"Checking demoships.plist";
33
34@interface OOCheckDemoShipsPListVerifierStage (OOPrivate)
35
36- (void)runCheckWithDemoShips:(NSArray*)demoshipsPList shipData:(NSDictionary*)shipdataPList;
37
38@end
39
41
42- (NSString*)name
43{
44 return kStageName;
45}
46
47- (BOOL)shouldRun
48{
49 OOFileScannerVerifierStage* fileScanner = nil;
50
51 fileScanner = [[self verifier] fileScannerStage];
52 return [fileScanner fileExists:@"demoships.plist"
53 inFolder:@"Config"
55 checkBuiltIn:NO];
56}
57
58- (void)run
59{
60 OOFileScannerVerifierStage* fileScanner = nil;
61 NSArray* demoshipsPList = nil;
62 NSDictionary* shipdataPList = nil;
63
64 fileScanner = [[self verifier] fileScannerStage];
65
66 demoshipsPList = [fileScanner plistNamed:@"demoships.plist"
67 inFolder:@"Config"
69 checkBuiltIn:NO];
70
71 if (demoshipsPList == nil)
72 return;
73
74 // Check that it's an array
75 if (![demoshipsPList isKindOfClass:[NSArray class]]) {
76 OOLog(@"verifyOXP.demoshipsPList.notArray", @"%@", @"***** ERROR: demoships.plist is not an array.");
77 return;
78 }
79
80 shipdataPList = [fileScanner plistNamed:@"shipdata.plist"
81 inFolder:@"Config"
83 checkBuiltIn:NO];
84
85 if (shipdataPList == nil)
86 return;
87
88 // Check that it's a dictionary
89 if (![shipdataPList isKindOfClass:[NSDictionary class]]) {
90 OOLog(@"verifyOXP.demoshipsPList.notDict", @"%@", @"***** ERROR: shipdata.plist is not a dictionary.");
91 return;
92 }
93
94 [self runCheckWithDemoShips:demoshipsPList shipData:shipdataPList];
95}
96
97@end
98
99@implementation OOCheckDemoShipsPListVerifierStage (OOPrivate)
100
101- (void)runCheckWithDemoShips:(NSArray*)demoshipsPList shipData:(NSDictionary*)shipdataPList
102{
103 NSString* name = nil;
104
105 foreach (name, demoshipsPList) {
106 if ([shipdataPList objectForKey:name] == nil) {
107 OOLog(@"verifyOXP.demoshipsPList.unknownShip", @"----- WARNING: demoships.plist entry \"%@\" not found in shipdata.plist.", name);
108 }
109 }
110}
111
112@end
113
114#endif
static NSString *const kStageName
#define OOLog(class, format,...)
Definition OOLogging.h:84
return nil
void runCheckWithDemoShips:shipData:(NSArray *demoshipsPList,[shipData] NSDictionary *shipdataPList)
id plistNamed:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)
BOOL fileExists:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)
OOOXPVerifier * verifier()
OOFileScannerVerifierStage * fileScannerStage()