Skip to content

Commit c0cfacc

Browse files
committed
Merge pull request OpenRA#6832 from pchote/disable-bogus-sp-maps
Disable missions that define bogus rules.
2 parents f94b484 + ab80ce8 commit c0cfacc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

OpenRA.Mods.RA/Widgets/Logic/MissionBrowserLogic.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.IO;
1414
using System.Linq;
1515
using System.Net;
16+
using System.Threading;
1617
using OpenRA.FileSystem;
1718
using OpenRA.Graphics;
1819
using OpenRA.Network;
@@ -107,7 +108,9 @@ public MissionBrowserLogic(Widget widget, Action onStart, Action onExit)
107108
if (allMaps.Any())
108109
SelectMap(allMaps.First());
109110

110-
widget.Get<ButtonWidget>("STARTGAME_BUTTON").OnClick = StartMission;
111+
var startButton = widget.Get<ButtonWidget>("STARTGAME_BUTTON");
112+
startButton.OnClick = StartMission;
113+
startButton.IsDisabled = () => selectedMapPreview.RuleStatus != MapRuleStatus.Cached;
111114

112115
widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
113116
{
@@ -145,6 +148,10 @@ void SelectMap(Map map)
145148
StopVideo();
146149

147150
selectedMapPreview = Game.modData.MapCache[map.Uid];
151+
152+
// Cache the rules on a background thread to avoid jank
153+
new Thread(selectedMapPreview.CacheRules).Start();
154+
148155
var video = selectedMapPreview.Map.PreviewVideo;
149156
var videoVisible = video != null;
150157
var videoDisabled = !(videoVisible && GlobalFileSystem.Exists(video));
@@ -187,6 +194,9 @@ void StartMission()
187194
{
188195
StopVideo();
189196

197+
if (selectedMapPreview.RuleStatus != MapRuleStatus.Cached)
198+
return;
199+
190200
OrderManager om = null;
191201

192202
Action lobbyReady = null;

0 commit comments

Comments
 (0)