diff -r 2c06b1120749 -r 00215a7ec5f5 project_files/HedgewarsMobile/Classes/HWUtils.m --- a/project_files/HedgewarsMobile/Classes/HWUtils.m Fri Dec 29 22:37:31 2017 +0100 +++ b/project_files/HedgewarsMobile/Classes/HWUtils.m Sat Dec 30 01:22:11 2017 +0100 @@ -35,33 +35,33 @@ #pragma mark - #pragma mark game status and type info -+(TGameType) gameType { ++ (TGameType)gameType { return gameType; } -+(void) setGameType:(TGameType) type { ++ (void)setGameType:(TGameType)type { gameType = type; } -+(TGameStatus) gameStatus { ++ (TGameStatus)gameStatus { return gameStatus; } -+(void) setGameStatus:(TGameStatus) status { ++ (void)setGameStatus:(TGameStatus)status { gameStatus = status; } -+(BOOL) isGameLaunched { ++ (BOOL)isGameLaunched { return ((gameStatus == gsLoading) || (gameStatus == gsInGame)); } -+(BOOL) isGameRunning { ++ (BOOL)isGameRunning { return (gameStatus == gsInGame); } #pragma mark - #pragma mark Helper Functions with cache -+(NSString *)modelType { ++ (NSString *)modelType { if (cachedModel == nil) { size_t size; // set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space @@ -70,13 +70,13 @@ // get the platform name sysctlbyname("hw.machine", name, &size, NULL, 0); - cachedModel = [[NSString stringWithUTF8String:name] retain]; + cachedModel = [NSString stringWithUTF8String:name]; free(name); } return cachedModel; } -+(NSArray *)teamColors { ++ (NSArray *)teamColors { if (cachedColors == nil) { // by default colors are ARGB but we do computation over RGB, hence we have to "& 0x00FFFFFF" before processing unsigned int colors[] = HW_TEAMCOLOR_ARRAY; @@ -86,24 +86,23 @@ while(colors[i] != 0) [array addObject:[NSNumber numberWithUnsignedInt:(colors[i++] & 0x00FFFFFF)]]; - cachedColors = [[NSArray arrayWithArray:array] retain]; - [array release]; + cachedColors = [NSArray arrayWithArray:array]; } return cachedColors; } -+(void) releaseCache { - [cachedModel release], cachedModel = nil; - [cachedColors release], cachedColors = nil; ++ (void)releaseCache { + cachedModel = nil; + cachedColors = nil; // don't release activePorts here } #pragma mark - #pragma mark Helper Functions without cache -+(NSInteger) randomPort { ++ (NSInteger)randomPort { // set a new feed only at initialization time and forbid connecting to the server port if (activePorts == nil) { - activePorts = [[NSMutableArray arrayWithObject:[NSNumber numberWithInt:NETGAME_DEFAULT_PORT]] retain]; + activePorts = [NSMutableArray arrayWithObject:[NSNumber numberWithInt:NETGAME_DEFAULT_PORT]]; } // pick a random number from the free ports list @@ -117,11 +116,11 @@ return res; } -+(void) freePort:(NSInteger) port { ++ (void)freePort:(NSInteger)port { [activePorts removeObject:[NSNumber numberWithInteger:port]]; } -+(BOOL) isNetworkReachable { ++ (BOOL)isNetworkReachable { // Create zero addy struct sockaddr_in zeroAddress; bzero(&zeroAddress, sizeof(zeroAddress)); @@ -150,7 +149,6 @@ timeoutInterval:20.0]; NSURLConnection *testConnection = [[NSURLConnection alloc] initWithRequest:testRequest delegate:nil]; BOOL testResult = testConnection ? YES : NO; - [testConnection release]; return ((isReachable && !needsConnection) || nonWiFi) ? testResult : NO; } @@ -162,7 +160,7 @@ } /* -+(UIView *)mainSDLViewInstance { ++ (UIView *)mainSDLViewInstance { SDL_Window *window = HW_getSDLWindow(); if (window == NULL) { SDL_SetError("Window does not exist"); @@ -177,7 +175,7 @@ + (NSString *)seed { CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); - NSString *seed = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid); + NSString *seed = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, uuid)); CFRelease(uuid); return seed; }