Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOC padding is wrong #23

Closed
sergeikrasnikov opened this issue Dec 14, 2022 · 2 comments · Fixed by #24
Closed

TOC padding is wrong #23

sergeikrasnikov opened this issue Dec 14, 2022 · 2 comments · Fixed by #24

Comments

@sergeikrasnikov
Copy link

sergeikrasnikov commented Dec 14, 2022

The table of content padding calculation is wrong

In the file
PckFile.cpp
the lines 137--139

        const size_t pathToWriteSize =
            entry.Path.size() + (entry.Path.size() % PadPathsToMultipleWithNULLS);
        const size_t padding = pathToWriteSize - entry.Path.size();

The middle line should be
entry.Path.size() + (PadPathsToMultipleWithNULLS - entry.Path.size() % PadPathsToMultipleWithNULLS)

For reference, see the function
static int _get_pad(int p_alignment, int p_n)
in
editor_export_platform.cpp

@hhyyrylainen
Copy link
Owner

So the problem is that the padding amount is reverse of what it should be?

@hhyyrylainen
Copy link
Owner

Doing an excel file with various values, I noticed that the corrected math you suggested results in the correct padded lengths, but when the length is exactly right it ends up adding 4 extra padding bytes, though maybe that is actually required to have at least one terminating null?

I'll do a PR to test if the new math works fine or if there is potentially a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants