hedgewars/uFLGameConfig.pas
branchqmlfrontend
changeset 10426 727a154cf784
parent 10406 b5fd52ac760f
child 10428 7c25297720f1
equal deleted inserted replaced
10424:4be6cd55f1cf 10426:727a154cf784
     1 unit uFLGameConfig;
     1 unit uFLGameConfig;
     2 
     2 
     3 interface
     3 interface
     4 
     4 
     5 procedure ResetGameConfig; cdecl; export;
     5 procedure resetGameConfig; cdecl; export;
       
     6 procedure runQuickGame; cdecl; export;
       
     7 procedure getPreview; cdecl; export;
     6 
     8 
     7 implementation
     9 implementation
     8 
    10 
     9 procedure ResetGameConfig; cdecl;
    11 const
       
    12     MAXCONFIGS = 5;
       
    13     MAXARGS = 32;
       
    14 
       
    15 type
       
    16     TGameType = (gtPreview, gtLocal);
       
    17     THedgehog = record
       
    18             name: shortstring;
       
    19             hat: shortstring;
       
    20             end;
       
    21     TTeam = record
       
    22             teamName: shortstring;
       
    23             flag: shortstring;
       
    24             graveName: shortstring;
       
    25             fortName: shortstring;
       
    26             owner: shortstring;
       
    27             extDriven: boolean;
       
    28             botLevel: Longword;
       
    29             hedgehogs: array[0..7] of THedgehog;
       
    30             hogsNumber: Longword;
       
    31             end;
       
    32     TGameConfig = record
       
    33             seed: shortstring;
       
    34             theme: shortstring;
       
    35             script: shortstring;
       
    36             gameType: TGameType;
       
    37             teams: array[0..7] of TTeam;
       
    38             arguments: array[0..Pred(MAXARGS)] of shortstring;
       
    39             argv: array[0..Pred(MAXARGS)] of PChar;
       
    40             argumentsNumber: Longword;
       
    41             end;
       
    42     PGameConfig = ^TGameConfig;
       
    43 
       
    44 var currentConfig: TGameConfig;
       
    45 
       
    46 procedure queueExecution;
       
    47 var pConfig: PGameConfig;
       
    48     i: Longword;
       
    49 begin
       
    50     new(pConfig);
       
    51     pConfig^:= currentConfig;
       
    52 
       
    53     with pConfig^ do
       
    54         for i:= 0 to Pred(MAXARGS) do
       
    55         begin
       
    56             if arguments[i][0] = #255 then 
       
    57                 arguments[i][255] = #0
       
    58             else
       
    59                 arguments[i][byte(arguments[i][0]) + 1] = #0;
       
    60             argv[i]:= @arguments[i][1]
       
    61         end;
       
    62 
       
    63     RunEngine(pConfig^.argumentsNumber, @pConfig^.argv);
       
    64 end;
       
    65 
       
    66 procedure resetGameConfig; cdecl;
    10 begin
    67 begin
    11 end;
    68 end;
    12 
    69 
       
    70 procedure runQuickGame; cdecl; export;
       
    71 begin
       
    72 
       
    73 end;
       
    74 
       
    75 procedure getPreview; cdecl; export;
       
    76 begin
       
    77     with currentConfig do
       
    78     begin
       
    79         gameType:= gtPreview;
       
    80         arguments[0]:= '';
       
    81         arguments[1]:= '--internal';
       
    82         arguments[2]:= '--landpreview';
       
    83         argumentsNumber:= 3;
       
    84     end;
       
    85 
       
    86     queueExecution
       
    87 end;
       
    88 
    13 end.
    89 end.