초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,114 @@
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using MetaAssets;
namespace GameServer.PacketHandler;
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.InvitePartySendListReq), typeof(InvitePartySendListPacketHandler), typeof(GameLoginListener))]
public class InvitePartySendListPacketHandler : PacketRecvHandler
{
private static void send_S2C_ACK_INVITE_PARTY_SEND_LIST(Player owner, Result result, IReadOnlyList<InvitePartySendState>? invites)
{
var ack_packet = new ClientToGame
{
Response = new ClientToGameRes
{
ErrorCode = result.ErrorCode,
InvitePartySendListRes = new()
}
};
if (result.isSuccess() && null != invites)
{
ack_packet.Response.InvitePartySendListRes.InvitePartySendList.AddRange(invites);
}
GameServerApp.getServerLogic().onSendPacket(owner, ack_packet);
}
public override async Task<Result> onProcessPacket(ISession entityWithSession, IMessage recvMessage)
{
var result = new Result();
string err_msg;
var entity_player = entityWithSession as Player;
NullReferenceCheckHelper.throwIfNull(entity_player, () => "player is null !!!");
// 1. 기본 정보 체크
var request = (recvMessage as ClientToGame)?.Request.InvitePartySendListReq;
if (null == request)
{
err_msg = $"Failed to get request type !!! : {nameof(ClientToGame.Request.InvitePartySendListReq)}";
result.setFail(ServerErrorCode.InvalidArgument, err_msg);
Log.getLogger().error(result.toBasicString());
send_S2C_ACK_INVITE_PARTY_SEND_LIST(entity_player, result, null);
return result;
}
// 2. 소속 파티 Guid 조회
var personal_party_action = entity_player.getEntityAction<PersonalPartyAction>();
NullReferenceCheckHelper.throwIfNull(personal_party_action, () => $"personal party action is null !!! - {entity_player.toBasicString()}");
var personal_party = personal_party_action.getPersonalParty();
if (null == personal_party)
{
err_msg = $"Failed to get party info !!! - not party member - {entity_player.getUserGuid()}";
result.setFail(ServerErrorCode.NotParty, err_msg);
Log.getLogger().error(err_msg);
send_S2C_ACK_INVITE_PARTY_SEND_LIST(entity_player, result, null);
return result;
}
var global_party = GameServerApp.getServerLogic().findGlobalEntity<GlobalParty>();
NullReferenceCheckHelper.throwIfNull(global_party, () => "global party is null !!!");
var party = global_party.getParty(personal_party.getPartyGuid());
NullReferenceCheckHelper.throwIfNull(party, () => "global party detail is null !!!");
// 3. 파티장 체크
var party_action = party.getEntityAction<GlobalPartyDetailAction>();
NullReferenceCheckHelper.throwIfNull(party_action, () => $"party detail action is null !!! - {entity_player.toBasicString()} / {party.toBasicString()}");
var is_leader = party_action.isLeader(entity_player.getUserGuid());
if (!is_leader)
{
err_msg = $"Failed to summon party member !!! : not party leader - {entity_player.getUserGuid()}";
result.setFail(ServerErrorCode.NotPartyLeader, err_msg);
Log.getLogger().error(err_msg);
send_S2C_ACK_INVITE_PARTY_SEND_LIST(entity_player, result, null);
return result;
}
// 4. invite send list 획득
var party_invite_send_action = party.getEntityAction<GlobalPartyInvitePartySendAction>();
NullReferenceCheckHelper.throwIfNull(party_invite_send_action, () => $"GlobalPartyInvitePartySendAction is null !!! - {entity_player.toBasicString()} / {party.toBasicString()}");
var sends = await party_invite_send_action.getPartyInvitePartySends();
var invites = new List<InvitePartySendState>();
foreach (var send in sends)
{
var nickname = await PartyHelper.getUserNicknameFromGuid(send.Key);
var invite = new InvitePartySendState();
invite.InviteUserNickname = nickname ?? string.Empty;
invite.InviteUserGuid = send.Key;
invite.EndTime = Timestamp.FromDateTime(send.Value);
invites.Add(invite);
}
send_S2C_ACK_INVITE_PARTY_SEND_LIST(entity_player, result, invites);
return result;
}
}