fix _patchedTypes having multiple of same type

This commit is contained in:
JohnCorby 2021-11-30 19:28:52 -08:00
parent 9571b27ae0
commit 459929e4df

View File

@ -84,10 +84,18 @@ namespace QSB.Patches
TypeToInstance = new Dictionary<QSBPatchTypes, Harmony> TypeToInstance = new Dictionary<QSBPatchTypes, Harmony>
{ {
{ QSBPatchTypes.OnClientConnect, new Harmony("QSB.Client") }, {
{ QSBPatchTypes.OnServerClientConnect, new Harmony("QSB.Server") }, QSBPatchTypes.OnClientConnect, new Harmony("QSB.Client")
{ QSBPatchTypes.OnNonServerClientConnect, new Harmony("QSB.NonServer") }, },
{ QSBPatchTypes.RespawnTime, new Harmony("QSB.Death") } {
QSBPatchTypes.OnServerClientConnect, new Harmony("QSB.Server")
},
{
QSBPatchTypes.OnNonServerClientConnect, new Harmony("QSB.NonServer")
},
{
QSBPatchTypes.RespawnTime, new Harmony("QSB.Death")
}
}; };
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success); DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
@ -109,13 +117,13 @@ namespace QSB.Patches
try try
{ {
patch.DoPatches(TypeToInstance[type]); patch.DoPatches(TypeToInstance[type]);
_patchedTypes.Add(type);
} }
catch (Exception ex) catch (Exception ex)
{ {
DebugLog.ToConsole($"Error while patching {patch.GetType().Name} :\r\n{ex}", MessageType.Error); DebugLog.ToConsole($"Error while patching {patch.GetType().Name} :\r\n{ex}", MessageType.Error);
} }
} }
_patchedTypes.Add(type);
} }
public static void DoUnpatchType(QSBPatchTypes type) public static void DoUnpatchType(QSBPatchTypes type)