minor bugfix and pad support

This commit is contained in:
Ferdinando 2026-09-12 10:42:01 +02:00
commit 6e87be3c77
21 changed files with 574 additions and 85 deletions

View file

@ -65,6 +65,11 @@ namespace RacesOfValheim
/// "RPC_" prefix in this build - "RPC_AddOre", not "AddOre". A wrong name here is a silent no-op,
/// which is exactly the class of bug that takes an evening to find, so the four names below were
/// read out of each Awake() rather than remembered.
///
/// A wrong ARGUMENT LIST is not silent: Valheim 1.0 added a trailing "bool cheated" to every
/// add-item RPC (and the Fermenter's now takes the prefab's stable hash, not its name), and the
/// old calls threw EndOfStreamException on the receiving end, every tick. The servant's goods
/// are real, so cheated is always false.
/// </summary>
public abstract class ButlerStation
{
@ -199,8 +204,9 @@ namespace RacesOfValheim
public static readonly MethodInfo CookFireLit = AccessTools.Method(typeof(CookingStation), "IsFireLit");
public static readonly MethodInfo FermenterStatus = AccessTools.Method(typeof(Fermenter), "GetStatus");
// 1.0 dropped the string overload: the Fermenter matches on GetStableHashCode of the name.
public static readonly MethodInfo FermenterAllowed =
AccessTools.Method(typeof(Fermenter), "IsItemAllowed", new[] { typeof(string) });
AccessTools.Method(typeof(Fermenter), "IsItemAllowed", new[] { typeof(int) });
// CookingStation.Status and Fermenter.Status are private nested enums: they cannot be named
// in source, so they travel as ints. Values read from the assembly, not assumed.
@ -270,7 +276,7 @@ namespace RacesOfValheim
public override void Add(string prefabName)
{
Claim();
Nview.InvokeRPC("RPC_AddOre", prefabName);
Nview.InvokeRPC("RPC_AddOre", prefabName, false);
}
public override bool HasWork { get { return Queued > 0; } }
@ -318,8 +324,9 @@ namespace RacesOfValheim
get { return m_cooking.m_slots != null ? m_cooking.m_slots.Length : 0; }
}
/// <summary>GetSlot hands back three values through out parameters, one of which is a
/// private enum. Through reflection that means an args array and an int.</summary>
/// <summary>GetSlot hands back four values through out parameters, one of which is a
/// private enum. Through reflection that means an args array and an int. The fourth, a
/// bool "cheated", arrived with 1.0; it is ignored, but the array must have room for it.</summary>
private bool ReadSlot(int index, out string name, out float cooked, out int status)
{
name = null;
@ -328,7 +335,7 @@ namespace RacesOfValheim
if (Vanilla.CookGetSlot == null) return false;
object[] args = new object[] { index, null, null, null };
object[] args = new object[] { index, null, null, null, null };
Vanilla.CookGetSlot.Invoke(m_cooking, args);
name = args[1] as string;
@ -367,7 +374,7 @@ namespace RacesOfValheim
public override void Add(string prefabName)
{
Claim();
Nview.InvokeRPC("RPC_AddItem", prefabName);
Nview.InvokeRPC("RPC_AddItem", prefabName, false);
}
public override bool HasWork { get { return !Vanilla.Call(Vanilla.CookEmpty, m_cooking, true); } }
@ -486,13 +493,14 @@ namespace RacesOfValheim
public override bool Accepts(string prefabName)
{
return Vanilla.Allowed(Vanilla.FermenterAllowed, m_fermenter, prefabName);
if (Vanilla.FermenterAllowed == null || string.IsNullOrEmpty(prefabName)) return false;
return (bool)Vanilla.FermenterAllowed.Invoke(m_fermenter, new object[] { prefabName.GetStableHashCode() });
}
public override void Add(string prefabName)
{
Claim();
Nview.InvokeRPC("RPC_AddItem", prefabName);
Nview.InvokeRPC("RPC_AddItem", prefabName.GetStableHashCode(), false);
}
public override bool HasWork { get { return Status != Vanilla.FermentEmpty; } }