bugfix 25/09/26
This commit is contained in:
parent
9bebcf340b
commit
f64fe83d9d
6 changed files with 111 additions and 8 deletions
96
JotunnModStub/ConfigSync.cs
Normal file
96
JotunnModStub/ConfigSync.cs
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using BepInEx.Configuration;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// Marks every gameplay config entry as admin-only so Jotunn syncs it from the server to the
|
||||
/// clients (and locks it for non-admins in Configuration Manager).
|
||||
///
|
||||
/// Jotunn only recognises ITS OWN ConfigurationManagerAttributes (global namespace, in
|
||||
/// Jotunn.dll) as a tag - it does an `is` check, not the field-name duck typing Configuration
|
||||
/// Manager does - so our internal look-alike tag is not enough. This runs once after every
|
||||
/// Bind() and adds Jotunn's tag beside whatever tags the entry already has, rather than
|
||||
/// touching each of the ~350 Bind() calls.
|
||||
///
|
||||
/// Left local, because they are per-player preferences and syncing them would only take the
|
||||
/// choice away from the player: keybinds, and the purely cosmetic entries (eye/claw colours,
|
||||
/// glow, tint, rotation and offset of models, the VFX toggle, the stamina-bar toggle, debug
|
||||
/// logging). Anything that changes a number the game computes with stays synced.
|
||||
/// </summary>
|
||||
internal static class ConfigSync
|
||||
{
|
||||
// Whole sections that are cosmetic or per-player.
|
||||
private static readonly string[] LocalSections =
|
||||
{
|
||||
"Aswid - Claws",
|
||||
"Aswid - Eyes",
|
||||
"Skeleton - Visuals",
|
||||
"Sverm - Dorsal Spines",
|
||||
"Sverm - Emberform",
|
||||
"War Vulture - Model",
|
||||
"War Vulture - Interface",
|
||||
};
|
||||
|
||||
// Cosmetic entries scattered through otherwise gameplay sections.
|
||||
private static readonly string[] LocalKeyParts =
|
||||
{
|
||||
"marker light", "tint", "colour", "color", "glow", "swarm scale", "log rounds", "debug",
|
||||
};
|
||||
|
||||
public static void Apply(ConfigFile config)
|
||||
{
|
||||
FieldInfo descField = typeof(ConfigEntryBase)
|
||||
.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
|
||||
.FirstOrDefault(f => f.FieldType == typeof(ConfigDescription));
|
||||
if (descField == null)
|
||||
{
|
||||
Debug.LogWarning("[RacesOfValheim] Config sync skipped: ConfigEntryBase has no ConfigDescription field.");
|
||||
return;
|
||||
}
|
||||
|
||||
int synced = 0, local = 0;
|
||||
foreach (ConfigDefinition def in config.Keys.ToList())
|
||||
{
|
||||
ConfigEntryBase entry = config[def];
|
||||
if (!ShouldSync(entry)) { local++; continue; }
|
||||
|
||||
ConfigDescription old = entry.Description;
|
||||
object[] tags = (old.Tags ?? new object[0]).Concat(new object[]
|
||||
{
|
||||
new global::ConfigurationManagerAttributes { IsAdminOnly = true }
|
||||
}).ToArray();
|
||||
descField.SetValue(entry, new ConfigDescription(old.Description, old.AcceptableValues, tags));
|
||||
synced++;
|
||||
}
|
||||
Debug.Log($"[RacesOfValheim] Config sync: {synced} entries admin-synced, {local} left local.");
|
||||
}
|
||||
|
||||
private static bool ShouldSync(ConfigEntryBase entry)
|
||||
{
|
||||
Type type = entry.SettingType;
|
||||
if (type == typeof(KeyboardShortcut) || type == typeof(KeyCode)) return false;
|
||||
|
||||
string section = entry.Definition.Section ?? "";
|
||||
string key = (entry.Definition.Key ?? "").ToLowerInvariant();
|
||||
|
||||
if (section.EndsWith("Keybinds", StringComparison.OrdinalIgnoreCase)) return false;
|
||||
if (LocalSections.Contains(section, StringComparer.OrdinalIgnoreCase)) return false;
|
||||
if (LocalKeyParts.Any(key.Contains)) return false;
|
||||
|
||||
// Model pose nudges (rotation/offset/yaw) are cosmetic, but "Attack Reach Offset" is a
|
||||
// real hit-detection distance and must stay in step with the server.
|
||||
if ((key.Contains("rotation") || key.Contains("offset") || key.Contains("yaw"))
|
||||
&& !key.Contains("reach")) return false;
|
||||
|
||||
// Decorative note lines (CustomDrawer/ReadOnly) carry no value worth sending.
|
||||
ConfigurationManagerAttributes ours = (entry.Description?.Tags ?? new object[0]).OfType<ConfigurationManagerAttributes>().FirstOrDefault();
|
||||
if (ours != null && (ours.CustomDrawer != null || ours.ReadOnly == true)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "RacesOfValheim",
|
||||
"description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
|
||||
"version_number": "1.4.22",
|
||||
"version_number": "1.4.23",
|
||||
"website_url": "",
|
||||
"dependencies": [
|
||||
"denikson-BepInExPack_Valheim-5.4.2333",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
public const string PluginGUID = "com.nandor.racesofvalheim";
|
||||
public const string PluginName = "Races Of Valheim";
|
||||
public const string PluginVersion = "1.4.22";
|
||||
public const string PluginVersion = "1.4.23";
|
||||
|
||||
private readonly Harmony harmony = new Harmony(PluginGUID);
|
||||
|
||||
|
|
@ -52,6 +52,8 @@ namespace RacesOfValheim
|
|||
// Not a race either: the faction truce and the faction merchants, which cut across
|
||||
// every race at once, so they bind last rather than inside the alphabetical run above.
|
||||
FactionsConfig.Bind(Config);
|
||||
// After every Bind above: tags the gameplay entries for Jotunn's server-to-client sync.
|
||||
ConfigSync.Apply(Config);
|
||||
harmony.PatchAll();
|
||||
gameObject.AddComponent<FenrirRace>();
|
||||
gameObject.AddComponent<SkadiRace>();
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(TreeBase), "RPC_Damage")]
|
||||
// Patched on Damage (attacker side), not RPC_Damage: the RPC runs on the object owner (host), where the attacker is not the local player.
|
||||
[HarmonyPatch(typeof(TreeBase), "Damage")]
|
||||
public static class Trol_TreeBase_RPC_Damage_Patch
|
||||
{
|
||||
public static void Prefix(HitData hit)
|
||||
|
|
@ -60,7 +61,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(TreeLog), "RPC_Damage")]
|
||||
[HarmonyPatch(typeof(TreeLog), "Damage")]
|
||||
public static class Trol_TreeLog_RPC_Damage_Patch
|
||||
{
|
||||
public static void Prefix(HitData hit)
|
||||
|
|
@ -69,7 +70,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Destructible), "RPC_Damage")]
|
||||
[HarmonyPatch(typeof(Destructible), "Damage")]
|
||||
public static class Trol_Destructible_RPC_Damage_Patch
|
||||
{
|
||||
public static void Prefix(HitData hit, Destructible __instance)
|
||||
|
|
@ -81,7 +82,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MineRock), "RPC_Hit")]
|
||||
[HarmonyPatch(typeof(MineRock), "Damage")]
|
||||
public static class Trol_MineRock_RPC_Hit_Patch
|
||||
{
|
||||
public static void Prefix(HitData hit)
|
||||
|
|
@ -90,7 +91,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MineRock5), "DamageArea")]
|
||||
[HarmonyPatch(typeof(MineRock5), "Damage")]
|
||||
public static class Trol_MineRock5_DamageArea_Patch
|
||||
{
|
||||
public static void Prefix(HitData hit)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue