|
1 unit uFLRunQueue; |
|
2 interface |
|
3 uses uFLTypes; |
|
4 |
|
5 procedure queueExecution(var config: TGameConfig); |
|
6 procedure passFlibEvent(p: pointer); cdecl; |
|
7 |
|
8 implementation |
|
9 uses uFLGameConfig, hwengine, uFLData, uFLUICallback; |
|
10 |
|
11 var runQueue: PGameConfig = nil; |
|
12 |
|
13 procedure nextRun; |
|
14 begin |
|
15 if runQueue <> nil then |
|
16 begin |
|
17 if runQueue^.gameType = gtPreview then |
|
18 sendUI(mtRenderingPreview, nil, 0); |
|
19 |
|
20 RunEngine(runQueue^.argumentsNumber, @runQueue^.argv); |
|
21 |
|
22 sendConfig(runQueue) |
|
23 end |
|
24 end; |
|
25 |
|
26 procedure cleanupConfig; |
|
27 var t: PGameConfig; |
|
28 begin |
|
29 t:= runQueue; |
|
30 runQueue:= t^.nextConfig; |
|
31 dispose(t) |
|
32 end; |
|
33 |
|
34 procedure queueExecution(var config: TGameConfig); |
|
35 var pConfig, t, tt: PGameConfig; |
|
36 i: Longword; |
|
37 begin |
|
38 new(pConfig); |
|
39 pConfig^:= config; |
|
40 |
|
41 with pConfig^ do |
|
42 begin |
|
43 nextConfig:= nil; |
|
44 |
|
45 for i:= 0 to Pred(MAXARGS) do |
|
46 begin |
|
47 if arguments[i][0] = #255 then |
|
48 arguments[i][255]:= #0 |
|
49 else |
|
50 arguments[i][byte(arguments[i][0]) + 1]:= #0; |
|
51 argv[i]:= @arguments[i][1] |
|
52 end; |
|
53 end; |
|
54 |
|
55 if runQueue = nil then |
|
56 begin |
|
57 runQueue:= pConfig; |
|
58 |
|
59 nextRun |
|
60 end else |
|
61 begin |
|
62 t:= runQueue; |
|
63 while t^.nextConfig <> nil do |
|
64 begin |
|
65 if (pConfig^.gameType = gtPreview) and (t^.nextConfig^.gameType = gtPreview) 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 t^.nextConfig:= pConfig |
|
76 end; |
|
77 end; |
|
78 |
|
79 procedure passFlibEvent(p: pointer); cdecl; |
|
80 begin |
|
81 case TFLIBEvent(p^) of |
|
82 flibGameFinished: begin |
|
83 cleanupConfig; |
|
84 nextRun |
|
85 end; |
|
86 end; |
|
87 end; |
|
88 |
|
89 end. |