Jump to content

Bug Open File Zip on Lua App Crash.


Yue
 Share

Go to solution Solved by Josh,

Recommended Posts

I have discovered something that may have something to do with the problem, if a zip file is in the root directory of the directory, when I try to launch the map editor it does not open, if I remove the zip file, it loads the editor without problems, maybe this can give a clue.

image.thumb.png.97ba6c0fa9add70796d2c0788866c9ee.png

  • Upvote 1

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

42 minutes ago, Josh said:

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

I have done this in my project that Yue is running.  It doesn't print anything it just crashes.  LoadPackage() itself is crashing shortly after it prints "Loading package".

Link to comment
Share on other sites

18 minutes ago, Yue said:

I have discovered something that may have something to do with the problem, if a zip file is in the root directory of the directory, when I try to launch the map editor it does not open, if I remove the zip file, it loads the editor without problems, maybe this can give a clue.

image.thumb.png.97ba6c0fa9add70796d2c0788866c9ee.png

Please upload the zip file that causes this problem.

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 asked before what your user name on Windows is, and you said it is "Yue" but I can see in your video the user folder is called "este equipo" or something like that?

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 am encountering a connection where if I try to run the game with either executable, it shuts down unexpectedly. And if I try to launch the map editor, unexpected shutdown, but if I remove the zip, everything works fine.

image.thumb.png.65cba2a32ce96b97b8da9ef17773c555.png

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

I uploaded a new build of the editor on Steam that might fix this. I can't tell, since I can't produce any error, but I have a suspicion.

  • Like 2

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 think the problem is in libzip, here. I think it has something to do with your locale and it not converting the path correctly to a wide string:

zip_source_file_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) {
    int size;
    wchar_t *wfname;
    zip_source_t *source;

    if (fname == NULL || length < ZIP_LENGTH_UNCHECKED) {
        zip_error_set(error, ZIP_ER_INVAL, 0);
        return NULL;
    }

    /* Convert fname from UTF-8 to Windows-friendly UTF-16. */
    size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, fname, -1, NULL, 0);
    if (size == 0) {
        zip_error_set(error, ZIP_ER_INVAL, 0);
        return NULL;
    }
    if ((wfname = (wchar_t *)malloc(sizeof(wchar_t) * size)) == NULL) {
        zip_error_set(error, ZIP_ER_MEMORY, 0);
        return NULL;
    }
    MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, fname, -1, wfname, size);

    source = zip_source_win32w_create(wfname, start, length, error);

    free(wfname);
    return source;
}

In zip_source_file_win32_utf8.c

  • 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

image.thumb.png.135d9d772a8cb21c1f53770b3544defb.png

 

If the zip is empty, the editor starts, but you see the message on the console that the zip has failed to load. If the zip has any files inside it, the editor will not start.

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

Probably the best thing for me to do is modify this lib so it accepts a wide string for the path. It will take some time.

  • Like 1
  • Upvote 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

 

 

 

 

It is still totally the same, what I was saying to the spider pig, for me this is very confusing.

Even if there is a zip inside the game directory, it does not load the map editor.  And when trying to load the zip from Lua script, it closes in the zip loading and does not give depuation messages.

image.thumb.png.f99a2b6399d55b568512a81ec34cfb52.png

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

27 minutes ago, Yue said:

Even if there is a zip inside the game directory, it does not load the map editor.  And when trying to load the zip from Lua script, it closes in the zip loading and does not give depuation messages.

I did not update the Lua binary yet, just the editor.

  • Like 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

 

I confirm that in previous versions of leadwerks it is possible to load a zip file, current version backwards 0.9.1.

The zip file does not interfere with the loading of the editor if it is in the root directory of the game. 

From the Lua script it does load the file without problems and does not close abruptly. 

image.thumb.png.93255ff26f1de9cb92fcb8a864ad36d7.png

image.thumb.png.d7409b591f6bb92ca5b65c10feee2aed.png

 

image.thumb.png.74525d98a65dbeaa995eae3e56be649c.png

  • Thanks 1

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

  • 4 weeks later...

That is interesting. Now we know the problem is definitely in the libzip library, in the zip_source_make_command_bitmap function, which means I can compile it as a DLL that you can run in the debugger to see what is going on...

  • Like 1
  • Upvote 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

  • 4 weeks later...

@Yue I found I did not dig deep enough to the deepest level of the file read system in the zip library. The updated editor that's on 0.9.7 beta now will actually use the wide string path to load zip files now.

I tried renaming a project folder to "здоровье" and the editor was able to load files from a zip in this project.

  • Like 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

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...