초기커밋

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,105 @@
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using static ClientToGameReq.Types;
using static ClientToGameRes.Types;
using META_ID = System.UInt32;
namespace GameServer.PacketHandler;
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_BEACON_SHOP_SEARCH_ITEM), typeof(BeaconShopSearchItemPacketHandler), typeof(GameLoginListener))]
public class BeaconShopSearchItemPacketHandler : PacketRecvHandler
{
public static bool send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(Player player, Result result, List<BeaconShopMongoDoc>? beaconShopMongoDocs)
{
var ack_packet = new ClientToGame();
ack_packet.Response = new ClientToGameRes();
ack_packet.Response.ErrorCode = result.ErrorCode;
ack_packet.Response.AckBeaconShopSearchItem = new GS2C_ACK_BEACON_SHOP_SEARCH_ITEM();
if (result.isSuccess() && beaconShopMongoDocs != null)
{
ack_packet.Response.AckBeaconShopSearchItem.BeaconShopItemBoardInfos.AddRange(beaconShopMongoDocs.Select<BeaconShopMongoDoc, BeaconShopItemBoardInfo>(x => x.toBeaconShopItemMongoDataClient()).ToList());
}
if (false == GameServerApp.getServerLogic().onSendPacket(player, ack_packet))
{
return false;
}
return true;
}
public override async Task<Result> onProcessPacket(ISession entityWithSession, IMessage recvMessage)
{
var result = new Result();
var err_msg = string.Empty;
var entity_player = entityWithSession as Player;
NullReferenceCheckHelper.throwIfNull(entity_player, () => $"entity_player is null !!!" );
var beacon_shop_action = entity_player.getEntityAction<BeaconShopAction>();
if (beacon_shop_action == null)
{
err_msg = $"Failed to get beacon shop action : {nameof(BeaconShopAction)}";
result.setFail(ServerErrorCode.EntityActionNotFound, err_msg);
Log.getLogger().error(err_msg);
send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(entity_player, result, null);
return result;
}
var game_msg = recvMessage as ClientToGame;
if (game_msg == null)
{
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.ReqBeaconShopSearchItem)}";
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
Log.getLogger().error(result.toBasicString());
send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(entity_player, result, null);
return result;
}
var request = game_msg.Request.ReqBeaconShopSearchItem;
if (request.ItemMetaid == 0)
{
err_msg = $"Invalid Request Argument !!! : ItemMetaid : {request.ItemMetaid}";
result.setFail(ServerErrorCode.BeaconShopInvalidArgument, err_msg);
Log.getLogger().error(result.toBasicString());
send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(entity_player, result, null);
return result;
}
result = await beacon_shop_action.BeaconShopSearchItem((META_ID)request.ItemMetaid);
if (result.isFail())
{
send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(entity_player, result, null);
return result;
}
return result;
}
public override async Task onProcessPacketException(ISession entityWithSession, IMessage recvMessage
, Result errorResult)
{
await Task.CompletedTask;
var player = entityWithSession as Player;
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!! - {entityWithSession.toBasicString()}");
send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(player, errorResult, null);
}
}