author | unc0rr |
Sat, 28 Nov 2015 00:18:04 +0300 | |
branch | qmlfrontend |
changeset 11438 | bca9afcc3a72 |
parent 11437 | 97e3e62ea5f9 |
child 11439 | 23912c93935a |
permissions | -rw-r--r-- |
10406 | 1 |
unit uFLGameConfig; |
2 |
interface |
|
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
3 |
uses uFLTypes; |
10406 | 4 |
|
10430 | 5 |
procedure resetGameConfig; cdecl; |
6 |
procedure runQuickGame; cdecl; |
|
10448 | 7 |
procedure runLocalGame; cdecl; |
10430 | 8 |
procedure getPreview; cdecl; |
10406 | 9 |
|
10430 | 10 |
procedure setSeed(seed: PChar); cdecl; |
11 |
function getSeed: PChar; cdecl; |
|
10456 | 12 |
procedure setTheme(themeName: PChar); cdecl; |
10612 | 13 |
procedure setScript(scriptName: PChar); cdecl; |
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
14 |
procedure setScheme(schemeName: PChar); cdecl; |
10888 | 15 |
procedure setAmmo(ammoName: PChar); cdecl; |
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
16 |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
17 |
procedure tryAddTeam(teamName: PChar); cdecl; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
18 |
procedure tryRemoveTeam(teamName: PChar); cdecl; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
19 |
procedure changeTeamColor(teamName: PChar; dir: LongInt); cdecl; |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
20 |
|
11436 | 21 |
procedure netSetSeed(seed: shortstring); |
22 |
procedure netSetTheme(themeName: shortstring); |
|
23 |
procedure netSetScript(scriptName: shortstring); |
|
11438 | 24 |
procedure netSetFeatureSize(fsize: LongInt); |
25 |
procedure netSetMapGen(mapgen: LongInt); |
|
26 |
procedure netSetMap(map: shortstring); |
|
27 |
procedure netSetMazeSize(mazesize: LongInt); |
|
28 |
procedure netSetTemplate(template: LongInt); |
|
29 |
procedure updatePreviewIfNeeded; |
|
11436 | 30 |
|
10406 | 31 |
implementation |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10892
diff
changeset
|
32 |
uses uFLIPC, hwengine, uFLUtils, uFLTeams, uFLData, uFLSChemes, uFLAmmo, uFLUICallback; |
10406 | 33 |
|
10426 | 34 |
const |
35 |
MAXCONFIGS = 5; |
|
36 |
MAXARGS = 32; |
|
37 |
||
38 |
type |
|
39 |
TGameConfig = record |
|
40 |
seed: shortstring; |
|
41 |
theme: shortstring; |
|
42 |
script: shortstring; |
|
11438 | 43 |
map: shortstring; |
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
44 |
scheme: TScheme; |
10892 | 45 |
ammo: TAmmo; |
11438 | 46 |
mapgen: LongInt; |
47 |
featureSize: LongInt; |
|
48 |
mazesize: LongInt; |
|
49 |
template: LongInt; |
|
10426 | 50 |
gameType: TGameType; |
51 |
teams: array[0..7] of TTeam; |
|
52 |
arguments: array[0..Pred(MAXARGS)] of shortstring; |
|
53 |
argv: array[0..Pred(MAXARGS)] of PChar; |
|
54 |
argumentsNumber: Longword; |
|
55 |
end; |
|
56 |
PGameConfig = ^TGameConfig; |
|
57 |
||
10432 | 58 |
var |
59 |
currentConfig: TGameConfig; |
|
11438 | 60 |
previewNeedsUpdate: boolean; |
10432 | 61 |
|
11436 | 62 |
function getScriptPath(scriptName: shortstring): shortstring; |
63 |
begin |
|
64 |
getScriptPath:= '/Scripts/Multiplayer/' + scriptName + '.lua' |
|
65 |
end; |
|
10430 | 66 |
|
10432 | 67 |
procedure sendConfig(config: PGameConfig); |
68 |
var i: Longword; |
|
69 |
begin |
|
70 |
with config^ do |
|
10430 | 71 |
begin |
10432 | 72 |
case gameType of |
73 |
gtPreview: begin |
|
11436 | 74 |
if script <> 'Normal' then |
75 |
ipcToEngine('escript ' + getScriptPath(script)); |
|
10432 | 76 |
ipcToEngine('eseed ' + seed); |
77 |
ipcToEngine('e$mapgen ' + intToStr(mapgen)); |
|
78 |
end; |
|
79 |
gtLocal: begin |
|
11436 | 80 |
if script <> 'Normal' then |
81 |
ipcToEngine('escript ' + getScriptPath(script)); |
|
10432 | 82 |
ipcToEngine('eseed ' + seed); |
83 |
ipcToEngine('e$mapgen ' + intToStr(mapgen)); |
|
10456 | 84 |
ipcToEngine('e$theme ' + theme); |
10612 | 85 |
|
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
86 |
sendSchemeConfig(scheme); |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
87 |
|
10432 | 88 |
i:= 0; |
89 |
while (i < 8) and (teams[i].hogsNumber > 0) do |
|
90 |
begin |
|
10892 | 91 |
sendAmmoConfig(config^.ammo); |
10432 | 92 |
ipcToEngine('eammstore'); |
93 |
sendTeamConfig(teams[i]); |
|
94 |
inc(i) |
|
95 |
end; |
|
96 |
end; |
|
97 |
end; |
|
98 |
||
99 |
ipcToEngine('!'); |
|
100 |
end; |
|
101 |
end; |
|
10426 | 102 |
|
103 |
procedure queueExecution; |
|
104 |
var pConfig: PGameConfig; |
|
105 |
i: Longword; |
|
106 |
begin |
|
107 |
new(pConfig); |
|
108 |
pConfig^:= currentConfig; |
|
109 |
||
110 |
with pConfig^ do |
|
111 |
for i:= 0 to Pred(MAXARGS) do |
|
112 |
begin |
|
113 |
if arguments[i][0] = #255 then |
|
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
114 |
arguments[i][255]:= #0 |
10426 | 115 |
else |
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
116 |
arguments[i][byte(arguments[i][0]) + 1]:= #0; |
10426 | 117 |
argv[i]:= @arguments[i][1] |
118 |
end; |
|
119 |
||
120 |
RunEngine(pConfig^.argumentsNumber, @pConfig^.argv); |
|
10432 | 121 |
|
122 |
sendConfig(pConfig) |
|
10426 | 123 |
end; |
124 |
||
125 |
procedure resetGameConfig; cdecl; |
|
10450 | 126 |
var i: Longword; |
10406 | 127 |
begin |
10450 | 128 |
with currentConfig do |
129 |
begin |
|
11436 | 130 |
script:= 'Normal'; |
131 |
||
10450 | 132 |
for i:= 0 to 7 do |
133 |
teams[i].hogsNumber:= 0 |
|
134 |
end |
|
10406 | 135 |
end; |
136 |
||
10430 | 137 |
procedure setSeed(seed: PChar); cdecl; |
138 |
begin |
|
11436 | 139 |
sendUI(mtSeed, @seed[1], length(seed)); |
10430 | 140 |
currentConfig.seed:= seed |
141 |
end; |
|
142 |
||
143 |
function getSeed: PChar; cdecl; |
|
144 |
begin |
|
145 |
getSeed:= str2PChar(currentConfig.seed) |
|
146 |
end; |
|
147 |
||
10450 | 148 |
function getUnusedColor: Longword; |
10448 | 149 |
var i, c: Longword; |
150 |
fColorMatched: boolean; |
|
151 |
begin |
|
152 |
c:= 0; |
|
153 |
i:= 0; |
|
154 |
repeat |
|
155 |
repeat |
|
10450 | 156 |
fColorMatched:= (currentConfig.teams[i].hogsNumber > 0) and (currentConfig.teams[i].color = c); |
10448 | 157 |
inc(i) |
158 |
until (i >= 8) or (currentConfig.teams[i].hogsNumber = 0) or fColorMatched; |
|
159 |
||
160 |
if fColorMatched then |
|
161 |
begin |
|
162 |
i:= 0; |
|
163 |
inc(c) |
|
164 |
end; |
|
165 |
until not fColorMatched; |
|
166 |
||
10450 | 167 |
getUnusedColor:= c |
10448 | 168 |
end; |
169 |
||
10430 | 170 |
procedure runQuickGame; cdecl; |
10426 | 171 |
begin |
10432 | 172 |
with currentConfig do |
173 |
begin |
|
174 |
gameType:= gtLocal; |
|
175 |
arguments[0]:= ''; |
|
176 |
arguments[1]:= '--internal'; |
|
10448 | 177 |
arguments[2]:= '--nomusic'; |
10432 | 178 |
argumentsNumber:= 3; |
10426 | 179 |
|
10432 | 180 |
teams[0]:= createRandomTeam; |
10450 | 181 |
teams[0].color:= 0; |
10432 | 182 |
teams[1]:= createRandomTeam; |
10450 | 183 |
teams[1].color:= 1; |
11429 | 184 |
teams[1].botLevel:= 3; |
10432 | 185 |
|
186 |
queueExecution; |
|
187 |
end; |
|
10426 | 188 |
end; |
189 |
||
10448 | 190 |
|
10430 | 191 |
procedure getPreview; cdecl; |
10426 | 192 |
begin |
11438 | 193 |
previewNeedsUpdate:= false; |
194 |
||
10426 | 195 |
with currentConfig do |
196 |
begin |
|
197 |
gameType:= gtPreview; |
|
198 |
arguments[0]:= ''; |
|
199 |
arguments[1]:= '--internal'; |
|
200 |
arguments[2]:= '--landpreview'; |
|
201 |
argumentsNumber:= 3; |
|
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
202 |
|
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
203 |
queueExecution; |
10426 | 204 |
end; |
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
205 |
end; |
10426 | 206 |
|
10448 | 207 |
procedure runLocalGame; cdecl; |
208 |
begin |
|
209 |
with currentConfig do |
|
210 |
begin |
|
211 |
gameType:= gtLocal; |
|
212 |
arguments[0]:= ''; |
|
213 |
arguments[1]:= '--internal'; |
|
214 |
arguments[2]:= '--nomusic'; |
|
215 |
argumentsNumber:= 3; |
|
216 |
||
217 |
queueExecution; |
|
218 |
end; |
|
219 |
end; |
|
220 |
||
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
221 |
procedure tryAddTeam(teamName: PChar); cdecl; |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
222 |
var msg: ansistring; |
10446 | 223 |
i, hn, hedgehogsNumber: Longword; |
224 |
team: PTeam; |
|
10450 | 225 |
c: Longword; |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
226 |
begin |
10446 | 227 |
with currentConfig do |
228 |
begin |
|
229 |
hedgehogsNumber:= 0; |
|
230 |
i:= 0; |
|
231 |
||
232 |
while (i < 8) and (teams[i].hogsNumber > 0) do |
|
233 |
begin |
|
234 |
inc(i); |
|
235 |
inc(hedgehogsNumber, teams[i].hogsNumber) |
|
236 |
end; |
|
237 |
||
238 |
// no free space for a team or reached hogs number maximum |
|
239 |
if (i > 7) or (hedgehogsNumber >= 48) then exit; |
|
240 |
||
241 |
team:= teamByName(teamName); |
|
242 |
if team = nil then exit; |
|
243 |
||
10448 | 244 |
c:= getUnusedColor; |
245 |
||
10446 | 246 |
teams[i]:= team^; |
247 |
||
248 |
if i = 0 then hn:= 4 else hn:= teams[i - 1].hogsNumber; |
|
249 |
if hn > 48 - hedgehogsNumber then hn:= 48 - hedgehogsNumber; |
|
250 |
teams[i].hogsNumber:= hn; |
|
10448 | 251 |
|
252 |
teams[i].color:= c; |
|
10446 | 253 |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
254 |
msg:= '0' + #10 + teamName; |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10892
diff
changeset
|
255 |
sendUI(mtAddPlayingTeam, @msg[1], length(msg)); |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
256 |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
257 |
msg:= teamName + #10 + colorsSet[teams[i].color]; |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10892
diff
changeset
|
258 |
sendUI(mtTeamColor, @msg[1], length(msg)); |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
259 |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
260 |
msg:= teamName; |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10892
diff
changeset
|
261 |
sendUI(mtRemoveTeam, @msg[1], length(msg)) |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
262 |
end |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
263 |
end; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
264 |
|
10448 | 265 |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
266 |
procedure tryRemoveTeam(teamName: PChar); cdecl; |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
267 |
var msg: ansistring; |
10448 | 268 |
i: Longword; |
269 |
tn: shortstring; |
|
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
270 |
begin |
10448 | 271 |
with currentConfig do |
272 |
begin |
|
273 |
i:= 0; |
|
274 |
tn:= teamName; |
|
275 |
while (i < 8) and (teams[i].teamName <> tn) do |
|
276 |
inc(i); |
|
277 |
||
278 |
// team not found??? |
|
279 |
if (i > 7) then exit; |
|
280 |
||
281 |
while (i < 7) and (teams[i + 1].hogsNumber > 0) do |
|
282 |
begin |
|
283 |
teams[i]:= teams[i + 1]; |
|
284 |
inc(i) |
|
285 |
end; |
|
286 |
||
287 |
teams[i].hogsNumber:= 0 |
|
288 |
end; |
|
289 |
||
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
290 |
msg:= teamName; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
291 |
|
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10892
diff
changeset
|
292 |
sendUI(mtRemovePlayingTeam, @msg[1], length(msg)); |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10892
diff
changeset
|
293 |
sendUI(mtAddTeam, @msg[1], length(msg)) |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
294 |
end; |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10432
diff
changeset
|
295 |
|
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
296 |
|
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
297 |
procedure changeTeamColor(teamName: PChar; dir: LongInt); cdecl; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
298 |
var i, dc: Longword; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
299 |
tn: shortstring; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
300 |
msg: ansistring; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
301 |
begin |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
302 |
with currentConfig do |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
303 |
begin |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
304 |
i:= 0; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
305 |
tn:= teamName; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
306 |
while (i < 8) and (teams[i].teamName <> tn) do |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
307 |
inc(i); |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
308 |
// team not found??? |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
309 |
if (i > 7) then exit; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
310 |
|
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
311 |
if dir >= 0 then dc:= 1 else dc:= 8; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
312 |
teams[i].color:= (teams[i].color + dc) mod 9; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
313 |
|
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
314 |
msg:= tn + #10 + colorsSet[teams[i].color]; |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
10892
diff
changeset
|
315 |
sendUI(mtTeamColor, @msg[1], length(msg)) |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
316 |
end |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
317 |
end; |
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
318 |
|
10456 | 319 |
procedure setTheme(themeName: PChar); cdecl; |
320 |
begin |
|
321 |
currentConfig.theme:= themeName |
|
322 |
end; |
|
323 |
||
10612 | 324 |
procedure setScript(scriptName: PChar); cdecl; |
325 |
begin |
|
11436 | 326 |
currentConfig.script:= scriptName |
10612 | 327 |
end; |
328 |
||
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
329 |
procedure setScheme(schemeName: PChar); cdecl; |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
330 |
var scheme: PScheme; |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
331 |
begin |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
332 |
scheme:= schemeByName(schemeName); |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
333 |
|
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
334 |
if scheme <> nil then |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
335 |
currentConfig.scheme:= scheme^ |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
336 |
end; |
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10612
diff
changeset
|
337 |
|
10888 | 338 |
procedure setAmmo(ammoName: PChar); cdecl; |
339 |
var ammo: PAmmo; |
|
340 |
begin |
|
341 |
ammo:= ammoByName(ammoName); |
|
342 |
||
343 |
if ammo <> nil then |
|
10892 | 344 |
currentConfig.ammo:= ammo^ |
10888 | 345 |
end; |
346 |
||
11436 | 347 |
procedure netSetSeed(seed: shortstring); |
348 |
begin |
|
349 |
if seed <> currentConfig.seed then |
|
350 |
begin |
|
351 |
currentConfig.seed:= seed; |
|
11437 | 352 |
sendUI(mtSeed, @seed[1], length(seed)); |
353 |
||
354 |
getPreview() |
|
11436 | 355 |
end |
356 |
end; |
|
357 |
||
358 |
procedure netSetTheme(themeName: shortstring); |
|
359 |
begin |
|
360 |
if themeName <> currentConfig.theme then |
|
361 |
begin |
|
362 |
currentConfig.theme:= themeName; |
|
363 |
sendUI(mtTheme, @themeName[1], length(themeName)) |
|
364 |
end |
|
365 |
end; |
|
366 |
||
367 |
procedure netSetScript(scriptName: shortstring); |
|
368 |
begin |
|
369 |
if scriptName <> currentConfig.script then |
|
370 |
begin |
|
11438 | 371 |
previewNeedsUpdate:= true; |
11436 | 372 |
currentConfig.script:= scriptName; |
373 |
sendUI(mtScript, @scriptName[1], length(scriptName)) |
|
374 |
end |
|
375 |
end; |
|
376 |
||
11438 | 377 |
procedure netSetFeatureSize(fsize: LongInt); |
378 |
var s: shortstring; |
|
379 |
begin |
|
380 |
if fsize <> currentConfig.featureSize then |
|
381 |
begin |
|
382 |
previewNeedsUpdate:= true; |
|
383 |
currentConfig.featureSize:= fsize; |
|
384 |
s:= IntToStr(fsize); |
|
385 |
sendUI(mtFeatureSize, @s[1], length(s)) |
|
386 |
end |
|
387 |
end; |
|
388 |
||
389 |
procedure netSetMapGen(mapgen: LongInt); |
|
390 |
var s: shortstring; |
|
391 |
begin |
|
392 |
if mapgen <> currentConfig.mapgen then |
|
393 |
begin |
|
394 |
previewNeedsUpdate:= true; |
|
395 |
currentConfig.mapgen:= mapgen; |
|
396 |
s:= IntToStr(mapgen); |
|
397 |
sendUI(mtMapGen, @s[1], length(s)) |
|
398 |
end |
|
399 |
end; |
|
400 |
||
401 |
procedure netSetMap(map: shortstring); |
|
402 |
begin |
|
403 |
sendUI(mtMap, @map[1], length(map)) |
|
404 |
end; |
|
405 |
||
406 |
procedure netSetMazeSize(mazesize: LongInt); |
|
407 |
var s: shortstring; |
|
408 |
begin |
|
409 |
if mazesize <> currentConfig.mazesize then |
|
410 |
begin |
|
411 |
previewNeedsUpdate:= true; |
|
412 |
currentConfig.mazesize:= mazesize; |
|
413 |
s:= IntToStr(mazesize); |
|
414 |
sendUI(mtMazeSize, @s[1], length(s)) |
|
415 |
end |
|
416 |
end; |
|
417 |
||
418 |
procedure netSetTemplate(template: LongInt); |
|
419 |
var s: shortstring; |
|
420 |
begin |
|
421 |
if template <> currentConfig.template then |
|
422 |
begin |
|
423 |
previewNeedsUpdate:= true; |
|
424 |
currentConfig.template:= template; |
|
425 |
s:= IntToStr(template); |
|
426 |
sendUI(mtTemplate, @s[1], length(s)) |
|
427 |
end |
|
428 |
end; |
|
429 |
||
430 |
procedure updatePreviewIfNeeded; |
|
431 |
begin |
|
432 |
if previewNeedsUpdate then |
|
433 |
getPreview |
|
434 |
end; |
|
435 |
||
10406 | 436 |
end. |