push the check-synchash-doesn't-change pattern into a utility fn. furthur reduce the number of uses on Game.world
This commit is contained in:
@@ -129,5 +129,22 @@ namespace OpenRA
|
||||
return p.Index * 0x567;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void CheckSyncUnchanged( World world, Action fn )
|
||||
{
|
||||
int sync = world.SyncHash();
|
||||
fn();
|
||||
if( sync != world.SyncHash() )
|
||||
throw new InvalidOperationException( "Desync in DispatchMouseInput" );
|
||||
}
|
||||
|
||||
public static T CheckSyncUnchanged<T>( World world, Func<T> fn )
|
||||
{
|
||||
int sync = world.SyncHash();
|
||||
var ret = fn();
|
||||
if( sync != world.SyncHash() )
|
||||
throw new InvalidOperationException( "Desync in DispatchMouseInput" );
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user