hedgewars/uFLRunQueue.pas
branchqmlfrontend
changeset 12861 488782d9aba9
parent 12860 e33bcb9d5e9c
child 12863 fe16fa088b69
equal deleted inserted replaced
12860:e33bcb9d5e9c 12861:488782d9aba9
     1 unit uFLRunQueue;
       
     2 interface
       
     3 uses uFLTypes;
       
     4 
       
     5 procedure queueExecution(var config: TGameConfig);
       
     6 
       
     7 implementation
       
     8 uses hwengine, uFLUICallback, uFLIPC;
       
     9 
       
    10 var runQueue: PGameConfig = nil;
       
    11 
       
    12 procedure nextRun;
       
    13 begin
       
    14     if runQueue <> nil then
       
    15     begin
       
    16         if runQueue^.gameType = gtPreview then
       
    17             sendUI(mtRenderingPreview, nil, 0);
       
    18 
       
    19         ipcRemoveBarrierFromEngineQueue();
       
    20         RunEngine(runQueue^.argumentsNumber, @runQueue^.argv);
       
    21     end
       
    22 end;
       
    23 
       
    24 procedure cleanupConfig;
       
    25 var t: PGameConfig;
       
    26 begin
       
    27     t:= runQueue;
       
    28     runQueue:= t^.nextConfig;
       
    29     dispose(t)
       
    30 end;
       
    31 
       
    32 procedure queueExecution(var config: TGameConfig);
       
    33 var pConfig, t, tt: PGameConfig;
       
    34     i: Longword;
       
    35 begin
       
    36     new(pConfig);
       
    37     pConfig^:= config;
       
    38 
       
    39     with pConfig^ do
       
    40     begin
       
    41         nextConfig:= nil;
       
    42 
       
    43         for i:= 0 to Pred(MAXARGS) do
       
    44         begin
       
    45             if arguments[i][0] = #255 then
       
    46                 arguments[i][255]:= #0
       
    47             else
       
    48                 arguments[i][byte(arguments[i][0]) + 1]:= #0;
       
    49             argv[i]:= @arguments[i][1]
       
    50         end;
       
    51     end;
       
    52 
       
    53     if runQueue = nil then
       
    54     begin
       
    55         runQueue:= pConfig;
       
    56 
       
    57         ipcSetEngineBarrier();
       
    58         //sendConfig(pConfig);
       
    59         nextRun
       
    60     end else
       
    61     begin
       
    62         t:= runQueue;
       
    63         while t^.nextConfig <> nil do 
       
    64         begin
       
    65             if false and (pConfig^.gameType = gtPreview) and (t^.nextConfig^.gameType = gtPreview) and (t <> runQueue) then
       
    66             begin
       
    67                 tt:= t^.nextConfig;
       
    68                 pConfig^.nextConfig:= tt^.nextConfig;
       
    69                 t^.nextConfig:= pConfig;
       
    70                 dispose(tt);
       
    71                 exit // boo
       
    72             end;
       
    73             t:= t^.nextConfig;
       
    74         end;
       
    75 
       
    76         ipcSetEngineBarrier();
       
    77         //sendConfig(pConfig);
       
    78         t^.nextConfig:= pConfig
       
    79     end;
       
    80 end;
       
    81 
       
    82 end.