2023-10-16 09:50:49 +00:00
|
|
|
|
using AscNet.Common.Database;
|
|
|
|
|
using AscNet.Common.MsgPack;
|
2023-11-13 12:10:02 +00:00
|
|
|
|
using AscNet.Table.share.fuben;
|
2023-11-12 01:58:59 +00:00
|
|
|
|
using AscNet.Table.share.guide;
|
2023-10-14 16:13:29 +00:00
|
|
|
|
using MessagePack;
|
2023-10-11 13:20:26 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2023-10-10 09:56:08 +00:00
|
|
|
|
|
|
|
|
|
namespace AscNet.GameServer.Handlers
|
|
|
|
|
{
|
|
|
|
|
internal class AccountModule
|
|
|
|
|
{
|
2023-10-14 13:00:56 +00:00
|
|
|
|
[RequestPacketHandler("HandshakeRequest")]
|
|
|
|
|
public static void HandshakeRequestHandler(Session session, Packet.Request packet)
|
2023-10-10 09:56:08 +00:00
|
|
|
|
{
|
2023-10-11 21:15:35 +00:00
|
|
|
|
// TODO: make this somehow universal, look into better architecture to handle packets
|
|
|
|
|
// and automatically log their deserialized form
|
2023-10-14 15:05:58 +00:00
|
|
|
|
|
2023-10-10 09:56:08 +00:00
|
|
|
|
HandshakeResponse response = new()
|
|
|
|
|
{
|
|
|
|
|
Code = 0,
|
|
|
|
|
UtcOpenTime = 0,
|
|
|
|
|
Sha1Table = null
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-14 13:00:56 +00:00
|
|
|
|
session.SendResponse(response, packet.Id);
|
2023-10-10 09:56:08 +00:00
|
|
|
|
}
|
2023-10-10 13:59:08 +00:00
|
|
|
|
|
2023-10-14 13:00:56 +00:00
|
|
|
|
[RequestPacketHandler("LoginRequest")]
|
|
|
|
|
public static void LoginRequestHandler(Session session, Packet.Request packet)
|
2023-10-10 13:59:08 +00:00
|
|
|
|
{
|
2023-10-16 09:50:49 +00:00
|
|
|
|
LoginRequest request = MessagePackSerializer.Deserialize<LoginRequest>(packet.Content);
|
|
|
|
|
Player? player = Player.FromToken(request.Token);
|
|
|
|
|
|
|
|
|
|
if (player is null)
|
|
|
|
|
{
|
|
|
|
|
session.SendResponse(new LoginResponse
|
|
|
|
|
{
|
|
|
|
|
Code = 1007 // LoginInvalidLoginToken
|
|
|
|
|
}, packet.Id);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-16 09:53:53 +00:00
|
|
|
|
session.player = player;
|
2023-10-19 07:07:48 +00:00
|
|
|
|
session.character = Character.FromUid(player.PlayerData.Id);
|
|
|
|
|
session.stage = Stage.FromUid(player.PlayerData.Id);
|
2023-10-10 13:59:08 +00:00
|
|
|
|
session.SendResponse(new LoginResponse
|
|
|
|
|
{
|
|
|
|
|
Code = 0,
|
2023-10-16 09:50:49 +00:00
|
|
|
|
ReconnectToken = player.Token,
|
2023-10-10 13:59:08 +00:00
|
|
|
|
UtcOffset = 0,
|
2023-10-14 13:00:56 +00:00
|
|
|
|
UtcServerTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
|
|
|
|
|
}, packet.Id);
|
2023-10-10 18:22:41 +00:00
|
|
|
|
|
2023-10-11 18:32:25 +00:00
|
|
|
|
DoLogin(session);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-14 18:01:21 +00:00
|
|
|
|
[RequestPacketHandler("ReconnectRequest")]
|
|
|
|
|
public static void ReconnectRequestHandler(Session session, Packet.Request packet)
|
|
|
|
|
{
|
2023-10-16 09:50:49 +00:00
|
|
|
|
ReconnectRequest request = MessagePackSerializer.Deserialize<ReconnectRequest>(packet.Content);
|
2023-10-19 07:07:48 +00:00
|
|
|
|
Player? player;
|
|
|
|
|
if (session.player is not null)
|
|
|
|
|
player = session.player;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
player = Player.FromToken(request.Token);
|
|
|
|
|
if (player is not null && (session.character is null || session.stage is null))
|
|
|
|
|
{
|
|
|
|
|
session.character = Character.FromUid(player.PlayerData.Id);
|
|
|
|
|
session.stage = Stage.FromUid(player.PlayerData.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-16 09:50:49 +00:00
|
|
|
|
|
|
|
|
|
if (player?.PlayerData.Id != request.PlayerId)
|
|
|
|
|
{
|
|
|
|
|
session.SendResponse(new ReconnectResponse()
|
|
|
|
|
{
|
|
|
|
|
Code = 1029 // ReconnectInvalidToken
|
|
|
|
|
}, packet.Id);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-16 09:53:53 +00:00
|
|
|
|
session.player = player;
|
2023-10-14 18:01:21 +00:00
|
|
|
|
session.SendResponse(new ReconnectResponse()
|
|
|
|
|
{
|
2023-10-16 09:50:49 +00:00
|
|
|
|
ReconnectToken = request.Token
|
2023-10-14 18:01:21 +00:00
|
|
|
|
}, packet.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* TODO
|
|
|
|
|
[RequestPacketHandler("ReconnectAck")]
|
|
|
|
|
public static void ReconnectAckHandler(Session session, Packet.Request packet)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2023-10-11 21:15:35 +00:00
|
|
|
|
// TODO: Move somewhere else, also split.
|
2023-10-11 18:32:25 +00:00
|
|
|
|
static void DoLogin(Session session)
|
|
|
|
|
{
|
2023-10-19 07:07:48 +00:00
|
|
|
|
NotifyLogin notifyLogin = new()
|
|
|
|
|
{
|
|
|
|
|
PlayerData = session.player.PlayerData,
|
|
|
|
|
TeamGroupData = session.player.TeamGroups,
|
|
|
|
|
BaseEquipLoginData = new(),
|
|
|
|
|
FubenData = new()
|
|
|
|
|
{
|
2023-11-13 12:10:02 +00:00
|
|
|
|
StageData = session.stage.Stages.ToDictionary(x => x.Key, x => x.Value),
|
2023-10-19 07:07:48 +00:00
|
|
|
|
FubenBaseData = new()
|
|
|
|
|
},
|
|
|
|
|
FubenMainLineData = new(),
|
|
|
|
|
FubenChapterExtraLoginData = new(),
|
|
|
|
|
FubenUrgentEventData = new(),
|
|
|
|
|
UseBackgroundId = 14000001 // main ui theme, table still failed to dump
|
|
|
|
|
};
|
2023-11-12 06:00:44 +00:00
|
|
|
|
if (notifyLogin.PlayerData.DisplayCharIdList.Count < 1)
|
|
|
|
|
notifyLogin.PlayerData.DisplayCharIdList.Add(notifyLogin.PlayerData.DisplayCharId);
|
2023-10-19 07:07:48 +00:00
|
|
|
|
notifyLogin.FashionList.AddRange(session.character.Fashions);
|
2023-11-12 01:58:59 +00:00
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
notifyLogin.PlayerData.GuideData = GuideGroupTableReader.Instance.All.Select(x => (long)x.Id).ToList();
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-10-19 07:07:48 +00:00
|
|
|
|
NotifyCharacterDataList notifyCharacterData = new();
|
|
|
|
|
notifyCharacterData.CharacterDataList.AddRange(session.character.Characters);
|
|
|
|
|
|
|
|
|
|
NotifyEquipDataList notifyEquipData = new();
|
|
|
|
|
notifyEquipData.EquipDataList.AddRange(session.character.Equips);
|
2023-11-12 01:58:59 +00:00
|
|
|
|
|
|
|
|
|
NotifyAssistData notifyAssistData = new()
|
|
|
|
|
{
|
|
|
|
|
AssistData = new()
|
|
|
|
|
{
|
|
|
|
|
AssistCharacterId = session.character.Characters.First().Id
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-14 15:05:58 +00:00
|
|
|
|
session.SendPush(notifyLogin);
|
2023-10-19 07:07:48 +00:00
|
|
|
|
session.SendPush(notifyCharacterData);
|
|
|
|
|
session.SendPush(notifyEquipData);
|
2023-11-12 01:58:59 +00:00
|
|
|
|
session.SendPush(notifyAssistData);
|
2023-10-14 17:16:45 +00:00
|
|
|
|
|
2023-11-11 11:08:20 +00:00
|
|
|
|
// NEEDED to not softlock!
|
|
|
|
|
session.SendPush(new NotifyFubenPrequelData() { FubenPrequelData = new() });
|
|
|
|
|
session.SendPush(new NotifyPrequelChallengeRefreshTime() { NextRefreshTime = (uint)DateTimeOffset.Now.ToUnixTimeSeconds() + 3600 * 24 });
|
|
|
|
|
session.SendPush(new NotifyMainLineActivity() { EndTime = 0 });
|
|
|
|
|
session.SendPush(new NotifyDailyFubenLoginData() { RefreshTime = (uint)DateTimeOffset.Now.ToUnixTimeSeconds() + 3600 * 24 });
|
|
|
|
|
session.SendPush(new NotifyBriefStoryData());
|
|
|
|
|
session.SendPush(new NotifyFubenBossSingleData()
|
|
|
|
|
{
|
|
|
|
|
FubenBossSingleData = new()
|
|
|
|
|
{
|
|
|
|
|
ActivityNo = 1,
|
|
|
|
|
TotalScore = 0,
|
|
|
|
|
MaxScore = 0,
|
|
|
|
|
OldLevelType = 0,
|
|
|
|
|
LevelType = 1,
|
|
|
|
|
ChallengeCount = 0,
|
|
|
|
|
RemainTime = 100000,
|
|
|
|
|
AutoFightCount = 0,
|
|
|
|
|
CharacterPoints = new {},
|
|
|
|
|
RankPlatform = 0
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
session.SendPush(new NotifyBfrtData() { BfrtData = new() });
|
2023-10-10 13:59:08 +00:00
|
|
|
|
}
|
2023-10-10 09:56:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|