Commit graph

238 commits

Author SHA1 Message Date
Kamron Batman
bd87035f12
fix(core): Fixes ability to delete object type if it deserialized improperly (#475) 2021-02-06 21:03:47 -08:00
Jabin
52df92c452
fix(core): Fixes SpanReader moving position before read (#468) 2021-02-05 23:45:44 -08:00
Kamron Batman
67625ad249
fix(core): Removes disposable netstates. (#467)
- [X] Removes IDisposable from NetState
- [X] Swaps Disconnect and Dispose methods
2021-02-05 14:33:35 -08:00
Kamron Batman
079eeb1b96
fix(core): Fixes nullables being disabled (#466) 2021-02-05 14:09:57 -08:00
Kamron Batman
657233b2eb
fix(core): Fix bad world save state (#462) 2021-02-05 01:14:50 -08:00
Kamron Batman
97aa092f17
fix(core): Removes refs for network stack (#461) 2021-02-05 01:11:13 -08:00
Jabin
6295699b3d
fix(network): Adds setting NetState.PacketEncoder only if not null (#460) 2021-02-04 17:07:41 -08:00
Kamron Batman
590c74a8fe
fix(core): Removes UOP file error message (#454) 2021-02-04 10:49:36 -08:00
Kamron Batman
50e9b367fc
fix(core): Fixes buy packet (#453)
- [X] Fixes buy packet
- [X] Changes from null to empty string in gump initial text
2021-02-04 10:40:41 -08:00
Kamron Batman
995149ad01
fix(core): Adds ability to store null value in ordered hash set (#447)
- [X] Adds the ability to store a null value in an ordered hash set

TODO:
Optimized the OrderedHashSet. See this:
* https://github.com/dotnet/runtime/issues/10050
Looks like the OrderedDictionary that I based this structure from was not updated.
See the source for diffing:
https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/HashSet.cs

Difference between a HashSet and an OrderedHashSet is updating the indexes of the entries after fixing the chain to preserve insertion order.
2021-02-03 17:57:03 -08:00
Kamron Batman
5d9ebf062f
core(fix): Fixes type aliasing, categorizations, and NPE (#444)
- [X] Fixes lookup of type aliases
- [X] Fixes categorization
- [X] Removes rebuild categorizations
- [X] Fixes an NPE with DoHarmful and Combatant

Closes #441
2021-02-03 16:14:04 -08:00
Kamron Batman
24ebdd0f90
fix(core): Fixes IPMatch and some cleanup (#443)
- [X] Fixes a bug where IPMatch was returning false on some IP ranges
- [X] Cleans up shrink table load.
2021-02-03 14:31:02 -08:00
Kamron Batman
c6e93a6814
fix(core): Fixes a few netstate issues (#436)
- [X] Fixes the order of disconnect/dispose
- [X] Removes IsDisposing
2021-02-01 20:37:51 -08:00
Kamron Batman
6f0e1a22f9
fix(core): Core cleanup, adds event loop synchronization, and fixes gumps (#429)
- [X] Cleans up gump packets
- [X] Adds event loop task synchronization
- [X] Moves timer pause and cleans up the delay task timer class
- [X] Cleans up the conserve cpu
- [X] Renames variables to make them consistent with the new style
- [X] Removes process delta recursion checking.
- [X] Properly diposes net states. This fixes edge cases that may cause hanging connections to stay open longer than they should.
- [X] Fixes an issue with gump items not compiling properly

Users can now utilize `Timer.Pause()` since the code will be executed on the proper thread.

```cs
public void async void Talk()
{
    _canTalk = false;
    await Timer.Pause(Utility.RandomMinMax(5000, 8000)); // Talk after 5-8 seconds
    DoTalk();
    await Timer.Pause(Utility.RandomMinMax(12000, 25000)); // Reset ability to talk after 12-25 seconds
    _canTalk = true;
}
```
2021-01-25 21:06:46 -08:00
Kamron Batman
07751654b7
fix(core): Moves map definitions and cleans up loading maps, regions, and tiles (#431)
- [X] Moves map definitions to a `map-definitions.json` file.
- [X] Creates a TileMatrixLoader.
- [X] Moves tile matrix and multi data configurations closer to their classes.
2021-01-25 11:05:52 -08:00
Kamron Batman
178f71c6dc
chore(content): Cleans up abilities and some spell timers (#427)
- [X] Exposes Index/Count on the timer.
- [X] Cleans up abilities
- [X] Combines some spell context/info objects with their timers to reduce allocations
- [X] Fixes a bug where immolating weapon both finishes effect or stops in the wrong order due to a race condition.
2021-01-23 16:40:53 -08:00
Kamron Batman
9ef7752beb
fix(core): Converts to ref struct enumerators (#426)
- [X] Converts boat moving entities to ref struct enumerator
- [X] Converts skills to a ref struct enumerator
- [X] Converts type cache to ref struct enumerator
2021-01-22 19:41:44 -08:00
Kamron Batman
c6ef6ff80a
fix(core): Fixes insensitive type lookup (#425) 2021-01-20 23:23:07 -08:00
Michael Whelehan
3cc09bf606
feat(mobile): Makes paralyze/freeze virtual (#423)
- [X] Makes paralyze/freeze virtual
2021-01-20 10:38:47 -08:00
Kamron Batman
e869c105d0
fix(core): Fixes type caching & cleanup (#422)
- [X] Fixes some issues with the type caching
- [X] Changes type check default to ignore case
- [X] Splits out type caching of insensitive and sensitive lists. This means less stuff to iterate through when checking a type against the string.
- [X] Adds an ArrayEnumerator, mostly for reference purposes (copy/paste as needed)
2021-01-20 00:10:33 -08:00
Kamron Batman
b921c38879
fix(core): Removes some uses of Linq (#421)
- [X] Removes some uses of linq
- [X] Creates struct based enumerator for Skills
- [X] Creates a struct based enumerator for TypeCache
- [X] Changes HarvestDefinition to an init array instead of List
- [X] Changes HeritageTokenGump Response from List to Array
2021-01-18 21:05:11 -08:00
Kamron Batman
cf22226382
fix(core): Adds back persistence. (#419)
- [X] Adds persistence back

Notes:
- Optimizations and parallel writing will not be supported in this PR.
2021-01-18 13:16:18 -08:00
Kamron Batman
87764ca968
fix(build): Attempt to fix possible nullable warnings as errors with releases (#418) 2021-01-18 11:52:31 -08:00
Kamron Batman
08f05afd01
fix(core): Converts boat packets (#416)
- [X] Converts boat packets
- [X] Makes a packet container builder for packet 0xF7
- [X] Generalizes world item packet so it works for mobiles too

Notes:
- This PR doesn't address proper smooth movement for boats.
2021-01-18 08:38:32 -08:00
Kamron Batman
fbafd7210d
fix(core): Converts some packets & misc fixes/cleanup (#414)
- [X] Adds a stop music packet
- [X] Converts chat packets
- [X] Breaks out chat code a little bit more
- [X] Converts character statue animation packet
- [X] Renames some folders to have spaces
- [X] Organizes and consolidates incoming/outgoing packets for other content
- [X] Fixes virtual checks
2021-01-16 21:01:54 -08:00
Kamron Batman
a146955f6c
fix(core): Converts book packets (#413)
- [X] Splits out BaseBook
- [X] Converts book packets
- [X] Makes FixHtml faster
2021-01-16 18:49:53 -08:00
Kamron Batman
97f311d7be
fix(core): Removes 6017 handler (#411)
- [X] Removes 6017 handler since it is only used in one place
- [X] Exposes a ref int to modify the packet length. This is acceptable since we technically have access to the entire reader/buffer.
2021-01-16 13:43:16 -08:00
Kamron Batman
c58aad733d
fix(core): Converts BB packets (#406)
- [X] Organizes and splits up bulletin boards
- [X] Converts packets
2021-01-13 22:28:31 -08:00
Kamron Batman
211c2ba8ee
fix(core): Streamlines text encoding (#407)
- [X] Streamlines text encoding
2021-01-13 18:56:32 -08:00
Kamron Batman
ca196e4729
fix(content): Converts mahjong packets (#402)
- [X] Converts mahjong packets
2021-01-12 00:59:42 -08:00
Kamron Batman
f4dd7c8e7f
fix(party): Converts party packets (#401)
- [X] Converts party packets
2021-01-10 14:23:10 -08:00
Kamron Batman
764d303543
chore: Code cleanup (#399)
- [X] Code cleanup
2021-01-10 09:14:03 -08:00
Kamron Batman
a6e1172f97
fix(docs): Removes docgen (#398)
- [X] Removes "docgen"
2021-01-09 20:12:08 -08:00
Kamron Batman
8763be8a21
fix(core): Cleans up uninitialized packets (#397)
- [X] Encapsulates/abstracts buffer cache checking
- [X] Changes mobile moving cache to use Span2D
2021-01-09 14:10:29 -08:00
Kamron Batman
0b9fb9c071
fix(core): Cleans up OPL code (#396)
- [X] Cleans up OPL code to simplify the calls
2021-01-09 11:56:05 -08:00
Kamron Batman
5882b1ab3f
fix(core): Fixes OPL packets (#395)
- [X] Fixes an issue with OPL packets using the wrong endianness and not updating the position properly.
- [X] Fixes an issue with SpanWriter not updating bytes written when it is used adhoc.
- [X] Moves packet creation for OPL inside the SendInfoTo function.

Bumps release version
2021-01-08 23:55:23 -08:00
Kamron Batman
1006352333
fix(core): Disables new movement and time sync (#391)
Bumps release version
2021-01-06 22:40:07 -08:00
Kamron Batman
dfe89024ca
Makes gump code a little more readable (#390)
- [X] Adds a WriteAscii for individual characters
- [X] Updates gump code to use it so it is a little more readable
2021-01-06 01:17:34 -08:00
Kamron Batman
03bdff2293
fix(content): Converts buff icon packets (#389)
- [X] Converts buff icon packets, and avoids string formatting.
2021-01-06 01:01:21 -08:00
Kamron Batman
0912876f7c
fix(core): Converts virtual hair packets (#388)
- [X] Converts virtual hair packets
2021-01-05 22:14:54 -08:00
Kamron Batman
30ef0761cb
chore(core): Cleans up networking leftovers from packet conversions (#387)
- [X] Removes span writing extensions
- [X] Removes span reading extensions
- [X] Cleans up OPL and uses uninitialized arrays

Bumps release version
2021-01-05 01:31:52 -08:00
Kamron Batman
a278623f38
fix(core): Converts Gump Packets (v1) (#379)
- [X] Converts gump packets
2021-01-05 01:17:34 -08:00
Kamron Batman
126b80f74b
fix(core): Cleans up networking (#386)
- [X] Deletes some unused networking code.
2021-01-05 00:41:22 -08:00
Kamron Batman
3dd0d8f42b
fix(core): Converts the rest of the packets (#385)
- [X] Converts vendor buy packets
- [X] Converts vendor sell packets
- [X] Converts target packets
- [X] Converts secure trade packets
- [X] Converts some player packets that were missed
2021-01-05 00:35:56 -08:00
Kamron Batman
ffc26459ff
fix(core): Converts message, mobile, movement, player packets (#384)
- [X] Converts message packets
- [X] Convers mobile packets
- [X] Converts movement packets
- [X] Converts player packets
2021-01-04 23:47:20 -08:00
Kamron Batman
353b46fbbd
fix(core): Converts more packets (#383)
- [X] Converts damage packets
- [X] Converts effect packets
- [X] Converts equipment packets
- [X] Converts gump packets
- [X] Converts light packets
- [X] Converts map packets
- [X] Converts menu packets
2021-01-04 23:11:43 -08:00
Kamron Batman
75c0527284
fix(core): Converts combat and container packets (#382)
- [X] Converts container packets
- [X] Converts combat packets
2021-01-04 21:17:39 -08:00
Kamron Batman
ac76c57c39
fix(core): Converts account packets to spanwriter (#381)
- [X] Converts account packets to spanwriter
2021-01-04 18:47:20 -08:00
Kamron Batman
3b413371dc
fix(core): Adds Gump component functionality (#377)
- [X] Adds gump close packet
- [X] Fixes gump tooltip
- [X] Adds new compile/append functions for the new gump packets
2021-01-02 19:08:35 -08:00
Kamron Batman
582e1877b8
feat(core): Makes spanwriter resizable (#376)
SpanWriter now has an argument that allows it to be resizable.
```cs
public SpanWriter(Span<byte> initialBuffer, bool resize = false)
public SpanWriter(int initialCapacity, bool resize = false)
```

If a SpanWriter is set to be resizable, or given an initial capacity instead of a buffer, it must be disposed:
```cs
public static void SomeMethod()
{
    using var writer = new SpanWriter(stackalloc byte[512], true);
    // stuff
    
    // Automatic Dispose of writer
}
```

This is because the SpanWriter uses `ArrayPool<byte>.Shared` _rented buffers_ to resize. If the writer is not disposed, those buffers will never be reused resulting in a _memory leak_.

It is possible that the SpanWriter will outright ditch the initial buffer if resize is set to true and growing is needed. To check/account for that we can do the following:

```cs
public static void SomeMethod()
{
    Span<byte> span = stackalloc byte[512];
    using var writer = new SpanWriter(span, true);
    // write some stuff that causes the span to grow
    
    span = writer.RawBuffer;
    // Do stuff with the span
}
```

Make sure you don't accidentally `Dispose()` the writer or use the `RawBuffer` outside of the `using` block. If you do, bad things will happen! (NullPointerException, or a fresh SpanWriter with no buffer, depending on the situation).

SpanWriter can also now be used with a fixed statement since it has a `PinnableReference()` function.
2020-12-31 19:57:02 -08:00