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

Cache issue with updated maps #28

Open
matchab opened this issue Oct 6, 2024 · 4 comments
Open

Cache issue with updated maps #28

matchab opened this issue Oct 6, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@matchab
Copy link

matchab commented Oct 6, 2024

Hello,

When a map has been opened via the TMX menu ingame, then if the map file is updated on TMX, it's impossible to open the new version ingame. It seems that the map is cached locally, and is never updated.

Steps to reproduce:

  1. Create a new map and upload it on TMX.
  2. Search the map via the TMX menu ingame, and click on Play map.
  3. Go back to the editor, modify the map, then upload the new version on TMX (in the same TMX entry).
  4. Search the map again via the TMX menu, and click on Play map.
  5. The old version of the map is loaded instead of the new one.

The only way I found to get the latest version of the map is to manually delete the game cache files, which is very inconvenient as it requires to restart the game.

@GreepTheSheep
Copy link
Owner

tbf this isn't a bug in the plugin since it's the game cache's fault. I need to find a way to delete the map file from the game cache then the game can download the newest version of the map

@GreepTheSheep
Copy link
Owner

Found out that I also need to do some modifications on a cache file (checksum.txt) that lists all user and shared data (like local maps, downloaded skins, map mods etc...) with their checksums.

Since that file is in XML format and Openplanet can't do XML serialization at the moment, we might need to wait a bit.
I already opened a issue on Openplanet more than 2 years ago about this openplanet-nl/issues#110

@GreepTheSheep GreepTheSheep added the enhancement New feature or request label Nov 13, 2024
@matchab
Copy link
Author

matchab commented Nov 13, 2024

Hey thanks for your feedback.

However, I finally took the time to dig in the code, and I wonder if we can solve the problem with a very simple trick. I can't access the code of Openplanet, but I assume (from experience) that the function ManiaTitleControlScriptAPI.PlayMap does use the URL of the map as cache key. So, we just need to modify the URL.

The trick is to add a URL parameter which is meaningless for TMX, but will change the URL from Openplanet's point of view. For example:

app.ManiaTitleControlScriptAPI.PlayMap("https://"+MXURL+"/maps/download/"+mapId+"?t="+mapUpdatedAt, Mode, "");

I haven't tested it, so maybe my guess about the cache key is wrong. But if you can give it a try, let me know if it works :)

@matchab
Copy link
Author

matchab commented Nov 14, 2024

Ah! I did some tests with your other plugin Load Map with URL, and it works like a charm. Here is the content of checksum.txt, we can see there are two cache entries for the same map, because the URL is different:

One map two cache entries

Edit : now this trick may not looks very "clean". A better solution would be to have a TMX API endpoint that allow to download a map with its TrackUID, so we can generate proper cache entries based on this identifier, like:

https://trackmania.exchange/maps/download/uid/<TrackUID of the map>

But idk if we can request that to TMX developers 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants