project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
branchios-revival
changeset 11206 2e80c9861818
parent 11199 3465047397da
child 11219 c51ecb9bcf05
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Wed Oct 14 02:28:32 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Wed Oct 14 21:25:49 2015 +0200
@@ -252,8 +252,6 @@
 }
 
 +(void) startSimpleGame {
-    srand(time(0));
-
     // generate a seed
     CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
     NSString *seed = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid);
@@ -263,7 +261,7 @@
 
     // pick a random static map
     NSArray *listOfMaps = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];
-    NSString *mapName = [listOfMaps objectAtIndex:random()%[listOfMaps count]];
+    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];
@@ -276,8 +274,8 @@
     NSArray *colorArray = [HWUtils teamColors];
     NSInteger firstColorIndex, secondColorIndex;
     do {
-        firstColorIndex = random()%[colorArray count];
-        secondColorIndex = random()%[colorArray count];
+        firstColorIndex = arc4random_uniform((int)[colorArray count]);
+        secondColorIndex = arc4random_uniform((int)[colorArray count]);
     } while (firstColorIndex == secondColorIndex);
     unsigned int firstColor = [[colorArray objectAtIndex:firstColorIndex] intValue];
     unsigned int secondColor = [[colorArray objectAtIndex:secondColorIndex] intValue];