Panakotta00 / FicsIt-Networks

Control, Monitor, Manage and Automate your Satisfactory.
https://ficsit.app/mod/FicsItNetworks
GNU General Public License v3.0
156 stars 51 forks source link

Crashes game when using network cards / routers #206

Closed dertroglodyt closed 1 year ago

dertroglodyt commented 2 years ago

Played for some days with the mod with no problems at all. Started crashing today as I set up a server to listen on a network card. Have used the internet card before without issues. So my best guess is the network card which is new. HTH

Server code looks like this:

-- fetches all libs from GIT and sends them over network on request

local libs = {}
local gitRoot = "https://gitlab.com/DerTroglodyt/satisfactory-lua/-/raw/main/src/"
-- get internet card
local inet = computer.getPCIDevices(findClass("FINInternetCard"))[1]
local nc = computer.getPCIDevices(findClass("NetworkCard"))[1]

-- get library from internet and write it to /lib/<name>. returns true if succesful or error string.
function fetchLib(libName)
    local name = libName..".lua"
    local req = inet:request(gitRoot..name, "GET", "")
    local result, libdata = req:await()
    if (result ~= 200) then
        print(result)
        print(libdata)
        return "Fetch of library <"..path.."> failed!"
    end
    libs[libName] = libdata
end

function fetchAllLibs()
    local libNames = {"json", "boot", "ed", "fp", "test", "util", "bootAlHuette"}
    for _, name in ipairs(libNames) do
        print("Fetching "..name.."...")
        fetchLib(name)
    end
end

-- Provide libraries over network to other cpus
fetchAllLibs()
nc:open(80)
event.clear()
event.listen(nc)
print("starting lib server...")
while true do
    local e, s, p1, p2, p3 = event.pull()
    --    print("Event:"..tostring(e).." s:"..tostring(s).." p1:"..tostring(p1).." p2:"..tostring(p2))
    if e == "NetworkMessage" then
        local rcv = p1
        local port = p2
        local x = p3:find("#")
        print("received msg from " .. rcv .. ":" .. port .. " -> " .. p3)
        local cmd = p3:sub(1,x-1)
        local msg = p3:sub(x+1)
        if cmd == "GETLIB" then
            local libData = libs[msg]
            if libData ~= nil then
                nc:send(rcv, port, "SENDLIB#"..libData)
            else
                nc:send(rcv, port, "ERROR#Unknown library '"..msg.."'!")
            end
        elseif cmd == "REFETCH" then
            print("Refetching all libs...")
            fetchAllLibs()
            nc:send(rcv, port, "REFETCHDONE#Ok.")
        else
            nc:send(rcv, port, "ERROR#Unknown command '"..cmd.."'!")
        end
    end
end

SMMDebug_2022-2-5_0-53-28.zip

Panakotta00 commented 2 years ago

So if you still have this issues... let me know and sen the bug again...

the crash you sent me is related to the VFS (FileSystems, Drives, Floppies etc.) and that when it saves the game. aka. it doesn't seem to be related to the network message system at all... I still can not say what the issue is... just that it happens when it wants to save your file system... it seems to try to open a file to read it and save it... but it fails to open the file... this can either be caused by some mod related issue... but can also easily be caused by something on your host system that opened a file handle/stream and interacts with the file (and doesnt allow the game to read it)