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

ExploreRegion: Fix encoding X and Z #1357

Merged
merged 1 commit into from
Jan 13, 2022
Merged

Conversation

jippi
Copy link
Contributor

@jippi jippi commented Jan 7, 2022

Use a long to store the two ints (x is upper and z is lower) - this is guaranteed to work with any world map size out there.

It also properly handle negative values that the old implementation sometimes did not properly manage.

This might use slightly more RAM, but should provide support for actual infinite/huge map sizes


Context

Negative coordinates in both X and Z do not encode properly back and forth between getPlace() and getChunkX() + getChunkZ()

Steps to reproduce

  • join server
  • join explorer
  • walk a couple of chunks in a negative X and/or Z chunk position
  • /stop the server
  • join the server again
  • walk the same couple of chunks
  • double entries from the same user in explorerData (and XP/money are given each time)

it only bugs out if I do a /stop - and it's extremely reproducible on my server.

Doing /jobs reload and other commands do not affect it, it seems to be a storage/read back on start-up issue.

As seen from my debugging branch the X/Z values do not always encode back and forth correctly, causing bad data (and duplicated rows) in the DB

1.18-test_1       | [19:52:17 WARN]: [Jobs] ADDING chunk value -92/13
1.18-test_1       | [19:52:17 WARN]: [Jobs] Returning would be -68/13

the X and Z coords matches F3 in-game, but the reversing does not 🙂
but its true for both x and z values, once the player are in negative territory, they skew

SQLite output (same issue with MySQL)

sqlite> select * from exploreData order by chunkZ,chunkX;
122|world|-68|13|1|1 
124|world|-68|13|1|1 <- duplicate of previous row
121|world|-68|14|1|1
125|world|-68|14|1|1 <- duplicate of previous row

Version info

[Fri, 7. Jan 2022 16:25:25 CET INFO] Jobs: 5.0.1.0 SqLite
[Fri, 7. Jan 2022 16:25:25 CET INFO] CMILib: 1.1.0.6
[Fri, 7. Jan 2022 16:25:25 CET INFO] Server: Paper(137) 1.18.1-R0.1-SNAPSHOT
[Fri, 7. Jan 2022 16:25:25 CET INFO] Economy: Essentials Economy Vault: 1.7.3-b131

Plugins

Plugins (48): AdvancedAFK, ArmoredElytra, AuctionHouse, BungeeTabListPlus, ChestShop, ChestShopNotifier, ChestSort, CMILib, CoreProtect, DiscordSRV, DiscordSRV-Staff-Chat, dynmap, Essentials, FastChunkPregenerator, floodgate, Graves, HolographicDisplays, HoloPlots, InvSeePlusPlus, Jobs, Lands, LeaderHeadsRevamped, LevelledMobs, LuckPerms, MoreMobHeads, Multiverse-Core, Multiverse-Inventories, Multiverse-Portals, MyCommand, NetworkManager, PlaceholderAPI, PlaceholderSIGN, Plot2Dynmap, PlotSquared, ProtocolLib, ServerlistMOTD*, ShowItem, SimplePortals, spark, SurvivalInvisiframes, UnifiedMetrics, Vault, VentureChat, ViaBackwards, ViaVersion, Votifier, VotingPlugin, WorldEdit

Signed-off-by: Christian Winther [email protected]

@jippi jippi force-pushed the fix-explore-cache branch from d2e6597 to ecae927 Compare January 7, 2022 22:51
Use a long to store the two ints (x is upper and z is lower) - this is guranteed to work with any world map size out there.

It also properly handle negative values that the old implementation some times did not properly manage.

This might use slighly more RAM, but should provide support for actual infinite / huge map sizes

Signed-off-by: Christian Winther <[email protected]>
@jippi jippi force-pushed the fix-explore-cache branch from ecae927 to a340b99 Compare January 7, 2022 22:51
@Zrips Zrips merged commit 41df0ea into Zrips:master Jan 13, 2022
@jippi jippi deleted the fix-explore-cache branch January 13, 2022 16:45
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