From f37f2f009fb3f833c604c11fb0cf043c97eb00c1 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Wed, 7 Jun 2023 14:17:10 -0400 Subject: [PATCH] comms only set nil max distance if requested max is exactly 0 --- scada-common/comms.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scada-common/comms.lua b/scada-common/comms.lua index 41528dc..c5e9fd2 100644 --- a/scada-common/comms.lua +++ b/scada-common/comms.lua @@ -9,7 +9,7 @@ local insert = table.insert ---@diagnostic disable-next-line: undefined-field local C_ID = os.getComputerID() ---@type integer computer ID -local max_distance = nil ---@type integer|nil maximum acceptable transmission distance +local max_distance = nil ---@type number|nil maximum acceptable transmission distance ---@class comms local comms = {} @@ -133,9 +133,9 @@ comms.BROADCAST = -1 -- configure the maximum allowable message receive distance
-- packets received with distances greater than this will be silently discarded ----@param distance integer max modem message distance (less than 1 disables the limit) +---@param distance integer max modem message distance (0 disables the limit) function comms.set_trusted_range(distance) - if distance < 1 then max_distance = nil else max_distance = distance end + if distance == 0 then max_distance = nil else max_distance = distance end end -- generic SCADA packet object