Moar things

This commit is contained in:
Amazed 2019-02-05 22:33:25 +01:00
parent 024712cc8d
commit 8f025dfa3d
3 changed files with 37 additions and 14 deletions

View File

@ -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

View File

@ -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("<L", int(self.server.version*1000)) # game version
er.ApplicationReservedData += b'\x02\x92\x05\x00\x01\x00\x00\x00\x00\x00' # Unknown
@ -102,7 +102,26 @@ class Netserver:
# \x00\x00\x00\x01: <custom map>
# \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

View File

@ -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