Added Md5Hash and made FIFO queue less cursed
Starting to run out of food.
This commit is contained in:
@@ -106,6 +106,7 @@ defaultLib["AutoItemPlacer"] = CreateStatic("Barotrauma.AutoItemPlacer")
|
|||||||
defaultLib["PropertyConditional"] = CreateStatic("Barotrauma.PropertyConditional", true)
|
defaultLib["PropertyConditional"] = CreateStatic("Barotrauma.PropertyConditional", true)
|
||||||
defaultLib["StatusEffect"] = CreateStatic("Barotrauma.StatusEffect", true)
|
defaultLib["StatusEffect"] = CreateStatic("Barotrauma.StatusEffect", true)
|
||||||
|
|
||||||
|
defaultLib["Md5Hash"] = CreateStatic("Barotrauma.Md5Hash", true)
|
||||||
defaultLib["ContentXElement"] = CreateStatic("Barotrauma.ContentXElement", true)
|
defaultLib["ContentXElement"] = CreateStatic("Barotrauma.ContentXElement", true)
|
||||||
defaultLib["ContentPath"] = CreateStatic("Barotrauma.ContentPath", true)
|
defaultLib["ContentPath"] = CreateStatic("Barotrauma.ContentPath", true)
|
||||||
defaultLib["XElement"] = CreateStatic("System.Xml.Linq.XElement", true)
|
defaultLib["XElement"] = CreateStatic("System.Xml.Linq.XElement", true)
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ RegisterBarotrauma("ContentXElement")
|
|||||||
RegisterBarotrauma("ContentPath")
|
RegisterBarotrauma("ContentPath")
|
||||||
RegisterBarotrauma("ContentPackageId")
|
RegisterBarotrauma("ContentPackageId")
|
||||||
RegisterBarotrauma("SteamWorkshopId")
|
RegisterBarotrauma("SteamWorkshopId")
|
||||||
|
RegisterBarotrauma("Md5Hash")
|
||||||
|
|
||||||
RegisterBarotrauma("SoundsFile")
|
RegisterBarotrauma("SoundsFile")
|
||||||
|
|
||||||
|
|||||||
@@ -56,25 +56,27 @@ local function AssertTypes(expectedTypes, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function ExecutionQueue()
|
local function ExecutionQueue()
|
||||||
local queue = {}
|
local executionQueue = {}
|
||||||
local function processQueueFIFO()
|
executionQueue.Queue = {}
|
||||||
while queue[1] ~= nil do
|
|
||||||
local folder, rootFolder, package = table.unpack(table.remove(queue, 1))
|
executionQueue.Process = function()
|
||||||
|
while executionQueue.Queue[1] ~= nil do
|
||||||
|
local folder, rootFolder, package = table.unpack(table.remove(executionQueue.Queue, 1))
|
||||||
print(string.format("%s %s", package.Name, package.ModVersion))
|
print(string.format("%s %s", package.Name, package.ModVersion))
|
||||||
RunFolder(folder, rootFolder, package)
|
RunFolder(folder, rootFolder, package)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function queueExecutionFIFO(...)
|
executionQueue.Add = function(...)
|
||||||
AssertTypes({ 'string', 'string', 'userdata' }, ...)
|
AssertTypes({ 'string', 'string', 'userdata' }, ...)
|
||||||
table.insert(queue, table.pack(...))
|
table.insert(executionQueue.Queue, table.pack(...))
|
||||||
end
|
end
|
||||||
|
|
||||||
return queueExecutionFIFO, processQueueFIFO
|
return executionQueue
|
||||||
end
|
end
|
||||||
|
|
||||||
local QueueAutorun, ProcessAutorun = ExecutionQueue()
|
local QueueAutorun = ExecutionQueue()
|
||||||
local QueueForcedAutorun, ProcessForcedAutorun = ExecutionQueue()
|
local QueueForcedAutorun = ExecutionQueue()
|
||||||
|
|
||||||
local function ProcessPackages(packages, fn)
|
local function ProcessPackages(packages, fn)
|
||||||
for pkg in packages do
|
for pkg in packages do
|
||||||
@@ -93,7 +95,7 @@ ProcessPackages(
|
|||||||
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
||||||
local autorunPath = pkgPath .. LUA_MOD_AUTORUN_PATH
|
local autorunPath = pkgPath .. LUA_MOD_AUTORUN_PATH
|
||||||
if File.DirectoryExists(autorunPath) then
|
if File.DirectoryExists(autorunPath) then
|
||||||
QueueAutorun(autorunPath, pkgPath, pkg)
|
QueueAutorun.Add(autorunPath, pkgPath, pkg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@@ -107,7 +109,7 @@ ProcessPackages(
|
|||||||
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
||||||
local forcedAutorunPath = pkgPath .. LUA_MOD_FORCEDAUTORUN_PATH
|
local forcedAutorunPath = pkgPath .. LUA_MOD_FORCEDAUTORUN_PATH
|
||||||
if File.DirectoryExists(forcedAutorunPath) then
|
if File.DirectoryExists(forcedAutorunPath) then
|
||||||
QueueForcedAutorun(forcedAutorunPath, pkgPath, pkg)
|
QueueForcedAutorun.Add(forcedAutorunPath, pkgPath, pkg)
|
||||||
executedLocalPackages[pkg.Name] = true
|
executedLocalPackages[pkg.Name] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -120,7 +122,7 @@ ProcessPackages(
|
|||||||
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
||||||
local forcedAutorunPath = pkgPath .. LUA_MOD_FORCEDAUTORUN_PATH
|
local forcedAutorunPath = pkgPath .. LUA_MOD_FORCEDAUTORUN_PATH
|
||||||
if File.DirectoryExists(forcedAutorunPath) then
|
if File.DirectoryExists(forcedAutorunPath) then
|
||||||
QueueForcedAutorun(forcedAutorunPath, pkgPath, pkg)
|
QueueForcedAutorun.Add(forcedAutorunPath, pkgPath, pkg)
|
||||||
executedLocalPackages[pkg.Name] = true
|
executedLocalPackages[pkg.Name] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -134,7 +136,7 @@ ProcessPackages(
|
|||||||
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
table.insert(package.path, pkgPath .. LUA_MOD_REQUIRE_PATH)
|
||||||
local forcedAutorunPath = pkgPath .. LUA_MOD_FORCEDAUTORUN_PATH
|
local forcedAutorunPath = pkgPath .. LUA_MOD_FORCEDAUTORUN_PATH
|
||||||
if File.DirectoryExists(forcedAutorunPath) then
|
if File.DirectoryExists(forcedAutorunPath) then
|
||||||
QueueForcedAutorun(forcedAutorunPath, pkgPath, pkg)
|
QueueForcedAutorun.Add(forcedAutorunPath, pkgPath, pkg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -142,8 +144,50 @@ ProcessPackages(
|
|||||||
|
|
||||||
setmodulepaths(package.path)
|
setmodulepaths(package.path)
|
||||||
setmodulepaths = nil
|
setmodulepaths = nil
|
||||||
ProcessAutorun()
|
|
||||||
ProcessForcedAutorun()
|
local allExecuted = {}
|
||||||
|
for key, value in pairs(QueueAutorun.Queue) do table.insert(allExecuted, value[3]) end
|
||||||
|
for key, value in pairs(QueueForcedAutorun.Queue) do table.insert(allExecuted, value[3]) end
|
||||||
|
|
||||||
|
if SERVER then
|
||||||
|
Networking.Receive("_luastart", function (message, client)
|
||||||
|
local num = message.ReadUInt16()
|
||||||
|
|
||||||
|
local packages = {}
|
||||||
|
|
||||||
|
for i = 1, num, 1 do
|
||||||
|
table.insert(packages, {
|
||||||
|
Name = message.ReadString(),
|
||||||
|
Version = message.ReadString(),
|
||||||
|
Id = message.ReadUInt64(),
|
||||||
|
Hash = message.ReadString()
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
Hook.Call("client.packages", client, packages)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
local message = Networking.Start("_luastart")
|
||||||
|
|
||||||
|
message.WriteUInt16(#allExecuted)
|
||||||
|
|
||||||
|
for key, package in pairs(allExecuted) do
|
||||||
|
local id = package.UgcId
|
||||||
|
local hash = package.Hash and package.Hash.StringRepresentation or ""
|
||||||
|
|
||||||
|
if id == none then id = 0 end
|
||||||
|
|
||||||
|
message.WriteString(package.Name)
|
||||||
|
message.WriteString(package.ModVersion)
|
||||||
|
message.WriteUInt64(UInt64(id))
|
||||||
|
message.WriteString(hash)
|
||||||
|
end
|
||||||
|
|
||||||
|
Networking.Send(message)
|
||||||
|
end
|
||||||
|
|
||||||
|
QueueAutorun.Process()
|
||||||
|
QueueForcedAutorun.Process()
|
||||||
|
|
||||||
Hook.Add("stop", "luaSetup.stop", function()
|
Hook.Add("stop", "luaSetup.stop", function()
|
||||||
print("Stopping Lua...")
|
print("Stopping Lua...")
|
||||||
|
|||||||
Reference in New Issue
Block a user