be fast by default; add 'Check Sync around Unsynced Code' option in debug panel

This commit is contained in:
Chris Forbes
2011-01-08 11:49:31 +13:00
parent 93a56f9a18
commit 303525a5ba
5 changed files with 20 additions and 2 deletions

View File

@@ -34,6 +34,7 @@ namespace OpenRA.GameRules
public bool BotDebug = false;
public bool PerfGraph = false;
public float LongTickThreshold = 0.001f;
public bool SanityCheckUnsyncedCode = false;
}
public class GraphicSettings

View File

@@ -140,9 +140,11 @@ namespace OpenRA
public static T CheckSyncUnchanged<T>( World world, Func<T> fn )
{
if( world == null ) return fn();
int sync = world.SyncHash();
var shouldCheckSync = Game.Settings.Debug.SanityCheckUnsyncedCode;
int sync = shouldCheckSync ? world.SyncHash() : 0;
bool prevInUnsyncedCode = inUnsyncedCode;
inUnsyncedCode = true;
try
{
return fn();
@@ -150,7 +152,7 @@ namespace OpenRA
finally
{
inUnsyncedCode = prevInUnsyncedCode;
if( sync != world.SyncHash() )
if( shouldCheckSync && sync != world.SyncHash() )
throw new InvalidOperationException( "CheckSyncUnchanged: sync-changing code may not run here" );
}
}

View File

@@ -123,6 +123,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
var debug = bg.GetWidget("DEBUG_PANE");
debug.GetWidget<CheckboxWidget>("PERFDEBUG_CHECKBOX").Bind(Game.Settings.Debug, "PerfGraph");
debug.GetWidget<CheckboxWidget>("GAMETIME_CHECKBOX").Bind(Game.Settings.Game, "MatchTimer");
debug.GetWidget<CheckboxWidget>("CHECKUNSYNCED_CHECKBOX").Bind(Game.Settings.Debug, "SanityCheckUnsyncedCode");
bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => {
Game.Settings.Save();

View File

@@ -217,3 +217,10 @@ Background@SETTINGS_MENU:
Width:300
Height:20
Text:Show Game Time Counter
Checkbox@CHECKUNSYNCED_CHECKBOX:
Id:CHECKUNSYNCED_CHECKBOX
X:0
Y:60
Width:300
Height:20
Text:Check Sync around Unsynced Code

View File

@@ -217,3 +217,10 @@ Background@SETTINGS_MENU:
Width:300
Height:20
Text:Show Game Time Counter
Checkbox@CHECKUNSYNCED_CHECKBOX:
Id:CHECKUNSYNCED_CHECKBOX
X:0
Y:60
Width:300
Height:20
Text:Check Sync around Unsynced Code