--- a/hedgewars/uFLGameConfig.pas Sun Sep 28 00:18:01 2014 +0400
+++ b/hedgewars/uFLGameConfig.pas Sun Sep 28 00:49:04 2014 +0400
@@ -1,12 +1,18 @@
unit uFLGameConfig;
-
interface
+uses uFLTypes;
procedure resetGameConfig; cdecl; export;
procedure runQuickGame; cdecl; export;
procedure getPreview; cdecl; export;
+procedure registerGUIMessagesCallback(p: pointer; f: TGUICallback); cdecl; export;
+
implementation
+uses uFLIPC, hwengine;
+
+var guiCallbackPointer: pointer;
+ guiCallbackFunction: TGUICallback;
const
MAXCONFIGS = 5;
@@ -54,9 +60,9 @@
for i:= 0 to Pred(MAXARGS) do
begin
if arguments[i][0] = #255 then
- arguments[i][255] = #0
+ arguments[i][255]:= #0
else
- arguments[i][byte(arguments[i][0]) + 1] = #0;
+ arguments[i][byte(arguments[i][0]) + 1]:= #0;
argv[i]:= @arguments[i][1]
end;
@@ -81,9 +87,26 @@
arguments[1]:= '--internal';
arguments[2]:= '--landpreview';
argumentsNumber:= 3;
+
+ queueExecution;
+
+ ipcToEngine('eseed ' + seed);
+ ipcToEngine('e$mapgen 0');
+ ipcToEngine('!');
end;
+end;
- queueExecution
+procedure engineMessageCallback(p: pointer; msg: PChar; len: Longword);
+begin
+ if len = 128 * 256 then guiCallbackFunction(guiCallbackPointer, mtPreview, msg, len)
+end;
+
+procedure registerGUIMessagesCallback(p: pointer; f: TGUICallback); cdecl; export;
+begin
+ guiCallbackPointer:= p;
+ guiCallbackFunction:= f;
+
+ registerIPCCallback(nil, @engineMessageCallback)
end;
end.