Difference between revisions of "Network protocol (Worms 2)"

From Worms Knowledge Base

Jump to: navigation, search
(Packet contents: Note about bogus client behavior when IDs are too small)
(Packet contents: List Users / Games sends RID, not UID, Leave / Close Room is also used for games)
Line 226: Line 226:
 
| 351 || List End || Reply || || || || || || || ||
 
| 351 || List End || Reply || || || || || || || ||
 
|- style="background:#FFFFCD"
 
|- style="background:#FFFFCD"
| 400 || List Users || Query || || || UID || || 0 || || ||
+
| 400 || List Users || Query || || || RID || || 0 || || ||
 
|- style="background:#FFFFCD"
 
|- style="background:#FFFFCD"
| 500 || List Games || Query || || || UID || || 0 || || ||
+
| 500 || List Games || Query || || || RID || || 0 || || ||
 
|- style="background:#FFE6CD"
 
|- style="background:#FFE6CD"
 
| 600 || Login || Query || || 0 || || || 0 || || || local user
 
| 600 || Login || Query || || 0 || || || 0 || || || local user
Line 248: Line 248:
 
| 801 || Join Room / Game || Reply || || || || || || || ||
 
| 801 || Join Room / Game || Reply || || || || || || || ||
 
|- style="background:#EFCDFF"
 
|- style="background:#EFCDFF"
| 900 || Leave Room || Query || || || left RID || || || local UID || ||
+
| 900 || Leave Room / Game || Query || || || left RID / GID || || || local UID || ||
 
|- style="background:#EFCDFF"
 
|- style="background:#EFCDFF"
| 900 || Leave Room || Notice || || || left RID || || || remote UID || ||
+
| 900 || Leave Room / Game || Notice || || || left RID / GID || || || remote UID || ||
 
|- style="background:#EFCDFF"
 
|- style="background:#EFCDFF"
| 901 || Leave Room || Reply || || || || || || || ||
+
| 901 || Leave Room / Game || Reply || || || || || || || ||
 
|- style="background:#CDCDFF"
 
|- style="background:#CDCDFF"
 
| 1000 || Disconnect User || Query<ref name=NotUsed>Only ever sent as a notice by the server, clients disconnect without any query and awaited reply.</ref> || || || || || || local UID || ||
 
| 1000 || Disconnect User || Query<ref name=NotUsed>Only ever sent as a notice by the server, clients disconnect without any query and awaited reply.</ref> || || || || || || local UID || ||
Line 260: Line 260:
 
| 1001 || Disconnect User || Reply<ref name=NotUsed/> || || || || || || || ||
 
| 1001 || Disconnect User || Reply<ref name=NotUsed/> || || || || || || || ||
 
|- style="background:#CDD6FF"
 
|- style="background:#CDD6FF"
| 1100 || Close Room || Query || || || || || || RID || ||
+
| 1100 || Close Room / Game || Query || || || || || || RID / GID || ||
 
|- style="background:#CDD6FF"
 
|- style="background:#CDD6FF"
| 1100 || Close Room || Notice || || || || || || RID || ||
+
| 1100 || Close Room / Game || Notice || || || || || || RID / GID || ||
 
|- style="background:#CDD6FF"
 
|- style="background:#CDD6FF"
| 1101 || Close Room || Reply || || || || || || || ||
+
| 1101 || Close Room / Game || Reply || || || || || || || ||
 
|- style="background:#CDEFFF"
 
|- style="background:#CDEFFF"
 
| 1200 || Create Game || Query<ref name=BadIP>Since the host reports its incorrectly detected NAT IP here, [[Worms 2 Memory Changer]] has to be used to inject the actual IP address into Worms 2 before creating a room.</ref> || || || RID || || GID? || || host IP || host
 
| 1200 || Create Game || Query<ref name=BadIP>Since the host reports its incorrectly detected NAT IP here, [[Worms 2 Memory Changer]] has to be used to inject the actual IP address into Worms 2 before creating a room.</ref> || || || RID || || GID? || || host IP || host

Revision as of 18:19, 10 July 2020

(Up to Game logic)

The Worms 2 servers host rooms in which users can meet to then connect to each other's PCs for playing games.

Official servers

The following servers are hosted by Team17:

Name IP address Port Notes
Worms2 Server (UK) uk1.servers.worms2.com 17000 "The Team17 Server". Started to reject new connections in July 2020, shortly after some Worms enthusiasts played on it. Unclear whether the sudden activity downed it, it did not immediately break. The client will display "Unable to create new player..." when attempting to connect to it.
Worms2 Demo Server (UK) uk1.servers.worms2.com 17171 Server for Worms 2 demo. Allows full versions to connect aswell. Did not go down in July 2020.

Server communication

The server hosting the user, room, and game lists communicates with packets in the following format:

Packet format

Offset Type Size Name Description
0 uint32 4 Code Determines the type of packet. Known packets are listed below.
4 uint32 4 Flags A bitset determining which of the following fields will be available.
 ? uint32 4 Value 0 If bit 0 is set in Flags.
 ? uint32 4 Value 1 If bit 1 is set in Flags.
 ? uint32 4 Value 2 If bit 2 is set in Flags.
 ? uint32 4 Value 3 If bit 3 is set in Flags.
 ? uint32 4 Value 4 If bit 4 is set in Flags. Never used other than client-side?
 ? uint32 4 Value 10 If bit 10 is set in Flags.
 ? uint32 4 Data Length If bit 5 is set in Flags.
 ? char[DataLength] Data Length Data If bit 5 is set in Flags, stores Windows-1251 encoded text like an IP string or full chat message.
 ? uint32 4 Error If bit 7 is set in Flags. Returns a Windows error code from the server, like E_FAIL for when the name of a room to create contains a bad word.
 ? char[20] 20 Name If bit 8 is set in Flags, stores a Windows-1251 encoded session name. Unused bytes are 0.
 ? Session info 50 Session If bit 9 is set in Flags. Unused bytes are 0.

Session info

Several packets identify a user, room, or game with the Name and Session fields. The latter provides the following information:

Offset Type Size Value
0 uint32 4 Always 0x17171717
4 uint32 4 Always 0x02010101
8 uint8 1 Nation / Flag
9 uint8 1 Game version, always 49
10 uint8 1 Game release (same as Game version, 50 if CD check failed)
11 uint8 1 Type (1=room, 4=game, 5=user)
12 uint8 1 Access (1=public, 2=protected)
13 uint8 1 Always 1
14 uint8 1 Always 0
15 gap 35 Unused, all 0.

Passing other or invalid combinations (protected users and rooms do not exist, only passworded games) will display a French flag with the default state or a question mark in the UI.

The Worms 2 1.0.1.1 Demo uses significantly different values compared to the full version 1.0.1.5 patch, causing said question marks to appear. However, interactions with full version users still work.

Nation / Flag

Determines which flag is displayed with the user, room, or game. Two flags are custom (Skull and Team17) and are not normally selectable. Des patch can unlock the selection of them, and adds another entry for an "invalid" country code, creating an empty flag.

Value Flag
1 United Kingdom
2 Argentinia
3 Australia
4 Austria
5 Beglium
6 Brazil
7 Canada
8 Croatia
9 Bosnia and Herzegovina (old flag)
10 Cyprus
11 Czech Republic
12 Denmark
13 Finland
14 France
15 Georgia
16 Germany
17 Greece
18 Hong Kong SAR
19 Hungary
20 Iceland
21 India
22 Indonesia
23 Iran
24 Iraq
25 Ireland
26 Israel
27 Italy
28 Japan
29 Liechtenstein
30 Luxembourg
31 Malaysia
32 Malta
33 Mexico
34 Morocco
35 Netherlands
36 New Zealand
37 Norway
38 Poland
39 Portugal
40 Puerto Rico
41 Romania
42 Russian Federation
43 Singapore
44 South Africa
45 Spain
46 Sweden
47 Switzerland
48 Turkey
49 United States
50 Skull image
51 Team17 logo
Game release

Becomes 50 if CD detection failed. The CD detection consists of the following tests:

  • Find CD drive, where drives A: and B: are ignored - a found drive letter is stored in the registry under HKCU\SOFTWARE\Team17SoftwareLTD\Worms2\CD. (error 2 otherwise)
  • Check the CD being "Worms 2" or "WORMS2". (error 1 otherwise)
  • Check if the CD has no free space to ensure it being a CD-ROM. (error 3 otherwise)
  • Check if the CD stores an "autorun.inf" file. (error 4 otherwise)

Packet contents

As specified above, the Code of a packet determines the Action to take on either the server or client side and in effect which fields are used. Some codes are reused for multiple occassions, and some are unused in the 1.0.1.5 patch.

Client query packets are also used for server notices, represented by the Type column in the following table:

  • Query: A client query to execute an action on the server, always getting a reply (even codes only).
  • Reply: A server reply to a client query, always reporting back an Error code, 0 for success (odd codes only).
  • Notice: Same as query, but coming as an out-of-bound server packet to update the state on the client, like when another user joins or creates a game.

Note that the same ID counter is incremented for users (UID), rooms (RID), and games (GID) - if a user logs in with UID 0x1000 and immediately creates a room, the RID will be 0x1001. The counter should also start at a high enough value (0x1000 seems to work fine) to not cause duplicate chat messages appearing client-side, apparently because it is also reused as an index in some packets.

Code Action Type Value 0 Value 1 Value 2 Value 3 Value 4 Value 10 Data Name / Session
50 not used Query  ?
51 not used Reply  ?
200 List Rooms Query 0
300 not used Query 0
350 List Item Reply UID / RID / GID user / creator / host IP user / room / game
351 List End Reply
400 List Users Query RID 0
500 List Games Query RID 0
600 Login Query 0 0 local user
600 Login Notice remote UID 0 remote user
601 Login Reply local UID
700 Create Room Query 0 0 creator IP room
700 Create Room Notice new RID 0 creator IP room
701 Create Room Reply new RID
800 Join Room / Game Query joined RID / GID local UID
800 Join Room / Game Notice joined RID / GID remote UID
801 Join Room / Game Reply
900 Leave Room / Game Query left RID / GID local UID
900 Leave Room / Game Notice left RID / GID remote UID
901 Leave Room / Game Reply
1000 Disconnect User Query[1] local UID
1000 Disconnect User Notice remote UID
1001 Disconnect User Reply[1]
1100 Close Room / Game Query RID / GID
1100 Close Room / Game Notice RID / GID
1101 Close Room / Game Reply
1200 Create Game Query[2] RID GID? host IP host
1200 Create Game Notice RID GID? host IP host
1201 Create Game Reply GID
1300 Room Chat Query local UID receiver RID / UID "GRP:[ UserName ]  Message" / "PRV:[ UserName ]  Message"
1300 Room Chat Notice remote UID receiver RID / UID "GRP:[ UserName ]  Message" / "PRV:[ UserName ]  Message"
1301 Room Chat Reply[3]
1320 not used Query  ?  ?
1321 not used Reply
1322 not used Query  ?  ?
1323 not used Reply
1324 not used Query  ?
1325 not used Reply  ?
1326 Connect Game Query GID
1327 Connect Game Reply host IP
  1. 1.0 1.1 Only ever sent as a notice by the server, clients disconnect without any query and awaited reply.
  2. Since the host reports its incorrectly detected NAT IP here, Worms 2 Memory Changer has to be used to inject the actual IP address into Worms 2 before creating a room.
  3. Original server always reports E_FAIL in error code, even though messages were sent.

Game room communication

The players are connected via P2P using DirectPlay. This means the ports 47624 (for the lobby connection itself) and 2300 to 2400 (for each player connection) should be forwarded in any router. The fact that each player is connected to another means that the host can leave the game at any time, the remaining players can continue playing without dropping, unlike in Worms Armageddon or Worms World Party.

See also

Personal tools