44
55from ..wire.exceptions import PacketInvalidData
66from ..wire.read import (
7+ read_string,
78 read_uint8,
89 read_uint16,
910 read_uint32,
@@ -74,6 +75,18 @@ def receive_PACKET_CONTENT_CLIENT_INFO_LIST(source, data):
7475 content_type, data = read_uint8(data)
7576 openttd_version, data = read_uint32(data)
7677
78+ # Since OpenTTD 12.0 we extended this packet to include multiple
79+ # branches and their versions, so patchpacks can filter the list
80+ # based on their version. This is indicated by sending an
81+ # openttd_version that is UINT32_MAX.
82+ branch_versions = {}
83+ if openttd_version == 0xFFFFFFFF:
84+ count, data = read_uint8(data)
85+ for _ in range(count):
86+ branch, data = read_string(data)
87+ version, data = read_string(data)
88+ branch_versions[branch] = version
89+
7790 if content_type >= ContentType.CONTENT_TYPE_END:
7891 raise PacketInvalidData("invalid ContentType", content_type)
7992
@@ -82,7 +95,7 @@ def receive_PACKET_CONTENT_CLIENT_INFO_LIST(source, data):
8295 if len(data) != 0:
8396 raise PacketInvalidData("more bytes than expected; remaining: ", len(data))
8497
85- return {"content_type": content_type, "openttd_version": openttd_version}
98+ return {"content_type": content_type, "openttd_version": openttd_version, "branch_versions": branch_versions }
8699
87100 @staticmethod
88101 def _receive_client_info(data, count, has_content_id=False, has_content_type_and_unique_id=False, has_md5sum=False):
0 commit comments