Skip to content

Commit

Permalink
Change the ISyncSimple fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SokyranTheDragon committed Mar 18, 2024
1 parent 5fa1ffc commit 28edfdc
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions Source/Client/Syncing/SyncSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ namespace Multiplayer.Client
{
public static class SyncSerialization
{
private static bool simplifiedSyncSimpleCheck = false;

public static void Init()
{
RwImplSerialization.Init();
Expand Down Expand Up @@ -53,24 +51,14 @@ public static bool CanHandle(SyncType syncType)
|| gtd == typeof(HashSet<>)
|| typeof(ITuple).IsAssignableFrom(gtd))
&& CanHandleGenericArgs(type);
if (type == typeof(ISyncSimple))
return true;
if (typeof(ISyncSimple).IsAssignableFrom(type))
{
// Prevent infinite recursive calls to CanHandle on ISyncSimple subtypes.
if (simplifiedSyncSimpleCheck)
return true;

try
{
simplifiedSyncSimpleCheck = true;
return ImplSerialization.syncSimples.
Where(t => type.IsAssignableFrom(t)).
SelectMany(AccessTools.GetDeclaredFields).
All(f => CanHandle(f.FieldType));
}
finally
{
simplifiedSyncSimpleCheck = false;
}
return ImplSerialization.syncSimples.
Where(t => type.IsAssignableFrom(t)).
SelectMany(AccessTools.GetDeclaredFields).
All(f => CanHandle(f.FieldType));
}
if (typeof(Def).IsAssignableFrom(type))
return true;
Expand Down

0 comments on commit 28edfdc

Please sign in to comment.