# HG changeset patch # User koda # Date 1282507719 -7200 # Node ID 73c2d7d5643bbfc96a013c21ac2eb4aeab77080f # Parent a70c61c076ae185b27c59d55d9b7b16baaed9d46 add the new flag, fix a couple of hicups in creating config files, swap animation between settings and lobby diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Classes/GameSetup.m --- a/project_files/HedgewarsMobile/Classes/GameSetup.m Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/GameSetup.m Sun Aug 22 22:08:39 2010 +0200 @@ -136,39 +136,41 @@ int i = 0; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x01; + result |= 0x00000001; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x10; + result |= 0x00000010; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x04; + result |= 0x00000004; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x08; + result |= 0x00000008; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x20; + result |= 0x00000020; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x40; + result |= 0x00000040; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x80; + result |= 0x00000080; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x100; + result |= 0x00000100; + if ([[scheme objectAtIndex:i++] boolValue]) + result |= 0x00000200; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x200; + result |= 0x00000400; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x400; + result |= 0x00000800; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x800; + result |= 0x00002000; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x2000; + result |= 0x00004000; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x4000; + result |= 0x00008000; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x8000; + result |= 0x00010000; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x10000; + result |= 0x00020000; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x20000; + result |= 0x00080000; if ([[scheme objectAtIndex:i++] boolValue]) - result |= 0x80000; + result |= 0x00100000; NSString *flags = [[NSString alloc] initWithFormat:@"e$gmflags %d",result]; [self sendToEngine:flags]; @@ -200,6 +202,7 @@ [self sendToEngine:minesNumber]; [minesNumber release]; + NSString *dudMines = [[NSString alloc] initWithFormat:@"e$minedudpct %d",[[scheme objectAtIndex:i++] intValue]]; [self sendToEngine:dudMines]; [dudMines release]; diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Classes/MainMenuViewController.m --- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sun Aug 22 22:08:39 2010 +0200 @@ -57,61 +57,75 @@ object:nil]; // now check if some configuration files are already set; if they are present it means that the current copy must be updated - NSError *err = nil; - NSString *fileToCheck, *teamToCheck, *teamToUpdate, *schemeToCheck, *schemeToUpdate; + BOOL doCreateFiles = NO; NSString *resDir = [[NSBundle mainBundle] resourcePath]; - NSString *dirToCheck = [NSString stringWithFormat:@"%@/done.txt",DOCUMENTS_FOLDER()]; - if ([[NSFileManager defaultManager] fileExistsAtPath:dirToCheck] == NO) { + NSString *versionFileToCheck = [NSString stringWithFormat:@"%@/version.txt",DOCUMENTS_FOLDER()]; + if ([[NSFileManager defaultManager] fileExistsAtPath:versionFileToCheck]) { + NSString *currentVersion = [NSString stringWithContentsOfFile:versionFileToCheck encoding:NSUTF8StringEncoding error:nil]; + NSString *newVersion = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/Settings/version.txt",resDir] encoding:NSUTF8StringEncoding error:nil]; + if ([currentVersion intValue] < [newVersion intValue]) { + doCreateFiles = YES; + [newVersion writeToFile:versionFileToCheck atomically:YES encoding:NSUTF8StringEncoding error:nil]; + } + } else { + doCreateFiles = YES; + [[NSFileManager defaultManager] copyItemAtPath:[NSString stringWithFormat:@"%@/Settings/version.txt",resDir] toPath:versionFileToCheck error:nil]; + } + + + if (doCreateFiles == YES) { + NSError *err = nil; + NSString *directoryToCheck, *fileToCheck, *fileToUpdate; DLog(@"Creating necessary files"); // if the settings file is already present, we merge current preferences with the update - fileToCheck = [NSString stringWithFormat:@"%@/Settings/settings.plist",resDir]; + directoryToCheck = [NSString stringWithFormat:@"%@/Settings/settings.plist",resDir]; if ([[NSFileManager defaultManager] fileExistsAtPath:SETTINGS_FILE()]) { NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()]; - NSMutableDictionary *update = [[NSMutableDictionary alloc] initWithContentsOfFile:fileToCheck]; + NSMutableDictionary *update = [[NSMutableDictionary alloc] initWithContentsOfFile:directoryToCheck]; [update addEntriesFromDictionary:settings]; [settings release]; [update writeToFile:SETTINGS_FILE() atomically:YES]; [update release]; } else - [[NSFileManager defaultManager] copyItemAtPath:fileToCheck toPath:SETTINGS_FILE() error:&err]; + [[NSFileManager defaultManager] copyItemAtPath:directoryToCheck toPath:SETTINGS_FILE() error:&err]; // if the teams are already present we merge the old teams if they still exist - fileToCheck = [NSString stringWithFormat:@"%@/Settings/Teams",resDir]; + directoryToCheck = [NSString stringWithFormat:@"%@/Settings/Teams",resDir]; if ([[NSFileManager defaultManager] fileExistsAtPath:TEAMS_DIRECTORY()]) { - for (NSString *str in [[NSFileManager defaultManager] contentsAtPath:fileToCheck]) { - teamToCheck = [NSString stringWithFormat:@"%@/%@",TEAMS_DIRECTORY(),str]; - teamToUpdate = [NSString stringWithFormat:@"%@/Settings/Teams/%@",resDir,str]; - if ([[NSFileManager defaultManager] fileExistsAtPath:teamToCheck]) { - NSDictionary *team = [[NSDictionary alloc] initWithContentsOfFile:teamToCheck]; - NSMutableDictionary *update = [[NSMutableDictionary alloc] initWithContentsOfFile:teamToUpdate]; + for (NSString *str in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryToCheck error:nil]) { + fileToCheck = [NSString stringWithFormat:@"%@/%@",TEAMS_DIRECTORY(),str]; + fileToUpdate = [NSString stringWithFormat:@"%@/Settings/Teams/%@",resDir,str]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fileToCheck]) { + NSDictionary *team = [[NSDictionary alloc] initWithContentsOfFile:fileToCheck]; + NSMutableDictionary *update = [[NSMutableDictionary alloc] initWithContentsOfFile:fileToUpdate]; [update addEntriesFromDictionary:team]; [team release]; - [update writeToFile:teamToCheck atomically:YES]; + [update writeToFile:fileToCheck atomically:YES]; [update release]; } } } else - [[NSFileManager defaultManager] copyItemAtPath:fileToCheck toPath:TEAMS_DIRECTORY() error:&err]; + [[NSFileManager defaultManager] copyItemAtPath:directoryToCheck toPath:TEAMS_DIRECTORY() error:&err]; // the same holds for schemes (but they're arrays) - fileToCheck = [NSString stringWithFormat:@"%@/Settings/Schemes",resDir]; + directoryToCheck = [NSString stringWithFormat:@"%@/Settings/Schemes",resDir]; if ([[NSFileManager defaultManager] fileExistsAtPath:SCHEMES_DIRECTORY()]) { - for (NSString *str in [[NSFileManager defaultManager] contentsAtPath:fileToCheck]) { - schemeToCheck = [NSString stringWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),str]; - schemeToUpdate = [NSString stringWithFormat:@"%@/Settings/Schemes/%@",resDir,str]; - if ([[NSFileManager defaultManager] fileExistsAtPath:schemeToCheck]) { - NSArray *scheme = [[NSArray alloc] initWithContentsOfFile:schemeToCheck]; - NSArray *update = [[NSArray alloc] initWithContentsOfFile:schemeToUpdate]; + for (NSString *str in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryToCheck error:nil]) { + fileToCheck = [NSString stringWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),str]; + fileToUpdate = [NSString stringWithFormat:@"%@/Settings/Schemes/%@",resDir,str]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fileToCheck]) { + NSArray *scheme = [[NSArray alloc] initWithContentsOfFile:fileToCheck]; + NSArray *update = [[NSArray alloc] initWithContentsOfFile:fileToUpdate]; if ([update count] > [scheme count]) - [update writeToFile:schemeToCheck atomically:YES]; + [update writeToFile:fileToCheck atomically:YES]; [update release]; [scheme release]; } } } else - [[NSFileManager defaultManager] copyItemAtPath:fileToCheck toPath:SCHEMES_DIRECTORY() error:&err]; + [[NSFileManager defaultManager] copyItemAtPath:directoryToCheck toPath:SCHEMES_DIRECTORY() error:&err]; // we create weapons the first time only, they are autoupdated each time if ([[NSFileManager defaultManager] fileExistsAtPath:WEAPONS_DIRECTORY()] == NO) { @@ -127,11 +141,7 @@ createWeaponNamed(@"Minefield", 5); } - // create a dummy file so that it doesn't get called again - if ([[NSFileManager defaultManager] createFileAtPath:dirToCheck - contents:[NSData dataWithContentsOfFile:SETTINGS_FILE()] - attributes:nil]) - DLog(@"Success"); + DLog(@"Success"); if (err != nil) DLog(@"%@", err); @@ -156,6 +166,7 @@ xib = @"GameConfigViewController"; GameConfigViewController *gcvc = [[GameConfigViewController alloc] initWithNibName:xib bundle:nil]; + gcvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; self.gameConfigViewController = gcvc; [gcvc release]; } @@ -165,7 +176,6 @@ case 2: if (nil == self.settingsViewController) { SplitViewRootController *svrc = [[SplitViewRootController alloc] initWithNibName:nil bundle:nil]; - svrc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; self.settingsViewController = svrc; [svrc release]; } diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m --- a/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Sun Aug 22 22:08:39 2010 +0200 @@ -78,6 +78,9 @@ [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Disable Land Objects",@""),@"title", NSLocalizedString(@"Disable land objects when generating maps",@""),@"description", @"DisableLandObjects",@"image",nil], + [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"AI Survival Mode",@""),@"title", + NSLocalizedString(@"AI-controlled hogs respawn on death",@""),@"description", + @"AISurvival",@"image",nil], nil]; self.gameModifierArray = mods; [mods release]; diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Resources/Settings/Schemes/Barrel Mayhem.plist --- a/project_files/HedgewarsMobile/Resources/Settings/Schemes/Barrel Mayhem.plist Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/Settings/Schemes/Barrel Mayhem.plist Sun Aug 22 22:08:39 2010 +0200 @@ -19,6 +19,7 @@ + 100 30 100 diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Resources/Settings/Schemes/Basketball.plist --- a/project_files/HedgewarsMobile/Resources/Settings/Schemes/Basketball.plist Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/Settings/Schemes/Basketball.plist Sun Aug 22 22:08:39 2010 +0200 @@ -18,6 +18,7 @@ + 100 30 diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Resources/Settings/Schemes/Default.plist --- a/project_files/HedgewarsMobile/Resources/Settings/Schemes/Default.plist Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/Settings/Schemes/Default.plist Sun Aug 22 22:08:39 2010 +0200 @@ -19,6 +19,7 @@ + 100 45 100 diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Resources/Settings/Schemes/Minefield.plist --- a/project_files/HedgewarsMobile/Resources/Settings/Schemes/Minefield.plist Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/Settings/Schemes/Minefield.plist Sun Aug 22 22:08:39 2010 +0200 @@ -18,6 +18,7 @@ + 150 30 diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Resources/Settings/Schemes/Pro Mode.plist --- a/project_files/HedgewarsMobile/Resources/Settings/Schemes/Pro Mode.plist Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/Settings/Schemes/Pro Mode.plist Sun Aug 22 22:08:39 2010 +0200 @@ -19,6 +19,7 @@ + 100 15 100 diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Resources/Settings/Schemes/Shoppa.plist --- a/project_files/HedgewarsMobile/Resources/Settings/Schemes/Shoppa.plist Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/Settings/Schemes/Shoppa.plist Sun Aug 22 22:08:39 2010 +0200 @@ -18,6 +18,7 @@ + 100 30 diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Resources/Settings/Schemes/Tunnel Hogs.plist --- a/project_files/HedgewarsMobile/Resources/Settings/Schemes/Tunnel Hogs.plist Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/Settings/Schemes/Tunnel Hogs.plist Sun Aug 22 22:08:39 2010 +0200 @@ -19,6 +19,7 @@ + 100 30 100 diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Resources/Settings/Teams/Pirates.plist --- a/project_files/HedgewarsMobile/Resources/Settings/Teams/Pirates.plist Sun Aug 22 16:31:57 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/Settings/Teams/Pirates.plist Sun Aug 22 22:08:39 2010 +0200 @@ -78,6 +78,6 @@ voicepack - Pirates + Pirate diff -r a70c61c076ae -r 73c2d7d5643b project_files/HedgewarsMobile/Resources/Settings/version.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/HedgewarsMobile/Resources/Settings/version.txt Sun Aug 22 22:08:39 2010 +0200 @@ -0,0 +1,1 @@ +1