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

fix: crash concurrent modification/casting in tile management #3107

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

dudantas
Copy link
Member

@dudantas dudantas commented Nov 12, 2024

Description

This PR adds the implementation for dynamically determining the type of tile (HouseTile, StaticTile, DynamicTile) when creating a new tile object. The motivation is to correctly identify and assign specific tile types, which enhances code readability and maintainability. The change also ensures that houses have associated HouseTile objects for better data integrity. No additional dependencies are required for this change.

Fixes this crash: crash house.txt

Behaviour

Actual

Tiles are being created without properly distinguishing between house, static, and dynamic types.

Expected

House tiles should be identified and instantiated as HouseTile objects, and other tiles should be correctly instantiated as StaticTile or DynamicTile based on the cached tile data.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested

The changes have been tested by:

  • Running scenarios where house, static, and dynamic tiles are created to ensure proper instantiation.
  • Verifying the correct behavior in the game client when interacting with house tiles.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Fixed issues related to concurrent modification of tile within safeCall by capturing the variable by reference. Added a null check for house to ensure safe usage. Updated the casting mechanism to improve robustness and avoid undefined behavior. These changes enhance thread safety and stability in the tile management system.
@dudantas dudantas force-pushed the dudantas/fix-crash-in-mapcache branch from b35fba1 to a14dcc7 Compare November 12, 2024 22:57
@dudantas dudantas changed the title fix: concurrent modification and casting in tile management fix: crash concurrent modification/casting in tile management Nov 13, 2024
@dudantas dudantas merged commit d360a63 into main Nov 13, 2024
35 checks passed
@dudantas dudantas deleted the dudantas/fix-crash-in-mapcache branch November 13, 2024 03:02
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