# HG changeset patch # User antonc27 # Date 1441842555 -7200 # Node ID 064a538617593dfd941ef29ec3a3db731159255e # Parent f9c460720e021ed072015c5298b06465670bfcea - Refactoring in order to remove some warning related to using of int instead of NSInteger diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/Appirater.m --- a/project_files/HedgewarsMobile/Classes/Appirater.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/Appirater.m Thu Sep 10 01:49:15 2015 +0200 @@ -82,11 +82,11 @@ double secondsUntilPrompt = 60 * 60 * 24 * DAYS_UNTIL_PROMPT; // get the launch count - int launchCount = [userDefaults integerForKey:kAppiraterLaunchCount]; + NSInteger launchCount = [userDefaults integerForKey:kAppiraterLaunchCount]; launchCount++; [userDefaults setInteger:launchCount forKey:kAppiraterLaunchCount]; if (APPIRATER_DEBUG) - NSLog(@"APPIRATER Launch count: %d", launchCount); + NSLog(@"APPIRATER Launch count: %ld", (long)launchCount); // have they previously declined to rate this version of the app? BOOL declinedToRate = [userDefaults boolForKey:kAppiraterDeclinedToRate]; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m --- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m Thu Sep 10 01:49:15 2015 +0200 @@ -96,8 +96,8 @@ for (int i = 0; i < numberOfPlayingHogs; i++) { NSDictionary *hog = [hogs objectAtIndex:i]; - NSString *hogLevelHealthAndName = [[NSString alloc] initWithFormat:@"eaddhh %@ %d %@", - [hog objectForKey:@"level"], initialHealth, [hog objectForKey:@"hogname"]]; + NSString *hogLevelHealthAndName = [[NSString alloc] initWithFormat:@"eaddhh %@ %ld %@", + [hog objectForKey:@"level"], (long)initialHealth, [hog objectForKey:@"hogname"]]; [self sendToEngine: hogLevelHealthAndName]; [hogLevelHealthAndName release]; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/FlagsViewController.m --- a/project_files/HedgewarsMobile/Classes/FlagsViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/FlagsViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -131,10 +131,10 @@ #pragma mark - #pragma mark Table view delegate -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - int newRow = [indexPath row]; - int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; - int newSection = [indexPath section]; - int oldSection = (lastIndexPath != nil) ? [lastIndexPath section] : -1; + NSInteger newRow = [indexPath row]; + NSInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; + NSInteger newSection = [indexPath section]; + NSInteger oldSection = (lastIndexPath != nil) ? [lastIndexPath section] : -1; if (newRow != oldRow || newSection != oldSection) { NSString *flag = nil; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/FortsViewController.m --- a/project_files/HedgewarsMobile/Classes/FortsViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/FortsViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -106,8 +106,8 @@ #pragma mark - #pragma mark Table view delegate -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - int newRow = [indexPath row]; - int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; + NSInteger newRow = [indexPath row]; + NSInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; if (newRow != oldRow) { // if the two selected rows differ update data on the hog dictionary and reload table content diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/GameConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -238,7 +238,7 @@ [filePath release]; NSArray *hatArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:HATS_DIRECTORY() error:NULL]; - int numberOfHats = [hatArray count]; + NSUInteger numberOfHats = [hatArray count]; int animationFrames = IS_VERY_POWERFUL([HWUtils modelType]) ? 18 : 1; if (self.imgContainer != nil) @@ -246,7 +246,7 @@ self.imgContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 40)]; NSInteger numberOfHogs = 1 + random() % 20; - DLog(@"Drawing %d nice hedgehogs", numberOfHogs); + DLog(@"Drawing %ld nice hedgehogs", (long)numberOfHogs); for (int i = 0; i < numberOfHogs; i++) { NSString *hat = [hatArray objectAtIndex:random()%numberOfHats]; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/GravesViewController.m --- a/project_files/HedgewarsMobile/Classes/GravesViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/GravesViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -88,8 +88,8 @@ #pragma mark - #pragma mark Table view delegate -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - int newRow = [indexPath row]; - int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; + NSInteger newRow = [indexPath row]; + NSInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; if (newRow != oldRow) { [teamDictionary setObject:[[graveArray objectAtIndex:newRow] stringByDeletingPathExtension] forKey:@"grave"]; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/HWUtils.m --- a/project_files/HedgewarsMobile/Classes/HWUtils.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/HWUtils.m Thu Sep 10 01:49:15 2015 +0200 @@ -111,15 +111,15 @@ NSInteger res = 0; do { res = (random() % 64511) + 1024; - } while ([activePorts containsObject:[NSNumber numberWithInt:res]]); + } while ([activePorts containsObject:[NSNumber numberWithInteger:res]]); // add this number to the forbdding list - [activePorts addObject:[NSNumber numberWithInt:res]]; + [activePorts addObject:[NSNumber numberWithInteger:res]]; return res; } +(void) freePort:(NSInteger) port { - [activePorts removeObject:[NSNumber numberWithInt:port]]; + [activePorts removeObject:[NSNumber numberWithInteger:port]]; } +(BOOL) isNetworkReachable { diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/HogHatViewController.m --- a/project_files/HedgewarsMobile/Classes/HogHatViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/HogHatViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -101,8 +101,8 @@ #pragma mark - #pragma mark Table view delegate -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - int newRow = [indexPath row]; - int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; + NSInteger newRow = [indexPath row]; + NSInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; if (newRow != oldRow) { // if the two selected rows differ update data on the hog dictionary and reload table content diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/LevelViewController.m --- a/project_files/HedgewarsMobile/Classes/LevelViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/LevelViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -141,9 +141,9 @@ } [sections release]; - DLog(@"New level is %d",level); + DLog(@"New level is %ld", (long)level); for (NSMutableDictionary *hog in hogs) - [hog setObject:[NSNumber numberWithInt:level] forKey:@"level"]; + [hog setObject:[NSNumber numberWithInteger:level] forKey:@"level"]; [self.tableView reloadData]; [[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil]; @@ -153,8 +153,8 @@ #pragma mark - #pragma mark Table view delegate -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - int newRow = [indexPath row]; - int oldRow = (self.lastIndexPath != nil) ? [self.lastIndexPath row] : -1; + NSInteger newRow = [indexPath row]; + NSInteger oldRow = (self.lastIndexPath != nil) ? [self.lastIndexPath row] : -1; if ([indexPath section] != 0) { if (newRow != oldRow) { @@ -162,8 +162,8 @@ NSInteger level = newRow + 1; for (NSMutableDictionary *hog in hogs) - [hog setObject:[NSNumber numberWithInt:level] forKey:@"level"]; - DLog(@"New level is %d",level); + [hog setObject:[NSNumber numberWithInteger:level] forKey:@"level"]; + DLog(@"New level is %ld", (long)level); // tell our boss to write this new stuff on disk [[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil]; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/MapConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -179,8 +179,8 @@ #pragma mark - #pragma mark Table view delegate -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - int newRow = [indexPath row]; - int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; + NSInteger newRow = [indexPath row]; + NSInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; if (newRow != oldRow) { NSArray *source = [self.dataSourceArray objectAtIndex:scIndex]; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m --- a/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Thu Sep 10 01:49:15 2015 +0200 @@ -25,7 +25,7 @@ #define INDICATOR_TAG 7654 @interface MapPreviewButtonView () -@property (nonatomic) int port; +@property (nonatomic) NSInteger port; @end @implementation MapPreviewButtonView @@ -83,13 +83,13 @@ // Open a connection with the IP provided (listen on the host's port) if (!(sd = SDLNet_TCP_Open(&ip))) { - DLog(@"SDLNet_TCP_Open: %s %d\n", SDLNet_GetError(), self.port); + DLog(@"SDLNet_TCP_Open: %s %ld\n", SDLNet_GetError(), (long)self.port); serverQuit = YES; } // launch the preview in background here so that we're sure the tcp channel is open dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{ - NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", self.port]; + NSString *ipcString = [[NSString alloc] initWithFormat:@"%ld", (long)self.port]; NSString *documentsDirectory = DOCUMENTS_FOLDER(); NSMutableArray *gameParameters = [[NSMutableArray alloc] initWithObjects: @@ -114,7 +114,7 @@ free(argv); }); - DLog(@"Waiting for a client on port %d", self.port); + DLog(@"Waiting for a client on port %ld", (long)self.port); while (!serverQuit) { /* This check the sd if there is a pending connection. * If there is one, accept that, and open a new socket for communicating */ @@ -176,7 +176,7 @@ waitUntilDone:NO]; [previewImage release]; [self performSelectorOnMainThread:@selector(setLabelText:) - withObject:[NSString stringWithFormat:@"%d", maxHogs] + withObject:[NSString stringWithFormat:@"%ld", (long)maxHogs] waitUntilDone:NO]; [self performSelectorOnMainThread:@selector(turnOnWidgets) withObject:nil diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -278,8 +278,8 @@ else lastIndexPath = self.lastIndexPath_lu; - int newRow = [indexPath row]; - int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; + NSInteger newRow = [indexPath row]; + NSInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; if (newRow != oldRow) { //TODO: this code works only for a single section table @@ -299,7 +299,7 @@ if ([[settings objectForKey:@"sync_ws"] boolValue]) { for (NSString *str in self.listOfWeapons) { if ([str isEqualToString:self.selectedScheme]) { - int row = [self.listOfSchemes indexOfObject:str]; + NSInteger row = [self.listOfSchemes indexOfObject:str]; self.selectedWeapon = str; self.lastIndexPath_we = [NSIndexPath indexPathForRow:row inSection:1]; break; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/SettingsBaseViewController.m --- a/project_files/HedgewarsMobile/Classes/SettingsBaseViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/SettingsBaseViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -198,8 +198,8 @@ #pragma mark - #pragma mark Table view delegate -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - int newRow = [indexPath row]; - int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; + NSInteger newRow = [indexPath row]; + NSInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; UIViewController *nextController = nil; if (newRow != oldRow) { diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m --- a/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -287,7 +287,7 @@ // save changes in the main array NSMutableArray *array = [self.schemeDictionary objectForKey:@"basic"]; - [array replaceObjectAtIndex:theSlider.tag-SLIDER_TAG withObject:[NSNumber numberWithInt:(NSInteger) theSlider.value]]; + [array replaceObjectAtIndex:theSlider.tag-SLIDER_TAG withObject:[NSNumber numberWithInteger:theSlider.value]]; } #pragma mark - diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/SquareButtonView.m --- a/project_files/HedgewarsMobile/Classes/SquareButtonView.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/SquareButtonView.m Thu Sep 10 01:49:15 2015 +0200 @@ -61,7 +61,7 @@ -(void) selectColor:(NSUInteger) color { if (color != self.selectedColor) { self.selectedColor = color; - self.colorIndex = [self.colorArray indexOfObject:[NSNumber numberWithUnsignedInt:color]]; + self.colorIndex = [self.colorArray indexOfObject:[NSNumber numberWithUnsignedInteger:color]]; self.backgroundColor = [UIColor colorWithRed:((color & 0x00FF0000) >> 16)/255.0f green:((color & 0x0000FF00) >> 8)/255.0f diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/TeamConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -247,7 +247,7 @@ SquareButtonView *squareButton = (SquareButtonView *)cell.accessoryView; NSInteger increaseNumber = [[selectedRow objectForKey:@"number"] intValue] + 1; - NSNumber *newNumber = [NSNumber numberWithInt:[self filterNumberOfHogs:increaseNumber]]; + NSNumber *newNumber = [NSNumber numberWithInteger:[self filterNumberOfHogs:increaseNumber]]; [squareButton setTitle:[newNumber stringValue] forState:UIControlStateNormal]; [selectedRow setObject:newNumber forKey:@"number"]; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/VoicesViewController.m --- a/project_files/HedgewarsMobile/Classes/VoicesViewController.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/VoicesViewController.m Thu Sep 10 01:49:15 2015 +0200 @@ -104,8 +104,8 @@ #pragma mark - #pragma mark Table view delegate -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - int newRow = [indexPath row]; - int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; + NSInteger newRow = [indexPath row]; + NSInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; if (newRow != oldRow) { [teamDictionary setObject:[voiceArray objectAtIndex:newRow] forKey:@"voicepack"]; diff -r f9c460720e02 -r 064a53861759 project_files/HedgewarsMobile/Classes/WeaponCellView.m --- a/project_files/HedgewarsMobile/Classes/WeaponCellView.m Thu Sep 10 01:31:52 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/WeaponCellView.m Thu Sep 10 01:49:15 2015 +0200 @@ -200,10 +200,10 @@ crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value]; [delegate updateValues:[NSArray arrayWithObjects: - [NSNumber numberWithInt:(int)initialSli.value], - [NSNumber numberWithInt:(int)probabilitySli.value], - [NSNumber numberWithInt:(int)delaySli.value], - [NSNumber numberWithInt:(int)crateSli.value], nil] + [NSNumber numberWithInteger:initialSli.value], + [NSNumber numberWithInteger:probabilitySli.value], + [NSNumber numberWithInteger:delaySli.value], + [NSNumber numberWithInteger:crateSli.value], nil] atIndex:self.tag]; } else DLog(@"error - delegate = nil!");