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

@@ -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" );
}
}