using ServerCore; using ServerBase; using ServerCommon; namespace GameServer; public static class GameZoneMoveHelper { public static async Task moveToAnotherChannel(Player player, ServerInfo destServer, Pos? pos) { var server_logic = GameServerApp.getServerLogic(); var server_name = ServerBase.ServerHelper.makeGameServerName(ServerType.Channel, destServer.WorldId, destServer.Channel); var WORLD_META_ID = destServer.WorldId; // 1. otp 생성 var (result, reserved_to_switch_server) = await ServerConnectionSwitchHelper.startServerSwitch(player, server_logic.getRedisConnector(), server_name); if (result.isFail() || null == reserved_to_switch_server) return result; var game_login_action = player.getEntityAction(); NullReferenceCheckHelper.throwIfNull(game_login_action, () => $"game login action is null !!! - {player.toBasicString()}"); var login_cache = game_login_action.getLoginCacheRequest()?.getLoginCache(); NullReferenceCheckHelper.throwIfNull(login_cache, () => $"login cache is null !!! - player:{player.toBasicString()}"); login_cache.ReservedToSwitchServer = reserved_to_switch_server; // 2. 이동 정보 저장 var account_attribute = player.getEntityAttribute(); NullReferenceCheckHelper.throwIfNull(account_attribute, () => $"account attribute is null !!! - {player.toBasicString()}"); account_attribute.ToConnectGameServerAddress = destServer.toNetworkAddress(); account_attribute.ToConnectGameServerName = server_name; account_attribute.OtpForServerConnect = reserved_to_switch_server.OneTimeKey; account_attribute.modifiedEntityAttribute(); // 3. Buff 정보 수정 var buff_action = player.getEntityAction(); NullReferenceCheckHelper.throwIfNull(buff_action, () => $"buff action is null !!! - {player.toBasicString()}"); result = await buff_action.MoveServer(EPlaceType.World); if (result.isFail()) return result; // 4. 위치 수정 var location_action = player.getEntityAction(); NullReferenceCheckHelper.throwIfNull(location_action, () => $"location action is null !!! - {player.toBasicString()}"); if (pos == null) { pos = location_action.getCurrentPos(); } result = await location_action.tryMoveToChannel(server_name, WORLD_META_ID, pos); if (result.isFail()) { var err_msg = $"Failed to tryMoveToChannel() !!! : {result.toBasicString()}"; Log.getLogger().error(err_msg); } return result; } }