From 8f025dfa3dcf70a6708664de0732dd251f1f7e43 Mon Sep 17 00:00:00 2001 From: HipsterCat Date: Tue, 5 Feb 2019 22:33:25 +0100 Subject: [PATCH] Moar things --- dpnet/DN_MSG_INTERNAL_SEND_CONNECT_INFO.py | 8 +++-- dpnet/netserver.py | 39 +++++++++++++++++----- server.py | 4 +-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/dpnet/DN_MSG_INTERNAL_SEND_CONNECT_INFO.py b/dpnet/DN_MSG_INTERNAL_SEND_CONNECT_INFO.py index 5713f0b..a7b9e28 100644 --- a/dpnet/DN_MSG_INTERNAL_SEND_CONNECT_INFO.py +++ b/dpnet/DN_MSG_INTERNAL_SEND_CONNECT_INFO.py @@ -8,7 +8,7 @@ class DN_NAMETABLE_ENTRY_INFO: self.dpnid = 0 self.dpnidOwner = 0 self.dwFlags = 0 - self.dwVersion = 0 + self.dwVersion = 2 self.dwVersionNotUsed = 0 self.dwDNETVersion = 7 self.dwNameOffset = 0 @@ -64,7 +64,7 @@ class DN_MSG_INTERNAl_SEND_CONNECT_INFO(DFrame): self.guidInstance = netserver.guid self.guidApplication = APPLICATION_GUID self.dpnid = newplayer.id - self.dwVersion = 0x21 + self.dwVersion = 3 self.dwVersionNotUsed = 0 self.dwEntryCount = 0 self.dwMembershipCount = 0 @@ -98,10 +98,12 @@ class DN_MSG_INTERNAl_SEND_CONNECT_INFO(DFrame): entry_server.dpnid = s.id entry_server.dwFlags = 0x0402 + entry_server.dwVersion = 2 entry_player.dpnid = p.id entry_player.dwFlags = 0x0200 - entry_player.Name = (p.name+"\x00").encode("utf-16-le") + entry_player.Name = p.name.encode("utf-16-le") + entry_player.dwVersion = 3 var = var + self.dwEntryCount * 48 # 48=size of DN_NAMETABLE_ENTRY_INFO entry_player.dwNameOffset = var diff --git a/dpnet/netserver.py b/dpnet/netserver.py index 2e16e27..f3d1c59 100644 --- a/dpnet/netserver.py +++ b/dpnet/netserver.py @@ -93,7 +93,7 @@ class Netserver: er.SessionName = self.server.name er.ApplicationInstanceGUID = self.guid er.ApplicationGUID = eq.ApplicationGUID - er.ApplicationReservedData = b'\xff' # Map ID + '''er.ApplicationReservedData = b'\xff' # Map ID er.ApplicationReservedData += b'\x00\x04\x00' # game type and teams er.ApplicationReservedData += struct.pack(" # \x9c\x53\xf4\xdd: Three Way Island - Canyons # \x1e\xe9\x39\xe1: Still Winter - er.ApplicationReservedData += self.server.currentmap.mapname.encode("ascii") + er.ApplicationReservedData += self.server.currentmap.mapname.encode("ascii")''' + + appdata = Packet() + appdata.putByte(0xff) # map ID + appdata.putByte(self.server.game_type) # game type + appdata.putByte(self.server.teams) # teams + appdata.write(b'\x00') # original: 0x00 - does not seem to affect client + appdata.putShort(int(self.server.version * 1000)) + appdata.write(b'\x02\x92') # original: 0292 - does not seem to affect client + appdata.putShort(self.server.points_per_capture) + appdata.putShort(self.server.points_per_kill) + appdata.write(b'\x00\x00') # original: 0000 - does not seem to affect client + appdata.putShort(self.server.detente_time) + appdata.write( + b'\x9c\x53\xf4\xdd') # Seems to be a checksum of current map OR linked to the number of chars in the map name + appdata.write(self.server.currentmap.mapname.encode("ascii")) + appdata.write(b'\x00' * (32 - len(self.server.currentmap.mapname))) + er.ApplicationReservedData = appdata.getvalue() + + logger.debug("Current map: %s", self.server.currentmap.mapname) er.ApplicationReservedData += b'\x00' * (32 - len(self.server.currentmap.mapname)) self.send_packet(addr, er.to_packet()) except Exception: @@ -168,6 +187,7 @@ class Netserver: session.Full = True # fully connected session.cancel_Connect_Retry_Timer() player.phase = PlayerPhases.CFRAME_CONNECTED + session.send_dframe_keepalive() elif cframe.ExtOpCode == CFrame.FRAME_EXOPCODE_SACK: if not session or not session.Full: @@ -194,9 +214,9 @@ class Netserver: if not session: logger.error("Received a POLL packet for a non fully connected session") return - logger.debug("Got a CFrame POLL. Replying with a SACK.") + #logger.debug("Got a CFrame POLL. Replying with a SACK.") # must send back a ACK - session.send_cframe_sack() + #session.send_cframe_sack() except Exception: logger.error("Should have been a CFRAME but could not parse it") traceback.print_exc() @@ -233,7 +253,8 @@ class Netserver: self.addrs.remove(session) return if dframe.Control & DFrame.PACKET_CONTROL_KEEPALIVE_OR_CORRELATE: - session.send_dframe_keepalive() + pass + #session.send_dframe_keepalive() session.next_expected_seq += 1 if dframe.Payload: @@ -273,7 +294,7 @@ class Netserver: name = name.decode("utf-16-le") logger.debug("%s connected!", name) player.name = name - session.send_dframe_keepalive() + #session.send_dframe_keepalive() # Response: DN_MSG_INTERNAL_SEND_CONNECT_INFO d = DN_MSG_INTERNAl_SEND_CONNECT_INFO(self, player) @@ -284,12 +305,12 @@ class Netserver: appdata.putByte(0xff) # map ID appdata.putByte(self.server.game_type) # game type appdata.putByte(self.server.teams) # teams - appdata.write(b'\xcc') # original: 0x00 - does not seem to affect client + appdata.write(b'\x00') # original: 0x00 - does not seem to affect client appdata.putShort(int(self.server.version * 1000)) appdata.write(b'\x03\x90') # original: 0292 - does not seem to affect client appdata.putShort(self.server.points_per_capture) appdata.putShort(self.server.points_per_kill) - appdata.write(b'\xff\xff') # original: 0000 - does not seem to affect client + appdata.write(b'\x00\x00') # original: 0000 - does not seem to affect client appdata.putShort(self.server.detente_time) appdata.write(b'\x9c\x53\xf4\xdd') # Seems to be a checksum of current map OR linked to the number of chars in the map name appdata.write(self.server.currentmap.mapname.encode("ascii")) @@ -325,7 +346,7 @@ class Netserver: player.session.send_gamedata(p1, acknow=False) player.session.send_gamedata(b'\x3d\x00\x5b\x53\x65\x72\x76\x65\x72\x5d'+b"\x00"*25) # [SERVER] - #player.session.send_gamedata(b'\x3d\x01'+player.name.encode("ascii")+b"\x00") # playername + player.session.send_gamedata(b'\x3d\x01'+player.name.encode("ascii")+b"\x00"*(33-len(player.name.encode("ascii")))) # playername """ player.session.send_gamedata(b'\x0f\x56\xab\x31\x96\x06\x00\x00\x00\x00\x00\x00\x00\x00') # unknown player.session.send_gamedata(b'\x10\x02\x56\xab\x31\x96\x00\x00\x00\x00\x00\x00\x00\x00') # unknown diff --git a/server.py b/server.py index 54d43fb..4e28aea 100644 --- a/server.py +++ b/server.py @@ -30,7 +30,7 @@ class Server: self.accept_new_players = True self.version = 1.497 - self.points_per_kill = 3 + self.points_per_kill = 1 self.points_per_capture = 5 self.detente_time = 0 # minutes self._plugins = [] @@ -106,5 +106,5 @@ class Server: if __name__ == '__main__': - server = Server(name="giantsd", maxplayers=14, register=False) + server = Server(name="giantsd", maxplayers=400, register=False) server.run() # blocking \ No newline at end of file