author | unc0rr |
Sun, 20 Dec 2015 12:45:49 +0300 | |
branch | qmlfrontend |
changeset 11465 | 9f2fb0031ef0 |
parent 11464 | 30397f91571c |
child 12863 | 0c6fb706f747 |
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 |
|
11461 | 9 |
uses uFLGameConfig, hwengine, uFLThemes, 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 |
end |
|
23 |
end; |
|
24 |
||
25 |
procedure cleanupConfig; |
|
26 |
var t: PGameConfig; |
|
27 |
begin |
|
28 |
t:= runQueue; |
|
29 |
runQueue:= t^.nextConfig; |
|
30 |
dispose(t) |
|
31 |
end; |
|
32 |
||
33 |
procedure queueExecution(var config: TGameConfig); |
|
34 |
var pConfig, t, tt: PGameConfig; |
|
35 |
i: Longword; |
|
36 |
begin |
|
37 |
new(pConfig); |
|
38 |
pConfig^:= config; |
|
39 |
||
40 |
with pConfig^ do |
|
41 |
begin |
|
42 |
nextConfig:= nil; |
|
43 |
||
44 |
for i:= 0 to Pred(MAXARGS) do |
|
45 |
begin |
|
46 |
if arguments[i][0] = #255 then |
|
47 |
arguments[i][255]:= #0 |
|
48 |
else |
|
49 |
arguments[i][byte(arguments[i][0]) + 1]:= #0; |
|
50 |
argv[i]:= @arguments[i][1] |
|
51 |
end; |
|
52 |
end; |
|
53 |
||
54 |
if runQueue = nil then |
|
55 |
begin |
|
56 |
runQueue:= pConfig; |
|
57 |
||
11464
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
58 |
ipcSetEngineBarrier(); |
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
59 |
sendConfig(pConfig); |
11439 | 60 |
nextRun |
61 |
end else |
|
62 |
begin |
|
63 |
t:= runQueue; |
|
64 |
while t^.nextConfig <> nil do |
|
65 |
begin |
|
11464
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
66 |
if false and (pConfig^.gameType = gtPreview) and (t^.nextConfig^.gameType = gtPreview) and (t <> runQueue) then |
11439 | 67 |
begin |
68 |
tt:= t^.nextConfig; |
|
69 |
pConfig^.nextConfig:= tt^.nextConfig; |
|
70 |
t^.nextConfig:= pConfig; |
|
71 |
dispose(tt); |
|
72 |
exit // boo |
|
73 |
end; |
|
74 |
t:= t^.nextConfig; |
|
75 |
end; |
|
11464
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
76 |
|
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
77 |
ipcSetEngineBarrier(); |
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
78 |
sendConfig(pConfig); |
11439 | 79 |
t^.nextConfig:= pConfig |
80 |
end; |
|
81 |
end; |
|
82 |
||
83 |
procedure passFlibEvent(p: pointer); cdecl; |
|
84 |
begin |
|
85 |
case TFLIBEvent(p^) of |
|
86 |
flibGameFinished: begin |
|
11465 | 87 |
cleanupConfig; |
88 |
nextRun |
|
89 |
end; |
|
11439 | 90 |
end; |
91 |
end; |
|
92 |
||
93 |
end. |