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

Reduce name length in save files #7775

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kphoenix137
Copy link
Collaborator

@kphoenix137 kphoenix137 commented Feb 22, 2025

The game only allows players to create a name of length 15, so we can reduce the size of pName to 16 bytes (leaves 1 byte for the null-terminated character). This opens up free space which could be used for modding purposes, although using this space could cause problems if save files were moved back to vanilla, since it loads 32 bytes rather than 16. (Not sure if the null-terminated character would ignore the rest of the bytes or not)

@StephenCWills
Copy link
Member

Do we care whether renaming MP characters via the Battle.net option can exceed 15 characters?

@kphoenix137
Copy link
Collaborator Author

Do we care whether renaming MP characters via the Battle.net option can exceed 15 characters?

Yes. I hadn't considered this.

@kphoenix137
Copy link
Collaborator Author

Do we care whether renaming MP characters via the Battle.net option can exceed 15 characters?

Constantine confirmed it's 15.

@StephenCWills
Copy link
Member

StephenCWills commented Feb 23, 2025

using this space could cause problems if save files were moved back to vanilla

I suppose the issue would be that the data used by mods would only be captured in the Single Player save file. PackPlayer() uses strcpy() which only copies bytes up to the null-terminating character. Creating a new game and saving in vanilla Diablo would cause the mod's data to be lost.

But maybe the unused bytes could be used by computed values like extra item flags. Something that could be computed on load. I'm not sure if that's what you had in mind by making this change.

@kphoenix137
Copy link
Collaborator Author

using this space could cause problems if save files were moved back to vanilla

I suppose the issue would be that the data used by mods would only be captured in the Single Player save file. PackPlayer() uses strcpy() which only copies bytes up to the null-terminating character. Creating a new game and saving in vanilla Diablo would cause the mod's data to be lost.

But maybe the unused bytes could be used by computed values like extra item flags. Something that could be computed on load. I'm not sure if that's what you had in mind by making this change.

The modding part was just a potential suggestion. I suppose it would make it easier for forwards compatibility with mods that want to save more data to the player struct, since adding more fields ends up making existing saves before the field was added unrecognized.

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 this pull request may close these issues.

2 participants