Prefix generated classes with Msg
This commit is contained in:
parent
d21092f44b
commit
0d4f6057a2
|
@ -65,7 +65,7 @@ def match_game7(msg_id: int, data: bytes) -> NetMessage:
|
|||
match_game7 += \
|
||||
f"""
|
||||
{if_} msg_id == twnet_parser.msg7.{name_snake.upper()}:
|
||||
msg = game7_{name_snake}.{name_camel}()"""
|
||||
msg = game7_{name_snake}.Msg{name_camel}()"""
|
||||
if_ = 'elif'
|
||||
|
||||
match_game7 += '\n\n if msg is None:\n'
|
||||
|
@ -121,7 +121,7 @@ def generate_msg(msg: NetMessageJson, game: str) -> None:
|
|||
out_file.write('from twnet_parser.chunk_header import ChunkHeader\n')
|
||||
out_file.write(get_dependencies(msg))
|
||||
out_file.write('\n')
|
||||
out_file.write(f'class {name_camel}(PrettyPrint):\n')
|
||||
out_file.write(f'class Msg{name_camel}(PrettyPrint):\n')
|
||||
out_file.write(' def __init__(\n')
|
||||
out_file.write(' self,\n')
|
||||
args: list[str] = []
|
||||
|
|
|
@ -1,27 +1,30 @@
|
|||
#!/usr/bin/env python
|
||||
# generated by scripts/generate_messages.py
|
||||
|
||||
from twnet_parser.pretty_print import PrettyPrint
|
||||
from twnet_parser.packer import Unpacker, pack_str, pack_int
|
||||
from twnet_parser.packer import Unpacker
|
||||
from twnet_parser.chunk_header import ChunkHeader
|
||||
from twnet_parser.packer import pack_str, pack_int
|
||||
|
||||
class MsgMapChange(PrettyPrint):
|
||||
def __init__(
|
||||
self,
|
||||
name: str = 'dm1',
|
||||
crc: int = -1,
|
||||
size: int = 1337,
|
||||
chunks_per_request: int = 8,
|
||||
chunk_size: int = 1384,
|
||||
sha256: bytes = bytes(32)
|
||||
name: str = 'default',
|
||||
crc: int = 0,
|
||||
size: int = 0,
|
||||
num_response_chunks_per_request: int = 0,
|
||||
chunk_size: int = 0,
|
||||
sha256: bytes = b'\x00'
|
||||
) -> None:
|
||||
self.message_name = 'map_change'
|
||||
self.system_message = True
|
||||
self.header: ChunkHeader
|
||||
|
||||
self.name = name
|
||||
self.crc = crc
|
||||
self.size = size
|
||||
self.chunks_per_request = chunks_per_request
|
||||
self.chunk_size = chunk_size
|
||||
self.sha256 = sha256
|
||||
self.name: str = name
|
||||
self.crc: int = crc
|
||||
self.size: int = size
|
||||
self.num_response_chunks_per_request: int = num_response_chunks_per_request
|
||||
self.chunk_size: int = chunk_size
|
||||
self.sha256: bytes = sha256
|
||||
|
||||
# first byte of data
|
||||
# has to be the first byte of the message payload
|
||||
|
@ -31,7 +34,7 @@ class MsgMapChange(PrettyPrint):
|
|||
self.name = unpacker.get_str()
|
||||
self.crc = unpacker.get_int()
|
||||
self.size = unpacker.get_int()
|
||||
self.chunks_per_request = unpacker.get_int()
|
||||
self.num_response_chunks_per_request = unpacker.get_int()
|
||||
self.chunk_size = unpacker.get_int()
|
||||
self.sha256 = unpacker.get_raw()
|
||||
return True
|
||||
|
@ -40,6 +43,6 @@ class MsgMapChange(PrettyPrint):
|
|||
return pack_str(self.name) + \
|
||||
pack_int(self.crc) + \
|
||||
pack_int(self.size) + \
|
||||
pack_int(self.chunks_per_request) + \
|
||||
pack_int(self.num_response_chunks_per_request) + \
|
||||
pack_int(self.chunk_size) + \
|
||||
self.sha256
|
||||
self.sha256
|
Loading…
Reference in a new issue