public void ModifyWanMoTaPaihangData(WanMotaInfo data, bool bIsLogin)
		{
			if (null != data)
			{
				lock (this.rankingDatas)
				{
					PlayerWanMoTaRankingData result = this.rankingDatas.Find((PlayerWanMoTaRankingData paiHang) => paiHang.roleId == data.nRoleID);
					if (null == result)
					{
						if (this.rankingDatas.Count < WanMoTaManager.RankingList_Max_Num)
						{
							this.rankingDatas.Add(data.getPlayerWanMoTaRankingData());
						}
						else if (data.nPassLayerCount > this.rankingDatas[this.rankingDatas.Count - 1].passLayerCount)
						{
							this.rankingDatas.RemoveAt(this.rankingDatas.Count - 1);
							this.rankingDatas.Add(data.getPlayerWanMoTaRankingData());
						}
					}
					else if (!bIsLogin)
					{
						try
						{
							result.UpdateData(data);
							this.rankingDatas.Sort();
						}
						catch (Exception ex)
						{
							DataHelper.WriteFormatExceptionLog(ex, "", false, false);
						}
					}
				}
			}
		}
        public bool processCmd(Logic.GameClient client, string[] cmdParams)
        {
            int    nID     = (int)TCPGameServerCmds.CMD_SPR_GET_WANMOTA_DETAIL;
            int    nRoleID = Global.SafeConvertToInt32(cmdParams[0]);
            string strCmd  = "";

            WanMotaInfo data = WanMotaCopySceneManager.GetWanMoTaDetail(client, false);

            if (null == data)
            {
                strCmd = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", -1, nRoleID, 0, 0, 0, 0, 0);
                client.sendCmd(nID, strCmd);
                return(true);
            }
            else
            {
                strCmd = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", 0, nRoleID,
                                       data.nPassLayerCount,
                                       data.nTopPassLayerCount,
                                       SweepWanMotaManager.GetSweepCount(client),
                                       data.nSweepLayer,
                                       WanMotaCopySceneManager.WanmotaIsSweeping(client));

                if (WanMoTaTopLayer < data.nTopPassLayerCount)
                {
                    WanMoTaTopLayer = data.nTopPassLayerCount;
                }

                client.sendCmd(nID, strCmd);
                return(true);
            }
        }
        public void processCmd(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            int         roleId = DataHelper.BytesToObject <int>(cmdParams, 0, count);
            WanMotaInfo data   = WanMoTaManager.getInstance().getWanMoTaData(roleId);

            client.sendCmd <WanMotaInfo>(10159, data);
        }
Exemple #4
0
        public void processCmd(GameServerClient client, byte[] cmdParams, int count)
        {
            int roleId = DataHelper.BytesToObject <int>(cmdParams, 0, count);

            WanMotaInfo data = WanMoTaManager.getInstance().getWanMoTaData(roleId);

            client.sendCmd <WanMotaInfo>((int)TCPGameServerCmds.CMD_DB_GET_WANMOTA_DETAIL, data);
        }
        /// <summary>
        /// 获取万魔塔信息并缓存到本地
        /// </summary>
        /// <param name="mapCode"></param>
        /// <returns></returns>
        public static WanMotaInfo GetWanMoTaDetail(GameClient client, bool bIsLogin)
        {
            WanMotaInfo dataWanMoTa = null;

            // 在扫荡状态,不向数据库请求万魔塔数据
            if (1 == WanmotaIsSweeping(client))
            {
                //获取玩家竞技场数据
                dataWanMoTa = Global.sendToDB <WanMotaInfo>((int)TCPGameServerCmds.CMD_DB_GET_WANMOTA_DETAIL, DataHelper.ObjectToBytes <int>(client.ClientData.RoleID));

                client.ClientData.WanMoTaProp = dataWanMoTa;
            }
            else
            {
                dataWanMoTa = client.ClientData.WanMoTaProp;
            }

            if (null != dataWanMoTa)
            {
                if (bIsLogin)
                {
                    if (null != client.ClientData.WanMoTaProp)
                    {
                        byte[] bytes = Convert.FromBase64String(client.ClientData.WanMoTaProp.strSweepReward);
                        client.ClientData.LayerRewardData = DataHelper.BytesToObject <LayerRewardData>(bytes, 0, bytes.Length);
                    }
                }
                else
                {
                    // 选10条奖励信息发送到客户端
                    if (null != client.ClientData.LayerRewardData)
                    {
                        lock (client.ClientData.LayerRewardData)
                        {
                            if (client.ClientData.LayerRewardData.WanMoTaLayerRewardList.Count > 0)
                            {
                                int nBeginIndex = 0;
                                if (client.ClientData.LayerRewardData.WanMoTaLayerRewardList.Count > 10)
                                {
                                    nBeginIndex = client.ClientData.LayerRewardData.WanMoTaLayerRewardList.Count - 10;
                                }

                                List <SingleLayerRewardData> listRewardData = new List <SingleLayerRewardData>();
                                for (int i = nBeginIndex; i < client.ClientData.LayerRewardData.WanMoTaLayerRewardList.Count; i++)
                                {
                                    listRewardData.Add(client.ClientData.LayerRewardData.WanMoTaLayerRewardList[i]);
                                }

                                SweepWanMotaManager.UpdataSweepInfo(client, listRewardData);
                            }
                        }
                    }
                }
            }

            return(dataWanMoTa);
        }
		internal void OnChangeName(int roleid, string oldName, string newName)
		{
			WanMotaInfo info = this.getWanMoTaData(roleid);
			if (info != null)
			{
				info.strRoleName = newName;
			}
			WanMoTaDBController.getInstance().OnChangeName(roleid, oldName, newName);
		}
		public void onPlayerLogout(int roleId)
		{
			WanMotaInfo data = null;
			lock (this.playerWanMoTaDatas)
			{
				this.playerWanMoTaDatas.TryGetValue(roleId, out data);
				if (null != data)
				{
					this.playerWanMoTaDatas.Remove(roleId);
				}
			}
		}
Exemple #8
0
        /// <summary>
        /// 修改万魔塔排行榜数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public void ModifyWanMoTaPaihangData(WanMotaInfo data, bool bIsLogin)
        {
            if (null == data)
            {
                return;
            }

            lock (rankingDatas)
            {
                PlayerWanMoTaRankingData result = rankingDatas.Find(
                    delegate(PlayerWanMoTaRankingData paiHang)
                {
                    return(paiHang.roleId == data.nRoleID);
                }
                    );

                // 如果没有在排行榜中,看看能不能添加
                if (null == result)
                {
                    // 排行榜数据量是有限制的
                    if (rankingDatas.Count < RankingList_Max_Num)
                    {
                        rankingDatas.Add(data.getPlayerWanMoTaRankingData());
                    }
                    else
                    {
                        // 如果数据好于排行榜最后一名,把排行榜最后移除掉,用其代替
                        if (data.nPassLayerCount > rankingDatas[rankingDatas.Count - 1].passLayerCount)
                        {
                            rankingDatas.RemoveAt(rankingDatas.Count - 1);
                            rankingDatas.Add(data.getPlayerWanMoTaRankingData());
                        }
                    }
                }
                // 在排行榜中,用新数据重新排序
                else
                {
                    // 由参数控制,登录时数据没有改变,不需要重新排序
                    if (!bIsLogin)
                    {
                        try
                        {
                            rankingDatas.Sort();
                        }
                        catch (Exception ex)
                        {
                            DataHelper.WriteFormatExceptionLog(ex, "", false);
                        }
                    }
                }
            }
        }
		public WanMotaInfo getWanMoTaData(int nRoleID)
		{
			WanMotaInfo data = null;
			lock (this.playerWanMoTaDatas)
			{
				if (this.playerWanMoTaDatas.TryGetValue(nRoleID, out data))
				{
					data.nTopPassLayerCount = this.rankingDatas[0].passLayerCount;
					return data;
				}
			}
			return data;
		}
		public int createWanMoTaData(WanMotaInfo data)
		{
			lock (this.playerWanMoTaDatas)
			{
				if (this.playerWanMoTaDatas.ContainsKey(data.nRoleID))
				{
					return 0;
				}
				this.playerWanMoTaDatas.Add(data.nRoleID, data);
			}
			this.ModifyWanMoTaPaihangData(data, true);
			return WanMoTaDBController.getInstance().insertWanMoTaData(TCPManager.getInstance().DBMgr, data);
		}
Exemple #11
0
        public bool processCmd(GameClient client, string[] cmdParams)
        {
            int         nID     = 618;
            int         nRoleID = Global.SafeConvertToInt32(cmdParams[0]);
            WanMotaInfo data    = WanMotaCopySceneManager.GetWanMoTaDetail(client, false);
            bool        result;

            if (null == data)
            {
                string strCmd = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", new object[]
                {
                    -1,
                    nRoleID,
                    0,
                    0,
                    0,
                    0,
                    0
                });
                client.sendCmd(nID, strCmd, false);
                result = true;
            }
            else
            {
                if (data.nPassLayerCount != client.ClientData.WanMoTaNextLayerOrder)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("角色roleid={0} 万魔塔层数不一致 nPassLayerCount={1}, WanMoTaNextLayerOrder={2}", client.ClientData.RoleID, data.nPassLayerCount, client.ClientData.WanMoTaNextLayerOrder), null, true);
                    client.ClientData.WanMoTaNextLayerOrder = data.nPassLayerCount;
                    GameManager.ClientMgr.SaveWanMoTaPassLayerValue(client, data.nPassLayerCount, true);
                }
                string strCmd = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", new object[]
                {
                    0,
                    nRoleID,
                    data.nPassLayerCount,
                    data.nTopPassLayerCount,
                    SweepWanMotaManager.GetSweepCount(client),
                    data.nSweepLayer,
                    WanMotaCopySceneManager.WanmotaIsSweeping(client)
                });
                SingletonTemplate <WanMoTaTopLayerManager> .Instance().CheckNeedUpdate(data.nTopPassLayerCount);

                client.sendCmd(nID, strCmd, false);
                result = true;
            }
            return(result);
        }
        public static WanMotaInfo GetWanMoTaDetail(GameClient client, bool bIsLogin)
        {
            WanMotaInfo dataWanMoTa = null;

            if (1 == WanMotaCopySceneManager.WanmotaIsSweeping(client))
            {
                dataWanMoTa = Global.sendToDB <WanMotaInfo, byte[]>(10159, DataHelper.ObjectToBytes <int>(client.ClientData.RoleID), client.ServerId);
                client.ClientData.WanMoTaProp = dataWanMoTa;
            }
            else
            {
                dataWanMoTa = client.ClientData.WanMoTaProp;
            }
            if (null != dataWanMoTa)
            {
                if (bIsLogin)
                {
                    if (null != client.ClientData.WanMoTaProp)
                    {
                        byte[] bytes = Convert.FromBase64String(client.ClientData.WanMoTaProp.strSweepReward);
                        client.ClientData.LayerRewardData = DataHelper.BytesToObject <LayerRewardData>(bytes, 0, bytes.Length);
                    }
                }
                else if (null != client.ClientData.LayerRewardData)
                {
                    lock (client.ClientData.LayerRewardData)
                    {
                        if (client.ClientData.LayerRewardData.WanMoTaLayerRewardList.Count > 0)
                        {
                            int nBeginIndex = 0;
                            if (client.ClientData.LayerRewardData.WanMoTaLayerRewardList.Count > 10)
                            {
                                nBeginIndex = client.ClientData.LayerRewardData.WanMoTaLayerRewardList.Count - 10;
                            }
                            List <SingleLayerRewardData> listRewardData = new List <SingleLayerRewardData>();
                            for (int i = nBeginIndex; i < client.ClientData.LayerRewardData.WanMoTaLayerRewardList.Count; i++)
                            {
                                listRewardData.Add(client.ClientData.LayerRewardData.WanMoTaLayerRewardList[i]);
                            }
                            SweepWanMotaManager.UpdataSweepInfo(client, listRewardData);
                        }
                    }
                }
            }
            return(dataWanMoTa);
        }
Exemple #13
0
        /// <summary>
        /// 创建万魔塔数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public int createWanMoTaData(WanMotaInfo data)
        {
            lock (playerWanMoTaDatas)
            {
                if (playerWanMoTaDatas.ContainsKey(data.nRoleID))
                {
                    return(0);
                }

                playerWanMoTaDatas.Add(data.nRoleID, data);
            }

            // 添加更新万魔塔排行榜数据
            ModifyWanMoTaPaihangData(data, true);

            return(WanMoTaDBController.getInstance().insertWanMoTaData(TCPManager.getInstance().DBMgr, data));
        }
        public bool processCmd(Logic.GameClient client, string[] cmdParams)
        {
            int    nID     = (int)TCPGameServerCmds.CMD_SPR_GET_WANMOTA_DETAIL;
            int    nRoleID = Global.SafeConvertToInt32(cmdParams[0]);
            string strCmd  = "";

            WanMotaInfo data = WanMotaCopySceneManager.GetWanMoTaDetail(client, false);

            if (null == data)
            {
                strCmd = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", -1, nRoleID, 0, 0, 0, 0, 0);
                client.sendCmd(nID, strCmd);
                return(true);
            }
            else
            {
                if (data.nPassLayerCount != client.ClientData.WanMoTaNextLayerOrder)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("角色roleid={0} 万魔塔层数不一致 nPassLayerCount={1}, WanMoTaNextLayerOrder={2}", client.ClientData.RoleID, data.nPassLayerCount, client.ClientData.WanMoTaNextLayerOrder));
                    client.ClientData.WanMoTaNextLayerOrder = data.nPassLayerCount;
                    //WanMoTaDBCommandManager.LayerChangeDBCommand(client, data.nPassLayerCount);
                    GameManager.ClientMgr.SaveWanMoTaPassLayerValue(client, data.nPassLayerCount, true);
                }

                strCmd = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", 0, nRoleID,
                                       data.nPassLayerCount,
                                       data.nTopPassLayerCount,
                                       SweepWanMotaManager.GetSweepCount(client),
                                       data.nSweepLayer,
                                       WanMotaCopySceneManager.WanmotaIsSweeping(client));

                // modify by chenjingui. 20150717,解决多线程操作问题
                // 其实应该在GameServer启动的时候,加载一次万魔塔最高通关,暂时先按照原有方式
                WanMoTaTopLayerManager.Instance().CheckNeedUpdate(data.nTopPassLayerCount);

                /*
                 * if (WanMoTaTopLayer < data.nTopPassLayerCount)
                 * {
                 *  WanMoTaTopLayer = data.nTopPassLayerCount;
                 * }*/

                client.sendCmd(nID, strCmd);
                return(true);
            }
        }
Exemple #15
0
        /// <summary>
        /// 创建万魔塔数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public WanMotaInfo getWanMoTaData(int nRoleID)
        {
            WanMotaInfo data = null;

            lock (playerWanMoTaDatas)
            {
                if (playerWanMoTaDatas.TryGetValue(nRoleID, out data))
                {
                    // 获取最高通关层数
                    data.nTopPassLayerCount = rankingDatas[0].passLayerCount;
                    return(data);
                }
            }

            // 没有找到的话直接返回空
            // 因为在登录时有处理,这里不找重复处理
            return(data);
        }
Exemple #16
0
        /// <summary>
        /// 玩家上线初始化时获取玩家万魔塔数据
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public void onPlayerLogin(int roleId, string strRoleName)
        {
            WanMotaInfo data = null;

            lock (playerWanMoTaDatas)
            {
                if (playerWanMoTaDatas.TryGetValue(roleId, out data))
                {
                    return;
                }
            }

            if (null == data)
            {
                data = WanMoTaDBController.getInstance().getPlayerWanMoTaDataById(roleId);
                if (null == data)
                {
                    // 数据库中没有万魔塔数据,插入相应的数据
                    WanMotaInfo newData = new WanMotaInfo();
                    newData.nRoleID     = roleId;
                    newData.strRoleName = strRoleName;
                    newData.lFlushTime  = TimeUtil.NOW();
                    newData.nSweepLayer = -1;

                    createWanMoTaData(newData);
                }
                else
                {
                    // 添加更新万魔塔排行榜数据
                    ModifyWanMoTaPaihangData(data, true);

                    lock (playerWanMoTaDatas)
                    {
                        playerWanMoTaDatas.Add(data.nRoleID, data);
                    }
                }
            }
        }
		public void onPlayerLogin(int roleId, string strRoleName)
		{
			WanMotaInfo data = null;
			lock (this.playerWanMoTaDatas)
			{
				if (this.playerWanMoTaDatas.TryGetValue(roleId, out data))
				{
					if (null != data)
					{
						return;
					}
				}
			}
			if (null == data)
			{
				data = WanMoTaDBController.getInstance().getPlayerWanMoTaDataById(roleId);
				if (null == data)
				{
					this.createWanMoTaData(new WanMotaInfo
					{
						nRoleID = roleId,
						strRoleName = strRoleName,
						lFlushTime = TimeUtil.NOW(),
						nSweepLayer = -1
					});
				}
				else
				{
					this.ModifyWanMoTaPaihangData(data, true);
					lock (this.playerWanMoTaDatas)
					{
						this.playerWanMoTaDatas.Add(data.nRoleID, data);
					}
				}
			}
		}
 public void processCmd(GameServerClient client, int nID, byte[] cmdParams, int count)
 {
     try
     {
         ModifyWanMotaData modifyData = DataHelper.BytesToObject <ModifyWanMotaData>(cmdParams, 0, count);
         if (null == modifyData)
         {
             LogManager.WriteLog(LogTypes.Error, string.Format("指令参数传输错误, CMD={0}, CmdData={2}", TCPGameServerCmds.CMD_DB_MODIFY_WANMOTA, cmdParams), null, true);
             client.sendCmd(10158, string.Format("{0}:{1}", 0, -1));
         }
         else
         {
             string   cmd    = modifyData.strParams;
             string[] fields = cmd.Split(new char[]
             {
                 ':'
             });
             if (fields.Length != 6)
             {
                 LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", TCPGameServerCmds.CMD_DB_MODIFY_WANMOTA, fields.Length, cmdParams), null, true);
                 client.sendCmd(10158, string.Format("{0}:{1}", 0, -1));
             }
             else
             {
                 fields[4] = modifyData.strSweepReward;
                 int         roleID      = Convert.ToInt32(fields[0]);
                 WanMotaInfo dataWanMota = WanMoTaManager.getInstance().getWanMoTaData(roleID);
                 if (null == dataWanMota)
                 {
                     LogManager.WriteLog(LogTypes.Error, string.Format("没有找到相应的万魔塔信息,CMD={0}, RoleID={1}", TCPGameServerCmds.CMD_DB_MODIFY_WANMOTA, roleID), null, true);
                     client.sendCmd(10158, string.Format("{0}:{1}", 0, -1));
                 }
                 else
                 {
                     int ret = WanMoTaManager.getInstance().updateWanMoTaData(roleID, fields, 1);
                     if (ret < 0)
                     {
                         LogManager.WriteLog(LogTypes.Error, string.Format("数据库更新万魔塔数据失败,CMD={0}, RoleID={1}", TCPGameServerCmds.CMD_DB_MODIFY_WANMOTA, roleID), null, true);
                     }
                     else
                     {
                         bool bPassLayerCountChange = false;
                         lock (dataWanMota)
                         {
                             dataWanMota.lFlushTime = DataHelper.ConvertToInt64(fields[1], dataWanMota.lFlushTime);
                             int nPassLayerCount = DataHelper.ConvertToInt32(fields[2], dataWanMota.nPassLayerCount);
                             dataWanMota.nSweepLayer     = DataHelper.ConvertToInt32(fields[3], dataWanMota.nSweepLayer);
                             dataWanMota.strSweepReward  = DataHelper.ConvertToStr(fields[4], dataWanMota.strSweepReward);
                             dataWanMota.lSweepBeginTime = DataHelper.ConvertToInt64(fields[5], dataWanMota.lSweepBeginTime);
                             if (nPassLayerCount != dataWanMota.nPassLayerCount)
                             {
                                 dataWanMota.nPassLayerCount = nPassLayerCount;
                                 bPassLayerCountChange       = true;
                             }
                         }
                         if (bPassLayerCountChange)
                         {
                             WanMoTaManager.getInstance().ModifyWanMoTaPaihangData(dataWanMota, false);
                         }
                     }
                     string strcmd = string.Format("{0}:{1}", roleID, ret);
                     client.sendCmd(10158, strcmd);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "", false, false);
         string strcmd = string.Format("{0}:{1}", 0, -1);
     }
 }