fix!: 0.6.5 chunk header

This change added a version flag to chunk header

``ChunkHeader()`` no longer works! You now have to do
``ChunkHeader(version = '0.6')`` or ``ChunkHeader(version = '0.7')``

This fixes 0.6 chunk header packing.
It has a suddle difference to 0.7 and it is now packed correctly.

Also unpacking 0.6.5 chunk headers is fixed by reading the correct size.
This commit is contained in:
ChillerDragon 2024-03-10 13:57:52 +08:00
parent d997c0b990
commit 4f845ea7ee
116 changed files with 283 additions and 178 deletions

View file

@ -1024,7 +1024,7 @@ def match_connless{self.protocol_version}(msg_id: bytes, data: bytes) -> Connles
out_file.write(f" self.system_message: bool = {sys}\n")
out_file.write(f" self.message_id: int = {msg['id']}\n")
out_file.write(" if not chunk_header:\n")
out_file.write(" chunk_header = ChunkHeader()\n")
out_file.write(f" chunk_header = ChunkHeader(version = '0.{self.protocol_version}')\n")
out_file.write(" self.header: ChunkHeader = chunk_header\n")
out_file.write('\n')
self.generate_field_assignments_in_initialize(msg, out_file)

View file

@ -0,0 +1,70 @@
from twnet_parser.packet import \
ChunkHeaderParser
from twnet_parser.chunk_header import \
ChunkHeader
def test_chunk_header_unpack_bogus_vital() -> None:
# this is a non sense header
# but the values are verified with the C++
# implementation
parser = ChunkHeaderParser()
header: ChunkHeader = parser.parse_header6(b'\x40\x10\x0a')
assert header.flags.resend is False
assert header.flags.vital is True
assert header.size == 0
assert header.seq == 74
def test_chunk_header_unpack_vital_seq38() -> None:
# this is a non sense header
# but the values are verified with the C++
# implementation
parser = ChunkHeaderParser()
header: ChunkHeader = parser.parse_header6(b'\x40\x02\x26')
assert header.flags.resend is False
assert header.flags.vital is True
assert header.size == 2
assert header.seq == 38
def test_chunk_header_unpack_bogus_no_flags_size107() -> None:
# this is a non sense header
# but the values are verified with the C++
# implementation
parser = ChunkHeaderParser()
header: ChunkHeader = parser.parse_header6(b'\x06\x0b')
assert header.flags.resend is False
assert header.flags.vital is False
assert header.size == 107
assert header.seq == -1
def test_chunk_header_unpack_bogus_no_flags_size27() -> None:
# this is a non sense header
# but the values are verified with the C++
# implementation
parser = ChunkHeaderParser()
header: ChunkHeader = parser.parse_header6(b'\x01\x0b')
assert header.flags.resend is False
assert header.flags.vital is False
assert header.size == 27
assert header.seq == -1
def test_chunk_header_all_set() -> None:
# this is a non sense header
# but the values are verified with the C++
# implementation
parser = ChunkHeaderParser()
header: ChunkHeader = parser.parse_header6(b'\xff\xff\xff')
assert header.flags.resend is True
assert header.flags.vital is True
assert header.size == 1023
assert header.seq == 1023

View file

@ -16,7 +16,7 @@ def test_chunk_header_unpack_vital1() -> None:
assert header.seq == 10
def test_chunk_header_pack_vital1() -> None:
header: ChunkHeader = ChunkHeader()
header: ChunkHeader = ChunkHeader(version = '0.7')
header.flags.resend = False
header.flags.vital = True
@ -29,7 +29,7 @@ def test_chunk_header_pack_vital1() -> None:
assert header.pack() == b'\x40\x10\x0a'
def test_chunk_header_pack_resend() -> None:
header: ChunkHeader = ChunkHeader()
header: ChunkHeader = ChunkHeader(version = '0.7')
header.flags.resend = True
header.flags.vital = False
@ -42,7 +42,7 @@ def test_chunk_header_pack_resend() -> None:
assert header.pack() == b'\x80\x10'
def test_chunk_header_pack_no_flags1() -> None:
header: ChunkHeader = ChunkHeader()
header: ChunkHeader = ChunkHeader(version = '0.7')
header.flags.resend = False
header.flags.vital = False
@ -55,7 +55,7 @@ def test_chunk_header_pack_no_flags1() -> None:
assert header.pack() == b'\x00\x10'
def test_chunk_header_pack_no_flags2() -> None:
header: ChunkHeader = ChunkHeader()
header: ChunkHeader = ChunkHeader(version = '0.7')
header.flags.resend = False
header.flags.vital = False
@ -87,7 +87,7 @@ def test_chunk_header_pack_no_flags2() -> None:
assert header.pack() == b'\x00\x15'
def test_chunk_header_pack_no_flags_max_size() -> None:
header: ChunkHeader = ChunkHeader()
header: ChunkHeader = ChunkHeader(version = '0.7')
header.flags.resend = False
header.flags.vital = False
@ -129,7 +129,7 @@ def test_chunk_header_pack_no_flags_max_size() -> None:
def test_chunk_header_pack_no_flags_out_of_bounds_size() -> None:
header: ChunkHeader = ChunkHeader()
header: ChunkHeader = ChunkHeader(version = '0.7')
header.flags.resend = False
header.flags.vital = False

View file

@ -4,47 +4,50 @@ from twnet_parser.messages6.system.input import MsgInput
from typing import cast
def test_real_ddnet_cl_emote_and_input6() -> None:
"""
This is from a traffic dump of a ddnet 0.6
client talking to a ddnet server
"""
data = b'\x80\x13' \
b'\x02\x4a\x42\xbb\x8b\x6e\x28\x18\xf1\x92\xe5\x82\x2c\x6b\x99\x36' \
b'\x1a\xf1\x78\x3e\x54\x0d\x67\x52\xaf\xb8\x01' \
packet = parse6(data)
assert packet.header.num_chunks == 2
assert packet.header.ack == 19
assert packet.header.flags.resend is False
assert packet.header.flags.connless is False
assert packet.header.flags.control is False
assert packet.header.flags.compression is True
assert len(packet.messages) == 2
emote: MsgClEmoticon = cast(MsgClEmoticon, packet.messages[0])
assert emote.message_name == 'cl_emoticon'
assert emote.emoticon == 7
inp: MsgInput = cast(MsgInput, packet.messages[1])
assert inp.message_name == 'input'
assert inp.ack_snapshot == 2556
assert inp.intended_tick == 2557
assert inp.input_size == 40
assert inp.input.direction == 0
assert inp.input.target_x == 394
assert inp.input.target_y == 68
assert inp.input.hook == 0
assert inp.input.fire == 0
assert inp.input.jump == 0
assert inp.input.player_flags == 1
assert inp.input.wanted_weapon == 0
assert inp.input.next_weapon == 0
assert inp.input.prev_weapon == 0
# def test_real_ddnet_cl_emote_and_input6() -> None:
# """
# This is from a traffic dump of a ddnet 0.6
# client talking to a ddnet server
#
# the last 4 bytes seem to be the ddnet token
# twnet_parser does not support the ddnet protocol yet
# """
# data = b'\x80\x13' \
# b'\x02\x4a\x42\xbb\x8b\x6e\x28\x18\xf1\x92\xe5\x82\x2c\x6b\x99\x36' \
# b'\x1a\xf1\x78\x3e\x54\x0d\x67\x52\xaf\xb8\x01' \
#
# packet = parse6(data)
#
# assert packet.header.num_chunks == 2
# assert packet.header.ack == 19
#
# assert packet.header.flags.resend is False
# assert packet.header.flags.connless is False
# assert packet.header.flags.control is False
# assert packet.header.flags.compression is True
#
# assert len(packet.messages) == 2
#
# emote: MsgClEmoticon = cast(MsgClEmoticon, packet.messages[0])
# assert emote.message_name == 'cl_emoticon'
# assert emote.emoticon == 7
#
# inp: MsgInput = cast(MsgInput, packet.messages[1])
# assert inp.message_name == 'input'
# assert inp.ack_snapshot == 2556
# assert inp.intended_tick == 2557
# assert inp.input_size == 40
#
# assert inp.input.direction == 0
# assert inp.input.target_x == 394
# assert inp.input.target_y == 68
# assert inp.input.hook == 0
# assert inp.input.fire == 0
# assert inp.input.jump == 0
# assert inp.input.player_flags == 1
# assert inp.input.wanted_weapon == 0
# assert inp.input.next_weapon == 0
# assert inp.input.prev_weapon == 0
def test_repack_real_ddnet_cl_emote_input6() -> None:
packet: TwPacket = TwPacket(version = '0.6')

View file

@ -1,6 +1,6 @@
from twnet_parser.packet import parse6
from twnet_parser.messages6.game.sv_chat import MsgSvChat
from twnet_parser.messages6.system.map_data import MsgMapData
from twnet_parser.messages6.system.snap_single import MsgSnapSingle
def test_game_sv_chat():
"""
@ -41,14 +41,15 @@ def test_game_sv_chat():
assert msg.client_id == -1
assert msg.message == "'nameless tee' entered and joined the game"
# no idea if this is correct
msg2: MsgMapData = packet.messages[1]
msg2: MsgSnapSingle = packet.messages[1]
assert msg2.system_message is True
assert msg2.message_name == "map_data"
assert msg2.chunk == 0
assert msg2.crc == 10
assert msg2.message_name == 'snap_single'
assert msg2.tick == 5210
assert msg2.delta_tick == 5211
assert msg2.crc == 1536533683
assert msg2.data_size == 95
# assert msg2.data == b''
repack = packet.pack()
# TODO: this has a diff
# assert repack == data
assert repack == data

View file

@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, Literal
from twnet_parser.pretty_print import PrettyPrint
@ -12,7 +12,8 @@ class ChunkFlags(PrettyPrint):
# same fields for 0.6 and 0.7
# different bit layout tho
class ChunkHeader(PrettyPrint):
def __init__(self) -> None:
def __init__(self, version: Literal['0.6', '0.7']) -> None:
self.version = version
self.flags: ChunkFlags = ChunkFlags()
self.size: Optional[int] = None
# TODO: should seq be a optional?
@ -39,12 +40,23 @@ class ChunkHeader(PrettyPrint):
flags |= 1
if self.size is None:
self.size = 0
data: bytearray = bytearray([ \
((flags & 0x03) << 6) | \
((self.size >> 6) & 0x3f),
self.size & 0x3f
])
if self.flags.vital:
data[1] |= (self.seq >> 2) & 0xc0
data += bytes([self.seq & 0xff])
data: bytearray
if self.version == '0.6':
data = bytearray([ \
((flags & 0x03) << 6) | \
((self.size >> 4) & 0x3f),
self.size & 0xf
])
if self.flags.vital:
data[1] |= (self.seq >> 2) & 0xf0
data += bytes([self.seq & 0xff])
else: # 0.7
data = bytearray([ \
((flags & 0x03) << 6) | \
((self.size >> 6) & 0x3f),
self.size & 0x3f
])
if self.flags.vital:
data[1] |= (self.seq >> 2) & 0xc0
data += bytes([self.seq & 0xff])
return bytes(data)

View file

@ -1,4 +1,4 @@
from typing import Literal
from typing import Literal, Optional
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.chunk_header import ChunkHeader
@ -6,13 +6,15 @@ from twnet_parser.chunk_header import ChunkHeader
class MsgDDNetUuid(PrettyPrint):
def __init__(
self,
chunk_header: ChunkHeader = ChunkHeader(),
chunk_header: Optional[ChunkHeader] = None,
payload: bytes = b''
) -> None:
self.message_type: Literal['system', 'game'] = 'system'
self.message_name: str = 'ddnet_uuid'
self.system_message: bool = True
self.message_id: int = 0
if not chunk_header:
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.payload: bytes = payload

View file

@ -19,7 +19,7 @@ class MsgClCallVote(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 25
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.type: str = type

View file

@ -23,7 +23,7 @@ class MsgClChangeInfo(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 21
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -18,7 +18,7 @@ class MsgClEmoticon(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 23
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.emoticon: int = emoticon

View file

@ -14,7 +14,7 @@ class MsgClKill(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 22
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header

View file

@ -18,7 +18,7 @@ class MsgClSay(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 17
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.team: bool = team

View file

@ -17,7 +17,7 @@ class MsgClSetSpectatorMode(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 19
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.spectator_id: int = spectator_id

View file

@ -18,7 +18,7 @@ class MsgClSetTeam(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 18
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.team: int = team

View file

@ -23,7 +23,7 @@ class MsgClStartInfo(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 20
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -17,7 +17,7 @@ class MsgClVote(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 24
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.vote: int = vote

View file

@ -17,7 +17,7 @@ class MsgSvBroadcast(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 2
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.message: str = message

View file

@ -19,7 +19,7 @@ class MsgSvChat(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 3
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.team: bool = team

View file

@ -19,7 +19,7 @@ class MsgSvEmoticon(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 10
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.client_id: int = client_id

View file

@ -17,7 +17,7 @@ class MsgSvExtraProjectile(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 7
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
if not projectile:

View file

@ -20,7 +20,7 @@ class MsgSvKillMsg(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 4
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.killer: int = killer

View file

@ -17,7 +17,7 @@ class MsgSvMotd(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 1
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.message: str = message

View file

@ -14,7 +14,7 @@ class MsgSvReadyToEnter(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 8
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header

View file

@ -18,7 +18,7 @@ class MsgSvSoundGlobal(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 5
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.sound_id: int = sound_id

View file

@ -49,7 +49,7 @@ class MsgSvTuneParams(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 6
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.ground_control_speed: float = ground_control_speed

View file

@ -14,7 +14,7 @@ class MsgSvVoteClearOptions(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 11
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header

View file

@ -17,7 +17,7 @@ class MsgSvVoteOptionAdd(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 13
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.description: str = description

View file

@ -19,7 +19,7 @@ class MsgSvVoteOptionListAdd(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 12
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.num_options: int = num_options

View file

@ -17,7 +17,7 @@ class MsgSvVoteOptionRemove(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 14
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.description: str = description

View file

@ -19,7 +19,7 @@ class MsgSvVoteSet(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 15
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.timeout: int = timeout

View file

@ -20,7 +20,7 @@ class MsgSvVoteStatus(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 16
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.yes: int = yes

View file

@ -18,7 +18,7 @@ class MsgSvWeaponPickup(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 9
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.weapon: int = weapon

View file

@ -14,7 +14,7 @@ class MsgConReady(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 4
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header

View file

@ -14,7 +14,7 @@ class MsgEnterGame(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 15
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header

View file

@ -18,7 +18,7 @@ class MsgInfo(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 1
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.version: str = version

View file

@ -21,7 +21,7 @@ class MsgInput(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 16
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.ack_snapshot: int = ack_snapshot

View file

@ -18,7 +18,7 @@ class MsgInputTiming(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 9
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.input_pred_tick: int = input_pred_tick

View file

@ -19,7 +19,7 @@ class MsgMapChange(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 2
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -21,7 +21,7 @@ class MsgMapData(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 3
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.last: int = last

View file

@ -14,7 +14,7 @@ class MsgPing(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 20
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header

View file

@ -14,7 +14,7 @@ class MsgPingReply(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 21
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header

View file

@ -19,7 +19,7 @@ class MsgRconAuth(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 18
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self._unused: str = _unused

View file

@ -18,7 +18,7 @@ class MsgRconAuthStatus(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 10
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.auth_level: Optional[int] = auth_level

View file

@ -17,7 +17,7 @@ class MsgRconCmd(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 17
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.cmd: str = cmd

View file

@ -19,7 +19,7 @@ class MsgRconCmdAdd(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 25
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -17,7 +17,7 @@ class MsgRconCmdRemove(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 26
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -17,7 +17,7 @@ class MsgRconLine(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 11
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.line: str = line

View file

@ -14,7 +14,7 @@ class MsgReady(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 14
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header

View file

@ -17,7 +17,7 @@ class MsgRequestMapData(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 19
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.chunk: int = chunk

View file

@ -9,7 +9,7 @@ from twnet_parser.snapshot7 import Snapshot
class MsgSnap(PrettyPrint):
def __init__(
self,
chunk_header: ChunkHeader = ChunkHeader(),
chunk_header: Optional[ChunkHeader] = None,
tick: int = 0,
delta_tick: int = 0,
num_parts: int = 0,
@ -22,6 +22,8 @@ class MsgSnap(PrettyPrint):
self.message_name: str = 'snap'
self.system_message: bool = True
self.message_id: int = 5
if not chunk_header:
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.tick: int = tick

View file

@ -18,7 +18,7 @@ class MsgSnapEmpty(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 6
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.tick: int = tick

View file

@ -21,7 +21,7 @@ class MsgSnapSingle(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 7
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.6')
self.header: ChunkHeader = chunk_header
self.tick: int = tick

View file

@ -20,7 +20,7 @@ class MsgClCallVote(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 32
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.type: str = type

View file

@ -18,7 +18,7 @@ class MsgClCommand(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 39
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -18,7 +18,7 @@ class MsgClEmoticon(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 30
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.emoticon: int = emoticon

View file

@ -14,7 +14,7 @@ class MsgClKill(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 28
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header

View file

@ -14,7 +14,7 @@ class MsgClReadyChange(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 29
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header

View file

@ -20,7 +20,7 @@ class MsgClSay(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 24
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.mode: int = mode

View file

@ -19,7 +19,7 @@ class MsgClSetSpectatorMode(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 26
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.spec_mode: int = spec_mode

View file

@ -18,7 +18,7 @@ class MsgClSetTeam(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 25
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.team: int = team

View file

@ -22,7 +22,7 @@ class MsgClSkinChange(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 34
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.skin_part_names = skin_part_names

View file

@ -25,7 +25,7 @@ class MsgClStartInfo(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 27
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -17,7 +17,7 @@ class MsgClVote(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 31
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.vote: int = vote

View file

@ -20,7 +20,7 @@ class MsgDeClientEnter(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 22
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -19,7 +19,7 @@ class MsgDeClientLeave(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 23
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -17,7 +17,7 @@ class MsgSvBroadcast(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 2
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.message: str = message

View file

@ -21,7 +21,7 @@ class MsgSvChat(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 3
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.mode: int = mode

View file

@ -17,7 +17,7 @@ class MsgSvCheckpoint(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 36
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.diff: int = diff

View file

@ -19,7 +19,7 @@ class MsgSvClientDrop(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 20
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.client_id: int = client_id

View file

@ -30,7 +30,7 @@ class MsgSvClientInfo(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 18
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.client_id: int = client_id

View file

@ -19,7 +19,7 @@ class MsgSvCommandInfo(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 37
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -17,7 +17,7 @@ class MsgSvCommandInfoRemove(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 38
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -19,7 +19,7 @@ class MsgSvEmoticon(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 10
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.client_id: int = client_id

View file

@ -17,7 +17,7 @@ class MsgSvExtraProjectile(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 7
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
if not projectile:

View file

@ -21,7 +21,7 @@ class MsgSvGameInfo(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 19
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.game_flags: int = game_flags

View file

@ -14,7 +14,7 @@ class MsgSvGameMsg(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 21
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header

View file

@ -20,7 +20,7 @@ class MsgSvKillMsg(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 5
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.killer: int = killer

View file

@ -17,7 +17,7 @@ class MsgSvMotd(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 1
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.message: str = message

View file

@ -21,7 +21,7 @@ class MsgSvRaceFinish(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 35
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.client_id: int = client_id

View file

@ -14,7 +14,7 @@ class MsgSvReadyToEnter(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 8
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header

View file

@ -22,7 +22,7 @@ class MsgSvServerSettings(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 17
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.kick_vote: bool = kick_vote

View file

@ -23,7 +23,7 @@ class MsgSvSkinChange(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 33
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.client_id: int = client_id

View file

@ -21,7 +21,7 @@ class MsgSvTeam(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 4
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.client_id: int = client_id

View file

@ -48,7 +48,7 @@ class MsgSvTuneParams(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 6
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.ground_control_speed: float = ground_control_speed

View file

@ -14,7 +14,7 @@ class MsgSvVoteClearOptions(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 11
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header

View file

@ -17,7 +17,7 @@ class MsgSvVoteOptionAdd(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 13
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.description: str = description

View file

@ -14,7 +14,7 @@ class MsgSvVoteOptionListAdd(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 12
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header

View file

@ -17,7 +17,7 @@ class MsgSvVoteOptionRemove(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 14
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.description: str = description

View file

@ -22,7 +22,7 @@ class MsgSvVoteSet(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 15
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.client_id: int = client_id

View file

@ -20,7 +20,7 @@ class MsgSvVoteStatus(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 16
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.yes: int = yes

View file

@ -18,7 +18,7 @@ class MsgSvWeaponPickup(PrettyPrint):
self.system_message: bool = False
self.message_id: int = 9
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.weapon: int = weapon

View file

@ -14,7 +14,7 @@ class MsgConReady(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 5
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header

View file

@ -14,7 +14,7 @@ class MsgEnterGame(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 19
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header

View file

@ -19,7 +19,7 @@ class MsgInfo(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 1
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.version: str = version

View file

@ -21,7 +21,7 @@ class MsgInput(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 20
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.ack_snapshot: int = ack_snapshot

View file

@ -18,7 +18,7 @@ class MsgInputTiming(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 10
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.input_pred_tick: int = input_pred_tick

View file

@ -22,7 +22,7 @@ class MsgMapChange(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 2
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -16,7 +16,7 @@ class MsgMapData(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 3
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.data: bytes = data

View file

@ -17,7 +17,7 @@ class MsgMaplistEntryAdd(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 29
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.name: str = name

View file

@ -17,7 +17,7 @@ class MsgMaplistEntryRem(PrettyPrint):
self.system_message: bool = True
self.message_id: int = 30
if not chunk_header:
chunk_header = ChunkHeader()
chunk_header = ChunkHeader(version = '0.7')
self.header: ChunkHeader = chunk_header
self.name: str = name

Some files were not shown because too many files have changed in this diff Show more