diff options
Diffstat (limited to 'network/map_server.gd')
-rw-r--r-- | network/map_server.gd | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/network/map_server.gd b/network/map_server.gd index f4dacc1..1f74055 100644 --- a/network/map_server.gd +++ b/network/map_server.gd @@ -1,40 +1,13 @@ class_name MapServer +extends Server -signal received_packet(packet: Packet) signal logged_in(packet: MapServerLoginSuccessPacket) -var host: String -var port: int = 5121 -var stream: PacketPeerStream = PacketPeerStream.new() -var peer: StreamPeerTCP = StreamPeerTCP.new() - @warning_ignore("shadowed_variable") func _init(host: String, port: int = 5121) -> void: - self.host = host - self.port = port - - stream.stream_peer = peer - peer.connect_to_host(host, port) - peer.poll() - - -## Emits [signal received_packet]. -func listen() -> void: - if peer.get_status() == StreamPeerTCP.Status.STATUS_CONNECTED: - var raw_packet: PackedByteArray = peer.get_partial_data(2)[1] - - if raw_packet.size() > 0: - var header = raw_packet.decode_u16(0) - var packet_type = Constants.PacketDB[header] - if packet_type.BYTE_LENGTH > 0: - raw_packet += peer.get_data(packet_type.BYTE_LENGTH - 2)[1] - else: - raw_packet += peer.get_data(peer.get_available_bytes())[1] - var packet = packet_type.from_bytes(raw_packet) - - received_packet.emit(packet) + super._init(host, port) func login(account_id: int, character_id: int, login_id1: int, gender: Constants.Gender): |