Oolite 1.91.0.7604-240417-a536cbe
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
35@interface OOCheckDemoShipsPListVerifierStage (OOPrivate)
36
37- (void)runCheckWithDemoShips:(NSArray *)demoshipsPList shipData:(NSDictionary *)shipdataPList;
38
39@end
40
41
43
44- (NSString *)name
45{
46 return kStageName;
47}
48
49
50- (BOOL)shouldRun
51{
52 OOFileScannerVerifierStage *fileScanner = nil;
53
54 fileScanner = [[self verifier] fileScannerStage];
55 return [fileScanner fileExists:@"demoships.plist"
56 inFolder:@"Config"
58 checkBuiltIn:NO];
59}
60
61
62- (void)run
63{
64 OOFileScannerVerifierStage *fileScanner = nil;
65 NSArray *demoshipsPList = nil;
66 NSDictionary *shipdataPList = nil;
67
68 fileScanner = [[self verifier] fileScannerStage];
69
70 demoshipsPList = [fileScanner plistNamed:@"demoships.plist"
71 inFolder:@"Config"
73 checkBuiltIn:NO];
74
75 if (demoshipsPList == nil) return;
76
77 // Check that it's an array
78 if (![demoshipsPList isKindOfClass:[NSArray class]])
79 {
80 OOLog(@"verifyOXP.demoshipsPList.notArray", @"%@", @"***** ERROR: demoships.plist is not an array.");
81 return;
82 }
83
84
85 shipdataPList = [fileScanner plistNamed:@"shipdata.plist"
86 inFolder:@"Config"
88 checkBuiltIn:NO];
89
90 if (shipdataPList == nil) return;
91
92 // Check that it's a dictionary
93 if (![shipdataPList isKindOfClass:[NSDictionary class]])
94 {
95 OOLog(@"verifyOXP.demoshipsPList.notDict", @"%@", @"***** ERROR: shipdata.plist is not a dictionary.");
96 return;
97 }
98
99 [self runCheckWithDemoShips:demoshipsPList shipData:shipdataPList];
100}
101
102@end
103
104
105@implementation OOCheckDemoShipsPListVerifierStage (OOPrivate)
106
107- (void)runCheckWithDemoShips:(NSArray *)demoshipsPList shipData:(NSDictionary *)shipdataPList
108{
109 NSEnumerator *nameEnum = nil;
110 NSString *name = nil;
111
112 for (nameEnum = [demoshipsPList objectEnumerator]; (name = [nameEnum nextObject]); )
113 {
114 if ([shipdataPList objectForKey:name] == nil)
115 {
116 OOLog(@"verifyOXP.demoshipsPList.unknownShip", @"----- WARNING: demoships.plist entry \"%@\" not found in shipdata.plist.", name);
117 }
118 }
119}
120
121@end
122
123#endif
static NSString *const kStageName
static NSString *const kStageName
#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)
BOOL fileExists:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)