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;
}
```
This commit is contained in:
Kamron Batman 2021-01-25 21:06:46 -08:00 committed by GitHub
parent 07751654b7
commit 6f0e1a22f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 763 additions and 449 deletions

View file

@ -283,9 +283,6 @@ namespace Server.Network
m.NetState?.Dispose();
// TODO: Make this wait one tick so we don't have to call it unnecessarily
NetState.ProcessDisposedQueue();
state.SendClientVersionRequest();
state.BlockAllPackets = true;
@ -395,8 +392,8 @@ namespace Server.Network
if (
!m_AuthIDWindow.TryGetValue(authID, out var ap) ||
state.m_AuthID != 0 && authID != state.m_AuthID ||
state.m_AuthID == 0 && authID != state.m_Seed
state._authId != 0 && authID != state._authId ||
state._authId == 0 && authID != state._seed
)
{
state.WriteConsole("Invalid client detected, disconnecting");
@ -445,19 +442,19 @@ namespace Server.Network
{
var si = info[index];
state.m_AuthID = GenerateAuthID(state);
state._authId = GenerateAuthID(state);
state.SentFirstPacket = false;
state.SendPlayServerAck(si, state.m_AuthID);
state.SendPlayServerAck(si, state._authId);
}
}
public static void LoginServerSeed(NetState state, CircularBufferReader reader, ref int packetLength)
{
state.m_Seed = reader.ReadInt32();
state._seed = reader.ReadInt32();
state.Seeded = true;
if (state.m_Seed == 0)
if (state._seed == 0)
{
state.WriteConsole("Invalid client detected, disconnecting");
state.Dispose();