초기커밋

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,361 @@
using GameServer.Quest;
using Nettention.Proud;
using ServerCommon;
using ServerCore; using ServerBase;
using static ClientToGameMessage.Types;
using static ClientToGameReq.Types;
namespace GameServer
{
internal class AuthHandler
{
public AuthHandler()
{
}
// static public async Task ProcessRequestPacket(HostID remote, RmiContext rmictx, ClientToGameReq request)
// {
// // Log.getLogger().info($"[{Thread.CurrentThread.ManagedThreadId}] recved. {request.MsgCase}");
// #if SEQUENCE
// ServerLog.Sequence("GameClient", "GameServer", request.MsgCase.ToString());
// #endif
// using (var clientInfo = GameServer.Instance._srv.GetClientInfo(remote))
// {
// ClientSession? session = ClientSessionManager.Instance.GetSession(remote);
// if (session == null)
// {
// GameServer.Instance._srv.CloseConnection(remote);
// Log.getLogger().error($"Not found Session : {clientInfo.tcpAddrFromServer.IPToString()}");
// return;
// }
// await session._serializer.post(async () =>
// {
// if (session.IsClosedProcessed)
// {
// Log.getLogger().error($"{session.Id} Session is Closed : {remote}");
// return;
// }
// /* 패킷별로 시간을 나누어야 될듯
// DateTime curTime = DateTime.Now;
// TimeSpan diff = curTime - session.lastPacketReceivTime;
// if (diff <= TimeSpan.FromMilliseconds(50))
// {
// Log.getLogger().warn($"{session.Id} ClientIP:{clientInfo.tcpAddrFromServer.IPToString()}, {request}");
// }
//
// session.lastPacketReceivTime = curTime;
// */
// switch (request.MsgCase)
// {
// case ClientToGameReq.MsgOneofCase.LoginReq:
// await HandleLoginReq(session, rmictx, request.LoginReq);
// break;
// case ClientToGameReq.MsgOneofCase.LogoutReq:
// await HandleLogoutReq(session, request.LogoutReq);
// break;
// default:
// await session.ProcessRequestPacket(request);
// break;
// }
//
// });
// }
//
// }
// static async Task HandleLoginReq(ClientSession session, RmiContext rmiCtx, LoginReq loginReq)
// {
// ClientToGame clientToGame = new();
// clientToGame.Response = new();
// clientToGame.Response.LoginRes = new();
// try
// {
// Log.getLogger().debug($"{loginReq.Name} loginReq {loginReq} {rmiCtx.encryptMode}");
// // TODO: rmiCtx.encryptMode
// if ( rmiCtx.encryptMode != EncryptMode.EM_Fast)
// {
// //Log.getLogger().error($"{loginReq.Name} loginReq {loginReq} {rmiCtx.encryptMode}");
// // session.Close();;
// }
//
// var block_enable = GameServer.Instance.getUserLoginBlockEnable();
// if(true == block_enable.Value)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.AccountLoginBlockEnable;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().debug($"User login Block !!! : {loginReq.Name}");
// await session.Close();
// return;
// }
//
// if (AccountAuthorityManager.Instance.IsWhiteListUser(loginReq.Name) == false)
// {
// //점검중
// if (AccountAuthorityManager.Instance.isInspection == true ||
// AccountAuthorityManager.Instance.isReadyForDistroy == true)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.Inspection;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().debug($"Now Inspection : {loginReq.Name}");
// await session.Close();
// return;
// }
//
// if (AccountAuthorityManager.Instance.IsBlackListUser(loginReq.Name) == true)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.BlackList;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().debug($"BlackList User :{loginReq.Name}");
// await session.Close();
// return;
// }
// }
//
// var loginInfo = await GameServerApp.Instance.LoginStorage.GetLoginInfo(loginReq.Name);
//
// if (loginInfo == null || loginInfo.Moving == null)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.LoginFail;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().error($"Not found LoginInfo User:{loginReq.Name}");
// await session.Close();
// return;
// }
//
// string departureServer = loginInfo.CurrentServer;
//
// if (loginReq.Otp != loginInfo.Moving.OneTimeKey)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.InvalidToken;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().error($"{loginReq.Name} Not correct Token {loginReq.Otp} != {loginInfo.Moving.OneTimeKey}");
// await session.Close();
// return;
// }
//
// if (await GameServerApp.Instance.LoginStorage.EndMoving(loginReq.Name, DateTime.Now) == false)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.LoginFail;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().error($"EndMoving fail !!! {loginReq.Name}");
// await session.Close();
// return;
// }
//
// if (loginInfo.Moving.DestServer != GameServer.Instance.ServerName)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.LoginFail;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().error($"Not correct Server:{loginInfo.Moving.DestServer} cur:{GameServer.Instance.ServerName} LoginInfo User:{loginReq.Name}");
// await session.Close();
// return;
// }
//
// session.Id = loginInfo.Name;
// session.AccountGuid = loginInfo.Guid;
// session.Email = loginInfo.Email;
// session.PartyGuid = loginInfo.PartyGuid;
//
// if (await session.AutoSelectChar(loginInfo) == false)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.LoginFail;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().error("Select Character fail !!!", session.ToString());
// await session.Close();
// return;
// }
//
// if( session._selectedChar == null
// || session._selectedChar._charEntity == null
// || session._selectedChar._charEntity.CharInfo == null)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.LoginFail;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().error("Select Character fail !!!", session.ToString());
// await session.Close();
// return;
// }
//
// if (session._selectedChar._charEntity.CharInfo.Operator != 1
// && ClientSessionManager.Instance.Count > (int)(ServerCommon.Constant.g_MaxUser))
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.ServerFull;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().debug($"Server Full ", session.ToString());
// await session.Close();
// return;
// }
//
// if(session.GameGuardInitialize() == false)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.GameGuardUserInitFailed;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().debug($"GameGuard Init Failed.", session.ToString());
// await session.Close();
// return;
// }
//
// if (false == ClientSessionManager.Instance.NewSession(session))
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.LoginFail;
// session.Send(RmiContext.ReliableSend, clientToGame);
// await session.Close();
// return;
// }
//
// // 각종 정보 로드
// if (!await session.LoadDB())
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.DbError;
// session.Send(RmiContext.ReliableSend, clientToGame);
// await session.Close();
// Log.getLogger().error("LoadDB Fail !!!", session.ToString());
// return;
// }
//
// bool IsPartyDestroy = false; // 서버 이동 중 파티가 해체되었는지 확인
// if (session.PartyGuid != string.Empty)
// {
// var error_code = await PartyManager.Instance.joinParty(session.PartyGuid, session);
// if (error_code.isFail())
// {
// IsPartyDestroy = true;
// }
// }
//
// InstanceRoom? joinedRoom = null;
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel)
// {
// if(GameServer.Instance.Map == null)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().error("GameServer.Instance.Map == null", session.ToString());
// await session.Close();
// return;
// }
// }
// else
// {
// // 인스턴스 룸 입장
// joinedRoom = await InstanceRoomManager.Instance.JoinRoom(session, session._selectedChar.LastPositionInfo.EnterInstanceInfo.InstanceRoomId, session._selectedChar.LastPositionInfo.EnterInstanceInfo.InstanceId);
// if (joinedRoom == null)
// {
// clientToGame.Response.ErrorCode = ServerErrorCode.LoginFail;
// session.Send(RmiContext.ReliableSend, clientToGame);
// Log.getLogger().error($"JoinRoom fail {loginReq.Name}", session.ToString());
// return;
// }
// }
//
// //여기서 Session 업데이트
// await GameServer.Instance.sessionUpdate();
//
// clientToGame.Response.LoginRes.ServerUtcTime = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(DateTime.UtcNow);
// clientToGame.Response.ErrorCode = ServerErrorCode.Success;
// session.Send(RmiContext.ReliableSend, clientToGame);
// // 각종 정보 클라로 전송
// session.SendInfo();
//
// bool isFromLogin = departureServer.Contains(EServerType.Login.ToString());
//
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel)
// {
// if(GameServer.Instance.Map != null)
// {
// session._selectedChar.EnterWorld(GameServer.Instance.Map, isFromLogin);
// }
//
// session._selectedChar.SendPos();
//
// //이전 서버가 게임서버이면 채널간 이동으로 본다.
// if (departureServer.Contains(EServerType.Game.ToString()))
// {
// }
//
// await GameServerApp.Instance.LoginStorage.ChangeInstanceRoomId(session.Id, string.Empty);
// }
// else
// {
// // 인스턴스 룸 입장 패킷 전송
// if (joinedRoom != null)
// {
// await joinedRoom.SendJoinSuccess(session);
//
// await GameServerApp.Instance.LoginStorage.ChangeInstanceRoomId(session.Id, session.InstanceRoomId);
// }
// }
//
// if (isFromLogin)
// {
// session.SendInfoFromLogin();
// }
// else
// {
// }
//
// if (session.PartyGuid != string.Empty)
// {
// if (IsPartyDestroy)
// {
// ClientToGame clientToGameNoti = new();
// clientToGameNoti.Message = new();
// clientToGameNoti.Message.DestroyPartyNoti = new();
//
// session.Send(RmiContext.ReliableSend, clientToGameNoti);
//
// session.PartyGuid = string.Empty;
// await GameServerApp.Instance.LoginStorage.ChangePartyGuid(session.Id, string.Empty);
// }
// else
// {
// // 서버 이동 중 파티원 위치 정보 및 본인 위치 정보 업데이트
// if (PartyManager.Instance.getMemberInfo(session.PartyGuid, session.getUserNickname(), out var memberInfo))
// {
// if (session._selectedChar.getLocationInfo(out var locationInfo))
// {
// memberInfo.LocationInfo = locationInfo;
//
// await PartyManager.Instance.UpdatePartyMemberInfo(session.PartyGuid, session.getUserNickname());
// PartyManager.Instance.sendPartyMemberLocationNoti(session.PartyGuid, session.getUserNickname(), session._selectedChar.Guid);
// }
// }
//
// PartyManager.Instance.sendAllPartyMemberLocationNoti(session.PartyGuid, session);
// }
// }
//
// session._selectedChar.ownedQuestList.checkQuestTimer(session._selectedChar);
// await session.ownedFriendList.checkInviteNoti(session._selectedChar);
// }
// catch (Exception ex)
// {
// Log.getLogger().error($"{ex} account:{loginReq.Name}");
// clientToGame.Response.ErrorCode = ServerErrorCode.LoginFail;
// session.Send(RmiContext.ReliableSend, clientToGame);
// await session.Close();
// }
// }
//
// static async Task HandleLogoutReq(ClientSession session, LogoutReq logoutReq)
// {
// Log.getLogger().debug($"logoutReq", session.ToString());
//
// ClientToGame clientToGame = new();
// clientToGame.Response = new();
// clientToGame.Response.LogoutRes = new();
// clientToGame.Response.ErrorCode = ServerErrorCode.Success;
// session.Send(RmiContext.ReliableSend, clientToGame);
//
// string sessionStr = session.ToString();
//
// await session.Close();
// }
}
}

View File

@@ -0,0 +1,155 @@
//using System;
//using System.Collections.Concurrent;
//using System.Collections.Generic;
//using System.Diagnostics.CodeAnalysis;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using ServerCommon;
//using ServerCore; using ServerBase;
//using Nettention.Proud;
//using Amazon.DynamoDBv2.Model;
//using System.Drawing;
//namespace GameServer
//{
// internal class BuildingManager
// {
// private static readonly BuildingManager _instance = new BuildingManager();
// static BuildingManager() { }
// private BuildingManager() { }
// public static BuildingManager Instance { get { return _instance; } }
// ConcurrentDictionary<int, BuildingEntity> Buildings = new ConcurrentDictionary<int, BuildingEntity>(); // 랜드에 설정된 빌딩 정보만 가진다
// public async Task<bool> LoadDB()
// {
// var buildingIdList = LandManager.Instance.GetBuildingIdList();
// var buildingEntityList = await GameServerApp.Instance.MainDB.GetBuildingEntityList(buildingIdList);
// if(buildingEntityList == null)
// {
// Log.getLogger().error("entityList == null");
// return false;
// }
// foreach (var buildingEntity in buildingEntityList)
// {
// if (!Buildings.TryAdd(buildingEntity.PK_Id, buildingEntity))
// {
// Log.getLogger().error($"DB BuildingData buildingid : {buildingEntity.PK_Id} - add fail");
// continue;
// }
// foreach (var prop in buildingEntity.Attr.PropInfo)
// {
// MapManager.Instance.UpdateProp(prop.Key, prop.Value);
// }
// }
// return true;
// }
// public void SendInfo(HostID hostId)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.BuildingInfoNoti = new ClientToGameMessage.Types.BuildingInfoNoti();
// foreach (var building in Buildings.Values)
// {
// BuildingInfo buildingInfo = new BuildingInfo();
// buildingInfo.Id = building.PK_Id;
// buildingInfo.Owner = building.Attr.Owner;
// buildingInfo.Name = building.Attr.Name;
// buildingInfo.Description = building.Attr.Description;
// foreach (var instance in building.Attr.FloorInfo)
// {
// SlotInfo slotInfo = new SlotInfo();
// slotInfo.Slot = instance.Key;
// slotInfo.Id = instance.Value;
// buildingInfo.RoomList.Add(slotInfo);
// }
// clientToGame.Message.BuildingInfoNoti.List.Add(buildingInfo);
// }
// GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame);
// }
// public List<int> GetRoomIdList()
// {
// List<int> returnList = new();
// foreach (var building in Buildings.Values)
// {
// foreach (var instance in building.Attr.FloorInfo)
// {
// returnList.Add(instance.Value);
// }
// }
// return returnList;
// }
// public bool GetBuildingEntity(int buildingId, [MaybeNullWhen(false)] out BuildingEntity outEntity)
// {
// return Buildings.TryGetValue(buildingId, out outEntity);
// }
// public bool ExchangeBuilding(BuildingEntity newBuildingEntity, int oldBuildingId, [MaybeNullWhen(false)] out BuildingEntity oldBuildingEntity)
// {
// oldBuildingEntity = default;
// if (!Buildings.TryAdd(newBuildingEntity.PK_Id, newBuildingEntity))
// {
// Log.getLogger().error($"add fail buildingid : {newBuildingEntity.PK_Id}");
// return false;
// }
// if (!Buildings.TryRemove(oldBuildingId, out oldBuildingEntity))
// {
// Buildings.TryRemove(newBuildingEntity.PK_Id, out _);
// Log.getLogger().error($"remove fail buildingid : {oldBuildingId}");
// return false;
// }
// return true;
// }
// //public bool UpdateLFProp(string buildingId, string anchorGuid, string itemGuid)
// //{
// // if (!GetBuildingEntity(buildingId, out var buildingEntity))
// // {
// // Log.getLogger().error($"get fail buildingid : {buildingId}");
// // return false;
// // }
// // buildingEntity.Attr.PropInfo[anchorGuid] = itemGuid;
// // return true;
// //}
// public bool UpdateInstance(int buildingId, int floor, int instanceId)
// {
// if (!GetBuildingEntity(buildingId, out var buildingEntity))
// {
// Log.getLogger().error($"get fail buildingid : {buildingId}");
// return false;
// }
// buildingEntity.Attr.FloorInfo[floor] = instanceId;
// return true;
// }
// public void ForcedUpdateBuilding(BuildingEntity entity)
// {
// Buildings[entity.PK_Id] = entity;
// }
// }
//}

View File

@@ -0,0 +1,702 @@
using GameServer;
using GameServer.PacketHandler;
using ServerCommon;
using ServerCore; using ServerBase;
using static ClientToGameReq.Types;
namespace GameServer
{
// 임시로 GameServer 내부로 이동 했다. - kangms
/*
public class ChatCommand : Attribute
{
Dictionary<string, ChatCommandBase> command_base_map = new Dictionary<string, ChatCommandBase>();
public ChatCommand()
{
loadChatCommand();
}
private void loadChatCommand()
{
// ChatCommand 클래스의 모든 메서드를 가져옵니다.
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var assembly in assemblies)
{
foreach (Type type in assembly.GetTypes())
{
ChatCommandAttribute[] attributes = (ChatCommandAttribute[])type.GetCustomAttributes(typeof(ChatCommandAttribute), false);
foreach (var attrib in attributes)
{
string command_key = attrib.getCommand();
if (command_key == null)
{
Log.getLogger().error($"chatCommand Key is null attrib : {attrib.getHandlerClass().FullName} ");
continue;
}
var handler_class = Activator.CreateInstance(attrib.getHandlerClass()) as ChatCommandBase;
if (handler_class == null)
{
Log.getLogger().error($"Failed to create chatCommand : commandKey:{command_key}");
continue;
}
handler_class.setAuthAdminLevelType(attrib.getAdminLevel());
handler_class.setClassName(attrib.getHandlerClass().Name);
if (command_base_map.TryAdd(command_key, handler_class) == false)
{
Log.getLogger().error($"command_base_map add Error : commandKey:{command_key}");
continue;
}
}
}
}
}
public bool isCheatCommand(string input)
{
return input.StartsWith("//");
}
public async Task<bool> HandleCommand(Player player, string input)
{
var tokenArr = input.Split(" ", 2);
try
{
var command = tokenArr[0].Remove(0, 2);
if(command_base_map.TryGetValue(command.ToLower(), out var handler_class) == false )
{
Log.getLogger().error($"Command Not Exist Command : {command.ToLower()}");
return false;
}
if (await hasAuthority(handler_class, player) == false)
{
return false;
}
if (tokenArr.Length > 1)
{
var args = tokenArr[1].Split(" ", StringSplitOptions.RemoveEmptyEntries);
await handler_class.invoke(player, tokenArr[1], args);
}
else
{
await handler_class.invoke(player, String.Empty, new string[] { });
}
}
catch (TaskCanceledException)
{
}
catch (Exception ex)
{
Log.getLogger().error($"{ex}");
return false;
}
return true;
}
private async Task<bool> hasAuthority(ChatCommandBase handlerClass, Player player)
{
//서버 타입이 Dev면 무조건 true처리
if (ServerConfigHelper.getServerConfig().ServiceType.Equals(ServiceType.Dev.ToString()))
{
return true;
}
var account_attribute = player.getEntityAttribute<AccountAttribute>();
var adim_level_type = account_attribute.AuthAdminLevelType;
//여기에 유저 레벨이랑, 클래스에 할당된 레벨이랑 비교 필요
var class_admin_level_type = handlerClass.getAuthAddminLevelType();
if (class_admin_level_type.Contains(adim_level_type) == false)
{
Log.getLogger().info($"Not Match Admin LevelType : {account_attribute.AccountId}, className = {handlerClass.getAuthAddminLevelType().ToString()}, className : {handlerClass.getClassName()}");
return false;
}
return true;
}
}
[AttributeUsage(AttributeTargets.Class)]
internal class ChatCommandAttribute : Attribute
{
readonly string m_cheat_comment;
private readonly Type m_handler_class;
private readonly HashSet<AuthAdminLevelType> m_auth_admin_level_type;
public ChatCommandAttribute(string cheatCommend, Type handlerClass, params AuthAdminLevelType[] authAdminLevelType)
{
m_cheat_comment = cheatCommend;
m_handler_class = handlerClass;
m_auth_admin_level_type = new HashSet<AuthAdminLevelType>(authAdminLevelType);
}
public string getCommand()
{
return m_cheat_comment;
}
public HashSet<AuthAdminLevelType> getAdminLevel()
{
return m_auth_admin_level_type;
}
public Type getHandlerClass()
{
return m_handler_class;
}
}
public abstract class ChatCommandBase
{
private HashSet<AuthAdminLevelType> m_auth_admin_level_type = new();
private string m_class_name = string.Empty;
public void setAuthAdminLevelType(HashSet<AuthAdminLevelType> typeSet)
{
m_auth_admin_level_type = typeSet;
}
public HashSet<AuthAdminLevelType> getAuthAddminLevelType()
{
return m_auth_admin_level_type;
}
public void setClassName(string className)
{
m_class_name = className;
}
public string getClassName()
{
return m_class_name;
}
public virtual async Task invoke(Player player, string token, string[] args) { }
}
[ChatCommandAttribute("dummyClazz", typeof(ChatCommandDummy), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandDummy : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
}
}
[ChatCommandAttribute("teleport", typeof(ChatCommandTeleport), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandTeleport : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleTeleport");
if (args.Length < 2)
return;
if (float.TryParse(args[0], out float x) == false || float.TryParse(args[1], out float y) == false)
return;
Pos pos = new Pos();
pos.X = x;
pos.Y = y;
pos.Z = 0.0f;
pos.Angle = 0;
//player.Teleport(pos);
}
}
[ChatCommandAttribute("additem", typeof(ChatCommandAddItem), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandAddItem : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleAddItem");
if (args.Length < 2)
return;
if (int.TryParse(args[0], out int itemId) == false || int.TryParse(args[1], out int count) == false)
return;
//await player.CheatAddItem(itemId, count);
}
}
[ChatCommandAttribute("delitem", typeof(ChatCommandDelItem), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandDelItem : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleDelItem");
if (args.Length < 2)
return;
if (int.TryParse(args[0], out int itemId) == false || int.TryParse(args[1], out int count) == false)
return;
//await player.CheatDelItem(itemId, count);
}
}
[ChatCommandAttribute("init", typeof(ChatCommandInit), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandInit : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleInit");
// player._charEntity.AvatarInfo.Init = 1;
// await GameServerApp.Instance.MainDB.SaveChar(player._charEntity);
}
}
[ChatCommandAttribute("mailsetremainedtime", typeof(ChatCommandMailSetRemainedTime), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandMailSetRemainedTime : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleMailDecreaseTime");
if (args.Length < 2)
{
Log.getLogger().error($"Invalid Argument");
return;
}
// var session = ClientSessionManager.Instance.GetSession(player.HostId);
//
// if (session is null)
// {
// Log.getLogger().error($"session is null.");
// return;
// }
// try
// {
// ServerErrorCode errorCode = await session.ownedMail.SetRemainedTime(int.Parse(args[0]) == 0 ? false : true, int.Parse(args[1]));
// if (errorCode != ServerErrorCode.Success)
// {
// Log.getLogger().error($"HandleMailDecreaseTime Cheat Failed.");
// return;
// }
// }
// catch (Exception ex)
// {
// Log.getLogger().error($"{ex}");
// }
}
}
[ChatCommandAttribute("mailsendtome", typeof(ChatCommandMailSendToMe), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandMailSendToMe : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleMailSendToMe");
if (args.Length < 1)
{
Log.getLogger().error($"Invalid Argument");
return;
}
// var session = ClientSessionManager.Instance.GetSession(player.HostId);
// if (session is null)
// {
// Log.getLogger().error($"session is null.");
// return;
// }
//
// DateTime now = DateTime.UtcNow;
// string nickName = player._charEntity.CharInfo.DisplayName;
// try
// {
// int mailCount = int.Parse(args[0]);
//
// CharMetaDataEntity MetaDataEntity = new CharMetaDataEntity(session.ownedCharMetaDataEntity.DocumentForUpdate());
// NickNameEntity? nicknameEntity = await GameServerApp.Instance.MainDB.GetEntityFromNickName(nickName);
// if (nicknameEntity is null)
// {
// Log.getLogger().debug($"InvalidTarget. Target : {nickName}");
// return;
// }
//
// for (int i = 0; i < mailCount; ++i)
// {
// var (errorCode, mailInfo) = await session.SendMailProcess(nickName, nicknameEntity.Attr.AccountId, nicknameEntity.Attr.AccountGuid, "testTitle", "testBody", MetaDataEntity);
// if (errorCode != ServerErrorCode.Success)
// {
// Log.getLogger().error($"HandleMailDecreaseTime Cheat Failed.");
// return;
// }
// }
// }
// catch (Exception ex)
// {
// Log.getLogger().error($"{ex}");
// }
}
}
[ChatCommandAttribute("mailsendcountinit", typeof(ChatCommandMailSendCountInit), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandMailSendCountInit : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleMailSendCountInit");
// var session = ClientSessionManager.Instance.GetSession(player.HostId);
// if (session is null)
// {
// Log.getLogger().error($"session is null.");
// return;
// }
//
// if (await session.CheatMailSendUpdateDay() == false)
// {
// Log.getLogger().error($"HandleMailSendCountInit Cheat Failed.");
// return;
// }
}
}
[ChatCommandAttribute("currencymodify", typeof(ChatCommandModifyCurrency), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandModifyCurrency : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
var money_action = player.getEntityAction<MoneyAction>();
money_action.modifyMoney();
}
}
[ChatCommandAttribute("questreset", typeof(ChatCommandQuestReset), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandQuestReset : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
var quest_action = player.getEntityAction<QuestAction>();
quest_action.resetQuest();
}
}
[ChatCommandAttribute("questcomplete", typeof(ChatCommandQuestComplete), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandQuestComplete : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
if (args.Length < 1)
{
Log.getLogger().error($"Invalid Argument");
return;
}
if (!int.TryParse(args[0], out var questId))
{
Log.getLogger().error($"questcomplete param parsing Error args : {args[0]}");
}
var quest_action = player.getEntityAction<QuestAction>();
quest_action.questComplete(questId);
}
}
[ChatCommandAttribute("startbuff", typeof(ChatCommandStartBuff), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandStartBuff : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleStartBuff");
// var session = ClientSessionManager.Instance.GetSession(player.HostId);
// if (session is null)
// {
// Log.getLogger().error($"session is null.");
// return;
// }
//
// if (args.Length < 1)
// {
// Log.getLogger().error($"Invalid Argument");
// return;
// }
//
// try
// {
// int buffId = int.Parse(args[0]);
// var errorCode = session.StartBuff(buffId);
// if (errorCode != ServerErrorCode.Success)
// {
// Log.getLogger().error($"StartBuff Cheat Failed.");
// return;
// }
// }
// catch (Exception ex)
// {
// Log.getLogger().error($"StartBuff Cheat Failed. {ex}");
// return;
// }
}
}
[ChatCommandAttribute("addsystemmail", typeof(ChatCommandAddSystemMail), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandAddSystemMail : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
// Log.getLogger().info($"HandleAddSystemMail");
// await SystemMailManager.Instance.CheatFuncSaveSystemMail();
// ClientSessionManager.Instance.AllPlayerSystemMailNoti();
}
}
[ChatCommandAttribute("addnoticechat", typeof(ChatCommandAddNoticeChat), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandAddNoticeChat : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
// Log.getLogger().info($"HandleAddNoticeChat");
//
// if (args.Length < 3)
// {
// Log.getLogger().error($"Invalid Argument");
// return;
// }
//
// try
// {
// int messageType = int.Parse(args[0]);
// string KoMessage = args[1];
// string EnMessage = args[2];
// await NoticeChatManager.Instance.TempFuncAddData(messageType, KoMessage, EnMessage);
// }
// catch (Exception ex)
// {
// Log.getLogger().error($"AddNoticeChat cheat Failed. {ex}");
// return;
// }
}
}
[ChatCommandAttribute("userreport", typeof(ChatCommandUserReport), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandUserReport : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleUserReport");
//await player.UserReport("그리노스", "이유", "신고", "신고합니다.");
}
}
[ChatCommandAttribute("changenickname", typeof(ChatCommandChangeNickName), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandChangeNickName : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleChangeNickName");
if (args.Length < 1)
{
Log.getLogger().error($"Invalid Argument");
return;
}
try
{
//await player.changeNickName(args[0]);
}
catch (Exception ex)
{
Log.getLogger().error($"ChangeNickName cheat Failed. {ex}");
return;
}
}
}
[ChatCommandAttribute("megaphone", typeof(ChatCommandMegaPhone), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandMegaPhone : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
Log.getLogger().info($"HandleMegaPhone");
if (args.Length < 1)
{
Log.getLogger().error($"Invalid Argument");
return;
}
// try
// {
// ClientToGame clientMsg = new();
// clientMsg.Message = new ClientToGameMessage();
// clientMsg.Message.Chat = new();
// clientMsg.Message.Chat.Message = args[0];
// clientMsg.Message.Chat.Sender = player._charEntity.CharInfo.DisplayName;
// clientMsg.Message.Chat.Type = (int)ChatType.Channel;
// ClientSessionManager.Instance.Broadcast(player, clientMsg);
// }
// catch (Exception ex)
// {
// Log.getLogger().error($"MegaPhone Cheat Failed. {ex}");
// return;
// }
}
}
[ChatCommandAttribute("userandomboxitem", typeof(ChatCommandRandomBoxItemReward), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandRandomBoxItemReward : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
var randombox_item_action = player.getEntityAction<RandomBoxItemUseAction>();
randombox_item_action.useRandomBoxItem();
}
}
[ChatCommandAttribute("socialactionall", typeof(ChatCommandSocialActionAll), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandSocialActionAll : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
// Log.getLogger().info($"HandleSocialActionAll");
// var session = ClientSessionManager.Instance.GetSession(player.HostId);
// if (session is null)
// {
// Log.getLogger().error($"session is null.");
// return;
// }
//
// await session.ownedSocialAction.AllSocialActionCollectionsSetting();
// session.ownedSocialAction.SendInfo(session.HostId);
}
}
[ChatCommandAttribute("storereset", typeof(ChatCommandStoreReset), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandStoreReset : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
// Log.getLogger().info($"HandleStoreReset");
// var session = ClientSessionManager.Instance.GetSession(player.HostId);
// if (session is null)
// {
// Log.getLogger().error($"session is null.");
// return;
// }
//
// ClientToGame clientMsg = new();
// clientMsg.Message = new ClientToGameMessage();
// clientMsg.Message.Chat = new();
// clientMsg.Message.Chat.Sender = "Cheat";
// clientMsg.Message.Chat.Type = ChatType.System;
//
// ServerErrorCode errorCode = await session.ownedShop.CheatInitResetTime();
// if (errorCode.isFail())
// {
// Log.getLogger().error($"Cheat Store Reset Failed. error : {errorCode}.");
// clientMsg.Message.Chat.Message = "Cheat Failed.";
// player.Send(clientMsg);
// return;
// }
// clientMsg.Message.Chat.Message = "StoreReset Complete.";
// player.Send(clientMsg);
}
}
[ChatCommandAttribute("methodtest", typeof(ChatCommandMethodTest), AuthAdminLevelType.Developer)]
internal class ChatCommandMethodTest : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
}
}
[ChatCommandAttribute("sessionkeepalivetime", typeof(ChatCommandSessionKeepAliveTime), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandSessionKeepAliveTime : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
// Log.getLogger().info($"handleSessionKeepAliveTime");
// var session = ClientSessionManager.Instance.GetSession(player.HostId);
// if (session is null)
// {
// Log.getLogger().error($"session is null.");
// return;
// }
//
// var keep_alive_minutes = int.Parse(args[0]);
//
// GameServer.Instance._srv.SetTimeoutTimeMs(player.HostId, keep_alive_minutes * 60 * 1000);
}
}
[ChatCommandAttribute("leveluptattoo", typeof(ChatCommandLevelUpTattoo), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
internal class ChatCommandLevelUpTattoo : ChatCommandBase
{
public override async Task invoke(Player player, string token, string[] args)
{
// Log.getLogger().info($"HandleLevelUpTattoo");
// var session = ClientSessionManager.Instance.GetSession(player.HostId);
// if (session is null || session._selectedChar is null)
// {
// Log.getLogger().error($"session is null.");
// return;
// }
//
// var slot = int.Parse(args[0]);
// var ItemGuid = session._selectedChar.GetTattooGuidFromSlot(slot);
// if (ItemGuid == string.Empty)
// {
// return;
// }
//
// List<ILogInvoker> invokers = new List<ILogInvoker>();
// var log_action = new LogActionEx(LogActionType.CheatCommandItemLevelUp);
//
// var itemlogDatas = await session.LevelUpTattoo(ItemGuid);
// if (itemlogDatas == null)
// {
// return;
// }
//
// foreach (var itemInfoLog in itemlogDatas)
// {
// //invokers.Add(new ItemLog(itemInfoLog));
// }
// BusinessLogger.collectLogs(log_action, session._selectedChar, invokers);
}
}
*/
}

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServerCommon;
namespace GameServer
{
internal class ChatRoomHandler
{
/*static int GetBestChattingServer(in List<ServerInfo> serverList)
{
int retIndex = 0;
int minCount = -1;
foreach (var serverInfo in serverList.Select((value, index) => new { value, index }))
{
if (minCount < serverInfo.value.Sessions)
{
retIndex = serverInfo.index;
minCount = serverInfo.value.Sessions;
}
}
return retIndex;
}
public static async Task<ChatRoomInfo?> CreateRoom(List<string> allowList)
{
ServerInfo emptyServer = new ServerInfo();
List<ServerInfo> serverList = await GameServerApp.Instance.ServerCUStorage.getServersCU(ServerType.Chat);
if (serverList.Count == 0)
return null;
int serverIndex = GetBestChattingServer(serverList);
if(serverIndex == -1)
return null;
ServerInfo chatServer = serverList[serverIndex];
return await GameServerApp.Instance.ChatRoomStorage.CreateChatRoom(
chatServer.Address, chatServer.Port, allowList);
}
public static async Task<ChatRoomInfo?> JoinRoom(long roomId, string charName)
{
ChatRoomInfo? charRoomInfo = await GameServerApp.Instance.ChatRoomStorage.GetChatRoom(roomId);
if (charRoomInfo == null)
return null;
if (charRoomInfo.AllowList.Contains(charName) == false)
return null;
return charRoomInfo;
}*/
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,108 @@
using Amazon.DynamoDBv2.DocumentModel;
using Google.Protobuf.WellKnownTypes;
using Nettention.Proud;
using ServerCommon;
using ServerCore; using ServerBase;
using System.Collections.Concurrent;
using static ClientToGameMessage.Types;
using static ClientToGameReq.Types;
namespace GameServer
{
// public partial class ClientSession : IEntityWithSession
// {
//
// public void HandleGetClaimInfoReq()
// {
//
// ServerErrorCode errorCode = claimInfoRefresh(_selectedChar);
//
// if(errorCode != ServerErrorCode.Success)
// {
// clientToGame.Response.ErrorCode = errorCode;
// Send(RmiContext.ReliableSend, clientToGame);
// return;
// }
//
// List<ClientToGame> CtoGs = ClaimRewardHelper.MakeClaimSendInfo(_selectedChar, true);
// Send(RmiContext.ReliableSend, CtoGs[0]);
//
// return;
// }
//
// public void claimInfosRefreshAndNoti(object player)
// {
// // if (!player.archiveEvents.TryGetValue(EEventType.ClaimReward, out var eventInfos))
// // {
// // Log.getLogger().error("archiveEvents is null");
// // return;
// // }
// //
// // if(eventInfos.RefreshEvent())
// // {
// // eventInfos.EventUpdateNoti();
// // }
// }
//
//
// public ServerErrorCode claimInfoRefresh(object player)
// {
// if (!player.archiveEvents.TryGetValue(EEventType.ClaimReward, out var eventInfos))
// {
// Log.getLogger().error("archiveEvents is null");
// return ServerErrorCode.ServerLogicError;
// }
//
// bool needUpdate = eventInfos.RefreshEvent();
// return ServerErrorCode.Success;
// }
//
// public void HandleClaimReset()
// {
// if (_selectedChar == null)
// {
// Log.getLogger().error("_selectedChar is null");
// throw new Exception("HandleClaimReset() and _selectedChar is null");
// }
//
//
// // ClaimNormalEntity newNormalEntity = new ClaimNormalEntity(_selectedChar.claimNormalEntity.DocumentForUpdate());
// // ClaimMembershipEntity newMembershipEntity = new ClaimMembershipEntity(_selectedChar.claimMembershipEntity.DocumentForUpdate());
// //
// // newNormalEntity.Attr = new();
// // newMembershipEntity.Attr = new();
// // Document docNormal = newNormalEntity.DocumentForUpdate();
// // Document docMembership = newMembershipEntity.DocumentForUpdate();
// // var cts = new CancellationTokenSource();
// //
// // List<DBDocumentInfo> dBDocumentInfos = new();
// // dBDocumentInfos.Add(new DBDocumentInfo(docNormal, EDBExecuteType.Update));
// // dBDocumentInfos.Add(new DBDocumentInfo(docMembership, EDBExecuteType.Update));
// //
// // try
// // {
// // GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2).WaitAsync(cts.Token);
// // }
// // catch (OperationCanceledException)
// // {
// // //ErrorLog
// // return;
// // }
// // finally
// // {
// // cts.Dispose(); // CancellationTokenSource 해제
// // }
// // _selectedChar.claimNormalEntity.ReadFrom(docNormal);
// // _selectedChar.claimMembershipEntity.ReadFrom(docMembership);
// return;
//
//
// }
//
//
}

View File

@@ -0,0 +1,65 @@
using Google.Protobuf.WellKnownTypes;
using Nettention.Proud;
using Newtonsoft.Json;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using ServerCore; using ServerBase;
using System.Collections.Concurrent;
using static ClientToGameReq.Types;
namespace GameServer
{
public partial class ClientSession
{
//
//
// public void getStateNotiFromFriend(string friendId, string friendGuid, string friendrNickName, int friendState, int friendMapId)
// {
//
// ClientSession? friendSession = ClientSessionManager.Instance.GetSessionByName(friendId);
//
// UserLocationInfo info = new();
// if (friendSession is null || friendSession._selectedChar is null)
// {
// Log.getLogger().warn($"{friendId} session is null so UserLocationInfo is empty", ToString());
// }
// else
// {
// friendSession._selectedChar.getLocationInfo(out var friendLocation);
// if (friendLocation is null)
// {
// Log.getLogger().warn($"{friendId} UserLocationInfo is null", ToString());
//
// }
// else
// {
// info = friendLocation;
// }
//
// }
//
//
//
// Send(RmiContext.ReliableSend, friendStateToMe);
// }
//
//
//
//
//
public string getAccountId()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,160 @@
using Amazon.DynamoDBv2.DocumentModel;
using GameServer;
using Google.Protobuf.WellKnownTypes;
using Nettention.Proud;
using Newtonsoft.Json;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using ServerCore; using ServerBase;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic;
using System.Numerics;
using static ClientToGameReq.Types;
namespace GameServer
{
public partial class ClientSession
{
/*
private async Task processAfterReward(Object player, QuestBaseInfo baseInfo)
{
var questidList = baseInfo.AssignableQuestsAfterEnd;
List<int> mailQuests = new();
foreach (int nextQuestId in questidList)
{
if (nextQuesInfo.AssignType.Equals(nameof(EAssignType.MAIL)) && nextQuesInfo.ForceAccept == false)
{
mailQuests.Add(nextQuestId);
continue;
}
else if (nextQuesInfo.AssignType.Equals(nameof(EAssignType.MAIL)) && nextQuesInfo.ForceAccept == true)
{
}
}
if (mailQuests.Count > 0)
{
}
}
void HandleGetQuestMailReq(GetQuestMailReq req)
{
ClientToGame clientToGame = new();
clientToGame.Response = new();
clientToGame.Response.GetQuestMailRes = new();
clientToGame.Response.ErrorCode = ServerErrorCode.Success;
if (_selectedChar == null)
{
Log.getLogger().error("_selectedChar is null");
clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError;
Send(RmiContext.ReliableSend, clientToGame);
return;
}
var questMails = _selectedChar.ownedQuestMail.GetQuestMailList();
clientToGame.Response.GetQuestMailRes.QuestMailList.AddRange(questMails);
Send(RmiContext.ReliableSend, clientToGame);
}
async Task HandleReadQuestMailReq(ReadQuestMailReq message)
{
ClientToGame clientToGame = new ClientToGame();
clientToGame.Response = new ClientToGameRes();
clientToGame.Response.ReadQuestMailRes = new ClientToGameRes.Types.ReadQuestMailRes();
if (_selectedChar == null)
{
Log.getLogger().error("_selectChar is null", ToString());
clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError;
Send(RmiContext.ReliableSend, clientToGame);
return;
}
ServerErrorCode errorCode = _selectedChar.ownedQuestMail.ReadQuestMail(message.QuestId, out var newQuestMailEntity);
if (errorCode != ServerErrorCode.Success || newQuestMailEntity == null)
{
Log.getLogger().error($"HandleReadQuestMailReq Failed");
clientToGame.Response.ErrorCode = errorCode;
Send(RmiContext.ReliableSend, clientToGame);
return;
}
if (await GameServerApp.Instance.MainDB.UpdateQuestMail(new List<QuestMailEntity>() { newQuestMailEntity }) == false)
{
Log.getLogger().error($"DB UpdateMail Failed. questId : {message.QuestId}");
clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed;
Send(RmiContext.ReliableSend, clientToGame);
return;
}
_selectedChar.ownedQuestMail.UpdateQuestMailToMemory(message.QuestId, newQuestMailEntity);
Send(RmiContext.ReliableSend, clientToGame);
}
public async Task CheatQuestComplete(int questId)
{
if (_selectedChar is null)
{
Log.getLogger().error("HandleQuestReset _selectedChar is null");
return;
}
_selectedChar.ownedQuestList.cheatQuestComplete(questId, out var newQuestListEntity);
List<DBDocumentInfo> dBDocumentInfos = new();
Document newDocument = newQuestListEntity.DocumentForUpdate();
dBDocumentInfos.Add(new DBDocumentInfo(newDocument, EDBExecuteType.Update));
if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false)
{
Log.getLogger().error($"HandleQuestAcceptReq DB Update Failed.");
return;
}
_selectedChar.ownedQuestList.UpdateDBToMemory(newDocument);
}
public async Task cheatQuestMailSend(int questId)
{
if (_selectedChar is null)
{
Log.getLogger().error("HandleQuestReset _selectedChar is null");
return;
}
}
*/
}
}

View File

@@ -0,0 +1,67 @@
using Nettention.Proud;
using ServerCommon;
using ServerCore; using ServerBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GameServer
{
public class CurrencyManager
{
private static readonly CurrencyManager _instance = new();
public static CurrencyManager Instance { get { return _instance; } }
// public void SendCurrencyMaxNoti(string currencyType, HostID hostID)
// {
// ClientToGame clientToGame = new();
// clientToGame.Message = new();
// clientToGame.Message.CurrencyMaxNoti = new();
// clientToGame.Message.CurrencyMaxNoti.CurrencyType = currencyType;
// //GameServer.Instance.Send(hostID, RmiContext.ReliableSend, clientToGame);
// }
// public long getCurrencyValueByType(CharEntity newCharEntity, ECurrencyType type)
// {
// switch (type)
// {
// case ECurrencyType.GOLD:
// return newCharEntity.CharInfo.Gold;
// case ECurrencyType.BLUECALI:
// return newCharEntity.CharInfo.BlueCali;
// case ECurrencyType.REDCALI:
// return newCharEntity.CharInfo.RedCali;
// case ECurrencyType.BLACKCALI:
// return newCharEntity.CharInfo.BlackCali;
// default:
// return long.MinValue;
// }
// }
//
// public void UpdateCurrencyValueByType(CharEntity newCharEntity, ECurrencyType type, long value)
// {
// switch (type)
// {
// case ECurrencyType.GOLD:
// newCharEntity.CharInfo.Gold = value;
// break;
// case ECurrencyType.BLUECALI:
// newCharEntity.CharInfo.BlueCali = value;
// break;
// case ECurrencyType.REDCALI:
// newCharEntity.CharInfo.RedCali = value;
// break;
// case ECurrencyType.BLACKCALI:
// newCharEntity.CharInfo.BlackCali = value;
// break;
// default:
// break;
// }
// }
}
}

View File

@@ -0,0 +1,61 @@
//using Nettention.Proud;
//using ServerCommon;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//namespace GameServer
//{
// public partial class ClientSession : IEntityWithSession
// {
// public HostID getHostId()
// {
// return HostId;
// }
// public int getSessionId()
// {
// return HostId.toSESSION_ID();
// }
// public string getUserId()
// {
// return Id;//_selectedChar._charEntity.Id;
// }
// public System.Guid getUserGuid()
// {
// return System.Guid.Parse(AccountGuid);
// }
// public string getUserNickname()
// {
// return _selectedChar._charEntity.CharInfo.DisplayName;
// }
// public LanguageType getLanguageType()
// {
// return (LanguageType)_selectedChar._charEntity.CharInfo.LanguageInfo;
// }
// public string toBasicString()
// {
// return $"EntityUser: userId:{getUserId()}, userNickname:{getUserNickname()}";
// }
// public string toSummaryString()
// {
// return $"EntityUser: userId:{getUserId()}, userGuid:{getUserGuid()}, userNickname:{getUserNickname()}";
// }
// public IntPtr getGameGuardInstance()
// {
// return GameGuardInstance;
// }
// }
//}

View File

@@ -0,0 +1,39 @@
//using ServerCommon;
//using ServerCore; using ServerBase;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//namespace GameServer
//{
// public class EscapePisitionTimeInfo
// {
// public EscapePositionEntity m_escape_postion_entity = new();
//// public async Task<bool> LoadDB(string accountGuid)
//// {
//// var escape_position_document = await GameServerApp.Instance.MainDB.getEscapePositionTimeInfo(accountGuid);
//// if(escape_position_document == null)
//// {
//// Log.getLogger().error("escape_position_document is null");
//// return false;
//// }
//// m_escape_postion_entity.ReadFrom(escape_position_document);
//// return true;
//// }
//// public void CopyEscapePositionEntityForTransaction(out EscapePositionEntity newEntity)
//// {
//// newEntity = new EscapePositionEntity(m_escape_postion_entity);
//// }
// public void UpdateMemory(EscapePositionEntity entity)
// {
// m_escape_postion_entity = entity;
// }
// }
//}

View File

@@ -0,0 +1,639 @@
//using GameServer.World;
//using Nettention.Proud;
//using ServerCommon;
//using ServerCommon.Redis;
//using ServerCore; using ServerBase;
//using System.Diagnostics;
//using System.Net;
//using ControlCenter.NamedPipe;
//namespace GameServer
//{
// internal class GameServer
// {
// static public GameServer Instance { get; } = new();
// static public AtomicBool m_user_login_block_enable = new(false);
// public NetServer _srv { get; } = new();
// PClientToGame.Stub _stub = new();
// public PClientToGame.Proxy _proxy { get; } = new();
// CancellationTokenSource _cts = new();
// TaskCompletionSource<bool>? _runTask;
// public RabbitMQ4Game _rabbitMQ4Game = null!;
// public string ServerName { get; private set; } = string.Empty;
// public string WorldServerName { get; private set; } = string.Empty;
// public AwsNewInstanceInfo myServerInfo = new AwsNewInstanceInfo();
// List<Task> periodicTasks = new(10);
// List<ChannelInfo> ChannelInfoList = new(1000);
// public Map? Map;
// public ChatCommand ChatCommand { get; private set; } = new ChatCommand();
// private GameServer()
// {
//#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다.
// _srv.ClientJoinHandler = async (clientInfo) =>
// {
// using (clientInfo)
// {
// Log.getLogger().debug($"Client {clientInfo.hostID.ToString()} ip:{clientInfo.m_TcpLocalAddrFromServer.ToString()} connected.");
// ClientSession session = new ClientSession(clientInfo.hostID, "", "");
// ClientSessionManager.Instance.AddHost(session);
// NamedPipeClientHelper.Instance.SetCurrentClientConnection(true);
// }
// };
// // set a routine for client leave event.
// _srv.ClientLeaveHandler = async (clientInfo, errorInfo, comment) =>
// {
// using (clientInfo)
// {
// Log.getLogger().debug($"Client {clientInfo.hostID.ToString()} ip:{clientInfo.tcpAddrFromServer.IPToString()} disconnected.");
// NamedPipeClientHelper.Instance.SetCurrentClientConnection(false);
// ClientSession? client = ClientSessionManager.Instance.GetSession(clientInfo.hostID);
// if (client == null)
// {
// Log.getLogger().error($"Notfound Session hostId:{clientInfo.hostID}");
// return;
// }
// // 세션종료로 레디스에 지운 정보를 백그라운드에서 다시 등록하는 것을 방지하기 위해 먼저 뺀다.
// // Close시에 이미 세션매니저에서는 제거된 상태임을 주의 바람.
// _ = client._serializer.post(async () =>
// {
// ClientSessionManager.Instance.ReleaseSession(client);
// await client.Close();
// });
// }
// };
// _srv.ErrorHandler = (ErrorInfo Info) =>
// {
// using (Info)
// {
// Log.getLogger().error(Info.ToString());
// }
// };
// _srv.ExceptionHandler = (Exception ex) =>
// {
// Log.getLogger().error(ex.ToString());
// };
// _srv.WarningHandler = (ErrorInfo Info) =>
// {
// using (Info)
// {
// Log.getLogger().warn(Info.ToString());
// }
// };
// _srv.InformationHandler = (ErrorInfo Info) =>
// {
// using (Info)
// {
// Log.getLogger().info(Info.ToString());
// }
// };
// _srv.ClientHackSuspectedHandler = (HostID clientID, HackType hackType) =>
// {
// var clientInfo = _srv.GetClientInfo(clientID);
// using (clientInfo)
// {
// ClientSession? client = ClientSessionManager.Instance.GetSession(clientID);
// if (client != null)
// {
// Log.getLogger().error($"hostID:{clientID} HanckType:{hackType} {clientInfo.m_TcpLocalAddrFromServer.ToString()}, AccountID:{client.Id}");
// }
// else
// {
// Log.getLogger().error($"hostID:{clientID} HanckType:{hackType} {clientInfo.m_TcpLocalAddrFromServer.ToString()}");
// }
// }
// };
//#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다.
// }
// void InitStub()
// {
// _stub.Message = (HostID remote, RmiContext rmiContext, ClientToGame message) =>
// {
// _ = AuthHandler.ProcessRequestPacket(remote, rmiContext, message.Request);
// return true;
// };
// }
// public async Task<bool> StartServer(Options option)
// {
// //서버 중복시 종료
// if (ServerUtil.isExistProcess(Process.GetCurrentProcess().ProcessName + Convert.ToString(option.Port)))
// {
// Log.getLogger().error("Duplicate Port : " + Process.GetCurrentProcess().ProcessName + Convert.ToString(option.Port));
// return false;
// }
// InitStub();
// _srv.AttachStub(_stub);
// _srv.AttachProxy(_proxy);
// string ip = string.Empty;
// if (GameServerApp.Instance.Config.ServiceType == "Dev")
// {
// ip = ServerUtil.GetLocalIPv4();
// }
// else
// {
// ip = ServerUtil.GetPublicIPv4();
// }
// m_user_login_block_enable.set(GameServerApp.Instance.Config.AccountLoginBlockEnable);
// ServerType serverType = GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel ? ServerType.Game : ServerType.Indun;
// myServerInfo.worldId = option.worldid;
// myServerInfo.channel = option.channel;
// myServerInfo.ip = ip;
// myServerInfo.port = option.Port;
// myServerInfo.serverType = (int)serverType;
// myServerInfo.capacity = GameServerApp.Instance.Config.DefaultMaxUser;
// Constant.g_MaxUser = GameServerApp.Instance.Config.DefaultMaxUser;
// if (GameServerApp.Instance.Config.AWS.Enable)
// {
// myServerInfo.instanceId = await ServerUtil.GetAwsInstanceID();
// }
// if (GameServerApp.Instance.Config.GameGuard == true)
// {
// uint uReturn = GameGuardHelper.InitCSAuth3("./support/GameGuard/");
// if (uReturn != 0)
// {
// Log.getLogger().error("Failed to Init GameGuard.");
// return false;
// }
// }
// _srv.AllowEmptyP2PGroup(true);
// string name = GameServerApp.Instance.Config.GameServerType.ToString();
// ServerName = ServerUtil.CreateServerName(serverType, ip,
// option.Port, myServerInfo.worldId, myServerInfo.channel);
// if (GameServerApp.Instance.Config.AWS.CloudWatchLog.Enable)
// {
// ServerLog.Init($"{serverType}Server", ip, option.Port,
// GameServerApp.Instance.Config.AWS.CloudWatchLog.CloudWatchLogGroup,
// GameServerApp.Instance.Config.AWS.CloudWatchLog.CloudWatchLogNamePattern,
// GameServerApp.Instance.Config.AWS.CloudWatchLog.CloudWatchLogLevel,
// GameServerApp.Instance.Config.AWS.Region,
// GameServerApp.Instance.Config.AWS.AccessKey,
// GameServerApp.Instance.Config.AWS.SecretKey,
// GameServerApp.Instance.Config.AWS.CloudWatchLog.CloudWatchLogLayout);
// }
// else
// {
// ServerLog.Init($"{serverType}Server", ip, option.Port);
// }
// string WorldServerName = $"{serverType}:{ServerUtil.MakeWorldidToString(myServerInfo.worldId)}";
// // 적용되지 않음. concurrentWrites=true 로 해결 인던서버와 게임서버를 로칼에서 실행할때
// // 로그파일이름이 중복되어 옵션을 켜줌. 실서비스시에는 끄는것이 좋음.
// //ServerLog.Init(logFileName);
// var param = new StartServerParameter();
// param.protocolVersion = new Nettention.Proud.Guid(ServerCommon.Constant.Version);
// param.tcpPorts.Add(option.Port);
// param.clientEmergencyLogMaxLineCount = 10;
// param.hostIDGenerationPolicySimplePacketMode = HostIDGenerationPolicy.HostIDGenerationPolicy_NoRecycle;
// param.m_enableAutoConnectionRecoveryOnServer = false;
// param.enableNagleAlgorithm = false;
// ///param.udpAssignMode = ServerUdpAssignMode.ServerUdpAssignMode_PerClient;
// //int udpPort = option.Port;
// //if (serverType != EServerType.Game)
// //{
// // udpPort = option.Port + 2500;
// //}
// //for (int i = 0; i < 2500; i++)
// //{
// // param.udpPorts.Add(udpPort + i);
// //}
// try
// {
//#if DEBUG
// // 서버와 오랫동안 통신이 되지 않을 때 서버와의 연결을 끊기 위한 타임아웃(초)의 임계값을 설정
// const Int32 SESSION_KEEP_ALIVE_TIME_MS = (60 * 60 * 1000) * 1; // 1시간 설정
// _srv.SetDefaultTimeoutTimeMs(SESSION_KEEP_ALIVE_TIME_MS);
//#else
// int keep_alive_time = GameServerApp.Instance.Config.SessionKeepAliveTimeSec * ConstValue.default_1000_millisec;
// _srv.SetDefaultTimeoutTimeMs(keep_alive_time);
//#endif//DEBUG
// //_srv.SetMessageMaxLength(ServerCommon.Constant.MaxPacketSize);
// _srv.Start(param);
// //_srv.EnableSpeedHackDetector();
// }
// catch (Exception ex)
// {
// Log.getLogger().error("Failed to start server~!!" + ex.ToString());
// return false;
// }
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel)
// {
// if (TableData.Instance._WorldDataTable.TryGetValue(myServerInfo.worldId, out var value) == false)
// {
// Log.getLogger().error("Failed to start server~!! : Failed to read WorldDataTable.");
// return false;
// }
// Map = new Map(value.MapPath);
// }
// _runTask = new TaskCompletionSource<bool>();
// Log.getLogger().info($"running server on {option.Port}, {GameServerApp.Instance.Config.GameServerType}");
// _rabbitMQ4Game = new RabbitMQ4Game(ServerName
// , GameServerApp.Instance.Config.Rabbitmq.HostName
// , GameServerApp.Instance.Config.Rabbitmq.Port
// , GameServerApp.Instance.Config.Rabbitmq.UserName
// , GameServerApp.Instance.Config.Rabbitmq.Password
// , GameServerApp.Instance.Config.Rabbitmq.SSL);
// if (false == _rabbitMQ4Game.StartConsumer4Game())
// {
// Log.getLogger().error($"Failed to start server~!! : Failed to startConsumer RabbitMQ4Game !!!");
// return false;
// }
// ServerAuthClient serverAuthClient = new();
// _ = serverAuthClient.SendIPAsync(ServerName);
// string hostName = Dns.GetHostName();
// // 주기적 실행 task
// // 아래 StartNew의 호출 인자는 Task updateTask = Task.Run(() => Update()); 호출과 같음
// // https://code-maze.com/csharp-task-run-vs-task-factory-startnew/
// /*
// Task updateTask = LogicThread.Factory.StartNew(() => Update(),
// CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
// */
// bool firstInit = true;
// Task updateCUTask = ServerUtil.RunPeriodicTask(async () =>
// {
// try
// {
// await sessionUpdate();
// if (firstInit == true)
// {
// await Task.Run(async Task<bool>? () =>
// {
// await Task.Delay(1000);
// //서버 처음 뜰때 한번 호출 UpdateServerCU 이후에 부르기 위함.
// bool ret = await GameServerApp.Instance.ServerCUStorage.initAddSortedServerKey(
// ServerName,
// serverType,
// myServerInfo.worldId);
// if (ret == false)
// {
// Log.getLogger().error($"Add Sorted Server Key fail.");
// return false;
// }
// return true;
// }, _cts.Token);
// firstInit = false;
// }
// }
// catch (Exception e)
// {
// Log.getLogger().error(e.ToString());
// }
//#if DEBUG
// using (NetServerStats stat = _srv.GetStats())
// {
// //Log.getLogger().info($"tcp RCV:{stat.totalTcpReceiveBytes} tcp SND:{stat.totalTcpSendBytes} udp RCV:{stat.totalUdpReceiveBytes} udp SND:{stat.totalUdpSendBytes}");
// }
//#endif
// },
// TimeSpan.FromMilliseconds(5000), _cts.Token);
// Task updateTask = ServerUtil.RunPeriodicTask(async () =>
// {
// try
// {
// //Stopwatch stopwatch = Stopwatch.StartNew();
// await Update();
// /*stopwatch.Stop();
// if(stopwatch.ElapsedMilliseconds> 1000)
// Log.getLogger().error($"updateTask Slow log {stopwatch.ElapsedMilliseconds}");
// */
// }
// catch (Exception e)
// {
// Log.getLogger().error(e.ToString());
// }
// },
// TimeSpan.FromMilliseconds(300), _cts.Token);
// Task updateLoginTask = ServerUtil.RunPeriodicTask(async () =>
// {
// try
// {
// //Stopwatch stopwatch= Stopwatch.StartNew();
// await ClientSessionManager.Instance.ForEach(async (ClientSession session) =>
// {
// if (session.IsClosedProcessed == false)
// {
// //ClientSessionManager.Instance.ReleaseSession(session);
// //return false;
// await session.KeepLogin();
// await Task.Delay(10);
// }
// return true;
// });
// /*
// stopwatch.Stop();
// if (stopwatch.ElapsedMilliseconds > 1000)
// Log.getLogger().error($"updateLoginTask Slow log {stopwatch.ElapsedMilliseconds}");
// */
// }
// catch (Exception e)
// {
// Log.getLogger().error(e.ToString());
// }
// }, TimeSpan.FromMilliseconds(ServerCommon.Constant.KEEP_LOGIN_UPDATE_TIME), _cts.Token);
// //이벤트 업데이트가 100밀리 세컨드까지 필요할까? 1초면 될듯..
// Task updateEventCheckTask = ServerUtil.RunPeriodicTask(async () =>
// {
// try
// {
// EventUpdate();
// }
// catch (Exception e)
// {
// Log.getLogger().error(e.ToString());
// }
// },
// TimeSpan.FromMilliseconds(1000), _cts.Token);
// //퀘스트는 1초마다 처리해주면 될것 같은데... 이벤트랑 합쳐서 타이머를 돌리는 것도 나쁘지 않을듯....
// Task updateQuestCheckTask = ServerUtil.RunPeriodicTask(async () =>
// {
// try
// {
// await QuestUpdate();
// }
// catch (Exception e)
// {
// Log.getLogger().error(e.ToString());
// }
// },
// TimeSpan.FromMilliseconds(100), _cts.Token);
// if (serverType == ServerType.Game)
// {
// Task updateChannelInfoTask = ServerUtil.RunPeriodicTask(async () =>
// {
// try
// {
// ChannelInfoList.Clear();
// var serverInfoList = await GameServerApp.Instance.ServerCUStorage.
// getGameServerChannelInWorldServerCU(
// GameServer.Instance.ServerName);
// foreach (var channel in serverInfoList)
// {
// ChannelInfo channelInfo = new ChannelInfo();
// channelInfo.Channel = channel.Channel;
// channelInfo.Language = (int)ServerUtil.getLanguageByChannel(channel.Channel);
// channelInfo.Trafficlevel = GetTrafficLevel(channel.Sessions, channel.Capacity);
// ChannelInfoList.Add(channelInfo);
// }
// }
// catch (Exception e)
// {
// Log.getLogger().error(e.ToString());
// }
// }, TimeSpan.FromMilliseconds(ServerCommon.Constant.CHANNEL_UPDATE_TIME), _cts.Token);
// periodicTasks.Add(updateChannelInfoTask);
// }
// if (GameServerApp.Instance.Config.GameGuard == true)
// {
// Task updateGameGuardTask = ServerUtil.RunPeriodicTask(async () =>// -- GameGuard
// {
// try
// {
// await ClientSessionManager.Instance.ForEach(async (ClientSession session) =>
// {
// if (GameGuardHelper.getGameGuardPacket(session.GameGuardInstance, out var packet, out var packetSize) == false)
// {
// await session.Close();
// }
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new();
// clientToGame.Message.GameGuardAuthNoti = new();
// clientToGame.Message.GameGuardAuthNoti.AuthValue.AddRange(Array.ConvertAll<byte, int>(packet, Convert.ToInt32).ToList());
// clientToGame.Message.GameGuardAuthNoti.AuthValueSize = packetSize;
// session.Send(RmiContext.ReliableSend, clientToGame);
// return true;
// });
// }
// catch (Exception e)
// {
// Log.getLogger().error(e.ToString());
// }
// }, TimeSpan.FromMinutes(ServerCommon.Constant.UPDATE_GAMEGUARD_AUTH), _cts.Token);
// periodicTasks.Add(updateGameGuardTask);
// }
// Task updateChatTask = ServerUtil.RunPeriodicTask(async () =>
// {
// NoticeChatManager.Instance.UpdateChat();
// }, TimeSpan.FromMilliseconds(ServerCommon.Constant.NOTICE_CHAT_UPDATE_TIME), _cts.Token);
// var keepPartyTask = PartyManager.Instance.KeepParty(_cts.Token);
// periodicTasks.Add(updateLoginTask);
// periodicTasks.Add(updateTask);
// periodicTasks.Add(updateCUTask);
// periodicTasks.Add(updateChatTask);
// periodicTasks.Add(keepPartyTask);
// periodicTasks.Add(updateEventCheckTask);
// return true;
// }
// public async Task sessionUpdate()
// {
// int roomCapacity = 0;
// if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Indun)
// {
// roomCapacity = InstanceRoomManager.Instance.Capacity;
// }
// (bool ret, _) = await GameServerApp.Instance.ServerCUStorage.UpdateServerCU(
// GameServer.Instance.ServerName,
// GameServer.Instance.myServerInfo.ip,
// GameServer.Instance.myServerInfo.port,
// ClientSessionManager.Instance.Count,
// Constant.g_MaxUser,
// GameServer.Instance.myServerInfo.instanceId,
// GameServer.Instance.myServerInfo.worldId,
// GameServer.Instance.myServerInfo.channel,
// ServerUtil.getLanguageByChannel(GameServer.Instance.myServerInfo.channel),
// roomCapacity);
// if (ret == false)
// {
// Log.getLogger().warn(
// $"GameServerCU Login Update fail {GameServerApp.Instance.Config.GameServerType}{GameServer.Instance.myServerInfo.ip}:{GameServer.Instance.myServerInfo.port} count:{ClientSessionManager.Instance.Count}");
// }
// ServerType serverType = GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel ? ServerType.Game : ServerType.Indun;
// MQHelper.SendSessionCount(GameServer.Instance._rabbitMQ4Game, GameServer.Instance.myServerInfo.instanceId, ClientSessionManager.Instance.Count, (int)serverType, GameServer.Instance.myServerInfo.worldId);
// }
// public async Task StopServer()
// {
// await GameServerApp.Instance.ServerCUStorage.DeleteServerInfo(ServerName);
// _srv.Stop();
// _cts.Cancel();
// _rabbitMQ4Game?.stop();
// if (GameServerApp.Instance.Config.GameGuard == true)
// {
// GameGuardHelper.CloseCSAuth3();
// }
// await NamedPipeMonitor.StopNamedPipeService();
// Task.WaitAll(periodicTasks.ToArray());
// _runTask?.SetResult(true);
// }
// public Task? Running()
// {
// return _runTask?.Task;
// }
// public bool Send(HostID hostID, RmiContext rmi, ClientToGame msg)
// {
// if (msg.Message is null || msg.Message.MsgCase != ClientToGameMessage.MsgOneofCase.MoveActor)
// {
// Log.getLogger().info($"{msg.MsgCase} size:{msg.CalculateSize()}");
// }
// return _proxy.Message(hostID, rmi, msg);
// }
// public bool Send(HostID[] hostID, ClientToGame msg)
// {
// Log.getLogger().info($"{msg.MsgCase} size:{msg.CalculateSize()}");
// return _proxy.Message(hostID, ServerCore.ProudNetHelper.compressRmi(), msg);
// }
// public bool BroadCastingAll(ClientToGame msg)
// {
// Log.getLogger().info($"{msg.MsgCase} size:{msg.CalculateSize()}");
// return _proxy.Message(_srv.GetClientHostIDs(), ServerCore.ProudNetHelper.compressRmi(), msg);
// }
// async Task Update()
// {
// await ProcessBuff();
// }
// private static async Task ProcessBuff()
// {
// await ClientSessionManager.Instance.ForEach((ClientSession session) =>
// {
// session.CheckBuff();
// return Task.FromResult(true);
// });
// }
// void EventUpdate()
// {
// EventManager.Instance.ClaimEventActiveCheck();
// }
// async Task QuestUpdate()
// {
// }
// public List<ChannelInfo> GetChannelInfoList()
// {
// return ChannelInfoList;
// }
// public int GetTrafficLevel(int CurUser, int MaxUser)
// {
// double trafficPercent = (double)CurUser / (double)MaxUser * (double)100;
// int trafficLevel = 0;
// if (0 <= trafficPercent && trafficPercent < 80.0f)
// {
// trafficLevel = 0;
// }
// else if (80.0f <= trafficPercent && trafficPercent < 100.0f)
// {
// trafficLevel = 1;
// }
// else if (100.0f <= trafficPercent)
// {
// trafficLevel = 2;
// }
// return trafficLevel;
// }
// public AtomicBool getUserLoginBlockEnable()
// {
// return m_user_login_block_enable;
// }
// public async Task logoutUserAllByKick()
// {
// var sessions = ClientSessionManager.Instance.getClientSessions().Values.ToList();
// foreach (var session in sessions)
// {
// await ClientSessionManager.Instance.Kick(session.getUserNickname());
// }
// }
// }
//}

View File

@@ -0,0 +1,157 @@
//using ServerCommon;
//using ServerCommon.Redis;
//using ServerCore; using ServerBase;
//using StackExchange.Redis;
//using System.Collections.Concurrent;
//using System.Diagnostics.CodeAnalysis;
//namespace GameServer
//{
// public class GameServerApp : IWithServerMetrics
// {
// public class ForcedMoveConnectInfo
// {
// public string ServerName = string.Empty;
// public string RoomId = string.Empty;
// public Pos Pos = new();
// public DateTime ExpireDate = DateTime.MinValue;
// }
// public static GameServerApp Instance { get; } = new();
// public LoginStorage LoginStorage = new();
// public ServerInfoStorage ServerCUStorage = new();
// public ChatRoomStorage ChatRoomStorage = new();
// public CharacterStorage CharacterStorage = new();
// public InstanceRoomStorage InstanceRoomStorage = new();
// public LastPositionStorage LastPositionStorage = new();
// public AwsNewInstanceInfoStorage awsNewInstanceInfoStorage = new();
// public BuffStorage buffStorage = new ();
// public PartyStorage PartyStorage = new();
// public MoveServerPlayerInfoStorage moveServerPlayerInfoStorage = new();
// public FileConfig Config = new();
// public MainDB MainDB = new();
// ConnectionMultiplexer _connection = default!;
// IDatabase _database = default!;
// ConcurrentDictionary<string, ForcedMoveConnectInfo> forcedMoveInfoFromGM = new();
// public ServerInfoStorage getServerMetrics() => ServerCUStorage;
// public GameServerApp()
// {
// }
// public async Task Init(string configFile, int type)
// {
// try
// {
// Config.LoadConfig(configFile);
// LogicThread.start(Config.SingleThreaded);
// if (type == 1)
// {
// Config.GameServerType = EGameServerType.Indun;
// }
// if (Config.GameServerType == EGameServerType.Indun)
// {
// DumpHelper.Init(Config.DumpDir, "InstanceServer");
// Log.getLogger().info("IndunServer Start");
// }
// else
// {
// DumpHelper.Init(Config.DumpDir, "GameServer");
// Log.getLogger().info("GameServer Start");
// }
// string prefix = string.Empty;
// Log.getLogger().info($"Redis {Config.Redis}");
// //_tw = new StreamWriter($"redis_{Config.GameServerType.ToString()}.log", true);
// //ConnectionMultiplexer.SetFeatureFlag(_tw);
// ConnectionMultiplexer.SetFeatureFlag("preventthreadtheft", true);
// var configObj = ConfigurationOptions.Parse(Config.Redis);
// configObj.SocketManager = SocketManager.Shared;
// _connection = await ConnectionMultiplexer.ConnectAsync(configObj);
// _database = _connection.GetDatabase();
// LoginStorage.Init(_database, prefix);
// ServerCUStorage.Init(_database, prefix);
// ChatRoomStorage.Init(_database, prefix);
// CharacterStorage.Init(_database, prefix);
// InstanceRoomStorage.Init(_database, prefix);
// LastPositionStorage.Init(_database, prefix);
// awsNewInstanceInfoStorage.Init(_database, prefix);
// buffStorage.Init(_database, prefix);
// PartyStorage.Init(_database, prefix);
// moveServerPlayerInfoStorage.Init(_database, prefix);
// MainDB.CreateClient(Config);
// if (await MainDB.CreateDBIfNotExists(false) == false)
// {
// Log.getLogger().error($"Can't Create DB");
// }
// if (Config.NftRule.NftDBAccess)
// {
// var result = await MySqlConnectorHelper.simpleTryConnectToDb(Config.AccountNftDb);
// if(result.isFail())
// {
// var err_msg = $"Failed to connect NFT Db !!! : {result.toBasicString()}";
// Log.getLogger().error(err_msg);
// throw new Exception(err_msg);
// }
// }
// ServerConfigHelper.init(Config);
// //await TestMainDB();
// }
// catch (Exception ex)
// {
// Log.getLogger().error(ex.ToString());
// throw;
// }
// }
// public void Stop()
// {
// LogicThread.join();
// }
// public void SetForecedMoveInfoFromGM(string GMName, ForcedMoveConnectInfo newServerConnectInfo)
// {
// if (!forcedMoveInfoFromGM.TryAdd(GMName, newServerConnectInfo))
// {
// forcedMoveInfoFromGM[GMName] = newServerConnectInfo;
// }
// }
// public bool GetForecedMoveInfoFromGM(string GMName, [MaybeNullWhen(false)] out ForcedMoveConnectInfo outData)
// {
// return forcedMoveInfoFromGM.TryGetValue(GMName, out outData);
// }
// public void UpdateForDeleteForecedMoveInfoFromGM()
// {
// foreach(var Info in forcedMoveInfoFromGM)
// {
// if(Info.Value.ExpireDate < DateTime.UtcNow)
// {
// if(forcedMoveInfoFromGM.TryRemove(Info.Key, out _) == false)
// {
// Log.getLogger().error($"Failed To Remove Data");
// continue;
// }
// }
// }
// }
// }
//}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
//using Amazon.DynamoDBv2.DocumentModel;
//using ServerCommon;
//using ServerCommon.BusinessLogDomain;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Security.Principal;
//using System.Text;
//using System.Threading.Tasks;
//namespace GameServer
//{
// public static class ItemBusinessLogHelper
// {
// public static ItemLogData toItemLogInfo(ItemEntity itemEntity, ItemData itemMetaData, CountDeltaType countDeltaType, int deltaCount, int deltaLevel, List<int> oldAttribute)
// {
// var log_item_info = new ItemLogData();
// log_item_info.setItemLogInfo(itemEntity, itemMetaData, countDeltaType, deltaCount, deltaLevel, oldAttribute);
// return log_item_info;
// }
// //=====================================================================================
// // 비즈니스 로그 주요 함수
// //=====================================================================================
// public static void setItemLogInfo(this ItemLogData logData, ItemEntity itemEntity, ItemData itemMetaData, CountDeltaType countDeltaType, int deltaCount, int deltaLevel, List<int> oldAttribute)
// {
// logData.ItemGUID = itemEntity.Attr.ItemGuid;
// logData.ItemPK = MainDB.MakePK(EEntityType.Item, itemEntity.PK_Guid);
// logData.ItemSK = MainDB.MakePK(EEntityType.Item, itemEntity.SK_Guid);
// logData.CountDeltaType = countDeltaType;
// logData.StackCount = itemEntity.Attr.Count;
// logData.DeltaCount = deltaCount;
// logData.ItemMID = itemEntity.Attr.ItemId;
// logData.ItemName = itemMetaData.Name;
// logData.Level = itemEntity.Attr.Level;
// logData.DeltaLevel = deltaLevel;
// logData.ItemTypeLarge = itemMetaData.TypeLarge.ToString();
// logData.ItemTypeSmall = itemMetaData.TypeSmall.ToString();
// logData.Attribute = itemEntity.Attr.AttributeIds;
// logData.OldAttribute = oldAttribute;
// }
// }
//}

View File

@@ -0,0 +1,154 @@
//using System;
//using System.Collections.Concurrent;
//using System.Collections.Generic;
//using System.Diagnostics.CodeAnalysis;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using ServerCore; using ServerBase;
//using ServerCommon;
//using Nettention.Proud;
//using System.ComponentModel.DataAnnotations;
//using Amazon.DynamoDBv2.Model;
//using Newtonsoft.Json.Bson;
//namespace GameServer
//{
// internal class LandManager
// {
// private static readonly LandManager _instance = new LandManager();
// static LandManager() { }
// private LandManager() { }
// public static LandManager Instance { get { return _instance; } }
// Dictionary<int, LandEntity> Lands = new Dictionary<int, LandEntity>();
// public async Task<bool> LoadDB()
// {
// List<int> landIdList = new();
// foreach (var landData in TableData.Instance._LandTable.Values)
// {
// landIdList.Add(landData.LandId);
// }
// var landEntityList = await GameServerApp.Instance.MainDB.GetLandEntityList(landIdList);
// if (landEntityList == null)
// {
// Log.getLogger().error("entityList == null");
// return false;
// }
// foreach (var landEntity in landEntityList)
// {
// if (!TableData.Instance._LandTable.TryGetValue(landEntity.PK_Id, out _))
// {
// Log.getLogger().error($"Not Exist LandID : {landEntity.PK_Id.ToString()}");
// continue;
// }
// if (!Lands.TryAdd(landEntity.PK_Id, landEntity))
// {
// Log.getLogger().error($"LandManager add fail LandID : {landEntity.PK_Id.ToString()}");
// return false;
// }
// foreach (var prop in landEntity.Attr.PropInfo)
// {
// MapManager.Instance.UpdateProp(prop.Key, prop.Value);
// }
// }
// return true;
// }
// public void SendInfo(HostID hostId)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.LandInfoNoti = new ClientToGameMessage.Types.LandInfoNoti();
// foreach (var land in Lands.Values)
// {
// LandInfo landInfo = new LandInfo();
// landInfo.Id = land.PK_Id;
// landInfo.Owner = land.Attr.Owner;
// landInfo.Name = land.Attr.Name;
// landInfo.Description = land.Attr.Description;
// landInfo.BuildingId = land.Attr.BuildingId;
// clientToGame.Message.LandInfoNoti.List.Add(landInfo);
// }
// GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame);
// }
// public List<int> GetBuildingIdList()
// {
// List<int> returnList = new();
// foreach (var land in Lands.Values)
// {
// returnList.Add(land.Attr.BuildingId);
// }
// return returnList;
// }
// public bool IsBuildingOnLand(int buildingId)
// {
// foreach (var land in Lands.Values)
// {
// if (land.Attr.BuildingId == buildingId)
// return true;
// }
// return false;
// }
// public bool GetLandEntity(int id, [MaybeNullWhen(false)] out LandEntity outEntity)
// {
// return Lands.TryGetValue(id, out outEntity);
// }
// public bool ExchangeLandProp(int landId, string anchorGuid, string itemGuid, out string? oldItemGuid, [MaybeNullWhen(false)] out LandEntity changedLandEntity)
// {
// oldItemGuid = null;
// changedLandEntity = default;
// if (!GetLandEntity(landId, out var landEntity))
// {
// Log.getLogger().error($"Invalid Land Data accountId:{landId}");
// return false;
// }
// // landEntity.Attr.PropInfo.TryGetValue(anchorGuid, out oldItemGuid);
// // landEntity.Attr.PropInfo[anchorGuid] = itemGuid;
// changedLandEntity = landEntity;
// return true;
// }
// public bool ExchangeBuilding(int landId, int buildingId, out int oldBuildingId, [MaybeNullWhen(false)] out LandEntity changedEntity)
// {
// oldBuildingId = default;
// changedEntity = default;
// if (!GetLandEntity(landId, out var landEntity))
// {
// Log.getLogger().error($"Invalid Land Data accountId:{landId}");
// return false;
// }
// oldBuildingId = landEntity.Attr.BuildingId;
// landEntity.Attr.BuildingId = buildingId;
// changedEntity = landEntity;
// return true;
// }
// public void RollBackExchangeBuilding(LandEntity changedEntity, int oldBuildingId)
// {
// changedEntity.Attr.BuildingId = oldBuildingId;
// }
// }
//}

View File

@@ -0,0 +1,43 @@
//using ServerCommon.BusinessLogDomain;
//using ServerCommon;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//namespace GameServer
//{
// public static class MailBusinessLogHelper
// {
// public static MailLogData toMailLogInfo(MailEntity mailEntity)
// {
// var log_mail_info = new MailLogData();
// log_mail_info.setMailLogInfo(mailEntity);
// return log_mail_info;
// }
// //=====================================================================================
// // 비즈니스 로그 주요 함수
// //=====================================================================================
// public static void setMailLogInfo(this MailLogData logData, MailEntity mailEntity)
// {
// logData.MailPK = MainDB.MakePK(mailEntity.entityType, mailEntity.PK_Guid);
// logData.MailSK = MainDB.MakePK(mailEntity.entityType, mailEntity.SK_DateSequence);
// logData.MailKey = mailEntity.Attr.mailKey;
// logData.Title = mailEntity.Attr.title;
// logData.Body = mailEntity.Attr.text;
// logData.IsSystemMail = mailEntity.Attr.isSystemMail;
// logData.IsReadMail = mailEntity.Attr.isRead;
// logData.SenderNickname = mailEntity.Attr.senderNickName;
// logData.SenderGuid = mailEntity.Attr.senderGuid;
// logData.ReceiverNickname = mailEntity.Attr.receiverNickName;
// logData.ReceiverGuid = mailEntity.Attr.receiverGuid;
// foreach(var mailitem in mailEntity.Attr.ItemList)
// {
// logData.MailItems.Add(new() { ItemMID = mailitem.ItemId, ItemCount = mailitem.Count });
// }
// }
// }
//}

View File

@@ -0,0 +1,29 @@
//using ServerCommon.BusinessLogDomain;
//using ServerCommon;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//namespace GameServer
//{
// public static class MailHelper
// {
// public static void setMailInfo(this MailInfo mailInfo, MailEntity mailEntity, EMailType mailType)
// {
// mailInfo.MailKey = mailEntity.Attr.mailKey;
// mailInfo.IsRead = mailEntity.Attr.isRead == true ? 1 : 0;
// mailInfo.IsGetItem = mailEntity.Attr.isGetItem == true ? 1 : 0;
// mailInfo.IsSystemMail = mailEntity.Attr.isSystemMail == true ? 1 : 0;
// mailInfo.NickName = mailType == EMailType.RECEIVED_MAIL ? mailEntity.Attr.senderNickName : mailEntity.Attr.receiverNickName;
// mailInfo.Guid = mailType == EMailType.RECEIVED_MAIL ? mailEntity.Attr.senderGuid : mailEntity.Attr.receiverGuid;
// mailInfo.Title = mailEntity.Attr.title;
// mailInfo.Text = mailEntity.Attr.text;
// mailInfo.CreateTime = mailEntity.Attr.createTime;
// mailInfo.ExpireTime = mailEntity.Attr.expireTime;
// mailInfo.MailType = (int)mailType;
// mailInfo.ItemList.AddRange(mailEntity.Attr.ItemList);
// }
// }
//}

View File

@@ -0,0 +1,219 @@
//using Amazon.DynamoDBv2.DocumentModel;
//using Nettention.Proud;
//using ServerCommon;
//using ServerCommon.BusinessLogDomain;
//using ServerCore; using ServerBase;
//using System.Diagnostics.CodeAnalysis;
//namespace GameServer
//{
// public class MyHome
// {
// MyHomeListEntity _myHomeList = new();
// MyHomeEntity _myHome = new();
// Document _myhomelist_backup_document;
// Document _myhome_backup_document;
// public MyHome () { }
// public int GetMyHomeId() { return _myHome.Attr.MyHomeId; }
// public async Task<bool> LoadDB(string accountGuid)
// {
// var myHomeListDocument = await GameServerApp.Instance.MainDB.GetMyHomeList(accountGuid);
// if (myHomeListDocument == null)
// {
// Log.getLogger().error("myHomeListDocument is null");
// return false;
// }
// if (!_myHomeList.ReadFrom(myHomeListDocument))
// {
// Log.getLogger().error("myHomeList read error");
// return false;
// }
// if (_myHomeList.Attr.myHomeIds.Count == 0)
// {
// await BasicMyHomeListSetting();
// }
// var myHomeDocument = await GameServerApp.Instance.MainDB.GetMyHomeData(accountGuid);
// if (myHomeDocument == null)
// {
// Log.getLogger().error("myHomeDocument is null");
// return false;
// }
// if (!_myHome.ReadFrom(myHomeDocument))
// {
// Log.getLogger().error("myHome read error");
// return false;
// }
// if (_myHome.Attr.MyHomeId == 0)
// {
// await BasicMyHomeSetting();
// }
// return true;
// }
// async Task BasicMyHomeListSetting()
// {
// int defaultMyhomeId = ServerCommon.Constant.DEFAULT_MYHOME_ID;
// if (TableData.Instance._GameConfigDataTable.TryGetValue("DefaultInstanceMyHomeId", out var stringValue))
// {
// if (ServerUtil.MakeStringToInt(stringValue, out var intValue))
// {
// defaultMyhomeId = intValue;
// }
// }
// AddMyHome(defaultMyhomeId);
// await GameServerApp.Instance.MainDB.UpdateDocument(_myHomeList.DocumentForUpdate());
// }
// async Task BasicMyHomeSetting()
// {
// int defaultMyhomeId = ServerCommon.Constant.DEFAULT_MYHOME_ID;
// if (TableData.Instance._GameConfigDataTable.TryGetValue("DefaultInstanceMyHomeId", out var stringValue))
// {
// if (ServerUtil.MakeStringToInt(stringValue, out var intValue))
// {
// defaultMyhomeId = intValue;
// }
// }
// _myHome.Attr.MyHomeId = defaultMyhomeId;
// await GameServerApp.Instance.MainDB.UpdateDocument(_myHome.DocumentForUpdate());
// }
// public void SendInfo(HostID hostId, string accountId)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.MyHomeInfoNoti = new ClientToGameMessage.Types.MyHomeInfoNoti();
// foreach(var myHomeId in _myHomeList.Attr.myHomeIds)
// {
// clientToGame.Message.MyHomeInfoNoti.Ownedlist.Add(myHomeId);
// }
// clientToGame.Message.MyHomeInfoNoti.Info = new();
// clientToGame.Message.MyHomeInfoNoti.Info.Id = _myHome.Attr.MyHomeId;
// clientToGame.Message.MyHomeInfoNoti.Info.FixedMyHomeRoomId = $"myhome:{accountId}";
// foreach (var prop in _myHome.Attr.PropInfo)
// {
// PropInfo propInfo = new PropInfo();
// propInfo.AnchorGuid = prop.Key;
// propInfo.ItemGuid = prop.Value.GuidByType;
// clientToGame.Message.MyHomeInfoNoti.Info.PropLIst.Add(propInfo);
// }
// GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame);
// }
// public bool AddMyHome(int myHomeId)
// {
// if (!TableData.Instance._MyHomeTable.TryGetValue(myHomeId, out _))
// {
// Log.getLogger().error($"myHomeId : {myHomeId} is not tabledata");
// return false;
// }
// _myHomeList.Attr.myHomeIds.Add(myHomeId);
// return true;
// }
// public ServerErrorCode AddMyHome(int myHomeId, out Document? changeDocument, out MyHomeLogInfo myHomeLogInfo)
// {
// changeDocument = default;
// myHomeLogInfo = default;
// if (!TableData.Instance._MyHomeTable.TryGetValue(myHomeId, out _))
// {
// Log.getLogger().error($"myHomeId : {myHomeId} is not tabledata");
// return ServerErrorCode.NotFoundTable;
// }
// if(_myHomeList.Attr.myHomeIds.Contains(myHomeId) == true)
// {
// Log.getLogger().info($"Already Register MyHome. myHomeId : {myHomeId}");
// return ServerErrorCode.AlreadyRegistered;
// }
// MyHomeListEntity changeEntity = new MyHomeListEntity(_myHomeList.DocumentForUpdate());
// changeEntity.Attr.myHomeIds.Add(myHomeId);
// changeDocument = changeEntity.DocumentForUpdate();
// myHomeLogInfo = MyHomeBusinessLogHelper.toMyHomeLogInfo(myHomeId, changeDocument);
// return ServerErrorCode.Success;
// }
// public void UpdateMyHomeToMemory(Document changeDocument)
// {
// _myHomeList.ReadFrom(changeDocument);
// }
// public bool ExchangeMyHome(int newMyHomeId, [MaybeNullWhen(false)] out Document changedDocument) // TODO: 마이홈ID로?? 마이홈아이템ID로??
// {
// changedDocument = default;
// if (!_myHomeList.Attr.myHomeIds.Contains(newMyHomeId))
// return false;
// BackUpMyHome();
// _myHome.Attr.MyHomeId = newMyHomeId;
// _myHome.Attr.PropInfo.Clear();
// changedDocument = _myHome.DocumentForUpdate();
// return true;
// }
// public bool ExchangeMyHomeProp(string anchorGuid, string itemGuid, int itemId, [MaybeNullWhen(false)] out Document changedDocument)
// {
// changedDocument = default;
// if (!TableData.Instance._MyHomeTable.TryGetValue(_myHome.Attr.MyHomeId, out var myHomeData))
// return false;
// if (!MapDataTable.Instance.IsExistAnchor(myHomeData.RoomFile, anchorGuid))
// return false;
// BackUpMyHome();
// AnchorProp prop = new();
// prop.TableId = itemId;
// prop.GuidByType = itemGuid;
// _myHome.Attr.PropInfo[anchorGuid] = prop;
// changedDocument = _myHome.DocumentForUpdate();
// return true;
// }
// public void BackUpMyHome()
// {
// _myhomelist_backup_document = _myHomeList.DocumentForUpdate();
// _myhome_backup_document = _myHome.DocumentForUpdate();
// }
// public void RollBackMyHome()
// {
// _myHomeList.ReadFrom(_myhomelist_backup_document);
// _myHome.ReadFrom(_myhome_backup_document);
// }
// }
//}

View File

@@ -0,0 +1,153 @@
//using Amazon.Runtime.Internal.Util;
//using Google.Protobuf.WellKnownTypes;
//using ServerCommon;
//using ServerCore; using ServerBase;
//using System;
//using System.Collections.Concurrent;
//using System.Collections.Generic;
//using System.Data;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using static GameServer.ClientSessionManager;
//using static GameServer.NoticeChatManager;
//using static ServerCommon.BuffData;
//namespace GameServer
//{
// public class NoticeChatManager
// {
// private static readonly NoticeChatManager _instance = new();
// public static NoticeChatManager Instance { get { return _instance; } }
// NoticeChatEntity noticeChatEntity = new();
// public async Task LoadNoticeChat()
// {
// var document = await GameServerApp.Instance.MainDB.GetNoticeChatList();
// if (document == null)
// {
// return;
// }
// noticeChatEntity = new NoticeChatEntity(document);
// List<NoticeChatInfo> CopyNoticeChats = CopyData();
// List<NoticeChatInfo> removeNoticeChats = new();
// foreach (var info in CopyNoticeChats)
// {
// while (true)
// {
// if (info.repeatCount == 0)
// {
// removeNoticeChats.Add(info);
// break;
// }
// if (info.startTime.ToDateTime() > DateTime.UtcNow)
// {
// break;
// }
// info.repeatCount -= 1;
// info.startTime = info.startTime.ToDateTime().AddMinutes(info.repeatMinuteTime).ToTimestamp();
// }
// }
// foreach(var info in removeNoticeChats)
// {
// CopyNoticeChats.Remove(info);
// }
// noticeChatEntity.Attr.noticeList = CopyNoticeChats;
// }
// public void UpdateChat()
// {
// List<NoticeChatInfo> CopyNoticeChats = CopyData();
// foreach (var info in CopyNoticeChats)
// {
// if (info.startTime <= DateTime.UtcNow.ToTimestamp())
// {
// if (info.messageType != 10 && info.messageType != 11)
// {
// Log.getLogger().error($"NoticeChatInfo messageType is invalid. - GMTOOL Data. messageType : {info.messageType}");
// DelChat(info);
// continue;
// }
// if (info.repeatCount <= 0)
// {
// DelChat(info);
// continue;
// }
// List<LanguageChatInfo> languageChatInfos = new();
// foreach (var detail in info.detailInfos)
// {
// ClientToGame clientMsg = new();
// clientMsg.Message = new ClientToGameMessage();
// clientMsg.Message.Chat = new();
// clientMsg.Message.Chat.Sender = info.sender;
// clientMsg.Message.Chat.Type = info.messageType;
// clientMsg.Message.Chat.Message = detail.chatMessage;
// languageChatInfos.Add(new LanguageChatInfo() { languageType = detail.language, message = clientMsg });
// }
// ClientSessionManager.Instance.ChatBroadcast(languageChatInfos);
// info.repeatCount -= 1;
// info.startTime = info.startTime.ToDateTime().AddMinutes(info.repeatMinuteTime).ToTimestamp();
// }
// }
// }
// private List<NoticeChatInfo> CopyData()
// {
// return new List<NoticeChatInfo>(noticeChatEntity.Attr.noticeList);
// }
// public void DelChat(NoticeChatInfo noticeChatInfo)
// {
// noticeChatEntity.Attr.noticeList.Remove(noticeChatInfo);
// }
// public async Task TempFuncAddData(int messageType, string KoMessage, string EnMessage)
// {
// if(messageType != 10 && messageType != 11)
// {
// return;
// }
// int id = 0;
// foreach (var noticeChatInfo in noticeChatEntity.Attr.noticeList)
// {
// if (id < noticeChatInfo.Id)
// {
// id = noticeChatInfo.Id;
// }
// }
// NoticeChatInfo noticeChat = new();
// noticeChat.Id = id + 1;
// noticeChat.startTime = DateTime.UtcNow.ToTimestamp();
// noticeChat.repeatCount = 10;
// noticeChat.repeatMinuteTime = 1;
// noticeChat.sender = "[GM]그리노스";
// noticeChat.messageType = messageType;
// List<DetailInfo> detailInfos = new();
// detailInfos.Add(new DetailInfo() { chatMessage = $"{noticeChat.Id} {KoMessage}", language = LanguageType.Ko });
// detailInfos.Add(new DetailInfo() { chatMessage = $"{noticeChat.Id} {EnMessage}", language = LanguageType.En });
// detailInfos.Add(new DetailInfo() { chatMessage = $"{noticeChat.Id} ภาษาไทย", language = LanguageType.Th });
// noticeChat.detailInfos.AddRange(detailInfos);
// noticeChatEntity.Attr.noticeList.Add(noticeChat);
// if (await GameServerApp.Instance.MainDB.UpdateNoticeChat(noticeChatEntity) == false)
// {
// return;
// }
// }
// }
//}

View File

@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServerCore; using ServerBase;
using ServerCommon;
using Nettention.Proud;
using System.Diagnostics.CodeAnalysis;
using Amazon.DynamoDBv2.DocumentModel;
namespace GameServer
{
public class OwnedBlockList
{
//BlockListEntity blockListEntity = new();
public OwnedBlockList() { }
// public async Task<bool> LoadDB(string accountGuid)
// {
// // var data = await GameServerApp.Instance.MainDB.GetBlockList(accountGuid);
// // if (data == null)
// // {
// // Log.getLogger().error("GetBlockList dataList is null");
// // return false;
// // }
// //
// // blockListEntity = data;
// return true;
// }
// public bool BlockUser(string myGuid, string targetGuid, string targetNickName, [MaybeNullWhen(false)] out Document document)
// {
// document = null;
// BlockInfo blockInfo = blockListEntity.MakeNewBlockInfo(targetGuid, targetNickName);
// if (!blockListEntity.Attr.blockList.TryAdd(targetGuid, blockInfo))
// {
// Log.getLogger().error($"BlockList TryAdd Error myGuid : {myGuid}, targetGuid = {targetGuid}, targetNickName = {targetNickName}");
// return false;
// }
// document = new();// blockListEntity.DocumentForInsert(myGuid, blockInfo);
//
// return true;
// }
//
// public List<BlockInfo> GetBlockList()
// {
// return blockListEntity.Attr.blockList.Values.ToList();
// }
//
// public BlockInfo? GetBlockInfo(string guid)
// {
// if (!blockListEntity.Attr.blockList.TryGetValue(guid, out var blockInfo))
// {
// //Log.getLogger().error($"GetBlockInfo TryGetValue return false guid : {guid}");
// return null;
// }
//
// return blockInfo;
// }
//
// public bool isBlockUser(string guid)
// {
// return blockListEntity.Attr.blockList.ContainsKey(guid);
// }
// public async Task<bool> isBlocked(string? myGuid, string guid)
// {
// if (myGuid == null) return false;
//
// BlockListAttr? attr = await getOthersBlockList(guid);
// if (attr is null) return false;
//
// return attr.blockList.ContainsKey(myGuid);
// }
// public async Task<BlockListAttr?> getOthersBlockList(string accountGuid)
// {
// // BlockListEntity? entity = await GameServerApp.Instance.MainDB.GetBlockList(accountGuid);
// // if (entity is null) return null;
//
// // return entity.Attr;
// return null;
// }
// public bool CancelBlock(string myGuid, string targetGuid, [MaybeNullWhen(false)] out Document document)
// {
// //document = blockListEntity.DocumentForDelete(myGuid, targetGuid);
// document = new();
// if (!blockListEntity.Attr.blockList.Remove(targetGuid))
// {
// Log.getLogger().warn($"BlockList TryAdd Error myGuid : {myGuid}, targetGuid = {targetGuid}");
// }
// return true;
// }
//
// public bool CheckBlockUser(string targetGuid)
// {
// return blockListEntity.Attr.blockList.ContainsKey(targetGuid);
// }
//
// public void SendInfo(HostID hostId)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.BlockListNoti = new ClientToGameMessage.Types.BlockListNoti();
// clientToGame.Message.BlockListNoti.BlockList.AddRange(blockListEntity.Attr.blockList.Values.ToArray());
// //GameServer.Instance._proxy.Message(hostId, RmiContext.ReliableSend, clientToGame);
// }
}
}

View File

@@ -0,0 +1,338 @@
//using Amazon.OpenSearchService.Model.Internal.MarshallTransformations;
//using Amazon.Runtime.Internal.Transform;
//using Google.Protobuf.WellKnownTypes;
//using Nettention.Proud;
//using Newtonsoft.Json;
//using ServerCommon;
//using ServerCore; using ServerBase;
//using System;
//using System.Collections.Concurrent;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using static ServerCommon.BuffData;
//namespace GameServer
//{
// public class OwnedBuff
// {
// Dictionary<EBuffCategory, ConcurrentDictionary<int,Buff>> BuffInfo = new ();
// string AccountId = string.Empty;
// Player? player = null;
// public async Task InitLoadRedisBuff(string accountId, Player player)
// {
// AccountId = accountId;
// this.player = player;
// List<AttributeInfo> attributeList = new();
// foreach (EBuffCategory category in System.Enum.GetValues(typeof(EBuffCategory)))
// {
// var buffchannelInfo = new ConcurrentDictionary<int, Buff>();
// BuffInfo.TryAdd(category, buffchannelInfo);
// }
// var BuffList = await GameServerApp.Instance.buffStorage.GetBuffInfo(AccountId);
// if (BuffList != null)
// {
// foreach(var buff in BuffList)
// {
// if (!TableData.Instance._BuffTable.TryGetValue(buff.BuffId, out var buffData))
// {
// Log.getLogger().error($"Not Found Table key : {buff.BuffId}");
// continue;
// }
// if(BuffInfo[buffData.BuffCategory].TryAdd(buffData.BuffChannel, buff) == false)
// {
// Log.getLogger().error($"TryAdd Failed. buffCategoty : {buffData.BuffCategory}, BuffChannel {buffData.BuffChannel}");
// continue;
// }
// changeAttribute(buff.BuffId, false);
// }
// }
// }
// private void changeAttribute(int buffId, bool isDelete)
// {
// if(player == null)
// {
// return;
// }
// int constant = isDelete ? -1 : 1;
// if (!TableData.Instance._BuffTable.TryGetValue(buffId, out var buffData))
// {
// Log.getLogger().error($"Not Found Table key : {buffId}");
// return;
// }
// foreach (var buffAttribute in buffData.traitsInfos)
// {
// if (TableData.Instance._AttributeDefinitionDataTable.TryGetValue(buffAttribute.Attrivute, out var attributeData) == false)
// {
// Log.getLogger().error($"TryAdd Failed. buffAttribute.Attrivute : {buffAttribute.Attrivute}");
// continue;
// }
// if (buffAttribute.Operation == "Sub")
// {
// constant *= -1;
// }
// player.ApplyAttribute(attributeData.ID, buffAttribute.Value * constant);
// }
// }
// //안의 값까지의 깊은 복사가 아닌 컨테이너만 복사.
// public Dictionary<EBuffCategory, Dictionary<int, Buff>> getCopyBuff()
// {
// Dictionary<EBuffCategory, Dictionary<int, Buff>> copyBuff = BuffInfo.ToDictionary(a => a.Key, b => new Dictionary<int, Buff>());
// foreach (var buffChannel in BuffInfo)
// {
// copyBuff[buffChannel.Key] = buffChannel.Value.ToDictionary(a => a.Key, b => b.Value);
// }
// return copyBuff;
// }
// public bool getBuff(EBuffCategory category, int channel, out Buff? buff)
// {
// return BuffInfo[category].TryGetValue(channel, out buff);
// }
// public ServerErrorCode AddBuffProcess(int buffId, out Buff? startBuff, out Buff? endBuff)
// {
// startBuff = null;
// endBuff = null;
// if (!TableData.Instance._BuffTable.TryGetValue(buffId, out var buffData))
// {
// Log.getLogger().error($"Not Found Table key : {buffId}");
// return ServerErrorCode.NotFoundBuffTableId;
// }
// var copyBuffInfo = getCopyBuff();
// //카테고리별 버프
// if (copyBuffInfo.TryGetValue(buffData.BuffCategory, out var buffchannelInfo) == false)
// {
// Log.getLogger().error($"Not Found Table key : {buffData.BuffCategory}");
// return ServerErrorCode.NotFoundBuffTableId;
// }
// //이미 동일한 채널의 버프가 있는경우
// if (buffchannelInfo.TryGetValue(buffData.BuffChannel, out var buffInfo) == true)
// {
// if (!TableData.Instance._BuffTable.TryGetValue(buffInfo.BuffId, out var oldBuffData))
// {
// Log.getLogger().error($"Not Found Table key : {buffInfo.BuffId}");
// return ServerErrorCode.NotFoundBuffTableId;
// }
// //새로운것이 더 높거나 같으면 교체
// if(oldBuffData.BuffPriority <= buffData.BuffPriority)
// {
// DelBuff(buffData.BuffCategory, buffData.BuffChannel, out var delBuff);
// AddBuff(buffData, out startBuff);
// }
// return ServerErrorCode.Success;
// }
// string MaxBuffCategoty = "";
// switch (buffData.BuffCategory)
// {
// case EBuffCategory.NORMAL: MaxBuffCategoty = "MaxNormalBuffNum"; break;
// case EBuffCategory.INSTANCE: MaxBuffCategoty = "MaxInstanceBuffNum"; break;
// case EBuffCategory.EVENT: MaxBuffCategoty = "MaxEventBuffNum"; break;
// case EBuffCategory.TOOL: MaxBuffCategoty = "MaxToolBuffNum";break;
// case EBuffCategory.WEAR: MaxBuffCategoty = "MaxWearBuffNum"; break;
// default:
// break;
// }
// if (!TableData.Instance._GameConfigDataTable.TryGetValue(MaxBuffCategoty, out var strMaxBuffCount))
// {
// Log.getLogger().error($"Not Found Table key : {MaxBuffCategoty}");
// return ServerErrorCode.NotFoundTable;
// }
// if(ServerUtil.MakeStringToInt(strMaxBuffCount, out var maxBuffCount) == false)
// {
// Log.getLogger().error($"string to int parse failed. data : {strMaxBuffCount}");
// return ServerErrorCode.TableError;
// }
// Timestamp? removeBuffStartTime = null;
// int removeBuffChannel = -1;
// //최대 버퍼수량을 초과했을경우 가장 오래된 버프 제거
// if (buffchannelInfo.Count >= maxBuffCount)
// {
// foreach(var oldBuffInfo in buffchannelInfo)
// {
// if(removeBuffStartTime == null || removeBuffStartTime > oldBuffInfo.Value.BuffStartTime)
// {
// removeBuffStartTime = oldBuffInfo.Value.BuffStartTime;
// removeBuffChannel = oldBuffInfo.Key;
// }
// }
// if(removeBuffStartTime != null)
// {
// DelBuff(buffData.BuffCategory, removeBuffChannel, out var delBuff);
// }
// }
// AddBuff(buffData, out startBuff);
// return ServerErrorCode.Success;
// }
// public ServerErrorCode DelBuffProcess(int buffId, out Buff? delBuff)
// {
// delBuff = null;
// if (!TableData.Instance._BuffTable.TryGetValue(buffId, out var buffData))
// {
// return ServerErrorCode.NotFoundBuffTableId;
// }
// if(DelBuff(buffData.BuffCategory, buffData.BuffChannel, out delBuff) == false)
// {
// return ServerErrorCode.NotFoundBuff;
// }
// return ServerErrorCode.Success;
// }
// public async Task<bool> MovePlace(EPlaceType toMove)
// {
// var copyBuffInfo = getCopyBuff();
// List<Buff> buffListForRedis = new ();
// List<Buff> delBuff = new();
// foreach (var ChannelBuff in copyBuffInfo)
// {
// foreach(var buff in ChannelBuff.Value)
// {
// if (!TableData.Instance._BuffTable.TryGetValue(buff.Value.BuffId, out var buffData))
// {
// Log.getLogger().error($"Not Found Table key : {buff.Value.BuffId}");
// continue;
// }
// if(isRemainBuff(toMove, buffData) == true)
// {
// buffListForRedis.Add(buff.Value);
// continue;
// }
// delBuff.Add(buff.Value);
// }
// }
// if(await GameServerApp.Instance.buffStorage.SaveBuff(AccountId, buffListForRedis) == false)
// {
// Log.getLogger().error($"SaveBuff Failed. AccountId : {AccountId}");
// return false;
// }
// foreach(var buff in delBuff)
// {
// changeAttribute(buff.BuffId, true);
// }
// var session = ClientSessionManager.Instance.GetSessionByName(AccountId);
// if (session == null)
// {
// return true;
// }
// ClientToGame message = new();
// message.Message = new();
// message.Message.DelBuffListNoti = new();
// message.Message.DelBuffListNoti.DelBuffList.AddRange(delBuff);
// session.Send(RmiContext.ReliableSend, message);
// return true;
// }
// private bool isRemainBuff(EPlaceType toMove, BuffData buffData)
// {
// switch (toMove)
// {
// case EPlaceType.Concert: return buffData.IsConcertRemain;
// case EPlaceType.Meeting: return buffData.IsMeetingRemain;
// case EPlaceType.MyHome: return buffData.IsMyhomeRemain;
// case EPlaceType.Movie: return buffData.IsMovieRemain;
// case EPlaceType.World: return buffData.IsNormalRemain;
// case EPlaceType.Instance:
// case EPlaceType.DressRoom:
// default:
// return false;
// }
// }
// private bool AddBuff(BuffData buffData, out Buff? buff)
// {
// buff = null;
// if (BuffInfo.TryGetValue(buffData.BuffCategory, out var buffchannelInfo) == false)
// {
// return false;
// }
// buff = new();
// buff.BuffId = buffData.BuffId;
// buff.BuffStartTime = DateTime.UtcNow.ToTimestamp();
// buff.Step = 0;
// buff.RandomState = 0;
// buff.ActionStartTime = 0;
// if(buffchannelInfo.TryAdd(buffData.BuffChannel, buff) == false)
// {
// return false;
// }
// changeAttribute(buffData.BuffId, false);
// return true;
// }
// private bool DelBuff(EBuffCategory category, int channel, out Buff? delBuff)
// {
// delBuff = null;
// if (BuffInfo.TryGetValue(category, out var buffchannelInfo) == false)
// {
// return false;
// }
// if(buffchannelInfo.Remove(channel, out delBuff) == false)
// {
// return false;
// }
// changeAttribute(delBuff.BuffId, true);
// return true;
// }
// public void SendInfo(HostID hostId)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.LoginBuffNoti = new ClientToGameMessage.Types.LoginBuffNoti();
// clientToGame.Message.LoginBuffNoti.BuffInfo = new BuffInfo();
// var buffInfo = getCopyBuff();
// foreach (var channelBuff in buffInfo)
// {
// clientToGame.Message.LoginBuffNoti.BuffInfo.Buff.AddRange(channelBuff.Value.Values.AsEnumerable());
// }
// GameServer.Instance._proxy.Message(hostId, RmiContext.ReliableSend, clientToGame);
// }
// }
//}

View File

@@ -0,0 +1,176 @@
//using System;
//using System.Collections.Concurrent;
//using System.Collections.Generic;
//using System.Diagnostics.CodeAnalysis;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using ServerCommon;
//using ServerCore; using ServerBase;
//using Nettention.Proud;
//namespace GameServer
//{
// public class OwnedBuilding
// {
// BuildingListEntity BuildingList = new();
// ConcurrentDictionary<int, BuildingEntity> Buildings = new();
// public OwnedBuilding() { }
// public async Task<bool> LoadDB(string accountGuid)
// {
//// var buildingListDocument = await GameServerApp.Instance.MainDB.GetBuildingList(accountGuid);
//// if (buildingListDocument == null)
//// {
//// Log.getLogger().error("document is null");
//// return false;
//// }
//// if (!BuildingList.ReadFrom(buildingListDocument))
//// {
//// Log.getLogger().error("RoomList read error");
//// return false;
//// }
////
//// var buildingEntityList = await GameServerApp.Instance.MainDB.GetBuildingEntityList(BuildingList.Attr.buildingIds.ToList());
//// if (buildingEntityList == null)
//// {
//// Log.getLogger().error("roomList is null");
//// return false;
//// }
////
//// foreach (var buildingEntity in buildingEntityList)
//// {
//// if (!Buildings.TryAdd(buildingEntity.PK_Id, buildingEntity))
//// {
//// Log.getLogger().error($"BuildingEntity buildingId : {buildingEntity.PK_Id} - add fail");
//// return false;
//// }
//// }
// return true;
// }
// public void SendInfo(HostID hostId)
// {
// // TODO: 소유빌딩이 없는 경우 패킷 보낼지 말지 결정
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.OwnedBuildingNoti = new ClientToGameMessage.Types.OwnedBuildingNoti();
// foreach (var building in Buildings.Values)
// {
// BuildingInfo data = new BuildingInfo();
// data.Id = building.PK_Id;
// data.Owner = building.Attr.Owner;
// data.Name = building.Attr.Name;
// data.Description = building.Attr.Description;
// foreach (var prop in building.Attr.PropInfo)
// {
// PropInfo propInfo = new();
// propInfo.AnchorGuid = prop.Key;
// propInfo.TableId = prop.Value.TableId;
// data.PropList.Add(propInfo);
// }
// foreach (var instance in building.Attr.FloorInfo)
// {
// SlotInfo slot = new SlotInfo();
// slot.Slot = instance.Key;
// slot.Id = instance.Value;
// data.RoomList.Add(slot);
// }
// clientToGame.Message.OwnedBuildingNoti.List.Add(data);
// }
// //GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame);
// }
// public bool GetBuildingEntity(int buildingId, [MaybeNullWhen(false)] out BuildingEntity outEntity)
// {
// return Buildings.TryGetValue(buildingId, out outEntity);
// }
// public bool ClearBuildingPropAndInstance(int buildingId, [MaybeNullWhen(false)] out BuildingEntity clearedEntity)
// {
// clearedEntity = default;
// if (!GetBuildingEntity(buildingId, out var buildingEntity))
// {
// Log.getLogger().error($"Not OwnedBuilding BuildingId:{buildingId}");
// return false;
// }
// buildingEntity.Attr.PropInfo.Clear();
// buildingEntity.Attr.FloorInfo.Clear();
// clearedEntity = buildingEntity;
// return true;
// }
// public bool IsChangeable(int buildingId, string guid) // TODO: accountId?? accountGuid?? characterGuid??
// {
// if (!Buildings.TryGetValue(buildingId, out var buildingData))
// {
// Log.getLogger().error($"Not OwnedBuilding BuildingId:{buildingId}");
// return false;
// }
// if (buildingData.Attr.Owner != guid)
// return false;
// return false;
// }
// public bool ExchangeProp(int buildingId, string anchorGuid, string itemGuid, [MaybeNullWhen(false)] out BuildingEntity changedEntity) // TODO: ID로?? 아이템ID로??
// {
// changedEntity = default;
// if (!GetBuildingEntity(buildingId, out var buildingEntity))
// {
// Log.getLogger().error($"Not OwnedBuilding BuildingId:{buildingId}");
// return false;
// }
// changedEntity = buildingEntity;
// return true;
// }
// //public void RollBackExchangeProp(BuildingEntity changedEntity, string anchorGuid, string oldItemGuid)
// //{
// // changedEntity.Attr.PropInfo[anchorGuid] = oldItemGuid;
// //}
// public bool ExchangeInstance(int buildingId, int floor, int instanceId, out int oldInstanceId, [MaybeNullWhen(false)] out BuildingEntity changedEntity)
// {
// oldInstanceId = 0;
// changedEntity = default;
// if (!GetBuildingEntity(buildingId, out var buildingEntity))
// {
// Log.getLogger().error($"Not OwnedBuilding BuildingId:{buildingId}");
// return false;
// }
// buildingEntity.Attr.FloorInfo.TryGetValue(floor, out oldInstanceId);
// buildingEntity.Attr.FloorInfo[floor] = instanceId;
// changedEntity = buildingEntity;
// return true;
// }
// public void RollBackExchangeInstance(BuildingEntity changedEntity, int floor, int oldInstanceId)
// {
// changedEntity.Attr.FloorInfo[floor] = oldInstanceId;
// }
// }
//}

View File

@@ -0,0 +1,266 @@
//using Nettention.Proud;
//using ServerCore; using ServerBase;
//using System;
//using System.Collections.Concurrent;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using static ClientToGameRes.Types;
//using Amazon.DynamoDBv2.DocumentModel;
//using ServerCommon;
//using Amazon.OpenSearchService.Model;
//using System.Linq.Expressions;
//using Microsoft.VisualBasic;
//namespace GameServer
//{
// public class OwnedCart
// {
// string accountGuid = string.Empty;
// CartEntity cartEntity = new();
// public async Task<bool> LoadDB(string accountGuid)
// {
// this.accountGuid = accountGuid;
// var cartEntity = await GameServerApp.Instance.MainDB.GetCart(accountGuid);
// if (cartEntity is null)
// {
// Log.getLogger().error("cartEntity == null");
// return false;
// }
// foreach(var selltype in Enum.GetValues<ECurrencyType>())
// {
// if(cartEntity.Attr.ItemCartInfo.ContainsKey(selltype) == false)
// {
// cartEntity.Attr.ItemCartInfo[selltype] = new List<CartItemInfo>();
// }
// }
// this.cartEntity = cartEntity;
// return true;
// }
// public void UpdateDBToMemory(Document document)
// {
// cartEntity.ReadFrom(document);
// }
// public Dictionary<ECurrencyType,List<CartItemInfo>> GetCart()
// {
// return cartEntity.Attr.ItemCartInfo;
// }
// private bool GetBuyType(int itemId, out ECurrencyType type)
// {
// type = ECurrencyType.GOLD;
// if (TableData.Instance._ItemTable.TryGetValue(itemId, out var itemData) == false)
// {
// Log.getLogger().error($"Not Found ItemTableId. itemTableId:{itemId}");
// return false;
// }
// type = itemData.BuyType;
// return true;
// }
// public CartItemInfo? FindItem(CartEntity newCartEntity, CartItemInfo itemInfo, ECurrencyType sellType)
// {
// foreach (var Item in newCartEntity.Attr.ItemCartInfo[sellType])
// {
// if (Item.ItemGuid == string.Empty)
// {
// if (Item.ItemId != itemInfo.ItemId)
// {
// continue;
// }
// }
// else
// {
// if (Item.ItemGuid != itemInfo.ItemGuid)
// {
// continue;
// }
// }
// return Item;
// }
// return null;
// }
// public ServerErrorCode AddCart(CartItemInfo itemInfo, out CartEntity newCartEntity, out CartItemInfo? newCartItemInfo)
// {
// newCartEntity = new CartEntity(cartEntity.DocumentForUpdate());
// newCartItemInfo = default;
// if (itemInfo.ItemGuid != string.Empty)
// {
// //상점 구현후 구현
// return ServerErrorCode.NotImplemented;
// }
// if (CompareBuyType(itemInfo.ItemId, itemInfo.BuyType, out var buyType) == false)
// {
// Log.getLogger().error("CompareBuyType Failed.");
// return ServerErrorCode.CartSellTypeMissMatchWithTable;
// }
// newCartItemInfo = FindItem(newCartEntity, itemInfo, buyType);
// if(newCartItemInfo == null)
// {
// if(newCartEntity.Attr.ItemCartInfo[buyType].Count >= 20)
// {
// Log.getLogger().error($"cart is Full. itemId : {itemInfo.ItemId}");
// return ServerErrorCode.CartisFull;
// }
// newCartEntity.Attr.ItemCartInfo[buyType].Add(itemInfo);
// newCartItemInfo = itemInfo;
// }
// else
// {
// if(newCartItemInfo.Count + itemInfo.Count > 99)
// {
// Log.getLogger().error($"FullStack of this item in cart. itemId : {newCartItemInfo.ItemId}");
// return ServerErrorCode.CartFullStackofItem;
// }
// newCartItemInfo.Count += itemInfo.Count;
// }
// return ServerErrorCode.Success;
// }
// public void DelCart(List<CartItemInfo> itemInfos, out Document? dBDocument, out bool isRemoveItem)
// {
// CartEntity newCartEntity = new CartEntity(cartEntity.DocumentForUpdate());
// isRemoveItem = false;
// dBDocument = null;
// foreach (CartItemInfo itemInfo in itemInfos)
// {
// if (CompareBuyType(itemInfo.ItemId, itemInfo.BuyType, out var buyType) == false)
// {
// Log.getLogger().error("CompareBuyType Failed.");
// return;
// }
// var findItem = FindItem(newCartEntity, itemInfo, buyType);
// if (findItem == null)
// {
// Log.getLogger().error("Not found itemid.");
// return;
// }
// else
// {
// if (findItem.Count < itemInfo.Count)
// {
// Log.getLogger().error("Invalid item Count.");
// return;
// }
// else if (findItem.Count - itemInfo.Count == 0)
// {
// newCartEntity.Attr.ItemCartInfo[buyType].Remove(findItem);
// isRemoveItem = true;
// }
// else
// {
// findItem.Count -= itemInfo.Count;
// }
// }
// }
// dBDocument = newCartEntity.DocumentForUpdate();
// }
// public void BuyCart(List<CartItemInfo> itemInfoList, out Document? dBDocument)
// {
// CartEntity newCartEntity = new CartEntity(cartEntity.DocumentForUpdate());
// dBDocument = null;
// foreach (var itemInfo in itemInfoList)
// {
// if (CompareBuyType(itemInfo.ItemId, itemInfo.BuyType, out var buyType) == false)
// {
// Log.getLogger().error("CompareBuyType Failed.");
// return;
// }
// var findItem = FindItem(newCartEntity, itemInfo, buyType);
// if (findItem == null)
// {
// Log.getLogger().error("Not found itemid.");
// return;
// }
// else
// {
// if (findItem.Count < itemInfo.Count)
// {
// Log.getLogger().error("Argument count is bigger then cart Item count.");
// return;
// }
// }
// }
// foreach (var itemInfo in itemInfoList)
// {
// if(CompareBuyType(itemInfo.ItemId, itemInfo.BuyType, out var buyType) == false)
// {
// Log.getLogger().error("CompareBuyType Failed.");
// return;
// }
// var findItem = FindItem(newCartEntity, itemInfo, buyType);
// if (findItem != null)
// {
// findItem.Count -= itemInfo.Count;
// if (findItem.Count == 0)
// {
// newCartEntity.Attr.ItemCartInfo[buyType].Remove(findItem);
// }
// }
// }
// dBDocument = newCartEntity.DocumentForUpdate();
// }
// private bool CompareBuyType(int itemId, string compareBuyType, out ECurrencyType requestBuyType)
// {
// requestBuyType = ECurrencyType.GOLD;
// try
// {
// requestBuyType = Enum.Parse<ECurrencyType>(compareBuyType);
// }
// catch (Exception ex)
// {
// Log.getLogger().error($"IteamTable BuyType is invalid. exception : {ex.ToString()}");
// return false;
// }
// ECurrencyType BuyType;
// if (GetBuyType(itemId, out BuyType) == false)
// {
// Log.getLogger().error($"Miss Match SellType. Table SellType : {BuyType}, request item SellType : {compareBuyType}");
// return false;
// }
// if (BuyType != requestBuyType)
// {
// Log.getLogger().error($"Miss Match SellType. Table SellType : {BuyType}, request item SellType : {compareBuyType}");
// return false;
// }
// return true;
// }
// public void SendInfoFromLogin(HostID hostId)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.CartNoti = new ClientToGameMessage.Types.CartNoti();
// foreach(var itemCartInfoList in cartEntity.Attr.ItemCartInfo)
// {
// clientToGame.Message.CartNoti.ItemList.AddRange(itemCartInfoList.Value);
// }
// GameServer.Instance._proxy.Message(hostId, RmiContext.ReliableSend, clientToGame);
// }
// }
//}

View File

@@ -0,0 +1,86 @@
//using System;
//using System.Collections.Generic;
//using System.Diagnostics.CodeAnalysis;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using ServerCommon;
//using ServerCore; using ServerBase;
//using Nettention.Proud;
//namespace GameServer
//{
// public class OwnedLand
// {
// LandListEntity LandList = new();
// public OwnedLand() { }
// public async Task<bool> LoadDB(string accountGuid, string eoa)
// {
// var landListDocument = await GameServerApp.Instance.MainDB.GetLandList(accountGuid);
// if (landListDocument == null)
// {
// Log.getLogger().error("document is null");
// return false;
// }
// if (!LandList.ReadFrom(landListDocument))
// {
// Log.getLogger().error("LandList read error");
// return false;
// }
// if (GameServerApp.Instance.Config.NftRule.NftDBAccess)
// {
// var (error_code, tokenInfos) = await NFTHelper.getLandNFTs(eoa);
// if (error_code.isFail() || tokenInfos == null)
// {
// Log.getLogger().error($"GetLandNFTs Fail");
// return false;
// }
// LandListAttr landListAttr = new LandListAttr();
// foreach (var tokenInfo in tokenInfos)
// {
// if (tokenInfo.is_staked == 0)
// continue;
// landListAttr.landIds.Add(tokenInfo.metaId);
// }
// var newLandListDocument = MainDB.DocumentForInsert(EEntityType.LandList, accountGuid, string.Empty, landListAttr);
// await GameServerApp.Instance.MainDB.UpdateDocument(newLandListDocument);
// if (!LandList.ReadFrom(newLandListDocument))
// {
// Log.getLogger().error("LandList read error");
// return false;
// }
// }
// return true;
// }
// public void SendInfo(HostID hostId)
// {
// // TODO: 소유지가 없는 경우 패킷 보낼지 말지 결정
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.OwnedLandNoti = new ClientToGameMessage.Types.OwnedLandNoti();
// foreach (var landId in LandList.Attr.landIds)
// {
// clientToGame.Message.OwnedLandNoti.List.Add(landId);
// }
// GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame);
// }
// public bool IsOwnedLand(int landId)
// {
// return LandList.Attr.landIds.TryGetValue(landId, out _);
// }
// }
//}

View File

@@ -0,0 +1,346 @@
//using Nettention.Proud;
//using ServerCore; using ServerBase;
//using Google.Protobuf.WellKnownTypes;
//using ServerCommon;
//using Amazon.CloudWatchLogs.Model.Internal.MarshallTransformations;
//using ServerCommon.Redis;
//namespace GameServer
//{
// public class OwnedMail
// {
// public bool isNewReceivedMail = false;
// public bool isNewSystemMail = false;
// string accountGuid = string.Empty;
// List<MailEntity> receivedMails = new();
// List<MailEntity> sendedMails = new();
// MovePlayerInfo movePlayerInfo = new MovePlayerInfo();
// public async Task<bool> LoadDB(string accountGuid)
// {
// this.accountGuid = accountGuid;
// var receiveMail = await GameServerApp.Instance.MainDB.GetMailList(accountGuid, EMailType.RECEIVED_MAIL);
// if (receiveMail is null)
// {
// Log.getLogger().error("receivedMails == null");
// return false;
// }
// receivedMails = receiveMail;
// foreach (var receivedEntity in receivedMails)
// {
// if (receivedEntity.Attr.isRead == false)
// {
// isNewReceivedMail = true;
// break;
// }
// }
// var sendMail = await GameServerApp.Instance.MainDB.GetMailList(accountGuid, EMailType.SENDED_MAIL);
// if (sendMail is null)
// {
// Log.getLogger().error("sendedMails == null");
// return false;
// }
// sendedMails = sendMail;
// return true;
// }
// private async Task<List<MailEntity>> GetReceivedMailList(string ownerNickName)
// {
// if(isNewReceivedMail == false)
// {
// return receivedMails;
// }
// var receiveMail = await GameServerApp.Instance.MainDB.GetMailList(accountGuid, EMailType.RECEIVED_MAIL);
// if (receiveMail is null)
// {
// Log.getLogger().error("receivedMails == null");
// return receivedMails;
// }
// receivedMails = receiveMail;
// List<MailEntity> newMailEntity = new();
// newMailEntity.AddRange(receivedMails);
// return newMailEntity;
// }
// private List<MailEntity> GetSendedMailList()
// {
// List<MailEntity> newMailEntity = new();
// newMailEntity.AddRange(sendedMails);
// return newMailEntity;
// }
// public void UpdateReceivedMailToMemory(string mailKey, MailEntity receivedEntity)
// {
// foreach(MailEntity updateMailEntity in receivedMails)
// {
// if(updateMailEntity.Attr.mailKey == mailKey)
// {
// updateMailEntity.ReadFrom(receivedEntity.DocumentForUpdate());
// break;
// }
// }
// }
// public void AddSendedMailToMemory(string mailKey, MailEntity sendedEntity)
// {
// sendedMails.Add(sendedEntity);
// }
// public void DeleteMailToMemory(string mailKey, EMailType mailType)
// {
// var EntityList = GetCopyMailList(mailType);
// var mailEntity = GetMailEntity(mailKey, EntityList);
// if(mailEntity != null)
// {
// if (mailType == EMailType.RECEIVED_MAIL)
// {
// receivedMails.Remove(mailEntity);
// }
// else
// {
// sendedMails.Remove(mailEntity);
// }
// }
// }
// private List<MailEntity> GetCopyMailList(EMailType mailType)
// {
// List<MailEntity> EntityList = new();
// switch (mailType)
// {
// case EMailType.RECEIVED_MAIL:
// EntityList.AddRange(receivedMails); break;
// case EMailType.SENDED_MAIL:
// EntityList.AddRange(sendedMails); break;
// default:
// return EntityList;
// }
// return EntityList;
// }
// public async Task<List<MailInfo>?> GetMailListInfo(EMailType mailType, string ownerNickName)
// {
// List<MailInfo> mailInfos = new List<MailInfo>();
// List<MailEntity> MailList;
// string frontKey = string.Empty;
// string backKey = string.Empty;
// switch (mailType)
// {
// case EMailType.RECEIVED_MAIL: MailList = await GetReceivedMailList(ownerNickName); frontKey = movePlayerInfo.frontReceivedMailKey; backKey = movePlayerInfo.backReceivedMailKey; break;
// case EMailType.SENDED_MAIL: MailList = GetSendedMailList(); frontKey = movePlayerInfo.frontSendedMailKey; backKey = movePlayerInfo.backSendedMailKey; break;
// default: return null;
// }
// bool skipMail = false;
// bool isBackMail = false;
// int mailCount = 0;
// string newFrontKey = string.Empty;
// string newBackKey = string.Empty;
// foreach (var mail in MailList)
// {
// ++mailCount;
// if(mailCount >= ServerCommon.Constant.MAX_READ_MAIL_DB_COUNT)
// {
// break;
// }
// if(mail.Attr.mailKey == frontKey)
// {
// skipMail = true;
// }
// if (mail.Attr.mailKey == backKey)
// {
// isBackMail = true;
// skipMail = false;
// }
// if (skipMail == true)
// {
// continue;
// }
// if(isBackMail == false)
// {
// newFrontKey = newFrontKey == string.Empty ? mail.Attr.mailKey : newFrontKey;
// }
// else
// {
// newBackKey = mail.Attr.mailKey;
// }
// MailInfo mailInfo = new MailInfo();
// mailInfo.setMailInfo(mail, mailType);
// mailInfos.Add(mailInfo);
// }
// switch (mailType)
// {
// case EMailType.RECEIVED_MAIL:
// {
// movePlayerInfo.frontReceivedMailKey = newFrontKey;
// movePlayerInfo.backReceivedMailKey = newBackKey;
// break;
// }
// case EMailType.SENDED_MAIL:
// {
// movePlayerInfo.frontSendedMailKey = newFrontKey;
// movePlayerInfo.backSendedMailKey = newBackKey;
// break;
// }
// default: return null;
// }
// return mailInfos;
// }
// public MovePlayerInfo MakeMovePlayerInfo()
// {
// return movePlayerInfo;
// }
// public void SaveMovePlayerInfo(MovePlayerInfo newMovePlayerInfo)
// {
// movePlayerInfo = newMovePlayerInfo;
// }
// public MailEntity? GetMailEntity(string mailKey, in List<MailEntity> mailEntityList)
// {
// foreach (var mailEntity in mailEntityList)
// {
// if(mailEntity.Attr.mailKey == mailKey)
// {
// return mailEntity;
// }
// }
// return null;
// }
// public ServerErrorCode DelMail(string mailKey, EMailType mailType, out MailEntity? newMailEntity)
// {
// newMailEntity = default;
// var EntityList = GetCopyMailList(mailType);
// var mailEntity = GetMailEntity(mailKey, EntityList);
// if(mailEntity == null)
// {
// Log.getLogger().error($"Not Found Mail. mailKey : {mailKey}");
// return ServerErrorCode.NotFoundMail;
// }
// newMailEntity = mailType == EMailType.RECEIVED_MAIL ? new ReceivedMailEntity(mailEntity.DocumentForUpdate()) : new SendedMailEntity(mailEntity.DocumentForUpdate());
// return ServerErrorCode.Success;
// }
// public ServerErrorCode ReadReceivedMail(string mailKey, out MailEntity? newMailEntity)
// {
// newMailEntity = default;
// var EntityList = GetCopyMailList(EMailType.RECEIVED_MAIL);
// var mailEntity = GetMailEntity(mailKey, EntityList);
// if (mailEntity == null)
// {
// Log.getLogger().error($"Not Found Mail. mailKey : {mailKey}");
// return ServerErrorCode.NotFoundMail;
// }
// newMailEntity = new ReceivedMailEntity(mailEntity.DocumentForUpdate());
// newMailEntity.Attr.isRead = true;
// return ServerErrorCode.Success;
// }
// public ServerErrorCode GetItemsReceivedMail(string mailKey, out MailEntity? newMailEntity)
// {
// newMailEntity = default;
// var EntityList = GetCopyMailList(EMailType.RECEIVED_MAIL);
// var mailEntity = GetMailEntity(mailKey, EntityList);
// if (mailEntity == null)
// {
// Log.getLogger().error($"Not Found Mail. mailKey : {mailKey}");
// return ServerErrorCode.NotFoundMail;
// }
// if (mailEntity.Attr.ItemList.Count == 0)
// {
// Log.getLogger().error($"Item is Empty. mailKey : {mailKey}");
// return ServerErrorCode.EmptyItemInMail;
// }
// newMailEntity = new ReceivedMailEntity(mailEntity.DocumentForUpdate());
// newMailEntity.Attr.isGetItem = true;
// return ServerErrorCode.Success;
// }
// public void newMailNoti()
// {
// isNewReceivedMail = true;
// }
// public void newSystemMailNoti()
// {
// isNewSystemMail = true;
// }
// public void SendInfoFromLogin(HostID hostId)
// {
// if(isNewReceivedMail == false)
// {
// return;
// }
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.NewMailNoti = new ClientToGameMessage.Types.NewMailNoti();
// clientToGame.Message.NewMailNoti.IsLoginNoti = 1;
// GameServer.Instance._proxy.Message(hostId, RmiContext.ReliableSend, clientToGame);
// }
// //for cheat command
// public async Task<ServerErrorCode> SetRemainedTime(bool isSendMail, int remainedTime)
// {
// var EntityList = GetCopyMailList(EMailType.RECEIVED_MAIL);
// if (isSendMail == true)
// {
// EntityList = GetCopyMailList(EMailType.SENDED_MAIL);
// }
// List<MailEntity> mailEntities = new List<MailEntity>();
// foreach(var mailEntity in EntityList)
// {
// mailEntity.Attr.expireTime = Timestamp.FromDateTime(DateTime.UtcNow.AddMinutes(remainedTime));
// mailEntities.Add(mailEntity);
// }
// if (await GameServerApp.Instance.MainDB.UpdateMail(mailEntities) == false)
// {
// Log.getLogger().error($"DB UpdateMail Failed.");
// return ServerErrorCode.DbUpdateFailed;
// }
// return ServerErrorCode.Success;
// }
// }
//}

View File

@@ -0,0 +1,347 @@
using Amazon.DynamoDBv2.DocumentModel;
using Google.Protobuf.WellKnownTypes;
using Nettention.Proud;
using ServerCommon;
using ServerCore; using ServerBase;
using System.Diagnostics;
using System.Numerics;
using System.Reflection.Metadata.Ecma335;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Amazon.CloudWatchLogs.Model;
namespace GameServer
{
using static ClientToGameMessage.Types;
using Timestamp = global::Google.Protobuf.WellKnownTypes.Timestamp;
public class OwnedQuestList
{
//public QuestListEntity questListEntity { get; set; } = new();
public OwnedQuestList() { }
// internal async Task<bool> LoadDB(object player, string accountGuid)
// {
// var questList = await GameServerApp.Instance.MainDB.GetQuestList(accountGuid);
// if (questList is null)
// {
// Log.getLogger().error("OwnedQuestList questList is null");
// return false;
// }
//
// foreach (var quest in questList.Quests.Values)
// {
//
// if (!questBaseInfo.QuestTaskGroupList.TryGetValue(quest.m_current_task_num, out var questTaskInfo))
// {
// Log.getLogger().error($"questEventInfo InvalidData questId = {quest.m_quest_id}, info.CurrentTaskNum : {quest.m_current_task_num}, id : {player.accountId}");
// continue;
// }
// Log.getLogger().debug($"LoadDB call Player = {player.accountId}, questInfo = {JsonConvert.SerializeObject(quest)} , activeListIdx before clear = {JsonConvert.SerializeObject(quest.m_active_idx_list)}");
// quest.m_active_idx_list.Clear();
// quest.m_active_idx_list.AddRange(QuestManager.Instance.getActiveIdx(player.accountId, quest, questTaskInfo));
//
// quest.m_active_events.Clear();
// quest.m_active_events.AddRange(QuestManager.Instance.getActiveEventStrings(quest, questTaskInfo));
//
// setQuestEventTimer(player, quest.m_active_idx_list, questTaskInfo);
// }
//
// questListEntity = questList;
// return true;
// }
// internal void checkQuestTimer(object player)
// {
// foreach (var quest in questListEntity.Quests.Values)
// {
//
// if (!questBaseInfo.QuestTaskGroupList.TryGetValue(quest.m_current_task_num, out var questTaskInfo))
// {
// Log.getLogger().error($"questEventInfo InvalidData questId = {quest.m_quest_id}, info.CurrentTaskNum : {quest.m_current_task_num}, id : {player.accountId}");
// continue;
// }
//
// setQuestEventTimer(player, quest.m_active_idx_list, questTaskInfo);
// }
// setNormalMailTimer(player, questListEntity);
// }
// private void setQuestEventTimer(object player, List<int> activeIdxs, QuestTaskGroup questTaskInfo)
// {
// foreach (int idx in activeIdxs)
// {
// if (!questTaskInfo.QuestEventGroup.TryGetValue(idx, out var eventInfo))
// {
// continue;
// }
//
// if (eventInfo.EventTarget.Equals(EQuestEventTargetType.TIMER.ToString()))
// {
// //QuestManager.Instance.m_timer_check_users.TryAdd(player.accountId, idx);
// }
// }
// }
// private void setNormalMailTimer(object player, QuestListEntity questList)
// {
// if (questList.RepeatInfo.m_is_checking == 1)
// {
// // QuestManager.Instance.m_normal_quest_check_users.TryAdd(player.accountId, 1);
// // Log.getLogger().info($"setNormalMailTimer m_normal_quest_check_users Add accountId : {player.accountId}");
// }
// }
// public bool CheckEndQuest(int questId, QuestBaseInfo questInfo)
// {
// bool isEnd = questListEntity.EndQuests.Any(v => v.Value.QuestId == questId);
//
// if (isEnd && !questInfo.QuestType.Equals(EQuestType.NORMAL.ToString()))
// {
// Log.getLogger().error($"Quest Alredy End questId = {questId}");
// return false;
// }
//
// return true;
// }
// public bool hasQuest(int questId)
// {
// bool hasValue = questListEntity.Quests.Any(v => v.Value.m_quest_id == questId);
//
// return hasValue;
// }
// public ServerErrorCode CheckAssignableQuest(QuestBaseInfo assignableQuestInfo)
// {
// if (!System.Enum.TryParse<EQuestType>(assignableQuestInfo.QuestType, out var questType))
// {
// Log.getLogger().error($"QuesType InvalidData QuesType = {assignableQuestInfo.QuestType}");
// return ServerErrorCode.QuestInvalidType;
// }
//
// var it = questListEntity.Quests.GetEnumerator();
//
// bool isMax = false;
//
// int epic_quest_count = 0;
// int tutorial_quest_count = 0;
// int normal_quest_count = 0;
//
//
//
// while (it.MoveNext())
// {
// var active_quest = it.Current;
//
// if (processingQuestInfo.QuestType.Equals(EQuestType.EPIC.ToString())) epic_quest_count++;
// else if (processingQuestInfo.QuestType.Equals(EQuestType.TUTORIAL.ToString())) tutorial_quest_count++;
// else if (processingQuestInfo.QuestType.Equals(EQuestType.NORMAL.ToString())) normal_quest_count++;
// }
//
// switch (questType)
// {
// case EQuestType.NORMAL:
// if (normal_quest_count >= MetaHelper.GameConfigMeta.MaxNormalQuest) isMax = true;
// break;
// case EQuestType.EPIC:
// if (epic_quest_count >= MetaHelper.GameConfigMeta.MaxEpicQuest) isMax = true;
// break;
// case EQuestType.TUTORIAL:
// if (tutorial_quest_count >= MetaHelper.GameConfigMeta.MaxTutorialQuest) isMax = true;
// break;
// default:
// break;
// }
//
// if (isMax) return ServerErrorCode.QuestTypeAssignCountMax;
//
// return ServerErrorCode.Success;
// }
// public bool DeleteQuestInMemory(int questId)
// {
// if (questListEntity.Quests.ContainsKey(questId))
// {
// if (!questListEntity.Quests.TryRemove(questId, out var quest))
// {
// Log.getLogger().error($"DeleteQuestInMemory Error questId : {questId}");
// return false;
// }
// }
//
// return true;
// }
// public bool DeleteQuestInMemory(out QuestListEntity newQuestListEntity)
// {
//
// questListEntity.Quests.Clear();
// questListEntity.EndQuests.Clear();
// questListEntity.RepeatInfo.m_is_checking = 0;
// newQuestListEntity = new QuestListEntity(questListEntity.DocumentForUpdate());
// return true;
// }
//
// public ServerErrorCode QuestEnd(int questId, QuestListEntity newQuestListEntity, string player)
// {
// if (!newQuestListEntity.Quests.TryRemove(questId, out var deletedQuestInfo))
// {
// Log.getLogger().error($"Quests.TryRemove Error questId = {questId}", player);
// return ServerErrorCode.QuestInvalidValue;
// }
//
// DateTime now = DateTime.UtcNow;
// TimeStamp ts = TimeStamp.FromDateTime(now);
// if (!newQuestListEntity.EndQuests.TryGetValue(questId, out var endQuest))
// {
// endQuest = new();
// endQuest.EndCount = 1;
// endQuest.LastEndTime = ts;
// endQuest.QuestId = questId;
//
// }
// endQuest.EndCount++;
// endQuest.LastEndTime = ts;
// endQuest.QuestId = questId;
// newQuestListEntity.EndQuests.AddOrUpdate(questId, endQuest, (key, oldValue) => endQuest);
// return ServerErrorCode.Success;
// }
// public ServerErrorCode cheatQuestComplete(int questId, out QuestListEntity newQuestListEntity)
// {
// newQuestListEntity = new QuestListEntity(questListEntity.DocumentForUpdate());
//
//
// if (!newQuestListEntity.Quests.TryGetValue(questId, out var questInfo))
// {
// return ServerErrorCode.QuestIdNotFound;
//
// }
//
// questInfo.m_active_idx_list.Clear();
// questInfo.m_active_events.Clear();
// questInfo.m_is_complete = true ? 1 : 0;
//
// return ServerErrorCode.Success;
//
// }
//
// public bool checkProcessingQuest(int questId, out QuestListEntity newQuestListEntity)
// {
// newQuestListEntity = new QuestListEntity(questListEntity.DocumentForUpdate());
// return newQuestListEntity.Quests.ContainsKey(questId);
// }
//
//
//
// public void SendInfoFromLogin(HostID hostId)
// {
// // SendQuestAssignMetaInfoNoti(hostId);
// // SendQuestListNoti(hostId);
// SendQuestEndListNoti(hostId);
// }
//
// public bool GetQuestInfo(out QuestListEntity newQuestListEntity)
// {
// newQuestListEntity = questListEntity.Clone();
// return true;
// }
// public void UpdateQuestReapeatInfo(Timestamp nextTS, out QuestListEntity newQuestListEntity)
// {
// newQuestListEntity = new(questListEntity.DocumentForUpdate());
//
// newQuestListEntity.RepeatInfo.m_next_allocate_time = nextTS;
// }
// void SendQuestListNoti(HostID hostId)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.QuestInfoNoti = new ClientToGameMessage.Types.QuestList();
// clientToGame.Message.QuestInfoNoti.Quests.AddRange(makeQeustInfoData(questListEntity.Quests.Values.ToList()));
// clientToGame.Message.QuestInfoNoti.QuestMetaInfos.AddRange(makeQuestMetaInfoData(questListEntity.Quests.Values.ToList()));
// //GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame);
// }
//
// void SendQuestAssignMetaInfoNoti(HostID hostId)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.NtfQuestAssignMetaInfo = new ClientToGameMessage.Types.GS2C_NTF_QUEST_ASSIGN_META_INFO();
// clientToGame.Message.NtfQuestAssignMetaInfo.QuestAssignMeteInfos.AddRange(TableData.Instance.m_quest_assign_meta_infos);
// clientToGame.Message.NtfQuestAssignMetaInfo.QuestTaskMetaInfos.AddRange(TableData.Instance.m_quest_task_meta_infos);
// // GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame);
// }
//
// private List<QuestInfo> makeQeustInfoData(List<UserQuestInfo> infos)
// {
// List<QuestInfo> questInfos = new List<QuestInfo>();
//
// foreach (UserQuestInfo info in infos)
// {
// QuestInfo questInfo = new QuestInfo();
// questInfo.QuestId = info.m_quest_id;
// questInfo.QuestAssignTime = info.m_quest_assign_time;
// questInfo.CurrentTaskNum = info.m_current_task_num;
// questInfo.TaskStartTime = info.m_task_start_time;
// questInfo.QuestCompleteTime = info.m_quest_complete_time;
// questInfo.ActiveIdxList.AddRange(info.m_active_idx_list);
// questInfo.HasCounter = info.m_has_counter;
// questInfo.MinCounter = info.m_min_counter;
// questInfo.MaxCounter = info.m_max_counter;
// questInfo.CurrentCounter = info.m_current_counter;
// questInfo.IsComplete = info.m_is_complete;
// questInfo.ReplacedRewardGroupId = info.m_replaced_reward_group_id;
// questInfo.HasTimer = info.m_has_timer;
// questInfo.TimerCompleteTime = info.m_timer_complete_time;
// questInfos.Add(questInfo);
// }
//
// return questInfos;
// }
//
// private List<QuestMetaInfo> makeQuestMetaInfoData(List<UserQuestInfo> infos)
// {
// List<QuestMetaInfo> metaInfos = new List<QuestMetaInfo>();
// foreach (UserQuestInfo info in infos)
// {
// if (!TableData.Instance._QuestScriptDataTable.TryGetValue(info.m_quest_id, out var questScripts))
// {
// Log.getLogger().error($"QuestMetaInfoData Not Exist questId : {info.m_quest_id}");
// continue;
// }
//
// foreach (var script in questScripts.Values)
// {
//
// //var meta = fillQuestMetaInfo(script);
// //metaInfos.Add(meta);
// }
// }
//
// return metaInfos;
//
// }
//
//
//
//
//
//
// public void UpdateDBToMemory(Document document)
// {
// questListEntity = new QuestListEntity(document);
// }
}
}

View File

@@ -0,0 +1,143 @@
using Nettention.Proud;
using ServerCore; using ServerBase;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Amazon.DynamoDBv2.DocumentModel;
using static ClientToGameMessage.Types;
using System.Data;
using ServerCommon;
namespace GameServer
{
public class OwnedQuestMail
{
string accountGuid = string.Empty;
//ConcurrentDictionary<int, QuestMailEntity> questMails = new();
//bool m_is_questmail_loaded = false;
public OwnedQuestMail() { }
// public async Task<bool> LoadDB(string accountGuid)
// {
// this.accountGuid = accountGuid;
// var questMailList = await GameServerApp.Instance.MainDB.GetQuestMailList(accountGuid);
// if (questMailList is null)
// {
// Log.getLogger().error("OwnedQuestMail questMailList is null");
// return false;
// }
// questMails = questMailList;
// m_is_questmail_loaded = true;
// return true;
// }
// public List<QuestMailInfo> GetQuestMailList()
// {
// //일단 새로 리프레시 하지 말고 기존에 저장하고 있는 값을 전달 해준다.
// //var questMailList = await GameServerApp.Instance.MainDB.GetQuestMailList(accountGuid);
// //if (questMailList is null)
// //{
// // Log.getLogger().error("OwnedQuestMail questMailList is null");
// // return new();
// //}
//
// List<QuestMailInfo> questmailInfos = new();
//
// foreach (var mail in questMails)
// {
// QuestMailInfo info = new();
//
// info.IsRead = mail.Value.Attr.isRead == true ? 1 : 0;
// info.QuestId = mail.Value.Attr.questId;
// info.CreateTime = mail.Value.Attr.createTime;
// questmailInfos.Add(info);
// }
//
// return questmailInfos;
// }
//
// public bool isMailLoad()
// {
// return m_is_questmail_loaded;
// }
//
// public bool CheckQuestMailExist(int questId)
// {
// bool ret = questMails.ContainsKey(questId);
// return ret;
// }
//
// public ServerErrorCode ReadQuestMail(int questId, out QuestMailEntity? newQuestMailEntity)
// {
// newQuestMailEntity = default;
//
// if(!questMails.TryGetValue(questId, out var questMailEntity))
// {
// Log.getLogger().error($"Not Found Mail. questId : {questId}");
// return ServerErrorCode.QuestMailNotExist;
// }
//
// questMailEntity.Attr.isRead = true;
// newQuestMailEntity = new(questMailEntity.DocumentForUpdate());
//
// return ServerErrorCode.Success;
// }
//
// public ServerErrorCode DelReceivedQuestMail(int questId, out QuestMailEntity? newQuestMailEntity)
// {
// newQuestMailEntity = new();
// if (!questMails.TryGetValue(questId, out var questMailEntity))
// {
// Log.getLogger().error($"Not Found Mail. questId : {questId}");
// return ServerErrorCode.QuestMailNotExist;
// }
//
// newQuestMailEntity = new(questMailEntity.DocumentForUpdate());
//
// return ServerErrorCode.Success;
// }
//
// public ServerErrorCode DelReceivedQuestMailAll(out List<Document> mailDocuments)
// {
// mailDocuments = new();
//
// foreach (QuestMailEntity entity in questMails.Values)
// {
//
// mailDocuments.Add(entity.DocumentForUpdate());
// }
//
// return ServerErrorCode.Success;
// }
//
//
// public void UpdateQuestMailToMemory(int questId, QuestMailEntity entity)
// {
// questMails.AddOrUpdate(questId, entity, (key, oldValue) => entity);
// }
//
// public void DeleteQuestMailToMemory(int questId)
// {
// if (!questMails.TryRemove(questId, out _))
// {
// Log.getLogger().error("DeleteQuestMailToMemory failed");
// }
// }
//
//
//
// public HashSet<int> getNormalMailSet()
// {
// HashSet<int> normalMailSet = new();
//
// return normalMailSet;
// }
}
}

View File

@@ -0,0 +1,264 @@
//using System.Diagnostics.CodeAnalysis;
//using ServerCommon;
//using ServerCore; using ServerBase;
//using Nettention.Proud;
//using Amazon.DynamoDBv2.DocumentModel;
//using ServerCommon.BusinessLogDomain;
//namespace GameServer
//{
// public class OwnedSocialAction
// {
// SocialActionCollectionEntity socialActionCollection = new();
// SocialActionSlotEntity socialActionSlot = new();
// /// <summary>
// /// 재생 중인 소셜액션 아이디
// /// </summary>
// public int PlayingSocialActionId { get; private set; } = 0;
// /// <summary>
// /// 소셜액션 재생 시작시간(UTC)
// /// </summary>
// public DateTime SocialActionStartTime { get; private set; }
// public OwnedSocialAction() { }
// public async Task<bool> LoadDB(string accountGuid)
// {
// var collectDocument = await GameServerApp.Instance.MainDB.GetSocialActionCollection(accountGuid);
// if (collectDocument == null)
// {
// Log.getLogger().error("collectDocument is null");
// return false;
// }
// if (!socialActionCollection.ReadFrom(collectDocument))
// {
// Log.getLogger().error("socialActionCollection read error");
// return false;
// }
// if (socialActionCollection.Attr.collectionInfos.Count == 0)
// {
// await BasicSocialActionCollectionsSetting(accountGuid);
// }
// var slotDocument = await GameServerApp.Instance.MainDB.GetSocialActionSlot(accountGuid);
// if(slotDocument == null)
// {
// Log.getLogger().error("slotDocument is null");
// return false;
// }
// if (!socialActionSlot.ReadFrom(slotDocument))
// {
// Log.getLogger().error("socialActionSlot read error");
// return false;
// }
// if (socialActionSlot.Attr.slotInfos.Count == 0)
// {
// await BasicSocialActionSlotSetting(accountGuid);
// }
// return true;
// }
// /// <summary>
// /// 기본 소셜액션 컬렉션 세팅
// /// </summary>
// /// <param name="accountGuid"></param>
// /// <returns></returns>
// async Task BasicSocialActionCollectionsSetting(string accountGuid)
// {
// foreach (var data in TableData.Instance._SocialActionTable.Values)
// {
// if (!data.IsDefault)
// continue;
// AddSocialAction(data.SocialActionId);
// }
// await GameServerApp.Instance.MainDB.UpdateDocument(socialActionCollection.DocumentForUpdate());
// }
// /// <summary>
// /// 치트용 모든 SocialAction 추가
// /// </summary>
// /// <returns></returns>
// public async Task AllSocialActionCollectionsSetting()
// {
// foreach (var data in TableData.Instance._SocialActionTable.Values)
// {
// if (socialActionCollection.Attr.collectionInfos.Contains(data.SocialActionId))
// continue;
// AddSocialAction(data.SocialActionId);
// }
// await GameServerApp.Instance.MainDB.UpdateDocument(socialActionCollection.DocumentForUpdate());
// }
// /// <summary>
// /// 기본 소셜액션 슬롯 세팅
// /// </summary>
// /// <param name="accountGuid"></param>
// /// <returns></returns>
// async Task BasicSocialActionSlotSetting(string accountGuid)
// {
// foreach (var data in TableData.Instance._SocialActionTable.Values)
// {
// if(!data.IsDefault)
// continue;
// if (data.SlotNum < 1 || data.SlotNum > Constant.MAX_EMOTION_SLOT)
// continue;
// int slot = data.SlotNum - 1;
// socialActionSlot.Attr.slotInfos[slot] = data.SocialActionId;
// }
// await GameServerApp.Instance.MainDB.UpdateDocument(socialActionSlot.DocumentForUpdate());
// }
// public void SendInfo(HostID hostId)
// {
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.OwnedSocialActionNoti = new ClientToGameMessage.Types.OwnedSocialActionNoti();
// foreach (var id in socialActionCollection.Attr.collectionInfos)
// {
// clientToGame.Message.OwnedSocialActionNoti.OwnedList.Add(id);
// }
// foreach (var slotInfo in socialActionSlot.Attr.slotInfos)
// {
// SlotInfo slot = new SlotInfo();
// slot.Slot = slotInfo.Key;
// slot.Id = slotInfo.Value;
// clientToGame.Message.OwnedSocialActionNoti.EquipList.Add(slot);
// }
// GameServer.Instance.Send(hostId, RmiContext.ReliableSend, clientToGame);
// }
// public bool ExchangeSocialActionSlot(int slot, int id, [MaybeNullWhen(false)] out Document changedDocument)
// {
// changedDocument = default;
// if (slot < 0 || slot >= ServerCommon.Constant.MAX_SOCIAL_ACTION_SLOT)
// {
// Log.getLogger().error($"Slot : {slot} is out range");
// return false;
// }
// if (id != 0)
// {
// if (!socialActionCollection.Attr.collectionInfos.TryGetValue(id, out _))
// {
// Log.getLogger().error($"SocialActionId : {id} - Not owned");
// return false;
// }
// foreach (var slotInfo in socialActionSlot.Attr.slotInfos)
// {
// if (slotInfo.Value == id)
// {
// Log.getLogger().error($"SocialActionId : {id} is duplicated");
// return false;
// }
// }
// }
// socialActionSlot.Attr.slotInfos[slot] = id;
// changedDocument = socialActionSlot.DocumentForUpdate();
// return true;
// }
// /// <summary>
// /// 소셜액션이 슬롯에 존재하는지 확인
// /// </summary>
// /// <param name="socialActionId">사용할 소셜액션 아이디</param>
// /// <returns><see langword="true"/> 슬롯에 존재, <see langword="false"/> 슬롯에 없음</returns>
// public bool IsSocialActionOnSlot(int socialActionId)
// {
// foreach (var slotInfo in socialActionSlot.Attr.slotInfos)
// {
// if (slotInfo.Value == socialActionId)
// return true;
// }
// return false;
// }
// public void SetPlaySocialAction(int socialActionId, DateTime startTime = default)
// {
// PlayingSocialActionId = socialActionId;
// SocialActionStartTime = DateTime.UtcNow;
// if (startTime != default)
// SocialActionStartTime = startTime;
// }
// public void RemovePlaySocialAction()
// {
// PlayingSocialActionId = 0;
// SocialActionStartTime = default;
// }
// /// <summary>
// /// 새로운 소셜액션 컬렉션에 추가
// /// </summary>
// /// <param name="socialActionId">소셜액션 컬렉션에 추가할 소셜액션 아이디</param>
// /// <returns><see langword="true"/> 추가 성공, <see langword="false"/> 추가 실패</returns>
// public bool AddSocialAction(int socialActionId)
// {
// if (!TableData.Instance._SocialActionTable.TryGetValue(socialActionId, out _))
// {
// Log.getLogger().error($"socialActionId : {socialActionId} is not tabledata");
// return false;
// }
// socialActionCollection.Attr.collectionInfos.Add(socialActionId);
// return true;
// }
// public ServerErrorCode AddSocialAction(int socialActionId, out Document? changeDocument, out SocialActionLogInfo? socialActionLogInfo)
// {
// changeDocument = default;
// socialActionLogInfo = default;
// if (!TableData.Instance._SocialActionTable.TryGetValue(socialActionId, out _))
// {
// Log.getLogger().error($"socialActionId : {socialActionId} is not tabledata");
// return ServerErrorCode.NotFoundTable;
// }
// if (socialActionCollection.Attr.collectionInfos.Contains(socialActionId) == true)
// {
// Log.getLogger().info($"Already Register SocialAction. socialActionId : {socialActionId}");
// return ServerErrorCode.AlreadyRegistered;
// }
// SocialActionCollectionEntity changeEntity = new SocialActionCollectionEntity(socialActionCollection.DocumentForUpdate());
// changeEntity.Attr.collectionInfos.Add(socialActionId);
// changeDocument = changeEntity.DocumentForUpdate();
// socialActionLogInfo = SocialActionBusinessLogHelper.toSocialActionLogInfo(socialActionId, changeDocument);
// return ServerErrorCode.Success;
// }
// public void UpdateSocialActionToMemory(Document changeDocument)
// {
// socialActionCollection.ReadFrom(changeDocument);
// }
// }
//}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,160 @@
//using System.Configuration;
//using ServerCore; using ServerBase;
//using System.Runtime.InteropServices;
//using CommandLine;
//using ServerCommon;
//using Nettention.Proud;
//using System.Diagnostics;
//using System.Reflection;
//using Amazon.Runtime.Internal.Util;
//using System.Threading;
//using ControlCenter.NamedPipe;
//using Google.Protobuf.WellKnownTypes;
//using ServerControlCenter;
//namespace GameServer
//{
// class Options
// {
// [Option("port", Default = (int)9200)]
// public int Port { get; set; }
// [Option("config", Default = "ServerConfig.json")]
// public string Config { get; set; } = string.Empty;
// [Option("type", Default = 0)]
// public int Type { get; set; } = 0;
// [Option("worldid", Default = 1)]
// public int worldid { get; set; } = 1;
// [Option("channel", Default = 0)]
// public int channel { get; set; } = 1;
// [Option("default", Default = 0)]
// public int DefaultMaxUser { get; set; } = 0;
// }
// public class Program
// {
// //public NetServer _srv { get; } = new NetServer();
// //PClientToGame.Stub _stub = new PClientToGame.Stub();
// static GameServer gameServer = GameServer.Instance;
// public static async Task ExitMain(bool isExit = false)
// {
// Log.getLogger().info("ExitMain");
// try
// {
// await gameServer.StopServer();
// GameServerApp.Instance.Stop();
// }
// catch (Exception e)
// {
// Log.getLogger().error($"{nameof(ExitMain)}: Exception - {e}");
// }
// finally
// {
// if (isExit)
// {
// Environment.Exit(0);
// }
// }
// }
// static async Task<int> Main(string[] args)
// {
// System.Threading.ThreadPool.GetMinThreads(out int workerThreads, out int completionPortThreads);
// int updateMinWorkerThreads = 128;
// int updateCompletionPortThreads = 128;
// System.Threading.ThreadPool.SetMinThreads(updateMinWorkerThreads, updateCompletionPortThreads);
// System.Threading.ThreadPool.GetMinThreads(out int outWorkerThreads, out int outCompletionPortThreads);
// Log.getLogger().info($"MinWorkerThreadCount = {outWorkerThreads}, outCompletionPortThreadsCount = {outCompletionPortThreads}");
// // SIGINT에 반응
// Console.CancelKeyPress += async (s, e) =>
// {
// await ExitMain();
// };
// // 프로세스 종료에 반응
// AppDomain.CurrentDomain.ProcessExit += async (s, e) =>
// {
// await ExitMain();
// };
// BusinessLogger.setup( new NLogAppender("./Config/nlog.config")
// , new JsonText()
// , LogTransToOutputType.TransToMultyLine );
// try
// {
// _ = await Parser.Default.ParseArguments<Options>(args)
// .MapResult(async (Options opts) =>
// {
// await GameServerApp.Instance.Init(opts.Config, opts.Type);
// //IMG서버들은 config파일의 ip와 비교해서 실행되지 않도록함.
// if (GameServerApp.Instance.Config.ServiceType != "Dev")
// {
// if (ServerUtil.GetPublicIPv4() == GameServerApp.Instance.Config.EC2TemplateIMG)
// {
// return 0;
// }
// }
// var type = opts.Type == 1 ? ServerType.Indun : ServerType.Game;
// GameServerApp.Instance.Config.DefaultMaxUser = opts.DefaultMaxUser > 0 ? opts.DefaultMaxUser : GameServerApp.Instance.Config.DefaultMaxUser;
// await NamedPipeMonitor.StartNamedPipeService(GameServerApp.Instance.Config.ControlAgentEnable, type, opts.Port, GameServerApp.Instance.Config.DefaultMaxUser, opts.channel);
// TableData.Instance.LoadTableAll();
// MapDataTable.Instance.Load();
// MapManager.Instance.Load();
// QuestManager.Instance.Load();
// await LandManager.Instance.LoadDB();
// await BuildingManager.Instance.LoadDB();
// await AccountAuthorityManager.Instance.LoadDB(GameServerApp.Instance.MainDB);
// await SystemMailManager.Instance.LoadSystemMail();
// await NoticeChatManager.Instance.LoadNoticeChat();
// await gameServer.StartServer(opts);
// Log.getLogger().info($"Game Server Start GameType:{GameServerApp.Instance.Config.GameServerType}");
// await NamedPipeMonitor.ChangeServerStatus(ServerStatus.Running);
// Task? runningTask = gameServer.Running();
// if (runningTask == null)
// {
// await NamedPipeMonitor.SetStopReason(StopReason.CannotRunning);
// return -1;
// }
// await runningTask;
// return 0;
// },
// errs => Task.FromResult(-1));
// }
// catch (Exception e)
// {
// // 차후에 자신의 서버 정보에 상세히 남길 수 있도록 수정해야 한다. - kangms
// ServerLog.Fatal($"Exception GameServer !!! : errDesc:{e.Message}, GameServerTpe:{GameServerApp.Instance.Config.GameServerType}");
// }
// Log.getLogger().info("Game Server End");
// ServerLog.End();
// return 0;
// }
// }
//}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,84 @@
//using Google.Protobuf.WellKnownTypes;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//namespace GameServer
//{
// public class SystemMailManager
// {
// SystemMailEntity systemMailEntities = new ();
// private static readonly SystemMailManager _instance = new();
// public static SystemMailManager Instance { get { return _instance; } }
// public async Task LoadSystemMail()
// {
// var document = await GameServerApp.Instance.MainDB.GetSystemMailList();
// if(document == null)
// {
// return;
// }
// systemMailEntities = new SystemMailEntity(document);
// }
// public List<SystemMailInfo> GetSystemMail(int lastGetSystemMailId)
// {
// List<SystemMailInfo> systemMailList = new();
// var mailList = CopyData();
// foreach (var systemMail in mailList)
// {
// var nowTimeStamp = DateTime.UtcNow.ToTimestamp();
// if(lastGetSystemMailId >= systemMail.Id)
// {
// continue;
// }
// if (systemMail.startTime < nowTimeStamp && systemMail.endTime > nowTimeStamp)
// {
// systemMailList.Add(systemMail);
// }
// }
// return systemMailList;
// }
// private List<SystemMailInfo> CopyData()
// {
// return new List<SystemMailInfo>(systemMailEntities.Attr.SystemMailList);
// }
// public async Task TempFuncSaveSystemMail()
// {
// int id = 0;
// foreach(var systemMailInfo in systemMailEntities.Attr.SystemMailList)
// {
// if(id < systemMailInfo.Id)
// {
// id = systemMailInfo.Id;
// }
// }
// List<MailItem> data = new List<MailItem>();
// data.Add(new MailItem() { ItemId = 15231470, Count = 1 });
// data.Add(new MailItem() { ItemId = 31020014, Count = 1 });
// SystemMailInfo mailInfo = new();
// mailInfo.Id = id + 1;
// mailInfo.title = "Test 시스템메일";
// mailInfo.text = "Test 합니다.";
// mailInfo.senderNickName = "[GM]그리노스";
// mailInfo.startTime = DateTime.UtcNow.ToTimestamp();
// mailInfo.endTime = DateTime.UtcNow.AddDays(2).ToTimestamp();
// mailInfo.ItemList.AddRange(data);
// systemMailEntities.Attr.SystemMailList.Add(mailInfo);
// if(await GameServerApp.Instance.MainDB.UpdateSystemMail(systemMailEntities) == false)
// {
// return;
// }
// }
// }
//}