Commit graph

2366 commits

Author SHA1 Message Date
Kamron Batman
10a69bf754
feat: Adds a memory mirrored ring buffer for networking. (#1533)
## Breaking Changes

Incoming packet registration signature has changed to:
```cs
delegate* void OnReceiveCallback(NetState state, SpanReader reader, int packetLength);

IncomingPackets.Register(int packetID, int length, bool ingame, OnReceiveCallback onReceive);
```

For example, an incoming packet handler signature would now look like this:
```cs
public static void SomeIncomingPacket(NetState state, SpanReader reader, int packetLength)
{
    // Parse the data
}
```

## Summary

Updates the network Pipe class to use a mirrored memory technique. This technique involves mapping the same physical memory to two contiguous virtual memory spaces so the byte buffer appears duplicated. This allows writing to a double-sized array to wrap around without the need for the `CircularBuffer` classes.

In practice this allows us to use `Span<byte>` as if the buffer was a regular array.


### Bug Fixes

- [X] Fixes bad fixed length string parsing
2023-10-09 00:57:53 -07:00
Kamron Batman
629a5008c3
fix: Fixes hanging tests (#1535) 2023-10-09 00:22:59 -07:00
Eric Vintimilla
d0d81d0d5f
fix: Fix ConsumeTotal always failing (#1534) 2023-10-06 11:02:59 -07:00
Eric Vintimilla
f4db1e3aad
fix: Fix animal trainer pet list only showing first pet. (#1532) 2023-10-04 11:03:25 -07:00
Kamron Batman
9b87049658
fix: Codegens BulkOrderBooks (#1531) 2023-10-03 20:44:15 -07:00
Kamron Batman
1f0acddc46
fix: Fixes serialization threading, moves world save to end of loop, and eliminates Parallel.ForEach. (#1530) 2023-10-03 00:42:49 -07:00
Kamron Batman
e18115dd94
fix: Fixes extension method refactors causing crash (#1529) 2023-10-02 22:24:16 -07:00
Kamron Batman
f2de2fbb77
fix: Cleans up entity persistence. Generalizes Mobiles/Items/Guilds (#1528)
### Summary
- [X] Fixed a bug where entity persistence was serialized out of order, causing world corruption.
- [X] Fixed LastSerialized not being utilized properly and dangling references still becoming an issue.
- [X] Added a new `GenericEntityPersistence<T>` type to encapsulate `ISerializable` serialization.
- [X] Removing the custom logic and moved Items, Mobiles, Guilds, and Accounts  to GenericEntityPersistence.
- [X] Changed serialization to use the singleton pattern to reduce calling methods from stored variables.
2023-10-01 22:10:47 -07:00
Kamron Batman
e0225c6e59
fix: Adds generic entity persistence support and BOBEntry as entities (#1527)
### Summary
Adds a generic entity persistence. This can be used to create new entity types that have a `Serial`.

Here is an example:

```cs
public class BOBEntries : GenericEntitySerialization<IBOBEntry>
{
    public static void Configure()
    {
        Configure("BOBEntries");
    }
}
```

The annotation tells the system what folder to serialize the entries to. The class/interface (`IBOBEntry`) is the root type that implements `ISerializable`.
2023-10-01 17:38:52 -07:00
Mink80
666b83a3dd
fix: ForceOfNature should damage the target (#1526) 2023-10-01 08:21:28 -07:00
Kamron Batman
d55406337f
fix: Fixes ML Escortables and codegens (#1525)
### Summary
- [X] Adds tot.json to ignore list.
- [X] Fixes bias in escortable random quest selection.
- [X] Adds New Haven specific destination/payment messages for escortable quests.
- [X] Codegens escortables.
2023-09-30 14:11:48 -07:00
Kamron Batman
7d05e3b1cb
fix: Codegens ToT and replaces persistence with config (#1524) 2023-09-30 02:09:28 -07:00
Kamron Batman
5ea5fb43cc
fix: Codegens character statues (#1523) 2023-09-30 01:30:47 -07:00
Kamron Batman
27cd214d58
fix: Codegens ML Quest items (#1522) 2023-09-30 00:46:07 -07:00
Kamron Batman
145c93ccf7
fix: Codegens Khaldun and Doom (#1521) 2023-09-30 00:27:06 -07:00
Kamron Batman
5dc2d09392
fix: Codegens construction items (#1520) 2023-09-29 23:28:51 -07:00
Kamron Batman
972949455b
fix: Changes BaseWeapon to source generator and changes crafter to string (#1519) 2023-09-29 22:45:37 -07:00
Kamron Batman
d6823309d4
fix: Fixes missing inscription message (#1518) 2023-09-29 21:38:06 -07:00
Kamron Batman
0d21459e85
fix: Cleans up ConsumeTotal and ClockworkAssembly (#1517) 2023-09-28 23:01:35 -07:00
Kamron Batman
d77dac9516
fix: Cleans up FindItems and removes allocations (#1516) 2023-09-28 22:20:36 -07:00
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
Kamron Batman
146abad36e
feat: Adds a movement throttle system. Removes Fastwalk system. (#1511)
### Summary

- Removes Fastwalk system
  - Removed the following settings:
    - `movement.enableFastWalkPrevention`
    - `movement.fastwalkExemptionLevel`
- Adds movement throttle system.
  - Adds the following settings:
    - `movement.throttleReset` - Default value is `1000` (1 second).
    - `movement.throttleThreshold` - Default value is `400` (400ms).

### Movement Throttling

This new system will trigger if a player requests 400ms (configurable) worth of movements quicker than wall clock time. When this happens, the player is throttled (all incoming packets to the server are halted) until wall clock time catches up with the requests. Upon each throttle, the player receives enough credit to handle up to 400ms of "lag" as a grace/catch-up.


### Developer Notes
We use two throttle queues to prevent an infinite loop.
2023-09-27 20:53:22 -07:00
Mink80
27df6344d9
fix: Optimizes redundant spell damage logic 2023-09-27 13:24:46 -07:00
Kamron Batman
0f41a3d1b1
fix: Fixes throttle receive packet issues (#1513) 2023-09-25 18:35:59 -07:00
Kamron Batman
5d78941ddf
fix: Fixes dropped packets (#1512) 2023-09-23 12:15:42 -07:00
Kamron Batman
7003552e71
fix: Fixes throttle state (#1510) 2023-09-23 11:07:14 -07:00
Kamron Batman
38557342f4
fix: Fixes region child level (#1508) 2023-09-19 10:35:50 -07:00
Kamron Batman
2a3e048b86
fix: Fixes more packet initializations (#1507) 2023-09-19 00:02:17 -07:00
Kamron Batman
0bec97639f
feat: Adds KR/EC client versions (No actual support yet). (#1506)
### Summary

- Adds KR/EC client versions to ClientVersion
- Adds distinction for enhanced versions in the page queue
- Adds KR Expansion flags
- Adds ProtocolChange enum support
- Adds missing Moongate checks for TerMur
- Adds better message for why a client version is not supported, and which ones are supported.
2023-09-18 23:53:18 -07:00
dependabot[bot]
cee4d0fb15
chore(deps): Bump xunit.runner.visualstudio from 2.5.0 to 2.5.1 (#1504)
Bumps [xunit.runner.visualstudio](https://github.com/xunit/xunit) from 2.5.0 to 2.5.1.
- [Commits](https://github.com/xunit/xunit/compare/2.5.0...2.5.1)

---
updated-dependencies:
- dependency-name: xunit.runner.visualstudio
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:37:53 -07:00
dependabot[bot]
a616d0fcd2
chore(deps): Bump xunit from 2.5.0 to 2.5.1 (#1505)
Bumps [xunit](https://github.com/xunit/xunit) from 2.5.0 to 2.5.1.
- [Commits](https://github.com/xunit/xunit/compare/2.5.0...2.5.1)

---
updated-dependencies:
- dependency-name: xunit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:36:49 -07:00
sp1r17
11e1b425d9
fix: Hireables should not drop their pack (#1503) 2023-09-17 17:24:59 -07:00
Kamron Batman
856db6a64c
fix: Fixes variable name in stamina system (#1501) 2023-09-16 18:10:55 -07:00
Kamron Batman
0f2870e94a
feat: Adds Stamina System to overhaul overweight. (#1465)
## Overhaul to Stamina (Overweight) System

### Added configurations

```json
{
  "settings": {
    "stamina.enableMountStamina": "True",
    "stamina.cannotMoveWhenFatigued": "True",
    "stamina.stonesPerOverweightLoss": "25",
    "stamina.stonesOverweightAllowance": "4",
    "stamina.baseOverweightLoss": "5",
    "stamina.additionalLossWhenBelow": "0.1",
    "stamina.mountLastMoveStepsReset": "01:00:00:00",
    "stamina.enableMountStamina": "True",
    "stamina.useMountStaminaOnlyWhenOverloaded": "False",
  },
}
```
- `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism.
- `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding)
- `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation.
- `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. 

### Mount stamina

Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_.

### Changes to player stamina

Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest.

### Developer Notes

- `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way.
- `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types.

Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
Kamron Batman
25eaff0b68
fix: Fixes arbitrage by adjusting prices. (#1500) 2023-09-15 19:22:35 -07:00
Kamron Batman
3481f60f5b
fix: Updates PollGroup to use the refactored/fixed changes by stefanomerotta (#1499) 2023-09-13 23:58:28 -07:00
Kamron Batman
dfca90e076
chore: Adds VC++ Redist 17 to README (#1498) 2023-09-13 22:54:32 -07:00
Kamron Batman
0d6a77ea74
fix: Bumps PollGroup to fix NPE error (#1497) 2023-09-13 12:51:12 -07:00
Kamron Batman
f4b329f203
fix: Bumps PollGroup to fix arm support (#1496) 2023-09-13 10:26:15 -07:00
Kamron Batman
319d82fec9
fix: Renames WeightOverloading to StaminaSystem (#1495) 2023-09-06 18:58:45 -07:00
Kamron Batman
6820efe0ca
fix: Codegens and fixes bugs with plant system (#1490) 2023-09-05 19:20:03 -07:00
dependabot[bot]
01b864f955
chore(deps): Bump MailKit from 4.1.0 to 4.2.0 (#1493)
Bumps [MailKit](https://github.com/jstedfast/MailKit) from 4.1.0 to 4.2.0.
- [Changelog](https://github.com/jstedfast/MailKit/blob/master/ReleaseNotes.md)
- [Commits](https://github.com/jstedfast/MailKit/compare/4.1.0...4.2.0)

---
updated-dependencies:
- dependency-name: MailKit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-04 22:37:30 -07:00
Kamron Batman
2d7a65d479
fix: Adds gate travel migration file (#1491) 2023-09-03 21:28:50 -07:00
Christian
5d6045eefd
docs: Adds starting a server notes and tips. (#1487) 2023-09-03 09:49:42 -07:00
Kamron Batman
74c6d91d34
fix: Fixes NPE in FilterAccess (#1488) 2023-09-03 09:33:12 -07:00
Kamron Batman
60a6796903
feat: Adds ping listener on port 12000 for server list (#1485) 2023-09-03 09:29:27 -07:00
Kamron Batman
15227a53ec
fix: Fixes gate travel location issue (#1484) 2023-09-01 09:23:10 -07:00
Kamron Batman
1b07b00510
fix: Fixes hellsteed name (#1480) 2023-08-30 09:05:38 -07:00
dependabot[bot]
083bfe7294
chore(deps): Bump Microsoft.NET.Test.Sdk from 17.7.1 to 17.7.2 (#1479)
Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.7.1 to 17.7.2.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md)
- [Commits](https://github.com/microsoft/vstest/compare/v17.7.1...v17.7.2)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-30 08:35:42 -07:00
Kamron Batman
e5439c1a8f
fix: Adds a timeout and retry to public IP detection (#1478) 2023-08-29 08:56:50 -07:00