hedgewars/uFLNetProtocol.pas
branchqmlfrontend
changeset 11429 d96a37de1076
parent 11425 2947f06e8533
child 11430 f88b3948adf3
equal deleted inserted replaced
11428:cc12bba5b2a2 11429:d96a37de1076
    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 
    19 
       
    20     procedure handler_ADD_TEAM(var p: TCmdParam);
       
    21 begin
       
    22 end;
       
    23 
       
    24 procedure handler_ADD_TEAM_s(var s: TCmdParamS);
       
    25 begin
       
    26 end;
       
    27 
    20 procedure handler_ASKPASSWORD(var p: TCmdParamS);
    28 procedure handler_ASKPASSWORD(var p: TCmdParamS);
    21 begin
    29 begin
    22 end;
    30 end;
    23 
    31 
    24 procedure handler_BANLIST(var p: TCmdParam);
    32 procedure handler_BANLIST(var p: TCmdParam);
    30 end;
    38 end;
    31 
    39 
    32 procedure handler_BYE(var p: TCmdParamSL);
    40 procedure handler_BYE(var p: TCmdParamSL);
    33 begin
    41 begin
    34     sendUI(mtDisconnected, @p.str2[1], length(p.str2));
    42     sendUI(mtDisconnected, @p.str2[1], length(p.str2));
       
    43 end;
       
    44 
       
    45 procedure handler_CFG_AMMO(var p: TCmdParamSL);
       
    46 begin
       
    47 end;
       
    48 
       
    49 procedure handler_CFG_DRAWNMAP(var p: TCmdParamL);
       
    50 begin
       
    51 end;
       
    52 
       
    53 procedure handler_CFG_FEATURE_SIZE(var p: TCmdParami);
       
    54 begin
       
    55 end;
       
    56 
       
    57 procedure handler_CFG_FULLMAPCONFIG(var p: TCmdParam);
       
    58 begin
       
    59 end;
       
    60 
       
    61 procedure handler_CFG_FULLMAPCONFIG_s(var s: TCmdParamS);
       
    62 begin
       
    63 end;
       
    64 
       
    65 procedure handler_CFG_MAP(var p: TCmdParamS);
       
    66 begin
       
    67 end;
       
    68 
       
    69 procedure handler_CFG_MAPGEN(var p: TCmdParami);
       
    70 begin
       
    71 end;
       
    72 
       
    73 procedure handler_CFG_MAZE_SIZE(var p: TCmdParami);
       
    74 begin
       
    75 end;
       
    76 
       
    77 procedure handler_CFG_SCHEME(var p: TCmdParam);
       
    78 begin
       
    79 end;
       
    80 
       
    81 procedure handler_CFG_SCHEME_s(var s: TCmdParamS);
       
    82 begin
       
    83 end;
       
    84 
       
    85 procedure handler_CFG_SCRIPT(var p: TCmdParamS);
       
    86 begin
       
    87 end;
       
    88 
       
    89 procedure handler_CFG_SEED(var p: TCmdParamS);
       
    90 begin
       
    91 end;
       
    92 
       
    93 procedure handler_CFG_TEMPLATE(var p: TCmdParami);
       
    94 begin
       
    95 end;
       
    96 
       
    97 procedure handler_CFG_THEME(var p: TCmdParamS);
       
    98 begin
    35 end;
    99 end;
    36 
   100 
    37 procedure handler_CHAT(var p: TCmdParamSL);
   101 procedure handler_CHAT(var p: TCmdParamSL);
    38 var s: string;
   102 var s: string;
    39 begin
   103 begin
   162 
   226 
   163 procedure handler_PROTO(var p: TCmdParami);
   227 procedure handler_PROTO(var p: TCmdParami);
   164 begin
   228 begin
   165 end;
   229 end;
   166 
   230 
       
   231 procedure handler_REMOVE_TEAM(var p: TCmdParamS);
       
   232 begin
       
   233 end;
       
   234 
   167 var roomInfo: string;
   235 var roomInfo: string;
   168     roomLinesCount: integer;
   236     roomLinesCount: integer;
       
   237 
       
   238 procedure handler_ROOMS(var p: TCmdParam);
       
   239 begin
       
   240     roomInfo:= '';
       
   241     roomLinesCount:= 0
       
   242 end;
       
   243 
       
   244 procedure handler_ROOMS_s(var s: TCmdParamS);
       
   245 begin
       
   246     roomInfo:= roomInfo + s.str1 + #10;
       
   247 
       
   248     if roomLinesCount = 8 then
       
   249     begin
       
   250         sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1);
       
   251         roomLinesCount:= 0;
       
   252         roomInfo:= ''
       
   253     end else inc(roomLinesCount);
       
   254 end;
   169 
   255 
   170 procedure handler_ROOM_ADD(var p: TCmdParam);
   256 procedure handler_ROOM_ADD(var p: TCmdParam);
   171 begin
   257 begin
   172     roomInfo:= '';
   258     roomInfo:= '';
   173     roomLinesCount:= 0
   259     roomLinesCount:= 0
   204 
   290 
   205     if roomLinesCount = 10 then
   291     if roomLinesCount = 10 then
   206         sendUI(mtUpdateRoom, @roomInfo[1], length(roomInfo) - 1);
   292         sendUI(mtUpdateRoom, @roomInfo[1], length(roomInfo) - 1);
   207 end;
   293 end;
   208 
   294 
   209 procedure handler_ROOMS(var p: TCmdParam);
       
   210 begin
       
   211     roomInfo:= '';
       
   212     roomLinesCount:= 0
       
   213 end;
       
   214 
       
   215 procedure handler_ROOMS_s(var s: TCmdParamS);
       
   216 begin
       
   217     roomInfo:= roomInfo + s.str1 + #10;
       
   218 
       
   219     if roomLinesCount = 8 then
       
   220     begin
       
   221         sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1);
       
   222         roomLinesCount:= 0;
       
   223         roomInfo:= ''
       
   224     end else inc(roomLinesCount);
       
   225 end;
       
   226 
       
   227 procedure handler_ROUND_FINISHED(var p: TCmdParam);
   295 procedure handler_ROUND_FINISHED(var p: TCmdParam);
   228 begin
   296 begin
   229 end;
   297 end;
   230 
   298 
   231 procedure handler_RUN_GAME(var p: TCmdParam);
   299 procedure handler_RUN_GAME(var p: TCmdParam);
   259 procedure handler_WARNING(var p: TCmdParamL);
   327 procedure handler_WARNING(var p: TCmdParamL);
   260 begin
   328 begin
   261     sendUI(mtWarning, @p.str1[1], length(p.str1));
   329     sendUI(mtWarning, @p.str1[1], length(p.str1));
   262 end;
   330 end;
   263 
   331 
   264 const handlers: array[TCmdType] of PHandler = (PHandler(@handler_ASKPASSWORD),
   332 const handlers: array[TCmdType] of PHandler = (PHandler(@handler_ADD_TEAM),
       
   333     PHandler(@handler_ADD_TEAM_s), PHandler(@handler_ASKPASSWORD),
   265     PHandler(@handler_BANLIST), PHandler(@handler_BANLIST_s),
   334     PHandler(@handler_BANLIST), PHandler(@handler_BANLIST_s),
   266     PHandler(@handler_BYE), PHandler(@handler_CHAT),
   335     PHandler(@handler_BYE), PHandler(@handler_CFG_AMMO),
       
   336     PHandler(@handler_CFG_DRAWNMAP), PHandler(@handler_CFG_FEATURE_SIZE),
       
   337     PHandler(@handler_CFG_FULLMAPCONFIG), PHandler(@handler_CFG_FULLMAPCONFIG_s),
       
   338     PHandler(@handler_CFG_MAP), PHandler(@handler_CFG_MAPGEN),
       
   339     PHandler(@handler_CFG_MAZE_SIZE), PHandler(@handler_CFG_SCHEME),
       
   340     PHandler(@handler_CFG_SCHEME_s), PHandler(@handler_CFG_SCRIPT),
       
   341     PHandler(@handler_CFG_SEED), PHandler(@handler_CFG_TEMPLATE),
       
   342     PHandler(@handler_CFG_THEME), PHandler(@handler_CHAT),
   267     PHandler(@handler_CLIENT_FLAGS), PHandler(@handler_CLIENT_FLAGS_s),
   343     PHandler(@handler_CLIENT_FLAGS), PHandler(@handler_CLIENT_FLAGS_s),
   268     PHandler(@handler_CONNECTED), PHandler(@handler_EM), PHandler(@handler_EM_s),
   344     PHandler(@handler_CONNECTED), PHandler(@handler_EM), PHandler(@handler_EM_s),
   269     PHandler(@handler_ERROR), PHandler(@handler_HH_NUM),
   345     PHandler(@handler_ERROR), PHandler(@handler_HH_NUM),
   270     PHandler(@handler_HH_NUM_s), PHandler(@handler_INFO), PHandler(@handler_INFO_s),
   346     PHandler(@handler_HH_NUM_s), PHandler(@handler_INFO), PHandler(@handler_INFO_s),
   271     PHandler(@handler_JOINED), PHandler(@handler_JOINED_s),
   347     PHandler(@handler_JOINED), PHandler(@handler_JOINED_s),
   272     PHandler(@handler_JOINING), PHandler(@handler_KICKED), PHandler(@handler_LEFT),
   348     PHandler(@handler_JOINING), PHandler(@handler_KICKED), PHandler(@handler_LEFT),
   273     PHandler(@handler_LEFT_s), PHandler(@handler_LOBBY_JOINED),
   349     PHandler(@handler_LEFT_s), PHandler(@handler_LOBBY_JOINED),
   274     PHandler(@handler_LOBBY_JOINED_s), PHandler(@handler_LOBBY_LEFT),
   350     PHandler(@handler_LOBBY_JOINED_s), PHandler(@handler_LOBBY_LEFT),
   275     PHandler(@handler_NICK), PHandler(@handler_NOTICE), PHandler(@handler_PING),
   351     PHandler(@handler_NICK), PHandler(@handler_NOTICE), PHandler(@handler_PING),
   276     PHandler(@handler_PING_s), PHandler(@handler_PROTO), PHandler(@handler_ROOMS),
   352     PHandler(@handler_PING_s), PHandler(@handler_PROTO),
       
   353     PHandler(@handler_REMOVE_TEAM), PHandler(@handler_ROOMS),
   277     PHandler(@handler_ROOMS_s), PHandler(@handler_ROOM_ADD),
   354     PHandler(@handler_ROOMS_s), PHandler(@handler_ROOM_ADD),
   278     PHandler(@handler_ROOM_ADD_s), PHandler(@handler_ROOM_DEL),
   355     PHandler(@handler_ROOM_ADD_s), PHandler(@handler_ROOM_DEL),
   279     PHandler(@handler_ROOM_UPD), PHandler(@handler_ROOM_UPD_s),
   356     PHandler(@handler_ROOM_UPD), PHandler(@handler_ROOM_UPD_s),
   280     PHandler(@handler_ROUND_FINISHED), PHandler(@handler_RUN_GAME),
   357     PHandler(@handler_ROUND_FINISHED), PHandler(@handler_RUN_GAME),
   281     PHandler(@handler_SERVER_AUTH), PHandler(@handler_SERVER_MESSAGE),
   358     PHandler(@handler_SERVER_AUTH), PHandler(@handler_SERVER_MESSAGE),