hedgewars/uFLGameConfig.pas
branchqmlfrontend
changeset 11447 6b04a266feee
parent 11445 330c14f4ba69
child 11448 5182d44fb733
equal deleted inserted replaced
11446:908aed8525f9 11447:6b04a266feee
    26 procedure netSetMap(map: shortstring);
    26 procedure netSetMap(map: shortstring);
    27 procedure netSetMazeSize(mazesize: LongInt);
    27 procedure netSetMazeSize(mazesize: LongInt);
    28 procedure netSetTemplate(template: LongInt);
    28 procedure netSetTemplate(template: LongInt);
    29 procedure netSetAmmo(name: shortstring; definition: ansistring);
    29 procedure netSetAmmo(name: shortstring; definition: ansistring);
    30 procedure netSetScheme(scheme: TScheme);
    30 procedure netSetScheme(scheme: TScheme);
       
    31 procedure netAddTeam(team: TTeam);
       
    32 procedure netSetTeamColor(team: shortstring; color: Longword);
    31 procedure updatePreviewIfNeeded;
    33 procedure updatePreviewIfNeeded;
    32 
    34 
    33 procedure sendConfig(config: PGameConfig);
    35 procedure sendConfig(config: PGameConfig);
    34 
    36 
    35 implementation
    37 implementation
    55                 ipcToEngine('escript ' + getScriptPath(script));
    57                 ipcToEngine('escript ' + getScriptPath(script));
    56             ipcToEngine('eseed ' + seed);
    58             ipcToEngine('eseed ' + seed);
    57             ipcToEngine('e$mapgen ' + intToStr(mapgen));
    59             ipcToEngine('e$mapgen ' + intToStr(mapgen));
    58             ipcToEngine('e$template_filter ' + intToStr(template));
    60             ipcToEngine('e$template_filter ' + intToStr(template));
    59             ipcToEngine('e$feature_size ' + intToStr(featureSize));
    61             ipcToEngine('e$feature_size ' + intToStr(featureSize));
       
    62             ipcToEngine('e$maze_size ' + intToStr(mazeSize));
    60         end;
    63         end;
    61     gtLocal: begin
    64     gtLocal: begin
    62             if script <> 'Normal' then
    65             if script <> 'Normal' then
    63                 ipcToEngine('escript ' + getScriptPath(script));
    66                 ipcToEngine('escript ' + getScriptPath(script));
    64             ipcToEngine('eseed ' + seed);
    67             ipcToEngine('eseed ' + seed);
    65             ipcToEngine('e$mapgen ' + intToStr(mapgen));
    68             ipcToEngine('e$mapgen ' + intToStr(mapgen));
    66             ipcToEngine('e$template_filter ' + intToStr(template));
    69             ipcToEngine('e$template_filter ' + intToStr(template));
    67             ipcToEngine('e$feature_size ' + intToStr(featureSize));
    70             ipcToEngine('e$feature_size ' + intToStr(featureSize));
    68             ipcToEngine('e$theme ' + theme);
    71             ipcToEngine('e$theme ' + theme);
       
    72             ipcToEngine('e$maze_size ' + intToStr(mazeSize));
    69 
    73 
    70             sendSchemeConfig(scheme);
    74             sendSchemeConfig(scheme);
    71 
    75 
    72             i:= 0;
    76             i:= 0;
    73             while (i < 8) and (teams[i].hogsNumber > 0) do
    77             while (i < 8) and (teams[i].hogsNumber > 0) do
   413 begin
   417 begin
   414     currentConfig.scheme:= scheme;
   418     currentConfig.scheme:= scheme;
   415     sendUI(mtScheme, @scheme.schemeName[1], length(scheme.schemeName))
   419     sendUI(mtScheme, @scheme.schemeName[1], length(scheme.schemeName))
   416 end;
   420 end;
   417 
   421 
       
   422 procedure netAddTeam(team: TTeam);
       
   423 var msg: ansistring;
       
   424     i, hn, hedgehogsNumber: Longword;
       
   425     c: Longword;
       
   426 begin
       
   427     with currentConfig do
       
   428     begin
       
   429         hedgehogsNumber:= 0;
       
   430         i:= 0;
       
   431 
       
   432         while (i < 8) and (teams[i].hogsNumber > 0) do
       
   433         begin
       
   434             inc(i);
       
   435             inc(hedgehogsNumber, teams[i].hogsNumber)
       
   436         end;
       
   437 
       
   438         // no free space for a team - server bug???
       
   439         if (i > 7) or (hedgehogsNumber >= 48) then exit;
       
   440 
       
   441         c:= getUnusedColor;
       
   442 
       
   443         teams[i]:= team;
       
   444 
       
   445         if i = 0 then hn:= 4 else hn:= teams[i - 1].hogsNumber;
       
   446         if hn > 48 - hedgehogsNumber then hn:= 48 - hedgehogsNumber;
       
   447         teams[i].hogsNumber:= hn;
       
   448 
       
   449         teams[i].color:= c;
       
   450 
       
   451         msg:= '0' + #10 + team.teamName;
       
   452         sendUI(mtAddPlayingTeam, @msg[1], length(msg));
       
   453 
       
   454         msg:= team.teamName + #10 + colorsSet[teams[i].color];
       
   455         sendUI(mtTeamColor, @msg[1], length(msg));
       
   456     end
       
   457 end;
       
   458 
       
   459 procedure netSetTeamColor(team: shortstring; color: Longword);
       
   460 var i: Longword;
       
   461     msg:  ansistring;
       
   462 begin
       
   463     with currentConfig do
       
   464     begin
       
   465         i:= 0;
       
   466 
       
   467         while (i < 8) and (teams[i].teamName <> team) do
       
   468             inc(i);
       
   469         // team not found???
       
   470         if (i > 7) then exit;
       
   471 
       
   472         teams[i].color:= color mod 9;
       
   473 
       
   474         msg:= team + #10 + colorsSet[teams[i].color];
       
   475         sendUI(mtTeamColor, @msg[1], length(msg))
       
   476     end
       
   477 end;
       
   478 
   418 end.
   479 end.