mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
breaking: get/setSyncVarHookGuard renamed to Get/SetSyncVarHookGuard
This commit is contained in:
parent
e4305b9d97
commit
e9a6b6e3d3
@ -102,8 +102,8 @@ public WeaverTypes(AssemblyDefinition assembly, Logger Log, ref bool WeavingFail
|
||||
syncVarNetworkIdentityEqualReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SyncVarNetworkIdentityEqual", ref WeavingFailed);
|
||||
syncVarGameObjectEqualReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SyncVarGameObjectEqual", ref WeavingFailed);
|
||||
setSyncVarReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SetSyncVar", ref WeavingFailed);
|
||||
setSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "setSyncVarHookGuard", ref WeavingFailed);
|
||||
getSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "getSyncVarHookGuard", ref WeavingFailed);
|
||||
setSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SetSyncVarHookGuard", ref WeavingFailed);
|
||||
getSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "GetSyncVarHookGuard", ref WeavingFailed);
|
||||
|
||||
setSyncVarGameObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "SetSyncVarGameObject", ref WeavingFailed);
|
||||
getSyncVarGameObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, assembly, Log, "GetSyncVarGameObject", ref WeavingFailed);
|
||||
|
@ -74,13 +74,14 @@ public abstract class NetworkBehaviour : MonoBehaviour
|
||||
ulong syncVarHookGuard;
|
||||
|
||||
// USED BY WEAVER to set syncvars in host mode without deadlocking
|
||||
protected bool getSyncVarHookGuard(ulong dirtyBit)
|
||||
{
|
||||
return (syncVarHookGuard & dirtyBit) != 0UL;
|
||||
}
|
||||
protected bool GetSyncVarHookGuard(ulong dirtyBit) =>
|
||||
(syncVarHookGuard & dirtyBit) != 0UL;
|
||||
|
||||
[Obsolete("Renamed to GetSyncVarHookGuard (uppercase)")]
|
||||
protected bool getSyncVarHookGuard(ulong dirtyBit) => GetSyncVarHookGuard(dirtyBit);
|
||||
|
||||
// USED BY WEAVER to set syncvars in host mode without deadlocking
|
||||
protected void setSyncVarHookGuard(ulong dirtyBit, bool value)
|
||||
protected void SetSyncVarHookGuard(ulong dirtyBit, bool value)
|
||||
{
|
||||
if (value)
|
||||
syncVarHookGuard |= dirtyBit;
|
||||
@ -88,6 +89,9 @@ protected void setSyncVarHookGuard(ulong dirtyBit, bool value)
|
||||
syncVarHookGuard &= ~dirtyBit;
|
||||
}
|
||||
|
||||
[Obsolete("Renamed to SetSyncVarHookGuard (uppercase)")]
|
||||
protected void setSyncVarHookGuard(ulong dirtyBit, bool value) => SetSyncVarHookGuard(dirtyBit, value);
|
||||
|
||||
// SyncLists, SyncSets, etc.
|
||||
protected readonly List<SyncObject> syncObjects = new List<SyncObject>();
|
||||
|
||||
@ -271,7 +275,7 @@ protected bool SyncVarGameObjectEqual(GameObject newGameObject, uint netIdField)
|
||||
// helper function for [SyncVar] GameObjects.
|
||||
protected void SetSyncVarGameObject(GameObject newGameObject, ref GameObject gameObjectField, ulong dirtyBit, ref uint netIdField)
|
||||
{
|
||||
if (getSyncVarHookGuard(dirtyBit))
|
||||
if (GetSyncVarHookGuard(dirtyBit))
|
||||
return;
|
||||
|
||||
uint newNetId = 0;
|
||||
@ -334,7 +338,7 @@ protected bool SyncVarNetworkIdentityEqual(NetworkIdentity newIdentity, uint net
|
||||
// helper function for [SyncVar] NetworkIdentities.
|
||||
protected void SetSyncVarNetworkIdentity(NetworkIdentity newIdentity, ref NetworkIdentity identityField, ulong dirtyBit, ref uint netIdField)
|
||||
{
|
||||
if (getSyncVarHookGuard(dirtyBit))
|
||||
if (GetSyncVarHookGuard(dirtyBit))
|
||||
return;
|
||||
|
||||
uint newNetId = 0;
|
||||
@ -391,7 +395,7 @@ protected bool SyncVarNetworkBehaviourEqual<T>(T newBehaviour, NetworkBehaviourS
|
||||
// helper function for [SyncVar] NetworkIdentities.
|
||||
protected void SetSyncVarNetworkBehaviour<T>(T newBehaviour, ref T behaviourField, ulong dirtyBit, ref NetworkBehaviourSyncVar syncField) where T : NetworkBehaviour
|
||||
{
|
||||
if (getSyncVarHookGuard(dirtyBit))
|
||||
if (GetSyncVarHookGuard(dirtyBit))
|
||||
return;
|
||||
|
||||
uint newNetId = 0;
|
||||
|
@ -974,15 +974,15 @@ public void HookGuard()
|
||||
ulong bit = 1ul << i;
|
||||
|
||||
// should be false by default
|
||||
Assert.That(getSyncVarHookGuard(bit), Is.False);
|
||||
Assert.That(GetSyncVarHookGuard(bit), Is.False);
|
||||
|
||||
// set true
|
||||
setSyncVarHookGuard(bit, true);
|
||||
Assert.That(getSyncVarHookGuard(bit), Is.True);
|
||||
SetSyncVarHookGuard(bit, true);
|
||||
Assert.That(GetSyncVarHookGuard(bit), Is.True);
|
||||
|
||||
// set false again
|
||||
setSyncVarHookGuard(bit, false);
|
||||
Assert.That(getSyncVarHookGuard(bit), Is.False);
|
||||
SetSyncVarHookGuard(bit, false);
|
||||
Assert.That(GetSyncVarHookGuard(bit), Is.False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user