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

Add map refresh #19885

Merged
merged 2 commits into from Apr 14, 2022
Merged

Add map refresh #19885

merged 2 commits into from Apr 14, 2022

Conversation

PunkPun
Copy link
Member

@PunkPun PunkPun commented Jan 17, 2022

Closes #19420

This is my first code contribution to ORA, so there's probably a lot of room for improvement

The way map refresh works:
MapCache has 2 instances of MapDirectoryTracker tracking both the custom and official maps folders for changes respectively. When they detect something, they analyse what and if they need to take action, then they put or edit appropriate actions in mapActionQueue. Whenever MapCache is queried for maps, it is updated from the records in mapActionQueue

I needed to queue actions because FileSystemWatcher is spamming quite a lot and those actions are often in an illogical order. F.e. when I add a file it calls Changed, then Created. Another example is when I add / edit an uncompressed map, then it spams a ton of actions. Furthermore maps are never deleted from MapCache. So if we were to update MapCache at every FileSystemWatcher event it would likely clog up memory with very similar maps. The queue is designed to address all of this by updating MapCache only when it is required

Map editor no longer updates the cache, since it already happens when when MapDirectoryTracker kicks in

The game now selects the last edited map when entering map chooser. If in lobby the selected map is updated it, it will switch to the updated version. I'm not sure if this change is necessary, but it would be fairly convenient.

OpenRA.Game/Map/MapCache.cs Outdated Show resolved Hide resolved
OpenRA.Game/Map/MapCache.cs Outdated Show resolved Hide resolved
OpenRA.Game/Map/MapCache.cs Outdated Show resolved Hide resolved
@PunkPun PunkPun force-pushed the refresh-map-selection branch 4 times, most recently from 9daa4a7 to a2e7f69 Compare January 18, 2022 16:14
@PunkPun PunkPun force-pushed the refresh-map-selection branch 2 times, most recently from 947936f to 3612602 Compare January 18, 2022 21:42
@PunkPun
Copy link
Member Author

PunkPun commented Jan 18, 2022

Fixed all bugs and crashes I could find. I changed ComputeUID to include map.png. This change should be done in another pr, but I added it here temporarily as it is a very noticeable bug #19891

OpenRA.Game/Map/Map.cs Outdated Show resolved Hide resolved
@PunkPun PunkPun force-pushed the refresh-map-selection branch 3 times, most recently from 9e6a47b to 317d256 Compare January 19, 2022 20:53
@PunkPun PunkPun force-pushed the refresh-map-selection branch 4 times, most recently from 68d8c1d to 5716d67 Compare January 22, 2022 19:03
@PunkPun
Copy link
Member Author

PunkPun commented Jan 22, 2022

rebased

@PunkPun PunkPun force-pushed the refresh-map-selection branch 2 times, most recently from a8652b8 to 65cf3de Compare January 31, 2022 11:33
@PunkPun
Copy link
Member Author

PunkPun commented Jan 31, 2022

Now when a user picks a map in map chooser that has been updated while user was in map chooser window, the game will act as if nothing was selected and exit.

I also separated MapDirectoryTracker class into it's own file and rebased

OpenRA.Game/Map/MapCache.cs Show resolved Hide resolved
OpenRA.Game/Map/MapCache.cs Outdated Show resolved Hide resolved
OpenRA.Game/Map/MapCache.cs Show resolved Hide resolved
OpenRA.Game/Map/MapDirectoryTracker.cs Show resolved Hide resolved
OpenRA.Game/Map/MapDirectoryTracker.cs Outdated Show resolved Hide resolved
OpenRA.Game/Map/MapDirectoryTracker.cs Outdated Show resolved Hide resolved
OpenRA.Game/Map/MapCache.cs Outdated Show resolved Hide resolved
OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs Outdated Show resolved Hide resolved
OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs Outdated Show resolved Hide resolved
OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs Outdated Show resolved Hide resolved
@PunkPun PunkPun force-pushed the refresh-map-selection branch 3 times, most recently from 5d1caf6 to 0fa2f61 Compare February 5, 2022 19:31
@PunkPun PunkPun force-pushed the refresh-map-selection branch 5 times, most recently from bdc2a6d to 48c16a9 Compare February 6, 2022 15:30
@PunkPun
Copy link
Member Author

PunkPun commented Feb 6, 2022

Now when you force start or click on a ready checkbox, the game properly handles the selected map becoming unavailable. The previous behaviour was quite unpolished. On game start the screen become black, and then the lobby is refreshed.

@PunkPun
Copy link
Member Author

PunkPun commented Feb 6, 2022

Handled a crash. Now if you try to play a map in MissionSelector that has been marked as unavailable you will exit MissionSelector. Same behaviour as Map Editor MapChooser

@PunkPun PunkPun force-pushed the refresh-map-selection branch 3 times, most recently from e61a538 to 158f7e5 Compare February 10, 2022 12:58
@PunkPun
Copy link
Member Author

PunkPun commented Feb 10, 2022

Now when you force start or click on a ready checkbox

I undid the checkbox behaviour (but kept force start). My solution felt a bit hacky and honestly unnecessary. It's a minor polish feature that can be added in a followup pr

RoosterDragon
RoosterDragon previously approved these changes Feb 26, 2022
RoosterDragon
RoosterDragon previously approved these changes Feb 26, 2022
@PunkPun
Copy link
Member Author

PunkPun commented Apr 14, 2022

rebased and changed console reporting from "Added 'map'" to "'map' was added"

I'm unsure wether we should keep this reporting. For me it made sense to exist, however when looking back on it, you wouldn't really use it for anything

@Mailaender
Copy link
Member

I am fine with it, as the map editor also reports file system changes that way.

@Mailaender Mailaender merged commit b254eb0 into OpenRA:bleed Apr 14, 2022
@Mailaender
Copy link
Member

Changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to test the map without restarting the game.
6 participants