author | unc0rr |
Thu, 11 Aug 2016 23:05:14 +0300 | |
branch | qmlfrontend |
changeset 11843 | 01f88c3b7b66 |
parent 11462 | 33a0e3a14ddc |
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 |
|
11416 | 6 |
procedure sendChatLine(msg: PChar); cdecl; |
11423 | 7 |
procedure joinRoom(roomName: PChar); cdecl; |
11424 | 8 |
procedure partRoom(msg: PChar); cdecl; |
9 |
||
10 |
procedure ResetNetState; |
|
11416 | 11 |
|
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
12 |
implementation |
11454 | 13 |
uses uFLNetTypes, uFLTypes, uFLUICallback, uFLNet, uFLGameConfig, uFLUtils, uFLIPC, uUtils; |
11413
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 |
|
11424 | 18 |
var isInRoom: boolean; |
19 |
||
11443 | 20 |
procedure onRoomLeaving(); |
21 |
begin |
|
22 |
isInRoom:= false; |
|
23 |
sendUI(mtMoveToLobby, nil, 0); |
|
24 |
netResetTeams |
|
25 |
end; |
|
26 |
||
11442 | 27 |
var teamIndex: LongInt; |
28 |
tmpTeam: TTeam; |
|
29 |
||
30 |
const teamFields: array[0..22] of PShortstring = ( |
|
31 |
@tmpTeam.teamName |
|
32 |
, @tmpTeam.grave |
|
33 |
, @tmpTeam.fort |
|
34 |
, @tmpTeam.voice |
|
35 |
, @tmpTeam.flag |
|
36 |
, @tmpTeam.owner |
|
37 |
, nil |
|
38 |
, @tmpTeam.hedgehogs[0].name |
|
39 |
, @tmpTeam.hedgehogs[0].hat |
|
40 |
, @tmpTeam.hedgehogs[1].name |
|
41 |
, @tmpTeam.hedgehogs[1].hat |
|
42 |
, @tmpTeam.hedgehogs[2].name |
|
43 |
, @tmpTeam.hedgehogs[2].hat |
|
44 |
, @tmpTeam.hedgehogs[3].name |
|
45 |
, @tmpTeam.hedgehogs[3].hat |
|
46 |
, @tmpTeam.hedgehogs[4].name |
|
47 |
, @tmpTeam.hedgehogs[4].hat |
|
48 |
, @tmpTeam.hedgehogs[5].name |
|
49 |
, @tmpTeam.hedgehogs[5].hat |
|
50 |
, @tmpTeam.hedgehogs[6].name |
|
51 |
, @tmpTeam.hedgehogs[6].hat |
|
52 |
, @tmpTeam.hedgehogs[7].name |
|
53 |
, @tmpTeam.hedgehogs[7].hat |
|
54 |
); |
|
11454 | 55 |
|
11430 | 56 |
procedure handler_ADD_TEAM(var p: TCmdParam); |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
57 |
begin |
11442 | 58 |
teamIndex:= 0; |
59 |
tmpTeam.color:= 0 |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
60 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
61 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
62 |
procedure handler_ADD_TEAM_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
63 |
begin |
11442 | 64 |
if teamIndex = 6 then |
65 |
tmpTeam.botLevel:= strToInt(s.str1) |
|
66 |
else if teamIndex < 23 then |
|
67 |
teamFields[teamIndex]^:= s.str1; |
|
68 |
||
69 |
if teamIndex = 22 then |
|
70 |
netAddTeam(tmpTeam); |
|
71 |
||
72 |
inc(teamIndex); |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
73 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
74 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
75 |
procedure handler_ASKPASSWORD(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
76 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
77 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
78 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
79 |
procedure handler_BANLIST(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
80 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
81 |
end; |
11418 | 82 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
83 |
procedure handler_BANLIST_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
84 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
85 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
86 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
87 |
procedure handler_BYE(var p: TCmdParamSL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
88 |
begin |
11415 | 89 |
sendUI(mtDisconnected, @p.str2[1], length(p.str2)); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
90 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
91 |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
92 |
procedure handler_CFG_AMMO(var p: TCmdParamSL); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
93 |
begin |
11437 | 94 |
netSetAmmo(p.str1, p.str2) |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
95 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
96 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
97 |
procedure handler_CFG_DRAWNMAP(var p: TCmdParamL); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
98 |
begin |
11462 | 99 |
netDrawnData(copy(ansistring(p.str1), 1, p.str1len)) |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
100 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
101 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
102 |
procedure handler_CFG_FEATURE_SIZE(var p: TCmdParami); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
103 |
begin |
11433 | 104 |
if isInRoom then |
105 |
begin |
|
106 |
netSetFeatureSize(p.param1); |
|
107 |
updatePreviewIfNeeded |
|
108 |
end; |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
109 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
110 |
|
11433 | 111 |
var fmcfgIndex: integer; |
112 |
||
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
113 |
procedure handler_CFG_FULLMAPCONFIG(var p: TCmdParam); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
114 |
begin |
11433 | 115 |
fmcfgIndex:= 0; |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
116 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
117 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
118 |
procedure handler_CFG_FULLMAPCONFIG_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
119 |
begin |
11433 | 120 |
if not isInRoom then exit; |
121 |
||
122 |
inc(fmcfgIndex); |
|
123 |
case fmcfgIndex of |
|
11436 | 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); |
|
11433 | 129 |
6: begin |
11436 | 130 |
netSetTemplate(strToInt(s.str1)); |
11433 | 131 |
updatePreviewIfNeeded; |
11436 | 132 |
end; |
11433 | 133 |
end; |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
134 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
135 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
136 |
procedure handler_CFG_MAP(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
137 |
begin |
11433 | 138 |
if isInRoom then |
139 |
netSetMap(p.str1); |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
140 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
141 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
142 |
procedure handler_CFG_MAPGEN(var p: TCmdParami); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
143 |
begin |
11433 | 144 |
if isInRoom then |
145 |
begin |
|
146 |
netSetMapGen(p.param1); |
|
147 |
updatePreviewIfNeeded |
|
148 |
end |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
149 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
150 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
151 |
procedure handler_CFG_MAZE_SIZE(var p: TCmdParami); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
152 |
begin |
11433 | 153 |
if isInRoom then |
154 |
begin |
|
155 |
netSetMazeSize(p.param1); |
|
156 |
updatePreviewIfNeeded |
|
157 |
end |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
158 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
159 |
|
11440 | 160 |
var schemeIndex: LongInt; |
161 |
tmpScheme: TScheme; |
|
162 |
||
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
163 |
procedure handler_CFG_SCHEME(var p: TCmdParam); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
164 |
begin |
11440 | 165 |
schemeIndex:= 0 |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
166 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
167 |
|
11440 | 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 |
||
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
215 |
procedure handler_CFG_SCHEME_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
216 |
begin |
11440 | 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); |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
233 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
234 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
235 |
procedure handler_CFG_SCRIPT(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
236 |
begin |
11431 | 237 |
if isInRoom then |
238 |
netSetScript(p.str1) |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
239 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
240 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
241 |
procedure handler_CFG_SEED(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
242 |
begin |
11431 | 243 |
if isInRoom then |
244 |
netSetSeed(p.str1) |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
245 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
246 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
247 |
procedure handler_CFG_TEMPLATE(var p: TCmdParami); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
248 |
begin |
11433 | 249 |
if isInRoom then |
250 |
begin |
|
251 |
netSetTemplate(p.param1); |
|
252 |
updatePreviewIfNeeded |
|
253 |
end |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
254 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
255 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
256 |
procedure handler_CFG_THEME(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
257 |
begin |
11431 | 258 |
if isInRoom then |
259 |
netSetTheme(p.str1) |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
260 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
261 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
262 |
procedure handler_CHAT(var p: TCmdParamSL); |
11415 | 263 |
var s: string; |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
264 |
begin |
11462 | 265 |
s:= p.str1 + #10 + copy(p.str2, 0, p.str2len); |
11424 | 266 |
if isInRoom then |
267 |
sendUI(mtRoomChatLine, @s[1], length(s)) |
|
268 |
else |
|
269 |
sendUI(mtLobbyChatLine, @s[1], length(s)); |
|
11413
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 |
|
11449 | 272 |
var flags: array[TClientFlag] of LongInt; |
273 |
isFlagsLine: boolean; |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
274 |
procedure handler_CLIENT_FLAGS(var p: TCmdParamS); |
11449 | 275 |
var f: TClientFlag; |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
276 |
begin |
11449 | 277 |
for f:= Low(TClientFlag) to High(TClientFlag) do |
278 |
flags[f]:= 0; |
|
279 |
||
280 |
isFlagsLine:= true; |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
281 |
end; |
11418 | 282 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
283 |
procedure handler_CLIENT_FLAGS_s(var s: TCmdParamS); |
11449 | 284 |
var isRemoval: boolean; |
285 |
flagValue, i: LongInt; |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
286 |
begin |
11449 | 287 |
if isFlagsLine then |
288 |
begin |
|
11450
0c75fa9ce340
- Use queues instead of single buffer to communicate between threads
unc0rr
parents:
11449
diff
changeset
|
289 |
if s.str1[1] = '+' then flagValue:= 1 else flagValue:= -1; |
11449 | 290 |
for i:= 2 to Length(s.str1) do |
11450
0c75fa9ce340
- Use queues instead of single buffer to communicate between threads
unc0rr
parents:
11449
diff
changeset
|
291 |
case s.str1[1] of |
11449 | 292 |
'r': flags[cfReady]:= flagValue; |
293 |
'u': flags[cfRegistered]:= flagValue; |
|
294 |
'i': flags[cfInRoom]:= flagValue; |
|
295 |
'c': flags[cfContributor]:= flagValue; |
|
296 |
'g': flags[cfInGame]:= flagValue; |
|
297 |
'h': flags[cfRoomAdmin]:= flagValue; |
|
298 |
'a': flags[cfServerAdmin]:= flagValue; |
|
299 |
end; |
|
300 |
||
301 |
isFlagsLine:= false; |
|
302 |
end else |
|
303 |
begin |
|
304 |
||
305 |
end |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
306 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
307 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
308 |
procedure handler_CONNECTED(var p: TCmdParami); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
309 |
begin |
11415 | 310 |
sendUI(mtConnected, nil, 0); |
11449 | 311 |
//writeln('Server features version ', p.param1); |
11843 | 312 |
sendNet('PROTO' + #10 + '52'); |
313 |
sendNet('NICK' + #10 + myNickname); |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
314 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
315 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
316 |
procedure handler_EM(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
317 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
318 |
end; |
11418 | 319 |
|
11454 | 320 |
procedure handler_EM_s(var p: TCmdParamL); |
321 |
var i, l: Longword; |
|
322 |
s: shortstring; |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
323 |
begin |
11454 | 324 |
i:= 1; |
325 |
l:= length(p.str1); |
|
326 |
||
327 |
while i < l do |
|
328 |
begin |
|
329 |
s:= DecodeBase64(copy(p.str1, i, 240)); |
|
11460 | 330 |
ipcToEngineRaw(@s[1], byte(s[0])); |
11454 | 331 |
inc(i, 160) |
332 |
end; |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
333 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
334 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
335 |
procedure handler_ERROR(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
336 |
begin |
11423 | 337 |
sendUI(mtError, @p.str1[1], length(p.str1)); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
338 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
339 |
|
11442 | 340 |
procedure handler_HH_NUM(var p: TCmdParamSS); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
341 |
begin |
11443 | 342 |
netSetHedgehogsNumber(p.str1, StrToInt(p.str2)) |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
343 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
344 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
345 |
procedure handler_INFO(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
346 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
347 |
end; |
11418 | 348 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
349 |
procedure handler_INFO_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
350 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
351 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
352 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
353 |
procedure handler_JOINED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
354 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
355 |
end; |
11418 | 356 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
357 |
procedure handler_JOINED_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
358 |
begin |
11430 | 359 |
if s.str1 = myNickname then // we joined a room |
11424 | 360 |
begin |
361 |
isInRoom:= true; |
|
362 |
sendUI(mtMoveToRoom, nil, 0); |
|
363 |
end; |
|
364 |
||
365 |
sendUI(mtAddRoomClient, @s.str1[1], length(s.str1)); |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
366 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
367 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
368 |
procedure handler_JOINING(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
369 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
370 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
371 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
372 |
procedure handler_KICKED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
373 |
begin |
11443 | 374 |
onRoomLeaving() |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
375 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
376 |
|
11441 | 377 |
procedure handler_LEFT(var p: TCmdParamSL); |
11462 | 378 |
var s: string; |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
379 |
begin |
11462 | 380 |
s:= p.str1 + #10 + copy(p.str2, 0, p.str2len); |
381 |
sendUI(mtRemoveRoomClient, @s[1], length(s)); |
|
11413
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_LOBBY_JOINED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
385 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
386 |
end; |
11418 | 387 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
388 |
procedure handler_LOBBY_JOINED_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
389 |
begin |
11430 | 390 |
if s.str1 = myNickname then |
11424 | 391 |
begin |
392 |
sendUI(mtMoveToLobby, nil, 0); |
|
393 |
sendNet('LIST'); |
|
394 |
end; |
|
11419 | 395 |
|
11415 | 396 |
sendUI(mtAddLobbyClient, @s.str1[1], length(s.str1)); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
397 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
398 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
399 |
procedure handler_LOBBY_LEFT(var p: TCmdParamSL); |
11462 | 400 |
var s: string; |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
401 |
begin |
11462 | 402 |
s:= p.str1 + #10 + copy(p.str2, 0, p.str2len); |
403 |
sendUI(mtRemoveLobbyClient, @s[1], length(s)); |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
404 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
405 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
406 |
procedure handler_NICK(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
407 |
begin |
11430 | 408 |
myNickname:= p.str1; |
409 |
sendUI(mtNickname, @p.str1[1], length(p.str1)); |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
410 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
411 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
412 |
procedure handler_NOTICE(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
413 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
414 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
415 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
416 |
procedure handler_PING(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
417 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
418 |
sendNet('PONG') |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
419 |
end; |
11418 | 420 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
421 |
procedure handler_PING_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
422 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
423 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
424 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
425 |
procedure handler_PROTO(var p: TCmdParami); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
426 |
begin |
11454 | 427 |
//writeln('Protocol ', p.param1) |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
428 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
429 |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
430 |
procedure handler_REMOVE_TEAM(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
431 |
begin |
11443 | 432 |
netRemoveTeam(p.str1) |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
433 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
434 |
|
11418 | 435 |
var roomInfo: string; |
436 |
roomLinesCount: integer; |
|
437 |
||
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
438 |
procedure handler_ROOMS(var p: TCmdParam); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
439 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
440 |
roomInfo:= ''; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
441 |
roomLinesCount:= 0 |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
442 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
443 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
444 |
procedure handler_ROOMS_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
445 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
446 |
roomInfo:= roomInfo + s.str1 + #10; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
447 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
448 |
if roomLinesCount = 8 then |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
449 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
450 |
sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
451 |
roomLinesCount:= 0; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
452 |
roomInfo:= '' |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
453 |
end else inc(roomLinesCount); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
454 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
455 |
|
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
456 |
procedure handler_ROOM_ADD(var p: TCmdParam); |
11418 | 457 |
begin |
458 |
roomInfo:= ''; |
|
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
459 |
roomLinesCount:= 0 |
11418 | 460 |
end; |
461 |
||
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
462 |
procedure handler_ROOM_ADD_s(var s: TCmdParamS); |
11418 | 463 |
begin |
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
464 |
roomInfo:= roomInfo + s.str1 + #10; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
465 |
inc(roomLinesCount); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
466 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
467 |
if roomLinesCount = 9 then |
11418 | 468 |
begin |
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
469 |
sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
470 |
roomInfo:= ''; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
471 |
roomLinesCount:= 0 |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
472 |
end; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
473 |
end; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
474 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
475 |
procedure handler_ROOM_DEL(var p: TCmdParamS); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
476 |
begin |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
477 |
sendUI(mtRemoveRoom, @p.str1[1], length(p.str1)); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
478 |
end; |
11418 | 479 |
|
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
480 |
procedure handler_ROOM_UPD(var p: TCmdParam); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
481 |
begin |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
482 |
roomInfo:= ''; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
483 |
roomLinesCount:= 0 |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
484 |
end; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
485 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
486 |
procedure handler_ROOM_UPD_s(var s: TCmdParamS); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
487 |
begin |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
488 |
roomInfo:= roomInfo + s.str1 + #10; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
489 |
inc(roomLinesCount); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
490 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
491 |
if roomLinesCount = 10 then |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
492 |
sendUI(mtUpdateRoom, @roomInfo[1], length(roomInfo) - 1); |
11418 | 493 |
end; |
494 |
||
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
495 |
procedure handler_ROUND_FINISHED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
496 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
497 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
498 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
499 |
procedure handler_RUN_GAME(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
500 |
begin |
11460 | 501 |
runNetGame |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
502 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
503 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
504 |
procedure handler_SERVER_AUTH(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
505 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
506 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
507 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
508 |
procedure handler_SERVER_MESSAGE(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
509 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
510 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
511 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
512 |
procedure handler_SERVER_VARS(var p: TCmdParamSL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
513 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
514 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
515 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
516 |
procedure handler_TEAM_ACCEPTED(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
517 |
begin |
11444 | 518 |
netAcceptedTeam(p.str1) |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
519 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
520 |
|
11442 | 521 |
procedure handler_TEAM_COLOR(var p: TCmdParamSS); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
522 |
begin |
11442 | 523 |
netSetTeamColor(p.str1, StrToInt(p.str2)); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
524 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
525 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
526 |
procedure handler_WARNING(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
527 |
begin |
11423 | 528 |
sendUI(mtWarning, @p.str1[1], length(p.str1)); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
529 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
530 |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
531 |
const handlers: array[TCmdType] of PHandler = (PHandler(@handler_ADD_TEAM), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
532 |
PHandler(@handler_ADD_TEAM_s), PHandler(@handler_ASKPASSWORD), |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
533 |
PHandler(@handler_BANLIST), PHandler(@handler_BANLIST_s), |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
534 |
PHandler(@handler_BYE), PHandler(@handler_CFG_AMMO), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
535 |
PHandler(@handler_CFG_DRAWNMAP), PHandler(@handler_CFG_FEATURE_SIZE), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
536 |
PHandler(@handler_CFG_FULLMAPCONFIG), PHandler(@handler_CFG_FULLMAPCONFIG_s), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
537 |
PHandler(@handler_CFG_MAP), PHandler(@handler_CFG_MAPGEN), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
538 |
PHandler(@handler_CFG_MAZE_SIZE), PHandler(@handler_CFG_SCHEME), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
539 |
PHandler(@handler_CFG_SCHEME_s), PHandler(@handler_CFG_SCRIPT), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
540 |
PHandler(@handler_CFG_SEED), PHandler(@handler_CFG_TEMPLATE), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
541 |
PHandler(@handler_CFG_THEME), PHandler(@handler_CHAT), |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
542 |
PHandler(@handler_CLIENT_FLAGS), PHandler(@handler_CLIENT_FLAGS_s), |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
543 |
PHandler(@handler_CONNECTED), PHandler(@handler_EM), PHandler(@handler_EM_s), |
11442 | 544 |
PHandler(@handler_ERROR), PHandler(@handler_HH_NUM), PHandler(@handler_INFO), |
545 |
PHandler(@handler_INFO_s), PHandler(@handler_JOINED), |
|
546 |
PHandler(@handler_JOINED_s), PHandler(@handler_JOINING), |
|
547 |
PHandler(@handler_KICKED), PHandler(@handler_LEFT), |
|
11441 | 548 |
PHandler(@handler_LOBBY_JOINED), PHandler(@handler_LOBBY_JOINED_s), |
549 |
PHandler(@handler_LOBBY_LEFT), PHandler(@handler_NICK), |
|
550 |
PHandler(@handler_NOTICE), PHandler(@handler_PING), PHandler(@handler_PING_s), |
|
551 |
PHandler(@handler_PROTO), PHandler(@handler_REMOVE_TEAM), |
|
552 |
PHandler(@handler_ROOMS), PHandler(@handler_ROOMS_s), |
|
553 |
PHandler(@handler_ROOM_ADD), PHandler(@handler_ROOM_ADD_s), |
|
554 |
PHandler(@handler_ROOM_DEL), PHandler(@handler_ROOM_UPD), |
|
555 |
PHandler(@handler_ROOM_UPD_s), PHandler(@handler_ROUND_FINISHED), |
|
556 |
PHandler(@handler_RUN_GAME), PHandler(@handler_SERVER_AUTH), |
|
557 |
PHandler(@handler_SERVER_MESSAGE), PHandler(@handler_SERVER_VARS), |
|
558 |
PHandler(@handler_TEAM_ACCEPTED), PHandler(@handler_TEAM_COLOR), |
|
11442 | 559 |
PHandler(@handler_WARNING)); |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
560 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
561 |
procedure passNetData(p: pointer); cdecl; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
562 |
begin |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
563 |
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
|
564 |
end; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
565 |
|
11416 | 566 |
procedure sendChatLine(msg: PChar); cdecl; |
567 |
begin |
|
568 |
sendNetLn('CHAT'); |
|
569 |
sendNet(msg); |
|
570 |
end; |
|
571 |
||
11423 | 572 |
procedure joinRoom(roomName: PChar); cdecl; |
573 |
begin |
|
574 |
sendNetLn('JOIN_ROOM'); |
|
575 |
sendNet(roomName); |
|
576 |
end; |
|
577 |
||
11424 | 578 |
procedure partRoom(msg: PChar); cdecl; |
579 |
var s: string; |
|
580 |
begin |
|
581 |
if isInRoom then |
|
582 |
begin |
|
583 |
s:= 'PART'; |
|
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
584 |
if length(msg) > 0 then |
11424 | 585 |
s:= s + #10 + msg; |
586 |
sendNet(s); |
|
11443 | 587 |
|
588 |
onRoomLeaving() |
|
11424 | 589 |
end |
590 |
end; |
|
591 |
||
592 |
procedure ResetNetState; |
|
593 |
begin |
|
594 |
isInRoom:= false; |
|
595 |
end; |
|
596 |
||
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
597 |
end. |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
598 |