2024-08-23 21:40:08 -04:00
|
|
|
using Arrowgene.Ddon.Database.Model;
|
2022-01-18 11:04:07 +08:00
|
|
|
using Arrowgene.Ddon.Server;
|
2022-01-18 15:28:26 +08:00
|
|
|
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
|
|
|
|
|
using Arrowgene.Ddon.Shared.Model;
|
2022-01-10 15:47:42 +08:00
|
|
|
using Arrowgene.Logging;
|
2024-08-23 21:40:08 -04:00
|
|
|
using System;
|
2022-01-10 15:47:42 +08:00
|
|
|
|
|
|
|
|
namespace Arrowgene.Ddon.GameServer.Handler
|
|
|
|
|
{
|
2024-08-18 01:29:28 +02:00
|
|
|
public class ConnectionMoveInServerHandler : GameRequestPacketHandler<C2SConnectionMoveInServerReq, S2CConnectionMoveInServerRes>
|
2022-01-10 15:47:42 +08:00
|
|
|
{
|
2022-01-18 11:04:07 +08:00
|
|
|
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(ConnectionMoveInServerHandler));
|
2022-01-10 15:47:42 +08:00
|
|
|
|
|
|
|
|
public ConnectionMoveInServerHandler(DdonGameServer server) : base(server)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-18 01:29:28 +02:00
|
|
|
public override S2CConnectionMoveInServerRes Handle(GameClient client, C2SConnectionMoveInServerReq request)
|
2022-01-10 15:47:42 +08:00
|
|
|
{
|
2024-08-18 01:29:28 +02:00
|
|
|
Logger.Debug(client, $"Received SessionKey:{request.SessionKey}");
|
|
|
|
|
GameToken token = Database.SelectToken(request.SessionKey);
|
2022-01-18 15:28:26 +08:00
|
|
|
if (token == null)
|
|
|
|
|
{
|
2024-08-18 01:29:28 +02:00
|
|
|
Logger.Error(client, $"SessionKey:{request.SessionKey} not found");
|
2022-01-18 15:28:26 +08:00
|
|
|
// TODO reply error
|
|
|
|
|
// return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Database.DeleteTokenByAccountId(token.AccountId);
|
|
|
|
|
|
|
|
|
|
Account account = Database.SelectAccountById(token.AccountId);
|
|
|
|
|
if (account == null)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error(client, $"AccountId:{token.AccountId} not found");
|
2024-08-18 01:29:28 +02:00
|
|
|
throw new ResponseErrorException(ErrorCode.ERROR_CODE_FAIL);
|
2022-01-18 15:28:26 +08:00
|
|
|
}
|
2024-08-18 01:29:28 +02:00
|
|
|
client.Account = account;
|
2022-01-18 15:28:26 +08:00
|
|
|
|
2026-04-30 21:28:52 -07:00
|
|
|
#if DEBUG
|
|
|
|
|
if (client.Identity.Contains("127.0.0.1"))
|
|
|
|
|
{
|
|
|
|
|
client.Account.State = AccountStateType.GameMaster;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-08-18 01:29:28 +02:00
|
|
|
Character character = Server.CharacterManager.SelectCharacter(client, token.CharacterId);
|
2022-01-18 15:28:26 +08:00
|
|
|
if (character == null)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error(client, $"CharacterId:{token.CharacterId} not found");
|
2024-08-18 01:29:28 +02:00
|
|
|
throw new ResponseErrorException(ErrorCode.ERROR_CODE_CHARACTER_DATA_INVALID_CHARACTER_ID);
|
2023-04-30 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
2022-01-18 15:28:26 +08:00
|
|
|
Logger.Info(client, "Moved Into GameServer");
|
|
|
|
|
|
|
|
|
|
|
2022-01-13 13:21:04 +08:00
|
|
|
// NTC
|
2022-03-05 23:17:11 +01:00
|
|
|
client.Send(new S2CItemExtendItemSlotNtc());
|
2022-01-18 15:28:26 +08:00
|
|
|
// client.Send(GameFull.Dump_5);
|
|
|
|
|
// client.Send(GameFull.Dump_6);
|
2022-01-13 13:21:04 +08:00
|
|
|
|
2024-08-23 21:40:08 -04:00
|
|
|
ulong now = (ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
|
|
|
|
foreach (var (id, course) in Server.AssetRepository.GPCourseInfoAsset.ValidCourses)
|
2024-08-18 01:29:28 +02:00
|
|
|
{
|
2024-08-23 21:40:08 -04:00
|
|
|
if (now >= course.StartTime && now <= course.EndTime)
|
2024-08-18 01:29:28 +02:00
|
|
|
{
|
2024-08-23 21:40:08 -04:00
|
|
|
S2CGPCourseExtendNtc courseExtendNtc = new S2CGPCourseExtendNtc()
|
|
|
|
|
{
|
|
|
|
|
CourseID = course.Id,
|
|
|
|
|
ExpiryTimestamp = course.EndTime
|
|
|
|
|
};
|
|
|
|
|
client.Send(courseExtendNtc);
|
|
|
|
|
}
|
2024-08-18 01:29:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new S2CConnectionMoveInServerRes();
|
2022-01-10 15:47:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|