Exemple #1
0
        public static int LayerChangeDBCommand(GameClient client, int nLayerCount)
        {
            long   lFlushTime = TimeUtil.NOW();
            string strcmd     = string.Format("{0}:{1}:{2}:{3}:{4}:{5}", new object[]
            {
                client.ClientData.RoleID,
                lFlushTime,
                nLayerCount,
                "*",
                "*",
                "*"
            });
            ModifyWanMotaData modifyData = new ModifyWanMotaData
            {
                strParams      = strcmd,
                strSweepReward = "*"
            };

            string[] fields = Global.SendToDB <ModifyWanMotaData>(10158, modifyData, client.ServerId);
            int      result;

            if (fields == null || fields.Length != 2)
            {
                result = -1;
            }
            else
            {
                result = Convert.ToInt32(fields[1]);
            }
            return(result);
        }
Exemple #2
0
        public static int UpdateSweepAwardDBCommand(GameClient client, int nSweepLayerCount)
        {
            int result;

            if (null == client.ClientData.LayerRewardData)
            {
                result = -1;
            }
            else
            {
                string strLayerReward = "";
                lock (client.ClientData.LayerRewardData)
                {
                    if (-1 != nSweepLayerCount)
                    {
                        byte[] bytes = DataHelper.ObjectToBytes <LayerRewardData>(client.ClientData.LayerRewardData);
                        strLayerReward = Convert.ToBase64String(bytes);
                    }
                }
                string strcmd = string.Format("{0}:{1}:{2}:{3}:{4}:{5}", new object[]
                {
                    client.ClientData.RoleID,
                    "*",
                    "*",
                    nSweepLayerCount,
                    "*",
                    "*"
                });
                ModifyWanMotaData modifyData = new ModifyWanMotaData
                {
                    strParams      = strcmd,
                    strSweepReward = strLayerReward
                };
                string[] fields = Global.SendToDB <ModifyWanMotaData>(10158, modifyData, client.ServerId);
                if (fields == null || fields.Length != 2)
                {
                    result = -1;
                }
                else
                {
                    client.ClientData.WanMoTaProp.nSweepLayer    = nSweepLayerCount;
                    client.ClientData.WanMoTaProp.strSweepReward = strLayerReward;
                    result = Convert.ToInt32(fields[1]);
                }
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 扫荡开始时操作万魔塔数据库表
        /// </summary>
        public static int SweepBeginDBCommand(GameClient client, int nLayerCount)
        {
            long lBeginTime = TimeUtil.NOW();

            //roleID, flushTime, passLayerCount, sweepLayer, sweepReward, sweepBeginTime,
            string            strcmd     = string.Format("{0}:{1}:{2}:{3}:{4}:{5}", client.ClientData.RoleID, "*", "*", "1", "", lBeginTime);
            ModifyWanMotaData modifyData = new ModifyWanMotaData()
            {
                strParams      = strcmd,
                strSweepReward = "*",
            };

            string[] fields = Global.ExecuteDBCmd2 <ModifyWanMotaData>((int)TCPGameServerCmds.CMD_DB_MODIFY_WANMOTA, modifyData);
            if (null == fields || fields.Length != 2)
            {
                return(-1);
            }

            return(Convert.ToInt32(fields[1]));
        }
Exemple #4
0
        /// <summary>
        /// 更新扫荡层号与相应层的扫荡奖励
        /// </summary>
        public static int UpdateSweepAwardDBCommand(GameClient client, int nSweepLayerCount)
        {
            if (null == client.ClientData.LayerRewardData)
            {
                return(-1);
            }

            string strLayerReward = "";

            lock (client.ClientData.LayerRewardData)
            {
                if (-1 != nSweepLayerCount)
                {
                    byte[] bytes = DataHelper.ObjectToBytes <LayerRewardData>(client.ClientData.LayerRewardData);
                    strLayerReward = Convert.ToBase64String(bytes);
                }
            }

            //roleID, flushTime, passLayerCount, sweepLayer, sweepReward, sweepBeginTime,
            string            strcmd     = string.Format("{0}:{1}:{2}:{3}:{4}:{5}", client.ClientData.RoleID, "*", "*", nSweepLayerCount, "*", "*");
            ModifyWanMotaData modifyData = new ModifyWanMotaData()
            {
                strParams      = strcmd,
                strSweepReward = strLayerReward,
            };

            string[] fields = Global.ExecuteDBCmd2 <ModifyWanMotaData>((int)TCPGameServerCmds.CMD_DB_MODIFY_WANMOTA, modifyData);
            if (null == fields || fields.Length != 2)
            {
                return(-1);
            }

            // 保存本地万魔塔扫荡层数
            client.ClientData.WanMoTaProp.nSweepLayer    = nSweepLayerCount;
            client.ClientData.WanMoTaProp.strSweepReward = strLayerReward;
            return(Convert.ToInt32(fields[1]));
        }
 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);
     }
 }