ModernUO/Projects/Server
Kamron Batman f4a87a8629
fix: Fixes adding items with ambiguous type lookup (#2307)
Fix [add command failing with ambiguous type names + refactor for performance

### Problem

[add blight would fail with "No type with that name was found" because multiple types contain "blight" (e.g., Server.Items.Blight, Server.Ethics.Evil.Blight, Server.Items.BlightGrippedLongbow, Server.Items.QuiverOfBlight). The old code only succeeded when exactly one type matched the search regardless of constructability and inheriting Mobi les/Items.

### Solution

Exact match takes priority: If a type's name exactly equals the search string (case-insensitive), use it directly. Otherwise, show the AddGump with all partial matches.

- [add blight → Creates Blight (exact name match)
- [add bligh → Shows gump with Blight, BlightGrippedLongbow, etc.

### Refactoring

- CommandEventArgs context: Added GetContext<T>/SetContext<T> to pass resolved type through the command chain without method signature changes
- Removed TrySetupTarget duplication: Validation now happens only in ValidateArgs, eliminating redundant code paths
- Split type matching:
  - ExactMatch(string) → Returns Type for exact name match (used by [add)
  - MatchEmptyCtor(string) → Returns ConstructorInfo[] for gump display (empty-callable constructors only)

### Memory & Performance Improvements

| Optimization                  | Benefit                                                                                      |
|-------------------------------|----------------------------------------------------------------------------------------------|
| _mobileItemTypes cache        | Filters Mobile/Item types once per assembly, reused on all subsequent searches               |
| ReadOnlySpan<string> for args | Avoids string[] heap allocations when slicing arguments                                      |
| ValueStringBuilder            | Stack-allocated string building, avoids StringBuilder heap allocation                        |
| Single type resolution        | Type resolved once in ValidateArgs, passed via context to Execute (was resolved 2-3x before) |
2026-01-06 21:21:29 -08:00
..
Buffers chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Client chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Collections chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Comparers chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Compression fix: Fixes libdeflate threading issue (#1813) 2024-06-02 15:02:47 -07:00
Configuration fix: Fixes idleCPU override (#2308) 2026-01-04 17:21:08 -08:00
Console fix: Console Input is disabled on Linux when no standard input is attached. (#1809) 2024-06-06 21:20:22 -07:00
ContextMenus fix: Moves ContextMenu out of core, streamlines code, fixes bugs (#1873) 2024-07-20 21:33:23 -07:00
Events fix: Fixes networking issues (#1958) 2024-09-19 16:54:49 -07:00
Exceptions chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
GarbageCollection chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Geometry fix: Fixes zero height spawners and normalizes spawn bounds before use. (#2301) 2025-12-31 10:25:42 -08:00
Items chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Json feat: Add spawn position caching and spiral scan optimization (#2295) 2025-12-28 02:40:21 -08:00
Localization chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Maps refactor: Add BitMask256 utility for 256-bit bitmask operations (#2300) 2025-12-29 12:54:49 -08:00
Menus fix: Cleans up core code (#1187) 2022-10-10 21:47:08 -07:00
Migrations fix: Hair and facial hair "teleporting" when mobile dies several times (#1901) 2024-08-07 20:10:23 -07:00
Mobiles chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Network feat: Adds Network Packet Documentation (#2302) 2026-01-01 17:52:56 -08:00
PropertyList chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Random chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Regions fix: Eliminates List allocations in various places. (#2158) 2025-11-16 18:33:53 -08:00
Serialization fix: Prevent cascading deletes during world deserialization (#2298) 2025-12-28 17:54:53 -08:00
Targeting chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Text chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
TileMatrix feat: Updates to .NET 9 (#1984) 2024-12-08 10:16:34 -08:00
Timer chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
TimeZones fix: Fixes order of execution with AutoSave and TZ (#1665) 2024-01-24 17:17:45 -08:00
Utilities feat: Adds grid support for the DynamicGump system (#2306) 2026-01-03 10:12:22 -08:00
World chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
AssemblyHandler.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Attributes.cs fix: Fixes props for interfaces and adds account manipulation (#2179) 2025-05-09 15:39:47 -07:00
CityInfo.cs chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Commands.cs fix: Fixes adding items with ambiguous type lookup (#2307) 2026-01-06 21:21:29 -08:00
Effects.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
EntityFinalizationTracker.cs feat: Adds an Item/Mobile memory leak detector. Fixes minor leak in doors. (#2159) 2025-04-15 19:14:45 -07:00
EventLoopTasks.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
ExpansionInfo.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Guild.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
HuePicker.cs fix: Cleans up core code (#1187) 2022-10-10 21:47:08 -07:00
IAccount.cs fix: Fixes looking up accounts that were renamed. (#2078) 2025-01-18 17:11:43 -08:00
IEntity.cs feat: Upgrades serialization v4 (Threaded Heap Serialization) (#1947) 2024-09-14 09:57:43 -07:00
Interfaces.cs feat: Add CanSpawnMobile overload with props Z-range support. (#2293) 2025-12-27 17:01:15 -08:00
IVirtualCheckGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
KeywordList.cs fix: Cleans up core code (#1187) 2022-10-10 21:47:08 -07:00
Main.cs fix: Fixes idleCPU override (#2308) 2026-01-04 17:21:08 -08:00
MessageType.cs fix: Moves the rest of the Incoming packets (#1338) 2023-02-10 22:59:36 -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
MultiData.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Party.cs fix: Cleans up core code (#1187) 2022-10-10 21:47:08 -07:00
Poison.cs fix: Adds ISpanParsable and fixes command conditionals (#1241) 2022-11-12 00:26:02 -08:00
Prompt.cs fix: Cleans up core code (#1187) 2022-10-10 21:47:08 -07:00
Race.cs fix: Fixes TryParse for Race (#1244) 2022-11-12 00:31:25 -08:00
SecureTrade.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
Serial.cs feat: Updates to .NET 9 (#1984) 2024-12-08 10:16:34 -08:00
Server.csproj feat: Bumps Serialization Generator for better support (#2292) 2025-12-26 14:27:24 -08:00
Skills.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
TileData.cs feat: Add CanSpawnMobile overload with props Z-range support. (#2293) 2025-12-27 17:01:15 -08:00
TileList.cs fix: Refactors getting static tiles to use enumerators (#1611) 2023-11-26 09:39:46 -08:00