Commit graph

423 commits

Author SHA1 Message Date
Kamron Batman
ecbee17690
fix: Optimizes OPL using string interpolation (#1041)
## Breaking Changes (New API)
ObjectPropertyList supports the following API:
```cs
list.Add(500000);
list.Add(500001, stringArgument);
list.Add("Some text");
list.Add($"Some text with {argument}");
list.Add(500002, $"{arg1}\t{arg2}");
```

## Notes
1. All API uses that require a formatter like this:
    ```cs
    list.Add(500002, "{0}\t{1}", arg1, arg2);
    ```
    Should be changed to use string interpolation, for example:
    ```cs
    list.Add(500002, $"{arg1}\t{arg2}");
    ```
2. The following paradigm should no longer be used:
    ```cs
    list.Add(1061170, prop.ToString()); // strength requirement ~1_val~
    ```
    The new string interpolation API will avoid having to convert the argument to a string before writing it to the packet. Instead use the following:
    ```cs
    list.Add(1061170, $"{prop}"); // strength requirement ~1_val~
    ```

### Benchmarks
```cs
|                         Method |     Mean |   Error |  StdDev |  Gen 0 | Allocated |
|------------------------------- |---------:|--------:|--------:|-------:|----------:|
|                BenchmarkOldOPL | 241.0 ns | 0.56 ns | 0.47 ns | 0.0105 |      88 B |
| BenchmarkStringInterpolatedOPL | 199.9 ns | 2.44 ns | 2.39 ns |      - |         - |
```

### Changes
- [X] Removes crash in STArray.Return when array is null.
- [X] Fixes NPE in OPL when entity is null. Serial in packet will be 0 when entity is null.
- [X] Fixes NPE in AosAttributes when Parent is null.
- [X] Changes OPL to use string interpolation.
- [X] Introduces `IPropertyList` to allow extending PropertyList for other uses.
2022-06-02 10:09:53 -07:00
Kamron Batman
98a74a89c7
fix: Fixes drag drop bounce issue (#1040) 2022-05-30 15:47:06 -07:00
Kamron Batman
3b7e3c2fb7
fix: Fixes ValueStringBuilder empty ctor issue (#1035) 2022-05-27 17:49:36 -07:00
Kamron Batman
e172dc9661
fix: Updates dependencies & adds Fedora 35/36 support (#1029) 2022-05-19 10:51:24 -07:00
Kamron Batman
f2ced497ec
fix: Updates pool of acid (#1028)
- [X] Removes duplicate Created property
- [X] Removes allocation while damaging mobiles
- [X] Adds manual dirty checking since we won't be codegenning it and we won't be serializing it.
2022-05-18 17:53:53 -07:00
Kamron Batman
a7fd1905e9
fix: Deletes wanderer (#1023) 2022-05-16 15:10:49 -07:00
Kamron Batman
dd95a8a1e3
fix: Codegens Food & Beverages (#1021)
- [X] Simplifies beverages
- [X] Codegens food & beverages
2022-05-15 21:56:04 -07:00
Kamron Batman
7b619f23b8
fix: Fixes static persistence of faction system (#1020) 2022-05-15 12:45:51 -07:00
Kamron Batman
eee8494558
fix: Removes scale speed by dex for monsters, fixes NPC movement/thinking speed (#1019)
* Removes scaled speed by dex for monsters
* Changes scaled speed by dex for pets (HS+ expansion) to be 400ms -> 100ms between 50 -> 200 dex
* Removes speed changes that were broken for various mobs
* Combines "Legacy" speed and renames the class to `NPCSpeeds`
* Creates speed "classes" (slow, medium, fast, very fast)
* Introduces a new overridable property `SpeedClass`. Register a new speed class using `NPCSpeeds.Register()` and then set the speed class to bulk/mass apply speeds.

Order of speed determination:
1. SpeedMod
2. SpeedClass property (not null)
3. SpeedClass entry in Data\npc-speeds.json for that type
4. "Fast" (200ms Active, 400ms Passive)
2022-05-15 10:01:14 -07:00
Kamron Batman
6ec84b3c01
fix: Cleans up string substring (#1018) 2022-05-14 16:56:03 -07:00
Kamron Batman
f7cbeacf48
fix: Fixes factions and makes it static (#993) 2022-05-10 11:57:37 -07:00
Tellundro
790cb5d733
fix: Fixes NPE in TreasureMapChest (#1010) 2022-05-04 19:10:55 -07:00
Kamron Batman
861ff307c0
fix: Fixes missing invalidate properties for default name (#1012) 2022-05-04 14:40:49 -07:00
Kamron Batman
0f304d77c4
fix: Fixes CAGLoader NPE (#1006) 2022-04-19 17:25:38 -07:00
Kamron Batman
848db6fc4b
fix: Fixes mount blocking and adds permanent option for customization (#1005) 2022-04-19 14:23:10 -07:00
Kamron Batman
3a0f2b0b90
fix: Fixes cutting cloth (#1003) 2022-04-18 15:01:13 -07:00
Kamron Batman
fc3d9b926d
fix: Adds Poison to codegen (#1002) 2022-04-18 00:05:44 -07:00
Kamron Batman
933c41070f
fix: Codegens farmables (#1001) 2022-04-17 17:10:45 -07:00
Kamron Batman
4bde9a4c86
fix: Codegens vendor contracts (#1000) 2022-04-17 16:51:59 -07:00
Kamron Batman
dbb75f78a0
chore: Deletes ConnectUO support (#999)
Looks like connectuo is dead so deleting the support for it.
2022-04-17 09:06:24 -07:00
Kamron Batman
54d728a322
fix: Updates serialization to use v2.0 (#998)
- [X] Deletes serialization annotations
- [X] Updates to ModernUO.Serialization.Annotations nuget
- [X] Updates serializer to v2.0
- [X] Changes all `Serializable()` to `SerializationGenerator()`
- [X] Updates to schema generator v2.0
2022-04-17 08:02:15 -07:00
Mink80
f91ebe8183
fix: Fixes food stacking for poisoned food. (#987) 2022-04-08 10:37:42 -07:00
Kamron Batman
9baa6f58e7
fix: Codegens deeds (#983) 2022-03-30 19:42:38 -07:00
Kamron Batman
b6d155687e
feat: Adds account enumerator (#980) 2022-03-29 13:29:35 -07:00
Kamron Batman
e148e1cabb
fix: Converts stealable artifacts to a system instead of a spawner. (#979) 2022-03-27 19:37:10 -07:00
Kamron Batman
b61968db86
fix: Codegens artifacts (#978) 2022-03-27 17:56:00 -07:00
Kamron Batman
fa0bf86a08
fix: Codegens furniture containers (#977) 2022-03-27 15:02:29 -07:00
Kamron Batman
8f922c94ae
fix: Codegens lockable containers and cleans up lockpickable (#976) 2022-03-26 21:48:18 -07:00
Kamron Batman
fc0594f87c
fix: Codegens TreasureMapChest (#975) 2022-03-26 21:33:46 -07:00
Kamron Batman
ba5bb13e60
fix: Codegens mark containers (#974) 2022-03-26 21:23:21 -07:00
Kamron Batman
2f6a0fad3a
fix: Codegens trappable containers (#973)
Splits out trappable container so the logic is easier to expand.
Changes trappable containers to be code genned.
2022-03-26 21:15:15 -07:00
Kamron Batman
81cafa0753
fix: Fixes bank checks falling to the floor. (#972) 2022-03-26 21:06:46 -07:00
Kamron Batman
c166e113b1
fix: Streamlines gump compilation (#969)
Changes gump compilation to use string interpolation. .NET 6 uses code generation and compile time tricks to speed up string interpolation between 15 and 30% and reduce allocations dramatically.
2022-03-22 23:46:10 -07:00
Kamron Batman
14b63ca48e
fix: Updates ArrayPool to STArrayPool for performance. (#968) 2022-03-22 20:07:32 -07:00
Kamron Batman
76fddcbccd
feat: Adds a single threaded array pool (#967)
## Added Feature
Adds a single threaded array pool that works exactly the same as `ArrayPool<T>.Shared`.
The `STArrayPool<T>.Shared` can only be used on a single thread, the main game thread of the server.

Note: Unlike the built-in array pool, there is no hook into the _GC Gen 2_. This means to relieve potentially high memory pressure, `ArrayPool<T>.Shared.Trim()` must be called. The pool will only release arrays _after two successive calls within 10 seconds or longer_. If the server is at less than 70% total memory usage, or the server is not going to use this pool for something egregious, then don't bother ever calling Trim().


## Changes
- [X] Fixes ArrayPool calls that should be cleared due to references.
- [X] Benchmarks against ArrayPool with 4+ rented arrays deep of the same length.
- [x] Unit tests
2022-03-22 09:58:24 -07:00
Kamron Batman
0925a2d435
fix: Cleans up Point checks and removes statics (#966)
- [X] Removes static freezing/unfreezing. Use other tools for this.
- [X] Cleans up IPoint3D allocations
- [X] Removes IPoint3D constructors since the compiler may not optimize the constructor path and allow allocations.


Note: Instead of `new Point3D(m)`, do something like `new Point3D(m.Location)`. Sorry for the inconvenience. In the long run this will prevent abuse of hot paths that will cause performance issues.
2022-03-20 23:15:59 -07:00
Kamron Batman
23532db603
fix: Cleans up LINQ calls. (#965)
- [X] Removes several `ToList()` uses with `PooledRefQueue`
- [X] Adds a `PeekRandom` to PooledRefQueue
- [X] Updates EV/BS so they dispel each other in a more efficient manner.
- [X] Fixes Firebomb so it works like a normal firefield.
- [X] Fixes field spells so they aren't unnecessarily using a Point3D ref more than necessary.
- [X] Removes extra allocation in campfire by using reverse loop.
- [X] Removes other LINQ calls that aren't needed.
2022-03-20 19:20:54 -07:00
Kamron Batman
89f3a0522c
fix: Round 3 of speed updates for NPCs (#963)
- [X] Fixes mobs having 0 speed.
- [X] Fixes mobs missing legacy speeds.
2022-03-18 12:56:42 -07:00
Kamron Batman
1e5b1a11a8
fix: Cleans up unused code (#961) 2022-03-15 20:02:40 -07:00
Kamron Batman
c64e3e3ba8
fix: Fixes bad movement checks (#960) 2022-03-15 19:39:52 -07:00
Kamron Batman
1ec3636951
fix: Fixes speed issues (#959)
- [X] Removes all speeds in constructors since _they aren't used anyways_.
- [X] Adjusted timers according to the _time transformations in RunUO_.
2022-03-15 10:18:27 -07:00
Kamron Batman
bdee7bc671
fix: Fixes NPC slowness. (#955)
* Adds the following configurations:
  * `movement.delay.npcMinDelay` - 0.1 - Pets or Non-monster NPCs
  * `movement.delay.npcMaxDelay` - 0.4 - Pets or Non-monster NPCs
  * `movement.delay.monsterMinDelay` - 0.4 - Non-pet Monsters or NPC vs Player Combat
  * `movement.delay.monsterMaxDelay` - 0.8 - Non-pet Monsters or NPC vs Player Combat
  * `movement.delay.monsterMinDex` - 150 - Dex maximum for delay by dex
  * `movement.delay.MinDex` - 190 - Dex maximum for delay by dex
2022-03-10 22:55:06 -08:00
Kamron Batman
44bd129734
fix: Fixes mana insufficient message for newer clients. (#957)
Publish 100 introduced the cliloc change for insufficient mana. This was rolled out starting with v7.0.65.4 on 6/22/2018.
2022-03-10 12:18:22 -08:00
Kamron Batman
58b907d39e
fix: Fixes packet length checks (#953)
Fixes an issue with DropReq where an old client was sending in 14 bytes, but the server was expecting 15 bytes.

To fix this we introduced a new packet handler, `ContainerGridPacketHandler` and changed the code to determine the length of the packet dynamically using `GetLength(NetState)`.

Also fixed throttling so dropped packets are properly skipped.
2022-03-04 12:32:25 -08:00
Kamron Batman
5a43c806fe
fix: Use tuple shorthand syntax (#951) 2022-02-28 08:43:41 -08:00
Kamron Batman
ca29fc640a
fix: Fixes stats for earlier expansions (#950) 2022-02-28 07:04:07 -08:00
Kamron Batman
54b268c02f
fix: Codegens treasure chests (#949) 2022-02-27 18:02:36 -08:00
Kamron Batman
17f8d3563a
fix: Codegens treasure/paragon chests & strongboxes (#948) 2022-02-27 17:22:38 -08:00
Kamron Batman
9bc6d5bdb8
fix: Codegens salvage bags (#947) 2022-02-27 17:09:12 -08:00
Kamron Batman
003ad1164f
fix: Codegens containers (#946) 2022-02-27 17:01:49 -08:00