초기커밋

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,79 @@
using ServerCommon;
using ServerCore; using ServerBase;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GameServer
{
internal class BuildingUpdateTicker : EntityTicker
{
public BuildingUpdateTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.BuildingUpdateTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
var result = new Result();
var err_msg = string.Empty;
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var server_config = server_logic.getServerConfig();
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
var modify_floor_linked_infos = new List<ModifyFloorLinkedInfo>();
var building_manager = server_logic.getBuildingManager();
var rental_finish_building_floors = building_manager.checkRentalFinish();
foreach (var (land_meta_id, building_meta_id, floor) in rental_finish_building_floors)
{
result = building_manager.tryRemoveBuildingFloor(building_meta_id, floor);
if (result.isFail())
continue;
if (!MapManager.Instance.tryRemoveRoomMapTree(building_meta_id, floor, out var removed_room_map_tree))
continue;
var ugc_npc_guids = removed_room_map_tree.UgcNpcs;
if (ugc_npc_guids.Count < 1)
continue;
var modify_floor_linked_info = MapHelper.makeModifyFloorLinkedInfo(ModifyType.Delete, land_meta_id, building_meta_id, floor, ugc_npc_guids);
modify_floor_linked_infos.Add(modify_floor_linked_info);
}
MapNotifyHelper.broadcast_S2C_NTF_MODIFY_FLOOR_LINKED_INFOS(modify_floor_linked_infos);
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
await Task.CompletedTask;
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}
}

View File

@@ -0,0 +1,94 @@
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DocumentModel;
using Amazon.DynamoDBv2.Model;
using ServerCore;
using ServerBase;
using ServerCommon;
namespace GameServer;
public class CaliumEventTicker : EntityTicker
{
private DynamoDbClient? m_dynamoDb_client { get; set; } = null;
public CaliumEventTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.CaliumEventTicker, onTickIntervalMilliseconds, cts)
{
var server_logic = GameServerApp.getServerLogic();
m_dynamoDb_client = server_logic.getDynamoDbClient();
}
public override async Task onTaskTick()
{
NullReferenceCheckHelper.throwIfNull(m_dynamoDb_client, () => $"dynamodb client is null !!! ");
var calium_storage_entity = GameServerApp.getServerLogic().findGlobalEntity<CaliumStorageEntity>();
NullReferenceCheckHelper.throwIfNull(calium_storage_entity, () => "calium storage entity is null !!!");
var calium_event_action = calium_storage_entity.getEntityAction<CaliumEventAction>();
NullReferenceCheckHelper.throwIfNull(calium_event_action, () => $"calium_event_action is null !!! - {calium_storage_entity.toBasicString()}");
// 1. doc 가져오기
var search = await searchDocuments();
foreach (var doc in search.list)
{
var (result, change_doc) = await calium_event_action.updateCaliumEventStatus(doc, CaliumEventStatus.Regist, CaliumEventStatus.Sending);
if (result.isFail() || null == change_doc) continue;
// 2. 재전송 처리
_ = await sendCaliumEventAsync(change_doc);
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
private async Task<Result> sendCaliumEventAsync(CaliumEventDoc sendDoc)
{
var server_logic = GameServerApp.getServerLogic();
var calium_event_entity = server_logic.findGlobalEntity<CaliumStorageEntity>();
NullReferenceCheckHelper.throwIfNull(calium_event_entity, () => "calium_event_entity is null !!!");
var calium_event_action = calium_event_entity.getEntityAction<CaliumEventAction>();
NullReferenceCheckHelper.throwIfNull(calium_event_action, () => $"calium_event_action is null !!! - {calium_event_entity.toBasicString()}");
var result = await calium_event_action.sendCaliumEventFromDB(sendDoc);
return result;
}
private async Task<(Result result, List<CaliumEventDoc> list)> searchDocuments()
{
NullReferenceCheckHelper.throwIfNull(m_dynamoDb_client, () => $"dynamodb client is null !!! ");
var query_config = new QueryOperationConfig();
query_config.Filter.AddCondition(PrimaryKey.PK_Define, QueryOperator.Equal, CaliumEventDoc.pk);
query_config.Limit = 10;
query_config.FilterExpression = new Expression
{
ExpressionStatement = "CaliumEventAttrib.#status = :statusValue",
ExpressionAttributeNames = new Dictionary<string, string>
{
{ "#status", "status" }
},
ExpressionAttributeValues = new Dictionary<string, DynamoDBEntry>
{
{ ":statusValue", CaliumEventStatus.Regist.ToString() }
}
};
var list = await m_dynamoDb_client.simpleQueryDocTypesWithQueryOperationConfig<CaliumEventDoc>(query_config);
return list;
}
}

View File

@@ -0,0 +1,43 @@

using ServerCore;
using ServerBase;
using ServerCommon;
namespace GameServer;
public class CaliumStorageRetryTicker : EntityTicker
{
public CaliumStorageRetryTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.CaliumEventTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
var calium_storage_entity = GameServerApp.getServerLogic().findGlobalEntity<CaliumStorageEntity>();
NullReferenceCheckHelper.throwIfNull(calium_storage_entity, () => "calium storage entity is null !!!");
var calium_storage_action = calium_storage_entity.getEntityAction<CaliumStorageAction>();
NullReferenceCheckHelper.throwIfNull(calium_storage_action, () => $"calium_storage_action is null !!! - {calium_storage_entity.toBasicString()}");
// 1. Redis Retry Key 조회
var check_retry = await calium_storage_action.checkRetryCaliumEchoSystem();
if (false == check_retry) return;
// 2. Retry 실시
await calium_storage_action.onFillUpDailyCalium();
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}

View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using ServerCore; using ServerBase;
using ServerCommon;
namespace GameServer
{
public class ChannelUpdateTicker : EntityTicker
{
public ChannelUpdateTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.ChannelUpdateTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
NullReferenceCheckHelper.throwIfNull(server_logic, () => $"server_logic is null !!!");
var server_config = server_logic.getServerConfig();
NullReferenceCheckHelper.throwIfNull(server_config, () => $"server_config is null !!!");
if(true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
await GameServerApp.getServerLogic().getChannelManager().updateChannels();
if(null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}
}

View File

@@ -0,0 +1,171 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServerCore; using ServerBase;
using ServerCommon;
using META_ID = System.UInt32;
using GameServer.PacketHandler;
using System.Diagnostics;
using ServerCommon.BusinessLogDomain;
using Microsoft.Extensions.Logging;
namespace GameServer
{
public class EntityUpdateTicker : EntityTicker
{
public EntityUpdateTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.EntityUpdateTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
var result = new Result();
var err_msg = string.Empty;
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var server_config = server_logic.getServerConfig();
var seasonPassManager = server_logic.getSeasonPassManager();
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
(bool isUpdateNewSeasonPass, META_ID new_season_pass_id) = seasonPassManager.updateNewSeason();
var ticker_stopwatch = Stopwatch.StartNew();
foreach (var each in server_logic.getPlayerManager().getUsers())
{
// TODO : 여기서 유저 주요 테스크를 처리 한다.
var user = each.Value;
var user_create_or_load_action = user.getEntityAction<UserCreateOrLoadAction>();
NullReferenceCheckHelper.throwIfNull(user_create_or_load_action, () => $"user_create_or_load_action is null !!! - {user.toBasicString()}");
if (false == user_create_or_load_action.isCompletedLoadUser())
{
continue;
}
ticker_stopwatch.Restart();
var buff_action = user.getEntityAction<BuffAction>();
NullReferenceCheckHelper.throwIfNull(buff_action, () => $"buff_action is null !!! - {user.toBasicString()}");
await buff_action.onTick();
stopWatchTickerCheck(ticker_stopwatch, "buff_action");
if (isUpdateNewSeasonPass == true)
{
var season_pass_action = user.getEntityAction<SeasonPassAction>();
NullReferenceCheckHelper.throwIfNull(season_pass_action, () => $"season_pass_action is null !!! - {user.toBasicString()}");
if (new_season_pass_id != 0)
{
await season_pass_action.StartNewSeasonPass(new_season_pass_id);
}
else
{
user.send_S2C_NTF_SEASON_PASS_INFOS();
}
}
stopWatchTickerCheck(ticker_stopwatch, "season_pass_action");
var ai_chat_action = user.getEntityAction<AIChatAction>();
NullReferenceCheckHelper.throwIfNull(ai_chat_action, () => $"ai_chat_action is null !!! - {user.toBasicString()}");
if (server_logic.getServerConfig().OfflineMode == false)
{
await ai_chat_action.updateTickOfIncentivePoint();
}
stopWatchTickerCheck(ticker_stopwatch, "ai_chat_action");
var task_reservation_action = user.getEntityAction<TaskReservationAction>();
NullReferenceCheckHelper.throwIfNull(task_reservation_action, () => $"task_reservation_action is null !!! - {user.toBasicString()}");
await task_reservation_action.UpdateTick();
stopWatchTickerCheck(ticker_stopwatch, "task_reservation_action");
var package_action = user.getEntityAction<PackageAction>();
NullReferenceCheckHelper.throwIfNull(package_action, () => $"package_action is null !!! - {user.toBasicString()}");
await package_action.UpdateTick();
stopWatchTickerCheck(ticker_stopwatch, "package_action");
var rental_agent_action = user.getEntityAction<RentalAgentAction>();
NullReferenceCheckHelper.throwIfNull(rental_agent_action, () => $"rental_agent_action is null !!! - {user.toBasicString()}");
await rental_agent_action.onTick();
stopWatchTickerCheck(ticker_stopwatch, "rental_agent_action");
var user_inventory_action = user.getEntityAction<UserInventoryAction>();
NullReferenceCheckHelper.throwIfNull(user_inventory_action, () => $"user_inventory_action is null !!! - {user.toBasicString()}");
await user_inventory_action.onTick();
stopWatchTickerCheck(ticker_stopwatch, "user_inventory_action");
/*
var fn_entity_update = async delegate ()
{
await Task.CompletedTask;
var result = new Result();
// TODO HERE : 유저가 처리해야 하는 Update 함수를 추가 한다.
return result;
};
result = await user.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "EntityUpdateTicker", fn_entity_update );
if(result.isFail())
{
err_msg = $"Failed to runTransactionRunnerSafely() on EntityUpdateTicker !!!"
+ $" : {result.toBasicString()} - {user.toBasicString()}";
//Log.getLogger().error(err_msg);
}
*/
}
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
private void stopWatchTickerCheck(Stopwatch ticker_stopwatch, string action)
{
var elapsed_msec = ticker_stopwatch.ElapsedMilliseconds;
if (elapsed_msec > 300)
{
Log.getLogger().error($"Ticker Stopwatch Stop. Action : {action}, ElapsedMSec:{elapsed_msec}");
}
ticker_stopwatch.Stop();
ticker_stopwatch.Restart();
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServerCore; using ServerBase;
using ServerCommon;
using System.Diagnostics;
namespace GameServer
{
public class EventUpdateTicker : EntityTicker
{
public EventUpdateTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.EventUpdateTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
// TODO HERE : 처리해야 하는 Update 함수를 추가 한다.
var result = new Result();
var err_msg = string.Empty;
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var server_config = server_logic.getServerConfig();
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
// TODO HERE : 처리해야 하는 Update 함수를 추가 한다.
(var deletables, var currents) = EventManager.It.claimEventActiveCheckAndGet();
foreach (var each in server_logic.getPlayerManager().getUsers())
{
// TODO : 여기서 유저 주요 테스크를 처리 한다.
var user = each.Value;
var user_create_or_load_action = user.getEntityAction<UserCreateOrLoadAction>();
NullReferenceCheckHelper.throwIfNull(user_create_or_load_action, () => $"user_create_or_load_action is null !!! - {user.toBasicString()}");
if (false == user_create_or_load_action.isCompletedLoadUser())
{
continue;
}
// ClaimEvent 신규, 삭졔 체크
if (deletables.Count > 0 || currents.Count > 0)
{
await EventManager.It.playerClaimUpdateAndNoti(user, deletables, currents);
}
}
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using ServerCore; using ServerBase;
using ServerCommon;
using META_ID = System.UInt32;
namespace GameServer
{
public class LandAuctionCheckTicker : EntityTicker
{
public LandAuctionCheckTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.LandAuctionCheckTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
var result = new Result();
var err_msg = string.Empty;
var call_tid = System.Guid.NewGuid().ToString("N");
var log_msg = $"Call LandAuctionCheckTicker.onTaskTick() !!! - TID:{call_tid}";
Log.getLogger().debug(log_msg);
var server_logic = GameServerApp.getServerLogic();
var server_config = server_logic.getServerConfig();
var requestor_id = server_logic.getServerName();
var land_auction_manager = LandAuctionManager.It;
result = await land_auction_manager.tryActivitingLandAuctions(requestor_id, new List<META_ID>(), call_tid);
if(result.isFail())
{
err_msg = $"Failed to tryActivitingLandAuctions() !!!, in onTaskTick() : {result.toBasicString()} - {toBasicString()}";
Log.getLogger().error(err_msg);
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}
}

View File

@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using ServerCore; using ServerBase;
using ServerCommon;
using META_ID = System.UInt32;
namespace GameServer
{
public class LandAuctionReservationConfigureTicker : EntityTicker
{
public LandAuctionReservationConfigureTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.LandAuctionReservationConfigureTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var server_config = server_logic.getServerConfig();
var result = new Result();
var err_msg = string.Empty;
var call_tid = System.Guid.NewGuid().ToString("N");
var log_msg = $"Call LandAuctionReservationConfigureTicker.onTaskTick() !!! - TID:{call_tid}";
Log.getLogger().debug(log_msg);
var requestor_id = server_logic.getServerName();
var land_auction_manager = LandAuctionManager.It;
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
result = await land_auction_manager.tryConfigureAndAddReservedLandAuctioKeyAll(requestor_id);
if(result.isFail())
{
err_msg = $"Failed to tryConfigureAndAddReservedLandAuctioKeyAll() !!!, in onTaskTick() : {result.toBasicString()} - requestorId:{requestor_id}, {toBasicString()}";
Log.getLogger().error(err_msg);
}
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
if(1000 <= elapsed_msec)
{
Log.getLogger().debug( $"{this.getTypeName()} Performance alert !!! : Execution delayed !!!"
+ $" - ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}" );
}
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}
}

View File

@@ -0,0 +1,253 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServerCore; using ServerBase;
using ServerCommon;
namespace GameServer;
public class NormalQuestCheckTicker : EntityTicker
{
public NormalQuestCheckTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.NormalQuestCheckTicker, onTickIntervalMilliseconds, cts)
{
}
public async Task onTaskTick_old()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
ArgumentNullException.ThrowIfNull(server_logic);
var server_config = server_logic.getServerConfig();
ArgumentNullException.ThrowIfNull(server_config);
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
//여기에 Transaction 걸기
await QuestManager.It.questTimerEventCheck();
await QuestManager.It.questNormalActiveCheck();
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override async Task onTaskTick()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
ArgumentNullException.ThrowIfNull(server_logic);
var server_config = server_logic.getServerConfig();
ArgumentNullException.ThrowIfNull(server_config);
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
//await QuestManager.It.questTimerEventCheck(); 의 대안
var timer_check_user = QuestManager.It.getTimerCheckUser();
List<string> delete_checker = new();
ArgumentNullException.ThrowIfNull(timer_check_user, $"timer_check_user is null !!!");
var player_manager = server_logic.getPlayerManager();
ArgumentNullException.ThrowIfNull(player_manager, $"player_manager is null !!!");
foreach (string user_guid in timer_check_user)
{
if (false == player_manager.tryGetUserByPrimaryKey(user_guid, out var player))
{
delete_checker.Add(user_guid);
continue;
}
var user_create_or_load_action = player.getEntityAction<UserCreateOrLoadAction>();
ArgumentNullException.ThrowIfNull(user_create_or_load_action,
$"user_create_or_load_action is null !!! - {player.toBasicString()}");
if (false == user_create_or_load_action.isCompletedLoadUser())
{
continue;
}
var fn_transaction_runner = async delegate()
{
var result = await QuestManager.It.QuestCheckWithoutTransaction(player, new QuestTimer(EQuestEventTargetType.TIMER, EQuestEventNameType.ENDED));
ArgumentNullException.ThrowIfNull(result, $"result is null !!!");
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.QuestTaskUpdate, server_logic.getDynamoDbClient());
{
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
}
result = await QueryHelper.sendQueryAndBusinessLog(batch);
if (result.isFail())
{
var err_msg = $"Failed to sendQueryAndBusinessLog() !!! : {result.toBasicString()} - {player.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
return result;
};
var result = await player.runTransactionRunnerSafelyWithTransGuid(player.getUserGuid(), TransactionIdType.PrivateContents, "QuestTimerCheckTick", fn_transaction_runner);
if (result.isFail())
{
var err_msg = $"Failed to runTransactionRunnerSafelyWithTransGuid() !!! : {result.toBasicString()} - {player.toBasicString()}";
Log.getLogger().error(err_msg);
}
}
QuestManager.It.deleteTimerCheckUser(delete_checker);
//questNormalActiveCheck() 의 대안
delete_checker = new();
DateTime now_dt = DateTimeHelper.Current;
foreach (var user_guid in QuestManager.It.m_normal_quest_check_users.Keys)
{
if (false == player_manager.tryGetUserByPrimaryKey(user_guid, out var player))
{
delete_checker.Add(user_guid);
continue;
}
var user_create_or_load_action = player.getEntityAction<UserCreateOrLoadAction>();
ArgumentNullException.ThrowIfNull(user_create_or_load_action,
$"user_create_or_load_action is null !!! - {player.toBasicString()}");
if (false == user_create_or_load_action.isCompletedLoadUser())
{
continue;
}
var fn_transaction_runner = async delegate()
{
var repeat_quest_attribute = player.getEntityAttribute<RepeatQuestAttribute>();
NullReferenceCheckHelper.throwIfNull(repeat_quest_attribute, () => $"repeat_quest_attribute is null !!!");
if (repeat_quest_attribute.m_is_checking == 0) return new();
if (now_dt < repeat_quest_attribute.m_next_allocate_time) return new();
//플레이어 정보는 퀘스트 메일 보내기 전에 로드 된다. 메일이 로드 안되어 있으면 리턴 할수 있도록 처리 해줘야된다.
var quest_mail_action = player.getEntityAction<QuestMailAction>();
if (false == quest_mail_action.isMailLoadedAll()) return new();
HashSet<UInt32> my_current_normal_mail_set = await quest_mail_action.getNormalMailSet();
int normal_mail_count = my_current_normal_mail_set.Count;
HashSet<UInt32> assignable_mail_set = await QuestManager.It.getAssignableMailSet(player, my_current_normal_mail_set);
//체크 대상이라 여기 들어왔는데 메일이 넘치면 미체크 대상으로 처리
if (MetaHelper.GameConfigMeta.MaxQuestSendMail <= normal_mail_count || assignable_mail_set.Count == 0)
{
QuestManager.It.m_normal_quest_check_users.TryRemove(player.getUserGuid(), out _);
return new();
}
//여기까지 왔으면 메일 보낼게 있다는 얘기이므로 전송한다.
var assignable_quest_id = QuestManager.It.getAssignableQuestMailId(assignable_mail_set);
ArgumentNullException.ThrowIfNull(assignable_quest_id, $"assignable_quest_id is null !!!");
//여기서 normalMailSet + 1 의 개수가 최대 개수를 넘으면 비활성화 처리
var check_value = QuestManager.It.questCheckUserAssignableQuestMaxCheck(player, my_current_normal_mail_set);
ArgumentNullException.ThrowIfNull(check_value, $"check_value is null !!!");
(var result, var quest_mail, var quest_mail_log_invoker) = await quest_mail_action.sendQuestMail(assignable_quest_id);
if (result.isFail())
{
return result;
}
repeat_quest_attribute.m_next_allocate_time = repeat_quest_attribute.m_next_allocate_time.AddMinutes(MetaHelper.GameConfigMeta.CooltimeNormalQuestSendMail);
if (false == check_value)
{
repeat_quest_attribute.m_is_checking = 0;
}
repeat_quest_attribute.modifiedEntityAttribute();
var server_logic = GameServerApp.getServerLogic();
ArgumentNullException.ThrowIfNull(server_logic, $"server_logic is null !!!");
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.QuestMailSend, server_logic.getDynamoDbClient());
{
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
}
batch.appendBusinessLog(new RepeatQuestBusinessLog(repeat_quest_attribute.m_next_allocate_time, repeat_quest_attribute.m_is_checking));
batch.appendBusinessLog(quest_mail_log_invoker);
result = await QueryHelper.sendQueryAndBusinessLog(batch);
if (result.isFail())
{
var err_msg = $"Failed to sendQueryAndBusinessLog() !!! : {result.toBasicString()} - {player.toBasicString()}";
Log.getLogger().error(err_msg);
return result;
}
await quest_mail_action.addNewQuestMails(new List<ServerCommon.QuestMail>() { quest_mail });
await quest_mail_action.send_NTF_RECEIVED_QUEST_MAIL(player, new List<UInt32>() { assignable_quest_id });
await QuestManager.It.QuestCheckWithoutTransaction(player, new QuestMail(EQuestEventTargetType.MAIL, EQuestEventNameType.RECEIVED, ""));
return result;
};
var result = await player.runTransactionRunnerSafelyWithTransGuid(player.getUserGuid(), TransactionIdType.PrivateContents, "mailAndUpdateRepeatQuestInfo", fn_transaction_runner);
if (result.isFail())
{
var err_msg = $"Failed to runTransactionRunnerSafelyWithTransGuid() !!! : {result.toBasicString()} - {player.toBasicString()}";
Log.getLogger().error(err_msg);
continue;
}
}
foreach (var delete_user in delete_checker)
{
QuestManager.It.m_normal_quest_check_users.TryRemove(delete_user, out _);
Log.getLogger()
.debug($"setNormalMailTimer m_normal_quest_check_users remove accountId : {delete_user}");
}
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServerCore; using ServerBase;
using ServerCommon;
namespace GameServer
{
public class NoticeChatTicker : EntityTicker
{
public NoticeChatTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.NoticeChatTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
ArgumentNullException.ThrowIfNull(server_logic);
var server_config = server_logic.getServerConfig();
ArgumentNullException.ThrowIfNull(server_config);
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
await GameServerApp.getServerLogic().getNoticeChatManager().UpdateChat();
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}
}

View File

@@ -0,0 +1,80 @@
using System.Diagnostics;
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using MetaAssets;
namespace GameServer;
public class PartyCacheRefreshTicker : EntityTicker
{
public PartyCacheRefreshTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.PartyCacheRefreshTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
ArgumentNullException.ThrowIfNull(server_logic);
var server_config = server_logic.getServerConfig();
ArgumentNullException.ThrowIfNull(server_config);
foreach (var each in server_logic.getPlayerManager().getUsers())
{
var user = each.Value;
var user_create_or_load_action = user.getEntityAction<UserCreateOrLoadAction>();
ArgumentNullException.ThrowIfNull(user_create_or_load_action, $"user_create_or_load_action is null !!! - {user.toBasicString()}");
if (false == user_create_or_load_action.isCompletedLoadUser())
{
continue;
}
var party_action = user.getEntityAction<PersonalPartyAction>();
ArgumentNullException.ThrowIfNull(party_action);
if (party_action.isParty())
{
var result = await party_action.runPartyTick();
if(result.isFail())
{
var err_msg = $"Failed to runPartyTick() !!! : {result.toBasicString()} - {user.toBasicString()}";
Log.getLogger().error(err_msg);
}
}
await Task.Delay(10); // 레디스 IO 오버헤드 감경 !!!
}
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}

View File

@@ -0,0 +1,55 @@
using System.Diagnostics;
using ServerCore;
using ServerBase;
using ServerCommon;
namespace GameServer;
public class ReservationCheckTicker : EntityTicker
{
public ReservationCheckTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts) : base(
EntityType.ReservationCheckTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var server_config = server_logic.getServerConfig();
var reservation_count = server_logic.getReservationManager().getReservedUserCount();
if (reservation_count <= 0) return;
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
await server_logic.getReservationManager().checkLimitReservedUsers();
await server_logic.getReturnManager().checkLimitReturnUsers();
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}

View File

@@ -0,0 +1,132 @@
using System.Diagnostics;
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using MetaAssets;
namespace GameServer;
public class ShopProductCheckTicker : EntityTicker
{
private Dictionary<int, Timestamp?> m_shop { get; set; } = new();
public ShopProductCheckTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.ShopProductCheckTicker, onTickIntervalMilliseconds, cts)
{
foreach (var shop in ShopHelper.getShopMetaData())
{
var end_time = ShopHelper.calculateSaleEndTime(shop.ResetTime);
m_shop.Add(shop.Id, end_time);
}
}
public override async Task onTaskTick()
{
await Task.CompletedTask;
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var server_config = server_logic.getServerConfig();
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
// 1. reset 상점 ids list 조회
var reset_shop_ids = checkShopEndTime();
if (!reset_shop_ids.Any()) return;
// 2. 유저의 상점 정보 체크
foreach (var each in server_logic.getPlayerManager().getUsers())
{
var player = each.Value;
var user_create_or_load_action = player.getEntityAction<UserCreateOrLoadAction>();
if (false == user_create_or_load_action.isCompletedLoadUser())
{
continue;
}
checkShopReset(player, reset_shop_ids.ToList());
}
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
private IEnumerable<int> checkShopEndTime()
{
var list = new List<int>(m_shop.Count);
foreach (var shop in m_shop)
{
if (shop.Value == null) continue;
if (shop.Value > DateTime.UtcNow.ToTimestamp()) continue;
var new_end_time = newEndTime(shop.Key);
if (new_end_time == null) continue;
m_shop[shop.Key] = new_end_time;
list.Add(shop.Key);
}
return list;
}
private static Timestamp? newEndTime(int shop_id)
{
var shop_table = ShopHelper.checkShopIdFromTableData(shop_id);
if (shop_table.result.isFail() || shop_table.shop_data == null) return null;
return ShopHelper.calculateSaleEndTime(shop_table.shop_data.ResetTime);
}
private static void checkShopReset(Player player, IReadOnlyList<int> shop_ids)
{
var server_logic = GameServerApp.getServerLogic();
var shop_action = player.getEntityAction<ShopAction>();
var message = new ClientToGame();
message.Message = new();
message.Message.NtfShopProductChange = new();
foreach (var shop in shop_action.getMyShopProducts())
{
var attribute = shop.getEntityAttribute<ShopProductTradingMeterAttribute>();
NullReferenceCheckHelper.throwIfNull(attribute, () => $"attribute is null !!!");
if (!shop_ids.Contains(attribute.ShopId)) continue;
message.Message.NtfShopProductChange.ShopId = attribute.ShopId;
server_logic.onSendPacket(player, message);
}
}
}

View File

@@ -0,0 +1,52 @@
using System.Diagnostics;
using ServerCommon;
using ServerCore; using ServerBase;
namespace GameServer;
public class SystemMailCheckTicker : EntityTicker
{
public SystemMailCheckTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.SystemMailCheckTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var server_config = server_logic.getServerConfig();
if (true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
await server_logic.getSystemMailManager().refreshDB();
//await server_logic.getSystemMailManager().notifyNewSystemMail();
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using ServerCore;
using ServerBase;
using ServerCommon;
namespace GameServer;
public class UserLoginCacheRefreshTicker : EntityTicker
{
public UserLoginCacheRefreshTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.UserLoginCacheRefreshTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
var server_config = server_logic.getServerConfig();
var result = new Result();
var err_msg = string.Empty;
var proud_net_listener = server_logic.getProudNetListener();
NullReferenceCheckHelper.throwIfNull(proud_net_listener, () => $"proud_net_listener is null !!! - {server_logic.toBasicString()}");
foreach (var each in proud_net_listener.getEntityWithSessions())
{
var user = each.Value as Player;
NullReferenceCheckHelper.throwIfNull(user, () => $"user is null !!!");
var game_login_action = user.getEntityAction<GameLoginAction>();
NullReferenceCheckHelper.throwIfNull(game_login_action, () => $"game_login_action is null !!! - {user.toBasicString()}");
result = await game_login_action.onRefreshUserLoginCache();
if(result.isFail())
{
err_msg = $"Failed to onRefreshUserLoginCache() !!! : {result.toBasicString()} - {user.toBasicString()}";
Log.getLogger().error(err_msg);
}
await Task.Delay(10); // 레디스 IO 오버헤드 감경 !!!
}
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
}
}
public override string toBasicString()
{
return $"{this.getTypeName()}";
}
public override string toSummaryString()
{
return $"{this.getTypeName()}";
}
}