- Send also some seed when loading missions on iOS (same behavior as on desktop)
authorantonc27 <antonc27@mail.ru>
Fri, 19 Feb 2016 00:07:59 +0100
changeset 11560 b96080df19d0
parent 11559 73e6a3d2f768
child 11561 af9aa8d5863c
- Send also some seed when loading missions on iOS (same behavior as on desktop)
project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
--- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Wed Feb 17 23:27:13 2016 +0100
+++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Fri Feb 19 00:07:59 2016 +0100
@@ -273,13 +273,14 @@
                 NSString *script = [gameConfig objectForKey:@"mission_command"];
                 if ([script length] != 0)
                     [self sendToEngine:script];
-                // missions/tranings only need the script configuration set
-                if ([gameConfig count] == 1)
-                    break;
-
+                
                 // seed info
                 [self sendToEngine:[gameConfig objectForKey:@"seed_command"]];
 
+                // missions/tranings only need the script configuration set and seed
+                if ([HWUtils gameType] == gtMission)
+                    break;
+                
                 // dimension of the map
                 [self sendToEngine:[gameConfig objectForKey:@"templatefilter_command"]];
                 [self sendToEngine:[gameConfig objectForKey:@"mapgen_command"]];
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Wed Feb 17 23:27:13 2016 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Fri Feb 19 00:07:59 2016 +0100
@@ -241,12 +241,18 @@
 }
 
 +(void) startMissionGame:(NSString *)withScript {
+    // generate a seed
+    NSString *seed = [HWUtils seed];
+    NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed];
+    [seed release];
+    
     NSString *missionPath = [[NSString alloc] initWithFormat:@"escript Missions/Training/%@.lua",withScript];
-    NSDictionary *missionLine = [[NSDictionary alloc] initWithObjectsAndKeys:missionPath,@"mission_command",nil];
+    
+    NSDictionary *missionDict = [[NSDictionary alloc] initWithObjectsAndKeys:missionPath, @"mission_command", seedCmd, @"seed_command", nil];
     [missionPath release];
 
-    [self startGame:gtMission atPath:nil withOptions:missionLine];
-    [missionLine release];
+    [self startGame:gtMission atPath:nil withOptions:missionDict];
+    [missionDict release];
 }
 
 +(void) startSimpleGame {