diff --git a/dpnet/netserver.py b/dpnet/netserver.py index 656f198..773f439 100644 --- a/dpnet/netserver.py +++ b/dpnet/netserver.py @@ -531,10 +531,16 @@ class Netserver(asyncio.DatagramProtocol): logger.debug("Fuck that no player wtf man") return p = Packet(payload) - opcode = p.getShort() - unknown1 = p.getULong() - unknown2 = p.getULong() - unknown3 = p.getULong() + opcode = p.getByte() + length = p.getByte() # length? + unknown1 = p.getByte() + unknown2 = p.getByte() + unknown3 = p.getByte() + playerindex = p.getByte() + objid = p.getShort() + unknown5 = p.getByte() + unknown6 = p.getByte() + model = p.getULong() playerx = p.getFloat() playery = p.getFloat() playerz = p.getFloat() @@ -542,16 +548,19 @@ class Netserver(asyncio.DatagramProtocol): unknown5 = p.getULong() unknown6 = p.getULong() unknown7 = p.getULong() - unknown8 = p.getULong() + orientation = p.getULong() # orientation unknown9 = p.getULong() player.x = playerx player.y = playery player.z = playerz + player.oid = objid + player.o = orientation #logger.info("%s is now at coords (%s,%s,%s)", player.name, player.x, player.y, player.z) - #await self.server.broadcast_message("%s is now at coords (%s,%s,%s)" % (player.name, player.x, player.y, player.z)) - await player.session.send_gamedata(b"", acknow=False) + await self.server.broadcast_message("%s is now at coords (%s,%s,%s, %s). Model: %s" % (player.name, player.x, player.y, player.z, player.o, model)) + #await self.server.broadcast_message("(%s,%s,%s, %s,%s)" % (unknown4, unknown5, unknown6, unknown7, unknown9)) + elif payload[0] == 0x3a: # CLIENT EXITED player = self.get_player(session) diff --git a/giants/map.py b/giants/map.py index 8025def..0b278c2 100644 --- a/giants/map.py +++ b/giants/map.py @@ -31,6 +31,8 @@ class Map: return b"\xc7\x5f\x61\x1f" if mappath == "test3.gck": return b"\x59\xbb\xab\x52" + if mappath == "Testmap.gck": + return b"\x74\x07\x98\xaf" # \x00\x00\x00\x00: [None] # \x00\x00\x00\x01: # \x9c\x53\xf4\xdd: Three Way Island - Canyons diff --git a/giants/player.py b/giants/player.py index 7f65807..9216b33 100644 --- a/giants/player.py +++ b/giants/player.py @@ -25,6 +25,7 @@ class Player(Entity): self.id = random.getrandbits(16) self.phase = PlayerPhases.NONE self.ping = 1 + self.oid = 0 async def change_team(self, newteam): self.team = newteam diff --git a/plugins/commands.py b/plugins/commands.py index 0374eea..d5405e3 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -6,7 +6,6 @@ import struct class Commands: def __init__(self, server): self.server = server - self._nextid = 118 async def on_player_chat(self, player, type, team, message): await self.server.broadcast_message_except(player, "%s: %s" % (player.name, message), color=ChatColor.Yellow) @@ -60,8 +59,16 @@ class Commands: await player.session.send_gamedata(bytes.fromhex("0b1a0000000002070000a5b0d4c35d9714c450abef354a68fb410914000000020700000402000000")+struct.pack(" 1: - await self.server.broadcast_message("Spawning "+command[1]+"") - await self.server.spawn(self._nextid, "00", command[1]) + await self.server.broadcast_message("Spawning " + command[1] + "") + await self.server.spawn(player, 0, int(command[1])) + + if command[0] == "changeme" and len(command) > 1: + await self.server.broadcast_message("Changing your model to " + command[1] + "") + await self.server.change_model(player, int(command[1])) + + if command[0] == "change" and len(command) > 2: + await self.server.broadcast_message("Changing model of "+command[1]+" to "+command[2]+"") + await self.server.change_model(self.server.get_player_by_index(int(command[1])), int(command[2])) def setup(server): diff --git a/server.py b/server.py index 3c9e8a6..ed11baa 100644 --- a/server.py +++ b/server.py @@ -1,3 +1,4 @@ +from dpnet.packet import Packet from giants.map import Map from giants.player import Player from dpnet.netserver import Netserver @@ -56,6 +57,8 @@ class Server: self.running = True self.ticks = 60 + self._nextid = 118 + def update(self): #logger.debug("Calling update") pass @@ -144,10 +147,115 @@ class Server: continue await pplayer.send_message(text, color=color, type=type) - async def spawn(self, objid, plix, model): - await self.broadcast_gamedata(bytes.fromhex("05" + plix + struct.pack(" death, 3 -> little move + # p.putULong(model) # model + # p.putFloat(player.x) # x + # p.putFloat(player.y) # y + # p.putFloat(player.z) # z + # p.putULong(0x00) # unknown + # p.putULong(0x00) # unknown + # p.putULong(0x00) # unknown + # p.putULong(0x00) # unknown + # p.putULong(player.o + 30) # orientation + # p.putULong(0x00) # unknown + + p = Packet() + p.putByte(0x0a) # opcode + p.putByte(0x32) # length + p.putByte(0x00) # unknown + p.putByte(0x00) # unknown + p.putByte(0x00) # unknown + p.putByte(plid) # player index + p.putShort(player.oid) # object id + p.putByte(0x00) # unknown + p.putByte(0x01) # 1 -> stand still, 4 -> death, 3 -> little move + p.putULong(model) # model + p.putFloat(0x00) # x + p.putFloat(player.y) # y + p.putFloat(player.z) # z + p.putULong(0x00) # unknown + p.putULong(0x00) # unknown + p.putULong(0x00) # unknown + p.putULong(0x00) # unknown + p.putULong((player.o + 30) % 360) # orientation + p.putULong(0x00) # unknown + + p.putByte(0x0a) # opcode + p.putByte(0x12) # length + p.putByte(0x00) # unknown + p.putByte(0x00) # unknown + p.putByte(0x00) # unknown + p.putByte(plid) # player index + p.putShort(player.oid) # object id + p.putByte(0x00) # unknown + p.putByte(0x00) # 1 -> stand still, 4 -> death, 3 -> little move + p.putULong(model) # model + p.putULong(0x00) + p.putByte(0x00) + p.putByte(0x00) + + await self.broadcast_gamedata(p.getvalue(), acknow=False) + #await self.broadcast_gamedata(bytes.fromhex("0a32000000" + plix + struct.pack("