forked from PGR/ascnet
1
0
Fork 0

disables guide on debug build + finishable stage

This commit is contained in:
rfi 2023-11-12 08:58:59 +07:00
parent ebc9883918
commit 2fda778dfc
4 changed files with 86 additions and 40 deletions

View File

@ -1,5 +1,6 @@
using AscNet.Common.Database;
using AscNet.Common.MsgPack;
using AscNet.Table.share.guide;
using MessagePack;
using Newtonsoft.Json;
@ -112,15 +113,29 @@ namespace AscNet.GameServer.Handlers
};
notifyLogin.FashionList.AddRange(session.character.Fashions);
#if DEBUG
// Per account settings flag(?)
notifyLogin.PlayerData.GuideData = GuideGroupTableReader.Instance.All.Select(x => (long)x.Id).ToList();
#endif
NotifyCharacterDataList notifyCharacterData = new();
notifyCharacterData.CharacterDataList.AddRange(session.character.Characters);
NotifyEquipDataList notifyEquipData = new();
notifyEquipData.EquipDataList.AddRange(session.character.Equips);
NotifyAssistData notifyAssistData = new()
{
AssistData = new()
{
AssistCharacterId = session.character.Characters.First().Id
}
};
session.SendPush(notifyLogin);
session.SendPush(notifyCharacterData);
session.SendPush(notifyEquipData);
session.SendPush(notifyAssistData);
// NEEDED to not softlock!
session.SendPush(new NotifyFubenPrequelData() { FubenPrequelData = new() });

File diff suppressed because one or more lines are too long

View File

@ -35,14 +35,17 @@ namespace AscNet.GameServer
public async void ClientLoop()
{
NetworkStream stream = client.GetStream();
int prevBuf = 0;
byte[] msg = new byte[1 << 16];
while (client.Connected)
{
try
{
if (prevBuf == 0)
Array.Clear(msg, 0, msg.Length);
int len = stream.Read(msg, 0, msg.Length);
int len = stream.Read(msg, prevBuf + 0, msg.Length - prevBuf);
len += prevBuf;
if (len > 0)
{
@ -54,10 +57,18 @@ namespace AscNet.GameServer
{
int packetLen = BinaryPrimitives.ReadInt32LittleEndian(msg.AsSpan()[readbytes..]);
readbytes += 4;
if (packetLen < 4)
if (packetLen < 1)
{
break;
}
else if (packetLen > len)
{
prevBuf += len;
break;
}
else
{
prevBuf = 0;
byte[] packet = GC.AllocateUninitializedArray<byte>(packetLen);
Array.Copy(msg, readbytes, packet, 0, packetLen);
readbytes += packetLen;
@ -69,6 +80,8 @@ namespace AscNet.GameServer
}
catch (Exception)
{
log.Debug(BitConverter.ToString(msg).Replace("-", ""));
log.Debug($"PacketLen = {packetLen}, ReadLen = {len}");
log.Error("Failed to deserialize packet: " + BitConverter.ToString(packet).Replace("-", ""));
}
}
@ -205,7 +218,7 @@ namespace AscNet.GameServer
return;
// DB save on disconnect
log.Info($"saving session state...");
log.Info($"Saving session state...");
player?.Save();
character?.Save();
stage?.Save();

File diff suppressed because one or more lines are too long