author | unc0rr |
Tue, 15 Mar 2016 22:29:40 +0300 | |
branch | qmlfrontend |
changeset 11607 | f0dcdbb9b2fe |
parent 11460 | 9f2fb0031ef0 |
child 12858 | 0c6fb706f747 |
permissions | -rw-r--r-- |
11434 | 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, uFLThemes, uFLUICallback, uFLIPC; |
11434 | 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 |
||
11452
78860824b5a5
Introduce barriers between messages to different engine instances
unc0rr
parents:
11451
diff
changeset
|
20 |
ipcRemoveBarrierFromEngineQueue(); |
11434 | 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 |
||
11459
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11456
diff
changeset
|
58 |
ipcSetEngineBarrier(); |
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11456
diff
changeset
|
59 |
sendConfig(pConfig); |
11434 | 60 |
nextRun |
61 |
end else |
|
62 |
begin |
|
63 |
t:= runQueue; |
|
64 |
while t^.nextConfig <> nil do |
|
65 |
begin |
|
11459
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11456
diff
changeset
|
66 |
if false and (pConfig^.gameType = gtPreview) and (t^.nextConfig^.gameType = gtPreview) and (t <> runQueue) then |
11434 | 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; |
|
11459
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11456
diff
changeset
|
76 |
|
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11456
diff
changeset
|
77 |
ipcSetEngineBarrier(); |
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11456
diff
changeset
|
78 |
sendConfig(pConfig); |
11434 | 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 |
|
11460 | 87 |
cleanupConfig; |
88 |
nextRun |
|
89 |
end; |
|
11434 | 90 |
end; |
91 |
end; |
|
92 |
||
93 |
end. |