ModernUO/Projects/UOContent
Kamron Batman 1e4cdc4ab6
fix: Fixes criminals having guards called on them (#2348)
## Summary

Fixes three bugs in `GuardedRegion.CallGuards`:

- **Operator precedence bug**: The condition `!m.Region.IsPartOf(this) && !m_GuardCandidates.ContainsKey(m)`
  was inverted from intent. Replaced with explicit split: dictionary members are targeted regardless of
  region; permanent candidates (reds/AlwaysMurderer) must be inside the region.
- **Premature `break`**: Only the first guard candidate was ever processed per "guards" call.
  Removed the `break` so all valid candidates in range get a guard spawned.
- **Misleading message for permanent reds**: "Guards can no longer be called on you." (502276)
  was sent to permanent reds, but guards can *always* be called on them. Now only sent to
  temporary criminals whose guard window is actually consumed.

Also extracts `IsAlwaysGuardCandidate()` helper and simplifies `IsGuardCandidate()`.

## Edge cases verified (by analysis)

- **Multiple players call guards on same red**: `BaseGuard.Spawn` dedup (scans 15 tiles for
  existing guard with same `Focus`) prevents duplicate guards. Message suppression eliminates spam.
- **Red fights spawned guard → criminal → guards called again**: Same dedup prevents infinite
  guard spawns. Existing guard already has `Focus == red`.

## Test plan

- [ ] Temporary criminal in guarded region → guard spawns, receives "Guards can no longer be called on you."
- [ ] Permanent red (5+ kills) in guarded region → guard spawns, does NOT receive the message
- [ ] Multiple players call "guards" on same red → only 1 guard spawns
- [ ] Criminal outside region but in dictionary → still targeted by guards call from inside region
- [ ] Red outside guarded region → NOT targeted by guards call (must be inside region)
2026-03-13 17:35:47 -07:00
..
Accounting fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Assistants chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Commands feat: Adds robust speed hack detection and movement throttling (#2266) 2026-03-07 11:44:37 -08:00
Compression chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Configuration fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Console feat: Adds console commands (#1714) 2024-03-30 09:40:43 -07:00
Context Menus fix: Moves ContextMenu out of core, streamlines code, fixes bugs (#1873) 2024-07-20 21:33:23 -07:00
Engines fix: Fixes bug with non blessed starter spellbooks (#2368) 2026-03-13 00:20:23 -07:00
Gumps feat: Adds Mobile.Murderer virtual property, consolidates kill-threshold checks (#2355) 2026-03-06 08:36:41 -08:00
Holiday Stuff fix: Fixes container enumeration not recycling pooled arrays (#2341) 2026-02-17 09:54:32 -08:00
Items feat: T2A ping-pong mechanic and consider sins behaviour (#2356) 2026-03-10 23:10:27 -07:00
Migrations feat: T2A ping-pong mechanic and consider sins behaviour (#2356) 2026-03-10 23:10:27 -07:00
Misc feat: T2A ping-pong mechanic and consider sins behaviour (#2356) 2026-03-10 23:10:27 -07:00
Mobiles fix: Adds guard for monster ability recursion (#2363) 2026-03-12 19:26:49 -07:00
Multis fix: Makes courtyard/2nd floor doors locked. (#2364) 2026-03-12 20:07:41 -07:00
Network feat: Adds robust speed hack detection and movement throttling (#2266) 2026-03-07 11:44:37 -08:00
Regions fix: Fixes criminals having guards called on them (#2348) 2026-03-13 17:35:47 -07:00
Skills fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Special Systems feat: Upgrades networking to use io_uring. (#2315) 2026-02-01 16:02:32 -08:00
Spells feat: Adds Mobile.Murderer virtual property, consolidates kill-threshold checks (#2355) 2026-03-06 08:36:41 -08:00
Systems/JailSystem fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Targets chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Text fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Utilities chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
World Saves fix: Fixes adding items with ambiguous type lookup (#2307) 2026-01-06 21:21:29 -08:00
Module.cs fix: Fixes sending packets and sidesteps a major issue with stackalloc and PGO in .NET 8 (#1607) 2023-11-21 12:18:20 -08:00
UOContent.csproj fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00