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

project: Use pragma pack and remove static_assert spam #773

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

F1F7Y
Copy link
Member

@F1F7Y F1F7Y commented Aug 25, 2024

Only removes the static_assert spam, doesn't fix any wonky classes.

@F1F7Y F1F7Y added needs testing Changes from the PR still need to be tested needs code review Changes from PR still need to be reviewed in code labels Aug 25, 2024
@GeckoEidechse GeckoEidechse changed the title project: use pragma pack and remove static_assert spam project: Use pragma pack and remove static_assert spam Aug 28, 2024
@GeckoEidechse GeckoEidechse added the feedback wanted Feedback is wanted whether the changes by this PR are desired label Aug 28, 2024
@GeckoEidechse
Copy link
Member

Talking with @RoyalBlue1 in vc about this and we kinda agree that in regards to the static_assert while it does hurt readability a bit, it's safer to keep them, especially given the fact that we have a size mismatch as pointed out by your code comment.

That being said we should still do the pragma pack part ofc. Maybe splice from the PR so that we can merge it early? ^^

@F1F7Y
Copy link
Member Author

F1F7Y commented Aug 28, 2024

Talking with @RoyalBlue1 in vc about this and we kinda agree that in regards to the static_assert while it does hurt readability a bit, it's safer to keep them, especially given the fact that we have a size mismatch as pointed out by your code comment.

The size mismatch is because the northstar class is wrong ( see CPlayer ) . While for basic classes the static_assert does hurt readability only a bit for larger classes ( once again see CPlayer and notice it inherits from other large classes ) it would hurt a LOT. There's also the argument that we have classes without static_assert and pragma packing and they haven't broken and unless we change the build system they wont break :).

That being said we should still do the pragma pack part ofc.

The static_assert is fine imo but ig we can yeah

Maybe splice from the PR so that we can merge it early? ^^

No :P, this is already split as i didnt want it to be too large.

@GeckoEidechse
Copy link
Member

I think the reasoning @RoyalBlue1 and I had in regards to the static_assert was to catch any case in which someone would accidentally swap class members.

I don't really hold too strong of an opinion there other than that I prefer to be overly cautious with checks to assert assumptions early to prevent weird behaviour caused by broken assumptions.

I'll leave the discussion up between the two of you ^^

@ASpoonPlaysGames
Copy link
Contributor

I'd argue that they can be removed for cases where we have mapped out all (or the vast majority) of the members. Member offsets accidentally being changed is much more likely to happen when we have huge unk gaps between members

@F1F7Y
Copy link
Member Author

F1F7Y commented Aug 28, 2024

Imo we have code review to catch these kinds of errors. If we enforce the // Offset ( Size ) comments its going to be even easier to catch.

Also anything from datamaps doesnt need offset checks at all as it was given to us by the game (eg CPlayer).

@p0358
Copy link
Contributor

p0358 commented Sep 30, 2024

I am against removing static_asserts as someone who did a good deal of effort to convince people to add them in the first place xD there's no reason not to have them honestly, and they'll save you in times you might not even expect. Even for fully mapped classes I wouldn't be comfortable removing those, various unexpected things can happen, too many to just cross one's fingers that everything is always gonna be as we expect. Rule of thumb should be, if you need any offset of any member to match up with something in existing game's code, have a static assert for it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback wanted Feedback is wanted whether the changes by this PR are desired needs code review Changes from PR still need to be reviewed in code needs testing Changes from the PR still need to be tested
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants