diff -r 2c06b1120749 -r 00215a7ec5f5 project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m --- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m Fri Dec 29 22:37:31 2017 +0100 +++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m Sat Dec 30 01:22:11 2017 +0100 @@ -30,15 +30,13 @@ #pragma mark - #pragma mark Instance methods for engine interaction // prepares the controllers for hosting a game --(void) earlyEngineLaunch:(NSDictionary *)optionsOrNil { - [self retain]; +- (void)earlyEngineLaunch:(NSDictionary *)optionsOrNil { [[AudioManagerController mainManager] fadeOutBackgroundMusic]; EngineProtocolNetwork *engineProtocol = [[EngineProtocolNetwork alloc] init]; self.port = engineProtocol.enginePort; engineProtocol.delegate = self; [engineProtocol spawnThread:self.savePath withOptions:optionsOrNil]; - [engineProtocol release]; // add a black view hiding the background UIWindow *thisWindow = [[HedgewarsAppDelegate sharedAppDelegate] uiwindow]; @@ -52,7 +50,6 @@ self.blackView.alpha = 1; [UIView commitAnimations]; [thisWindow addSubview:self.blackView]; - [self.blackView release]; // keep the point of return for games that completed loading NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; @@ -65,7 +62,7 @@ } // cleans up everything --(void) lateEngineLaunch { +- (void)lateEngineLaunch { // notify views below that they are getting the spotlight again [[[HedgewarsAppDelegate sharedAppDelegate] uiwindow] makeKeyAndVisible]; [callingController viewWillAppear:YES]; @@ -91,11 +88,10 @@ [[AudioManagerController mainManager] fadeInBackgroundMusic]; [HWUtils setGameStatus:gsNone]; [HWUtils setGameType:gtNone]; - [self release]; } // main routine for calling the actual game engine --(void) engineLaunch { +- (void)engineLaunch { CGFloat width, height; CGFloat screenScale = [[UIScreen mainScreen] safeScale]; NSString *ipcString = [[NSString alloc] initWithFormat:@"%d",self.port]; @@ -141,11 +137,6 @@ @"--prefix", resourcePath, @"--user-prefix", documentsDirectory, nil]; - [verticalSize release]; - [horizontalSize release]; - [resourcePath release]; - [localeString release]; - [ipcString release]; NSString *username = [settings objectForKey:@"username"]; if ([username length] > 0) { @@ -175,7 +166,6 @@ const char **argv = (const char **)malloc(sizeof(const char*)*argc); for (int i = 0; i < argc; i++) argv[i] = strdup([[gameParameters objectAtIndex:i] UTF8String]); - [gameParameters release]; // this is the pascal function that starts the game RunEngine(argc, argv); @@ -189,88 +179,72 @@ [self lateEngineLaunch]; } --(void) dealloc { - releaseAndNil(blackView); - releaseAndNil(savePath); - [super dealloc]; -} #pragma mark - #pragma mark EngineProtocolDelegate methods --(void) gameEndedWithStatistics:(NSArray *)stats { +- (void)gameEndedWithStatistics:(NSArray *)stats { if (stats != nil) { StatsPageViewController *statsPage = [[StatsPageViewController alloc] init]; statsPage.statsArray = stats; statsPage.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [callingController presentViewController:statsPage animated:YES completion:nil]; - [statsPage release]; } } #pragma mark - #pragma mark Class methods for setting up the engine from outsite -+(void) registerCallingController:(UIViewController *)controller { ++ (void)registerCallingController:(UIViewController *)controller { callingController = controller; } -+(void) startGame:(TGameType) type atPath:(NSString *)path withOptions:(NSDictionary *)config { ++ (void)startGame:(TGameType)type atPath:(NSString *)path withOptions:(NSDictionary *)config { [HWUtils setGameType:type]; id bridge = [[self alloc] init]; [bridge setSavePath:path]; [bridge earlyEngineLaunch:config]; - [bridge release]; } -+(void) startLocalGame:(NSDictionary *)withOptions { ++ (void)startLocalGame:(NSDictionary *)withOptions { NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init]; [outputFormatter setDateFormat:@"yyyy-MM-dd '@' HH.mm"]; NSString *savePath = [[NSString alloc] initWithFormat:@"%@%@.hws",SAVES_DIRECTORY(),[outputFormatter stringFromDate:[NSDate date]]]; - [outputFormatter release]; // in the rare case in which a savefile with the same name exists the older one must be removed (otherwise it gets corrupted) if ([[NSFileManager defaultManager] fileExistsAtPath:savePath]) [[NSFileManager defaultManager] removeItemAtPath:savePath error:nil]; [self startGame:gtLocal atPath:savePath withOptions:withOptions]; - [savePath release]; } -+(void) startSaveGame:(NSString *)atPath { ++ (void)startSaveGame:(NSString *)atPath { [self startGame:gtSave atPath:atPath withOptions:nil]; } -+(void) startMissionGame:(NSString *)withScript { ++ (void)startMissionGame:(NSString *)withScript { NSString *seedCmd = [self seedCommand]; NSString *missionPath = [[NSString alloc] initWithFormat:@"escript Missions/Training/%@.lua",withScript]; NSDictionary *missionDict = [[NSDictionary alloc] initWithObjectsAndKeys:missionPath, @"mission_command", seedCmd, @"seed_command", nil]; - [missionPath release]; - [seedCmd release]; [self startGame:gtMission atPath:nil withOptions:missionDict]; - [missionDict release]; } -+(NSString *) seedCommand { ++ (NSString *)seedCommand { // generate a seed NSString *seed = [HWUtils seed]; NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed]; - [seed release]; return seedCmd; } -+(void) startCampaignMissionGameWithScript:(NSString *)missionScriptName forCampaign:(NSString *)campaignName { ++ (void)startCampaignMissionGameWithScript:(NSString *)missionScriptName forCampaign:(NSString *)campaignName { NSString *seedCmd = [self seedCommand]; NSString *campaignMissionPath = [[NSString alloc] initWithFormat:@"escript Missions/Campaign/%@/%@", campaignName, missionScriptName]; NSDictionary *campaignMissionDict = [[NSDictionary alloc] initWithObjectsAndKeys:campaignMissionPath, @"mission_command", seedCmd, @"seed_command", nil]; - [campaignMissionPath release]; - [seedCmd release]; [self startGame:gtCampaign atPath:nil withOptions:campaignMissionDict]; - [campaignMissionDict release]; } -+(void) startSimpleGame { ++ (void)startSimpleGame { NSString *seedCmd = [self seedCommand]; // pick a random static map @@ -278,9 +252,7 @@ NSString *mapName = [listOfMaps objectAtIndex:arc4random_uniform((int)[listOfMaps count])]; NSString *fileCfg = [[NSString alloc] initWithFormat:@"%@/%@/map.cfg",MAPS_DIRECTORY(),mapName]; NSString *contents = [[NSString alloc] initWithContentsOfFile:fileCfg encoding:NSUTF8StringEncoding error:NULL]; - [fileCfg release]; NSArray *split = [contents componentsSeparatedByString:@"\n"]; - [contents release]; NSString *themeCommand = [[NSString alloc] initWithFormat:@"etheme %@", [split objectAtIndex:0]]; NSString *staticMapCommand = [[NSString alloc] initWithFormat:@"emap %@", mapName]; @@ -301,8 +273,6 @@ [NSNumber numberWithUnsignedInt:secondColor],@"color", @"Robots.plist",@"team",nil]; NSArray *listOfTeams = [[NSArray alloc] initWithObjects:firstTeam,secondTeam,nil]; - [firstTeam release]; - [secondTeam release]; // create the configuration NSDictionary *gameDictionary = [[NSDictionary alloc] initWithObjectsAndKeys: @@ -317,14 +287,9 @@ @"Default.plist",@"weapon", @"",@"mission_command", nil]; - [listOfTeams release]; - [staticMapCommand release]; - [themeCommand release]; - [seedCmd release]; // launch game [GameInterfaceBridge startLocalGame:gameDictionary]; - [gameDictionary release]; } @end