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