author | unc0rr |
Thu, 10 Dec 2015 00:33:45 +0300 | |
branch | qmlfrontend |
changeset 11450 | 0c75fa9ce340 |
parent 11449 | 2bf0491d5e88 |
child 11451 | 6e9b12864856 |
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 |
11433 | 13 |
uses uFLNetTypes, uFLTypes, uFLUICallback, uFLNet, uFLGameConfig, uFLUtils; |
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; |
11430 | 19 |
myNickname: shortstring; |
11424 | 20 |
|
11443 | 21 |
procedure onRoomLeaving(); |
22 |
begin |
|
23 |
isInRoom:= false; |
|
24 |
sendUI(mtMoveToLobby, nil, 0); |
|
25 |
netResetTeams |
|
26 |
end; |
|
27 |
||
11442 | 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 |
); |
|
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.extDriven:= true; |
|
60 |
tmpTeam.color:= 0 |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
61 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
62 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
63 |
procedure handler_ADD_TEAM_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
64 |
begin |
11442 | 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); |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
74 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
75 |
|
11413
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; |
11418 | 83 |
|
11413
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 |
11415 | 90 |
sendUI(mtDisconnected, @p.str2[1], length(p.str2)); |
11413
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 |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
93 |
procedure handler_CFG_AMMO(var p: TCmdParamSL); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
94 |
begin |
11437 | 95 |
netSetAmmo(p.str1, p.str2) |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
96 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
97 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
98 |
procedure handler_CFG_DRAWNMAP(var p: TCmdParamL); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
99 |
begin |
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 |
11415 | 265 |
s:= p.str1 + #10 + p.str2; |
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); |
11415 | 312 |
sendNet('PROTO' + #10 + '51'); |
313 |
sendNet('NICK' + #10 + 'qmlfrontend'); |
|
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 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
320 |
procedure handler_EM_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
321 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
322 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
323 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
324 |
procedure handler_ERROR(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
325 |
begin |
11423 | 326 |
sendUI(mtError, @p.str1[1], length(p.str1)); |
11413
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 |
|
11442 | 329 |
procedure handler_HH_NUM(var p: TCmdParamSS); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
330 |
begin |
11443 | 331 |
netSetHedgehogsNumber(p.str1, StrToInt(p.str2)) |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
332 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
333 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
334 |
procedure handler_INFO(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
335 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
336 |
end; |
11418 | 337 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
338 |
procedure handler_INFO_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
339 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
340 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
341 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
342 |
procedure handler_JOINED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
343 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
344 |
end; |
11418 | 345 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
346 |
procedure handler_JOINED_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
347 |
begin |
11430 | 348 |
if s.str1 = myNickname then // we joined a room |
11424 | 349 |
begin |
350 |
isInRoom:= true; |
|
351 |
sendUI(mtMoveToRoom, nil, 0); |
|
352 |
end; |
|
353 |
||
354 |
sendUI(mtAddRoomClient, @s.str1[1], length(s.str1)); |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
355 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
356 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
357 |
procedure handler_JOINING(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
358 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
359 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
360 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
361 |
procedure handler_KICKED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
362 |
begin |
11443 | 363 |
onRoomLeaving() |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
364 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
365 |
|
11441 | 366 |
procedure handler_LEFT(var p: TCmdParamSL); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
367 |
begin |
11441 | 368 |
p.str2:= p.str1 + #10 + p.str2; |
369 |
sendUI(mtRemoveRoomClient, @p.str2[1], length(p.str2)); |
|
11413
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_LOBBY_JOINED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
373 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
374 |
end; |
11418 | 375 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
376 |
procedure handler_LOBBY_JOINED_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
377 |
begin |
11430 | 378 |
if s.str1 = myNickname then |
11424 | 379 |
begin |
380 |
sendUI(mtMoveToLobby, nil, 0); |
|
381 |
sendNet('LIST'); |
|
382 |
end; |
|
11419 | 383 |
|
11415 | 384 |
sendUI(mtAddLobbyClient, @s.str1[1], length(s.str1)); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
385 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
386 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
387 |
procedure handler_LOBBY_LEFT(var p: TCmdParamSL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
388 |
begin |
11423 | 389 |
p.str2:= p.str1 + #10 + p.str2; |
390 |
sendUI(mtRemoveLobbyClient, @p.str2[1], length(p.str2)); |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
391 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
392 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
393 |
procedure handler_NICK(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
394 |
begin |
11430 | 395 |
myNickname:= p.str1; |
396 |
sendUI(mtNickname, @p.str1[1], length(p.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_NOTICE(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
400 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
401 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
402 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
403 |
procedure handler_PING(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
404 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
405 |
sendNet('PONG') |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
406 |
end; |
11418 | 407 |
|
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
408 |
procedure handler_PING_s(var s: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
409 |
begin |
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_PROTO(var p: TCmdParami); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
413 |
begin |
11434 | 414 |
writeln('Protocol ', p.param1) |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
415 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
416 |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
417 |
procedure handler_REMOVE_TEAM(var p: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
418 |
begin |
11443 | 419 |
netRemoveTeam(p.str1) |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
420 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
421 |
|
11418 | 422 |
var roomInfo: string; |
423 |
roomLinesCount: integer; |
|
424 |
||
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
425 |
procedure handler_ROOMS(var p: TCmdParam); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
426 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
427 |
roomInfo:= ''; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
428 |
roomLinesCount:= 0 |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
429 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
430 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
431 |
procedure handler_ROOMS_s(var s: TCmdParamS); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
432 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
433 |
roomInfo:= roomInfo + s.str1 + #10; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
434 |
|
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
435 |
if roomLinesCount = 8 then |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
436 |
begin |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
437 |
sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
438 |
roomLinesCount:= 0; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
439 |
roomInfo:= '' |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
440 |
end else inc(roomLinesCount); |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
441 |
end; |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
442 |
|
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
443 |
procedure handler_ROOM_ADD(var p: TCmdParam); |
11418 | 444 |
begin |
445 |
roomInfo:= ''; |
|
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
446 |
roomLinesCount:= 0 |
11418 | 447 |
end; |
448 |
||
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
449 |
procedure handler_ROOM_ADD_s(var s: TCmdParamS); |
11418 | 450 |
begin |
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
451 |
roomInfo:= roomInfo + s.str1 + #10; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
452 |
inc(roomLinesCount); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
453 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
454 |
if roomLinesCount = 9 then |
11418 | 455 |
begin |
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
456 |
sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
457 |
roomInfo:= ''; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
458 |
roomLinesCount:= 0 |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
459 |
end; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
460 |
end; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
461 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
462 |
procedure handler_ROOM_DEL(var p: TCmdParamS); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
463 |
begin |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
464 |
sendUI(mtRemoveRoom, @p.str1[1], length(p.str1)); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
465 |
end; |
11418 | 466 |
|
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
467 |
procedure handler_ROOM_UPD(var p: TCmdParam); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
468 |
begin |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
469 |
roomInfo:= ''; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
470 |
roomLinesCount:= 0 |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
471 |
end; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
472 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
473 |
procedure handler_ROOM_UPD_s(var s: TCmdParamS); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
474 |
begin |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
475 |
roomInfo:= roomInfo + s.str1 + #10; |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
476 |
inc(roomLinesCount); |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
477 |
|
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
478 |
if roomLinesCount = 10 then |
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
479 |
sendUI(mtUpdateRoom, @roomInfo[1], length(roomInfo) - 1); |
11418 | 480 |
end; |
481 |
||
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
482 |
procedure handler_ROUND_FINISHED(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
483 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
484 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
485 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
486 |
procedure handler_RUN_GAME(var p: TCmdParam); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
487 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
488 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
489 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
490 |
procedure handler_SERVER_AUTH(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
491 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
492 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
493 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
494 |
procedure handler_SERVER_MESSAGE(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
495 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
496 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
497 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
498 |
procedure handler_SERVER_VARS(var p: TCmdParamSL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
499 |
begin |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
500 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
501 |
|
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
502 |
procedure handler_TEAM_ACCEPTED(var p: TCmdParamS); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
503 |
begin |
11444 | 504 |
netAcceptedTeam(p.str1) |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
505 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
506 |
|
11442 | 507 |
procedure handler_TEAM_COLOR(var p: TCmdParamSS); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
508 |
begin |
11442 | 509 |
netSetTeamColor(p.str1, StrToInt(p.str2)); |
11413
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_WARNING(var p: TCmdParamL); |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
513 |
begin |
11423 | 514 |
sendUI(mtWarning, @p.str1[1], length(p.str1)); |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
515 |
end; |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
516 |
|
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
517 |
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
|
518 |
PHandler(@handler_ADD_TEAM_s), PHandler(@handler_ASKPASSWORD), |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
519 |
PHandler(@handler_BANLIST), PHandler(@handler_BANLIST_s), |
11429
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
520 |
PHandler(@handler_BYE), PHandler(@handler_CFG_AMMO), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
521 |
PHandler(@handler_CFG_DRAWNMAP), PHandler(@handler_CFG_FEATURE_SIZE), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
522 |
PHandler(@handler_CFG_FULLMAPCONFIG), PHandler(@handler_CFG_FULLMAPCONFIG_s), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
523 |
PHandler(@handler_CFG_MAP), PHandler(@handler_CFG_MAPGEN), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
524 |
PHandler(@handler_CFG_MAZE_SIZE), PHandler(@handler_CFG_SCHEME), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
525 |
PHandler(@handler_CFG_SCHEME_s), PHandler(@handler_CFG_SCRIPT), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
526 |
PHandler(@handler_CFG_SEED), PHandler(@handler_CFG_TEMPLATE), |
d96a37de1076
Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents:
11425
diff
changeset
|
527 |
PHandler(@handler_CFG_THEME), PHandler(@handler_CHAT), |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
528 |
PHandler(@handler_CLIENT_FLAGS), PHandler(@handler_CLIENT_FLAGS_s), |
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
529 |
PHandler(@handler_CONNECTED), PHandler(@handler_EM), PHandler(@handler_EM_s), |
11442 | 530 |
PHandler(@handler_ERROR), PHandler(@handler_HH_NUM), PHandler(@handler_INFO), |
531 |
PHandler(@handler_INFO_s), PHandler(@handler_JOINED), |
|
532 |
PHandler(@handler_JOINED_s), PHandler(@handler_JOINING), |
|
533 |
PHandler(@handler_KICKED), PHandler(@handler_LEFT), |
|
11441 | 534 |
PHandler(@handler_LOBBY_JOINED), PHandler(@handler_LOBBY_JOINED_s), |
535 |
PHandler(@handler_LOBBY_LEFT), PHandler(@handler_NICK), |
|
536 |
PHandler(@handler_NOTICE), PHandler(@handler_PING), PHandler(@handler_PING_s), |
|
537 |
PHandler(@handler_PROTO), PHandler(@handler_REMOVE_TEAM), |
|
538 |
PHandler(@handler_ROOMS), PHandler(@handler_ROOMS_s), |
|
539 |
PHandler(@handler_ROOM_ADD), PHandler(@handler_ROOM_ADD_s), |
|
540 |
PHandler(@handler_ROOM_DEL), PHandler(@handler_ROOM_UPD), |
|
541 |
PHandler(@handler_ROOM_UPD_s), PHandler(@handler_ROUND_FINISHED), |
|
542 |
PHandler(@handler_RUN_GAME), PHandler(@handler_SERVER_AUTH), |
|
543 |
PHandler(@handler_SERVER_MESSAGE), PHandler(@handler_SERVER_VARS), |
|
544 |
PHandler(@handler_TEAM_ACCEPTED), PHandler(@handler_TEAM_COLOR), |
|
11442 | 545 |
PHandler(@handler_WARNING)); |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
546 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
547 |
procedure passNetData(p: pointer); cdecl; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
548 |
begin |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
549 |
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
|
550 |
end; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
551 |
|
11416 | 552 |
procedure sendChatLine(msg: PChar); cdecl; |
553 |
begin |
|
554 |
sendNetLn('CHAT'); |
|
555 |
sendNet(msg); |
|
556 |
end; |
|
557 |
||
11423 | 558 |
procedure joinRoom(roomName: PChar); cdecl; |
559 |
begin |
|
560 |
sendNetLn('JOIN_ROOM'); |
|
561 |
sendNet(roomName); |
|
562 |
end; |
|
563 |
||
11424 | 564 |
procedure partRoom(msg: PChar); cdecl; |
565 |
var s: string; |
|
566 |
begin |
|
567 |
if isInRoom then |
|
568 |
begin |
|
569 |
s:= 'PART'; |
|
11425
2947f06e8533
Another approach to parsing two-lines protocol commands
unc0rr
parents:
11424
diff
changeset
|
570 |
if length(msg) > 0 then |
11424 | 571 |
s:= s + #10 + msg; |
572 |
sendNet(s); |
|
11443 | 573 |
|
574 |
onRoomLeaving() |
|
11424 | 575 |
end |
576 |
end; |
|
577 |
||
578 |
procedure ResetNetState; |
|
579 |
begin |
|
580 |
isInRoom:= false; |
|
581 |
end; |
|
582 |
||
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
583 |
end. |
11413
ffff8a0d1a76
Implement processing net commands in the main thread
unc0rr
parents:
10953
diff
changeset
|
584 |