update mirror weaver

This commit is contained in:
JohnCorby 2023-06-09 19:03:55 -07:00
parent 3b493361fb
commit f1cf09c85a
5 changed files with 20 additions and 8 deletions

View File

@ -18,7 +18,6 @@ namespace Mirror.FizzySteam
DISCONNECT
}
// CHANGED
private Steamworks.Callback<P2PSessionRequest_t> callback_OnNewConnection = null;
private Steamworks.Callback<P2PSessionConnectFail_t> callback_OnConnectFail = null;
@ -28,7 +27,6 @@ namespace Mirror.FizzySteam
{
channels = transport.Channels;
// CHANGED
callback_OnNewConnection = Steamworks.Callback<P2PSessionRequest_t>.Create(OnNewConnection);
callback_OnConnectFail = Steamworks.Callback<P2PSessionConnectFail_t>.Create(OnConnectFail);

View File

@ -18,7 +18,6 @@ namespace Mirror.FizzySteam
private event Action<byte[], int> OnReceivedData;
private event Action OnConnected;
private event Action OnDisconnected;
// CHANGED
private Steamworks.Callback<SteamNetConnectionStatusChangedCallback_t> c_onConnectionChange = null;
private CancellationTokenSource cancelToken;
@ -62,7 +61,6 @@ namespace Mirror.FizzySteam
private async void Connect(string host)
{
cancelToken = new CancellationTokenSource();
// CHANGED
c_onConnectionChange = Steamworks.Callback<SteamNetConnectionStatusChangedCallback_t>.Create(OnConnectionStatusChanged);
try

View File

@ -20,7 +20,6 @@ namespace Mirror.FizzySteam
private HSteamListenSocket listenSocket;
// CHANGED
private Steamworks.Callback<SteamNetConnectionStatusChangedCallback_t> c_onConnectionChange = null;
private NextServer(int maxConnections)
@ -29,7 +28,6 @@ namespace Mirror.FizzySteam
connToMirrorID = new BidirectionalDictionary<HSteamNetConnection, int>();
steamIDToMirrorID = new BidirectionalDictionary<CSteamID, int>();
nextConnectionID = 1;
// CHANGED
c_onConnectionChange = Steamworks.Callback<SteamNetConnectionStatusChangedCallback_t>.Create(OnConnectionStatusChanged);
}

View File

@ -242,7 +242,16 @@ namespace Mirror.Weaver
{
foreach (FieldDefinition field in typeDefinition.Fields)
{
if (field.IsStatic || field.IsPrivate)
// ignore static, private, protected fields
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3485
// credit: James Frowen
if (field.IsStatic || field.IsPrivate || field.IsFamily)
continue;
// also ignore internal fields
// we dont want to create different writers for this type if they are in current dll or another dll
// so we have to ignore internal in all cases
if (field.IsAssembly)
continue;
if (field.IsNotSerialized)

View File

@ -123,7 +123,16 @@ namespace Mirror.Weaver
ParameterDefinition param = md.Parameters[index];
if (param.IsOut)
{
TypeReference elementType = param.ParameterType.GetElementType();
// this causes IL2CPP build issues with generic out parameters:
// https://github.com/MirrorNetworking/Mirror/issues/3482
// TypeReference elementType = param.ParameterType.GetElementType();
//
// instead we need to use ElementType not GetElementType()
// GetElementType() will get the element type of the inner elementType
// which will return wrong type for arrays and generic
// credit: JamesFrowen
ByReferenceType byRefType = (ByReferenceType)param.ParameterType;
TypeReference elementType = byRefType.ElementType;
md.Body.Variables.Add(new VariableDefinition(elementType));
md.Body.InitLocals = true;