Difference between revisions of "Network protocol (Worms 2)"
From Worms Knowledge Base
(→Nation / Flag: List them as displayed when hovering players, including the political incorrectness) |
m (→Packet format: Wording) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
! width="170px" | Name !! IP address !! Port !! Notes | ! width="170px" | Name !! IP address !! Port !! Notes | ||
|- | |- | ||
− | | Worms2 Server (UK) || uk1.servers.worms2.com || 17000 || "The Team17 Server". Started | + | | Worms2 Server (UK) || uk1.servers.worms2.com || 17000 || "The Team17 Server". Started rejecting new connections with "Unable to create new player..." in July 2020 after Worms enthusiasts played on it (it is unclear whether the renewed activity downed it as it did not immediately break). Offline since at least May 2024, timing out with "Unable to connect to the specified server" on connection attempts. |
|- | |- | ||
− | | 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. | + | | 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. A UK-flag "test" room seems to no longer unlist but can be used to play in. |
|} | |} | ||
Line 41: | Line 41: | ||
| ? || uint32 || 4 || Data Length || If bit 5 is set in '''Flags'''. | | ? || uint32 || 4 || Data Length || If bit 5 is set in '''Flags'''. | ||
|- | |- | ||
− | | ? || char[DataLength] || Data Length || Data || If bit | + | | ? || char[DataLength] || Data Length || Data || If bit 6 is set in '''Flags''' (and implicitly bit 5 and non-zero Data Length), stores a 0-terminated Windows 1251-encoded text (like an IP string or full chat message). The terminator is included in Data Length. |
|- | |- | ||
| ? || 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. | | ? || 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. | ||
Line 209: | Line 209: | ||
* Query: A client query to execute an action on the server, always getting a reply (even codes only). | * 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). | * 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 | + | * Notice: Same as query, but sent by the server 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. | 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. |
Latest revision as of 20:26, 16 May 2024
The Worms 2 servers host rooms in which users can meet to then connect to each other's PCs for playing games.
Contents
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 rejecting new connections with "Unable to create new player..." in July 2020 after Worms enthusiasts played on it (it is unclear whether the renewed activity downed it as it did not immediately break). Offline since at least May 2024, timing out with "Unable to connect to the specified server" on connection attempts. |
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. A UK-flag "test" room seems to no longer unlist but can be used to play in. |
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 6 is set in Flags (and implicitly bit 5 and non-zero Data Length), stores a 0-terminated Windows 1251-encoded text (like an IP string or full chat message). The terminator is included in Data Length. |
? | 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. Below, the flags are listed with the description displayed when hovering players.
Value | Description | Notes |
---|---|---|
1 | United Kingdom | |
2 | Argentina | |
3 | Australia | |
4 | Austria | |
5 | Belgium | |
6 | Brazil | |
7 | Canada | |
8 | Croatia | |
9 | Bosnia | old flag of Bosnia and Herzegovina |
10 | Cyprus | |
11 | Czech | |
12 | Denmark | |
13 | Finland | |
14 | France | |
15 | Georgia | |
16 | Germany | |
17 | Greece | |
18 | Hong Kong | |
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 | Puertorico | |
41 | Romania | |
42 | Russia | |
43 | Singapore | |
44 | South Africa | |
45 | Spain | |
46 | Sweden | |
47 | Switzerland | |
48 | Turkey | |
49 | United States of America | |
50 | Iraq | Skull flag |
51 | Worms2 Imperial Troopers | Team17 flag |
other | Unknown | French flag for players, question mark for rooms |
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 labeled "Worms 2", "WORMS2", or - for Trymedia 1.07 versions - "Worms2_bl". (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 sent by the server 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] | 0 | RID | 0x800 | host IP | host | |||
1200 | Create Game | Notice | GID | RID | 0x800 | 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.0 1.1 Only ever sent as a notice by the server, clients disconnect without any query and awaited reply.
- ↑ 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.
- ↑ 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
- Selected sample logs
- Worms 2 Game Server, cross-platform server implementing the above protocol.