author | unc0rr |
Thu, 17 Dec 2015 00:51:20 +0300 | |
branch | qmlfrontend |
changeset 11464 | 30397f91571c |
parent 11461 | ab77e2ea2f82 |
child 11465 | 9f2fb0031ef0 |
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 |
|
11464
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
17 |
writeln('RUNNING ', runQueue^.gameType); |
11439 | 18 |
if runQueue^.gameType = gtPreview then |
19 |
sendUI(mtRenderingPreview, nil, 0); |
|
20 |
||
11457
78860824b5a5
Introduce barriers between messages to different engine instances
unc0rr
parents:
11456
diff
changeset
|
21 |
ipcRemoveBarrierFromEngineQueue(); |
11439 | 22 |
RunEngine(runQueue^.argumentsNumber, @runQueue^.argv); |
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 |
|
11464
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
38 |
writeln('QUEUE EXECUTION ', config.gameType); |
11439 | 39 |
new(pConfig); |
40 |
pConfig^:= config; |
|
41 |
||
42 |
with pConfig^ do |
|
43 |
begin |
|
44 |
nextConfig:= nil; |
|
45 |
||
46 |
for i:= 0 to Pred(MAXARGS) do |
|
47 |
begin |
|
48 |
if arguments[i][0] = #255 then |
|
49 |
arguments[i][255]:= #0 |
|
50 |
else |
|
51 |
arguments[i][byte(arguments[i][0]) + 1]:= #0; |
|
52 |
argv[i]:= @arguments[i][1] |
|
53 |
end; |
|
54 |
end; |
|
55 |
||
56 |
if runQueue = nil then |
|
57 |
begin |
|
58 |
runQueue:= pConfig; |
|
59 |
||
11464
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
60 |
ipcSetEngineBarrier(); |
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
61 |
sendConfig(pConfig); |
11439 | 62 |
nextRun |
63 |
end else |
|
64 |
begin |
|
65 |
t:= runQueue; |
|
66 |
while t^.nextConfig <> nil do |
|
67 |
begin |
|
11464
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
68 |
if false and (pConfig^.gameType = gtPreview) and (t^.nextConfig^.gameType = gtPreview) and (t <> runQueue) then |
11439 | 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; |
|
11464
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
78 |
|
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
79 |
ipcSetEngineBarrier(); |
30397f91571c
Fix a ton of bugs in engine instances queue and ipc
unc0rr
parents:
11461
diff
changeset
|
80 |
sendConfig(pConfig); |
11439 | 81 |
t^.nextConfig:= pConfig |
82 |
end; |
|
83 |
end; |
|
84 |
||
85 |
procedure passFlibEvent(p: pointer); cdecl; |
|
86 |
begin |
|
87 |
case TFLIBEvent(p^) of |
|
88 |
flibGameFinished: begin |
|
89 |
cleanupConfig; |
|
90 |
nextRun |
|
11456 | 91 |
end; |
92 |
flibRunNetGame: begin |
|
93 |
runNetGame |
|
94 |
end; |
|
11439 | 95 |
end; |
96 |
end; |
|
97 |
||
98 |
end. |