Exemplo n.º 1
0
        private ChangeNameError HandleChangeName(string uid, int zoneId, int roleId, string newName)
        {
            ChangeNameError result;

            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot6))
            {
                result = ChangeNameError.ServerDenied;
            }
            else
            {
                SecPwdState pwdState = SecondPasswordManager.GetSecPwdState(uid);
                if (pwdState != null && pwdState.NeedVerify)
                {
                    result = ChangeNameError.NeedVerifySecPwd;
                }
                else if (string.IsNullOrEmpty(newName) || NameServerNamager.CheckInvalidCharacters(newName, false) <= 0)
                {
                    result = ChangeNameError.InvalidName;
                }
                else if (!this.IsNameLengthOK(newName))
                {
                    result = ChangeNameError.NameLengthError;
                }
                else if (NameServerNamager.RegisterNameToNameServer(zoneId, uid, new string[]
                {
                    newName
                }, 0, roleId) <= 0)
                {
                    result = ChangeNameError.NameAlreayUsed;
                }
                else
                {
                    int      canFreeMod    = GameManager.VersionSystemOpenMgr.IsVersionSystemOpen("FreeModName") ? 1 : 0;
                    int      canZuanShiMod = GameManager.VersionSystemOpenMgr.IsVersionSystemOpen("ZuanShiModName") ? 1 : 0;
                    string[] dbRet         = Global.ExecuteDBCmd(14001, string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}:{7}", new object[]
                    {
                        uid,
                        zoneId,
                        roleId,
                        newName,
                        this.CostZuanShiBase,
                        this.CostZuanShiMax,
                        canFreeMod,
                        canZuanShiMod
                    }), 0);
                    if (dbRet == null || dbRet.Length != 4)
                    {
                        result = ChangeNameError.DBFailed;
                    }
                    else
                    {
                        int    ec          = Convert.ToInt32(dbRet[0]);
                        string oldName     = dbRet[1];
                        int    costDiamond = Convert.ToInt32(dbRet[2]);
                        int    leftDiamond = Convert.ToInt32(dbRet[3]);
                        if (ec == 0)
                        {
                            if (costDiamond > 0)
                            {
                                string msg = "改名 " + oldName + " -> " + newName;
                                EventLogManager.AddResourceEvent(uid, zoneId, roleId, MoneyTypes.YuanBao, (long)(-(long)costDiamond), (long)leftDiamond, msg);
                                GameManager.logDBCmdMgr.AddDBLogInfo(-1, "钻石", "改名", oldName, newName, "减少", costDiamond, zoneId, uid, leftDiamond, 0, null);
                            }
                            this._OnChangeNameSuccess(roleId, oldName, newName);
                        }
                        result = (ChangeNameError)ec;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        private ChangeNameError HandleChangeName(string uid, int zoneId, int roleId, string newName)
        {
            // 如果1.6的功能没开放
            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot6))
            {
                return(ChangeNameError.ServerDenied);
            }

            SecPwdState pwdState = SecondPasswordManager.GetSecPwdState(uid);

            if (pwdState != null && pwdState.NeedVerify)
            {
                // 二级密码尚未验证
                return(ChangeNameError.NeedVerifySecPwd);
            }

            // 非法字符
            if (string.IsNullOrEmpty(newName) || NameServerNamager.CheckInvalidCharacters(newName) <= 0)
            {
                return(ChangeNameError.InvalidName);
            }

            // 检测长度
            if (!IsNameLengthOK(newName))
            {
                return(ChangeNameError.NameLengthError);
            }

            /*
             * // 跨服禁止改名
             * // 组队情况下禁止改名, 副本开房间等待中禁止改名(队伍或者开房间改名需要广播,禁止掉)
             * // 非常规地图禁止改名,(副本中可能需要更新各个角色的战斗积分信息,禁止掉)
             * if (client.ClientSocket.IsKuaFuLogin
             || client.ClientData.TeamID > 0 || CopyTeamManager.getInstance().FindRoleID2TeamID(client.ClientData.RoleID) > 0
             || MapTypes.Normal != Global.GetMapType(client.ClientData.MapCode)
             || )
             ||{
             || return ChangeNameError.SelfIsBusy;
             ||}
             */

            if (NameServerNamager.RegisterNameToNameServer(zoneId, uid, new string[] { newName }, 0, roleId) <= 0)
            {
                return(ChangeNameError.NameAlreayUsed);
            }

            int canFreeMod    = GameManager.VersionSystemOpenMgr.IsVersionSystemOpen(VersionSystemOpenKey.FreeModName) ? 1 : 0;
            int canZuanShiMod = GameManager.VersionSystemOpenMgr.IsVersionSystemOpen(VersionSystemOpenKey.ZuanShiModName) ? 1 : 0;

            // db上重点检查名字是否重复
            string[] dbRet = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_SPR_CHANGE_NAME,
                                                 string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}:{7}", uid, zoneId, roleId, newName, CostZuanShiBase, CostZuanShiMax, canFreeMod, canZuanShiMod),
                                                 GameManager.LocalServerId);
            if (dbRet == null || dbRet.Length != 4)
            {
                return(ChangeNameError.DBFailed);
            }

            int    ec          = Convert.ToInt32(dbRet[0]);
            string oldName     = dbRet[1];
            int    costDiamond = Convert.ToInt32(dbRet[2]);
            int    leftDiamond = Convert.ToInt32(dbRet[3]);

            if (ec == (int)ChangeNameError.Success)
            {
                if (costDiamond > 0)
                {
                    /**/ string msg = "改名 " + oldName + " -> " + newName;
                    Global.AddRoleUserMoneyEvent(roleId, "-", costDiamond, msg);
                    GameManager.logDBCmdMgr.AddDBLogInfo(-1, "钻石", "改名", oldName, newName, "减少", costDiamond, zoneId, uid, leftDiamond, GameManager.LocalServerId);
                    EventLogManager.AddMoneyEvent(GameManager.ServerId, zoneId, uid, roleId, OpTypes.AddOrSub, OpTags.Use, MoneyTypes.YuanBao, -costDiamond, -1, "改名");
                }
                _OnChangeNameSuccess(roleId, oldName, newName);
            }

            return((ChangeNameError)ec);
        }