Generate system and game message classes

Most of the code is generated by

`./scripts/generate_messages.py`
This commit is contained in:
ChillerDragon 2023-03-31 10:26:04 +02:00
parent 91df2614b3
commit b2f2ff2f9a
67 changed files with 2441 additions and 31 deletions

View file

@ -141,4 +141,15 @@ def teste_parse_7_real_broadcast_input_snap() -> None:
# Tick: 446 # Tick: 446
# Delta tick: 4 # Delta tick: 4
# packet = parse7(data) packet = parse7(data)
assert len(packet.messages) == 3
assert packet.messages[0].message_name == 'sv_broadcast'
assert packet.messages[0].system_message is False
assert packet.messages[1].message_name == 'input_timing'
assert packet.messages[1].system_message is True
assert packet.messages[2].message_name == 'snap_empty'
assert packet.messages[2].system_message is True

View file

@ -1,21 +1,7 @@
from typing import cast
import twnet_parser.msg7
import twnet_parser.messages7.system.map_change
from twnet_parser.net_message import NetMessage from twnet_parser.net_message import NetMessage
from twnet_parser.chunk_header import ChunkHeader
# TODO: remove when msg class generation is done from twnet_parser.msg_matcher.game7 import match_game7
# this is just a placeholder to scaffold code from twnet_parser.msg_matcher.system7 import match_system7
class TodoMessage():
def __init__(self, name: str) -> None:
self.message_name = name
self.system_message = False
self.header: ChunkHeader
def unpack(self, data: bytes) -> bool:
return len(data) > 0
def pack(self) -> bytes:
return b'\x00'
# could also be named ChunkParser # could also be named ChunkParser
class MessageParser(): class MessageParser():
@ -24,17 +10,6 @@ class MessageParser():
# NOT the whole packet with packet header # NOT the whole packet with packet header
# and NOT the whole message with chunk header # and NOT the whole message with chunk header
def parse_game_message(self, msg_id: int, data: bytes) -> NetMessage: def parse_game_message(self, msg_id: int, data: bytes) -> NetMessage:
if msg_id == twnet_parser.msg7.SV_MOTD: return match_game7(msg_id, data)
return TodoMessage('sv_motd')
if msg_id == twnet_parser.msg7.SV_SERVER_SETTINGS:
return TodoMessage('sv_server_settings')
raise ValueError(f"Error: unknown message game.id={msg_id} data={data[0]}")
def parse_sys_message(self, msg_id: int, data: bytes) -> NetMessage: def parse_sys_message(self, msg_id: int, data: bytes) -> NetMessage:
if msg_id == twnet_parser.msg7.MAP_CHANGE: return match_system7(msg_id, data)
msg = twnet_parser.messages7.system.map_change.MsgMapChange()
msg.unpack(data)
return cast(NetMessage, msg)
if msg_id == twnet_parser.msg7.CON_READY:
return TodoMessage('con_ready')
raise ValueError(f"Error: unknown message sys.id={msg_id} data={data[0]}")

View file

@ -0,0 +1,40 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgClCallVote(PrettyPrint):
def __init__(
self,
type: str = 'default',
value: str = 'default',
reason: str = 'default',
force: bool = False
) -> None:
self.message_name = 'cl_call_vote'
self.system_message = False
self.header: ChunkHeader
self.type: str = type
self.value: str = value
self.reason: str = reason
self.force: bool = force
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.type = unpacker.get_str()
self.value = unpacker.get_str()
self.reason = unpacker.get_str()
self.force = unpacker.get_int() == 1
return True
def pack(self) -> bytes:
return pack_str(self.type) + \
pack_str(self.value) + \
pack_str(self.reason) + \
pack_int(self.force)

View file

@ -0,0 +1,32 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgClCommand(PrettyPrint):
def __init__(
self,
name: str = 'default',
arguments: str = 'default'
) -> None:
self.message_name = 'cl_command'
self.system_message = False
self.header: ChunkHeader
self.name: str = name
self.arguments: str = arguments
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
self.arguments = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.name) + \
pack_str(self.arguments)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgClEmoticon(PrettyPrint):
def __init__(
self,
emoticon: int = 0
) -> None:
self.message_name = 'cl_emoticon'
self.system_message = False
self.header: ChunkHeader
self.emoticon: int = emoticon
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.emoticon = unpacker.get_int() # TODO: this is a enum
return True
def pack(self) -> bytes:
return pack_int(self.emoticon)

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgClKill(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'cl_kill'
self.system_message = False
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgClReadyChange(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'cl_ready_change'
self.system_message = False
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,36 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgClSay(PrettyPrint):
def __init__(
self,
mode: int = 0,
target: int = 0,
message: str = 'default'
) -> None:
self.message_name = 'cl_say'
self.system_message = False
self.header: ChunkHeader
self.mode: int = mode
self.target: int = target
self.message: str = message
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.mode = unpacker.get_int() # TODO: this is a enum
self.target = unpacker.get_int()
self.message = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_int(self.mode) + \
pack_int(self.target) + \
pack_str(self.message)

View file

@ -0,0 +1,32 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgClSetSpectatorMode(PrettyPrint):
def __init__(
self,
spec_mode: int = 0,
spectator_id: int = 0
) -> None:
self.message_name = 'cl_set_spectator_mode'
self.system_message = False
self.header: ChunkHeader
self.spec_mode: int = spec_mode
self.spectator_id: int = spectator_id
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.spec_mode = unpacker.get_int() # TODO: this is a enum
self.spectator_id = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.spec_mode) + \
pack_int(self.spectator_id)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgClSetTeam(PrettyPrint):
def __init__(
self,
team: int = 0
) -> None:
self.message_name = 'cl_set_team'
self.system_message = False
self.header: ChunkHeader
self.team: int = team
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.team = unpacker.get_int() # TODO: this is a enum
return True
def pack(self) -> bytes:
return pack_int(self.team)

View file

@ -0,0 +1,36 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgClSkinChange(PrettyPrint):
def __init__(
self,
skin_part_names: int = 0,
use_custom_colors: int = 0,
skin_part_colors: int = 0
) -> None:
self.message_name = 'cl_skin_change'
self.system_message = False
self.header: ChunkHeader
self.skin_part_names: int = skin_part_names
self.use_custom_colors: int = use_custom_colors
self.skin_part_colors: int = skin_part_colors
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.skin_part_names = unpacker.get_int() # TODO: this is an array
self.use_custom_colors = unpacker.get_int() # TODO: this is an array
self.skin_part_colors = unpacker.get_int() # TODO: this is an array
return True
def pack(self) -> bytes:
return pack_int(self.skin_part_names) + \
pack_int(self.use_custom_colors) + \
pack_int(self.skin_part_colors)

View file

@ -0,0 +1,48 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgClStartInfo(PrettyPrint):
def __init__(
self,
name: str = 'default',
clan: str = 'default',
country: int = 0,
skin_part_names: int = 0,
use_custom_colors: int = 0,
skin_part_colors: int = 0
) -> None:
self.message_name = 'cl_start_info'
self.system_message = False
self.header: ChunkHeader
self.name: str = name
self.clan: str = clan
self.country: int = country
self.skin_part_names: int = skin_part_names
self.use_custom_colors: int = use_custom_colors
self.skin_part_colors: int = skin_part_colors
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
self.clan = unpacker.get_str()
self.country = unpacker.get_int()
self.skin_part_names = unpacker.get_int() # TODO: this is an array
self.use_custom_colors = unpacker.get_int() # TODO: this is an array
self.skin_part_colors = unpacker.get_int() # TODO: this is an array
return True
def pack(self) -> bytes:
return pack_str(self.name) + \
pack_str(self.clan) + \
pack_int(self.country) + \
pack_int(self.skin_part_names) + \
pack_int(self.use_custom_colors) + \
pack_int(self.skin_part_colors)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgClVote(PrettyPrint):
def __init__(
self,
vote: int = 0
) -> None:
self.message_name = 'cl_vote'
self.system_message = False
self.header: ChunkHeader
self.vote: int = vote
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.vote = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.vote)

View file

@ -0,0 +1,36 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgDeClientEnter(PrettyPrint):
def __init__(
self,
name: str = 'default',
client_id: int = 0,
team: int = 0
) -> None:
self.message_name = 'de_client_enter'
self.system_message = False
self.header: ChunkHeader
self.name: str = name
self.client_id: int = client_id
self.team: int = team
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
self.client_id = unpacker.get_int()
self.team = unpacker.get_int() # TODO: this is a enum
return True
def pack(self) -> bytes:
return pack_str(self.name) + \
pack_int(self.client_id) + \
pack_int(self.team)

View file

@ -0,0 +1,36 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgDeClientLeave(PrettyPrint):
def __init__(
self,
name: str = 'default',
client_id: int = 0,
reason: str = 'default'
) -> None:
self.message_name = 'de_client_leave'
self.system_message = False
self.header: ChunkHeader
self.name: str = name
self.client_id: int = client_id
self.reason: str = reason
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
self.client_id = unpacker.get_int()
self.reason = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.name) + \
pack_int(self.client_id) + \
pack_str(self.reason)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgSvBroadcast(PrettyPrint):
def __init__(
self,
message: str = 'default'
) -> None:
self.message_name = 'sv_broadcast'
self.system_message = False
self.header: ChunkHeader
self.message: str = message
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.message = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.message)

View file

@ -0,0 +1,40 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgSvChat(PrettyPrint):
def __init__(
self,
mode: int = 0,
client_id: int = 0,
target_id: int = 0,
message: str = 'default'
) -> None:
self.message_name = 'sv_chat'
self.system_message = False
self.header: ChunkHeader
self.mode: int = mode
self.client_id: int = client_id
self.target_id: int = target_id
self.message: str = message
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.mode = unpacker.get_int() # TODO: this is a enum
self.client_id = unpacker.get_int()
self.target_id = unpacker.get_int()
self.message = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_int(self.mode) + \
pack_int(self.client_id) + \
pack_int(self.target_id) + \
pack_str(self.message)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvCheckpoint(PrettyPrint):
def __init__(
self,
diff: int = 0
) -> None:
self.message_name = 'sv_checkpoint'
self.system_message = False
self.header: ChunkHeader
self.diff: int = diff
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.diff = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.diff)

View file

@ -0,0 +1,36 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgSvClientDrop(PrettyPrint):
def __init__(
self,
client_id: int = 0,
reason: str = 'default',
silent: bool = False
) -> None:
self.message_name = 'sv_client_drop'
self.system_message = False
self.header: ChunkHeader
self.client_id: int = client_id
self.reason: str = reason
self.silent: bool = silent
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.client_id = unpacker.get_int()
self.reason = unpacker.get_str()
self.silent = unpacker.get_int() == 1
return True
def pack(self) -> bytes:
return pack_int(self.client_id) + \
pack_str(self.reason) + \
pack_int(self.silent)

View file

@ -0,0 +1,64 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgSvClientInfo(PrettyPrint):
def __init__(
self,
client_id: int = 0,
local: bool = False,
team: int = 0,
name: str = 'default',
clan: str = 'default',
country: int = 0,
skin_part_names: int = 0,
use_custom_colors: int = 0,
skin_part_colors: int = 0,
silent: bool = False
) -> None:
self.message_name = 'sv_client_info'
self.system_message = False
self.header: ChunkHeader
self.client_id: int = client_id
self.local: bool = local
self.team: int = team
self.name: str = name
self.clan: str = clan
self.country: int = country
self.skin_part_names: int = skin_part_names
self.use_custom_colors: int = use_custom_colors
self.skin_part_colors: int = skin_part_colors
self.silent: bool = silent
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.client_id = unpacker.get_int()
self.local = unpacker.get_int() == 1
self.team = unpacker.get_int() # TODO: this is a enum
self.name = unpacker.get_str()
self.clan = unpacker.get_str()
self.country = unpacker.get_int()
self.skin_part_names = unpacker.get_int() # TODO: this is an array
self.use_custom_colors = unpacker.get_int() # TODO: this is an array
self.skin_part_colors = unpacker.get_int() # TODO: this is an array
self.silent = unpacker.get_int() == 1
return True
def pack(self) -> bytes:
return pack_int(self.client_id) + \
pack_int(self.local) + \
pack_int(self.team) + \
pack_str(self.name) + \
pack_str(self.clan) + \
pack_int(self.country) + \
pack_int(self.skin_part_names) + \
pack_int(self.use_custom_colors) + \
pack_int(self.skin_part_colors) + \
pack_int(self.silent)

View file

@ -0,0 +1,36 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgSvCommandInfo(PrettyPrint):
def __init__(
self,
name: str = 'default',
args_format: str = 'default',
help_text: str = 'default'
) -> None:
self.message_name = 'sv_command_info'
self.system_message = False
self.header: ChunkHeader
self.name: str = name
self.args_format: str = args_format
self.help_text: str = help_text
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
self.args_format = unpacker.get_str()
self.help_text = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.name) + \
pack_str(self.args_format) + \
pack_str(self.help_text)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgSvCommandInfoRemove(PrettyPrint):
def __init__(
self,
name: str = 'default'
) -> None:
self.message_name = 'sv_command_info_remove'
self.system_message = False
self.header: ChunkHeader
self.name: str = name
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.name)

View file

@ -0,0 +1,32 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvEmoticon(PrettyPrint):
def __init__(
self,
client_id: int = 0,
emoticon: int = 0
) -> None:
self.message_name = 'sv_emoticon'
self.system_message = False
self.header: ChunkHeader
self.client_id: int = client_id
self.emoticon: int = emoticon
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.client_id = unpacker.get_int()
self.emoticon = unpacker.get_int() # TODO: this is a enum
return True
def pack(self) -> bytes:
return pack_int(self.client_id) + \
pack_int(self.emoticon)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvExtraProjectile(PrettyPrint):
def __init__(
self,
projectile: int = 0
) -> None:
self.message_name = 'sv_extra_projectile'
self.system_message = False
self.header: ChunkHeader
self.projectile: int = projectile
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.projectile = unpacker.get_int() # TODO: this is a snapshot object
return True
def pack(self) -> bytes:
return pack_int(self.projectile)

View file

@ -0,0 +1,44 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvGameInfo(PrettyPrint):
def __init__(
self,
game_flags: int = 0,
score_limit: int = 0,
time_limit: int = 0,
match_num: int = 0,
match_current: int = 0
) -> None:
self.message_name = 'sv_game_info'
self.system_message = False
self.header: ChunkHeader
self.game_flags: int = game_flags
self.score_limit: int = score_limit
self.time_limit: int = time_limit
self.match_num: int = match_num
self.match_current: int = match_current
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.game_flags = unpacker.get_int() # TODO: this is a flag
self.score_limit = unpacker.get_int()
self.time_limit = unpacker.get_int()
self.match_num = unpacker.get_int()
self.match_current = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.game_flags) + \
pack_int(self.score_limit) + \
pack_int(self.time_limit) + \
pack_int(self.match_num) + \
pack_int(self.match_current)

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgSvGameMsg(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'sv_game_msg'
self.system_message = False
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,40 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvKillMsg(PrettyPrint):
def __init__(
self,
killer: int = 0,
victim: int = 0,
weapon: int = 0,
mode_special: int = 0
) -> None:
self.message_name = 'sv_kill_msg'
self.system_message = False
self.header: ChunkHeader
self.killer: int = killer
self.victim: int = victim
self.weapon: int = weapon
self.mode_special: int = mode_special
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.killer = unpacker.get_int()
self.victim = unpacker.get_int()
self.weapon = unpacker.get_int()
self.mode_special = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.killer) + \
pack_int(self.victim) + \
pack_int(self.weapon) + \
pack_int(self.mode_special)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgSvMotd(PrettyPrint):
def __init__(
self,
message: str = 'default'
) -> None:
self.message_name = 'sv_motd'
self.system_message = False
self.header: ChunkHeader
self.message: str = message
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.message = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.message)

View file

@ -0,0 +1,44 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvRaceFinish(PrettyPrint):
def __init__(
self,
client_id: int = 0,
time: int = 0,
diff: int = 0,
record_personal: bool = False,
record_server: bool = False
) -> None:
self.message_name = 'sv_race_finish'
self.system_message = False
self.header: ChunkHeader
self.client_id: int = client_id
self.time: int = time
self.diff: int = diff
self.record_personal: bool = record_personal
self.record_server: bool = record_server
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.client_id = unpacker.get_int()
self.time = unpacker.get_int()
self.diff = unpacker.get_int()
self.record_personal = unpacker.get_int() == 1
self.record_server = unpacker.get_int() == 1
return True
def pack(self) -> bytes:
return pack_int(self.client_id) + \
pack_int(self.time) + \
pack_int(self.diff) + \
pack_int(self.record_personal) + \
pack_int(self.record_server)

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgSvReadyToEnter(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'sv_ready_to_enter'
self.system_message = False
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,48 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvServerSettings(PrettyPrint):
def __init__(
self,
kick_vote: bool = False,
kick_min: int = 0,
spec_vote: bool = False,
team_lock: bool = False,
team_balance: bool = False,
player_slots: int = 0
) -> None:
self.message_name = 'sv_server_settings'
self.system_message = False
self.header: ChunkHeader
self.kick_vote: bool = kick_vote
self.kick_min: int = kick_min
self.spec_vote: bool = spec_vote
self.team_lock: bool = team_lock
self.team_balance: bool = team_balance
self.player_slots: int = player_slots
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.kick_vote = unpacker.get_int() == 1
self.kick_min = unpacker.get_int()
self.spec_vote = unpacker.get_int() == 1
self.team_lock = unpacker.get_int() == 1
self.team_balance = unpacker.get_int() == 1
self.player_slots = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.kick_vote) + \
pack_int(self.kick_min) + \
pack_int(self.spec_vote) + \
pack_int(self.team_lock) + \
pack_int(self.team_balance) + \
pack_int(self.player_slots)

View file

@ -0,0 +1,40 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvSkinChange(PrettyPrint):
def __init__(
self,
client_id: int = 0,
skin_part_names: int = 0,
use_custom_colors: int = 0,
skin_part_colors: int = 0
) -> None:
self.message_name = 'sv_skin_change'
self.system_message = False
self.header: ChunkHeader
self.client_id: int = client_id
self.skin_part_names: int = skin_part_names
self.use_custom_colors: int = use_custom_colors
self.skin_part_colors: int = skin_part_colors
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.client_id = unpacker.get_int()
self.skin_part_names = unpacker.get_int() # TODO: this is an array
self.use_custom_colors = unpacker.get_int() # TODO: this is an array
self.skin_part_colors = unpacker.get_int() # TODO: this is an array
return True
def pack(self) -> bytes:
return pack_int(self.client_id) + \
pack_int(self.skin_part_names) + \
pack_int(self.use_custom_colors) + \
pack_int(self.skin_part_colors)

View file

@ -0,0 +1,40 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvTeam(PrettyPrint):
def __init__(
self,
client_id: int = 0,
team: int = 0,
silent: bool = False,
cooldown_tick: int = 0
) -> None:
self.message_name = 'sv_team'
self.system_message = False
self.header: ChunkHeader
self.client_id: int = client_id
self.team: int = team
self.silent: bool = silent
self.cooldown_tick: int = cooldown_tick
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.client_id = unpacker.get_int()
self.team = unpacker.get_int() # TODO: this is a enum
self.silent = unpacker.get_int() == 1
self.cooldown_tick = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.client_id) + \
pack_int(self.team) + \
pack_int(self.silent) + \
pack_int(self.cooldown_tick)

View file

@ -0,0 +1,152 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvTuneParams(PrettyPrint):
def __init__(
self,
ground_control_speed: int = 0,
ground_control_accel: int = 0,
ground_friction: int = 0,
ground_jump_impulse: int = 0,
air_jump_impulse: int = 0,
air_control_speed: int = 0,
air_control_accel: int = 0,
air_friction: int = 0,
hook_length: int = 0,
hook_fire_speed: int = 0,
hook_drag_accel: int = 0,
hook_drag_speed: int = 0,
gravity: int = 0,
velramp_start: int = 0,
velramp_range: int = 0,
velramp_curvature: int = 0,
gun_curvature: int = 0,
gun_speed: int = 0,
gun_lifetime: int = 0,
shotgun_curvature: int = 0,
shotgun_speed: int = 0,
shotgun_speeddiff: int = 0,
shotgun_lifetime: int = 0,
grenade_curvature: int = 0,
grenade_speed: int = 0,
grenade_lifetime: int = 0,
laser_reach: int = 0,
laser_bounce_delay: int = 0,
laser_bounce_num: int = 0,
laser_bounce_cost: int = 0,
player_collision: int = 0,
player_hooking: int = 0
) -> None:
self.message_name = 'sv_tune_params'
self.system_message = False
self.header: ChunkHeader
self.ground_control_speed: int = ground_control_speed
self.ground_control_accel: int = ground_control_accel
self.ground_friction: int = ground_friction
self.ground_jump_impulse: int = ground_jump_impulse
self.air_jump_impulse: int = air_jump_impulse
self.air_control_speed: int = air_control_speed
self.air_control_accel: int = air_control_accel
self.air_friction: int = air_friction
self.hook_length: int = hook_length
self.hook_fire_speed: int = hook_fire_speed
self.hook_drag_accel: int = hook_drag_accel
self.hook_drag_speed: int = hook_drag_speed
self.gravity: int = gravity
self.velramp_start: int = velramp_start
self.velramp_range: int = velramp_range
self.velramp_curvature: int = velramp_curvature
self.gun_curvature: int = gun_curvature
self.gun_speed: int = gun_speed
self.gun_lifetime: int = gun_lifetime
self.shotgun_curvature: int = shotgun_curvature
self.shotgun_speed: int = shotgun_speed
self.shotgun_speeddiff: int = shotgun_speeddiff
self.shotgun_lifetime: int = shotgun_lifetime
self.grenade_curvature: int = grenade_curvature
self.grenade_speed: int = grenade_speed
self.grenade_lifetime: int = grenade_lifetime
self.laser_reach: int = laser_reach
self.laser_bounce_delay: int = laser_bounce_delay
self.laser_bounce_num: int = laser_bounce_num
self.laser_bounce_cost: int = laser_bounce_cost
self.player_collision: int = player_collision
self.player_hooking: int = player_hooking
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.ground_control_speed = unpacker.get_int() # TODO: this is a tune param
self.ground_control_accel = unpacker.get_int() # TODO: this is a tune param
self.ground_friction = unpacker.get_int() # TODO: this is a tune param
self.ground_jump_impulse = unpacker.get_int() # TODO: this is a tune param
self.air_jump_impulse = unpacker.get_int() # TODO: this is a tune param
self.air_control_speed = unpacker.get_int() # TODO: this is a tune param
self.air_control_accel = unpacker.get_int() # TODO: this is a tune param
self.air_friction = unpacker.get_int() # TODO: this is a tune param
self.hook_length = unpacker.get_int() # TODO: this is a tune param
self.hook_fire_speed = unpacker.get_int() # TODO: this is a tune param
self.hook_drag_accel = unpacker.get_int() # TODO: this is a tune param
self.hook_drag_speed = unpacker.get_int() # TODO: this is a tune param
self.gravity = unpacker.get_int() # TODO: this is a tune param
self.velramp_start = unpacker.get_int() # TODO: this is a tune param
self.velramp_range = unpacker.get_int() # TODO: this is a tune param
self.velramp_curvature = unpacker.get_int() # TODO: this is a tune param
self.gun_curvature = unpacker.get_int() # TODO: this is a tune param
self.gun_speed = unpacker.get_int() # TODO: this is a tune param
self.gun_lifetime = unpacker.get_int() # TODO: this is a tune param
self.shotgun_curvature = unpacker.get_int() # TODO: this is a tune param
self.shotgun_speed = unpacker.get_int() # TODO: this is a tune param
self.shotgun_speeddiff = unpacker.get_int() # TODO: this is a tune param
self.shotgun_lifetime = unpacker.get_int() # TODO: this is a tune param
self.grenade_curvature = unpacker.get_int() # TODO: this is a tune param
self.grenade_speed = unpacker.get_int() # TODO: this is a tune param
self.grenade_lifetime = unpacker.get_int() # TODO: this is a tune param
self.laser_reach = unpacker.get_int() # TODO: this is a tune param
self.laser_bounce_delay = unpacker.get_int() # TODO: this is a tune param
self.laser_bounce_num = unpacker.get_int() # TODO: this is a tune param
self.laser_bounce_cost = unpacker.get_int() # TODO: this is a tune param
self.player_collision = unpacker.get_int() # TODO: this is a tune param
self.player_hooking = unpacker.get_int() # TODO: this is a tune param
return True
def pack(self) -> bytes:
return pack_int(self.ground_control_speed) + \
pack_int(self.ground_control_accel) + \
pack_int(self.ground_friction) + \
pack_int(self.ground_jump_impulse) + \
pack_int(self.air_jump_impulse) + \
pack_int(self.air_control_speed) + \
pack_int(self.air_control_accel) + \
pack_int(self.air_friction) + \
pack_int(self.hook_length) + \
pack_int(self.hook_fire_speed) + \
pack_int(self.hook_drag_accel) + \
pack_int(self.hook_drag_speed) + \
pack_int(self.gravity) + \
pack_int(self.velramp_start) + \
pack_int(self.velramp_range) + \
pack_int(self.velramp_curvature) + \
pack_int(self.gun_curvature) + \
pack_int(self.gun_speed) + \
pack_int(self.gun_lifetime) + \
pack_int(self.shotgun_curvature) + \
pack_int(self.shotgun_speed) + \
pack_int(self.shotgun_speeddiff) + \
pack_int(self.shotgun_lifetime) + \
pack_int(self.grenade_curvature) + \
pack_int(self.grenade_speed) + \
pack_int(self.grenade_lifetime) + \
pack_int(self.laser_reach) + \
pack_int(self.laser_bounce_delay) + \
pack_int(self.laser_bounce_num) + \
pack_int(self.laser_bounce_cost) + \
pack_int(self.player_collision) + \
pack_int(self.player_hooking)

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgSvVoteClearOptions(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'sv_vote_clear_options'
self.system_message = False
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgSvVoteOptionAdd(PrettyPrint):
def __init__(
self,
description: str = 'default'
) -> None:
self.message_name = 'sv_vote_option_add'
self.system_message = False
self.header: ChunkHeader
self.description: str = description
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.description = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.description)

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgSvVoteOptionListAdd(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'sv_vote_option_list_add'
self.system_message = False
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgSvVoteOptionRemove(PrettyPrint):
def __init__(
self,
description: str = 'default'
) -> None:
self.message_name = 'sv_vote_option_remove'
self.system_message = False
self.header: ChunkHeader
self.description: str = description
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.description = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.description)

View file

@ -0,0 +1,44 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgSvVoteSet(PrettyPrint):
def __init__(
self,
client_id: int = 0,
type: int = 0,
timeout: int = 0,
description: str = 'default',
reason: str = 'default'
) -> None:
self.message_name = 'sv_vote_set'
self.system_message = False
self.header: ChunkHeader
self.client_id: int = client_id
self.type: int = type
self.timeout: int = timeout
self.description: str = description
self.reason: str = reason
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.client_id = unpacker.get_int()
self.type = unpacker.get_int() # TODO: this is a enum
self.timeout = unpacker.get_int()
self.description = unpacker.get_str()
self.reason = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_int(self.client_id) + \
pack_int(self.type) + \
pack_int(self.timeout) + \
pack_str(self.description) + \
pack_str(self.reason)

View file

@ -0,0 +1,40 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvVoteStatus(PrettyPrint):
def __init__(
self,
yes: int = 0,
no: int = 0,
pass_: int = 0,
total: int = 0
) -> None:
self.message_name = 'sv_vote_status'
self.system_message = False
self.header: ChunkHeader
self.yes: int = yes
self.no: int = no
self.pass_: int = pass_
self.total: int = total
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.yes = unpacker.get_int()
self.no = unpacker.get_int()
self.pass_ = unpacker.get_int()
self.total = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.yes) + \
pack_int(self.no) + \
pack_int(self.pass_) + \
pack_int(self.total)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSvWeaponPickup(PrettyPrint):
def __init__(
self,
weapon: int = 0
) -> None:
self.message_name = 'sv_weapon_pickup'
self.system_message = False
self.header: ChunkHeader
self.weapon: int = weapon
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.weapon = unpacker.get_int() # TODO: this is a enum
return True
def pack(self) -> bytes:
return pack_int(self.weapon)

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgConReady(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'con_ready'
self.system_message = True
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgEnterGame(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'enter_game'
self.system_message = True
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,36 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int, pack_str
class MsgInfo(PrettyPrint):
def __init__(
self,
version: str = 'default',
password: int = 0,
client_version: int = 0
) -> None:
self.message_name = 'info'
self.system_message = True
self.header: ChunkHeader
self.version: str = version
self.password: int = password
self.client_version: int = client_version
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.version = unpacker.get_str()
self.password = unpacker.get_int() # TODO: this is a optional of type any
self.client_version = unpacker.get_int() # TODO: this is a optional of type any
return True
def pack(self) -> bytes:
return pack_str(self.version) + \
pack_int(self.password) + \
pack_int(self.client_version)

View file

@ -0,0 +1,40 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgInput(PrettyPrint):
def __init__(
self,
ack_snapshot: int = 0,
intended_tick: int = 0,
input_size: int = 0,
input: int = 0
) -> None:
self.message_name = 'input'
self.system_message = True
self.header: ChunkHeader
self.ack_snapshot: int = ack_snapshot
self.intended_tick: int = intended_tick
self.input_size: int = input_size
self.input: int = input
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.ack_snapshot = unpacker.get_int()
self.intended_tick = unpacker.get_int()
self.input_size = unpacker.get_int()
self.input = unpacker.get_int() # TODO: this is a snapshot object
return True
def pack(self) -> bytes:
return pack_int(self.ack_snapshot) + \
pack_int(self.intended_tick) + \
pack_int(self.input_size) + \
pack_int(self.input)

View file

@ -0,0 +1,32 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgInputTiming(PrettyPrint):
def __init__(
self,
input_pred_tick: int = 0,
time_left: int = 0
) -> None:
self.message_name = 'input_timing'
self.system_message = True
self.header: ChunkHeader
self.input_pred_tick: int = input_pred_tick
self.time_left: int = time_left
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.input_pred_tick = unpacker.get_int()
self.time_left = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.input_pred_tick) + \
pack_int(self.time_left)

View file

@ -3,7 +3,7 @@
from twnet_parser.pretty_print import PrettyPrint from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str, pack_int from twnet_parser.packer import pack_int, pack_str
class MsgMapChange(PrettyPrint): class MsgMapChange(PrettyPrint):
def __init__( def __init__(

View file

@ -0,0 +1,27 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgMapData(PrettyPrint):
def __init__(
self,
data: bytes = b'\x00'
) -> None:
self.message_name = 'map_data'
self.system_message = True
self.header: ChunkHeader
self.data: bytes = data
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.data = unpacker.get_raw()
return True
def pack(self) -> bytes:
return self.data

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgMaplistEntryAdd(PrettyPrint):
def __init__(
self,
name: str = 'default'
) -> None:
self.message_name = 'maplist_entry_add'
self.system_message = True
self.header: ChunkHeader
self.name: str = name
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.name)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgMaplistEntryRem(PrettyPrint):
def __init__(
self,
name: str = 'default'
) -> None:
self.message_name = 'maplist_entry_rem'
self.system_message = True
self.header: ChunkHeader
self.name: str = name
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.name)

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgPing(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'ping'
self.system_message = True
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgPingReply(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'ping_reply'
self.system_message = True
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgRconAuth(PrettyPrint):
def __init__(
self,
password: str = 'default'
) -> None:
self.message_name = 'rcon_auth'
self.system_message = True
self.header: ChunkHeader
self.password: str = password
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.password = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.password)

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgRconAuthOff(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'rcon_auth_off'
self.system_message = True
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgRconAuthOn(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'rcon_auth_on'
self.system_message = True
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgRconCmd(PrettyPrint):
def __init__(
self,
cmd: str = 'default'
) -> None:
self.message_name = 'rcon_cmd'
self.system_message = True
self.header: ChunkHeader
self.cmd: str = cmd
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.cmd = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.cmd)

View file

@ -0,0 +1,36 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgRconCmdAdd(PrettyPrint):
def __init__(
self,
name: str = 'default',
help: str = 'default',
params: str = 'default'
) -> None:
self.message_name = 'rcon_cmd_add'
self.system_message = True
self.header: ChunkHeader
self.name: str = name
self.help: str = help
self.params: str = params
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
self.help = unpacker.get_str()
self.params = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.name) + \
pack_str(self.help) + \
pack_str(self.params)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgRconCmdRem(PrettyPrint):
def __init__(
self,
name: str = 'default'
) -> None:
self.message_name = 'rcon_cmd_rem'
self.system_message = True
self.header: ChunkHeader
self.name: str = name
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.name = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.name)

View file

@ -0,0 +1,28 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_str
class MsgRconLine(PrettyPrint):
def __init__(
self,
line: str = 'default'
) -> None:
self.message_name = 'rcon_line'
self.system_message = True
self.header: ChunkHeader
self.line: str = line
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.line = unpacker.get_str()
return True
def pack(self) -> bytes:
return pack_str(self.line)

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgReady(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'ready'
self.system_message = True
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,25 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgRequestMapData(PrettyPrint):
def __init__(
self,
) -> None:
self.message_name = 'request_map_data'
self.system_message = True
self.header: ChunkHeader
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
return True
def pack(self) -> bytes:
return b''

View file

@ -0,0 +1,27 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
class MsgServerInfo(PrettyPrint):
def __init__(
self,
data: bytes = b'\x00'
) -> None:
self.message_name = 'server_info'
self.system_message = True
self.header: ChunkHeader
self.data: bytes = data
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.data = unpacker.get_raw()
return True
def pack(self) -> bytes:
return self.data

View file

@ -0,0 +1,48 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSnap(PrettyPrint):
def __init__(
self,
tick: int = 0,
delta_tick: int = 0,
num_parts: int = 0,
part: int = 0,
crc: int = 0,
data: bytes = b'\x00'
) -> None:
self.message_name = 'snap'
self.system_message = True
self.header: ChunkHeader
self.tick: int = tick
self.delta_tick: int = delta_tick
self.num_parts: int = num_parts
self.part: int = part
self.crc: int = crc
self.data: bytes = data
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.tick = unpacker.get_int()
self.delta_tick = unpacker.get_int()
self.num_parts = unpacker.get_int()
self.part = unpacker.get_int()
self.crc = unpacker.get_int()
self.data = unpacker.get_raw()
return True
def pack(self) -> bytes:
return pack_int(self.tick) + \
pack_int(self.delta_tick) + \
pack_int(self.num_parts) + \
pack_int(self.part) + \
pack_int(self.crc) + \
self.data

View file

@ -0,0 +1,32 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSnapEmpty(PrettyPrint):
def __init__(
self,
tick: int = 0,
delta_tick: int = 0
) -> None:
self.message_name = 'snap_empty'
self.system_message = True
self.header: ChunkHeader
self.tick: int = tick
self.delta_tick: int = delta_tick
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.tick = unpacker.get_int()
self.delta_tick = unpacker.get_int()
return True
def pack(self) -> bytes:
return pack_int(self.tick) + \
pack_int(self.delta_tick)

View file

@ -0,0 +1,40 @@
# generated by scripts/generate_messages.py
from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from twnet_parser.packer import pack_int
class MsgSnapSingle(PrettyPrint):
def __init__(
self,
tick: int = 0,
delta_tick: int = 0,
crc: int = 0,
data: bytes = b'\x00'
) -> None:
self.message_name = 'snap_single'
self.system_message = True
self.header: ChunkHeader
self.tick: int = tick
self.delta_tick: int = delta_tick
self.crc: int = crc
self.data: bytes = data
# first byte of data
# has to be the first byte of the message payload
# NOT the chunk header and NOT the message id
def unpack(self, data: bytes) -> bool:
unpacker = Unpacker(data)
self.tick = unpacker.get_int()
self.delta_tick = unpacker.get_int()
self.crc = unpacker.get_int()
self.data = unpacker.get_raw()
return True
def pack(self) -> bytes:
return pack_int(self.tick) + \
pack_int(self.delta_tick) + \
pack_int(self.crc) + \
self.data

View file

@ -0,0 +1,172 @@
# generated by scripts/generate_messages.py
from typing import Optional
import twnet_parser.msg7
from twnet_parser.net_message import NetMessage
import twnet_parser.messages7.game.sv_motd as \
game7_sv_motd
import twnet_parser.messages7.game.sv_broadcast as \
game7_sv_broadcast
import twnet_parser.messages7.game.sv_chat as \
game7_sv_chat
import twnet_parser.messages7.game.sv_team as \
game7_sv_team
import twnet_parser.messages7.game.sv_kill_msg as \
game7_sv_kill_msg
import twnet_parser.messages7.game.sv_tune_params as \
game7_sv_tune_params
import twnet_parser.messages7.game.sv_extra_projectile as \
game7_sv_extra_projectile
import twnet_parser.messages7.game.sv_ready_to_enter as \
game7_sv_ready_to_enter
import twnet_parser.messages7.game.sv_weapon_pickup as \
game7_sv_weapon_pickup
import twnet_parser.messages7.game.sv_emoticon as \
game7_sv_emoticon
import twnet_parser.messages7.game.sv_vote_clear_options as \
game7_sv_vote_clear_options
import twnet_parser.messages7.game.sv_vote_option_list_add as \
game7_sv_vote_option_list_add
import twnet_parser.messages7.game.sv_vote_option_add as \
game7_sv_vote_option_add
import twnet_parser.messages7.game.sv_vote_option_remove as \
game7_sv_vote_option_remove
import twnet_parser.messages7.game.sv_vote_set as \
game7_sv_vote_set
import twnet_parser.messages7.game.sv_vote_status as \
game7_sv_vote_status
import twnet_parser.messages7.game.sv_server_settings as \
game7_sv_server_settings
import twnet_parser.messages7.game.sv_client_info as \
game7_sv_client_info
import twnet_parser.messages7.game.sv_game_info as \
game7_sv_game_info
import twnet_parser.messages7.game.sv_client_drop as \
game7_sv_client_drop
import twnet_parser.messages7.game.sv_game_msg as \
game7_sv_game_msg
import twnet_parser.messages7.game.de_client_enter as \
game7_de_client_enter
import twnet_parser.messages7.game.de_client_leave as \
game7_de_client_leave
import twnet_parser.messages7.game.cl_say as \
game7_cl_say
import twnet_parser.messages7.game.cl_set_team as \
game7_cl_set_team
import twnet_parser.messages7.game.cl_set_spectator_mode as \
game7_cl_set_spectator_mode
import twnet_parser.messages7.game.cl_start_info as \
game7_cl_start_info
import twnet_parser.messages7.game.cl_kill as \
game7_cl_kill
import twnet_parser.messages7.game.cl_ready_change as \
game7_cl_ready_change
import twnet_parser.messages7.game.cl_emoticon as \
game7_cl_emoticon
import twnet_parser.messages7.game.cl_vote as \
game7_cl_vote
import twnet_parser.messages7.game.cl_call_vote as \
game7_cl_call_vote
import twnet_parser.messages7.game.sv_skin_change as \
game7_sv_skin_change
import twnet_parser.messages7.game.cl_skin_change as \
game7_cl_skin_change
import twnet_parser.messages7.game.sv_race_finish as \
game7_sv_race_finish
import twnet_parser.messages7.game.sv_checkpoint as \
game7_sv_checkpoint
import twnet_parser.messages7.game.sv_command_info as \
game7_sv_command_info
import twnet_parser.messages7.game.sv_command_info_remove as \
game7_sv_command_info_remove
import twnet_parser.messages7.game.cl_command as \
game7_cl_command
def match_game7(msg_id: int, data: bytes) -> NetMessage:
msg: Optional[NetMessage] = None
if msg_id == twnet_parser.msg7.SV_MOTD:
msg = game7_sv_motd.MsgSvMotd()
elif msg_id == twnet_parser.msg7.SV_BROADCAST:
msg = game7_sv_broadcast.MsgSvBroadcast()
elif msg_id == twnet_parser.msg7.SV_CHAT:
msg = game7_sv_chat.MsgSvChat()
elif msg_id == twnet_parser.msg7.SV_TEAM:
msg = game7_sv_team.MsgSvTeam()
elif msg_id == twnet_parser.msg7.SV_KILL_MSG:
msg = game7_sv_kill_msg.MsgSvKillMsg()
elif msg_id == twnet_parser.msg7.SV_TUNE_PARAMS:
msg = game7_sv_tune_params.MsgSvTuneParams()
elif msg_id == twnet_parser.msg7.SV_EXTRA_PROJECTILE:
msg = game7_sv_extra_projectile.MsgSvExtraProjectile()
elif msg_id == twnet_parser.msg7.SV_READY_TO_ENTER:
msg = game7_sv_ready_to_enter.MsgSvReadyToEnter()
elif msg_id == twnet_parser.msg7.SV_WEAPON_PICKUP:
msg = game7_sv_weapon_pickup.MsgSvWeaponPickup()
elif msg_id == twnet_parser.msg7.SV_EMOTICON:
msg = game7_sv_emoticon.MsgSvEmoticon()
elif msg_id == twnet_parser.msg7.SV_VOTE_CLEAR_OPTIONS:
msg = game7_sv_vote_clear_options.MsgSvVoteClearOptions()
elif msg_id == twnet_parser.msg7.SV_VOTE_OPTION_LIST_ADD:
msg = game7_sv_vote_option_list_add.MsgSvVoteOptionListAdd()
elif msg_id == twnet_parser.msg7.SV_VOTE_OPTION_ADD:
msg = game7_sv_vote_option_add.MsgSvVoteOptionAdd()
elif msg_id == twnet_parser.msg7.SV_VOTE_OPTION_REMOVE:
msg = game7_sv_vote_option_remove.MsgSvVoteOptionRemove()
elif msg_id == twnet_parser.msg7.SV_VOTE_SET:
msg = game7_sv_vote_set.MsgSvVoteSet()
elif msg_id == twnet_parser.msg7.SV_VOTE_STATUS:
msg = game7_sv_vote_status.MsgSvVoteStatus()
elif msg_id == twnet_parser.msg7.SV_SERVER_SETTINGS:
msg = game7_sv_server_settings.MsgSvServerSettings()
elif msg_id == twnet_parser.msg7.SV_CLIENT_INFO:
msg = game7_sv_client_info.MsgSvClientInfo()
elif msg_id == twnet_parser.msg7.SV_GAME_INFO:
msg = game7_sv_game_info.MsgSvGameInfo()
elif msg_id == twnet_parser.msg7.SV_CLIENT_DROP:
msg = game7_sv_client_drop.MsgSvClientDrop()
elif msg_id == twnet_parser.msg7.SV_GAME_MSG:
msg = game7_sv_game_msg.MsgSvGameMsg()
elif msg_id == twnet_parser.msg7.DE_CLIENT_ENTER:
msg = game7_de_client_enter.MsgDeClientEnter()
elif msg_id == twnet_parser.msg7.DE_CLIENT_LEAVE:
msg = game7_de_client_leave.MsgDeClientLeave()
elif msg_id == twnet_parser.msg7.CL_SAY:
msg = game7_cl_say.MsgClSay()
elif msg_id == twnet_parser.msg7.CL_SET_TEAM:
msg = game7_cl_set_team.MsgClSetTeam()
elif msg_id == twnet_parser.msg7.CL_SET_SPECTATOR_MODE:
msg = game7_cl_set_spectator_mode.MsgClSetSpectatorMode()
elif msg_id == twnet_parser.msg7.CL_START_INFO:
msg = game7_cl_start_info.MsgClStartInfo()
elif msg_id == twnet_parser.msg7.CL_KILL:
msg = game7_cl_kill.MsgClKill()
elif msg_id == twnet_parser.msg7.CL_READY_CHANGE:
msg = game7_cl_ready_change.MsgClReadyChange()
elif msg_id == twnet_parser.msg7.CL_EMOTICON:
msg = game7_cl_emoticon.MsgClEmoticon()
elif msg_id == twnet_parser.msg7.CL_VOTE:
msg = game7_cl_vote.MsgClVote()
elif msg_id == twnet_parser.msg7.CL_CALL_VOTE:
msg = game7_cl_call_vote.MsgClCallVote()
elif msg_id == twnet_parser.msg7.SV_SKIN_CHANGE:
msg = game7_sv_skin_change.MsgSvSkinChange()
elif msg_id == twnet_parser.msg7.CL_SKIN_CHANGE:
msg = game7_cl_skin_change.MsgClSkinChange()
elif msg_id == twnet_parser.msg7.SV_RACE_FINISH:
msg = game7_sv_race_finish.MsgSvRaceFinish()
elif msg_id == twnet_parser.msg7.SV_CHECKPOINT:
msg = game7_sv_checkpoint.MsgSvCheckpoint()
elif msg_id == twnet_parser.msg7.SV_COMMAND_INFO:
msg = game7_sv_command_info.MsgSvCommandInfo()
elif msg_id == twnet_parser.msg7.SV_COMMAND_INFO_REMOVE:
msg = game7_sv_command_info_remove.MsgSvCommandInfoRemove()
elif msg_id == twnet_parser.msg7.CL_COMMAND:
msg = game7_cl_command.MsgClCommand()
if msg is None:
raise ValueError(f"Error: unknown game message id={msg_id} data={data[0]}")
msg.unpack(data)
return msg

View file

@ -0,0 +1,112 @@
# generated by scripts/generate_messages.py
from typing import Optional
import twnet_parser.msg7
from twnet_parser.net_message import NetMessage
import twnet_parser.messages7.system.info as \
system7_info
import twnet_parser.messages7.system.map_change as \
system7_map_change
import twnet_parser.messages7.system.map_data as \
system7_map_data
import twnet_parser.messages7.system.server_info as \
system7_server_info
import twnet_parser.messages7.system.con_ready as \
system7_con_ready
import twnet_parser.messages7.system.snap as \
system7_snap
import twnet_parser.messages7.system.snap_empty as \
system7_snap_empty
import twnet_parser.messages7.system.snap_single as \
system7_snap_single
import twnet_parser.messages7.system.input_timing as \
system7_input_timing
import twnet_parser.messages7.system.rcon_auth_on as \
system7_rcon_auth_on
import twnet_parser.messages7.system.rcon_auth_off as \
system7_rcon_auth_off
import twnet_parser.messages7.system.rcon_line as \
system7_rcon_line
import twnet_parser.messages7.system.rcon_cmd_add as \
system7_rcon_cmd_add
import twnet_parser.messages7.system.rcon_cmd_rem as \
system7_rcon_cmd_rem
import twnet_parser.messages7.system.ready as \
system7_ready
import twnet_parser.messages7.system.enter_game as \
system7_enter_game
import twnet_parser.messages7.system.input as \
system7_input
import twnet_parser.messages7.system.rcon_cmd as \
system7_rcon_cmd
import twnet_parser.messages7.system.rcon_auth as \
system7_rcon_auth
import twnet_parser.messages7.system.request_map_data as \
system7_request_map_data
import twnet_parser.messages7.system.ping as \
system7_ping
import twnet_parser.messages7.system.ping_reply as \
system7_ping_reply
import twnet_parser.messages7.system.maplist_entry_add as \
system7_maplist_entry_add
import twnet_parser.messages7.system.maplist_entry_rem as \
system7_maplist_entry_rem
def match_system7(msg_id: int, data: bytes) -> NetMessage:
msg: Optional[NetMessage] = None
if msg_id == twnet_parser.msg7.INFO:
msg = system7_info.MsgInfo()
elif msg_id == twnet_parser.msg7.MAP_CHANGE:
msg = system7_map_change.MsgMapChange()
elif msg_id == twnet_parser.msg7.MAP_DATA:
msg = system7_map_data.MsgMapData()
elif msg_id == twnet_parser.msg7.SERVER_INFO:
msg = system7_server_info.MsgServerInfo()
elif msg_id == twnet_parser.msg7.CON_READY:
msg = system7_con_ready.MsgConReady()
elif msg_id == twnet_parser.msg7.SNAP:
msg = system7_snap.MsgSnap()
elif msg_id == twnet_parser.msg7.SNAP_EMPTY:
msg = system7_snap_empty.MsgSnapEmpty()
elif msg_id == twnet_parser.msg7.SNAP_SINGLE:
msg = system7_snap_single.MsgSnapSingle()
elif msg_id == twnet_parser.msg7.INPUT_TIMING:
msg = system7_input_timing.MsgInputTiming()
elif msg_id == twnet_parser.msg7.RCON_AUTH_ON:
msg = system7_rcon_auth_on.MsgRconAuthOn()
elif msg_id == twnet_parser.msg7.RCON_AUTH_OFF:
msg = system7_rcon_auth_off.MsgRconAuthOff()
elif msg_id == twnet_parser.msg7.RCON_LINE:
msg = system7_rcon_line.MsgRconLine()
elif msg_id == twnet_parser.msg7.RCON_CMD_ADD:
msg = system7_rcon_cmd_add.MsgRconCmdAdd()
elif msg_id == twnet_parser.msg7.RCON_CMD_REM:
msg = system7_rcon_cmd_rem.MsgRconCmdRem()
elif msg_id == twnet_parser.msg7.READY:
msg = system7_ready.MsgReady()
elif msg_id == twnet_parser.msg7.ENTER_GAME:
msg = system7_enter_game.MsgEnterGame()
elif msg_id == twnet_parser.msg7.INPUT:
msg = system7_input.MsgInput()
elif msg_id == twnet_parser.msg7.RCON_CMD:
msg = system7_rcon_cmd.MsgRconCmd()
elif msg_id == twnet_parser.msg7.RCON_AUTH:
msg = system7_rcon_auth.MsgRconAuth()
elif msg_id == twnet_parser.msg7.REQUEST_MAP_DATA:
msg = system7_request_map_data.MsgRequestMapData()
elif msg_id == twnet_parser.msg7.PING:
msg = system7_ping.MsgPing()
elif msg_id == twnet_parser.msg7.PING_REPLY:
msg = system7_ping_reply.MsgPingReply()
elif msg_id == twnet_parser.msg7.MAPLIST_ENTRY_ADD:
msg = system7_maplist_entry_add.MsgMaplistEntryAdd()
elif msg_id == twnet_parser.msg7.MAPLIST_ENTRY_REM:
msg = system7_maplist_entry_rem.MsgMaplistEntryRem()
if msg is None:
raise ValueError(f"Error: unknown system message id={msg_id} data={data[0]}")
msg.unpack(data)
return msg