From d65ac2086e34775b445d5aa2692e18e5263e1873 Mon Sep 17 00:00:00 2001 From: Ukendio Date: Sun, 24 Dec 2023 18:39:24 +0100 Subject: [PATCH] Update storage index on empty storage --- lib/query.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/query.lua b/lib/query.lua index 1703bd9..2ddbd54 100644 --- a/lib/query.lua +++ b/lib/query.lua @@ -33,7 +33,6 @@ end local function nextItem(query) local world = query.world local currentCompatibleArchetype = query.currentCompatibleArchetype - local storageIndex = query.storageIndex local seenEntities = query.seenEntities local compatibleArchetypes = query.compatibleArchetypes @@ -41,7 +40,7 @@ local function nextItem(query) local storages = world._storages repeat - local nextStorage = storages[storageIndex] + local nextStorage = storages[query.storageIndex] local currently = nextStorage[currentCompatibleArchetype] if currently then entityId, entityData = next(currently, query.lastEntityId) @@ -51,9 +50,9 @@ local function nextItem(query) currentCompatibleArchetype = next(compatibleArchetypes, currentCompatibleArchetype) if currentCompatibleArchetype == nil then - storageIndex += 1 + query.storageIndex += 1 - nextStorage = storages[storageIndex] + nextStorage = storages[query.storageIndex] if nextStorage == nil or next(nextStorage) == nil then return