/// <summary> /// 处理客户端查询七日活动 /// </summary> private bool HandleClientQuery(GameClient client, int nID, byte[] bytes, string[] cmdParams) { // 如果1.8的功能没开放 if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot8)) { return(false); } int act = Convert.ToInt32(cmdParams[1]); SevenDayActQueryData resultData = new SevenDayActQueryData(); resultData.ActivityType = act; resultData.ItemDict = null; TCPOutPacket packet = null; Dictionary <int, SevenDayItemData> itemData = GetActivityData(client, (ESevenDayActType)act); if (itemData == null) { packet = DataHelper.ObjectToTCPOutPacket(resultData, TCPOutPacketPool.getInstance(), nID); } else { // 外部会修改,锁住,保证原子性 lock (itemData) { resultData.ItemDict = itemData; if (act == (int)ESevenDayActType.Charge) { //为兼容老数据,七日充值数据,数据库保存的是人民币值,给客户端时,转换为钻石数 resultData.ItemDict = new Dictionary <int, SevenDayItemData>(); foreach (var kv in itemData) { resultData.ItemDict.Add(kv.Key, new SevenDayItemData() { AwardFlag = kv.Value.AwardFlag, Params1 = Global.TransMoneyToYuanBao(kv.Value.Params1), Params2 = kv.Value.Params2, }); } } packet = DataHelper.ObjectToTCPOutPacket(resultData, TCPOutPacketPool.getInstance(), nID); } } if (packet != null) { client.sendCmd(packet); } return(true); }
private bool HandleClientQuery(GameClient client, int nID, byte[] bytes, string[] cmdParams) { bool result; if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot8)) { result = false; } else { int act = Convert.ToInt32(cmdParams[1]); SevenDayActQueryData resultData = new SevenDayActQueryData(); resultData.ActivityType = act; resultData.ItemDict = null; TCPOutPacket packet = null; Dictionary <int, SevenDayItemData> itemData = this.GetActivityData(client, (ESevenDayActType)act); if (itemData == null) { packet = DataHelper.ObjectToTCPOutPacket <SevenDayActQueryData>(resultData, TCPOutPacketPool.getInstance(), nID); } else { lock (itemData) { resultData.ItemDict = itemData; if (act == 2) { resultData.ItemDict = new Dictionary <int, SevenDayItemData>(); foreach (KeyValuePair <int, SevenDayItemData> kv in itemData) { resultData.ItemDict.Add(kv.Key, new SevenDayItemData { AwardFlag = kv.Value.AwardFlag, Params1 = Global.TransMoneyToYuanBao(kv.Value.Params1), Params2 = kv.Value.Params2 }); } } packet = DataHelper.ObjectToTCPOutPacket <SevenDayActQueryData>(resultData, TCPOutPacketPool.getInstance(), nID); } } if (packet != null) { client.sendCmd(packet, true); } result = true; } return(result); }