private EChangeGuildNameError HandleChangeBangHuiName(GameClient client, string newName) { EChangeGuildNameError ne = EChangeGuildNameError.OperatorDenied; // 非法字符 if (string.IsNullOrEmpty(newName) || NameServerNamager.CheckInvalidCharacters(newName) <= 0) { ne = EChangeGuildNameError.InvalidName; } else if (!IsNameLengthOK(newName)) // 检测长度 { ne = EChangeGuildNameError.LengthError; } else { string[] result = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_SPR_CHANGE_BANGHUI_NAME, string.Format("{0}:{1}:{2}", client.ClientData.RoleID, client.ClientData.Faction, newName), client.ServerId); if (result == null || result.Length < 1) { ne = EChangeGuildNameError.DBFailed; } else { ne = (EChangeGuildNameError)Convert.ToInt32(result[0]); } } if (ne == EChangeGuildNameError.Success) { client.ClientData.BHName = newName; //通知所有指定帮会的在线用户帮会已经改名 GameManager.ClientMgr.NotifyBangHuiChangeName(client.ClientData.Faction, newName); //通知GameServer同步领地帮会分布 JunQiManager.NotifySyncBangHuiLingDiItemsDict(); //更新缓存项 Global.UpdateBangHuiMiniDataName(client.ClientData.Faction, newName); //罗兰城主 LuoLanChengZhanManager.getInstance().ReShowLuolanKing(); // pk之王 if (GameManager.ArenaBattleMgr.GetPKKingRoleID() == client.ClientData.RoleID) { GameManager.ArenaBattleMgr.ReShowPKKing(); } AllyManager.getInstance().UnionDataChange(client.ClientData.Faction, client.ServerId); } return(ne); }
private EChangeGuildNameError HandleChangeBangHuiName(GameClient client, string newName) { EChangeGuildNameError ne; if (string.IsNullOrEmpty(newName) || NameServerNamager.CheckInvalidCharacters(newName, false) <= 0) { ne = EChangeGuildNameError.InvalidName; } else if (!this.IsNameLengthOK(newName)) { ne = EChangeGuildNameError.LengthError; } else { string[] result = Global.ExecuteDBCmd(14006, string.Format("{0}:{1}:{2}", client.ClientData.RoleID, client.ClientData.Faction, newName), client.ServerId); if (result == null || result.Length < 1) { ne = EChangeGuildNameError.DBFailed; } else { ne = (EChangeGuildNameError)Convert.ToInt32(result[0]); } } if (ne == EChangeGuildNameError.Success) { client.ClientData.BHName = newName; GameManager.ClientMgr.NotifyBangHuiChangeName(client.ClientData.Faction, newName); JunQiManager.NotifySyncBangHuiLingDiItemsDict(); Global.UpdateBangHuiMiniDataName(client.ClientData.Faction, newName); LuoLanChengZhanManager.getInstance().ReShowLuolanKing(0); if (GameManager.ArenaBattleMgr.GetPKKingRoleID() == client.ClientData.RoleID) { GameManager.ArenaBattleMgr.ReShowPKKing(); } AllyManager.getInstance().UnionDataChange(client.ClientData.Faction, client.ServerId, false, 0); JunTuanManager.getInstance().OnBangHuiChangeName(client.ClientData.Faction, newName); } return(ne); }
private bool CreateOccupationSummoner(GameClient client, int nID, byte[] bytes, string[] cmdParams) { int PurchaseOccupationGoods = 0; lock (this.RuntimeData.Mutex) { PurchaseOccupationGoods = this.RuntimeData.PurchaseOccupationGoods; } bool result2; if (!SummonerData.CreateMapSet.Contains(client.CurrentMapCode)) { string strcmd = string.Format("{0}:{1}", -21, string.Format("{0}${1}${2}${3}${4}${5}", new object[] { "", "", "", "", "", "" })); client.sendCmd(nID, strcmd, false); result2 = true; } else { int GoodsNum = Global.GetTotalGoodsCountByID(client, PurchaseOccupationGoods); if (GoodsNum <= 0) { string strcmd = string.Format("{0}:{1}", -6, string.Format("{0}${1}${2}${3}${4}${5}", new object[] { "", "", "", "", "", "" })); client.sendCmd(nID, strcmd, false); result2 = true; } else { TMSKSocket clientSocket = GameManager.OnlineUserSession.FindSocketByUserID(client.strUserID); if (null == clientSocket) { result2 = true; } else { string userID = cmdParams[0]; string userName = cmdParams[1]; int sex = Convert.ToInt32(cmdParams[2]); int occup = Convert.ToInt32(cmdParams[3]); string[] nameAndPingTaiID = cmdParams[4].Split(new char[] { '$' }); int zoneID = Convert.ToInt32(cmdParams[5]); string deviceID = clientSocket.deviceID; if (sex != 1 || occup != 5 || !GameManager.SummonerMgr.IsVersionSystemOpenOfSummoner()) { string strcmd = string.Format("{0}:{1}", -12, string.Format("{0}${1}${2}${3}${4}${5}", new object[] { "", "", "", "", "", "" })); client.sendCmd(nID, strcmd, false); result2 = true; } else { string name = nameAndPingTaiID[0]; int ret = NameServerNamager.CheckInvalidCharacters(name, false); if (ret <= 0) { string strcmd = string.Format("{0}:{1}", ret, string.Format("{0}${1}${2}${3}${4}${5}", new object[] { "", "", "", "", "", "" })); client.sendCmd(nID, strcmd, false); result2 = true; } else if (!SingletonTemplate <NameManager> .Instance().IsNameLengthOK(name)) { string strcmd = string.Format("{0}:{1}", -2, string.Format("{0}${1}${2}${3}${4}${5}", new object[] { "", "", "", "", "", "" })); client.sendCmd(nID, strcmd, false); result2 = true; } else { ret = NameServerNamager.RegisterNameToNameServer(zoneID, userID, nameAndPingTaiID, 0, 0); if (ret <= 0) { string strcmd = string.Format("{0}:{1}", ret, string.Format("{0}${1}${2}${3}${4}${5}", new object[] { "", "", "", "", "", "" })); client.sendCmd(nID, strcmd, false); result2 = true; } else { int NotifyLeftTime = 0; if (!SingletonTemplate <CreateRoleLimitManager> .Instance().IfCanCreateRole(userID, userName, deviceID, ((IPEndPoint)clientSocket.RemoteEndPoint).Address.ToString(), out NotifyLeftTime)) { string strcmd = string.Format("{0}:{1}", -7, NotifyLeftTime); client.sendCmd(nID, strcmd, false); result2 = true; } else { string cmddata = string.Format("{0}:{1}", new UTF8Encoding().GetString(bytes, 0, bytes.Length), 1); byte[] bytesCmd = new UTF8Encoding().GetBytes(cmddata); TCPOutPacket tcpOutPacket = null; TCPProcessCmdResults result = Global.TransferRequestToDBServer(TCPManager.getInstance(), clientSocket, Global._TCPManager.tcpClientPool, TCPManager.getInstance().tcpRandKey, Global._TCPManager.TcpOutPacketPool, 102, bytesCmd, bytesCmd.Length, out tcpOutPacket, clientSocket.ServerId); if (null == tcpOutPacket) { result2 = true; } else { tcpOutPacket.PacketCmdID = (ushort)nID; string strCmdResult = null; tcpOutPacket.GetPacketCmdData(out strCmdResult); client.sendCmd(tcpOutPacket, true); if (null != strCmdResult) { string[] ResultField = strCmdResult.Split(new char[] { ':' }); if (ResultField.Length == 2 && Global.SafeConvertToInt32(ResultField[0]) == 1) { bool usedBinding = false; bool usedTimeLimited = false; GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, PurchaseOccupationGoods, 1, false, out usedBinding, out usedTimeLimited, false); SingletonTemplate <CreateRoleLimitManager> .Instance().ModifyCreateRoleNum(userID, userName, deviceID, ((IPEndPoint)clientSocket.RemoteEndPoint).Address.ToString()); string[] fields = ResultField[1].Split(new char[] { '$' }); int newRoleID = Global.SafeConvertToInt32(fields[0]); client.sendCmd <int>(13999, newRoleID, false); } } result2 = true; } } } } } } } } return(result2); }
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); }
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); }