ModernUO/Projects/UOContent.Tests/Tests
Kamron Batman 114dbba6e2
fix: a stop order silently cancelled a standing follow order (#2616)
## The bug

Pet is set to follow. It gets attacked and defends itself (the order flips to `Attack`), or the player tells it to `come`. The player then says `stop`. The pet quietly stops following and starts idle-wandering — the player has to re-issue the order to get it back.

`ResolveStop` clears `ControlTarget`, since the transient order that is ending owns it, and then resumes the standing order. Nothing restores a target, so the resumed `Follow` has none. `DoOrderFollow` checks for a target before anything else, finds none on the very next think, says "I have no one to follow" and cancels the order to `None`:

```
follow standing        order=Follow  target=set  persist=Follow  cur=0.2 => move=0.3
attacked (defends)     order=Attack  target=set  persist=Follow  cur=0.2 => move=0.3
stop issued            order=Follow  target=null persist=Follow  cur=0.2 => move=0.3
  next think           order=None    target=null persist=Follow  cur=0.4 => move=0.9
```

Two things go wrong at once:

- `PersistentOrder` still reads `Follow` while `ControlOrder` is `None`, so the pet never recovers on its own.
- The pace falls from the active clock to the passive one. A shard that tunes `SetMoveSpeed(active, passive)` sees a following pet drop from its active move speed to its passive one for no visible reason — which is how this surfaced.

Era-independent. Guard is unaffected: `DoOrderGuard` works off `ControlMaster`, not `ControlTarget`.

## The fix

A standing `Follow` does not always mean "follow the master" — a pet friend can point it elsewhere with `all follow me` / `*follow me` (0x163, 0x16C) or `*follow` plus a target pick. So `SetPersistentOrder` remembers the target the standing order was given, and `ResumePersistentOrder` restores it, falling back to the master only when that target is gone. The field is runtime-only, like `PersistentOrder` itself.

Doing this in `ResumePersistentOrder` rather than `ResolveStop` also covers the Friend/Unfriend/Transfer resumes, where `ControlTarget` points at a third party and the pet would otherwise have resumed its follow on *them*. It matches what `HandleInvalidControlTarget` already does before its own resume.

## Tests

`Stop_WhileAttacking_FallsBackToPersistentFollow` already existed and passed, because it asserted the resumed order without checking for a target or driving a think tick. Three tests added alongside it:

- `Stop_WhileAttacking_ResumedFollowTargetsTheMaster`
- `Stop_WhileAttacking_ResumedFollowKeepsAPetFriendAsItsTarget` — a friend's follow order is not hijacked back to the owner
- `Stop_WhileAttacking_ResumedFollowSurvivesTheNextThink` — the one that catches the cancellation

Each was confirmed to fail without the change (`Expected: Follow, Actual: None`; wrong target). Full suites green: 782 UOContent, 869 Server.
2026-09-07 08:51:10 -07:00
..
Accounting perf(login): run password hashing on a parked worker thread (#2566) 2026-08-09 00:13:34 -07:00
Engines fix: OPL revision hash collided on reordered and repeated properties (#2615) 2026-09-06 21:32:12 -07:00
Gumps fix: Warn when sending empty gumps (#2563) 2026-08-08 00:55:12 -07:00
Items fix: Stop treasure chest guardian spawn farming via stack splits (#2568) 2026-08-10 09:01:29 -07:00
Misc fix: Removes side effects from locked down items, decaying houses, bracelet of binding, and builds (#2608) 2026-09-06 09:39:00 -07:00
Mobiles fix: a stop order silently cancelled a standing follow order (#2616) 2026-09-07 08:51:10 -07:00
Multis fix: Removes side effects from locked down items, decaying houses, bracelet of binding, and builds (#2608) 2026-09-06 09:39:00 -07:00
Network feat: make the blocklist and manual allowlist opt-in; cut the ban subsystem's on-loop cost (#2577) 2026-08-13 23:22:35 -07:00
Skills feat: Implements passive Detect Hidden mechanics (#2342) 2026-02-28 11:24:49 -08:00
Spells refactor: Changes BaseCreature to the SerializationGenerator (delta save requirement) (#2611) 2026-09-06 14:11:51 -07:00
Utilities fix: Harden Advanced Search: crash-safety, autosave, correct results & worker fixes (#2543) 2026-07-21 07:51:06 -07:00
WorldSaves fix: Removes side effects from locked down items, decaying houses, bracelet of binding, and builds (#2608) 2026-09-06 09:39:00 -07:00