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