Include ids in message classes
This commit is contained in:
parent
65cac66724
commit
6a351073d3
|
@ -533,9 +533,10 @@ class CodeGenerator():
|
|||
self.write_init_method_header(out_file, msg, game, name_snake)
|
||||
else:
|
||||
out_file.write(' def __init__(self) -> None:\n')
|
||||
out_file.write(f" self.message_name = '{name_snake}'\n")
|
||||
out_file.write(f" self.message_name: str = '{name_snake}'\n")
|
||||
sys: str = 'True' if game == 'system' else 'False'
|
||||
out_file.write(f" self.system_message = {sys}\n")
|
||||
out_file.write(f" self.system_message: bool = {sys}\n")
|
||||
out_file.write(f" self.message_id: int = {msg['id']}\n")
|
||||
out_file.write(" self.header: ChunkHeader\n")
|
||||
out_file.write('\n')
|
||||
for member in msg['members']:
|
||||
|
|
|
@ -2,6 +2,7 @@ from typing import Protocol
|
|||
|
||||
class CtrlMessage(Protocol):
|
||||
message_name: str
|
||||
message_id: int
|
||||
def unpack(self, data: bytes, we_are_a_client: bool = False) -> bool:
|
||||
...
|
||||
def pack(self) -> bytes:
|
||||
|
|
|
@ -2,7 +2,8 @@ from twnet_parser.pretty_print import PrettyPrint
|
|||
|
||||
class CtrlAccept(PrettyPrint):
|
||||
def __init__(self) -> None:
|
||||
self.message_name = 'accept'
|
||||
self.message_name: str = 'accept'
|
||||
self.message_id: int = 2
|
||||
|
||||
def unpack(self, data: bytes, we_are_a_client: bool = False) -> bool:
|
||||
return False
|
||||
|
|
|
@ -9,7 +9,9 @@ class CtrlClose(PrettyPrint):
|
|||
self,
|
||||
reason: Optional[str] = None
|
||||
) -> None:
|
||||
self.message_name = 'close'
|
||||
self.message_name: str = 'close'
|
||||
self.message_id: int = 4
|
||||
|
||||
self.reason: Optional[str] = reason
|
||||
|
||||
# first byte of data
|
||||
|
|
|
@ -5,7 +5,9 @@ class CtrlConnect(PrettyPrint):
|
|||
self,
|
||||
response_token: bytes = b'\xff\xff\xff\xff'
|
||||
) -> None:
|
||||
self.message_name = 'connect'
|
||||
self.message_name: str = 'connect'
|
||||
self.message_id: int = 1
|
||||
|
||||
self.response_token: bytes = response_token
|
||||
|
||||
def unpack(self, data: bytes, we_are_a_client: bool = False) -> bool:
|
||||
|
|
|
@ -2,7 +2,8 @@ from twnet_parser.pretty_print import PrettyPrint
|
|||
|
||||
class CtrlKeepAlive(PrettyPrint):
|
||||
def __init__(self) -> None:
|
||||
self.message_name = 'keep_alive'
|
||||
self.message_name: str = 'keep_alive'
|
||||
self.message_id: int = 0
|
||||
|
||||
def unpack(self, data: bytes, we_are_a_client: bool = False) -> bool:
|
||||
return False
|
||||
|
|
|
@ -5,7 +5,9 @@ class CtrlToken(PrettyPrint):
|
|||
self,
|
||||
response_token: bytes = b'\xff\xff\xff\xff'
|
||||
) -> None:
|
||||
self.message_name = 'token'
|
||||
self.message_name: str = 'token'
|
||||
self.message_id: int = 5
|
||||
|
||||
self.response_token: bytes = response_token
|
||||
|
||||
def unpack(self, data: bytes, we_are_a_client: bool = False) -> bool:
|
||||
|
|
|
@ -13,8 +13,9 @@ class MsgClCallVote(PrettyPrint):
|
|||
reason: str = 'default',
|
||||
force: bool = False
|
||||
) -> None:
|
||||
self.message_name = 'cl_call_vote'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_call_vote'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 32
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.type: str = type
|
||||
|
|
|
@ -11,8 +11,9 @@ class MsgClCommand(PrettyPrint):
|
|||
name: str = 'default',
|
||||
arguments: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'cl_command'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_command'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 39
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -11,8 +11,9 @@ class MsgClEmoticon(PrettyPrint):
|
|||
self,
|
||||
emoticon: int = enum7.Emoticon.OOP.value
|
||||
) -> None:
|
||||
self.message_name = 'cl_emoticon'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_emoticon'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 30
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.emoticon: int = emoticon
|
||||
|
|
|
@ -5,8 +5,9 @@ from twnet_parser.chunk_header import ChunkHeader
|
|||
|
||||
class MsgClKill(PrettyPrint):
|
||||
def __init__(self) -> None:
|
||||
self.message_name = 'cl_kill'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_kill'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 28
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ 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.message_name: str = 'cl_ready_change'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 29
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -13,8 +13,9 @@ class MsgClSay(PrettyPrint):
|
|||
target: int = 0,
|
||||
message: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'cl_say'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_say'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 24
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.mode: int = mode
|
||||
|
|
|
@ -12,8 +12,9 @@ class MsgClSetSpectatorMode(PrettyPrint):
|
|||
spec_mode: int = enum7.Spec.FREEVIEW.value,
|
||||
spectator_id: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'cl_set_spectator_mode'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_set_spectator_mode'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 26
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.spec_mode: int = spec_mode
|
||||
|
|
|
@ -11,8 +11,9 @@ class MsgClSetTeam(PrettyPrint):
|
|||
self,
|
||||
team: int = enum7.Team.SPECTATORS.value
|
||||
) -> None:
|
||||
self.message_name = 'cl_set_team'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_set_team'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 25
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.team: int = team
|
||||
|
|
|
@ -16,8 +16,9 @@ class MsgClSkinChange(PrettyPrint):
|
|||
skin_part_colors: Annotated[list[int], 6] = \
|
||||
[0, 0, 0, 0, 0, 0]
|
||||
) -> None:
|
||||
self.message_name = 'cl_skin_change'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_skin_change'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 34
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.skin_part_names = skin_part_names
|
||||
|
|
|
@ -19,8 +19,9 @@ class MsgClStartInfo(PrettyPrint):
|
|||
skin_part_colors: Annotated[list[int], 6] = \
|
||||
[0, 0, 0, 0, 0, 0]
|
||||
) -> None:
|
||||
self.message_name = 'cl_start_info'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_start_info'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 27
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgClVote(PrettyPrint):
|
|||
self,
|
||||
vote: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'cl_vote'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'cl_vote'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 31
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.vote: int = vote
|
||||
|
|
|
@ -13,8 +13,9 @@ class MsgDeClientEnter(PrettyPrint):
|
|||
client_id: int = 0,
|
||||
team: int = enum7.Team.SPECTATORS.value
|
||||
) -> None:
|
||||
self.message_name = 'de_client_enter'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'de_client_enter'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 22
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -12,8 +12,9 @@ class MsgDeClientLeave(PrettyPrint):
|
|||
client_id: int = 0,
|
||||
reason: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'de_client_leave'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'de_client_leave'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 23
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgSvBroadcast(PrettyPrint):
|
|||
self,
|
||||
message: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'sv_broadcast'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_broadcast'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 2
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.message: str = message
|
||||
|
|
|
@ -14,8 +14,9 @@ class MsgSvChat(PrettyPrint):
|
|||
target_id: int = 0,
|
||||
message: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'sv_chat'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_chat'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 3
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.mode: int = mode
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgSvCheckpoint(PrettyPrint):
|
|||
self,
|
||||
diff: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'sv_checkpoint'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_checkpoint'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 36
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.diff: int = diff
|
||||
|
|
|
@ -12,8 +12,9 @@ class MsgSvClientDrop(PrettyPrint):
|
|||
reason: str = 'default',
|
||||
silent: bool = False
|
||||
) -> None:
|
||||
self.message_name = 'sv_client_drop'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_client_drop'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 20
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.client_id: int = client_id
|
||||
|
|
|
@ -24,8 +24,9 @@ class MsgSvClientInfo(PrettyPrint):
|
|||
[0, 0, 0, 0, 0, 0],
|
||||
silent: bool = False
|
||||
) -> None:
|
||||
self.message_name = 'sv_client_info'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_client_info'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 18
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.client_id: int = client_id
|
||||
|
|
|
@ -12,8 +12,9 @@ class MsgSvCommandInfo(PrettyPrint):
|
|||
args_format: str = 'default',
|
||||
help_text: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'sv_command_info'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_command_info'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 37
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgSvCommandInfoRemove(PrettyPrint):
|
|||
self,
|
||||
name: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'sv_command_info_remove'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_command_info_remove'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 38
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -12,8 +12,9 @@ class MsgSvEmoticon(PrettyPrint):
|
|||
client_id: int = 0,
|
||||
emoticon: int = enum7.Emoticon.OOP.value
|
||||
) -> None:
|
||||
self.message_name = 'sv_emoticon'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_emoticon'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 10
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.client_id: int = client_id
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgSvExtraProjectile(PrettyPrint):
|
|||
self,
|
||||
projectile: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'sv_extra_projectile'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_extra_projectile'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 7
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.projectile: int = projectile
|
||||
|
|
|
@ -14,8 +14,9 @@ class MsgSvGameInfo(PrettyPrint):
|
|||
match_num: int = 0,
|
||||
match_current: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'sv_game_info'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_game_info'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 19
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.game_flags: int = game_flags
|
||||
|
|
|
@ -5,8 +5,9 @@ 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.message_name: str = 'sv_game_msg'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 21
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -13,8 +13,9 @@ class MsgSvKillMsg(PrettyPrint):
|
|||
weapon: int = 0,
|
||||
mode_special: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'sv_kill_msg'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_kill_msg'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 5
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.killer: int = killer
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgSvMotd(PrettyPrint):
|
|||
self,
|
||||
message: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'sv_motd'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_motd'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 1
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.message: str = message
|
||||
|
|
|
@ -14,8 +14,9 @@ class MsgSvRaceFinish(PrettyPrint):
|
|||
record_personal: bool = False,
|
||||
record_server: bool = False
|
||||
) -> None:
|
||||
self.message_name = 'sv_race_finish'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_race_finish'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 35
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.client_id: int = client_id
|
||||
|
|
|
@ -5,8 +5,9 @@ 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.message_name: str = 'sv_ready_to_enter'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 8
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@ class MsgSvServerSettings(PrettyPrint):
|
|||
team_balance: bool = False,
|
||||
player_slots: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'sv_server_settings'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_server_settings'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 17
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.kick_vote: bool = kick_vote
|
||||
|
|
|
@ -17,8 +17,9 @@ class MsgSvSkinChange(PrettyPrint):
|
|||
skin_part_colors: Annotated[list[int], 6] = \
|
||||
[0, 0, 0, 0, 0, 0]
|
||||
) -> None:
|
||||
self.message_name = 'sv_skin_change'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_skin_change'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 33
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.client_id: int = client_id
|
||||
|
|
|
@ -14,8 +14,9 @@ class MsgSvTeam(PrettyPrint):
|
|||
silent: bool = False,
|
||||
cooldown_tick: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'sv_team'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_team'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 4
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.client_id: int = client_id
|
||||
|
|
|
@ -41,8 +41,9 @@ class MsgSvTuneParams(PrettyPrint):
|
|||
player_collision: float = 1,
|
||||
player_hooking: float = 1
|
||||
) -> None:
|
||||
self.message_name = 'sv_tune_params'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_tune_params'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 6
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.ground_control_speed: float = ground_control_speed
|
||||
|
|
|
@ -5,8 +5,9 @@ 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.message_name: str = 'sv_vote_clear_options'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 11
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgSvVoteOptionAdd(PrettyPrint):
|
|||
self,
|
||||
description: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'sv_vote_option_add'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_vote_option_add'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 13
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.description: str = description
|
||||
|
|
|
@ -5,8 +5,9 @@ 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.message_name: str = 'sv_vote_option_list_add'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 12
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgSvVoteOptionRemove(PrettyPrint):
|
|||
self,
|
||||
description: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'sv_vote_option_remove'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_vote_option_remove'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 14
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.description: str = description
|
||||
|
|
|
@ -15,8 +15,9 @@ class MsgSvVoteSet(PrettyPrint):
|
|||
description: str = 'default',
|
||||
reason: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'sv_vote_set'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_vote_set'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 15
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.client_id: int = client_id
|
||||
|
|
|
@ -13,8 +13,9 @@ class MsgSvVoteStatus(PrettyPrint):
|
|||
pass_: int = 0,
|
||||
total: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'sv_vote_status'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_vote_status'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 16
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.yes: int = yes
|
||||
|
|
|
@ -11,8 +11,9 @@ class MsgSvWeaponPickup(PrettyPrint):
|
|||
self,
|
||||
weapon: int = enum7.Weapon.HAMMER.value
|
||||
) -> None:
|
||||
self.message_name = 'sv_weapon_pickup'
|
||||
self.system_message = False
|
||||
self.message_name: str = 'sv_weapon_pickup'
|
||||
self.system_message: bool = False
|
||||
self.message_id: int = 9
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.weapon: int = weapon
|
||||
|
|
|
@ -5,8 +5,9 @@ from twnet_parser.chunk_header import ChunkHeader
|
|||
|
||||
class MsgConReady(PrettyPrint):
|
||||
def __init__(self) -> None:
|
||||
self.message_name = 'con_ready'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'con_ready'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 5
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ from twnet_parser.chunk_header import ChunkHeader
|
|||
|
||||
class MsgEnterGame(PrettyPrint):
|
||||
def __init__(self) -> None:
|
||||
self.message_name = 'enter_game'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'enter_game'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 19
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,9 @@ class MsgInfo(PrettyPrint):
|
|||
password: str = '',
|
||||
client_version: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'info'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'info'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 1
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.version: str = version
|
||||
|
|
|
@ -13,8 +13,9 @@ class MsgInput(PrettyPrint):
|
|||
input_size: int = 0,
|
||||
input: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'input'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'input'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 20
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.ack_snapshot: int = ack_snapshot
|
||||
|
|
|
@ -11,8 +11,9 @@ class MsgInputTiming(PrettyPrint):
|
|||
input_pred_tick: int = 0,
|
||||
time_left: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'input_timing'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'input_timing'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 10
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.input_pred_tick: int = input_pred_tick
|
||||
|
|
|
@ -16,8 +16,9 @@ class MsgMapChange(PrettyPrint):
|
|||
chunk_size: int = 0,
|
||||
sha256: Annotated[bytes, 32] = bytes(32)
|
||||
) -> None:
|
||||
self.message_name = 'map_change'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'map_change'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 2
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -9,8 +9,9 @@ class MsgMapData(PrettyPrint):
|
|||
self,
|
||||
data: bytes = b'\x00'
|
||||
) -> None:
|
||||
self.message_name = 'map_data'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'map_data'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 3
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.data: bytes = data
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgMaplistEntryAdd(PrettyPrint):
|
|||
self,
|
||||
name: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'maplist_entry_add'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'maplist_entry_add'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 29
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgMaplistEntryRem(PrettyPrint):
|
|||
self,
|
||||
name: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'maplist_entry_rem'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'maplist_entry_rem'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 30
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -5,8 +5,9 @@ from twnet_parser.chunk_header import ChunkHeader
|
|||
|
||||
class MsgPing(PrettyPrint):
|
||||
def __init__(self) -> None:
|
||||
self.message_name = 'ping'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'ping'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 26
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ from twnet_parser.chunk_header import ChunkHeader
|
|||
|
||||
class MsgPingReply(PrettyPrint):
|
||||
def __init__(self) -> None:
|
||||
self.message_name = 'ping_reply'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'ping_reply'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 27
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgRconAuth(PrettyPrint):
|
|||
self,
|
||||
password: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'rcon_auth'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'rcon_auth'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 22
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.password: str = password
|
||||
|
|
|
@ -5,8 +5,9 @@ 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.message_name: str = 'rcon_auth_off'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 12
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ 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.message_name: str = 'rcon_auth_on'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 11
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgRconCmd(PrettyPrint):
|
|||
self,
|
||||
cmd: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'rcon_cmd'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'rcon_cmd'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 21
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.cmd: str = cmd
|
||||
|
|
|
@ -12,8 +12,9 @@ class MsgRconCmdAdd(PrettyPrint):
|
|||
help: str = 'default',
|
||||
params: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'rcon_cmd_add'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'rcon_cmd_add'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 14
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgRconCmdRem(PrettyPrint):
|
|||
self,
|
||||
name: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'rcon_cmd_rem'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'rcon_cmd_rem'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 15
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name: str = name
|
||||
|
|
|
@ -10,8 +10,9 @@ class MsgRconLine(PrettyPrint):
|
|||
self,
|
||||
line: str = 'default'
|
||||
) -> None:
|
||||
self.message_name = 'rcon_line'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'rcon_line'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 13
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.line: str = line
|
||||
|
|
|
@ -5,8 +5,9 @@ from twnet_parser.chunk_header import ChunkHeader
|
|||
|
||||
class MsgReady(PrettyPrint):
|
||||
def __init__(self) -> None:
|
||||
self.message_name = 'ready'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'ready'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 18
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ 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.message_name: str = 'request_map_data'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 23
|
||||
self.header: ChunkHeader
|
||||
|
||||
|
||||
|
|
|
@ -9,8 +9,9 @@ class MsgServerInfo(PrettyPrint):
|
|||
self,
|
||||
data: bytes = b'\x00'
|
||||
) -> None:
|
||||
self.message_name = 'server_info'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'server_info'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 4
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.data: bytes = data
|
||||
|
|
|
@ -17,8 +17,9 @@ class MsgSnap(PrettyPrint):
|
|||
data_size: Optional[int] = None,
|
||||
data: bytes = b'\x00'
|
||||
) -> None:
|
||||
self.message_name = 'snap'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'snap'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 6
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.tick: int = tick
|
||||
|
|
|
@ -11,8 +11,9 @@ class MsgSnapEmpty(PrettyPrint):
|
|||
tick: int = 0,
|
||||
delta_tick: int = 0
|
||||
) -> None:
|
||||
self.message_name = 'snap_empty'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'snap_empty'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 7
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.tick: int = tick
|
||||
|
|
|
@ -15,8 +15,9 @@ class MsgSnapSingle(PrettyPrint):
|
|||
data_size: Optional[int] = None,
|
||||
data: bytes = b'\x00'
|
||||
) -> None:
|
||||
self.message_name = 'snap_single'
|
||||
self.system_message = True
|
||||
self.message_name: str = 'snap_single'
|
||||
self.system_message: bool = True
|
||||
self.message_id: int = 8
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.tick: int = tick
|
||||
|
|
|
@ -5,6 +5,7 @@ from twnet_parser.chunk_header import ChunkHeader
|
|||
class NetMessage(Protocol):
|
||||
message_name: str
|
||||
system_message: bool
|
||||
message_id: int
|
||||
header: ChunkHeader
|
||||
def unpack(self, data: bytes) -> bool:
|
||||
...
|
||||
|
|
Loading…
Reference in a new issue