- Small refactoring for seed command
authorantonc27 <antonc27@mail.ru>
Wed, 24 Feb 2016 00:10:12 +0100
changeset 11576 b709768e720c
parent 11575 fba0c7a5aaf4
child 11577 28afdaa159cb
- Small refactoring for seed command
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Tue Feb 23 23:29:06 2016 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Wed Feb 24 00:10:12 2016 +0100
@@ -241,25 +241,26 @@
 }
 
 +(void) startMissionGame:(NSString *)withScript {
-    // generate a seed
-    NSString *seed = [HWUtils seed];
-    NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed];
-    [seed release];
-    
+    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];
 }
 
-+(void) startSimpleGame {
++(NSString *) seedCommand {
     // generate a seed
     NSString *seed = [HWUtils seed];
     NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed];
     [seed release];
+    return seedCmd;
+}
+
++(void) startSimpleGame {
+    NSString *seedCmd = [self seedCommand];
 
     // pick a random static map
     NSArray *listOfMaps = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];