--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sun Dec 05 19:00:41 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sun Dec 05 23:48:58 2010 +0100
@@ -37,7 +37,6 @@
// check if some configuration files are already set; if they are present it means that the current copy must be updated
-(void) createNecessaryFiles {
- NSString *sourceFile, *destinationFile;
NSString *resourcesDir = [[NSBundle mainBundle] resourcePath];
DLog(@"Creating necessary files");
@@ -69,31 +68,21 @@
// we copy teams only the first time because it's unlikely that newer ones are going to be added
NSString *baseTeamsDir = [[NSString alloc] initWithFormat:@"%@/Settings/Teams/",resourcesDir];
for (NSString *str in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:baseTeamsDir error:NULL]) {
- sourceFile = [baseTeamsDir stringByAppendingString:str];
- destinationFile = [TEAMS_DIRECTORY() stringByAppendingString:str];
+ NSString *sourceFile = [baseTeamsDir stringByAppendingString:str];
+ NSString *destinationFile = [TEAMS_DIRECTORY() stringByAppendingString:str];
[[NSFileManager defaultManager] removeItemAtPath:destinationFile error:NULL];
[[NSFileManager defaultManager] copyItemAtPath:sourceFile toPath:destinationFile error:NULL];
}
[baseTeamsDir release];
}
- // TODO: is merge needed?
+ // merge not needed as format rarely changes
- // SCHEMES - update old stuff and add new stuff
- if ([[NSFileManager defaultManager] fileExistsAtPath:SCHEMES_DIRECTORY()] == NO)
- [[NSFileManager defaultManager] createDirectoryAtPath:SCHEMES_DIRECTORY()
- withIntermediateDirectories:YES
- attributes:nil
- error:NULL];
- // TODO: do the merge if necessary
- // we overwrite the default ones because it is likely that new modes are added every release
+ // SCHEMES - always overwrite and delete custom ones
+ if ([[NSFileManager defaultManager] fileExistsAtPath:SCHEMES_DIRECTORY()] == YES)
+ [[NSFileManager defaultManager] removeItemAtPath:SCHEMES_DIRECTORY() error:NULL];
NSString *baseSchemesDir = [[NSString alloc] initWithFormat:@"%@/Settings/Schemes/",resourcesDir];
- for (NSString *str in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:baseSchemesDir error:NULL]) {
- sourceFile = [baseSchemesDir stringByAppendingString:str];
- destinationFile = [SCHEMES_DIRECTORY() stringByAppendingString:str];
- [[NSFileManager defaultManager] removeItemAtPath:destinationFile error:NULL];
- [[NSFileManager defaultManager] copyItemAtPath:sourceFile toPath:destinationFile error:NULL];
- }
- [baseSchemesDir release];
+ [[NSFileManager defaultManager] copyItemAtPath:baseSchemesDir toPath:SCHEMES_DIRECTORY() error:NULL];
+
// WEAPONS - always overwrite
if ([[NSFileManager defaultManager] fileExistsAtPath:WEAPONS_DIRECTORY()] == NO)
@@ -108,6 +97,7 @@
createWeaponNamed(@"Clean Slate", 4);
createWeaponNamed(@"Minefield", 5);
createWeaponNamed(@"Thinking with Portals", 6);
+ // merge not needed because weapons not present in the set are 0ed by GameSetup
DLog(@"Success");
}