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 BotDebug = false;
public bool PerfGraph = false; public bool PerfGraph = false;
public float LongTickThreshold = 0.001f; public float LongTickThreshold = 0.001f;
public bool SanityCheckUnsyncedCode = false;
} }
public class GraphicSettings public class GraphicSettings

View File

@@ -140,9 +140,11 @@ namespace OpenRA
public static T CheckSyncUnchanged<T>( World world, Func<T> fn ) public static T CheckSyncUnchanged<T>( World world, Func<T> fn )
{ {
if( world == null ) return 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; bool prevInUnsyncedCode = inUnsyncedCode;
inUnsyncedCode = true; inUnsyncedCode = true;
try try
{ {
return fn(); return fn();
@@ -150,7 +152,7 @@ namespace OpenRA
finally finally
{ {
inUnsyncedCode = prevInUnsyncedCode; inUnsyncedCode = prevInUnsyncedCode;
if( sync != world.SyncHash() ) if( shouldCheckSync && sync != world.SyncHash() )
throw new InvalidOperationException( "CheckSyncUnchanged: sync-changing code may not run here" ); 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"); var debug = bg.GetWidget("DEBUG_PANE");
debug.GetWidget<CheckboxWidget>("PERFDEBUG_CHECKBOX").Bind(Game.Settings.Debug, "PerfGraph"); debug.GetWidget<CheckboxWidget>("PERFDEBUG_CHECKBOX").Bind(Game.Settings.Debug, "PerfGraph");
debug.GetWidget<CheckboxWidget>("GAMETIME_CHECKBOX").Bind(Game.Settings.Game, "MatchTimer"); 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 => { bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => {
Game.Settings.Save(); Game.Settings.Save();

View File

@@ -217,3 +217,10 @@ Background@SETTINGS_MENU:
Width:300 Width:300
Height:20 Height:20
Text:Show Game Time Counter 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 Width:300
Height:20 Height:20
Text:Show Game Time Counter 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