diff options
| author | Ritabrata Das <[email protected]> | 2025-03-09 12:01:43 +0530 |
|---|---|---|
| committer | Ritabrata Das <[email protected]> | 2025-03-09 12:01:43 +0530 |
| commit | 42d2d3acfc44455b70bb46c7bcd9cb1487a79ca4 (patch) | |
| tree | 5350ce57c193bca206c3c5537c1ec0560782cdaf | |
| parent | 19ac5fec99c54086f52a17b254e98b37192a9627 (diff) | |
Add support for longer than 16 char username and fix bugs
| -rw-r--r-- | lib/PacketManager/packets/FSNETCMD_LOGON.py | 2 | ||||
| -rw-r--r-- | lib/Player.py | 3 | ||||
| -rw-r--r-- | plugins/crash_on_ground.py | 2 | ||||
| -rw-r--r-- | plugins/radar.py | 2 | ||||
| -rw-r--r-- | proxy.py | 23 |
5 files changed, 21 insertions, 11 deletions
diff --git a/lib/PacketManager/packets/FSNETCMD_LOGON.py b/lib/PacketManager/packets/FSNETCMD_LOGON.py index 9848590..620b2cd 100644 --- a/lib/PacketManager/packets/FSNETCMD_LOGON.py +++ b/lib/PacketManager/packets/FSNETCMD_LOGON.py @@ -55,4 +55,4 @@ class FSNETCMD_LOGON: #1 @staticmethod def alter_version(buffer:bytes, new_version:int): - return buffer[:20]+pack("I",new_version)+buffer[24:]
\ No newline at end of file + return buffer[:20]+pack("I",new_version)+buffer[24:] diff --git a/lib/Player.py b/lib/Player.py index cfd50a8..f8da70e 100644 --- a/lib/Player.py +++ b/lib/Player.py @@ -27,7 +27,8 @@ class Player: self.ip = ip def check_add_object(self, packet:FSNETCMD_ADDOBJECT): - if packet.pilot == self.username: + # we check the full name here + if packet.pilot == self.alias: self.aircraft = Aircraft() self.aircraft.name = packet.identifier self.aircraft.id = packet.object_id diff --git a/plugins/crash_on_ground.py b/plugins/crash_on_ground.py index 4cc334b..15b1fbf 100644 --- a/plugins/crash_on_ground.py +++ b/plugins/crash_on_ground.py @@ -10,8 +10,6 @@ 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_add_object_server', self.on_join) self.plugin_manager.register_hook('on_remove_airplane_server', self.on_death) def on_death(self, data, player, message_to_client, message_to_server): diff --git a/plugins/radar.py b/plugins/radar.py index e09447d..ac47b5b 100644 --- a/plugins/radar.py +++ b/plugins/radar.py @@ -60,7 +60,7 @@ class Plugin: try: # This is a really arbitary position thats hard to reach, better would # be to randomise it for every time the server starts. - position_data = struct.pack("3f", 10e7, 10e7, 10e7) + position_data = struct.pack("3f", 10e8, 200, 10e8) if decode.packet_version == 4 or 5: updated_data = data[:14] + position_data + data[26:] else: @@ -131,11 +131,17 @@ async def handle_client(client_reader, client_writer): try: if packet_type == "FSNETCMD_LOGON": - # keep_message = plugin_manager.triggar_hook('on_login', packet, player, message_to_client, message_to_server) - # if not keep_message: - # data = None - player.login(FSNETCMD_LOGON(packet)) + decode = FSNETCMD_LOGON(packet) + for p in CONNECTED_PLAYERS: + if p.username == decode.username: + client_writer.write(YSchat.message(f"Same username {decode.username} is aldready connected to server! Kicked {ipAddr}")) + data = None + info(f"Same username {decode.username} is aldready connected to server! Kicked {ipAddr}") + await close_connection(client_writer, server_writer) + + player.login(decode) info(f"Player {player.username} connected from {player.ip}") + if player.version != YSF_VERSION and VIA_VERSION: info(f"ViaVersion enabled : Porting {player.username} from {player.version} to {YSF_VERSION}") message_to_client.append(YSchat.message(f"Porting you to YSFlight {YSF_VERSION}, This is currently Experimental")) @@ -152,7 +158,9 @@ async def handle_client(client_reader, client_writer): elif packet_type == "FSNETCMD_AIRPLANESTATE": decode = FSNETCMD_AIRPLANESTATE(packet) - player.aircraft.add_state(decode) #TODO: Do we want to convert all this to plugins? Probably not, but there is duplicated functionality + player.aircraft.add_state(decode) + + #TODO: Do we want to convert all this to plugins? Probably not, but there is duplicated functionality # keep_message = plugin_manager.triggar_hook('on_flight_data', packet, player, message_to_client, message_to_server) # if not keep_message: # data = None @@ -186,6 +194,7 @@ async def handle_client(client_reader, client_writer): data = None command = msg.message.split(" ")[0][1:] asyncio.create_task(triggerCommand.triggerCommand(command, msg.message, player, message_to_client, message_to_server, plugin_manager)) + info(f"Command {command} triggered by {player.username}") else: if DISCORD_ENABLED: # Make it non blocking! @@ -267,8 +276,10 @@ async def handle_client(client_reader, client_writer): """ if not player.connection_closed: player.connection_closed = True + CONNECTED_PLAYERS.remove(player) if not player.is_a_bot: - message_to_server.append(YSchat.message(f"{player.username} has left the server!")) + for player in CONNECTED_PLAYERS: + player.streamWriterObject.write(YSchat.message(f"{player.username} has left the server!")) if DISCORD_ENABLED: await discord_send_message(CHANNEL_ID, f"{player.username} has left the server!") await close_connection(client_writer, server_writer) |
