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

Create an alignment function for EGG::Stream to handle padding bytes #129

Open
vabold opened this issue Jul 17, 2024 · 0 comments
Open

Create an alignment function for EGG::Stream to handle padding bytes #129

vabold opened this issue Jul 17, 2024 · 0 comments
Labels
engine Code involving engine (C++) improvement Improvement to existing code P4 Priority: Trivial

Comments

@vabold
Copy link
Owner

vabold commented Jul 17, 2024

It would look something like this:

    s32 align(s32 alignment = 4);

    template <ParseableType T>
    s32 align() {
        return align(sizeof(T));
    }

The non-template version takes in an s32 alignment. If the alignment is positive, it rounds up. For completion, if the alignment is negative, it rounds down. The return value is the change in m_index as a result. It has a default parameter of 4; we typically target 32-bit files, so we assume that struct alignment is 4.

The template version would align to the nearest valid index for a given parseable type. We ensure that it's a parseable type, as if we are aligning for a struct, the non-template version should be used instead.

@vabold vabold added engine Code involving engine (C++) improvement Improvement to existing code P4 Priority: Trivial labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine Code involving engine (C++) improvement Improvement to existing code P4 Priority: Trivial
Projects
None yet
Development

No branches or pull requests

1 participant