mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-04 02:47:22 +00:00
incompatible mods stuff
This commit is contained in:
parent
c2703f3014
commit
9b0791bc4a
@ -13,6 +13,8 @@ public class PlayerJoinMessage : QSBMessage
|
|||||||
private string QSBVersion;
|
private string QSBVersion;
|
||||||
private string GameVersion;
|
private string GameVersion;
|
||||||
private bool DlcInstalled;
|
private bool DlcInstalled;
|
||||||
|
// empty if no incompatible mods
|
||||||
|
private string FirstIncompatibleMod;
|
||||||
|
|
||||||
private int[] AddonHashes;
|
private int[] AddonHashes;
|
||||||
|
|
||||||
@ -23,6 +25,17 @@ public class PlayerJoinMessage : QSBMessage
|
|||||||
GameVersion = QSBCore.GameVersion;
|
GameVersion = QSBCore.GameVersion;
|
||||||
DlcInstalled = QSBCore.DLCInstalled;
|
DlcInstalled = QSBCore.DLCInstalled;
|
||||||
|
|
||||||
|
var allEnabledMods = QSBCore.Helper.Interaction.GetMods();
|
||||||
|
|
||||||
|
FirstIncompatibleMod = "";
|
||||||
|
foreach (var mod in allEnabledMods)
|
||||||
|
{
|
||||||
|
if (QSBCore.IncompatibleMods.Contains(mod.ModHelper.Manifest.UniqueName))
|
||||||
|
{
|
||||||
|
FirstIncompatibleMod = mod.ModHelper.Manifest.UniqueName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AddonHashes = QSBCore.Addons.Keys
|
AddonHashes = QSBCore.Addons.Keys
|
||||||
.Select(x => x.GetStableHashCode())
|
.Select(x => x.GetStableHashCode())
|
||||||
.ToArray();
|
.ToArray();
|
||||||
@ -35,6 +48,7 @@ public class PlayerJoinMessage : QSBMessage
|
|||||||
writer.Write(QSBVersion);
|
writer.Write(QSBVersion);
|
||||||
writer.Write(GameVersion);
|
writer.Write(GameVersion);
|
||||||
writer.Write(DlcInstalled);
|
writer.Write(DlcInstalled);
|
||||||
|
writer.Write(FirstIncompatibleMod);
|
||||||
|
|
||||||
writer.Write(AddonHashes);
|
writer.Write(AddonHashes);
|
||||||
}
|
}
|
||||||
@ -46,6 +60,7 @@ public class PlayerJoinMessage : QSBMessage
|
|||||||
QSBVersion = reader.ReadString();
|
QSBVersion = reader.ReadString();
|
||||||
GameVersion = reader.ReadString();
|
GameVersion = reader.ReadString();
|
||||||
DlcInstalled = reader.Read<bool>();
|
DlcInstalled = reader.Read<bool>();
|
||||||
|
FirstIncompatibleMod = reader.ReadString();
|
||||||
|
|
||||||
AddonHashes = reader.Read<int[]>();
|
AddonHashes = reader.Read<int[]>();
|
||||||
}
|
}
|
||||||
@ -91,6 +106,12 @@ public class PlayerJoinMessage : QSBMessage
|
|||||||
new PlayerKickMessage(From, $"Addon mismatch. (Client:{AddonHashes.Length} addons, Server:{addonHashes.Length} addons)").Send();
|
new PlayerKickMessage(From, $"Addon mismatch. (Client:{AddonHashes.Length} addons, Server:{addonHashes.Length} addons)").Send();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FirstIncompatibleMod != "" && !QSBCore.IncompatibleModsAllowed)
|
||||||
|
{
|
||||||
|
DebugLog.ToConsole($"Error - Client {PlayerName} connecting with incompatible mod. (First mod found was {FirstIncompatibleMod})");
|
||||||
|
new PlayerKickMessage(From, $"Using an incompatible/disallowed mod. First mod found was {FirstIncompatibleMod}").Send();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var player = QSBPlayerManager.GetPlayer(From);
|
var player = QSBPlayerManager.GetPlayer(From);
|
||||||
|
@ -51,10 +51,22 @@ public class QSBCore : ModBehaviour
|
|||||||
// ignore the last patch numbers like the title screen does
|
// ignore the last patch numbers like the title screen does
|
||||||
Application.version.Split('.').Take(3).Join(delimiter: ".");
|
Application.version.Split('.').Take(3).Join(delimiter: ".");
|
||||||
public static bool DLCInstalled => EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned;
|
public static bool DLCInstalled => EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned;
|
||||||
|
public static bool IncompatibleModsAllowed { get; private set; }
|
||||||
public static IMenuAPI MenuApi { get; private set; }
|
public static IMenuAPI MenuApi { get; private set; }
|
||||||
public static DebugSettings DebugSettings { get; private set; } = new();
|
public static DebugSettings DebugSettings { get; private set; } = new();
|
||||||
public static Storage Storage { get; private set; } = new();
|
public static Storage Storage { get; private set; } = new();
|
||||||
|
|
||||||
|
public static readonly string[] IncompatibleMods = new[]
|
||||||
|
{
|
||||||
|
// cheats mods
|
||||||
|
"Glitch.AltDebugMenu",
|
||||||
|
"PacificEngine.CheatsMod",
|
||||||
|
// incompatible mods
|
||||||
|
"Raicuparta.NomaiVR",
|
||||||
|
"xen.NewHorizons",
|
||||||
|
"Vesper.AutoResume"
|
||||||
|
};
|
||||||
|
|
||||||
public void Awake()
|
public void Awake()
|
||||||
{
|
{
|
||||||
EpicRerouter.ModSide.Interop.Go();
|
EpicRerouter.ModSide.Interop.Go();
|
||||||
@ -174,7 +186,11 @@ public class QSBCore : ModBehaviour
|
|||||||
DebugLog.DebugWrite("Assemblies initialized", MessageType.Success);
|
DebugLog.DebugWrite("Assemblies initialized", MessageType.Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Configure(IModConfig config) => DefaultServerIP = config.GetSettingsValue<string>("defaultServerIP");
|
public override void Configure(IModConfig config)
|
||||||
|
{
|
||||||
|
DefaultServerIP = config.GetSettingsValue<string>("defaultServerIP");
|
||||||
|
IncompatibleModsAllowed = config.GetSettingsValue<bool>("incompatibleModsAllowed");
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
private void Update()
|
private void Update()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"settings": {
|
"settings": {
|
||||||
"defaultServerIP": "localhost"
|
"defaultServerIP": "localhost",
|
||||||
|
"incompatibleModsAllowed": false
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user