From 4c59fc24b86fda2e317f4fce77eea7a11ff87e30 Mon Sep 17 00:00:00 2001 From: Ritabrata Das Date: Mon, 3 Mar 2025 14:41:24 +0530 Subject: Fix crash on ground plugin, add additional logging, fix readback packet --- lib/PacketManager/packets/FSNETCMD_READBACK.py | 8 ++++---- plugins/crash_on_ground.py | 14 ++++++++++++-- proxy.py | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/PacketManager/packets/FSNETCMD_READBACK.py b/lib/PacketManager/packets/FSNETCMD_READBACK.py index 0fd4ead..b86199f 100644 --- a/lib/PacketManager/packets/FSNETCMD_READBACK.py +++ b/lib/PacketManager/packets/FSNETCMD_READBACK.py @@ -6,7 +6,7 @@ class FSNETCMD_READBACK: #6 * Client sends FSNETREADBACK_ADDAIRPLAN or FSNETREADBACK_ADDGROUND to acknowledge FSNETCMD_ADDOBJECT - * Client sends FSNETREADBACK_REMOVEAIRPLANE or FSNETREADBACK_REMOVEGROUND + * Client sends FSNETREADBACK_REMOVEAIRPLANE or FSNETREADBACK_REMOVEGROUND to acknowledge FSNETCMD_REMOVEAIRPLANE or FSNETCMD_REMOVEGROUND * Client sends FSNETREADBACK_ENVIRONMENT to acknowledge FSNETCMD_ENVIRONMENT * Client sends FSNETREADBACK_JOINREQUEST to acknowledge FSNETCMD_JOINREQUEST @@ -14,7 +14,7 @@ class FSNETCMD_READBACK: #6 * Client sends FSNETREADBACK_USEMISSILE to acknowledge FSNETCMD_USEMISSILE * Client sends FSNETREADBACK_USEUNGUIDEDWEAPON to acknowledge FSNETCMD_USEUNGUIDEDWEAPON * Client sends FSNETREADBACK_CTRLSHOWUSERNAME to acknowledge FSNETCMD_CTRLSHOWUSERNAME - + * Server sends FSNETREADBACK_JOINREQUEST to acknowledge FSNETCMD_JOINREQUEST - Will punt the user if the server receives this from them * There are probably more, but I've not gone into much detail here yet. @@ -33,7 +33,7 @@ class FSNETCMD_READBACK: #6 @staticmethod def encode(read_back_type, read_back_param, with_size:bool=False): - buffer = pack("IhhI", 6, read_back_type, 0, read_back_param) + buffer = pack("IhhI", 6, 0, read_back_type, read_back_param) if with_size: return pack("I",len(buffer))+buffer - return buffer \ No newline at end of file + return buffer diff --git a/plugins/crash_on_ground.py b/plugins/crash_on_ground.py index 935ace3..fb9d080 100644 --- a/plugins/crash_on_ground.py +++ b/plugins/crash_on_ground.py @@ -1,5 +1,6 @@ # This plugin renders the dead plane until crashes in ground # Thus disabling mid air dispawning when dead +from lib.PacketManager.packets import FSNETCMD_REMOVEAIRPLANE, FSNETCMD_READBACK ENABLED = True @@ -9,7 +10,16 @@ class Plugin: def register(self, plugin_manager): self.plugin_manager = plugin_manager - self.plugin_manager.register_hook('on_unjoin', self.on_death) + #self.plugin_manager.register_hook('on_unjoin', self.on_death) + self.plugin_manager.register_hook('on_remove_airplane_server', self.on_death) def on_death(self, data, player, message_to_client, message_to_server): - return False + if player.aircraft.id != -1: + if player.aircraft.id == FSNETCMD_REMOVEAIRPLANE(data).object_id: + return True + else: + a = FSNETCMD_READBACK.encode(2, player.aircraft.id, True) + message_to_server.append(a) + return False + else: + return True diff --git a/proxy.py b/proxy.py index 433e316..d55bba2 100644 --- a/proxy.py +++ b/proxy.py @@ -125,7 +125,7 @@ async def handle_client(client_reader, client_writer): data = header + packet packet_type = PacketManager().get_packet_type(packet) if direction == "client_to_server": - debug("C2S" + str(packet_type)) + debug("C2S" + str(packet_type) + str(player.username)) debug(data) try: @@ -203,7 +203,7 @@ async def handle_client(client_reader, client_writer): traceback.print_exc() # This will display the full traceback else : - debug("S2C" + str(packet_type)) + debug("S2C" + str(packet_type) + str(player.username)) debug(data) #if packet_type == "FSNETCMD_AIRCMD": -- cgit v1.2.3