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.Database;
using AscNet.Common.MsgPack; using AscNet.Common.MsgPack;
using AscNet.Table.share.guide;
using MessagePack; using MessagePack;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -111,16 +112,30 @@ namespace AscNet.GameServer.Handlers
UseBackgroundId = 14000001 // main ui theme, table still failed to dump UseBackgroundId = 14000001 // main ui theme, table still failed to dump
}; };
notifyLogin.FashionList.AddRange(session.character.Fashions); 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(); NotifyCharacterDataList notifyCharacterData = new();
notifyCharacterData.CharacterDataList.AddRange(session.character.Characters); notifyCharacterData.CharacterDataList.AddRange(session.character.Characters);
NotifyEquipDataList notifyEquipData = new(); NotifyEquipDataList notifyEquipData = new();
notifyEquipData.EquipDataList.AddRange(session.character.Equips); notifyEquipData.EquipDataList.AddRange(session.character.Equips);
NotifyAssistData notifyAssistData = new()
{
AssistData = new()
{
AssistCharacterId = session.character.Characters.First().Id
}
};
session.SendPush(notifyLogin); session.SendPush(notifyLogin);
session.SendPush(notifyCharacterData); session.SendPush(notifyCharacterData);
session.SendPush(notifyEquipData); session.SendPush(notifyEquipData);
session.SendPush(notifyAssistData);
// NEEDED to not softlock! // NEEDED to not softlock!
session.SendPush(new NotifyFubenPrequelData() { FubenPrequelData = new() }); 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() public async void ClientLoop()
{ {
NetworkStream stream = client.GetStream(); NetworkStream stream = client.GetStream();
int prevBuf = 0;
byte[] msg = new byte[1 << 16]; byte[] msg = new byte[1 << 16];
while (client.Connected) while (client.Connected)
{ {
try try
{ {
Array.Clear(msg, 0, msg.Length); if (prevBuf == 0)
int len = stream.Read(msg, 0, msg.Length); Array.Clear(msg, 0, msg.Length);
int len = stream.Read(msg, prevBuf + 0, msg.Length - prevBuf);
len += prevBuf;
if (len > 0) if (len > 0)
{ {
@ -54,10 +57,18 @@ namespace AscNet.GameServer
{ {
int packetLen = BinaryPrimitives.ReadInt32LittleEndian(msg.AsSpan()[readbytes..]); int packetLen = BinaryPrimitives.ReadInt32LittleEndian(msg.AsSpan()[readbytes..]);
readbytes += 4; readbytes += 4;
if (packetLen < 4) if (packetLen < 1)
{
break; break;
}
else if (packetLen > len)
{
prevBuf += len;
break;
}
else else
{ {
prevBuf = 0;
byte[] packet = GC.AllocateUninitializedArray<byte>(packetLen); byte[] packet = GC.AllocateUninitializedArray<byte>(packetLen);
Array.Copy(msg, readbytes, packet, 0, packetLen); Array.Copy(msg, readbytes, packet, 0, packetLen);
readbytes += packetLen; readbytes += packetLen;
@ -69,6 +80,8 @@ namespace AscNet.GameServer
} }
catch (Exception) catch (Exception)
{ {
log.Debug(BitConverter.ToString(msg).Replace("-", ""));
log.Debug($"PacketLen = {packetLen}, ReadLen = {len}");
log.Error("Failed to deserialize packet: " + BitConverter.ToString(packet).Replace("-", "")); log.Error("Failed to deserialize packet: " + BitConverter.ToString(packet).Replace("-", ""));
} }
} }
@ -205,7 +218,7 @@ namespace AscNet.GameServer
return; return;
// DB save on disconnect // DB save on disconnect
log.Info($"saving session state..."); log.Info($"Saving session state...");
player?.Save(); player?.Save();
character?.Save(); character?.Save();
stage?.Save(); stage?.Save();

File diff suppressed because one or more lines are too long