author | unc0rr |
Sun, 06 Dec 2015 20:07:35 +0300 | |
branch | qmlfrontend |
changeset 11450 | 465b4db35232 |
parent 11449 | 91f8c6ff5bab |
child 11454 | 2bf0491d5e88 |
permissions | -rw-r--r-- |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
1 |
unit uFLNetProtocol; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
2 |
interface |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
3 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
4 |
procedure passNetData(p: pointer); cdecl; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
5 |
|
11421 | 6 |
procedure sendChatLine(msg: PChar); cdecl; |
11428 | 7 |
procedure joinRoom(roomName: PChar); cdecl; |
11429 | 8 |
procedure partRoom(msg: PChar); cdecl; |
9 |
||
10 |
procedure ResetNetState; |
|
11421 | 11 |
|
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
12 |
implementation |
11438 | 13 |
uses uFLNetTypes, uFLTypes, uFLUICallback, uFLNet, uFLGameConfig, uFLUtils; |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
14 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
15 |
type |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
16 |
PHandler = procedure (var t: TCmdData); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
17 |
|
11429 | 18 |
var isInRoom: boolean; |
11435 | 19 |
myNickname: shortstring; |
11429 | 20 |
|
11448 | 21 |
procedure onRoomLeaving(); |
22 |
begin |
|
23 |
isInRoom:= false; |
|
24 |
sendUI(mtMoveToLobby, nil, 0); |
|
25 |
netResetTeams |
|
26 |
end; |
|
27 |
||
11447 | 28 |
var teamIndex: LongInt; |
29 |
tmpTeam: TTeam; |
|
30 |
||
31 |
const teamFields: array[0..22] of PShortstring = ( |
|
32 |
@tmpTeam.teamName |
|
33 |
, @tmpTeam.grave |
|
34 |
, @tmpTeam.fort |
|
35 |
, @tmpTeam.voice |
|
36 |
, @tmpTeam.flag |
|
37 |
, @tmpTeam.owner |
|
38 |
, nil |
|
39 |
, @tmpTeam.hedgehogs[0].name |
|
40 |
, @tmpTeam.hedgehogs[0].hat |
|
41 |
, @tmpTeam.hedgehogs[1].name |
|
42 |
, @tmpTeam.hedgehogs[1].hat |
|
43 |
, @tmpTeam.hedgehogs[2].name |
|
44 |
, @tmpTeam.hedgehogs[2].hat |
|
45 |
, @tmpTeam.hedgehogs[3].name |
|
46 |
, @tmpTeam.hedgehogs[3].hat |
|
47 |
, @tmpTeam.hedgehogs[4].name |
|
48 |
, @tmpTeam.hedgehogs[4].hat |
|
49 |
, @tmpTeam.hedgehogs[5].name |
|
50 |
, @tmpTeam.hedgehogs[5].hat |
|
51 |
, @tmpTeam.hedgehogs[6].name |
|
52 |
, @tmpTeam.hedgehogs[6].hat |
|
53 |
, @tmpTeam.hedgehogs[7].name |
|
54 |
, @tmpTeam.hedgehogs[7].hat |
|
55 |
); |
|
11435 | 56 |
procedure handler_ADD_TEAM(var p: TCmdParam); |
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
57 |
begin |
11447 | 58 |
teamIndex:= 0; |
59 |
tmpTeam.extDriven:= true; |
|
60 |
tmpTeam.color:= 0 |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
61 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
62 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
63 |
procedure handler_ADD_TEAM_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
64 |
begin |
11447 | 65 |
if teamIndex = 6 then |
66 |
tmpTeam.botLevel:= strToInt(s.str1) |
|
67 |
else if teamIndex < 23 then |
|
68 |
teamFields[teamIndex]^:= s.str1; |
|
69 |
||
70 |
if teamIndex = 22 then |
|
71 |
netAddTeam(tmpTeam); |
|
72 |
||
73 |
inc(teamIndex); |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
74 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
75 |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
76 |
procedure handler_ASKPASSWORD(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
77 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
78 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
79 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
80 |
procedure handler_BANLIST(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
81 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
82 |
end; |
11423 | 83 |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
84 |
procedure handler_BANLIST_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
85 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
86 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
87 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
88 |
procedure handler_BYE(var p: TCmdParamSL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
89 |
begin |
11420 | 90 |
sendUI(mtDisconnected, @p.str2[1], length(p.str2)); |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
91 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
92 |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
93 |
procedure handler_CFG_AMMO(var p: TCmdParamSL); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
94 |
begin |
11442 | 95 |
netSetAmmo(p.str1, p.str2) |
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
96 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
97 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
98 |
procedure handler_CFG_DRAWNMAP(var p: TCmdParamL); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
99 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
100 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
101 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
102 |
procedure handler_CFG_FEATURE_SIZE(var p: TCmdParami); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
103 |
begin |
11438 | 104 |
if isInRoom then |
105 |
begin |
|
106 |
netSetFeatureSize(p.param1); |
|
107 |
updatePreviewIfNeeded |
|
108 |
end; |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
109 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
110 |
|
11438 | 111 |
var fmcfgIndex: integer; |
112 |
||
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
113 |
procedure handler_CFG_FULLMAPCONFIG(var p: TCmdParam); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
114 |
begin |
11438 | 115 |
fmcfgIndex:= 0; |
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
116 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
117 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
118 |
procedure handler_CFG_FULLMAPCONFIG_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
119 |
begin |
11438 | 120 |
if not isInRoom then exit; |
121 |
||
122 |
inc(fmcfgIndex); |
|
123 |
case fmcfgIndex of |
|
11441 | 124 |
1: netSetFeatureSize(strToInt(s.str1)); |
125 |
2: if s.str1[0] <> '+' then netSetMap(s.str1); |
|
126 |
3: netSetMapGen(strToInt(s.str1)); |
|
127 |
4: netSetMazeSize(strToInt(s.str1)); |
|
128 |
5: netSetSeed(s.str1); |
|
11438 | 129 |
6: begin |
11441 | 130 |
netSetTemplate(strToInt(s.str1)); |
11438 | 131 |
updatePreviewIfNeeded; |
11441 | 132 |
end; |
11438 | 133 |
end; |
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
134 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
135 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
136 |
procedure handler_CFG_MAP(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
137 |
begin |
11438 | 138 |
if isInRoom then |
139 |
netSetMap(p.str1); |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
140 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
141 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
142 |
procedure handler_CFG_MAPGEN(var p: TCmdParami); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
143 |
begin |
11438 | 144 |
if isInRoom then |
145 |
begin |
|
146 |
netSetMapGen(p.param1); |
|
147 |
updatePreviewIfNeeded |
|
148 |
end |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
149 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
150 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
151 |
procedure handler_CFG_MAZE_SIZE(var p: TCmdParami); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
152 |
begin |
11438 | 153 |
if isInRoom then |
154 |
begin |
|
155 |
netSetMazeSize(p.param1); |
|
156 |
updatePreviewIfNeeded |
|
157 |
end |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
158 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
159 |
|
11445 | 160 |
var schemeIndex: LongInt; |
161 |
tmpScheme: TScheme; |
|
162 |
||
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
163 |
procedure handler_CFG_SCHEME(var p: TCmdParam); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
164 |
begin |
11445 | 165 |
schemeIndex:= 0 |
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
166 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
167 |
|
11445 | 168 |
const schemeFields: array[0..43] of pointer = ( |
169 |
@tmpScheme.schemeName // 0 |
|
170 |
, @tmpScheme.fortsmode // 1 |
|
171 |
, @tmpScheme.divteams // 2 |
|
172 |
, @tmpScheme.solidland // 3 |
|
173 |
, @tmpScheme.border // 4 |
|
174 |
, @tmpScheme.lowgrav // 5 |
|
175 |
, @tmpScheme.laser // 6 |
|
176 |
, @tmpScheme.invulnerability // 7 |
|
177 |
, @tmpScheme.resethealth // 8 |
|
178 |
, @tmpScheme.vampiric // 9 |
|
179 |
, @tmpScheme.karma // 10 |
|
180 |
, @tmpScheme.artillery // 11 |
|
181 |
, @tmpScheme.randomorder // 12 |
|
182 |
, @tmpScheme.king // 13 |
|
183 |
, @tmpScheme.placehog // 14 |
|
184 |
, @tmpScheme.sharedammo // 15 |
|
185 |
, @tmpScheme.disablegirders // 16 |
|
186 |
, @tmpScheme.disablelandobjects // 17 |
|
187 |
, @tmpScheme.aisurvival // 18 |
|
188 |
, @tmpScheme.infattack // 19 |
|
189 |
, @tmpScheme.resetweps // 20 |
|
190 |
, @tmpScheme.perhogammo // 21 |
|
191 |
, @tmpScheme.disablewind // 22 |
|
192 |
, @tmpScheme.morewind // 23 |
|
193 |
, @tmpScheme.tagteam // 24 |
|
194 |
, @tmpScheme.bottomborder // 25 |
|
195 |
, @tmpScheme.damagefactor // 26 |
|
196 |
, @tmpScheme.turntime // 27 |
|
197 |
, @tmpScheme.health // 28 |
|
198 |
, @tmpScheme.suddendeath // 29 |
|
199 |
, @tmpScheme.caseprobability // 30 |
|
200 |
, @tmpScheme.minestime // 31 |
|
201 |
, @tmpScheme.minesnum // 32 |
|
202 |
, @tmpScheme.minedudpct // 33 |
|
203 |
, @tmpScheme.explosives // 34 |
|
204 |
, @tmpScheme.airmines // 35 |
|
205 |
, @tmpScheme.healthprobability // 36 |
|
206 |
, @tmpScheme.healthcaseamount // 37 |
|
207 |
, @tmpScheme.waterrise // 38 |
|
208 |
, @tmpScheme.healthdecrease // 39 |
|
209 |
, @tmpScheme.ropepct // 40 |
|
210 |
, @tmpScheme.getawaytime // 41 |
|
211 |
, @tmpScheme.worldedge // 42 |
|
212 |
, @tmpScheme.scriptparam // 43 |
|
213 |
); |
|
214 |
||
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
215 |
procedure handler_CFG_SCHEME_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
216 |
begin |
11445 | 217 |
if(schemeIndex = 0) then |
218 |
tmpScheme.schemeName:= s.str1 |
|
219 |
else |
|
220 |
if(schemeIndex = 43) then |
|
221 |
tmpScheme.scriptparam:= copy(s.str1, 2, length(s.str1) - 1) |
|
222 |
else |
|
223 |
if(schemeIndex < 26) then |
|
224 |
PBoolean(schemeFields[schemeIndex])^:= s.str1[1] = 't' |
|
225 |
else |
|
226 |
if(schemeIndex < 43) then |
|
227 |
PLongInt(schemeFields[schemeIndex])^:= strToInt(s.str1); |
|
228 |
||
229 |
if(schemeIndex = 43) then |
|
230 |
netSetScheme(tmpScheme); |
|
231 |
||
232 |
inc(schemeIndex); |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
233 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
234 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
235 |
procedure handler_CFG_SCRIPT(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
236 |
begin |
11436 | 237 |
if isInRoom then |
238 |
netSetScript(p.str1) |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
239 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
240 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
241 |
procedure handler_CFG_SEED(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
242 |
begin |
11436 | 243 |
if isInRoom then |
244 |
netSetSeed(p.str1) |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
245 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
246 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
247 |
procedure handler_CFG_TEMPLATE(var p: TCmdParami); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
248 |
begin |
11438 | 249 |
if isInRoom then |
250 |
begin |
|
251 |
netSetTemplate(p.param1); |
|
252 |
updatePreviewIfNeeded |
|
253 |
end |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
254 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
255 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
256 |
procedure handler_CFG_THEME(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
257 |
begin |
11436 | 258 |
if isInRoom then |
259 |
netSetTheme(p.str1) |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
260 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
261 |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
262 |
procedure handler_CHAT(var p: TCmdParamSL); |
11420 | 263 |
var s: string; |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
264 |
begin |
11420 | 265 |
s:= p.str1 + #10 + p.str2; |
11429 | 266 |
if isInRoom then |
267 |
sendUI(mtRoomChatLine, @s[1], length(s)) |
|
268 |
else |
|
269 |
sendUI(mtLobbyChatLine, @s[1], length(s)); |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
270 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
271 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
272 |
procedure handler_CLIENT_FLAGS(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
273 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
274 |
end; |
11423 | 275 |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
276 |
procedure handler_CLIENT_FLAGS_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
277 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
278 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
279 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
280 |
procedure handler_CONNECTED(var p: TCmdParami); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
281 |
begin |
11420 | 282 |
sendUI(mtConnected, nil, 0); |
11439 | 283 |
writeln('Server features version ', p.param1); |
11420 | 284 |
sendNet('PROTO' + #10 + '51'); |
285 |
sendNet('NICK' + #10 + 'qmlfrontend'); |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
286 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
287 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
288 |
procedure handler_EM(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
289 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
290 |
end; |
11423 | 291 |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
292 |
procedure handler_EM_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
293 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
294 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
295 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
296 |
procedure handler_ERROR(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
297 |
begin |
11428 | 298 |
sendUI(mtError, @p.str1[1], length(p.str1)); |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
299 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
300 |
|
11447 | 301 |
procedure handler_HH_NUM(var p: TCmdParamSS); |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
302 |
begin |
11448 | 303 |
netSetHedgehogsNumber(p.str1, StrToInt(p.str2)) |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
304 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
305 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
306 |
procedure handler_INFO(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
307 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
308 |
end; |
11423 | 309 |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
310 |
procedure handler_INFO_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
311 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
312 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
313 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
314 |
procedure handler_JOINED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
315 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
316 |
end; |
11423 | 317 |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
318 |
procedure handler_JOINED_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
319 |
begin |
11435 | 320 |
if s.str1 = myNickname then // we joined a room |
11429 | 321 |
begin |
322 |
isInRoom:= true; |
|
323 |
sendUI(mtMoveToRoom, nil, 0); |
|
324 |
end; |
|
325 |
||
326 |
sendUI(mtAddRoomClient, @s.str1[1], length(s.str1)); |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
327 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
328 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
329 |
procedure handler_JOINING(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
330 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
331 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
332 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
333 |
procedure handler_KICKED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
334 |
begin |
11448 | 335 |
onRoomLeaving() |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
336 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
337 |
|
11446 | 338 |
procedure handler_LEFT(var p: TCmdParamSL); |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
339 |
begin |
11446 | 340 |
p.str2:= p.str1 + #10 + p.str2; |
341 |
sendUI(mtRemoveRoomClient, @p.str2[1], length(p.str2)); |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
342 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
343 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
344 |
procedure handler_LOBBY_JOINED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
345 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
346 |
end; |
11423 | 347 |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
348 |
procedure handler_LOBBY_JOINED_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
349 |
begin |
11435 | 350 |
if s.str1 = myNickname then |
11429 | 351 |
begin |
352 |
sendUI(mtMoveToLobby, nil, 0); |
|
353 |
sendNet('LIST'); |
|
354 |
end; |
|
11424 | 355 |
|
11420 | 356 |
sendUI(mtAddLobbyClient, @s.str1[1], length(s.str1)); |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
357 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
358 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
359 |
procedure handler_LOBBY_LEFT(var p: TCmdParamSL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
360 |
begin |
11428 | 361 |
p.str2:= p.str1 + #10 + p.str2; |
362 |
sendUI(mtRemoveLobbyClient, @p.str2[1], length(p.str2)); |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
363 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
364 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
365 |
procedure handler_NICK(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
366 |
begin |
11435 | 367 |
myNickname:= p.str1; |
368 |
sendUI(mtNickname, @p.str1[1], length(p.str1)); |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
369 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
370 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
371 |
procedure handler_NOTICE(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
372 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
373 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
374 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
375 |
procedure handler_PING(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
376 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
377 |
sendNet('PONG') |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
378 |
end; |
11423 | 379 |
|
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
380 |
procedure handler_PING_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
381 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
382 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
383 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
384 |
procedure handler_PROTO(var p: TCmdParami); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
385 |
begin |
11439 | 386 |
writeln('Protocol ', p.param1) |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
387 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
388 |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
389 |
procedure handler_REMOVE_TEAM(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
390 |
begin |
11448 | 391 |
netRemoveTeam(p.str1) |
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
392 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
393 |
|
11423 | 394 |
var roomInfo: string; |
395 |
roomLinesCount: integer; |
|
396 |
||
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
397 |
procedure handler_ROOMS(var p: TCmdParam); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
398 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
399 |
roomInfo:= ''; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
400 |
roomLinesCount:= 0 |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
401 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
402 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
403 |
procedure handler_ROOMS_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
404 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
405 |
roomInfo:= roomInfo + s.str1 + #10; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
406 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
407 |
if roomLinesCount = 8 then |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
408 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
409 |
sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
410 |
roomLinesCount:= 0; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
411 |
roomInfo:= '' |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
412 |
end else inc(roomLinesCount); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
413 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
414 |
|
11430
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
415 |
procedure handler_ROOM_ADD(var p: TCmdParam); |
11423 | 416 |
begin |
417 |
roomInfo:= ''; |
|
11430
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
418 |
roomLinesCount:= 0 |
11423 | 419 |
end; |
420 |
||
11430
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
421 |
procedure handler_ROOM_ADD_s(var s: TCmdParamS); |
11423 | 422 |
begin |
11430
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
423 |
roomInfo:= roomInfo + s.str1 + #10; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
424 |
inc(roomLinesCount); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
425 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
426 |
if roomLinesCount = 9 then |
11423 | 427 |
begin |
11430
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
428 |
sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
429 |
roomInfo:= ''; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
430 |
roomLinesCount:= 0 |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
431 |
end; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
432 |
end; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
433 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
434 |
procedure handler_ROOM_DEL(var p: TCmdParamS); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
435 |
begin |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
436 |
sendUI(mtRemoveRoom, @p.str1[1], length(p.str1)); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
437 |
end; |
11423 | 438 |
|
11430
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
439 |
procedure handler_ROOM_UPD(var p: TCmdParam); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
440 |
begin |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
441 |
roomInfo:= ''; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
442 |
roomLinesCount:= 0 |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
443 |
end; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
444 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
445 |
procedure handler_ROOM_UPD_s(var s: TCmdParamS); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
446 |
begin |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
447 |
roomInfo:= roomInfo + s.str1 + #10; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
448 |
inc(roomLinesCount); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
449 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
450 |
if roomLinesCount = 10 then |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
451 |
sendUI(mtUpdateRoom, @roomInfo[1], length(roomInfo) - 1); |
11423 | 452 |
end; |
453 |
||
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
454 |
procedure handler_ROUND_FINISHED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
455 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
456 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
457 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
458 |
procedure handler_RUN_GAME(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
459 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
460 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
461 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
462 |
procedure handler_SERVER_AUTH(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
463 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
464 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
465 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
466 |
procedure handler_SERVER_MESSAGE(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
467 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
468 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
469 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
470 |
procedure handler_SERVER_VARS(var p: TCmdParamSL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
471 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
472 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
473 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
474 |
procedure handler_TEAM_ACCEPTED(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
475 |
begin |
11449 | 476 |
netAcceptedTeam(p.str1) |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
477 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
478 |
|
11447 | 479 |
procedure handler_TEAM_COLOR(var p: TCmdParamSS); |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
480 |
begin |
11447 | 481 |
netSetTeamColor(p.str1, StrToInt(p.str2)); |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
482 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
483 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
484 |
procedure handler_WARNING(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
485 |
begin |
11428 | 486 |
sendUI(mtWarning, @p.str1[1], length(p.str1)); |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
487 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
488 |
|
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
489 |
const handlers: array[TCmdType] of PHandler = (PHandler(@handler_ADD_TEAM), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
490 |
PHandler(@handler_ADD_TEAM_s), PHandler(@handler_ASKPASSWORD), |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
491 |
PHandler(@handler_BANLIST), PHandler(@handler_BANLIST_s), |
11434
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
492 |
PHandler(@handler_BYE), PHandler(@handler_CFG_AMMO), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
493 |
PHandler(@handler_CFG_DRAWNMAP), PHandler(@handler_CFG_FEATURE_SIZE), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
494 |
PHandler(@handler_CFG_FULLMAPCONFIG), PHandler(@handler_CFG_FULLMAPCONFIG_s), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
495 |
PHandler(@handler_CFG_MAP), PHandler(@handler_CFG_MAPGEN), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
496 |
PHandler(@handler_CFG_MAZE_SIZE), PHandler(@handler_CFG_SCHEME), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
497 |
PHandler(@handler_CFG_SCHEME_s), PHandler(@handler_CFG_SCRIPT), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
498 |
PHandler(@handler_CFG_SEED), PHandler(@handler_CFG_TEMPLATE), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11430
diff
changeset
|
499 |
PHandler(@handler_CFG_THEME), PHandler(@handler_CHAT), |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
500 |
PHandler(@handler_CLIENT_FLAGS), PHandler(@handler_CLIENT_FLAGS_s), |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
501 |
PHandler(@handler_CONNECTED), PHandler(@handler_EM), PHandler(@handler_EM_s), |
11447 | 502 |
PHandler(@handler_ERROR), PHandler(@handler_HH_NUM), PHandler(@handler_INFO), |
503 |
PHandler(@handler_INFO_s), PHandler(@handler_JOINED), |
|
504 |
PHandler(@handler_JOINED_s), PHandler(@handler_JOINING), |
|
505 |
PHandler(@handler_KICKED), PHandler(@handler_LEFT), |
|
11446 | 506 |
PHandler(@handler_LOBBY_JOINED), PHandler(@handler_LOBBY_JOINED_s), |
507 |
PHandler(@handler_LOBBY_LEFT), PHandler(@handler_NICK), |
|
508 |
PHandler(@handler_NOTICE), PHandler(@handler_PING), PHandler(@handler_PING_s), |
|
509 |
PHandler(@handler_PROTO), PHandler(@handler_REMOVE_TEAM), |
|
510 |
PHandler(@handler_ROOMS), PHandler(@handler_ROOMS_s), |
|
511 |
PHandler(@handler_ROOM_ADD), PHandler(@handler_ROOM_ADD_s), |
|
512 |
PHandler(@handler_ROOM_DEL), PHandler(@handler_ROOM_UPD), |
|
513 |
PHandler(@handler_ROOM_UPD_s), PHandler(@handler_ROUND_FINISHED), |
|
514 |
PHandler(@handler_RUN_GAME), PHandler(@handler_SERVER_AUTH), |
|
515 |
PHandler(@handler_SERVER_MESSAGE), PHandler(@handler_SERVER_VARS), |
|
516 |
PHandler(@handler_TEAM_ACCEPTED), PHandler(@handler_TEAM_COLOR), |
|
11447 | 517 |
PHandler(@handler_WARNING)); |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
518 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
519 |
procedure passNetData(p: pointer); cdecl; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
520 |
begin |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
521 |
handlers[TCmdData(p^).cmd.cmd](TCmdData(p^)) |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
522 |
end; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
523 |
|
11421 | 524 |
procedure sendChatLine(msg: PChar); cdecl; |
525 |
begin |
|
526 |
sendNetLn('CHAT'); |
|
527 |
sendNet(msg); |
|
528 |
end; |
|
529 |
||
11428 | 530 |
procedure joinRoom(roomName: PChar); cdecl; |
531 |
begin |
|
532 |
sendNetLn('JOIN_ROOM'); |
|
533 |
sendNet(roomName); |
|
534 |
end; |
|
535 |
||
11429 | 536 |
procedure partRoom(msg: PChar); cdecl; |
537 |
var s: string; |
|
538 |
begin |
|
539 |
if isInRoom then |
|
540 |
begin |
|
541 |
s:= 'PART'; |
|
11430
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11429
diff
changeset
|
542 |
if length(msg) > 0 then |
11429 | 543 |
s:= s + #10 + msg; |
544 |
sendNet(s); |
|
11448 | 545 |
|
546 |
onRoomLeaving() |
|
11429 | 547 |
end |
548 |
end; |
|
549 |
||
550 |
procedure ResetNetState; |
|
551 |
begin |
|
552 |
isInRoom:= false; |
|
553 |
end; |
|
554 |
||
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
555 |
end. |
11418
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
556 |