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

[MapleLib] Fixed copyright header parsing (#77) #79

Merged
merged 1 commit into from
Nov 5, 2020
Merged

[MapleLib] Fixed copyright header parsing (#77) #79

merged 1 commit into from
Nov 5, 2020

Conversation

shavitush
Copy link
Contributor

@shavitush shavitush commented Nov 4, 2020

Closes #77.

This patch fixes parsing for the copyright part in the WZ file's header and therefore, fixes parsing for WZ files that were produced by the ancient versions of HaCreator. I found that the issue happens because the game client reads a fixed amount of bytes for the copyright string however the old version of MapleLib for some reason wrote a 50 instead of a 0 (null terminator) at the end of the string, therefore -- breaking it all apart

It's a bit hacky (and hardcoded). I accomplished it by reversing the parsing from the MapleLib library I had which happened to have the correct parsing patched into it.

I have tested this patch on various WZ files including stock v83, a variety of modded v83s, stock v84, v92, v95, v127, v162, v176, stock v179, Kastia's v179, v213.. all seems well!

This patch fixes parsing for copyright parsing in the WZ file's header and therefore, fixes parsing for WZ files that were produced by the ancient versions of HaCreator.
this.Header.Copyright = reader.ReadString((int)(Header.FStart - 17U));

reader.ReadBytes(1);
reader.ReadBytes((int)(Header.FStart - (ulong)reader.BaseStream.Position));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I see the proper way would be just to not do these 2 byte reads and instead move the reader.BaseStream.Position to Header.FStart

Copy link
Contributor Author

@shavitush shavitush Nov 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as much as I'd like to do that, that would break the header upon saving the file (we should read the data - not skip it)

@lastbattle
Copy link
Owner

lastbattle commented Nov 5, 2020

Looks ok in my testing on GMS v83, v188. SEA v15, 198.
I'll just merge this for now.

@lastbattle lastbattle merged commit 6051f36 into lastbattle:master Nov 5, 2020
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.

Unable to open certain files
3 participants