hedgewars/hwengine.pas
changeset 3365 37ac593e9027
parent 3312 6d8f1c76756d
child 3369 c7289e42f0ee
--- a/hedgewars/hwengine.pas	Thu Apr 22 17:43:12 2010 +0000
+++ b/hedgewars/hwengine.pas	Sun Apr 25 02:30:42 2010 +0000
@@ -324,6 +324,8 @@
 
 procedure initEverything;
 begin
+    Randomize();
+
     uConsts.initModule;
     uMisc.initModule;
     uConsole.initModule;    // MUST happen after uMisc
@@ -395,21 +397,27 @@
 end;
 
 /////////////////////////
-procedure GenLandPreview;
+procedure GenLandPreview{$IFDEF IPHONEOS}(port: LongInt){$ENDIF}; {$IFDEF HWLIBRARY}cdecl; export;{$ENDIF}
 var Preview: TPreview;
-    h: byte;
 begin
+{$IFDEF IPHONEOS}
+    initEverything();
+    WriteLnToConsole('Preview connecting on port ' + inttostr(port));
+    ipcPort:= port;
+{$ENDIF}
     InitIPC;
     IPCWaitPongEvent;
     TryDo(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
 
-    Preview:= GenPreview;
+    Preview:= GenPreview();
     WriteLnToConsole('Sending preview...');
     SendIPCRaw(@Preview, sizeof(Preview));
-    h:= MaxHedgehogs;
-    SendIPCRaw(@h, sizeof(h));
+    SendIPCRaw(@MaxHedgehogs, sizeof(byte));
     WriteLnToConsole('Preview sent, disconnect');
     CloseIPC();
+{$IFDEF IPHONEOS}
+    freeEverything();
+{$ENDIF}
 end;
 
 {$IFNDEF HWLIBRARY}
@@ -580,7 +588,6 @@
     WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
     
     GetParams();
-    Randomize();
 
     if GameType = gmtLandPreview then GenLandPreview()
     else if GameType = gmtSyntax then DisplayUsage()