forked from hipstercat/giantsd
Dynamic packet payloads
This commit is contained in:
parent
d594e38be5
commit
831a4dbf9d
@ -9,6 +9,7 @@ import socket
|
|||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
import uuid
|
import uuid
|
||||||
|
import struct
|
||||||
from utils.logger import setup_logger
|
from utils.logger import setup_logger
|
||||||
from giants.player import Player
|
from giants.player import Player
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ class Netserver:
|
|||||||
er.ApplicationGUID = eq.ApplicationGUID
|
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 += b'\x00\x04\x00' # game type and teams
|
||||||
er.ApplicationReservedData += b'\xd9\x05' # game version
|
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
|
er.ApplicationReservedData += b'\x02\x92\x05\x00\x01\x00\x00\x00\x00\x00' # Unknown
|
||||||
er.ApplicationReservedData += b'\x9c\x53\xf4\xde' # Seems to be a checksum of current map
|
er.ApplicationReservedData += b'\x9c\x53\xf4\xde' # Seems to be a checksum of current map
|
||||||
# \x00\x00\x00\x00: [None]
|
# \x00\x00\x00\x00: [None]
|
||||||
@ -282,49 +283,15 @@ class Netserver:
|
|||||||
payload.putLong(0) # unknown
|
payload.putLong(0) # unknown
|
||||||
payload.write((name + "\x00").encode("utf-16-le"))
|
payload.write((name + "\x00").encode("utf-16-le"))
|
||||||
payload.write(b'\xff') # map ID
|
payload.write(b'\xff') # map ID
|
||||||
payload.write(b'\x08') # game type
|
payload.putByte(self.server.game_type) # game type
|
||||||
# 00: Team Deathmatch
|
payload.putByte(self.server.teams) # teams
|
||||||
# 01: Team Deathmatch with full base
|
|
||||||
# 02: Capture Smartie
|
|
||||||
# 03: Capture Smartie with full base
|
|
||||||
# 04: Base Build Deathmatch
|
|
||||||
# 05: Base Build and Capture the Smartie
|
|
||||||
# 06: Defend Base
|
|
||||||
# 07: Defend Base and Capture the Smartie
|
|
||||||
# 08: GTypeStone
|
|
||||||
# 09: GTypeWood
|
|
||||||
# 0a: crash to desktop
|
|
||||||
# 0b: crash to desktop
|
|
||||||
# 0c: GType(null)
|
|
||||||
# 0d: crash to desktop
|
|
||||||
# 0e: crash to desktop
|
|
||||||
# 0f: crash to desktop
|
|
||||||
# 10: crash to desktop
|
|
||||||
# feel free to try other values...
|
|
||||||
# aa: crash to desktop
|
|
||||||
# ff: crash to desktop
|
|
||||||
|
|
||||||
payload.write(b'\x00') # teams
|
|
||||||
# 00: MvM
|
|
||||||
# 01: MvMvM
|
|
||||||
# 02: RvR
|
|
||||||
# 03: MvR
|
|
||||||
# 04: MvRvK
|
|
||||||
# 05: MvK
|
|
||||||
# 06: RvK
|
|
||||||
# 07: ? Team B
|
|
||||||
# 08: ? Team B
|
|
||||||
# feel free to try other values...
|
|
||||||
# 10: ? Team B
|
|
||||||
# 0c: ? Team B
|
|
||||||
# 5a: crash to desktop
|
|
||||||
payload.write(b'\xcc') # original: 0x00 - does not seem to affect client
|
payload.write(b'\xcc') # original: 0x00 - does not seem to affect client
|
||||||
payload.write(b'\xd9\x05') # game version
|
payload.putShort(int(self.server.version*1000))
|
||||||
payload.write(b'\x03\x90') # original: 0292 - does not seem to affect client
|
payload.write(b'\x03\x90') # original: 0292 - does not seem to affect client
|
||||||
payload.write(b'\x05\x00') # points per capture
|
payload.putShort(self.server.points_per_capture)
|
||||||
payload.write(b'\x01\x00') # points per kill
|
payload.putShort(self.server.points_per_kill)
|
||||||
payload.write(b'\xff\xff') # original: 0000 - does not seem to affect client
|
payload.write(b'\xff\xff') # original: 0000 - does not seem to affect client
|
||||||
payload.write(b'\x00\x00') # détente time
|
payload.putShort(self.server.detente_time)
|
||||||
payload.write(b'\x9c\x53\xf4\xdf') # Seems to be a checksum of current map OR linked to the number of chars in the map name
|
payload.write(b'\x9c\x53\xf4\xdf') # Seems to be a checksum of current map OR linked to the number of chars in the map name
|
||||||
payload.write(self.server.currentmap.mapname.encode("ascii"))
|
payload.write(self.server.currentmap.mapname.encode("ascii"))
|
||||||
payload.write(b'\x00' * (32 - len(self.server.currentmap.mapname)))
|
payload.write(b'\x00' * (32 - len(self.server.currentmap.mapname)))
|
||||||
|
@ -1,4 +1,18 @@
|
|||||||
class Teams:
|
class Teams:
|
||||||
|
# 00: MvM
|
||||||
|
# 01: MvMvM
|
||||||
|
# 02: RvR
|
||||||
|
# 03: MvR
|
||||||
|
# 04: MvRvK
|
||||||
|
# 05: MvK
|
||||||
|
# 06: RvK
|
||||||
|
# 07: ? Team B
|
||||||
|
# 08: ? Team B
|
||||||
|
# feel free to try other values...
|
||||||
|
# 10: ? Team B
|
||||||
|
# 0c: ? Team B
|
||||||
|
# 5a: crash to desktop
|
||||||
|
|
||||||
MvM = 0x00
|
MvM = 0x00
|
||||||
MvMvM = 0x01
|
MvMvM = 0x01
|
||||||
RvR = 0x02
|
RvR = 0x02
|
||||||
@ -11,6 +25,27 @@ class Teams:
|
|||||||
|
|
||||||
|
|
||||||
class GameTypes:
|
class GameTypes:
|
||||||
|
# 00: Team Deathmatch
|
||||||
|
# 01: Team Deathmatch with full base
|
||||||
|
# 02: Capture Smartie
|
||||||
|
# 03: Capture Smartie with full base
|
||||||
|
# 04: Base Build Deathmatch
|
||||||
|
# 05: Base Build and Capture the Smartie
|
||||||
|
# 06: Defend Base
|
||||||
|
# 07: Defend Base and Capture the Smartie
|
||||||
|
# 08: GTypeStone
|
||||||
|
# 09: GTypeWood
|
||||||
|
# 0a: crash to desktop
|
||||||
|
# 0b: crash to desktop
|
||||||
|
# 0c: GType(null)
|
||||||
|
# 0d: crash to desktop
|
||||||
|
# 0e: crash to desktop
|
||||||
|
# 0f: crash to desktop
|
||||||
|
# 10: crash to desktop
|
||||||
|
# feel free to try other values...
|
||||||
|
# aa: crash to desktop
|
||||||
|
# ff: crash to desktop
|
||||||
|
|
||||||
TeamDeathmatch = 0x00
|
TeamDeathmatch = 0x00
|
||||||
TeamDeathmatchWithFullBase = 0x01
|
TeamDeathmatchWithFullBase = 0x01
|
||||||
CaptureSmartie = 0x02
|
CaptureSmartie = 0x02
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import socket
|
import socket
|
||||||
from dpnet.packet import Packet
|
from dpnet.packet import Packet
|
||||||
import threading
|
import threading
|
||||||
|
from utils.logger import setup_logger
|
||||||
|
|
||||||
|
logger = setup_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class MasterServer:
|
class MasterServer:
|
||||||
@ -17,8 +20,8 @@ class MasterServer:
|
|||||||
|
|
||||||
def register_and_run(self):
|
def register_and_run(self):
|
||||||
self.socket.bind((self.server.listen_ip, 8911))
|
self.socket.bind((self.server.listen_ip, 8911))
|
||||||
print("Listening to " + self.server.listen_ip + ":" + str(8911))
|
logger.info("Listening to " + self.server.listen_ip + ":" + str(8911))
|
||||||
print("Registering to Master Server")
|
logger.info("Registering to Master Server")
|
||||||
self._register()
|
self._register()
|
||||||
self.keepalive()
|
self.keepalive()
|
||||||
self.handle_packets()
|
self.handle_packets()
|
||||||
@ -42,7 +45,7 @@ class MasterServer:
|
|||||||
print("Received command:", command)
|
print("Received command:", command)
|
||||||
if command == "\\status\\":
|
if command == "\\status\\":
|
||||||
resp = Packet()
|
resp = Packet()
|
||||||
respstr = "\\gamename\\giants\\gamever\\1.497\\hostname\\" + self.server.name + "\\hostport\\" + str(
|
respstr = "\\gamename\\giants\\gamever\\"+str(self.server.version)+"\\hostname\\" + self.server.name + "\\hostport\\" + str(
|
||||||
self.server.listen_port) + "\\mapname\\" + self.server.currentmap.mapname + "\\gametype\\Capture Smartie with full base\\numplayers\\" + str(
|
self.server.listen_port) + "\\mapname\\" + self.server.currentmap.mapname + "\\gametype\\Capture Smartie with full base\\numplayers\\" + str(
|
||||||
len(self.server.players)) + "\\maxplayers\\" + str(
|
len(self.server.players)) + "\\maxplayers\\" + str(
|
||||||
self.server.maxplayers) + "\\gamemode\\openplaying\\timelimit\\60\\fraglimit\\0\\teamfraglimit\\0\\firstbasecomplete\\0\\player_0\\Amazed\\frags_0\\0\\deaths_0\\0\\ping_0\\0\\team_0\\Green\\final\\\\queryid\\2.1"
|
self.server.maxplayers) + "\\gamemode\\openplaying\\timelimit\\60\\fraglimit\\0\\teamfraglimit\\0\\firstbasecomplete\\0\\player_0\\Amazed\\frags_0\\0\\deaths_0\\0\\ping_0\\0\\team_0\\Green\\final\\\\queryid\\2.1"
|
||||||
|
@ -27,6 +27,10 @@ class Server:
|
|||||||
self.register_with_ms = kwargs.get("register", False)
|
self.register_with_ms = kwargs.get("register", False)
|
||||||
self.teams = kwargs.get("teams", Teams.MvM)
|
self.teams = kwargs.get("teams", Teams.MvM)
|
||||||
self.game_type = kwargs.get("gametype", GameTypes.TeamDeathmatchWithFullBase)
|
self.game_type = kwargs.get("gametype", GameTypes.TeamDeathmatchWithFullBase)
|
||||||
|
self.version = 1.497
|
||||||
|
self.points_per_kill = 1
|
||||||
|
self.points_per_capture = 5
|
||||||
|
self.detente_time = 0 # minutes
|
||||||
self._plugins = []
|
self._plugins = []
|
||||||
|
|
||||||
def add_player(self, player):
|
def add_player(self, player):
|
||||||
|
Loading…
Reference in New Issue
Block a user