[VMF Package Manager] Better queue handling

This commit is contained in:
Azumgi 2019-01-04 09:38:53 +03:00
parent f12bc8a9f0
commit 514d417626

View file

@ -54,6 +54,16 @@ local function flush_package(package_name)
end end
end end
local function remove_package_from_queue(package_name)
for i, queued_package_name in ipairs(_queued_packages) do
if package_name == queued_package_name then
table.remove(_queued_packages, i)
return
end
end
end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### VMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
@ -101,6 +111,9 @@ function VMFMod:load_package(package_name, callback, sync)
if _packages[package_name].status == "queued" then if _packages[package_name].status == "queued" then
resource_package:load() resource_package:load()
end end
if is_already_queued then
remove_package_from_queue(package_name)
end
flush_package(package_name) flush_package(package_name)
else else
if is_already_queued then if is_already_queued then
@ -130,12 +143,7 @@ function VMFMod:unload_package(package_name)
end end
if package_status == "queued" then if package_status == "queued" then
for i, queued_package_name in ipairs(_queued_packages) do remove_package_from_queue(package_name)
if package_name == queued_package_name then
table.remove(_queued_packages, i)
break
end
end
elseif package_status == "loading" then elseif package_status == "loading" then
self:error(ERRORS.REGULAR.cant_unload_loading_package, package_name) self:error(ERRORS.REGULAR.cant_unload_loading_package, package_name)
return return