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