From c3e71f935cb65900173a68d4d9a4fa15b36270d6 Mon Sep 17 00:00:00 2001 From: Crestwave Date: Thu, 20 Mar 2025 21:24:34 +0800 Subject: [PATCH 1/2] Fix malformed coordinates crash - Fixed a crash caused by players intentionally sending malformed coordinates --- scripts/components/environmentpinger.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/components/environmentpinger.lua b/scripts/components/environmentpinger.lua index e02ea0b..28ef421 100644 --- a/scripts/components/environmentpinger.lua +++ b/scripts/components/environmentpinger.lua @@ -42,7 +42,7 @@ local EnvironmentPinger = Class(function(self,inst) function EnvironmentPinger:SetClickableMessage(chatline) local base_pattern = STRINGS.LMB..".+"..STRINGS.RMB.." " - local data_pattern = base_pattern.."{[-]?%d+[%.%d+]+,[-]?%d+[%.%d+]+} %S+ %S+" + local data_pattern = base_pattern.."{[-]?%d*%.?%d+,[-]?%d*%.?%d+} %S+ %S+" local message = chatline.message:GetString() local name = chatline.user:GetString() local colour = chatline.user:GetColour() @@ -87,16 +87,16 @@ end function EnvironmentPinger:OnMessageReceived(chathistory,guid,userid, netid, name, prefab, message, colour, whisper, isemote, user_vanity, ignore_sound, ignore_mobs) local base_pattern = STRINGS.LMB..".+"..STRINGS.RMB.." " - local data_pattern = base_pattern.."{[-]?%d+[%.%d+]+,[-]?%d+[%.%d+]+} %S+ %S+" + local data_pattern = base_pattern.."{[-]?%d*%.?%d+,[-]?%d*%.?%d+} %S+ %S+" if (not string.match(message,data_pattern)) and string.match(message,base_pattern..".+") then message = string.match(message,base_pattern)..Encryptor.E(string.match(message,base_pattern.."(%S+)") or "",cipher) end if string.match(message,data_pattern) then - local pos_str = string.match(message,base_pattern.."{([-]?%d+[%.%d+]+,[-]?%d+[%.%d+]+)} %S+") + local pos_str = string.match(message,base_pattern.."{([-]?%d*%.?%d+,[-]?%d*%.?%d+)} %S+") local pos_x = tonumber(string.match(pos_str,"(.+),")) local pos_z = tonumber(string.match(pos_str,",(.+)")) - local ping_type = string.match(message,base_pattern.."{[-]?%d+[%.%d+]+,[-]?%d+[%.%d+]+} (%S+)") - local world = string.match(message,base_pattern.."{[-]?%d+[%.%d+]+,[-]?%d+[%.%d+]+} %S+ (%S+)") + local ping_type = string.match(message,base_pattern.."{[-]?%d*%.?%d+,[-]?%d*%.?%d+} (%S+)") + local world = string.match(message,base_pattern.."{[-]?%d*%.?%d+,[-]?%d*%.?%d+} %S+ (%S+)") -- As the world identifier, let us use the session id. if world and not (current_world == world) then return nil end -- Different world means different ping meaning. if EnvironmentPinger:IsValidPingType(ping_type) then From 64981151ec94426e31bf5a6bcb994a896b199cf7 Mon Sep 17 00:00:00 2001 From: Crestwave Date: Sat, 17 May 2025 16:07:50 +0800 Subject: [PATCH 2/2] Fix stale entity crash - Fixed a crash caused by receiving pings while switching characters --- modmain.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modmain.lua b/modmain.lua index 08488bf..ce9d093 100644 --- a/modmain.lua +++ b/modmain.lua @@ -169,7 +169,9 @@ local function PlayerPostInit(player) local ChatHistory = _G.ChatHistory old_OnSay = ChatHistory.OnSay ChatHistory.OnSay = function(...) - player.components.environmentpinger:OnMessageReceived(...) + if player:IsValid() then + player.components.environmentpinger:OnMessageReceived(...) + end old_OnSay(...) end end