Commit graph

132 commits

Author SHA1 Message Date
Kamron Batman
ca3df9cfa7
fix: Adds multis to map iterators, fixes searching empty nested containers (#1581)
### Summary
Eliminates `IPooledEnumerable<BaseMulti>` and `eable.Free()` from `Map` for multis. This drastically simplifies code that iterates in range, for example:

```cs
foreach (var m in m.GetMultisInRange(5))
{
}
```
The code above no longer requires an eable and calling `Free()`.


### Bug Fixes
- [X] Fixes an issue with searching through nested empty containers.
2023-11-05 08:17:34 -08:00
Kamron Batman
1f04a13f67
fix: Fixes poison field duration, cleans up skill calculations and poison calculations (#1582)
### Summary
- [X] Fixes poison field duration
- [X] Adds SA+ poison spell calculations
- [X] Cleans up skill calculations
- [X] Adjusts poison level thresholds to properly reflect OSI
2023-11-04 12:32:54 -07:00
Kamron Batman
28c06c1cc0
fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553)
### Summary

Eliminates `IPooledEnumerable<T>` and `eable.Free()` from `Map` for mobiles. This drastically simplifies code that iterates in range, for example:

```cs
foreach (var m in m.GetMobilesInRange(5))
{
}
```
The code above no longer requires an eable and calling `Free()`.

- [X] Fixed several locations where an NPC that was damaged would cause a server crash.
- [X] Removed an unnecessary allocation in guard fake calls (NPCs calling guards on you)
- [X] Fixes damage precision loss in Poison Strike Spell
- [X] BogThing no longer attempts to "search" for boglings to eat when it is at full health
2023-10-29 22:42:46 -07:00
Kamron Batman
d919f71149
fix: Fixes map iterators for Items (#1564)
### Summary

Modifying a ValueLinkList using one of the methods will bump the "version". This field is used by iterators (foreach loops) to determine if the link list was modified while iterating. The sector.Items (and in the future other lists), will no longer be safe to modify while iterating. The server will _CRASH_ if the ValueLinkList is modified.

Thanks to @stefanomerotta for help!


### Screenshots
<img width="588" alt="image" src="https://github.com/modernuo/ModernUO/assets/3953314/83ee0b6e-ff4f-4768-9e29-84456e04b1ec">
2023-10-26 17:49:15 -07:00
mark1145
f6491c0fe5
fix: Fixes mana vampire creating mana from thin air (#1561) 2023-10-22 12:07:14 -07:00
Kamron Batman
24858f3989
fix: Changes Map.Sector.Items to link list. (#1547)
### Summary

Eliminates `IPooledEnumerable<T>` and `eable.Free()` from `Map` for items. This drastically simplifies code that iterates in range, for example:

```cs
foreach (var item in m.GetItemsInRange(5))
{
}
```
The code above no longer requires an eable and calling `Free()`.
2023-10-16 20:51:02 -07:00
Kamron Batman
d57f1fecc1
fix: Prepares for IPooledEnumerable removal (#1548)
### Summary

- Removes `IPooledEnumerable` (non-generic)
- Changes `IPooledEnumerable<T>` so that  `Free()` is replaced with the `IDisposable` pattern
2023-10-15 11:20:49 -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
Mink80
27df6344d9
fix: Optimizes redundant spell damage logic 2023-09-27 13:24:46 -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
Kamron Batman
319d82fec9
fix: Renames WeightOverloading to StaminaSystem (#1495) 2023-09-06 18:58:45 -07:00
Kamron Batman
15227a53ec
fix: Fixes gate travel location issue (#1484) 2023-09-01 09:23:10 -07:00
Kamron Batman
ffb0b24e1a
fix: Codegens talismans - Fixes memory leak (#1469) 2023-08-23 22:41:48 -07:00
Kamron Batman
3b97e8d39c
fix: Fixes stabled, abilities targeting self, and unsummon memory leak (#1418)
## **MAJOR CHANGE**
* `Stabled` has been moved to `PlayerMobile`.
* New methods added, `PlayerMobile.AddStabled` and `PlayerMobile.RemoveStabled`.
* Added `PlayerMobile.AddFollower` and `PlayerMobile.RemoveFollower`.
* `Stabled`, `AutoStabled`, and `AllFollowers` are now `HashSet` and **_CAN BE NULL_**.

### Summary
* Fixes monster abilities causing harm to the monster through reflect
* Adds `CanTriggerAgainstSelf` to override this for healing or some other self-affecting ability
* Fixes a major memory leak where `UnsummonTimer` from animated dead spell lasts up-to 24hrs and therefore holds onto references of dead/deleted mobs.
* Fixes another minor leak where a mob is not unregistered from the animated dead spell list until the next spell cast.
2023-07-03 09:45:22 -07:00
vexyl
8f26ad4ac1
fix: Fixes mana drain crash on debug builds (#1413) 2023-06-20 21:22:47 -07:00
mark1145
5e16149b81
fix: Explosion doesn't properly cleanup if mobile fails harmful check (#1412) 2023-06-17 19:42:46 -07:00
mark1145
55dc4a7da5
fix: Fixes casting by sending ParalyzeFlag to client while animating (#1397) 2023-04-27 23:12:07 -07:00
Kamron Batman
41ccc51caa
fix: Fixes death strike never ending (#1386) 2023-04-05 08:58:28 -07:00
Kamron Batman
3097eb4fa7
fix: Fixes Dice Infinite loop and deserialization of some items (#1360)
### Summary
- Fixes deserialization issues with some items.
- Changes Utility.Dice to prevent long iteration by passing `(uint)-1`
2023-03-05 18:29:48 -08:00
Kamron Batman
d14e864c85
fix: Updates disguises and codegens tinkering items (#1353) 2023-02-25 12:01:06 -08:00
Kamron Batman
42012538bc
fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
Kamron Batman
43d33759df
fix: Fixes travel restriction messages (#1302) 2022-12-13 16:47:04 -08:00
Kamron Batman
b1cfb10ef8
fix: Removes duplicate stat offsets (#1293) 2022-12-04 14:23:02 -08:00
Kamron Batman
bd1db66858
fix: Fixes stat offset effects (#1292) 2022-12-04 14:20:17 -08:00
Kamron Batman
284186359d
fix: Fixes buff icons for confidence, honorable excution, and divine fury (#1291) 2022-12-04 13:52:44 -08:00
Kamron Batman
1745faa28c
fix: Fixes divine fury (#1290) 2022-12-04 12:39:30 -08:00
Fabrizio
537526a328
fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
Kamron Batman
0facd73842
fix: Fixes travel issues (#1285) 2022-11-28 17:36:00 -08:00
Kamron Batman
1d8e8ec0a8
fix: Fixes travel restriction messages (#1263)
- [X] `BaseRegion.CheckTravel` now properly cascades through parent regions
- [X] `SpellHelper.CheckTravel` now returns a failure message instead of sending one internally.
- [X] Consolidates travel restriction messages so they aren't duplicated.
2022-11-22 16:57:42 -08:00
Kamron Batman
8e01db8555
fix: Fixes random bias & Adds back champion arties for UOML (#1235)
* Fixes RNG bias, we should never do `Utility.RandomDouble() <=`
* Adds back champion artifacts behind UOML flag.
2022-11-09 16:33:27 -08:00
Kamron Batman
59dcd24bed
fix: Fixes DeltaQueue recursion, StatMod bug, and memory leak (#1233)
* Fixes recursion with DeltaQueue causing multiple sets of packets to be sent to the client.
* Fixes StatMods that are expired not being checked properly.
* Adds a timer to properly expire/remove stat mods instead of relying on a side-effect.
2022-11-08 09:08:05 -08:00
Kamron Batman
fd6f4239e2
fix: Adds FindItemOnLayer generic (#1223) 2022-11-01 00:49:20 -07:00
mark1145
053dbcbad0
fix: Fixes ignoring mobs, champions, party crash, slayer rarity, boat speedhack, etc (#1222)
* Movie ignore mobiles to Mobile class
* Allow necromancer familiars to ignore mobiles
* ChampionSpawn should not quietly fail when creating new spawn
* Fix client party crash bug: 2 people partied, the leader logs out, other client is hung
* Fix spellbooks creating with magery/meditation only and creating magery multiple times
* Fix BaseRunicTool.GetRandomSlayer() creating more undead slayers than intended
* Do not allow players to dismount each other whilst mounted
* Fix AOS onwards damage increase tooltip and wrong formula in AOS
* Fix monsters killing other monster revenants + animate dead should not attack player pets + other animates
* Fix fire steed having loot pack added twice
* Fix oaks spawn not able to create Unicorns + Kirins via Activator.CreateInstace() due to constructor having name as parametr
* Fix ignoreMobiles flag not propagated to client for non-players.
* Fix harrower tents not leeching from players
* Fix boats speedhacking around the map
* Fix bless, agility etc. not renewing duration
* Fix reveal always worked
* Fix empty constructor for steeds so they don't throw now.
2022-10-31 22:16:50 -07:00
Kamron Batman
910e06767b
fix: Optimizes TextDefinition to eliminate allocations. Removes TextDefinition ctor. (#1221)
### BREAKING CHANGE ###
The constructor for `TextDefinition` has been removed. Instead use `TextDefinition.Of()` or cast the integer/string to TextDefinition.
2022-10-30 16:53:23 -07:00
Kamron Batman
d791feb583
feat: Adds TextDefinition serialization support. (#1217) 2022-10-30 01:42:48 -07:00
Kamron Batman
ffdc08259f
fix: Adds name support for all mods (#1128) 2022-10-15 10:46:31 -07:00
Kamron Batman
e1e30998ba
fix: Adds ReadType/Write(Type) and improves type referencing (#1172)
## Changes
* Improves type hashing by introducing xxHash3 (64bit)
* Removes individual `tdb` files in favor of a single `SerializedTypes.db` file. This file is only used to identify a type that is being deserialized, which doesn't exist.
* Adds duplicate type alias detection
* Adds `AssemblyHandler.FindTypeByHash`

View changed files whitespaces: https://github.com/modernuo/ModernUO/pull/1172/files?diff=split&w=1

## SerializedTypes.db
The serialized types file is used to get back the original name of a type in case it no longer exists in code. This can easily be necessary if a class is renamed in code and no `TypeAlias` is provided.

### Format
byte[4] - version
byte[4] - count
--array--
byte[8] - xxHash
byte[1] - flag, 0 - null, 1 - not null
byte[n] - Full class name in UTF8

### Example
<img width="472" alt="SerializedTypes_Example" src="https://user-images.githubusercontent.com/3953314/195255429-31d24293-6bd1-419e-811b-07874dd0f78d.png">

## Benchmarks
Serialized 500 Type fields. The 8192bytes comes from the _ConcurrentQueue_ that would later be used for SerializedTypes.
Note that the queue is never cleared, so it's size grew considerably.
```cs
|               Method |     Mean |    Error |   StdDev | Allocated |
|--------------------- |---------:|---------:|---------:|----------:|
|      BenchmarkXXHash | 18.44 us | 0.278 us | 0.260 us |    8192 B |
| BenchmarkTypeStrings | 25.09 us | 0.292 us | 0.259 us |         - |
```

TODO:
* Add support in the Serialization Generator for `ReadType()` and `Write(Type)`
* Remove `SetTypeRef` from Serialization Generator
2022-10-11 22:17:22 -07:00
Kamron Batman
0138d40bda
fix: Fixes cast delay issue being 0 (#1186) 2022-10-10 13:30:41 -07:00
Kamron Batman
43e7fe29c2
feat: Adds Monster Abilities (#1179)
* Adds ability to create monster abilities
* Adds Fire/Cold/Chaos Breath
* Adds Grasping Claw
* Adds Summon Skeletons & Summon Undead w/ Polymorph
2022-10-01 21:09:36 -07:00
Kamron Batman
8a2c0ead3d
fix: Fixes cast spell speeds for various expansions (#1178)
* Adds 0.25s for all spells for SA+ Era
* Fixes Summon Creature & Blade Spirits cast delay
* Fixes minimum cast delay for chivalry spells
* Fixes poison strike and wither spells
2022-10-01 12:25:40 -07:00
mark1145
060edaa76a
fix: Fixes disarm, strangle, curse, summons, looting rights, creatures attacking, and items going to the floor (#1174)
* Fixes disarm
* Fixes strangle not refreshing
* Fixes curse not refreshing
* Fixes 125% bonus to looting rights
* Fixes mobs attacking each other, or not attacking each other
* Fixes items dropping to the floor
* Fixes protection spell
* Fixes cure sending wrong message
2022-09-27 22:19:15 -07:00
mark1145
1e50ff9966
fix: Blood Oath, Wraith form, & Strangle (#1153)
Fixes blood oath mechanic, and wraith form not properly leeching.
2022-09-01 09:19:40 -07:00
Kamron Batman
c5d2a58917
fix: Fixes the number of rounds for Strangle (#1151) 2022-08-28 06:19:49 -07:00
mark1145
42f2c7f6ae
* After casting a spell, the player was always faced south (#1148) 2022-08-26 17:49:39 -07:00
mark1145
23ae7a3c26
fix: Players casting is sometimes not disturbed (#1138) 2022-08-16 22:17:39 -07:00
Kamron Batman
03f0605a0a
fix: Adds Cleansing Winds Spell (#1126) 2022-07-17 07:49:55 -07:00
Kamron Batman
84f1084e44
fix: Fixes stoneform spell (#1125) 2022-07-17 07:40:43 -07:00
Kamron Batman
fbf60b65a5
fix: Updates mysticism spells and adds bombard (#1124) 2022-07-17 00:04:41 -07:00
Kamron Batman
54da2c94a5
fix: Updates Mysticism to use circles (#1123) 2022-07-16 23:25:48 -07:00
Kamron Batman
c5d1927df3
fix: Cleans up more spells (#1122) 2022-07-16 23:15:45 -07:00