RynthAi: a relog ends "never reached your hand" weapon bans

A 'never reached your hand' ban is a guess from a missing answer, unlike the server's own 'skill too low' refusal. Track those bans separately and lift them when the character logs in (or relogs); 'skill too low' bans stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-11-07 09:05:08 -08:00
commit 3b439a66f1
2 changed files with 44 additions and 3 deletions

View file

@ -1336,6 +1336,15 @@ public partial class CombatManager : IDisposable
_inHandId = 0;
_inHandReadAt = DateTime.MinValue;
}
// A login or relog (the same character too): every "never reached your hand" ban ends. Those
// are guesses from a missing answer; the server's own "skill too low" bans stay.
if (_neverReachedBans.Count > 0)
{
foreach (int id in _neverReachedBans) _skillTooLowUntil.Remove(id);
_host.Log($"[EquipDiag] relog: {_neverReachedBans.Count} weapon(s) left out as 'never reached your hand' are back in the weapon choice");
_neverReachedBans.Clear();
_planCache = null;
}
_playerId = playerId;
_monsterMatchEval = new MonsterMatchEvaluator(_worldFilter, playerId);
}
@ -5834,6 +5843,10 @@ public partial class CombatManager : IDisposable
/// skill raise may let it in later).</summary>
internal const double SkillTooLowSkipMin = 30;
private readonly Dictionary<int, DateTime> _skillTooLowUntil = new();
// The entries of _skillTooLowUntil put there because a wield "never reached your hand" (no
// server answer). A relog clears these; a real "skill too low" from the server stays.
private readonly HashSet<int> _neverReachedBans = new();
internal const string NeverReachedWhy = "it never reached your hand (the client refused the wield)";
/// <summary>
/// True while <paramref name="id"/> sits out a SkillTooLow refusal. Drakkon (2026-10-16) was
@ -5845,14 +5858,18 @@ public partial class CombatManager : IDisposable
if (!_skillTooLowUntil.TryGetValue(id, out DateTime until)) return false;
if (RynthClock.Now < until) return true;
_skillTooLowUntil.Remove(id);
_neverReachedBans.Remove(id);
return false;
}
private void NoteSkillTooLow(int id, string? why = null)
private void NoteSkillTooLow(int id, string? why = null, bool neverReached = false)
{
if (id == 0) return;
bool first = !_skillTooLowUntil.ContainsKey(id);
_skillTooLowUntil[id] = RynthClock.Now.AddMinutes(SkillTooLowSkipMin);
// The server's own "skill too low" outranks a "never reached your hand" on the same weapon.
if (!neverReached) _neverReachedBans.Remove(id);
else if (first) _neverReachedBans.Add(id);
_planCache = null;
if (first)
{
@ -5879,7 +5896,7 @@ public partial class CombatManager : IDisposable
// (the client refused it unasked). Out of the choice like a "skill too low" answer,
// not retried every 2 minutes with the off hand taken off each time (the Tetsubo, 2026-10-18).
if (SwapTracker.GaveUpId is int gaveUp && NeverReachedHand(gaveUp))
NoteSkillTooLow(gaveUp, "it never reached your hand (the client refused the wield)");
NoteSkillTooLow(gaveUp, NeverReachedWhy, neverReached: true);
}
SwapTracker.GaveUpId = null;
if (step == WeaponSwapTracker.Step.Hold && (RynthClock.Now - _lastSwapHoldLogAt).TotalSeconds > 10)

View file

@ -25,6 +25,7 @@ internal static class WieldBanTests
{
r.Add("wield ban: a weapon seen wielded between combat's looks is not banned, its tries start over", SeenWieldedNotBanned);
r.Add("wield ban: no ban while the equipment list shows the weapon at the give-up", ListShowsItAtGiveUp);
r.Add("wield ban: a relog ends 'never reached your hand' bans, not 'skill too low' ones", RelogClearsNeverReached);
r.Add("wield ban: a wield that never shows in the list is still banned", NeverShownStillBanned);
r.Add("wield ban: one sighting, then three wields never seen: banned (a new run forgets the sighting)", SeenOnceThenNeverBanned);
r.Add("wield ban: a weapon in the shield slot is not a main-hand sighting, it still rests", ShieldSlotNotASighting);
@ -39,10 +40,11 @@ internal static class WieldBanTests
private readonly MethodInfo _send = typeof(CombatManager).GetMethod("MarkWieldSent", F)!;
private readonly MethodInfo _step = typeof(CombatManager).GetMethod("SwapStep", F)!;
public Rig(bool equipped = true)
public Rig(bool equipped = true, bool weenieErrors = false)
{
FakeHost.Reset();
FakeHost.EquippedCalls = equipped;
FakeHost.WeenieErrorCalls = weenieErrors;
FakeHost.Names[Blade] = "Test Blade";
FakeHost.Names[Wand] = "Fire Wand";
FakeHost.Names[Nodachi] = "Nodachi";
@ -117,6 +119,28 @@ internal static class WieldBanTests
finally { EquippedState.Invalidate(); }
}
/// <summary>SetPlayerId (a login or relog) ends 'never reached' bans only.</summary>
private static void RelogClearsNeverReached()
{
var rig = new Rig(weenieErrors: true);
try
{
// The blade: three wields that never show in the list -> 'never reached your hand'.
for (int i = 1; i <= 3; i++) { rig.Send(Blade, Wand); rig.C.OnHeartbeat(); rig.Step(Blade, Wand); }
Check.True(rig.Banned(Blade), "setup: the blade left out as 'never reached your hand'");
// Nodachi: the server answers 'skill too low'.
rig.Send(Nodachi, Wand);
FakeHost.WeenieError(CombatManager.SkillTooLowErr, 0x00A0, Nodachi);
rig.Step(Nodachi, Wand);
Check.True(rig.Banned(Nodachi), "setup: Nodachi left out as 'skill too low'");
rig.C.SetPlayerId(Player); // the same character logs in again
Check.False(rig.Banned(Blade), "relog: the 'never reached your hand' ban is over");
Check.True(rig.Banned(Nodachi), "relog: the server's 'skill too low' ban stays");
}
finally { EquippedState.Invalidate(); }
}
/// <summary>A wield the client or server truly refuses (never in the list) still bans.</summary>
private static void NeverShownStillBanned()
{