author | unc0rr |
Sat, 12 Dec 2015 23:38:18 +0300 | |
branch | qmlfrontend |
changeset 11457 | 78860824b5a5 |
parent 11456 | 6e9b12864856 |
child 11461 | ab77e2ea2f82 |
permissions | -rw-r--r-- |
11439 | 1 |
unit uFLRunQueue; |
2 |
interface |
|
3 |
uses uFLTypes; |
|
4 |
||
5 |
procedure queueExecution(var config: TGameConfig); |
|
6 |
procedure passFlibEvent(p: pointer); cdecl; |
|
7 |
||
8 |
implementation |
|
11456 | 9 |
uses uFLGameConfig, hwengine, uFLData, uFLUICallback, uFLIPC; |
11439 | 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 |
||
11457
78860824b5a5
Introduce barriers between messages to different engine instances
unc0rr
parents:
11456
diff
changeset
|
20 |
ipcRemoveBarrierFromEngineQueue(); |
11439 | 21 |
RunEngine(runQueue^.argumentsNumber, @runQueue^.argv); |
22 |
||
23 |
sendConfig(runQueue) |
|
24 |
end |
|
25 |
end; |
|
26 |
||
27 |
procedure cleanupConfig; |
|
28 |
var t: PGameConfig; |
|
29 |
begin |
|
30 |
t:= runQueue; |
|
31 |
runQueue:= t^.nextConfig; |
|
32 |
dispose(t) |
|
33 |
end; |
|
34 |
||
35 |
procedure queueExecution(var config: TGameConfig); |
|
36 |
var pConfig, t, tt: PGameConfig; |
|
37 |
i: Longword; |
|
38 |
begin |
|
11457
78860824b5a5
Introduce barriers between messages to different engine instances
unc0rr
parents:
11456
diff
changeset
|
39 |
ipcSetEngineBarrier(); |
78860824b5a5
Introduce barriers between messages to different engine instances
unc0rr
parents:
11456
diff
changeset
|
40 |
|
11439 | 41 |
new(pConfig); |
42 |
pConfig^:= config; |
|
43 |
||
44 |
with pConfig^ do |
|
45 |
begin |
|
46 |
nextConfig:= nil; |
|
47 |
||
48 |
for i:= 0 to Pred(MAXARGS) do |
|
49 |
begin |
|
50 |
if arguments[i][0] = #255 then |
|
51 |
arguments[i][255]:= #0 |
|
52 |
else |
|
53 |
arguments[i][byte(arguments[i][0]) + 1]:= #0; |
|
54 |
argv[i]:= @arguments[i][1] |
|
55 |
end; |
|
56 |
end; |
|
57 |
||
58 |
if runQueue = nil then |
|
59 |
begin |
|
60 |
runQueue:= pConfig; |
|
61 |
||
62 |
nextRun |
|
63 |
end else |
|
64 |
begin |
|
65 |
t:= runQueue; |
|
66 |
while t^.nextConfig <> nil do |
|
67 |
begin |
|
68 |
if (pConfig^.gameType = gtPreview) and (t^.nextConfig^.gameType = gtPreview) then |
|
69 |
begin |
|
70 |
tt:= t^.nextConfig; |
|
71 |
pConfig^.nextConfig:= tt^.nextConfig; |
|
72 |
t^.nextConfig:= pConfig; |
|
73 |
dispose(tt); |
|
74 |
exit // boo |
|
75 |
end; |
|
76 |
t:= t^.nextConfig; |
|
77 |
end; |
|
78 |
t^.nextConfig:= pConfig |
|
79 |
end; |
|
80 |
end; |
|
81 |
||
82 |
procedure passFlibEvent(p: pointer); cdecl; |
|
83 |
begin |
|
84 |
case TFLIBEvent(p^) of |
|
85 |
flibGameFinished: begin |
|
86 |
cleanupConfig; |
|
87 |
nextRun |
|
11456 | 88 |
end; |
89 |
flibRunNetGame: begin |
|
90 |
runNetGame |
|
91 |
end; |
|
11439 | 92 |
end; |
93 |
end; |
|
94 |
||
95 |
end. |