hedgewars/uFLNetProtocol.pas
author unc0rr
Sun, 20 Dec 2015 12:45:49 +0300
branchqmlfrontend
changeset 11460 9f2fb0031ef0
parent 11454 3c5d99013baf
child 11462 33a0e3a14ddc
permissions -rw-r--r--
Fix two bugs, and yay, spectating works now
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
     6
procedure sendChatLine(msg: PChar); cdecl;
11423
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
     7
procedure joinRoom(roomName: PChar); cdecl;
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
     8
procedure partRoom(msg: PChar); cdecl;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
     9
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    10
procedure ResetNetState;
11416
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
    11
10951
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
    12
implementation
11454
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
    13
uses uFLNetTypes, uFLTypes, uFLUICallback, uFLNet, uFLGameConfig, uFLUtils, uFLIPC, uUtils;
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
    14
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
    15
type
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
    16
    PHandler = procedure (var t: TCmdData);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
    17
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    18
var isInRoom: boolean;
11430
f88b3948adf3 UI knowns local player nickname
unc0rr
parents: 11429
diff changeset
    19
    myNickname: shortstring;
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    20
11443
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
    21
procedure onRoomLeaving();
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
    22
begin
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
    23
    isInRoom:= false;
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
    24
    sendUI(mtMoveToLobby, nil, 0);
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
    25
    netResetTeams
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
    26
end;
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
    27
11442
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    28
var teamIndex: LongInt;
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    29
    tmpTeam: TTeam;
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    30
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    31
const teamFields: array[0..22] of PShortstring = (
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    32
    @tmpTeam.teamName
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    33
    , @tmpTeam.grave
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    34
    , @tmpTeam.fort
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    35
    , @tmpTeam.voice
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    36
    , @tmpTeam.flag
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    37
    , @tmpTeam.owner
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    38
    , nil
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    39
    , @tmpTeam.hedgehogs[0].name
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    40
    , @tmpTeam.hedgehogs[0].hat
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    41
    , @tmpTeam.hedgehogs[1].name
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    42
    , @tmpTeam.hedgehogs[1].hat
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    43
    , @tmpTeam.hedgehogs[2].name
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    44
    , @tmpTeam.hedgehogs[2].hat
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    45
    , @tmpTeam.hedgehogs[3].name
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    46
    , @tmpTeam.hedgehogs[3].hat
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    47
    , @tmpTeam.hedgehogs[4].name
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    48
    , @tmpTeam.hedgehogs[4].hat
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    49
    , @tmpTeam.hedgehogs[5].name
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    50
    , @tmpTeam.hedgehogs[5].hat
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    51
    , @tmpTeam.hedgehogs[6].name
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    52
    , @tmpTeam.hedgehogs[6].hat
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    53
    , @tmpTeam.hedgehogs[7].name
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    54
    , @tmpTeam.hedgehogs[7].hat
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    55
    );
11454
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
    56
11430
f88b3948adf3 UI knowns local player nickname
unc0rr
parents: 11429
diff changeset
    57
procedure handler_ADD_TEAM(var p: TCmdParam);
11429
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
    58
begin
11442
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    59
    teamIndex:= 0;
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    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
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    65
    if teamIndex = 6 then
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    66
        tmpTeam.botLevel:= strToInt(s.str1)
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    67
    else if teamIndex < 23 then
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    68
        teamFields[teamIndex]^:= s.str1;
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    69
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    70
    if teamIndex = 22 then
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    71
        netAddTeam(tmpTeam);
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    72
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
    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
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    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
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 11413
diff changeset
    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
6e641b5453f9 Accept ammo scheme from network
unc0rr
parents: 11436
diff changeset
    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
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   104
    if isInRoom then
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   105
    begin
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   106
        netSetFeatureSize(p.param1);
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   107
        updatePreviewIfNeeded
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   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
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   111
var fmcfgIndex: integer;
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   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
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   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
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   120
    if not isInRoom then exit;
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   121
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   122
    inc(fmcfgIndex);
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   123
    case fmcfgIndex of
11436
f7fa429e42ab Fix FULLMAPCONFIG handling
unc0rr
parents: 11434
diff changeset
   124
        1: netSetFeatureSize(strToInt(s.str1));
f7fa429e42ab Fix FULLMAPCONFIG handling
unc0rr
parents: 11434
diff changeset
   125
        2: if s.str1[0] <> '+' then netSetMap(s.str1);
f7fa429e42ab Fix FULLMAPCONFIG handling
unc0rr
parents: 11434
diff changeset
   126
        3: netSetMapGen(strToInt(s.str1));
f7fa429e42ab Fix FULLMAPCONFIG handling
unc0rr
parents: 11434
diff changeset
   127
        4: netSetMazeSize(strToInt(s.str1));
f7fa429e42ab Fix FULLMAPCONFIG handling
unc0rr
parents: 11434
diff changeset
   128
        5: netSetSeed(s.str1);
11433
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   129
        6: begin
11436
f7fa429e42ab Fix FULLMAPCONFIG handling
unc0rr
parents: 11434
diff changeset
   130
                netSetTemplate(strToInt(s.str1));
11433
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   131
                updatePreviewIfNeeded;
11436
f7fa429e42ab Fix FULLMAPCONFIG handling
unc0rr
parents: 11434
diff changeset
   132
            end;
11433
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   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
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   138
    if isInRoom then
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   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
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   144
    if isInRoom then
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   145
    begin
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   146
        netSetMapGen(p.param1);
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   147
        updatePreviewIfNeeded
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   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
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   153
    if isInRoom then
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   154
    begin
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   155
        netSetMazeSize(p.param1);
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   156
        updatePreviewIfNeeded
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   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
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   160
var schemeIndex: LongInt;
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   161
    tmpScheme: TScheme;
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   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
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   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
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   168
const schemeFields: array[0..43] of pointer = (
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   169
      @tmpScheme.schemeName          //  0
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   170
    , @tmpScheme.fortsmode           //  1
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   171
    , @tmpScheme.divteams            //  2
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   172
    , @tmpScheme.solidland           //  3
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   173
    , @tmpScheme.border              //  4
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   174
    , @tmpScheme.lowgrav             //  5
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   175
    , @tmpScheme.laser               //  6
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   176
    , @tmpScheme.invulnerability     //  7
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   177
    , @tmpScheme.resethealth         //  8
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   178
    , @tmpScheme.vampiric            //  9
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   179
    , @tmpScheme.karma               // 10
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   180
    , @tmpScheme.artillery           // 11
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   181
    , @tmpScheme.randomorder         // 12
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   182
    , @tmpScheme.king                // 13
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   183
    , @tmpScheme.placehog            // 14
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   184
    , @tmpScheme.sharedammo          // 15
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   185
    , @tmpScheme.disablegirders      // 16
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   186
    , @tmpScheme.disablelandobjects  // 17
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   187
    , @tmpScheme.aisurvival          // 18
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   188
    , @tmpScheme.infattack           // 19
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   189
    , @tmpScheme.resetweps           // 20
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   190
    , @tmpScheme.perhogammo          // 21
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   191
    , @tmpScheme.disablewind         // 22
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   192
    , @tmpScheme.morewind            // 23
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   193
    , @tmpScheme.tagteam             // 24
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   194
    , @tmpScheme.bottomborder        // 25
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   195
    , @tmpScheme.damagefactor        // 26
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   196
    , @tmpScheme.turntime            // 27
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   197
    , @tmpScheme.health              // 28
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   198
    , @tmpScheme.suddendeath         // 29
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   199
    , @tmpScheme.caseprobability     // 30
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   200
    , @tmpScheme.minestime           // 31
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   201
    , @tmpScheme.minesnum            // 32
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   202
    , @tmpScheme.minedudpct          // 33
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   203
    , @tmpScheme.explosives          // 34
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   204
    , @tmpScheme.airmines            // 35
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   205
    , @tmpScheme.healthprobability   // 36
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   206
    , @tmpScheme.healthcaseamount    // 37
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   207
    , @tmpScheme.waterrise           // 38
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   208
    , @tmpScheme.healthdecrease      // 39
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   209
    , @tmpScheme.ropepct             // 40
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   210
    , @tmpScheme.getawaytime         // 41
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   211
    , @tmpScheme.worldedge           // 42
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   212
    , @tmpScheme.scriptparam         // 43
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   213
   );
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   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
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   217
    if(schemeIndex = 0) then
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   218
        tmpScheme.schemeName:= s.str1
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   219
    else
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   220
    if(schemeIndex = 43) then
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   221
        tmpScheme.scriptparam:= copy(s.str1, 2, length(s.str1) - 1)
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   222
    else
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   223
    if(schemeIndex < 26) then
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   224
        PBoolean(schemeFields[schemeIndex])^:= s.str1[1] = 't'
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   225
    else
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   226
    if(schemeIndex < 43) then
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   227
        PLongInt(schemeFields[schemeIndex])^:= strToInt(s.str1);
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   228
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   229
    if(schemeIndex = 43) then
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   230
        netSetScheme(tmpScheme);
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   231
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
   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
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
   237
    if isInRoom then
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
   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
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
   243
    if isInRoom then
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
   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
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   249
    if isInRoom then
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   250
    begin
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   251
        netSetTemplate(p.param1);
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   252
        updatePreviewIfNeeded
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
   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
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
   258
    if isInRoom then
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
   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
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 11413
diff changeset
   263
var s: string;
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   264
begin
11415
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 11413
diff changeset
   265
    s:= p.str1 + #10 + p.str2;
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   266
    if isInRoom then
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   267
        sendUI(mtRoomChatLine, @s[1], length(s))
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   268
    else
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   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
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   272
var flags: array[TClientFlag] of LongInt;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   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
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   275
var f: TClientFlag;
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   276
begin
11449
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   277
    for f:= Low(TClientFlag) to High(TClientFlag) do
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   278
        flags[f]:= 0;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   279
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   280
    isFlagsLine:= true;
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   281
end;
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   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
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   284
var isRemoval: boolean;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   285
    flagValue, i: LongInt;
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   286
begin
11449
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   287
    if isFlagsLine then
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   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
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   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
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   292
                'r': flags[cfReady]:= flagValue;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   293
                'u': flags[cfRegistered]:= flagValue;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   294
                'i': flags[cfInRoom]:= flagValue;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   295
                'c': flags[cfContributor]:= flagValue;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   296
                'g': flags[cfInGame]:= flagValue;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   297
                'h': flags[cfRoomAdmin]:= flagValue;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   298
                'a': flags[cfServerAdmin]:= flagValue;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   299
            end;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   300
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   301
        isFlagsLine:= false;
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   302
    end else
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   303
    begin
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   304
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   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
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 11413
diff changeset
   310
    sendUI(mtConnected, nil, 0);
11449
2bf0491d5e88 Client flags handling implementation start
unc0rr
parents: 11444
diff changeset
   311
    //writeln('Server features version ', p.param1);
11415
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 11413
diff changeset
   312
    sendNet('PROTO' + #10 + '51');
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 11413
diff changeset
   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
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   319
11454
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   320
procedure handler_EM_s(var p: TCmdParamL);
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   321
var i, l: Longword;
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   322
    s: shortstring;
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   323
begin
11454
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   324
    i:= 1;
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   325
    l:= length(p.str1);
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   326
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   327
    while i < l do
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   328
    begin
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   329
        s:= DecodeBase64(copy(p.str1, i, 240));
11460
9f2fb0031ef0 Fix two bugs, and yay, spectating works now
unc0rr
parents: 11454
diff changeset
   330
        ipcToEngineRaw(@s[1], byte(s[0]));
11454
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   331
        inc(i, 160)
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   332
    end;
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   333
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   334
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   335
procedure handler_ERROR(var p: TCmdParamL);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   336
begin
11423
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   337
    sendUI(mtError, @p.str1[1], length(p.str1));
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   338
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   339
11442
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
   340
procedure handler_HH_NUM(var p: TCmdParamSS);
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   341
begin
11443
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
   342
    netSetHedgehogsNumber(p.str1, StrToInt(p.str2))
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   343
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   344
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   345
procedure handler_INFO(var p: TCmdParam);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   346
begin
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   347
end;
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   348
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   349
procedure handler_INFO_s(var s: TCmdParamS);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   350
begin
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   351
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   352
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   353
procedure handler_JOINED(var p: TCmdParam);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   354
begin
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   355
end;
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   356
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   357
procedure handler_JOINED_s(var s: TCmdParamS);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   358
begin
11430
f88b3948adf3 UI knowns local player nickname
unc0rr
parents: 11429
diff changeset
   359
    if s.str1 = myNickname then // we joined a room
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   360
    begin
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   361
        isInRoom:= true;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   362
        sendUI(mtMoveToRoom, nil, 0);
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   363
    end;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   364
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   365
    sendUI(mtAddRoomClient, @s.str1[1], length(s.str1));
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   366
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   367
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   368
procedure handler_JOINING(var p: TCmdParamS);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   369
begin
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   370
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   371
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   372
procedure handler_KICKED(var p: TCmdParam);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   373
begin
11443
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
   374
    onRoomLeaving()
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   375
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   376
11441
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   377
procedure handler_LEFT(var p: TCmdParamSL);
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   378
begin
11441
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   379
    p.str2:= p.str1 + #10 + p.str2;
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   380
    sendUI(mtRemoveRoomClient, @p.str2[1], length(p.str2));
11413
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;
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   386
11413
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
11430
f88b3948adf3 UI knowns local player nickname
unc0rr
parents: 11429
diff changeset
   389
    if s.str1 = myNickname then
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   390
    begin
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   391
        sendUI(mtMoveToLobby, nil, 0);
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   392
        sendNet('LIST');
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   393
    end;
11419
8a5cc31483c6 - Handle ROOM DEL
unc0rr
parents: 11418
diff changeset
   394
11415
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 11413
diff changeset
   395
    sendUI(mtAddLobbyClient, @s.str1[1], length(s.str1));
11413
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
11423
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   400
    p.str2:= p.str1 + #10 + p.str2;
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   401
    sendUI(mtRemoveLobbyClient, @p.str2[1], length(p.str2));
11413
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
11430
f88b3948adf3 UI knowns local player nickname
unc0rr
parents: 11429
diff changeset
   406
    myNickname:= p.str1;
f88b3948adf3 UI knowns local player nickname
unc0rr
parents: 11429
diff changeset
   407
    sendUI(mtNickname, @p.str1[1], length(p.str1));
11413
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;
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   418
11413
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
11454
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
   425
    //writeln('Protocol ', p.param1)
11413
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
11429
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   428
procedure handler_REMOVE_TEAM(var p: TCmdParamS);
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   429
begin
11443
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
   430
    netRemoveTeam(p.str1)
11429
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   431
end;
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   432
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   433
var roomInfo: string;
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   434
    roomLinesCount: integer;
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   435
11429
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   436
procedure handler_ROOMS(var p: TCmdParam);
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   437
begin
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   438
    roomInfo:= '';
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   439
    roomLinesCount:= 0
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   440
end;
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   441
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   442
procedure handler_ROOMS_s(var s: TCmdParamS);
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   443
begin
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   444
    roomInfo:= roomInfo + s.str1 + #10;
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   445
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   446
    if roomLinesCount = 8 then
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   447
    begin
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   448
        sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1);
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   449
        roomLinesCount:= 0;
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   450
        roomInfo:= ''
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   451
    end else inc(roomLinesCount);
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   452
end;
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   453
11425
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   454
procedure handler_ROOM_ADD(var p: TCmdParam);
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   455
begin
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   456
    roomInfo:= '';
11425
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   457
    roomLinesCount:= 0
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   458
end;
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   459
11425
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   460
procedure handler_ROOM_ADD_s(var s: TCmdParamS);
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   461
begin
11425
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   462
    roomInfo:= roomInfo + s.str1 + #10;
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   463
    inc(roomLinesCount);
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   464
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   465
    if roomLinesCount = 9 then
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   466
    begin
11425
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   467
        sendUI(mtAddRoom, @roomInfo[1], length(roomInfo) - 1);
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   468
        roomInfo:= '';
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   469
        roomLinesCount:= 0
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   470
    end;
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_DEL(var p: 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
    sendUI(mtRemoveRoom, @p.str1[1], length(p.str1));
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   476
end;
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   477
11425
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   478
procedure handler_ROOM_UPD(var p: TCmdParam);
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   479
begin
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   480
    roomInfo:= '';
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   481
    roomLinesCount:= 0
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   482
end;
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   483
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   484
procedure handler_ROOM_UPD_s(var s: TCmdParamS);
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   485
begin
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   486
    roomInfo:= roomInfo + s.str1 + #10;
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   487
    inc(roomLinesCount);
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   488
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   489
    if roomLinesCount = 10 then
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   490
        sendUI(mtUpdateRoom, @roomInfo[1], length(roomInfo) - 1);
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   491
end;
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   492
11413
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);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   498
begin
11460
9f2fb0031ef0 Fix two bugs, and yay, spectating works now
unc0rr
parents: 11454
diff changeset
   499
    runNetGame
11413
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_SERVER_AUTH(var p: TCmdParamS);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   503
begin
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   504
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   505
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   506
procedure handler_SERVER_MESSAGE(var p: TCmdParamL);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   507
begin
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   508
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   509
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   510
procedure handler_SERVER_VARS(var p: TCmdParamSL);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   511
begin
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   512
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   513
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   514
procedure handler_TEAM_ACCEPTED(var p: TCmdParamS);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   515
begin
11444
91f8c6ff5bab - Send team to net
unc0rr
parents: 11443
diff changeset
   516
    netAcceptedTeam(p.str1)
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   517
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   518
11442
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
   519
procedure handler_TEAM_COLOR(var p: TCmdParamSS);
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   520
begin
11442
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
   521
    netSetTeamColor(p.str1, StrToInt(p.str2));
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   522
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   523
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   524
procedure handler_WARNING(var p: TCmdParamL);
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   525
begin
11423
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   526
    sendUI(mtWarning, @p.str1[1], length(p.str1));
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   527
end;
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   528
11429
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   529
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
   530
    PHandler(@handler_ADD_TEAM_s), PHandler(@handler_ASKPASSWORD),
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   531
    PHandler(@handler_BANLIST), PHandler(@handler_BANLIST_s),
11429
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   532
    PHandler(@handler_BYE), PHandler(@handler_CFG_AMMO),
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   533
    PHandler(@handler_CFG_DRAWNMAP), PHandler(@handler_CFG_FEATURE_SIZE),
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   534
    PHandler(@handler_CFG_FULLMAPCONFIG), PHandler(@handler_CFG_FULLMAPCONFIG_s),
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   535
    PHandler(@handler_CFG_MAP), PHandler(@handler_CFG_MAPGEN),
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   536
    PHandler(@handler_CFG_MAZE_SIZE), PHandler(@handler_CFG_SCHEME),
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   537
    PHandler(@handler_CFG_SCHEME_s), PHandler(@handler_CFG_SCRIPT),
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   538
    PHandler(@handler_CFG_SEED), PHandler(@handler_CFG_TEMPLATE),
d96a37de1076 Apply generated code to .pas files, fix FULLMAPCONFIG handling
unc0rr
parents: 11425
diff changeset
   539
    PHandler(@handler_CFG_THEME), PHandler(@handler_CHAT),
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   540
    PHandler(@handler_CLIENT_FLAGS), PHandler(@handler_CLIENT_FLAGS_s),
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   541
    PHandler(@handler_CONNECTED), PHandler(@handler_EM), PHandler(@handler_EM_s),
11442
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
   542
    PHandler(@handler_ERROR), PHandler(@handler_HH_NUM), PHandler(@handler_INFO),
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
   543
    PHandler(@handler_INFO_s), PHandler(@handler_JOINED),
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
   544
    PHandler(@handler_JOINED_s), PHandler(@handler_JOINING),
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
   545
    PHandler(@handler_KICKED), PHandler(@handler_LEFT),
11441
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   546
    PHandler(@handler_LOBBY_JOINED), PHandler(@handler_LOBBY_JOINED_s),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   547
    PHandler(@handler_LOBBY_LEFT), PHandler(@handler_NICK),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   548
    PHandler(@handler_NOTICE), PHandler(@handler_PING), PHandler(@handler_PING_s),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   549
    PHandler(@handler_PROTO), PHandler(@handler_REMOVE_TEAM),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   550
    PHandler(@handler_ROOMS), PHandler(@handler_ROOMS_s),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   551
    PHandler(@handler_ROOM_ADD), PHandler(@handler_ROOM_ADD_s),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   552
    PHandler(@handler_ROOM_DEL), PHandler(@handler_ROOM_UPD),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   553
    PHandler(@handler_ROOM_UPD_s), PHandler(@handler_ROUND_FINISHED),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   554
    PHandler(@handler_RUN_GAME), PHandler(@handler_SERVER_AUTH),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   555
    PHandler(@handler_SERVER_MESSAGE), PHandler(@handler_SERVER_VARS),
908aed8525f9 Fix LEFT command handling
unc0rr
parents: 11440
diff changeset
   556
    PHandler(@handler_TEAM_ACCEPTED), PHandler(@handler_TEAM_COLOR),
11442
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11441
diff changeset
   557
    PHandler(@handler_WARNING));
10951
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
   558
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
   559
procedure passNetData(p: pointer); cdecl;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
   560
begin
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   561
    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
   562
end;
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
   563
11416
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
   564
procedure sendChatLine(msg: PChar); cdecl;
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
   565
begin
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
   566
    sendNetLn('CHAT');
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
   567
    sendNet(msg);
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
   568
end;
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
   569
11423
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   570
procedure joinRoom(roomName: PChar); cdecl;
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   571
begin
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   572
    sendNetLn('JOIN_ROOM');
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   573
    sendNet(roomName);
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   574
end;
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11420
diff changeset
   575
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   576
procedure partRoom(msg: PChar); cdecl;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   577
var s: string;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   578
begin
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   579
    if isInRoom then
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   580
    begin
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   581
        s:= 'PART';
11425
2947f06e8533 Another approach to parsing two-lines protocol commands
unc0rr
parents: 11424
diff changeset
   582
        if length(msg) > 0 then
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   583
            s:= s + #10 + msg;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   584
        sendNet(s);
11443
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
   585
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11442
diff changeset
   586
        onRoomLeaving()
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   587
    end
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   588
end;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   589
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   590
procedure ResetNetState;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   591
begin
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   592
    isInRoom:= false;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   593
end;
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
   594
10951
89a7f617e091 - Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff changeset
   595
end.
11413
ffff8a0d1a76 Implement processing net commands in the main thread
unc0rr
parents: 10953
diff changeset
   596