From 04632d55cd8c0434840b1e578ce932b21e108e6c Mon Sep 17 00:00:00 2001 From: YetAnotherClown Date: Mon, 26 Aug 2024 02:39:47 -0400 Subject: [PATCH] Fix: QueryResult filter stops iteration, causing packets to not be queried --- lib/QueryResult.luau | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/QueryResult.luau b/lib/QueryResult.luau index 293fa78..0d2304e 100644 --- a/lib/QueryResult.luau +++ b/lib/QueryResult.luau @@ -80,24 +80,31 @@ function QueryResult:__iter() local senders = self._senders local identifier = self._identifier - local snapshot = self._snapshot - local i = 0 + local filteredSnapshot = {} - return function() - -- Tick for new packet - i += 1 - - local packet = snapshot[i] + for i = 1, #self._snapshot do + local packet = self._snapshot[i] if not packet then - return + continue end - -- Return all packets if no Senders are supplied, or filter by Senders local filterSenders = #senders > 0 local isSenderAllowed = if filterSenders then table.find(senders, packet.sender) else true - -- Don't return packet if filtered if read(packet.identifier) ~= read(identifier) or not isSenderAllowed then + continue + end + + table.insert(filteredSnapshot, packet) + end + + local i = 0 + + return function() + i += 1 + + local packet = filteredSnapshot[i] + if not packet then return end