hedgewars/uFLGameConfig.pas
branchqmlfrontend
changeset 11467 33a0e3a14ddc
parent 11463 8318e841648f
child 11485 b0c34402038c
--- a/hedgewars/uFLGameConfig.pas	Sun Dec 20 12:45:49 2015 +0300
+++ b/hedgewars/uFLGameConfig.pas	Sat Dec 26 22:29:57 2015 +0300
@@ -33,6 +33,7 @@
 procedure netSetTeamColor(team: shortstring; color: Longword);
 procedure netSetHedgehogsNumber(team: shortstring; hogsNumber: Longword);
 procedure netRemoveTeam(teamName: shortstring);
+procedure netDrawnData(data: ansistring);
 procedure netResetTeams();
 procedure updatePreviewIfNeeded;
 
@@ -40,7 +41,8 @@
 procedure runNetGame();
 
 implementation
-uses uFLIPC, uFLUtils, uFLTeams, uFLThemes, uFLSChemes, uFLAmmo, uFLUICallback, uFLRunQueue, uFLNet;
+uses uFLIPC, uFLUtils, uFLTeams, uFLThemes, uFLSChemes, uFLAmmo
+    , uFLUICallback, uFLRunQueue, uFLNet, uUtils;
 
 var
     currentConfig: TGameConfig;
@@ -51,6 +53,24 @@
     getScriptPath:= '/Scripts/Multiplayer/' + scriptName + '.lua'
 end;
 
+procedure sendDrawnMap(config: PGameConfig);
+var i: Longword;
+    s: shortstring;
+begin
+    i:= 1;
+
+    while i < config^.drawnDataSize do
+    begin
+        if config^.drawnDataSize - i > 240 then
+            s:= copy(config^.drawnData, i, 240)
+        else
+            s:= copy(config^.drawnData, i, config^.drawnDataSize - i);
+        system.writeln('[DRAWN MAP] ', s);
+        ipcToEngine('edraw ' + DecodeBase64(s));
+        inc(i, 240)
+    end;
+end;
+
 procedure sendConfig(config: PGameConfig);
 var i: Longword;
 begin
@@ -67,6 +87,8 @@
             else
                 ipcToEngine('e$template_filter ' + intToStr(template));
             ipcToEngine('e$feature_size ' + intToStr(featureSize));
+            if mapgen = 3 then
+                sendDrawnMap(config);
         end;
 gtLocal, gtNet: begin
             if gameType = gtNet then
@@ -81,6 +103,8 @@
                 ipcToEngine('e$template_filter ' + intToStr(template));
             ipcToEngine('e$feature_size ' + intToStr(featureSize));
             ipcToEngine('e$theme ' + theme);
+            if mapgen = 3 then
+                sendDrawnMap(config);
 
             sendSchemeConfig(scheme);
 
@@ -640,4 +664,12 @@
     end;
 end;
 
+procedure netDrawnData(data: ansistring);
+begin
+    currentConfig.drawnDataSize:= length(data);
+    currentConfig.drawnData:= data;
+
+    getPreview
+end;
+
 end.