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

Refactor Automap #6555

Merged
merged 45 commits into from
Sep 15, 2023
Merged

Refactor Automap #6555

merged 45 commits into from
Sep 15, 2023

Conversation

kphoenix137
Copy link
Collaborator

@kphoenix137 kphoenix137 commented Sep 2, 2023

This is a hefty one. The automap has some issues:

  • Automap scales that aren't multiples of 25 can produce misaligned pixels and lines
  • Automap functions draw lines beyond the boundaries of their respective megatile, making it problematic to correctly align Catacombs doors
  • Caves automap incorrectly draws A LOT

Foundational Changes:

  • AmLine() split into AmOffset() and AmLine()
    • AmLine() was used for both offsetting Point as well as providing the length for drawn lines.
  • Enumerators for AmOffset() arguments: AmWidthOffset and AmHeightOffset
    • This way of using enumerators allows us to intuitively adjust offsets without needing to reference TILE_WIDTH and TILE_HEIGHT, and also softcodes these values. The enumerators are set to values that are friendly with the original assert found in AmLine(), intended to keep everything aligned to a grid.
  • Enumerators for AmLine() argument: AmLineLength
  • center offset moved from the center of the top tile to the center of the megatile
    • Automap tiles are a full megatile in size, and are drawn mostly to cover the bounds of the megatile, however, due to drawing from the center of the top tile, the entire automap appears to be a half tile too high. This was recently corrected with a workaround hack in 1.5.1.
  • Automap lines no longer are drawn outside their respective megatile boundaries
    • Previously, lines were drawn beyond the boundaries of the megatile in order to avoid leaving gaps in walls. I found this behavior to have edge cases where it was problematic. Therefore, tiles have "connection lines" drawn within a megatile to fill in gaps, with logic that depends on the context of the megatile being checked, and surrounding megatiles. These lines are drawn at the top of the megatile facing NW and/or NE. There is a caves version, due to the nature of cave walls, which draws lines at the bottom of the megatile facing SW and/or SE.

Changes:

  • Many shape drawing functions were revised
    • Many shapes were incorrectly drawn; The most noticeable case of this is in the Caves. Cave walls are located on the lower half of the megatiles, where standard walls are located on the upper half of megatiles. Cave walls were drawn as if there were in the upper half of the megatile, which caused 2 tile thick walls to have lines drawn on top of each other, and displayed an overall incorrect layout of the map.
  • Door positions are corrected
    • Previously, the drawing function for doors maintained the same logic regardless of tileset, even though different tilesets had different door placements.
  • More enumerators for special case tile types in AutomapTile::Types
    • There are 2 tiles in Hell that needed to be overridden, since they were defined as an Arch, causing a missing wall line. It was likely done this way originally because Blizzard North wanted these tiles to have a Diamond for visual consistency. I opted to use this new enumerator to draw an automap tile that contains both a Diamond and a line.
    • There is 1 tile in the Catacombs that needed to be overridden for the same reason as the above. No new enumerator was added; it was changed to behave like a standard wall.
    • There are 2 tiles in Caves that needed east and west facing corners to be added, since the current wall connection functions only draw on the tops and bottoms of metatiles, not on the sides.
    • Lava was added to the Caves and Nest automap, which includes several new enumerators for various lava tiles.
  • Extra diamonds drawn on opposite side of arches and grates
    • If an arch or grate is drawn, a diamond will be drawn on the opposite side of the opening for visual consistency. If a diamond is drawn in a dirt tile, a single pixel will be omitted to prevent drawing inside the diamond.
  • Door correction
    • To avoid a problem with the new door positions causing the door diamond to be drawn over by the next drawn automap tile, 2 functions have been added to redraw the line of the door diamond being overwritten, in any case where another tile will draw pixels over the door diamond.
  • Grates
    • Grates are now representing by 3 pixels in the path that the original line took, in order to show the player that they are not solid walls.

Source/automap.cpp Outdated Show resolved Hide resolved
@kphoenix137 kphoenix137 marked this pull request as ready for review September 9, 2023 04:00
Copy link
Collaborator

@glebm glebm left a comment

Choose a reason for hiding this comment

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

Looks much better! 🎉
Just a couple of comments and then the tests need to be updated as well!

Source/automap.cpp Outdated Show resolved Hide resolved
Source/automap.cpp Outdated Show resolved Hide resolved
@kphoenix137
Copy link
Collaborator Author

I need help

@glebm
Copy link
Collaborator

glebm commented Sep 10, 2023

The tests are failing because you cannot compare an int and an enum class directly:

- EXPECT_EQ(AmLine(AmLineLength::DoubleTile), AmLineLength::HalfTile);
+ EXPECT_EQ(AmLine(AmLineLength::DoubleTile), static_cast<int>(AmLineLength::HalfTile));

Source/automap.cpp Outdated Show resolved Hide resolved
Source/automap.cpp Outdated Show resolved Hide resolved
@FitzRoyX
Copy link

Reporting some cathedral pillar stuff that doesn't look right

Untitled888

@kphoenix137
Copy link
Collaborator Author

Can you take a screenshot of this same view but in master or release 1.5.1? I need it for reference.

@FitzRoyX
Copy link

Master
Untitled6767

@kphoenix137
Copy link
Collaborator Author

kphoenix137 commented Sep 12, 2023

Master
Untitled6767

Thank you. Yeah looks like I got confused. I thought grates were supposed to be a diamond in the same way that doors are diamonds. Backwards from how it's supposed to be.

Also interesting how all the diamonds drawn are offset. I chose to instead align them to the top tile so that they're correctly representing the pillars

@kphoenix137
Copy link
Collaborator Author

Reporting some cathedral pillar stuff that doesn't look right

Untitled888

fixed

Source/automap.cpp Outdated Show resolved Hide resolved
glebm added a commit to glebm/devilutionX that referenced this pull request Sep 13, 2023
glebm added a commit that referenced this pull request Sep 13, 2023
Source/automap.cpp Outdated Show resolved Hide resolved
Source/automap.cpp Outdated Show resolved Hide resolved
@AJenbo AJenbo merged commit c754d95 into diasurgical:master Sep 15, 2023
18 checks passed
@kphoenix137 kphoenix137 deleted the fix-automap-3 branch September 15, 2023 15:41
This was referenced Sep 15, 2023
wkdgmr pushed a commit to wkdgmr/wkdmod that referenced this pull request Oct 2, 2023
wkdgmr pushed a commit to wkdgmr/wkdmod that referenced this pull request Oct 2, 2023
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.

4 participants