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

feat: Cleans up UOP file handling. Adds automatic bounds.bin generation #1744

Merged
merged 11 commits into from
May 2, 2024

Conversation

kaczy93
Copy link
Contributor

@kaczy93 kaczy93 commented Apr 27, 2024

It allows for easy access to art dimensions and real bounds based on the pixel transparency.
Used for dynamically sized gumps and stuff.
Code is rough on the edges since it's almost untouched ServUO code, but System.Drawing.Imaging references are gone.
Tested and gives exactly the same results as original ServUO code.

@CLAassistant
Copy link

CLAassistant commented Apr 27, 2024

CLA assistant check
All committers have signed the CLA.

@kamronbatman kamronbatman changed the title Read art size and real bounds directly from client files feat: Adds reading art file for bounds Apr 28, 2024
@kamronbatman kamronbatman changed the title feat: Adds reading art file for bounds feat: Cleans up UOP file handling. Adds automatic bounds.bin generation Apr 30, 2024
return xMax switch
{
// If no non-black pixels were found, return an empty rectangle
-1 => Rectangle2D.Empty,
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that in RunUO/ServUO, this value is [0, 0, 0xFFFF, 0xFFFF]. Intentionally different here. if the entire pic is black, there are no bounds, so we can keep it as all 00's. This also allows us to easily detect "empty" or "missing" entries without a validation structure.

private void ConvertToMapEntries(FileStream stream)
{
// Sorting by offset to make seeking faster
Array.Sort(_uopMapEntries, (a, b) => a.Offset.CompareTo(b.Offset));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only doable because I don't think the hashed file name order is important. I also don't think those files match the order field in the data block.

TODO: In the future we can memory map this and get good performance and wouldn't need the sort.

@kamronbatman kamronbatman merged commit dc118d8 into modernuo:main May 2, 2024
12 of 13 checks passed
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.

None yet

3 participants