Give queue verify fixes: drop interval migration, stricter gone rule, stackable guard
- R1: drop MigrateGiveQueueIntervalMs (it ran on every CopySettings). - R2: the accept line no longer shortens the two-tick rule for an unreadable item. - R3: a failed stack read on a stackable item (MaxStackSize > 1) sends nothing that tick (first in line again next tick); comment states what the code does. - R4: comment corrected (chat type 17 is Spellcasting); unclassified log skips types 1, 7, 17 and bracketed lines, cap raised to 10. - R6: a container that is neither the player nor the target and whose own container reads 0 is unreadable, not gone. - Tests for R2, R3, R6; migration test removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
620048211b
commit
da8e9a70e3
4 changed files with 103 additions and 27 deletions
|
|
@ -1946,7 +1946,7 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
dst.ShowTerrainPassability = tmp.ShowTerrainPassability;
|
||||
dst.NavLabelMode = NavLabelModes.Clamp(tmp.NavLabelMode);
|
||||
dst.NavGuideLine = tmp.NavGuideLine;
|
||||
dst.GiveQueueIntervalMs = LegacyUiSettings.MigrateGiveQueueIntervalMs(tmp.GiveQueueIntervalMs);
|
||||
dst.GiveQueueIntervalMs = tmp.GiveQueueIntervalMs;
|
||||
dst.T11ItemAugsOverride = tmp.T11ItemAugsOverride;
|
||||
dst.SpellCastIntervalMs = tmp.SpellCastIntervalMs;
|
||||
dst.StuckCastBreakMs = tmp.StuckCastBreakMs;
|
||||
|
|
|
|||
|
|
@ -398,9 +398,6 @@ public sealed class LegacyUiSettings
|
|||
public List<string> MonsterNameBlacklist { get; set; } = new();
|
||||
|
||||
public int GiveQueueIntervalMs = 0;
|
||||
/// <summary>A saved GiveQueueIntervalMs: the old default (150) becomes 0 (the interval is now only a
|
||||
/// minimum gap between sends; a round trip is longer than 150 ms anyway). Any other value is kept.</summary>
|
||||
public static int MigrateGiveQueueIntervalMs(int saved) => saved == 150 ? 0 : saved;
|
||||
|
||||
/// <summary>
|
||||
/// Item augmentation count used for T11 wield gates in loot rules ("T11: Can Wield").
|
||||
|
|
|
|||
|
|
@ -3469,10 +3469,10 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Speech, tells and emotes are other players' words, never the server's answer to a give. The engine
|
||||
/// reports the client's own chat type: another player's speech arrives as 17 (DecalBridge log lines
|
||||
/// "chat type=17 ... says, ..."), system notices as 0. Tells and emotes are not in any log, so the
|
||||
/// text shape backs the type up.
|
||||
/// Speech, tells and emotes are other players' words, never the server's answer to a give. The text
|
||||
/// shape is the real guard. Chat type 17 is the client's Spellcasting type (spell words, ours and
|
||||
/// other casters': "chat type=17 ... says, "Zojak Ves""), which is never an answer either, so it is
|
||||
/// skipped too; system notices such as "You give ..." arrive as 0.
|
||||
/// </summary>
|
||||
private static bool IsGiveChatSpeech(string text, int chatType)
|
||||
{
|
||||
|
|
@ -3499,7 +3499,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
var kind = ClassifyGiveChat(text);
|
||||
if (kind == GiveChat.None)
|
||||
{
|
||||
if (_giveUnclassified < 5)
|
||||
// Types 1 (RynthAi's own lines), 7 (magic) and 17 (spell words) are never worth a slot.
|
||||
if (_giveUnclassified < 10 && chatType != 1 && chatType != 7 && !text.StartsWith("[", StringComparison.Ordinal))
|
||||
{
|
||||
_giveUnclassified++;
|
||||
Host.Log($"[Give] unclassified chat: type={chatType} '{text}'");
|
||||
|
|
@ -3552,7 +3553,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
_giveRunItems = 0;
|
||||
_giveRunSkips.Clear();
|
||||
}
|
||||
SendGive(itemId, targetId, amount, 1, resent: false, now);
|
||||
if (!SendGive(itemId, targetId, amount, 1, resent: false, now))
|
||||
_giveRedo = (itemId, targetId, amount); // unreadable stack: first in line again next tick
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -3568,8 +3570,23 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
// the stack count reads -1 (never a clamped 1, which looked like a shrink of 99), and an
|
||||
// unreadable object (no cache entry, Container 0) must read the same on two ticks in a row.
|
||||
var wo = _objectCache?[unchecked((int)_giveInFlightId)];
|
||||
bool readable = wo != null && wo.Container != 0;
|
||||
bool carried = readable && InPlayerInventory(wo!.Container);
|
||||
// Where it is: in the pack (the player, or a pack the player carries), with the give target (gone),
|
||||
// or somewhere we cannot place. A container that is neither the player nor the target and whose own
|
||||
// container reads 0 is unreadable, not gone.
|
||||
int cont = wo?.Container ?? 0;
|
||||
bool readable = wo != null && cont != 0;
|
||||
bool carried = false;
|
||||
if (readable)
|
||||
{
|
||||
int playerInt = unchecked((int)_playerId);
|
||||
if (cont == playerInt) carried = true;
|
||||
else if (cont != unchecked((int)_giveInFlightTarget))
|
||||
{
|
||||
int outer = _objectCache?.GetContainerId(cont) ?? 0;
|
||||
if (outer == 0) readable = false;
|
||||
else carried = outer == playerInt;
|
||||
}
|
||||
}
|
||||
int stackNow = wo != null ? wo.Values(LongValueKey.StackCount, -1) : -1;
|
||||
bool gone;
|
||||
if (readable && !carried) { gone = true; _giveGoneStreak = 0; }
|
||||
|
|
@ -3577,7 +3594,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
else
|
||||
{
|
||||
_giveGoneStreak++;
|
||||
gone = _giveSawAcceptLine || _giveGoneStreak >= 2;
|
||||
gone = _giveGoneStreak >= 2;
|
||||
}
|
||||
if (gone)
|
||||
{
|
||||
|
|
@ -3643,7 +3660,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
{
|
||||
if (now < _giveBusyRetryAt) return false;
|
||||
_giveBusyRetryAt = 0;
|
||||
SendGive(_giveInFlightId, _giveInFlightTarget, _giveInFlightRemaining, _giveInFlightTries, resent: true, now);
|
||||
if (!SendGive(_giveInFlightId, _giveInFlightTarget, _giveInFlightRemaining, _giveInFlightTries, resent: true, now))
|
||||
_giveBusyRetryAt = now; // unreadable stack: try again next tick
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -3652,7 +3670,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
if (_giveInFlightTries < GiveMaxTries)
|
||||
{
|
||||
Host.Log($"[RynthAi] Give answer: no-answer {tag} after {sinceSend} ms; re-sending");
|
||||
SendGive(_giveInFlightId, _giveInFlightTarget, _giveInFlightRemaining, _giveInFlightTries + 1, resent: true, now);
|
||||
if (!SendGive(_giveInFlightId, _giveInFlightTarget, _giveInFlightRemaining, _giveInFlightTries + 1, resent: true, now))
|
||||
_giveBusyRetryAt = now; // unreadable stack: try again next tick
|
||||
return false;
|
||||
}
|
||||
Host.Log($"[RynthAi] Give answer: no-answer {tag} after {sinceSend} ms; giving up");
|
||||
|
|
@ -3681,12 +3700,16 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
}
|
||||
|
||||
/// <summary>Sends one give and records it as the in-flight one (amount = items still to hand over).</summary>
|
||||
private void SendGive(uint itemId, uint targetId, int amount, int tries, bool resent, long now)
|
||||
private bool SendGive(uint itemId, uint targetId, int amount, int tries, bool resent, long now)
|
||||
{
|
||||
WorldObject? wo = _objectCache?[unchecked((int)itemId)];
|
||||
// A failed or absent stack read is -1: record max(1, amount) as the stack, and send an explicit
|
||||
// amount when it is more than one (never the whole object on a failed read).
|
||||
int read = wo != null ? wo.Values(LongValueKey.StackCount, -1) : -1;
|
||||
// A failed read on a stackable item (MaxStackSize above 1) is no information: nothing is sent this
|
||||
// tick, and the caller tries again next tick (amount 1 would otherwise send the whole stack).
|
||||
if (read < 0 && wo != null && wo.Values(LongValueKey.MaxStackSize, -1) > 1) return false;
|
||||
// Here a negative read means a non-stackable or unknown item: record max(1, amount) as its stack.
|
||||
// An amount above 1 is sent as that explicit amount; an amount of 1 sends the whole object, which
|
||||
// for such an item is the one object.
|
||||
int whole = read >= 0 ? Math.Max(1, read) : Math.Max(1, amount);
|
||||
string name = wo?.Name ?? string.Empty;
|
||||
_giveInFlightId = itemId;
|
||||
|
|
@ -3704,6 +3727,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
if (!resent) { _giveBusyCount = 0; _giveBusySince = 0; _giveUnclassified = 0; }
|
||||
GiveItem(itemId, targetId, amount, read >= 0 ? whole : (amount > 1 ? amount + 1 : amount));
|
||||
Host.Log($"[RynthAi] Give send: 0x{itemId:X8} '{name}' stack={(read >= 0 ? whole.ToString() : "?")} amount={amount} try={tries}{(resent ? " (re-send)" : string.Empty)}");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void FinishGiveRun(long now)
|
||||
|
|
|
|||
|
|
@ -38,10 +38,12 @@ internal static class GiveTests
|
|||
r.Add("give: an unreadable stack count is no information, not a shrink", UnreadableStackIsNotAShrink);
|
||||
r.Add("give: an item unreadable for one tick is not gone; for two it is", OneTickUnreadableIsNotGone);
|
||||
r.Add("give: speech lines never answer a give; item not found with the stack unchanged is a skip", SpeechIgnoredAndNotFoundNeedsGone);
|
||||
r.Add("give: busy notice after 10 s, busy logging throttled, unclassified lines logged (max 5)", BusyNoticeAndLogThrottle);
|
||||
r.Add("give: busy notice after 10 s, busy logging throttled, unclassified lines logged (max 10)", BusyNoticeAndLogThrottle);
|
||||
r.Add("give: a counted give from one stack goes through the queue (NPC one per give, player split once)", CountedSingleStack);
|
||||
r.Add("give: cancel in the middle of a busy wait stops everything", CancelMidBusy);
|
||||
r.Add("give: a saved interval of 150 migrates to 0, other values stay", IntervalMigration); }
|
||||
r.Add("give: an accept line does not shorten the two-tick rule for an unreadable item", AcceptLineDoesNotAbandon);
|
||||
r.Add("give: a failed stack read on a stackable item sends nothing until it reads", FailedStackReadOnStackableWaits);
|
||||
r.Add("give: a container we cannot place is unreadable, not gone", UnplaceableContainerIsUnreadable); }
|
||||
|
||||
private sealed class World
|
||||
{
|
||||
|
|
@ -367,8 +369,9 @@ internal static class GiveTests
|
|||
FakeHost.GiveHandler = (_, _, _) => { };
|
||||
w.Call("EnqueueGive", Mote1, Npc, 1);
|
||||
w.Tick();
|
||||
for (int i = 0; i < 6; i++) w.Chat("Something odd " + i);
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[Give] unclassified chat:")), 5, "at most 5 unclassified lines logged per give");
|
||||
w.Chat("You cast Inner Calm on yourself", 7); // magic lines never take a slot
|
||||
for (int i = 0; i < 12; i++) w.Chat("Something odd " + i);
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[Give] unclassified chat:")), 10, "at most 10 unclassified lines logged per give");
|
||||
int busyCycles = 0;
|
||||
long start = w.Now;
|
||||
while (w.Now - start < 9000)
|
||||
|
|
@ -435,11 +438,63 @@ internal static class GiveTests
|
|||
Check.True(w.ChatHas("Give queue cancelled"), "cancel reported");
|
||||
}
|
||||
|
||||
private static void IntervalMigration()
|
||||
private static void AcceptLineDoesNotAbandon()
|
||||
{
|
||||
Check.Eq(LegacyUiSettings.MigrateGiveQueueIntervalMs(150), 0, "the old default becomes 0");
|
||||
Check.Eq(LegacyUiSettings.MigrateGiveQueueIntervalMs(400), 400, "a chosen value stays");
|
||||
Check.Eq(LegacyUiSettings.MigrateGiveQueueIntervalMs(0), 0, "0 stays");
|
||||
Check.Eq(new LegacyUiSettings().GiveQueueIntervalMs, 0, "the default is 0");
|
||||
var w = new World();
|
||||
FakeHost.GiveHandler = (_, _, _) => { };
|
||||
w.Call("EnqueueGive", Mote1, Npc, 1);
|
||||
w.Call("EnqueueGive", Mote2, Npc, 1);
|
||||
w.Tick();
|
||||
w.Chat("You give Town Crier Mana Mote.");
|
||||
FakeHost.Containers[Mote1] = 0; // one unreadable tick
|
||||
w.Tick();
|
||||
Check.Eq(FakeHost.Gives.Count, 1, "an accept line plus one unreadable tick does not abandon the stack");
|
||||
FakeHost.Containers[Mote1] = Player;
|
||||
w.Tick();
|
||||
Check.Eq(FakeHost.Gives.Count, 1, "read again, still carried");
|
||||
}
|
||||
|
||||
private static void FailedStackReadOnStackableWaits()
|
||||
{
|
||||
var w = new World();
|
||||
FakeHost.GiveHandler = (_, _, _) => { };
|
||||
w.AddStack(Carapace, "Olthoi Slayer Carapace", 5);
|
||||
FakeHost.Ints[(Carapace, (uint)(int)LongValueKey.MaxStackSize)] = 100;
|
||||
FakeHost.Ints.Remove((Carapace, 12)); // the stack read fails
|
||||
w.Call("EnqueueGive", Carapace, Npc, 1);
|
||||
w.Tick();
|
||||
w.Tick();
|
||||
Check.Eq(FakeHost.Gives.Count, 0, "a stackable item with an unreadable stack is not sent (amount 1 would hand over the whole stack)");
|
||||
FakeHost.Ints[(Carapace, 12)] = 5;
|
||||
w.Tick();
|
||||
Check.Eq(FakeHost.Gives.Count, 1, "sent on the first tick that reads it");
|
||||
Check.Eq(FakeHost.Gives[0].Amount, 1, "one item, not the whole object");
|
||||
}
|
||||
|
||||
private static void UnplaceableContainerIsUnreadable()
|
||||
{
|
||||
const uint Pack = 0x80281F01, Stranger = 0x80281F02;
|
||||
var w = new World();
|
||||
FakeHost.GiveHandler = (_, _, _) => { };
|
||||
w.Call("EnqueueGive", Mote1, Npc, 1);
|
||||
w.Call("EnqueueGive", Mote2, Npc, 1);
|
||||
w.Tick();
|
||||
// In a side pack that itself reads as inside the player's pack: carried.
|
||||
FakeHost.Containers[Pack] = Player;
|
||||
FakeHost.Containers[Mote1] = Pack;
|
||||
w.Tick(); w.Tick(); w.Tick();
|
||||
Check.Eq(FakeHost.Gives.Count, 1, "a pack the player carries: still carried");
|
||||
// In a container whose own container reads 0: unreadable, needs two ticks.
|
||||
FakeHost.Containers.Remove(Stranger);
|
||||
FakeHost.Containers[Mote1] = Stranger;
|
||||
w.Tick();
|
||||
Check.Eq(FakeHost.Gives.Count, 1, "one tick of an unplaceable container is not gone");
|
||||
FakeHost.Containers[Mote1] = Pack;
|
||||
w.Tick();
|
||||
FakeHost.Containers[Mote1] = Stranger;
|
||||
w.Tick();
|
||||
Check.Eq(FakeHost.Gives.Count, 1, "the streak restarts after a good read");
|
||||
w.Tick();
|
||||
Check.Eq(FakeHost.Gives.Count, 2, "two unreadable ticks in a row: gone");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue