Commit graph

434 commits

Author SHA1 Message Date
Kamron Batman
6ec84b3c01
fix: Cleans up string substring (#1018) 2022-05-14 16:56:03 -07:00
Kamron Batman
87b63b38a5
fix: Eliminates string allocations while writing gump packets (#1017)
* Introduces `RawInterpolatedStringHandler` which is exactly the same as `DefaultInterpolatedStringHandler` except it _unsafely exposes_ it's `ReadOnlySpan<char>` buffer. This is useful for writing the string's data without actually building the string.
* Uses this new string interpolation handler in `SpanWriter` to eliminate intermediate strings built. This is immensely useful in eliminating string allocations in writing Gump packets.
2022-05-10 18:50:23 -07:00
Kamron Batman
f7cbeacf48
fix: Fixes factions and makes it static (#993) 2022-05-10 11:57:37 -07:00
Kamron Batman
097c0143b0
fix: Fixes missing localization interpolation handler (#1016) 2022-05-10 00:42:59 -07:00
Kamron Batman
8031de4738
fix: Fixes string format of cliloc arguments (#1015) 2022-05-10 00:37:07 -07:00
Kamron Batman
47d427ed6e
fix: Adds cliloc replacement support (#1014) 2022-05-09 21:10:58 -07:00
Kamron Batman
be7da3a3dc
feat: Adds cliloc support and fixes valuestringbuilder ctor (#1013)
- [X] Adds cliloc support using the following API:
```cs
public static class Localization
{
    string GetText(int number);
    string GetText(int number, string lang);
    string Format(int number, params object[] args);
    string Format(int number, string lang, params object[] args);

    string Format(int number, $"{arg1}{arg2}{arg3}");
    string Format(int number, lang, $"{arg1}{arg2}{arg3}");

    bool TryGetLocalization(int number, out LocalizationEntry entry);
    bool TryGetLocalization(int number, string lang, out LocalizationEntry entry);
}

public class LocalizationEntry
{
    string Language { get; }
    string Number { get; }
    string Text { get; }
    string?[] TextSlices { get; } // Used for string building
    string StringFormatter { get; }

    string Format(params object[] args);
    string Format($"{arg1}{arg2}{arg3}");
}
```

- [X] Fixes a bug with ValueStringBuilder and default initialization size
- [X] Optimizes ValueStringBuilder to use `ISpanFormattable`
- [X] Adds `Append<T>(T value);` support ValueStringBuilder
- [X] Adds `Append($"");` string interpolation support to ValueStringBuider
2022-05-08 21:24:32 -07:00
Kamron Batman
8f1240d25e
fix: Fixes expansion flags for animations (#1009) 2022-05-01 18:35:42 -07:00
Kamron Batman
f2275cb65b
fix: Adds OnBeforeDisconnected and BeforeDisconnected eventsink (#1004) 2022-04-19 00:34:02 -07:00
Kamron Batman
fc3d9b926d
fix: Adds Poison to codegen (#1002) 2022-04-18 00:05:44 -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
Kamron Batman
910549db84
fix: Fixes loading multi when client is missing (#996)
* Changes reading multi.mul/multi.idx so it is loaded entirely during bootup.
* Fixes finding files in Linux.
* Fixes handling HS format.
* Removes verdata support.

ModernUO will still have issues if there is a multi.mul that is pre-HS loaded when it detects a client that is 7.0.9+.
2022-04-14 16:52:45 -07:00
Kamron Batman
6c22bb2b97
fix: Fixes spelling of 8th age (#995) 2022-04-12 21:00:30 -07:00
Kamron Batman
de0bf03f46
fix: Simplifies expansion checks (#994) 2022-04-12 20:52:53 -07:00
Kamron Batman
0d9259e4cd
fix: Adds Combine overloads (#989) 2022-04-06 15:51:03 -07:00
Kamron Batman
943b2eca36
feat: Adds Combine for arrays (#988) 2022-04-06 15:34:47 -07:00
jkachhad
b2b4c809f8
fix: Properly count timers for DumpInfo (#986) 2022-04-03 00:00:01 -07:00
Kamron Batman
fdcd6c80a8
chore: Adds benchmarks for RunUO vs ModernUO Timers (#984) 2022-03-31 00:16:45 -07:00
Kamron Batman
55a6589644
fix: Fixes wrong point reference in building region (#982) 2022-03-30 13:14:29 -07:00
Kamron Batman
a5a5460291
fix: Fixes world save timer issue (#981)
Fixes a major bug where a race condition could cause the timer wheel to have non-deterministic behavior and potentially never finish the save.
2022-03-29 15:08:23 -07:00
Kamron Batman
e9f986f55b
fix: Adds Gen2 callback for each STArrayPool (#971)
Adds. Gen2Callback for STArrayPool so it can purge the internal array stacks properly. This only happens if significant timed has passed, 2 Gen 2's have been run, and memory pressure exceeds a threshold.
2022-03-26 13:57:42 -07:00
Kamron Batman
474427041f
feat: Adds a PooledRefList (#676) 2022-03-26 11:11:22 -07:00
Kamron Batman
601eb4e116
fix: Uses variables for gump html localized (#970) 2022-03-22 23:51:36 -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
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
16c4268b54
fix: Fixes file reading. (#958)
.NET 6 introduced a breaking change where lseek and sys-calls are not used for reading and file streams. This effectively broke out native reader. Since the file reading is fairly optimized, and honestly we don't need it to be "fast" in this case, I have removed the native reader.

https://devblogs.microsoft.com/dotnet/file-io-improvements-in-dotnet-6/
2022-03-11 01:45:03 -08: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
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
1f4162288e
fix: Fixes UOClient NPE (#952) 2022-02-28 17:24:00 -08:00
Kamron Batman
651cffa872
fix: Cleans up mobile status packets (#835)
* Removes Span2D for mobile moving. Instead uses pure math and simplifies the calculation.
* Cleans up the extended mobile status packet.
2022-02-27 03:10:35 -08:00
Kamron Batman
e873d2ed7e
fix: Simplifies fastwalk detection (#907)
* Uses a circular buffer for steps.
* Limits to 3 steps instead of 4.
* Gives a 5% buffer on the first step.
2022-02-27 02:20:03 -08:00
Kamron Batman
5b7b99e0de
fix: Adds CUO settings support and adds more robust 7.0.9 support (#945) 2022-02-27 02:15:06 -08:00
Kamron Batman
941452de4a
fix: Stops creating blocked packets entirely (#944)
Optimizes larger servers where users are logging in and packets are being created for no reason.
2022-02-27 00:13:49 -08:00
Kamron Batman
5db8b1354c
fix: Fixes various minor issues (#943) 2022-02-26 23:43:25 -08:00
Kamron Batman
6593abf418
fix: Fixes weight problem with dupe. Fixes mobile base weight. (#938) 2022-02-18 22:11:57 -08:00
Kamron Batman
48f1fe3384
fix: Moves codegen to its own repo (#918)
- [X] Replace serialization generator with nuget
- [X] Replace schema migration with dotnet bool
- [X] Add ability to run migrations in VS/Rider using a project build
2022-02-12 17:58:42 -08:00
Kamron Batman
ba378fc5f2
fix: Adds Ubuntu 14 and Linux Mint 17/18/19 support specifically (#908) 2022-01-03 14:19:39 -08:00
Kamron Batman
c1134c526f
fix: Fixes sorting (#905) 2021-12-29 10:10:53 -08:00
Kamron Batman
284c3d0f34
fix: Removes LINQ from Map.cs (#834)
* Removes LINQ from Map
* Removes broken GetObjectsInRange with items/mobile flags.
2021-12-28 14:32:45 -08:00
Kamron Batman
93f09ba831
fix: Fixes account gold settings (#898) 2021-12-27 17:17:45 -08:00
Kamron Batman
58190674f9
feat: Adds StaffAccess and ResetStaffDress commands (#895) 2021-12-27 01:27:15 -08:00
Kamron Batman
63e1b02d93
chore: Cleans up pattern checks. (#892) 2021-12-24 15:53:59 -08:00
Kamron Batman
b125146b27
fix: Adds BitArray support with codegen (#888)
* Adds a custom BitArray class with the following added features:
  * ctor for creating BitArray against read only span
  * ctor for creating BitArray against BinaryReader
  * CopyTo to copy a BitArray to a Span
* Adds BitArray to UO Primitive serialization so it can be codegenned.
2021-12-13 09:31:02 -08:00
Kamron Batman
16f65e59c6
fix: Fixes VS builds by reverting back to nstd20 (#882) 2021-12-07 10:20:30 -08:00
Kamron Batman
ef5aee87f3
fix: Adds back generic timer delay call (#880) 2021-12-05 22:55:24 -08:00
Kamron Batman
b67d57d806
fix: Adds Debian 11 and fixes Fedora 34 support (#875)
* Adds Debian 11 support
* Fixes Fedora 34 support
* Updates CentOS8 support
2021-12-04 23:40:38 -08:00