Beispiel #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);
        }