hedgewars/uFLNetProtocol.pas
branchqmlfrontend
changeset 11443 5182d44fb733
parent 11442 6b04a266feee
child 11444 91f8c6ff5bab
equal deleted inserted replaced
11442:6b04a266feee 11443:5182d44fb733
    15 type
    15 type
    16     PHandler = procedure (var t: TCmdData);
    16     PHandler = procedure (var t: TCmdData);
    17 
    17 
    18 var isInRoom: boolean;
    18 var isInRoom: boolean;
    19     myNickname: shortstring;
    19     myNickname: shortstring;
       
    20 
       
    21 procedure onRoomLeaving();
       
    22 begin
       
    23     isInRoom:= false;
       
    24     sendUI(mtMoveToLobby, nil, 0);
       
    25     netResetTeams
       
    26 end;
    20 
    27 
    21 var teamIndex: LongInt;
    28 var teamIndex: LongInt;
    22     tmpTeam: TTeam;
    29     tmpTeam: TTeam;
    23 
    30 
    24 const teamFields: array[0..22] of PShortstring = (
    31 const teamFields: array[0..22] of PShortstring = (
   291     sendUI(mtError, @p.str1[1], length(p.str1));
   298     sendUI(mtError, @p.str1[1], length(p.str1));
   292 end;
   299 end;
   293 
   300 
   294 procedure handler_HH_NUM(var p: TCmdParamSS);
   301 procedure handler_HH_NUM(var p: TCmdParamSS);
   295 begin
   302 begin
       
   303     netSetHedgehogsNumber(p.str1, StrToInt(p.str2))
   296 end;
   304 end;
   297 
   305 
   298 procedure handler_INFO(var p: TCmdParam);
   306 procedure handler_INFO(var p: TCmdParam);
   299 begin
   307 begin
   300 end;
   308 end;
   322 begin
   330 begin
   323 end;
   331 end;
   324 
   332 
   325 procedure handler_KICKED(var p: TCmdParam);
   333 procedure handler_KICKED(var p: TCmdParam);
   326 begin
   334 begin
   327     isInRoom:= false;
   335     onRoomLeaving()
   328     sendUI(mtMoveToLobby, nil, 0);
       
   329 end;
   336 end;
   330 
   337 
   331 procedure handler_LEFT(var p: TCmdParamSL);
   338 procedure handler_LEFT(var p: TCmdParamSL);
   332 begin
   339 begin
   333     p.str2:= p.str1 + #10 + p.str2;
   340     p.str2:= p.str1 + #10 + p.str2;
   379     writeln('Protocol ', p.param1)
   386     writeln('Protocol ', p.param1)
   380 end;
   387 end;
   381 
   388 
   382 procedure handler_REMOVE_TEAM(var p: TCmdParamS);
   389 procedure handler_REMOVE_TEAM(var p: TCmdParamS);
   383 begin
   390 begin
       
   391     netRemoveTeam(p.str1)
   384 end;
   392 end;
   385 
   393 
   386 var roomInfo: string;
   394 var roomInfo: string;
   387     roomLinesCount: integer;
   395     roomLinesCount: integer;
   388 
   396 
   527 procedure partRoom(msg: PChar); cdecl;
   535 procedure partRoom(msg: PChar); cdecl;
   528 var s: string;
   536 var s: string;
   529 begin
   537 begin
   530     if isInRoom then
   538     if isInRoom then
   531     begin
   539     begin
   532         isInRoom:= false;
       
   533         s:= 'PART';
   540         s:= 'PART';
   534         if length(msg) > 0 then
   541         if length(msg) > 0 then
   535             s:= s + #10 + msg;
   542             s:= s + #10 + msg;
   536         sendNet(s);
   543         sendNet(s);
   537         sendUI(mtMoveToLobby, nil, 0);
   544 
       
   545         onRoomLeaving()
   538     end
   546     end
   539 end;
   547 end;
   540 
   548 
   541 procedure ResetNetState;
   549 procedure ResetNetState;
   542 begin
   550 begin