private void HandleChangeNameResult(NodeMessage lobbyMsg) { GameFrameworkMessage.ChangeNameResult protoMsg = lobbyMsg.m_ProtoData as GameFrameworkMessage.ChangeNameResult; if (null == protoMsg) { return; } ChangeNameResult.ChangeNameResultEnum ret = protoMsg.m_Result; if (ret == ChangeNameResult.ChangeNameResultEnum.Success) { ClientInfo.Instance.RoleData.Nickname = protoMsg.m_Nickname; } else { PluginFramework.Instance.HighlightPrompt("Tip_OperationFailed"); } }
private void CreateRole(string accountId, string nickname, int heroId) { AccountInfo accountInfo = m_AccountSystem.FindAccountById(accountId); var ds_thread = UserServer.Instance.DataCacheThread; if (accountInfo != null) { //检查昵称是否可用 NicknameSystem.CheckNicknameResult ret = m_NicknameSystem.CheckNickname(accountId, nickname); if (ret == NicknameSystem.CheckNicknameResult.Success) { UserInfo ui = NewUserInfo(); ui.Guid = accountInfo.UserGuid; ui.AccountId = accountInfo.AccountId; ui.Nickname = nickname; ui.HeroId = heroId; InitUserinfo(ui); m_NicknameSystem.UpdateUsedNickname(nickname, ui.Guid); LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "LoginStep_7a: Create new role SUCCESS. AccountId:{0}, UserGuid:{1}, Nickname:{2}, HeroId:{3}", accountId, accountInfo.AccountId, ui.Guid, ui.Nickname, ui.HeroId); if (ds_thread.DataStoreAvailable) { ds_thread.DSPSaveCreateUser(accountInfo, nickname, ui.Guid); ds_thread.DSPSaveUser(ui, ui.NextUserSaveCount); } //游戏角色创建成功,直接进入游戏 ui.NodeName = accountInfo.NodeName; this.DoUserLogin(ui); LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "LoginStep_8c: New role enter SUCCESS. AccountId:{0}, UserGuid:{1}, Nickname:{2}", accountId, ui.Guid, ui.Nickname); NodeMessage enterMsg = new NodeMessage(LobbyMessageDefine.RoleEnterResult, ui.AccountId, ui.Guid); GameFrameworkMessage.RoleEnterResult protoData = CreateRoleEnterResultMsg(ui); protoData.Result = RoleEnterResult.RoleEnterResultEnum.Success; enterMsg.m_ProtoData = protoData; NodeMessageDispatcher.SendNodeMessage(accountInfo.NodeName, enterMsg); } else { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "LoginStep_7b: Create new role FAILED. AccountId:{0}, Nickname:{1}", accountId, nickname); NodeMessage replyMsg = new NodeMessage(LobbyMessageDefine.ChangeNameResult, accountId); GameFrameworkMessage.ChangeNameResult protoMsg = new GameFrameworkMessage.ChangeNameResult(); if (ret == NicknameSystem.CheckNicknameResult.AlreadyUsed) { //昵称已经被使用 protoMsg.m_Result = ChangeNameResult.ChangeNameResultEnum.NicknameError; } else { //昵称不合法 protoMsg.m_Result = ChangeNameResult.ChangeNameResultEnum.UnknownError; } replyMsg.m_ProtoData = protoMsg; NodeMessageDispatcher.SendNodeMessage(accountInfo.NodeName, replyMsg); } } }
internal void DoChangeName(ulong guid, string nickname) { UserInfo ui = GetUserInfo(guid); if (null != ui) { NicknameSystem.CheckNicknameResult ret = m_NicknameSystem.CheckNickname(ui.AccountId, nickname); if (ret == NicknameSystem.CheckNicknameResult.Success) { ui.Nickname = nickname; LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "ChangeName SUCCESS. AccountId:{0}, Nickname:{1}", ui.AccountId, nickname); NodeMessage replyMsg = new NodeMessage(LobbyMessageDefine.ChangeNameResult, ui.AccountId); GameFrameworkMessage.ChangeNameResult protoMsg = new GameFrameworkMessage.ChangeNameResult(); protoMsg.m_Result = ChangeNameResult.ChangeNameResultEnum.Success; replyMsg.m_ProtoData = protoMsg; NodeMessageDispatcher.SendNodeMessage(ui.NodeName, replyMsg); } else { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "ChangeName FAILED. AccountId:{0}, Nickname:{1}", ui.AccountId, nickname); NodeMessage replyMsg = new NodeMessage(LobbyMessageDefine.ChangeNameResult, ui.AccountId); GameFrameworkMessage.ChangeNameResult protoMsg = new GameFrameworkMessage.ChangeNameResult(); if (ret == NicknameSystem.CheckNicknameResult.AlreadyUsed) { //昵称已经被使用 protoMsg.m_Result = ChangeNameResult.ChangeNameResultEnum.NicknameError; } else { //昵称不合法 protoMsg.m_Result = ChangeNameResult.ChangeNameResultEnum.UnknownError; } replyMsg.m_ProtoData = protoMsg; NodeMessageDispatcher.SendNodeMessage(ui.NodeName, replyMsg); } } }