Jump to content

Bug Open File Zip on Lua App Crash.


Yue
 Share

Go to solution Solved by Josh,

Recommended Posts

@Yue and I have been discussing on discord about why my game does not load packages on his PC.  On my PC and several others who have run my game it works as it should.

The game states that it is loading the package then it will crash.  This occurs for both password protected and non password protected zip files.

Writing an example for this is extremely hard as It's only happening on his PC.  The only thing that we can see what is different is that his Windows PC is in Spanish.  Could that be effecting something?  @Yue Can you please post your system specs here for Josh?

  • Upvote 1
Link to comment
Share on other sites

I tried this and it worked with no issues:

Assert(FileType(GetPath(PATH_DESKTOP) + L"/Пожалуйста.zip") == 1);
auto p = LoadPackage(GetPath(PATH_DESKTOP) + L"/Пожалуйста.zip");

If you are storing a path in a string and not a WString you could lose information.

Please upload a zip file for me to test, or tell me what the path that is causing the problem is.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

This is my code for loading all packages within the game directory.  Yue has uploaded a zip on the thread he created.

vector<shared_ptr<Engine::Package>> packages;
void LoadPackages(Engine::WString path = "") {
    auto directories = LoadDir(path);

    for (auto dir : directories) {
        auto ext = ExtractExt(dir);
        if (ext != "") {
            if (ext == "zip" || ext == "pak") {
                auto package = LoadPackage((path != "" ? path + "\\" : "") + dir);
                if (package != nullptr) {
                    package->SetPassword("password");
                    packages.emplace_back(package);

#ifdef ENABLE_LOG
                    Log("SUCCESS : Loaded Package : " + path + "\\" + dir);
#endif
                }
                else {
#ifdef ENABLE_LOG
                    Log("ERROR : Failed to Load Package : " + path + "\\" + dir + "!");
#endif
                }
            }
        }
        else {
            LoadPackages((path != "" ? path + "\\" : "") + dir);
        }
    }
}

 

Link to comment
Share on other sites

This code works without any problem:

    auto p = LoadPackage("maps.zip");
    p->SetPassword("1500");
    auto stream = p->ReadFile("Test.ultra");

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Update main, herror continue.

 


--Initialze Steam (optional)
--if not Steamworks.Initialize() then return 1 end

--Load FreeImage plugin (optional)
local fiplugin = LoadPlugin("Plugins/FITextureLoader")

--Get the displays
local displays = GetDisplays()

--Create a window
local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_CENTER | WINDOW_TITLEBAR)

--Create a framebuffer
local framebuffer = CreateFramebuffer(window)

--Create a world
local world = CreateWorld()

--Load a map
local mapname = "Maps/start.ultra"
local cl = CommandLine()
if type(cl["map"]) == "string" then mapname = cl["map"] end
local scene = LoadMap(world, mapname)

while window:KeyDown(KEY_ESCAPE) == false and window:Closed() == false do
    
    --Garbage collection step
    collectgarbage()

    --Update the world
    world:Update()
    Steamworks.Update()
    if window:KeyDown(KEY_R) then

        local p = LoadPackage("Maps.zip")
        p:SetPassword("1500")
    end 
    --Render the world to the framebuffer
    world:Render(framebuffer)
end

Steamworks.Shutdown()

 

main.lua

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

Your code says this:

 

p:SetPasworld("1500")

 

It should be this:

 

p:SetPassword("1500")

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I do not know what the problem is. Your example runs perfectly, even if I put it in a folder with non-English characters.

  • Confused 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

You should check to make sure LoadPackage is returning a value. Right now we don't know what command is causing the problem:

local p = LoadPackage("Maps.zip")
if p == nil then
    Print("Failed to load package")
else
    p:SetPassword("1500")
end

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I have this, but it still doesn't go past loading the package, I don't get any information in the debugger before closing, just that it's loading the package.

image.thumb.png.d18f9f52fd919bd0cf7b618011076887.png

image.thumb.png.246f91c001fb5c2b1e28bc3fa29c6453.png

If for example I put a zip that doesn't exist, I get this back.

image.thumb.png.a314bb7432af151b72813fcd5469f221.png

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...