public bool processCmdEx(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         lock (this.AuctionMsgMutex)
         {
             if (nID == 2080)
             {
                 GoldAuctionS2C msgData = new GoldAuctionS2C();
                 this.GetGlodAuction(client, nID, bytes, cmdParams, ref msgData);
                 client.sendCmd <GoldAuctionS2C>(nID, msgData, false);
             }
             else if (nID == 2081)
             {
                 int info = 0;
                 this.SetGlodAuction(client, nID, bytes, cmdParams, ref info);
                 client.sendCmd(nID, info.ToString(), false);
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
     return(true);
 }
 private void GetGlodAuction(GameClient client, int nID, byte[] bytes, string[] cmdParams, ref GoldAuctionS2C msgData)
 {
     try
     {
         int    Auctiontype = Convert.ToInt32(cmdParams[1]);
         int    ordeType    = Convert.ToInt32(cmdParams[2]);
         int    sortNum     = Convert.ToInt32(cmdParams[3]);
         int    startPage   = Convert.ToInt32(cmdParams[4]);
         int    maxNum      = Convert.ToInt32(cmdParams[5]);
         string Seach       = cmdParams[6];
         int    Color       = Convert.ToInt32(cmdParams[7]);
         if (!GoldAuctionManager.IsOpenAuction((AuctionOrderEnum)Auctiontype))
         {
             msgData.Info = 2;
         }
         else if (Auctiontype == 1 && client.ClientData.Faction < 1)
         {
             msgData.Info = 1;
         }
         else
         {
             this.GoldAuctionMgr.GetGoldAuctionS2C(Auctiontype, ordeType, sortNum, startPage, maxNum, Seach, Color, ref msgData);
             msgData.Info = 0;
         }
     }
     catch (Exception ex)
     {
         msgData.Info = 100;
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }
Пример #3
0
 public void GetGoldAuctionS2C(int Auctiontype, int ordeType, int sortNum, int startNum, int maxNum, string Seach, int Color, ref GoldAuctionS2C clientData)
 {
     try
     {
         lock (this.AuctionMutex)
         {
             string memKey = string.Format("{0}|{1}|{2}|{3}|{4}", new object[]
             {
                 Auctiontype,
                 ordeType,
                 sortNum,
                 Seach,
                 Color
             });
             int allNum = 0;
             List <AuctionItemS2C> dList = new List <AuctionItemS2C>();
             AuctionS2CCache       Cache;
             if (!this.S2CCache.TryGetValue(memKey, out Cache))
             {
                 Cache = new AuctionS2CCache();
                 foreach (GoldAuctionItem item in this.AuctionItemList)
                 {
                     if (item.AuctionType == Auctiontype)
                     {
                         allNum++;
                         AuctionItemS2C temp;
                         if (CopyData.Copy2AuctionItemS2C(item, out temp, Seach, Color))
                         {
                             dList.Add(temp);
                         }
                     }
                 }
                 dList.Sort(new GlodAuctionIComparer(ordeType, sortNum > 0));
                 Cache.MaxNum = allNum;
                 Cache.dList.AddRange(dList);
                 this.S2CCache.Add(memKey, Cache);
             }
             else
             {
                 allNum = Cache.MaxNum;
                 foreach (AuctionItemS2C item2 in Cache.dList)
                 {
                     string[] itemKey = item2.AuctionItemKey.Split(new char[]
                     {
                         '|'
                     });
                     GoldAuctionItem AuctionItem = this.getGoldAuctionItem(itemKey[0].Replace(',', ':'), Convert.ToInt32(itemKey[1]));
                     AuctionItemS2C  temp;
                     if (CopyData.Copy2AuctionItemS2C(item2, out temp, AuctionItem))
                     {
                         dList.Add(temp);
                     }
                 }
             }
             int len       = maxNum;
             int starIndex = (startNum - 1) * maxNum;
             clientData.CurrentPage = startNum;
             if (starIndex < 1 || starIndex >= dList.Count)
             {
                 clientData.CurrentPage = 1;
                 len = Math.Min(maxNum, dList.Count);
             }
             else if (starIndex + maxNum > dList.Count)
             {
                 len = dList.Count - starIndex;
             }
             clientData.TotalCount = allNum;
             clientData.ItemList.AddRange(dList.GetRange(starIndex, len));
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }