Commit graph

743 commits

Author SHA1 Message Date
Kamron Batman
6f444488a5
fix: Fixes crashing due to bad packet assumptions. (#1829)
### Summary
- Fixes various exploits that can crash the shard when the client misbehaves.
- Clients will now be disconnected if they send packets that are marked as out of game only (new flag), while they are in-game.


> [!Note]
> **Developer Note**
> Added an `OutOfGameOnly` which should be used to flag packets as only available out of the game.
> This is the opposite of, yet not the converse to `InGameOnly`.
2024-06-07 18:08:07 -07:00
Kamron Batman
1f8ab0e783
fix: Console Input is disabled on Linux when no standard input is attached. (#1809) 2024-06-06 21:20:22 -07:00
Kamron Batman
0b802dbe1b
fix: Fixes duping containers and removes copying private setter properties (#1816)
### Summary
- Removes copying private setters
- Fixes duping containers
- Adds public `Dupe.DoDupe` functions for external scripts to hook into the existing logic.
2024-06-03 15:44:56 -07:00
Kamron Batman
db6e852c91
fix: Fixes reading incoming string packets (#1819) 2024-06-03 14:49:26 -07:00
Kamron Batman
04a15e9620
fix: Adds missing dupe ignore (#1815) 2024-06-02 15:09:35 -07:00
Kamron Batman
9c7cb5d778
fix: Fixes dupe property copying. Adds IgnoreDupe (#1811)
## Summary

### Changes
- Adds `[IgnoreDupe]` and `[SerializedIgnoreDupe]`
- Updates all _known_ classes that need the attribute. Some might be missing, please helps us find them!
- Adds `Item.Dupe()` command and encapsulates `CopyProperties` and `OnAfterDuped`. This is also overridable.
- Updates Dupe command to use the new logic.
- Fixes duping multiple kinds of objects that used to be outright broken.

### Bug Fixes
- Fixes issue with durability after duping
- Fixes issue with hue after duping

> [!Note]
> **Developer Note**
> Customizing how duping an item works now requires two steps:
> 1. Add `[IgnoreDupe]` or `[SerializedIgnoreDupe]` to the property/field
> 2. Add custom logic in an `OnAfterDuped` override
>
> When do you need to do this?
> *When the property being copied is not a primitive, and you need to manually deep-clone the contents of the property such as with Lists, Dictionaries, or sub classes.*
2024-06-02 15:04:54 -07:00
Kamron Batman
a8d3d2773e
fix: Fixes libdeflate threading issue (#1813) 2024-06-02 15:02:47 -07:00
Kamron Batman
aeba2261d2
fix: Fixes reading multiple strings (books) (#1814) 2024-06-02 15:01:18 -07:00
Kamron Batman
5f8f7982eb
fix: Fixes publishing (#1808)
### Summary
- Fixes publishing issues when the Application project was created.
- Fixes missing dotnet clean file deletions
2024-05-31 12:59:59 -07:00
Kamron Batman
60a3a6f501
feat: Splits Server in Core and Application (#1806)
> [!Note]
> **Developer Note**
> Now developers will only need to build/run the Application project instead of everything.
> When adding new projects, make sure to: 
> 1. Add a reference to that project in the Application project.
> 2. Add the dll file to the Distribution/Data/assemblies.json file

### Summary
- Adds an application project
- Consolidates process restarts to use `Core.Kill(true)`
- Removes some old messaging, for example processor optimization
- Fixes missing build cleanup
2024-05-30 23:34:03 -07:00
Daniel Dias Rodrigues
e85c56ec2d
fix: Fix ConsoleInput for Linux users with try/catch. (#1803) 2024-05-30 14:03:28 -07:00
Kamron Batman
96a398784f
fix: Fixes incorrect interpolation in legacy gumps (#1800) 2024-05-28 18:38:51 -07:00
Kamron Batman
a4522b9d43
fix: Fixes stalled connections and infinite throttle (#1796)
> [!Warning]
> **Developer Warning**
> The `PacketThrottle` callback return value is now reversed. `true` indicates the connection is _throttled_.

### Summary
- Fixes an issue where connections get stalled forever
- Fixes an issue where the throttler is not working properly
- Removes account attack limiter
- Rewrites IP limiter
- Removes IP restrictions (they weren't used, and not practical)
- Fixes issue where IP limiter was counting before firewall was blocking.

View without whitespace:
https://github.com/modernuo/ModernUO/pull/1796/files?diff=split&w=1
2024-05-27 21:32:55 -07:00
Kamron Batman
ccad915464
fix: Adds more NetState dumping for debug (#1795) 2024-05-27 12:10:27 -07:00
Kamron Batman
21c5e46565
fix: Fixes libdeflate gc pin issue (#1794) 2024-05-25 18:11:46 -07:00
Kamron Batman
21347c8b6b
fix: Fixes binary file writer position increment (#1793) 2024-05-24 16:59:24 -07:00
Kamron Batman
9f1f314077
fix: Fixes infinite loop in BinaryFileWriter (#1792)
### Summary
- Fixes infinite loop with binary file writer
- Removes extra buffer copying with binary file writer
- Removes storing type counts during world save file writing
- Fixes display cache self-deletion warning during world load
2024-05-24 14:36:43 -07:00
Kamron Batman
0011db7f47
fix: Fixes house update range bug (#1790) 2024-05-23 16:07:33 -07:00
Kamron Batman
6596046216
fix: Bumps PollGroup to .Net 8 (#1789) 2024-05-22 18:17:20 -07:00
Stefano Merotta
50d3779d9b
fix: Adds dispose call to LibDeflateBinding on process exits (#1784) 2024-05-21 13:40:03 -07:00
Marcelo Paez Sequeira
00908d030f
fix: Moves many EventSinks out of core. (#1783) 2024-05-21 10:02:30 -07:00
Marcelo Paez Sequeira
1cb798d807
fix: Removed StunRequest and DisarmRequest EventSinks (#1781) 2024-05-19 14:12:58 -07:00
Kamron Batman
1f701e7b55
feat: Replaces Zlib with LibDeflate (#1774)
> [!Warning]
> Users on Linux/OSX will need to follow the Readme
> and make sure `libdeflate` is properly installed

> [!Note]
> **Developer Note**
> The API for compression has changed. Use `Deflate.Standard` for the same functionality.

### Summary
* Replaces Zlib with LibDeflate for a 50% performance improvement!
* Adds MacOS 14 to properly test Arm64
2024-05-16 22:53:01 -07:00
Kamron Batman
d6c87a4da4
fix: Fixes infinite loop in gump builders (#1772)
### Summary
- Fixes infinite loop in gump builders
- Removes allocations for centering/coloring html in builders
2024-05-11 11:13:57 -07:00
Kamron Batman
622250b8f4
fix: Fixes issue with cached static gump strings. Fixes bad gump colors (#1771)
### Summary
- Fixes an issue that causes CUO to crash due to bad string caching in static gumps
- Fixes wrong/bad 16bit html gump hues.
- Moves `C16232` (16-bit to 32-bit) and `C32216` (32-bit to 16-bit) to Utility class for broader use.

TODO:
- Some gumps have different 32bit (for string content) vs 16bit (for localized content) strings. Does this matter?
2024-05-10 22:44:16 -07:00
Kamron Batman
aec75d0810
fix: Fixes GetInRange to use GetAt instead (#1768) 2024-05-09 14:01:25 -07:00
Kamron Batman
26dfde19ee
fix: Consolidates Color/Center html (#1762)
### Summary
- Fixes bad color in virtual check gump
- Consolidates the Color/Center html strings for all gumps
2024-05-07 23:56:32 -07:00
Kamron Batman
05535ec9d1
fix: Fixes continuing after deserialization error (#1761) 2024-05-07 16:56:32 -07:00
Kamron Batman
9d2f471e91
fix: Fixes HtmlLocalized color for gump layouts (#1758) 2024-05-03 21:42:52 -07:00
Kamron Batman
becd7aad05
fix: Cleans up FixHtml (#1757) 2024-05-03 21:24:31 -07:00
Kamron Batman
4ea1d79cad
fix: Removes broken OrderedHashSet and adds a simple OrderedSet (#1756)
> [!CAUTION]
> **BREAKING CHANGE**
> Removed `OrderdHashSet` and `PooledOrderedHashSet` due to bugs.

> [!NOTE]
> **Developer Note**
> The OrderedSet is not a full data structure. It is not particularly efficient. Pull Requests are welcome for a better implementation, especially if it ends up supporting `ISet<T>` and `IReadOnlySet<T>`

## Summary

The ordered hash set was buggy. It's kind of painful to implement, so for now, I added a simple `OrderedSet` to suffice for gumps. Please reach out if this causes disruption!
2024-05-03 18:03:26 -07:00
kaczy93
dc118d836f
feat: Cleans up UOP file handling. Adds automatic bounds.bin generation (#1744)
### Summary
* Unifies reading UOP File indexes
* Adds ArtData file reader to get graphic bounds
* Automatically generates Bounds.bin from art file if missing
* Adds [GenBounds command to regenerate the bounds.bin file. Useful for when the art file changes.
2024-05-01 20:02:06 -07:00
Kamron Batman
c4fbc6b88e
fix: Adds text command to throttle. Fixes throttle itself. (#1743) 2024-04-26 17:54:33 -07:00
Kamron Batman
65532ea887
feat: Adds optimized dynamic/static layout gumps (#1652)
# New Gump API
We are pleased to release a new API that is faster, allocates nearly zero memory, and still feels very similar to the original API. The API is broken into 3 types of gumps, dynamic, static with placeholders, and static without placeholders. 

### Dynamic Gumps
These gumps will inherit `DynamicGump` and are meant for gumps that have a dynamic layout. This includes specifying dynamic arguments to HtmlLocalized entries.

## Static Gumps 
Static gumps are those where the function to the build the layout is called only once and cached forever. They can optionally have placeholders. These placeholders allow the developer to specify the string values later, dynamically in a `BuildStrings` method on the gump. If a gump does not have any placeholders, the string entries will also be cached forever.

## Benchmarks
To make sure we were going in the right direction and not wasting time, we took copious benchmarks. Here are the final benchmarks for a really simple gump. 

Note:
* The majority of creating a gump is compressing the layout and the strings. Compressing each section takes ~6,000ns (12us total).

```cs
| Method                         | Mean         | Error        | StdDev       | Median       | Ratio | RatioSD | Gen0   | Allocated | Alloc Ratio |
|------------------------------- |-------------:|-------------:|-------------:|-------------:|------:|--------:|-------:|----------:|------------:|
| OldGump                        | 13,308.29 ns | 1,059.695 ns | 1,883.608 ns | 14,330.72 ns | 1.000 |    0.00 | 0.1526 |    2400 B |        1.00 |
| DynamicLayoutGump              | 13,357.86 ns |   129.144 ns |   226.185 ns | 13,323.60 ns | 1.029 |    0.17 |      - |      48 B |        0.02 |
| StaticLayoutDynamicStringsGump |  6,653.10 ns |    81.815 ns |   143.292 ns |  6,617.45 ns | 0.514 |    0.09 |      - |      40 B |        0.02 |
| StaticLayoutGump               |     86.33 ns |     0.760 ns |     1.350 ns |     86.07 ns | 0.007 |    0.00 | 0.0020 |      32 B |        0.01 |
```

# Non-Breaking Changes
* All gump components in the core have been moved to `Gumps/Legacy`.
* All legacy gumps will still inherit `Gump`, which now inherits `BaseGump`

# Special Thanks

Thank you to @stefanomerotta for considerable contributions/benchmarking/testing to make this effort a reality! We collectively went through over 10 iterations, but it is finally ready.
2024-04-25 22:40:30 -07:00
Kamron Batman
1c10b6dbed
fix: Adds support for ROS to HashUtility (#1740) 2024-04-25 00:42:10 -07:00
Kamron Batman
9cd84ba3d6
fix: Removes support for v4 Client and old gump packet. (#1739)
### Summary
* Removes old gump packet support
* Removes support for v4 clients
* Removes `Unpack` flag and assumes it is always true.
* Removes StringToBuffer since this is built into .NET now.

> [!Note]
> View the file changes with white space off: https://github.com/modernuo/ModernUO/pull/1739/files?diff=split&w=1
2024-04-24 19:39:37 -07:00
Kamron Batman
7a160bb0fd
fix: Fixes STArray size and tests (#1737) 2024-04-23 16:18:24 -07:00
Kamron Batman
3a27ab8810
fix: Improves STArray and SpanWriter with packets (#1736) 2024-04-21 20:44:25 -07:00
Kamron Batman
3e3b08e666
fix: Fixes max items serializatio n issue (#1728)
### Summary

Fixes an issue where max items is deserialized as 0 instead of -1. To fix broken containers, run the following in-game:
`[global set maxitems -1 where container maxitems = 0`

In vanilla MUO, there are no containers that actually have max items set to 0.
2024-04-12 14:11:58 -07:00
Kamron Batman
ac562e67dc
fix: Adds back socket connected event (#1688)
### Summary
Adds back the `SocketConnected` event. This event only fires asynchronously! (TcpServer thread).

Example:
```cs

public static void Configure()
{
    TcpServer.EventSink.SocketConnected += OnSocketConnected;
}

// WARNING: Executed on the TcpServer thread!
private static void OnSocketConnected(TcpServer.SocketConnectedEventArgs args)
{
    if (... logic here...)
    {
        AdminFirewall.Add(((IPEndPoint)Socket.RemoteEndPoint)!.Address);
    }
}
```
2024-04-06 10:26:46 -07:00
Kamron Batman
6cb18f87fa
fix: Simplifies create food and localizes. Fixes localization fallback (#1721) 2024-04-05 19:45:42 -07:00
Kamron Batman
912eaab460
fix: Fixes unresponsive console input (#1720)
### Summary
Fixes an issue where the call priority of `Initialize` functions causes a dead lock because the console input handler was not initialized.
2024-04-05 15:07:43 -07:00
Kamron Batman
29ea813242
fix: Cleans up code with feeding pets and adds batch coin flips random check (#1717) 2024-04-04 15:09:15 -07:00
Kamron Batman
183f6fa4ac
fix: Fixes stuck connections (#1708) 2024-04-03 08:14:41 -07:00
Kamron Batman
39215935cf
fix: Fixes amount error spam from scissors (#1715) 2024-03-30 09:52:40 -07:00
Kamron Batman
e638fb7893
feat: Adds console commands (#1714)
### Summary
* Adds console command support.
* Adds `save`, `restart`, and `shutdown` commands.
2024-03-30 09:40:43 -07:00
Kamron Batman
1a7e7c7c70
fix: Fixes spawner timer deserialization, decimal deserialization, and adds potion keg reverse lookup (#1711)
### Summary
* Fixes spawner timer deserialization
* Adds a check for a null timer and allows the timer to get recreated
* Adds PotionKeg reverse lookup
* Heavily optimizes decimal serialize/deserialize
2024-03-28 13:34:12 -07:00
Kamron Batman
3332fabc39
fix: Reverts to RunUO speeds, fixes direction glitching, adds movement speed interpolation (#1695)
> [!IMPORTANT]  
> Please read through these changes, as they changed certain expectations for how the internal AI thinking/movement work.
> Note that some mobs still don't have smooth movement on ClassicUO due to how the client handles animations/movement.

### Summary
- **Important Change**: Mobs will now move at a more regular pace. If the OnThink results in a move, but the cooldown would otherwise prevent the move, then the movement is scheduled on another timer.
- Added a 400ms delay to mobs turning to face a player to attack in order to avoid glitching between moving and turning.
- Reverted AI thinking speeds back to RunUO specific speeds.
- Reverted the AI thinking to moving conversion delays back to RunUO.
- For thinking speeds that are not exactly the predefined speeds from RunUO, there is a new calculation to determine the correct conversion to movement speed. This stops speeds like `0.35` from being faster than `0.3`

> [!NOTE]  
> **Developer Note**
> BaseAI.CheckMove() no longer contains the check for whether or not a mob is on movement cooldown. This function can now be overwritten without causing issues to figuring out that cooldown.
2024-03-18 14:13:41 -07:00
Kamron Batman
9e37879f19
fix: Fixes iterating with multiple multis in a sector (#1706) 2024-03-10 11:35:57 -07:00
Kamron Batman
b5342a82e1
fix: Fixes language casing and adds localization reset command (#1703) 2024-03-09 11:02:56 -08:00