67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using Google.Protobuf;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
using ServerCommon;
|
|
using ServerCommon.BusinessLogDomain;
|
|
using MetaAssets;
|
|
|
|
|
|
using USER_GUID = System.String;
|
|
|
|
namespace GameServer;
|
|
|
|
public class ReservationManager : ReservationManagerBase
|
|
{
|
|
public ReservationManager()
|
|
{
|
|
base.onInit(GameServerApp.getServerLogic());
|
|
}
|
|
|
|
protected override async Task<bool> checkReservationCondition(ServerMoveType moveType, USER_GUID reservationUserGuid)
|
|
{
|
|
// 1. server block 체크
|
|
var block_enable = GameServerApp.getServerLogic().getAccountLoginBlockEnable();
|
|
if (true == block_enable.Value)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// 2. 기존 예약 유저 체크
|
|
if (m_reservation_user_manager.checkReserved(reservationUserGuid))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// 3. return user 체크
|
|
if (GameServerApp.getServerLogic().getReturnManager().isReturnUser(reservationUserGuid))
|
|
return true;
|
|
|
|
// 4. free count 체크 ( 리턴으로 인한 예약이면 return_count 에 포함되는 인원임 )
|
|
var free_count = await checkFreeSessionCount();
|
|
|
|
// 5. Force 이동 체크
|
|
if (moveType == ServerMoveType.Force && free_count >= 1)
|
|
return true;
|
|
|
|
// 6. 입장 허용치 계산
|
|
return calculateConnectionRate(free_count);
|
|
}
|
|
|
|
protected override async Task<int> checkFreeSessionCount()
|
|
{
|
|
await Task.CompletedTask;
|
|
|
|
var server_logic = GameServerApp.getServerLogic();
|
|
var pround_net_listener = server_logic.getProudNetListener();
|
|
var max_connection_count = pround_net_listener.getMaxConnectionCount();
|
|
|
|
// 잔여 공간 계산 : MaxCount - ( 유저 Connection 수 + 입장 예약자 수 + 리턴 예약자 수 + 비컨 설치 수 )
|
|
var delete_count = pround_net_listener.getEntityWithSessions().Count + m_reservation_user_manager.Count + server_logic.getReturnManager().getReturnUserCount() + UgcNpcCountManager.Instance.calculateNpcCount();
|
|
var free_count = max_connection_count - delete_count;
|
|
|
|
return free_count;
|
|
}
|
|
} |