181 [theWeapon release]; |
181 [theWeapon release]; |
182 } |
182 } |
183 |
183 |
184 void createSchemeNamed (NSString *nameWithoutExt) { |
184 void createSchemeNamed (NSString *nameWithoutExt) { |
185 NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
185 NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
|
186 NSString *path = nil; |
186 |
187 |
187 if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
188 if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
188 [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
189 [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
189 withIntermediateDirectories:NO |
190 withIntermediateDirectories:NO |
190 attributes:nil |
191 attributes:nil |
191 error:NULL]; |
192 error:NULL]; |
192 } |
193 } |
193 |
194 |
194 int basicFlags[] = {100, 100, 45, 15, 47, 5, 100, 5, 35, 25, 3, 4, 0, 2}; |
195 // load data to get the size of the arrays and their default values |
195 BOOL gameFlags[] = {NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, YES, NO, NO, NO, NO, |
196 path = [NSString stringWithFormat:@"%@/basicFlags_en.plist",IFRONTEND_DIRECTORY()]; |
196 NO, NO, NO, NO, NO, NO, NO}; |
197 NSArray *basicSettings = [[NSArray alloc] initWithContentsOfFile:path]; |
197 |
198 NSMutableArray *basicArray = [[NSMutableArray alloc] initWithCapacity:[basicSettings count]]; |
198 NSMutableArray *basicArray = [[NSMutableArray alloc] initWithObjects: |
199 for (NSDictionary *basicDict in basicSettings) |
199 [NSNumber numberWithInt:basicFlags[0]], //initialhealth |
200 [basicArray addObject:[basicDict objectForKey:@"default"]]; |
200 [NSNumber numberWithInt:basicFlags[1]], //damagemodifier |
201 [basicSettings release]; |
201 [NSNumber numberWithInt:basicFlags[2]], //turntime |
202 |
202 [NSNumber numberWithInt:basicFlags[3]], //suddendeathtimeout |
203 path = [NSString stringWithFormat:@"%@/gameFlags_en.plist",IFRONTEND_DIRECTORY()]; |
203 [NSNumber numberWithInt:basicFlags[4]], //waterrise |
204 NSArray *mods = [[NSArray alloc] initWithContentsOfFile:path]; |
204 [NSNumber numberWithInt:basicFlags[5]], //healthdecrease |
205 NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithCapacity:[mods count]]; |
205 [NSNumber numberWithInt:basicFlags[6]], //ropelength |
206 for (int i = 0; i < [mods count]; i++) |
206 [NSNumber numberWithInt:basicFlags[7]], //cratedrops |
207 [gamemodArray addObject:[NSNumber numberWithBool:NO]]; |
207 [NSNumber numberWithInt:basicFlags[8]], //healthprob |
208 [mods release]; |
208 [NSNumber numberWithInt:basicFlags[9]], //healthamount |
209 |
209 [NSNumber numberWithInt:basicFlags[10]], //minestime |
210 // workaround for randomorder that has to be set to YES |
210 [NSNumber numberWithInt:basicFlags[11]], //minesnumber |
211 [gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]]; |
211 [NSNumber numberWithInt:basicFlags[12]], //dudmines |
212 |
212 [NSNumber numberWithInt:basicFlags[13]], //explosives |
|
213 nil]; |
|
214 |
|
215 NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithObjects: |
|
216 [NSNumber numberWithBool:gameFlags[0]], //fortmode |
|
217 [NSNumber numberWithBool:gameFlags[1]], //divideteam |
|
218 [NSNumber numberWithBool:gameFlags[2]], //solidland |
|
219 [NSNumber numberWithBool:gameFlags[3]], //addborder |
|
220 [NSNumber numberWithBool:gameFlags[4]], //lowgravity |
|
221 [NSNumber numberWithBool:gameFlags[5]], //lasersight |
|
222 [NSNumber numberWithBool:gameFlags[6]], //invulnerable |
|
223 [NSNumber numberWithBool:gameFlags[7]], //resethealth |
|
224 [NSNumber numberWithBool:gameFlags[8]], //vampirism |
|
225 [NSNumber numberWithBool:gameFlags[9]], //karma |
|
226 [NSNumber numberWithBool:gameFlags[10]], //artillery |
|
227 [NSNumber numberWithBool:gameFlags[11]], //randomorder |
|
228 [NSNumber numberWithBool:gameFlags[12]], //king |
|
229 [NSNumber numberWithBool:gameFlags[13]], //placehedgehogs |
|
230 [NSNumber numberWithBool:gameFlags[14]], //clansharesammo |
|
231 [NSNumber numberWithBool:gameFlags[15]], //disablegirders |
|
232 [NSNumber numberWithBool:gameFlags[16]], //disablelandobjects |
|
233 [NSNumber numberWithBool:gameFlags[17]], //aisurvival |
|
234 [NSNumber numberWithBool:gameFlags[18]], //infattack |
|
235 [NSNumber numberWithBool:gameFlags[19]], //resetweaps |
|
236 [NSNumber numberWithBool:gameFlags[20]], //perhogammo |
|
237 [NSNumber numberWithBool:gameFlags[21]], //nowind |
|
238 [NSNumber numberWithBool:gameFlags[22]], //morewind |
|
239 nil]; |
|
240 |
|
241 NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
213 NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
242 basicArray,@"basic", |
214 basicArray,@"basic", |
243 gamemodArray,@"gamemod", |
215 gamemodArray,@"gamemod", |
244 nil]; |
216 nil]; |
245 [gamemodArray release]; |
217 [gamemodArray release]; |