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

Remove hacks around checking sync while disposing the shellmap #19714

Merged
merged 3 commits into from Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions OpenRA.Game/Sync.cs
Expand Up @@ -181,10 +181,10 @@ public static T RunUnsynced<T>(World world, Func<T> fn)
public static T RunUnsynced<T>(bool checkSyncHash, World world, Func<T> fn)
{
// PERF: Detect sync changes in top level entry point only. Do not recalculate sync hash during reentry.
if (inUnsyncedCode || world == null)
if (!checkSyncHash || inUnsyncedCode || world == null)
return fn();

var sync = checkSyncHash ? world.SyncHash() : 0;
var sync = world.SyncHash();
inUnsyncedCode = true;

try
Expand All @@ -194,7 +194,10 @@ public static T RunUnsynced<T>(bool checkSyncHash, World world, Func<T> fn)
finally
{
inUnsyncedCode = false;
if (checkSyncHash && sync != world.SyncHash())

// When the world is disposing all actors and effects have been removed
// So do not check the hash for a disposing world since it definitively has changed
if (!world.Disposing && sync != world.SyncHash())
abcdefg30 marked this conversation as resolved.
Show resolved Hide resolved
throw new InvalidOperationException("RunUnsynced: sync-changing code may not run here");
}
}
Expand Down
4 changes: 1 addition & 3 deletions OpenRA.Mods.Common/Widgets/Logic/Editor/NewMapLogic.cs
Expand Up @@ -70,9 +70,7 @@ public NewMapLogic(Action onExit, Action<string> onSelect, Widget widget, World

Action<string> afterSave = uid =>
{
// HACK: Work around a synced-code change check.
// It's not clear why this is needed here, but not in the other places that load maps.
Game.RunAfterTick(() => Game.LoadEditor(uid));
Game.LoadEditor(uid);

Ui.CloseWindow();
onSelect(uid);
Expand Down
4 changes: 1 addition & 3 deletions OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs
Expand Up @@ -343,9 +343,7 @@ void OnRemoteDirectConnect(ConnectionTarget endpoint)

void LoadMapIntoEditor(string uid)
{
// HACK: Work around a synced-code change check.
// It's not clear why this is needed here, but not in the other places that load maps.
Game.RunAfterTick(() => Game.LoadEditor(uid));
Game.LoadEditor(uid);

DiscordService.UpdateStatus(DiscordState.InMapEditor);

Expand Down