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

From Worms Knowledge Base

Jump to: navigation, search
(Create page, moved from my user page.)
 
m (Packet format: Wording)
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{ParentArticle|[[Game logic]]}}
 
The Worms 2 servers host rooms in which users can meet to then connect to each other's PCs for playing games.
 
The Worms 2 servers host rooms in which users can meet to then connect to each other's PCs for playing games.
  
Line 8: 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 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 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.
 
|}
 
|}
  
 
== Server communication ==
 
== Server communication ==
  
The server hosting the user, room, and game lists (referred to as "sessions" in the following) communicates with packets in the following format:
+
The server hosting the user, room, and game lists communicates with packets in the following format:
  
 
=== Packet format ===
 
=== Packet format ===
Line 22: Line 23:
 
! Offset !! Type !! Size !! Name !! Description
 
! Offset !! Type !! Size !! Name !! Description
 
|-
 
|-
| 0 || uint32 || 4 || Code || Determines the type of packet. Known values are listed below.
+
| 0 || uint32 || 4 || Code || Determines the type of packet. Known packets are listed [[#Packet contents|below]].
 
|-
 
|-
| 4 || uint32 || 4 || Flags || A bitset determining which data will be available in the following.
+
| 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 0 || If bit 0 is set in '''Flags'''.
Line 40: Line 41:
 
| ? || uint32 || 4 || Data Length || If bit 5 is set in '''Flags'''.
 
| ? || uint32 || 4 || Data Length || If bit 5 is set in '''Flags'''.
 
|-
 
|-
| ? || uint8[DataLength] || Data Length || Data || If bit 5 is set in '''Flags''' and '''Data Length''' is not 0.
+
| ? || 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.
 
|-
 
|-
| ? || char[20] || 20 || Name || If bit 8 is set in '''Flags'''. Returns a session name. Unused bytes are 0.
+
| ? || char[20] || 20 || Name || If bit 8 is set in '''Flags''', stores a Windows-1251 encoded session name. Unused bytes are 0.
 
|-
 
|-
| ? || uint8[50] || 50 || [[#Session info|Session info]] || If bit 9 is set in '''Flags'''. Unused bytes are 0.
+
| ? || [[#Session info|Session info]] || 50 || Session || If bit 9 is set in '''Flags'''. Unused bytes are 0.
 
|}
 
|}
  
=== Packet contents ===
+
==== Session info ====
  
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.
+
Several packets identify a user, room, or game with the '''Name''' and '''Session''' fields. The latter provides the following information:
 
+
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.
+
 
+
It should be noted that the same ID counter is incremented for users (UID), rooms (RID), and games (GID). If a user logs in with UID 3 and immediately creates a room, the RID will be 4.
+
 
+
{| class="wikitable sortable"
+
! Code !! Action !! Type !! Value 0 !! Value 1 !! Value 2 !! Value 3 !! Value 4 !! Value 10 !! Data !! Name / Session
+
|- style="background:#FFF"
+
| 50 || ''not used'' || Query || || || || || ? || || ||
+
|- style="background:#FFF"
+
| 51 || ''not used'' || Reply || || || || || ? || || ||
+
|- style="background:#FFFFCD"
+
| 200 || List Rooms || Query || || || || || 0 || || ||
+
|- style="background:#FFFFFF"
+
| 300 || ''not used'' || Query || || || || || 0 || || ||
+
|- style="background:#FFFFCD"
+
| 350 || List Item || Reply || || UID / RID / GID || || || || || user / room / host IP || user / room / host
+
|- style="background:#FFFFCD"
+
| 351 || List End || Reply || || || || || || || ||
+
|- style="background:#FFFFCD"
+
| 400 || List Users || Query || || || UID || || 0 || || ||
+
|- style="background:#FFFFCD"
+
| 500 || List Games || Query || || || UID || || 0 || || ||
+
|- style="background:#FFE6CD"
+
| 600 || Login || Query || || 0 || || || 0 || || || local user
+
|- style="background:#FFE6CD"
+
| 600 || Login || Notice || || remote UID || || || 0 || || || remote user
+
|- style="background:#FFE6CD"
+
| 601 || Login || Reply || || local UID || || || || || ||
+
|- style="background:#FFCDCD"
+
| 700 || Create Room || Query || || 0 || || || 0 || || creator IP || room
+
|- style="background:#FFCDCD"
+
| 700 || Create Room ||Notice || || new RID || || || 0 || || creator IP || room
+
|- style="background:#FFCDCD"
+
| 701 || Create Room || Reply || || new RID || || || || || ||
+
|- style="background:#FFCDEF"
+
| 800 || Join Room / Game || Query || || || joined RID / GID || || || local UID || ||
+
|- style="background:#FFCDEF"
+
| 800 || Join Room / Game || Notice || || || joined RID / GID || || || remote UID || ||
+
|- style="background:#FFCDEF"
+
| 801 || Join Room / Game || Reply || || || || || || || ||
+
|- style="background:#EFCDFF"
+
| 900 || Leave Room || Query || || || left RID || || || local UID || ||
+
|- style="background:#EFCDFF"
+
| 900 || Leave Room || Notice || || || left RID || || || remote UID || ||
+
|- style="background:#EFCDFF"
+
| 901 || Leave Room || Reply || || || || || || || ||
+
|- 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 || ||
+
|- style="background:#CDCDFF"
+
| 1000 || Disconnect User || Notice || || || || || || remote UID || ||
+
|- style="background:#CDCDFF"
+
| 1001 || Disconnect User || Reply<ref name=NotUsed/> || || || || || || || ||
+
|- style="background:#CDD6FF"
+
| 1100 || Close Room || Query || || || || || || RID || ||
+
|- style="background:#CDD6FF"
+
| 1100 || Close Room || Notice || || || || || || RID || ||
+
|- style="background:#CDD6FF"
+
| 1101 || Close Room || Reply || || || || || || || ||
+
|- 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
+
|- style="background:#CDEFFF"
+
| 1200 || Create Game || Notice || || || RID || || GID? || || host IP || host
+
|- style="background:#CDEFFF"
+
| 1201 || Create Game || Reply || || GID || || || || || ||
+
|- style="background:#CDFFEF"
+
| 1300 || Room Chat || Query || local UID || || || receiver RID / UID || || || "GRP:[ UserName ] &nbsp;Message" / "PRV:[ UserName ] &nbsp;Message" ||
+
|- style="background:#CDFFEF"
+
| 1300 || Room Chat || Notice || remote UID || || || receiver RID / UID || || || "GRP:[ UserName ] &nbsp;Message" / "PRV:[ UserName ] &nbsp;Message" ||
+
|- style="background:#CDFFEF"
+
| 1301 || Room Chat || Reply<ref name=ReturnsEFail>Original server always reports E_FAIL in error code, even though messages were sent.</ref> || || || || || || || ||
+
|- style="background:#FFFFFF"
+
| 1320 || ''not used'' || Query || ? || || || || || || ? ||
+
|- style="background:#FFFFFF"
+
| 1321 || ''not used'' || Reply || || || || || || || ||
+
|- style="background:#FFFFFF"
+
| 1322 || ''not used'' || Query || ? || || || || || || ? ||
+
|- style="background:#FFFFFF"
+
| 1323 || ''not used'' || Reply || || || || || || || ||
+
|- style="background:#FFFFFF"
+
| 1324 || ''not used'' || Query || ? || || || || || || ||
+
|- style="background:#FFFFFF"
+
| 1325 || ''not used'' || Reply || || || || || || || ? ||
+
|- style="background:#CDFFCD"
+
| 1326 || Connect Game || Query || GID || || || || || || ||
+
|- style="background:#CDFFCD"
+
| 1327 || Connect Game || Reply || || || || || || || host IP ||
+
|}
+
<references />
+
 
+
=== Session info ===
+
 
+
Several packets identify a user, room, or game with the '''Name''' and '''Session Info''' fields. The latter provides the following information:
+
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 164: Line 69:
 
| 11 || uint8 || 1 || Type (1=room, 4=game, 5=user)
 
| 11 || uint8 || 1 || Type (1=room, 4=game, 5=user)
 
|-
 
|-
| 12 || uint8 || 1 || State (1=default, 2=passworded room)
+
| 12 || uint8 || 1 || Access (1=public, 2=protected)
 
|-
 
|-
 
| 13 || uint8 || 1 || Always 1
 
| 13 || uint8 || 1 || Always 1
Line 173: Line 78:
 
|}
 
|}
  
It should be noted that passing other values than the ones given above or creating invalid combinations like "passworded user" will display either a French flag with the default state in the UI, or a question mark.
+
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.
 
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 ====
+
===== Nation / Flag =====
  
The nation field 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.
+
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.
  
 
{| class="wikitable sortable mw-collapsible mw-collapsed"
 
{| class="wikitable sortable mw-collapsible mw-collapsed"
! Value !! Flag
+
! Value !! Description !! Notes
 
|-
 
|-
| 1 || United Kingdom
+
| 1 || United Kingdom ||
 
|-
 
|-
| 2 || Argentinia
+
| 2 || Argentina ||
 
|-
 
|-
| 3 || Australia
+
| 3 || Australia ||
 
|-
 
|-
| 4 || Austria
+
| 4 || Austria ||
 
|-
 
|-
| 5 || Beglium
+
| 5 || Belgium ||
 
|-
 
|-
| 6 || Brazil
+
| 6 || Brazil ||
 
|-
 
|-
| 7 || Canada
+
| 7 || Canada ||
 
|-
 
|-
| 8 || Croatia
+
| 8 || Croatia ||
 
|-
 
|-
| 9 || Bosnia and Herzegovina (old flag)
+
| 9 || Bosnia || old flag of Bosnia and Herzegovina
 
|-
 
|-
| 10 || Cyprus
+
| 10 || Cyprus ||
 
|-
 
|-
| 11 || Czech Republic
+
| 11 || Czech ||
 
|-
 
|-
| 12 || Denmark
+
| 12 || Denmark ||
 
|-
 
|-
| 13 || Finland
+
| 13 || Finland ||
 
|-
 
|-
| 14 || France
+
| 14 || France ||
 
|-
 
|-
| 15 || Georgia
+
| 15 || Georgia ||
 
|-
 
|-
| 16 || Germany
+
| 16 || Germany ||
 
|-
 
|-
| 17 || Greece
+
| 17 || Greece ||
 
|-
 
|-
| 18 || Hong Kong SAR
+
| 18 || Hong Kong ||
 
|-
 
|-
| 19 || Hungary
+
| 19 || Hungary ||
 
|-
 
|-
| 20 || Iceland
+
| 20 || Iceland ||
 
|-
 
|-
| 21 || India
+
| 21 || India ||
 
|-
 
|-
| 22 || Indonesia
+
| 22 || Indonesia ||
 
|-
 
|-
| 23 || Iran
+
| 23 || Iran ||
 
|-
 
|-
| 24 || Iraq
+
| 24 || Iraq ||
 
|-
 
|-
| 25 || Ireland
+
| 25 || Ireland ||
 
|-
 
|-
| 26 || Israel
+
| 26 || Israel ||
 
|-
 
|-
| 27 || Italy
+
| 27 || Italy ||
 
|-
 
|-
| 28 || Japan
+
| 28 || Japan ||
 
|-
 
|-
| 29 || Liechtenstein
+
| 29 || Liechtenstein ||
 
|-
 
|-
| 30 || Luxembourg
+
| 30 || Luxembourg ||
 
|-
 
|-
| 31 || Malaysia
+
| 31 || Malaysia ||
 
|-
 
|-
| 32 || Malta
+
| 32 || Malta ||
 
|-
 
|-
| 33 || Mexico
+
| 33 || Mexico ||
 
|-
 
|-
| 34 || Morocco
+
| 34 || Morocco ||
 
|-
 
|-
| 35 || Netherlands
+
| 35 || Netherlands ||
 
|-
 
|-
| 36 || New Zealand
+
| 36 || New Zealand ||
 
|-
 
|-
| 37 || Norway
+
| 37 || Norway ||
 
|-
 
|-
| 38 || Poland
+
| 38 || Poland ||
 
|-
 
|-
| 39 || Portugal
+
| 39 || Portugal ||
 
|-
 
|-
| 40 || Puerto Rico
+
| 40 || Puertorico ||
 
|-
 
|-
| 41 || Romania
+
| 41 || Romania ||
 
|-
 
|-
| 42 || Russian Federation
+
| 42 || Russia ||
 
|-
 
|-
| 43 || Singapore
+
| 43 || Singapore ||
 
|-
 
|-
| 44 || South Africa
+
| 44 || South Africa ||
 
|-
 
|-
| 45 || Spain
+
| 45 || Spain ||
 
|-
 
|-
| 46 || Sweden
+
| 46 || Sweden ||
 
|-
 
|-
| 47 || Switzerland
+
| 47 || Switzerland ||
 
|-
 
|-
| 48 || Turkey
+
| 48 || Turkey ||
 
|-
 
|-
| 49 || United States
+
| 49 || United States of America ||
 
|-
 
|-
| 50 || Skull image
+
| 50 || Iraq || Skull flag
 
|-
 
|-
| 51 || Team17 logo
+
| 51 || Worms2 Imperial Troopers || Team17 flag
 +
|-
 +
| other || Unknown || French flag for players, question mark for rooms
 
|}
 
|}
  
==== Game release ====
+
===== Game release =====
  
'''Game release''' becomes 50 if CD detection failed. The CD detection consists of the following tests:
+
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)
 
* 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 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 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)
 
* 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.
 +
 +
{| class="wikitable sortable"
 +
! Code !! Action !! Type !! Value 0 !! Value 1 !! Value 2 !! Value 3 !! Value 4 !! Value 10 !! Data !! Name / Session
 +
|- style="background:#FFF"
 +
| 50 || ''not used'' || Query || || || || || ? || || ||
 +
|- style="background:#FFF"
 +
| 51 || ''not used'' || Reply || || || || || ? || || ||
 +
|- style="background:#FFFFCD"
 +
| 200 || List Rooms || Query || || || || || 0 || || ||
 +
|- style="background:#FFFFFF"
 +
| 300 || ''not used'' || Query || || || || || 0 || || ||
 +
|- style="background:#FFFFCD"
 +
| 350 || List Item || Reply || || UID / RID / GID || || || || || user / creator / host IP || user / room / game
 +
|- style="background:#FFFFCD"
 +
| 351 || List End || Reply || || || || || || || ||
 +
|- style="background:#FFFFCD"
 +
| 400 || List Users || Query || || || RID || || 0 || || ||
 +
|- style="background:#FFFFCD"
 +
| 500 || List Games || Query || || || RID || || 0 || || ||
 +
|- style="background:#FFE6CD"
 +
| 600 || Login || Query || || 0 || || || 0 || || || local user
 +
|- style="background:#FFE6CD"
 +
| 600 || Login || Notice || || remote UID || || || 0 || || || remote user
 +
|- style="background:#FFE6CD"
 +
| 601 || Login || Reply || || local UID || || || || || ||
 +
|- style="background:#FFCDCD"
 +
| 700 || Create Room || Query || || 0 || || || 0 || || creator IP || room
 +
|- style="background:#FFCDCD"
 +
| 700 || Create Room || Notice || || new RID || || || 0 || || creator IP || room
 +
|- style="background:#FFCDCD"
 +
| 701 || Create Room || Reply || || new RID || || || || || ||
 +
|- style="background:#FFCDEF"
 +
| 800 || Join Room / Game || Query || || || joined RID / GID || || || local UID || ||
 +
|- style="background:#FFCDEF"
 +
| 800 || Join Room / Game || Notice || || || joined RID / GID || || || remote UID || ||
 +
|- style="background:#FFCDEF"
 +
| 801 || Join Room / Game || Reply || || || || || || || ||
 +
|- style="background:#EFCDFF"
 +
| 900 || Leave Room / Game || Query || || || left RID / GID || || || local UID || ||
 +
|- style="background:#EFCDFF"
 +
| 900 || Leave Room / Game || Notice || || || left RID / GID || || || remote UID || ||
 +
|- style="background:#EFCDFF"
 +
| 901 || Leave Room / Game || Reply || || || || || || || ||
 +
|- 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 || ||
 +
|- style="background:#CDCDFF"
 +
| 1000 || Disconnect User || Notice || || || || || || remote UID || ||
 +
|- style="background:#CDCDFF"
 +
| 1001 || Disconnect User || Reply<ref name=NotUsed/> || || || || || || || ||
 +
|- style="background:#CDD6FF"
 +
| 1100 || Close Room / Game || Query || || || || || || RID / GID || ||
 +
|- style="background:#CDD6FF"
 +
| 1100 || Close Room / Game || Notice || || || || || || RID / GID || ||
 +
|- style="background:#CDD6FF"
 +
| 1101 || Close Room / Game || Reply || || || || || || || ||
 +
|- 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> || || 0 || RID || || 0x800 || || host IP || host
 +
|- style="background:#CDEFFF"
 +
| 1200 || Create Game || Notice || || GID || RID || || 0x800 || || host IP || host
 +
|- style="background:#CDEFFF"
 +
| 1201 || Create Game || Reply || || GID || || || || || ||
 +
|- style="background:#CDFFEF"
 +
| 1300 || Room Chat || Query || local UID || || || receiver RID / UID || || || "GRP:[ UserName ] &nbsp;Message" / "PRV:[ UserName ] &nbsp;Message" ||
 +
|- style="background:#CDFFEF"
 +
| 1300 || Room Chat || Notice || remote UID || || || receiver RID / UID || || || "GRP:[ UserName ] &nbsp;Message" / "PRV:[ UserName ] &nbsp;Message" ||
 +
|- style="background:#CDFFEF"
 +
| 1301 || Room Chat || Reply<ref name=ReturnsEFail>Original server always reports E_FAIL in error code, even though messages were sent.</ref> || || || || || || || ||
 +
|- style="background:#FFFFFF"
 +
| 1320 || ''not used'' || Query || ? || || || || || || ? ||
 +
|- style="background:#FFFFFF"
 +
| 1321 || ''not used'' || Reply || || || || || || || ||
 +
|- style="background:#FFFFFF"
 +
| 1322 || ''not used'' || Query || ? || || || || || || ? ||
 +
|- style="background:#FFFFFF"
 +
| 1323 || ''not used'' || Reply || || || || || || || ||
 +
|- style="background:#FFFFFF"
 +
| 1324 || ''not used'' || Query || ? || || || || || || ||
 +
|- style="background:#FFFFFF"
 +
| 1325 || ''not used'' || Reply || || || || || || || ? ||
 +
|- style="background:#CDFFCD"
 +
| 1326 || Connect Game || Query || GID || || || || || || ||
 +
|- style="background:#CDFFCD"
 +
| 1327 || Connect Game || Reply || || || || || || || host IP ||
 +
|}
 +
<references />
  
 
== Game room communication ==
 
== 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]].
 
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 ==
 +
 +
* [[User:Pac-Man/Worms_2_network_samples|Selected sample logs]]
 +
* [[Worms 2 Game Server]], cross-platform server implementing the above protocol.

Latest revision as of 20:26, 16 May 2024

(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 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. 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