ModernUO/Projects/UOContent/Engines
Kamron Batman a4cabe2fa4
fix: Optimizes FindItemsByType by removing allocations. (#1515)
### Summary
Container enumeration is in dire need of optimization. Thanks to @stefanomerotta for initiating this work with PR #1443. This PR handles a small part of what Stefan started. Also included are some bug fixes.

### Method Signatures

```cs
// Use with foreach without moving/deleting items
FindItemsByTypeEnumerator<T> FindItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use with foreach when moving/deleting items
QueuedItemsEnumerator<T> EnumerateItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiple times or queuing
PooledRefQueue<T> QueueItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiples times or manipulating elements without traversing
PooledRefList<T> ListItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)
```

* `FindItemsByType<T>` has changed from returning `List<T>` to `FindItemsByTypeEnumerator<T>` - This method is not safe to use in situations where an item may get consumed, deleted, or moved.

* `EnumerateItemsByType<T>` was added as a safe way to iterate and manipulate items.
  * **Note**: EnumerateItemsByType will _completely traverse the container_ before iteration starts because it uses `QueueItemsByType` under the hood.

* `QueueItemsByType<T>`  and `ListItemsByType<T>` was added to return a queue or list of items to iterate multiple times and manipulate the items. This isn't the most efficient since it uses a predicate and can result in 2 or 3 total iterations unnecessarily.

### Bug Fixes
- [X] Fishing had an error in the random check that may have caused slight bias.
2023-09-28 19:36:45 -07:00
..
Bulk Orders fix: Updates messages with clilocs (#1381) 2023-03-26 00:54:09 -07:00
CannedEvil chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Chat chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
ConPVP fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Craft fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Doom fix: Fixes doors as decorations & optimizes them (#1392) 2023-04-18 19:28:54 -07:00
Ethics feat: Adds Stamina System to overhaul overweight. (#1465) 2023-09-16 17:52:54 -07:00
Events fix(core): Caches DateTime.NowUtc (#548) 2021-03-13 01:32:04 -08:00
Factions fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Harvest fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Help feat: Adds KR/EC client versions (No actual support yet). (#1506) 2023-09-18 23:53:18 -07:00
Khaldun fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
ML Quests fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Party fix: Fixes more packet initializations (#1507) 2023-09-19 00:02:17 -07:00
Pathing fix: Removes run flag from NPC movement (#1357) 2023-03-02 10:58:17 -08:00
Plants fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Player Murder System feat: Adds Stamina System to overhaul overweight. (#1465) 2023-09-16 17:52:54 -07:00
Quests fix: Overhauls virtue system (#1376) 2023-07-19 21:43:47 -07:00
Spawners chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Stealables fix: Fixes factions and makes it static (#993) 2022-05-10 11:57:37 -07:00
Treasures of Tokuno fix: Replaces FindItem(s)ByType(s) implementation with BFS strategy (#1454) 2023-08-18 22:05:28 -07:00
UltimaStore fix: Replaces throttlers and packet callbacks with function pointers (#1063) 2022-06-15 12:48:43 -07:00
Veteran Rewards chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Virtues feat: Adds Stamina System to overhaul overweight. (#1465) 2023-09-16 17:52:54 -07:00