summaryrefslogtreecommitdiff
path: root/network/map_server.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-28 18:38:42 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-28 18:38:42 +0100
commite8aa9f50886b66d525307a58d71036e6fd3d4aa1 (patch)
treece6f59eecf1eb3e1ba2794166c09623d8a2d7d83 /network/map_server.gd
parentc89f25f59aa493d95bcac8e75ca5cdd57a0403e7 (diff)
next commit
Diffstat (limited to 'network/map_server.gd')
-rw-r--r--network/map_server.gd35
1 files changed, 35 insertions, 0 deletions
diff --git a/network/map_server.gd b/network/map_server.gd
new file mode 100644
index 0000000..af46c6c
--- /dev/null
+++ b/network/map_server.gd
@@ -0,0 +1,35 @@
+class_name MapServer
+
+
+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()
+
+
+func login(account_id: int, character_id: int, login_id1: int, gender: Constants.Gender) -> MapServerLoginSuccessPacket:
+ var map_server_login_packet = MapServerLoginPacket.new()
+ map_server_login_packet.account_id = account_id
+ map_server_login_packet.character_id = character_id
+ map_server_login_packet.login_id1 = login_id1
+ map_server_login_packet.gender = gender
+
+ peer.put_data(map_server_login_packet.to_bytes())
+
+ peer.get_data(6) # in-between packet
+ peer.get_data(4) # in-between packet
+
+ var success = MapServerLoginSuccessPacket.from_bytes_via_peer(peer)
+ print(inst_to_dict(success))
+
+ return success