public void processCmdUpdateBuildLog(GameServerClient client, int nID, byte[] cmdParams, int count) { string cmdData = null; try { cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); client.sendCmd(30767, "0"); return; } string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 2) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd(30767, "0"); } else { string TimeLog = fields[0]; BuildingLogType LogType = (BuildingLogType)Convert.ToInt32(fields[1]); DBManager dbMgr = DBManager.getInstance(); DBWriter.UpdateBuildingLog(dbMgr, TimeLog, LogType); string strcmd = string.Format("{0}", 0); client.sendCmd(nID, strcmd); } }
public void processCmd(GameServerClient client, byte[] cmdParams, int count) { string cmdData = null; int nID = 20002; try { cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID)); client.sendCmd(32767, "0"); return; } string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 24) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData)); client.sendCmd(32767, "0"); } else { DBItemLogWriter.getInstance().insertTradeNumLog(DBManager.getInstance(), fields); string strcmd = string.Format("{0}", 1); client.sendCmd(nID, strcmd); } }
public void processCmd(GameServerClient client, byte[] cmdParams, int count) { string cmdData = null; int nID = (int)TCPGameServerCmds.CMD_SPR_GETBAITANLOG; try { cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); } catch (Exception) //解析错误 { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID)); client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, "0"); return; } List <BaiTanLogItemData> list = new List <BaiTanLogItemData>(); string[] fields = cmdData.Split(':'); if (fields.Length != 2) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData)); client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, list); return; } int rid = Convert.ToInt32(fields[0]); int pageIndex = Convert.ToInt32(fields[1]); client.sendCmd <List <BaiTanLogItemData> >((int)TCPGameServerCmds.CMD_SPR_GETBAITANLOG, BaiTanManager.getInstance().getDetailByPageIndex(rid, pageIndex)); }
private void CheckRoleZuoQiData(GameServerClient client, int nID, byte[] cmdParams, int count) { try { string cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); int roleID = Convert.ToInt32(cmdData); DBRoleInfo dbRoleInfo = DBManager.getInstance().FindDBRoleInfo(ref roleID); if (null == dbRoleInfo) { LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true); client.sendCmd(30767, "0"); } else { using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("update t_zuoqi set isnew=0 where rid={0}", roleID); conn.ExecuteNonQuery(cmdText, 0); } foreach (MountData item in dbRoleInfo.MountList) { item.IsNew = false; } client.sendCmd <int>(nID, 1); } } catch (Exception ex) { LogManager.WriteException(ex.Message); client.sendCmd <int>(nID, -8); } }
private void OlympicsGuess(GameServerClient client, int nID, byte[] cmdParams, int count) { string[] fields = null; int length = 2; if (!CheckHelper.CheckTCPCmdFields(nID, cmdParams, count, out fields, length)) { client.sendCmd <bool>(nID, false); } else { int roleID = int.Parse(fields[0]); int dayID = int.Parse(fields[1]); OlympicsGuessDataDB data = new OlympicsGuessDataDB(); data.RoleID = roleID; data.DayID = dayID; using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("SELECT a1,a2,a3,award1,award2,award3 FROM t_olympics_guess WHERE roleID='{0}' and dayID='{1}' ", roleID, dayID); MySQLDataReader reader = conn.ExecuteReader(cmdText, new MySQLParameter[0]); while (reader.Read()) { data.A1 = int.Parse(reader["a1"].ToString()); data.A2 = int.Parse(reader["a2"].ToString()); data.A3 = int.Parse(reader["a3"].ToString()); data.Award1 = int.Parse(reader["award1"].ToString()); data.Award2 = int.Parse(reader["award2"].ToString()); data.Award3 = int.Parse(reader["award3"].ToString()); } } client.sendCmd <OlympicsGuessDataDB>(nID, data); } }
private void HandleGetZhanBao(GameServerClient client, int nID, byte[] cmdParams, int count) { try { string cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 2) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd(30767, "0"); } else { int role = Convert.ToInt32(fields[0]); int role2 = Convert.ToInt32(fields[1]); long unionCouple = this.GetUnionCouple(role, role2); List <CoupleArenaZhanBaoItemData> result = this.GetZhanBao(unionCouple).ToList <CoupleArenaZhanBaoItemData>(); result.Reverse(); client.sendCmd <List <CoupleArenaZhanBaoItemData> >(nID, result); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, "HandleGetZhanBao failed, " + ex.Message, null, true); client.sendCmd(30767, "0"); } }
public void processCmd(GameServerClient client, int nID, byte[] cmdParams, int count) { string cmdData = null; try { cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); client.sendCmd(30767, "0"); return; } List <BaiTanLogItemData> list = new List <BaiTanLogItemData>(); string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 2) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd <List <BaiTanLogItemData> >(30767, list); } else { int rid = Convert.ToInt32(fields[0]); int pageIndex = Convert.ToInt32(fields[1]); client.sendCmd <List <BaiTanLogItemData> >(603, BaiTanManager.getInstance().getDetailByPageIndex(rid, pageIndex)); } }
public void processCmd(GameServerClient client, byte[] cmdParams, int count) { string cmdData = null; int nID = (int)TCPGameServerCmds.CMD_DB_ADD_BAITANLOG; try { cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); } catch (Exception) //解析错误 { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID)); client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, "0"); return; } string[] fields = cmdData.Split(':'); if (fields.Length != 12) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData)); client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, "0"); return; } int roleID = Convert.ToInt32(fields[0]); int otherroleid = Convert.ToInt32(fields[1]); string otherrname = fields[2]; int goodsid = Convert.ToInt32(fields[3]); int goodsnum = Convert.ToInt32(fields[4]); int forgelevel = Convert.ToInt32(fields[5]); int totalprice = Convert.ToInt32(fields[6]); int leftyuanbao = Convert.ToInt32(fields[7]); int YinLiang = Convert.ToInt32(fields[8]); int LeftYinLiang = Convert.ToInt32(fields[9]); int tax = Convert.ToInt32(fields[10]); int excellenceinfo = Convert.ToInt32(fields[11]); BaiTanLogItemData data = new BaiTanLogItemData(); data.rid = roleID; data.OtherRoleID = otherroleid; data.OtherRName = otherrname; data.GoodsID = goodsid; data.GoodsNum = goodsnum; data.ForgeLevel = forgelevel; data.TotalPrice = totalprice; data.LeftYuanBao = leftyuanbao; data.YinLiang = YinLiang; data.LeftYinLiang = LeftYinLiang; data.BuyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); data.Tax = tax; data.Excellenceinfo = excellenceinfo; BaiTanManager.getInstance().onAddBaiTanLog(data); client.sendCmd <string>((int)TCPGameServerCmds.CMD_DB_ADD_BAITANLOG, string.Format("{0}", 0)); }
public void processCmdUpdateBuildData(GameServerClient client, int nID, byte[] cmdParams, int count) { string cmdData = null; try { cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); client.sendCmd(30767, "0"); return; } string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 9) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd(30767, "0"); } else { BuildingData myBuildData = new BuildingData(); int roleID = Convert.ToInt32(fields[0]); myBuildData.BuildId = Convert.ToInt32(fields[1]); myBuildData.BuildLev = Convert.ToInt32(fields[2]); myBuildData.BuildExp = Convert.ToInt32(fields[3]); myBuildData.TaskID_1 = Convert.ToInt32(fields[5]); myBuildData.TaskID_2 = Convert.ToInt32(fields[6]); myBuildData.TaskID_3 = Convert.ToInt32(fields[7]); myBuildData.TaskID_4 = Convert.ToInt32(fields[8]); myBuildData.BuildTime = fields[4].Replace('$', ':'); DBManager dbMgr = DBManager.getInstance(); DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref roleID); if (null == dbRoleInfo) { LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true); client.sendCmd(30767, "0"); } else { lock (dbRoleInfo) { if (null == dbRoleInfo.BuildingDataList) { dbRoleInfo.BuildingDataList = new List <BuildingData>(); } this.UpdateBuildData(dbRoleInfo.BuildingDataList, myBuildData); } DBWriter.UpdateBuildingData(dbMgr, roleID, myBuildData); string strcmd = string.Format("{0}", 0); client.sendCmd(nID, strcmd); } } }
private void HandleLoadPkLog(GameServerClient client, int nID, byte[] cmdParams, int count) { string cmdData = null; try { cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); client.sendCmd(30767, "0"); return; } string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 2) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd(30767, "0"); } else { int month = Convert.ToInt32(fields[0]); int maxNum = Convert.ToInt32(fields[1]); string sql = string.Format("SELECT month,day,rid1,zoneid1,rname1,ismirror1,rid2,zoneid2,rname2,ismirror2,result,upgrade,starttime,endtime FROM t_zhengba_pk_log WHERE month={0} ORDER BY endtime DESC LIMIT {1};", month, maxNum); MySQLDataReader reader = this.ExecSelect(sql); List <ZhengBaPkLogData> logList = new List <ZhengBaPkLogData>(); while (reader != null && reader.Read()) { logList.Add(new ZhengBaPkLogData { Day = Convert.ToInt32(reader["day"].ToString()), Month = Convert.ToInt32(reader["month"].ToString()), RoleID1 = Convert.ToInt32(reader["rid1"].ToString()), ZoneID1 = Convert.ToInt32(reader["zoneid1"].ToString()), RoleName1 = reader["rname1"].ToString(), IsMirror1 = (Convert.ToInt32(reader["ismirror1"].ToString()) == 1), RoleID2 = Convert.ToInt32(reader["rid2"].ToString()), ZoneID2 = Convert.ToInt32(reader["zoneid2"].ToString()), RoleName2 = reader["rname2"].ToString(), IsMirror2 = (Convert.ToInt32(reader["ismirror2"].ToString()) == 1), PkResult = Convert.ToInt32(reader["result"].ToString()), UpGrade = (Convert.ToInt32(reader["upgrade"].ToString()) == 1), StartTime = DateTime.Parse(reader["starttime"].ToString()), EndTime = DateTime.Parse(reader["endtime"].ToString()) }); } logList.Reverse(); client.sendCmd <List <ZhengBaPkLogData> >(nID, logList); } }
public void UserReturnDataList(GameServerClient client, int nID, byte[] cmdParams, int count) { List <ReturnData> result = new List <ReturnData>(); string[] fields = null; try { int length = 4; if (!CheckHelper.CheckTCPCmdFields(nID, cmdParams, count, out fields, length)) { client.sendCmd <List <ReturnData> >(nID, result); return; } string activityDay = fields[0]; int activityID = int.Parse(fields[1]); int zoneID = int.Parse(fields[2]); int roleID = int.Parse(fields[3]); using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("SELECT id,activityID,activityDay,pzoneID,proleID,czoneID,croleID,vip,`level`,logTime,checkState,logState \r\n FROM t_user_return_back \r\n WHERE activityDay='{0}' AND activityID={1} AND pzoneID={2} AND proleID={3} AND logState=0 ", new object[] { activityDay, activityID, zoneID, roleID }); MySQLDataReader reader = conn.ExecuteReader(cmdText, new MySQLParameter[0]); while (reader.Read()) { result.Add(new ReturnData { DBID = Convert.ToInt32(reader["id"].ToString()), ActivityID = Convert.ToInt32(reader["activityID"].ToString()), ActivityDay = reader["activityDay"].ToString(), PZoneID = Convert.ToInt32(reader["pzoneID"].ToString()), PRoleID = Convert.ToInt32(reader["proleID"].ToString()), CZoneID = Convert.ToInt32(reader["czoneID"].ToString()), CRoleID = Convert.ToInt32(reader["croleID"].ToString()), Vip = Convert.ToInt32(reader["vip"].ToString()), Level = Convert.ToInt32(reader["level"].ToString()), LogTime = Convert.ToDateTime(reader["logTime"].ToString()), StateCheck = Convert.ToInt32(reader["checkState"].ToString()), StateLog = Convert.ToInt32(reader["logState"].ToString()) }); } } } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "", false, false); } client.sendCmd <List <ReturnData> >(nID, result); }
private void UpdateRoleJueXingData(GameServerClient client, int nID, byte[] cmdParams, int count) { try { string cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 3) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd <int>(nID, -4); } int roleID = Convert.ToInt32(fields[0]); int suitid = Convert.ToInt32(fields[1]); string activite = fields[2]; DBRoleInfo dbRoleInfo = DBManager.getInstance().FindDBRoleInfo(ref roleID); if (null == dbRoleInfo) { LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true); client.sendCmd(30767, "0"); } else { using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("REPLACE INTO t_juexing(rid, suitid, activite) VALUES('{0}', '{1}', '{2}')", roleID, suitid, activite); conn.ExecuteNonQuery(cmdText, 0); } TaoZhuangData suitData = dbRoleInfo.JueXingTaoZhuangList.Find((TaoZhuangData _g) => _g.ID == suitid); if (null == suitData) { suitData = new TaoZhuangData { ID = suitid, ActiviteList = new List <int>() }; dbRoleInfo.JueXingTaoZhuangList.Add(suitData); } suitData.ActiviteList = Array.ConvertAll <string, int>(activite.Split(new char[] { ',' }), (string x) => Convert.ToInt32(x)).ToList <int>(); client.sendCmd <int>(nID, 0); } } catch (Exception ex) { LogManager.WriteException(ex.Message); client.sendCmd <int>(nID, -8); } }
private void SetRoleZuoQiData(GameServerClient client, int nID, byte[] cmdParams, int count) { try { string cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 3) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd <int>(nID, -4); } int roleID = Convert.ToInt32(fields[0]); int goodsID = Convert.ToInt32(fields[1]); int isNew = Convert.ToInt32(fields[2]); DBRoleInfo dbRoleInfo = DBManager.getInstance().FindDBRoleInfo(ref roleID); if (null == dbRoleInfo) { LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true); client.sendCmd(30767, "0"); } else { using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("REPLACE INTO t_zuoqi(rid, goodsid, isnew) VALUES('{0}', '{1}', '{2}')", roleID, goodsID, isNew); conn.ExecuteNonQuery(cmdText, 0); } MountData mountData = dbRoleInfo.MountList.Find((MountData _g) => _g.GoodsID == goodsID); if (null == mountData) { mountData = new MountData { GoodsID = goodsID, IsNew = (1 == isNew) }; dbRoleInfo.MountList.Add(mountData); } else { mountData.IsNew = (1 == isNew); } client.sendCmd <int>(nID, 1); } } catch (Exception ex) { LogManager.WriteException(ex.Message); client.sendCmd <int>(nID, -8); } }
private void AllyLogAdd(GameServerClient client, int nID, byte[] cmdParams, int count) { bool bResult = false; AllyLogData item = DataHelper.BytesToObject <AllyLogData>(cmdParams, 0, count); if (item == null) { client.sendCmd <bool>(nID, bResult); } else { lock (this._lock) { if (!this._allyLogDic.ContainsKey(item.MyUnionID)) { List <AllyLogData> list = this.GetAllyLogData(item.MyUnionID); this._allyLogDic.Add(item.MyUnionID, list); } using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("INSERT INTO t_ally_log(myUnionID,unionID,unionZoneID,unionName,logTime,logState) VALUE('{0}','{1}','{2}','{3}','{4}','{5}')", new object[] { item.MyUnionID, item.UnionID, item.UnionZoneID, item.UnionName, item.LogTime, item.LogState }); bResult = (conn.ExecuteNonQuery(cmdText, 0) > 0); } if (bResult && item != null && item.MyUnionID > 0) { if (this._allyLogDic.ContainsKey(item.MyUnionID)) { List <AllyLogData> list = this._allyLogDic[item.MyUnionID]; list.Insert(0, item); if (list.Count > 20) { list.RemoveRange(20, list.Count - 20); } } else { List <AllyLogData> list = this.GetAllyLogData(item.MyUnionID); list.Add(item); this._allyLogDic.Add(item.MyUnionID, list); } } client.sendCmd <bool>(nID, bResult); } } }
public TCPProcessCmdResults ProcessUpdateFluorescentPointCmd(DBManager dbMgr, GameServerClient client, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string cmdData = null; bool bRet = false; try { cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); client.sendCmd <bool>(nID, bRet); return(TCPProcessCmdResults.RESULT_OK); } try { string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 2) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd <bool>(nID, bRet); return(TCPProcessCmdResults.RESULT_OK); } int nRoleID = Convert.ToInt32(fields[0]); int nPoint = Convert.ToInt32(fields[1]); DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref nRoleID); if (null == dbRoleInfo) { LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, nRoleID), null, true); client.sendCmd <bool>(nID, bRet); return(TCPProcessCmdResults.RESULT_OK); } bRet = FluorescentGemDBOperate.UpdateFluorescentPoint(dbMgr, nRoleID, nPoint); lock (dbRoleInfo) { dbRoleInfo.FluorescentPoint = nPoint; } client.sendCmd <bool>(nID, bRet); return(TCPProcessCmdResults.RESULT_OK); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "", false, false); } client.sendCmd <bool>(nID, bRet); return(TCPProcessCmdResults.RESULT_OK); }
private void UpdateRoleFuWenTab(GameServerClient client, int nID, byte[] cmdParams, int count) { try { FuWenTabData newTab = DataHelper.BytesToObject <FuWenTabData>(cmdParams, 0, count); int roleID = newTab.OwnerID; DBRoleInfo dbRoleInfo = DBManager.getInstance().FindDBRoleInfo(ref roleID); if (null == dbRoleInfo) { LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true); client.sendCmd(30767, "0"); } else { bool ret = false; using (MyDbConnection3 conn = new MyDbConnection3(false)) { string fuWenEquip = (newTab.FuWenEquipList == null) ? "" : string.Join <int>(",", newTab.FuWenEquipList); string shenShiActive = (newTab.ShenShiActiveList == null) ? "" : string.Join <int>(",", newTab.ShenShiActiveList); string cmdText = string.Format("REPLACE INTO t_fuwen(rid, tabid, name, fuwenequip, shenshiactive, skillequip) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", new object[] { roleID, newTab.TabID, newTab.Name, fuWenEquip, shenShiActive, newTab.SkillEquip }); ret = conn.ExecuteNonQueryBool(cmdText, 0); } if (!ret) { LogManager.WriteLog(LogTypes.Error, string.Format("更新角色插入符文页数据失败,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true); client.sendCmd <int>(nID, -8); } else { lock (dbRoleInfo.FuWenTabList) { dbRoleInfo.FuWenTabList[newTab.TabID] = newTab; } client.sendCmd <int>(nID, ret ? 0 : -8); } } } catch (Exception ex) { LogManager.WriteException(ex.Message); client.sendCmd <int>(nID, -8); } }
private void HandleLoadWaitAwardYaZhu(GameServerClient client, int nID, byte[] cmdParams, int count) { try { string cmdData = null; try { cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); client.sendCmd(30767, "0"); return; } string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 1) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd(30767, "0"); } else { int month = Convert.ToInt32(fields[0]); string querySql = string.Format("SELECT to_union_group,to_group,rank_of_day,is_award,from_rid FROM t_zhengba_support_flag WHERE support_type={0} AND month={1} AND is_award=0", 3, month); MySQLDataReader reader = this.ExecSelect(querySql); List <ZhengBaWaitYaZhuAwardData> waitAwardYaZhuList = new List <ZhengBaWaitYaZhuAwardData>(); while (reader != null && reader.Read()) { waitAwardYaZhuList.Add(new ZhengBaWaitYaZhuAwardData { FromRoleId = Convert.ToInt32(reader["from_rid"].ToString()), Month = month, RankOfDay = Convert.ToInt32(reader["rank_of_day"].ToString()), UnionGroup = Convert.ToInt32(reader["to_union_group"].ToString()), Group = Convert.ToInt32(reader["to_group"].ToString()) }); } client.sendCmd <List <ZhengBaWaitYaZhuAwardData> >(nID, waitAwardYaZhuList); } } catch (Exception ex) { LogManager.WriteException(ex.Message); client.sendCmd <List <ZhengBaWaitYaZhuAwardData> >(nID, null); } }
private void HandleSetYaZhuAward(GameServerClient client, int nID, byte[] cmdParams, int count) { try { string cmdData = null; try { cmdData = new UTF8Encoding().GetString(cmdParams, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); client.sendCmd(30767, "0"); return; } string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 4) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); client.sendCmd(30767, "0"); } else { int month = Convert.ToInt32(fields[0]); int roleId = Convert.ToInt32(fields[1]); int unionGroup = Convert.ToInt32(fields[2]); int group = Convert.ToInt32(fields[3]); string logSql = string.Format("UPDATE t_zhengba_support_flag SET is_award=1 WHERE month={0} AND from_rid={1} AND to_union_group={2} AND to_group={3} AND support_type={4};", new object[] { month, roleId, unionGroup, group, 3 }); if (!this.ExecNonQuery(logSql)) { } client.sendCmd <bool>(nID, true); } } catch (Exception ex) { LogManager.WriteException(ex.Message); client.sendCmd <bool>(nID, false); } }
private void HandleSaveSupportLog(GameServerClient client, int nID, byte[] cmdParams, int count) { try { ZhengBaSupportLogData data = DataHelper.BytesToObject <ZhengBaSupportLogData>(cmdParams, 0, count); if (data.FromServerId == GameDBManager.ZoneID) { string flagSql = string.Format("INSERT INTO t_zhengba_support_flag(month,rank_of_day,from_rid,from_zoneid,from_rolename,support_type,to_union_group,to_group,time,from_serverid) VALUES({0},{1},{2},{3},'{4}',{5},{6},{7},'{8}',{9})", new object[] { data.Month, data.RankOfDay, data.FromRoleId, data.FromZoneId, data.FromRolename, data.SupportType, data.ToUnionGroup, data.ToGroup, data.Time.ToString("yyyy-MM-dd HH:mm:ss"), data.FromServerId }); if (!this.ExecNonQuery(flagSql)) { client.sendCmd <bool>(nID, false); return; } } string updateSql = string.Format("INSERT INTO t_zhengba_support_log(month,rank_of_day,from_rid,from_zoneid,from_rolename,support_type,to_union_group,to_group,time,from_serverid) VALUES({0},{1},{2},{3},'{4}',{5},{6},{7},'{8}',{9})", new object[] { data.Month, data.RankOfDay, data.FromRoleId, data.FromZoneId, data.FromRolename, data.SupportType, data.ToUnionGroup, data.ToGroup, data.Time.ToString("yyyy-MM-dd HH:mm:ss"), data.FromServerId }); if (!this.ExecNonQuery(updateSql)) { } client.sendCmd <bool>(nID, true); } catch (Exception ex) { LogManager.WriteException(ex.Message); client.sendCmd <bool>(nID, false); } }
private void ShenJiModify(GameServerClient client, int nID, byte[] cmdParams, int count) { string[] fields = null; int length = 3; if (!CheckHelper.CheckTCPCmdFields(nID, cmdParams, count, out fields, length)) { client.sendCmd <bool>(nID, false); } else { int roleID = int.Parse(fields[0]); int shenjiID = int.Parse(fields[1]); int shenjiLev = int.Parse(fields[2]); DBRoleInfo dbRoleInfo = DBManager.getInstance().FindDBRoleInfo(ref roleID); if (null == dbRoleInfo) { LogManager.WriteLog(LogTypes.Error, string.Format("精灵神迹,找不到玩家 roleid={0}", roleID), null, true); client.sendCmd(30767, "0"); } else { bool ret = false; using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("REPLACE INTO t_shenjifuwen(rid, sjID, level) VALUES('{0}', '{1}', '{2}')", roleID, shenjiID, shenjiLev); ret = conn.ExecuteNonQueryBool(cmdText, 0); } if (!ret) { LogManager.WriteLog(LogTypes.Error, string.Format("更新角色更新精灵神迹数据失败,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true); client.sendCmd <bool>(nID, ret); } else { lock (dbRoleInfo.ShenJiDict) { ShenJiFuWenData data = new ShenJiFuWenData { ShenJiID = shenjiID, Level = shenjiLev }; dbRoleInfo.ShenJiDict[shenjiID] = data; } client.sendCmd <bool>(nID, ret); } } } }
public TCPProcessCmdResults ProcessEquipGemCmd(DBManager dbMgr, GameServerClient client, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; bool bRet = false; FluorescentGemSaveDBData gemData = null; try { gemData = DataHelper.BytesToObject <FluorescentGemSaveDBData>(data, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); client.sendCmd <bool>(nID, bRet); return(TCPProcessCmdResults.RESULT_OK); } try { DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref gemData._RoleID); if (null == dbRoleInfo) { LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, gemData._RoleID), null, true); client.sendCmd <bool>(nID, bRet); return(TCPProcessCmdResults.RESULT_OK); } bRet = FluorescentGemDBOperate.EquipFluorescentGem(dbMgr, gemData); if (bRet) { lock (dbRoleInfo) { GoodsData goodsData = new GoodsData(); goodsData.GoodsID = gemData._GoodsID; goodsData.GCount = 1; goodsData.Binding = gemData._Bind; goodsData.Site = 7001; goodsData.BagIndex = this.GenerateBagIndex(gemData._Position, gemData._GemType); dbRoleInfo.FluorescentGemData.GemEquipList.Add(goodsData); } } client.sendCmd <bool>(nID, bRet); return(TCPProcessCmdResults.RESULT_OK); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "", false, false); } client.sendCmd <bool>(nID, bRet); return(TCPProcessCmdResults.RESULT_OK); }
public void processCmd(GameServerClient client, int nID, byte[] cmdParams, int count) { int[] challengeRankings = DataHelper.BytesToObject <int[]>(cmdParams, 0, count); List <PlayerJingJiMiniData> miniDatas = JingJiChangManager.getInstance().getChallengeData(challengeRankings); client.sendCmd <List <PlayerJingJiMiniData> >(10141, miniDatas); }
private void getBoCaiOpenList(GameServerClient client, int nID, string cmdData) { GetOpenList msgData = new GetOpenList(); msgData.Flag = false; try { string[] files = cmdData.Split(new char[] { ',' }); int type = Convert.ToInt32(files[1]); long DataPeriods = Convert.ToInt64(files[1]); msgData.MaxDataPeriods = BoCaiDBOperator.GetMaxData(type); BoCaiDBOperator.SelectOpenLottery(type, out msgData.ItemList); if (msgData.MaxDataPeriods >= 0L && null != msgData.ItemList) { msgData.Flag = true; } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } client.sendCmd <GetOpenList>(nID, msgData); }
public void processCmd(GameServerClient client, byte[] cmdParams, int count) { string cmd = new UTF8Encoding().GetString(cmdParams, 0, count); string[] param = cmd.Split(':'); ZhanMengShiJianData data = new ZhanMengShiJianData(); data.BHID = Convert.ToInt32(param[0]); data.RoleName = Convert.ToString(param[1]); data.ShiJianType = Convert.ToInt32(param[2]); data.SubValue1 = Convert.ToInt32(param[3]); data.SubValue2 = Convert.ToInt32(param[4]); data.SubValue3 = Convert.ToInt32(param[5]); data.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //需要特殊处理的战盟事件类型: 职务改变 if (data.ShiJianType == ZhanMengShiJianConstants.ChangeZhiWu) { string otherRoleName; string otherUserID; Global.GetRoleNameAndUserID(DBManager.getInstance(), data.SubValue3, out otherRoleName, out otherUserID); data.RoleName = otherRoleName; } ZhanMengShiJianManager.getInstance().onAddZhanMengShiJian(data); byte[] arrSendData = DataHelper.ObjectToBytes <string>(string.Format("{0}", 1)); client.sendCmd((int)TCPGameServerCmds.CMD_DB_ADD_ZHANMENGSHIJIAN, arrSendData); }
public void processCmd(GameServerClient client, int nID, byte[] cmdParams, int count) { int roleId = DataHelper.BytesToObject <int>(cmdParams, 0, count); bool result = JingJiChangManager.getInstance().removeCD(roleId); client.sendCmd <bool>(10147, result); }
private void ProcessArmorLevelStarUpCmd(GameServerClient client, int nID, byte[] cmdParams, int count) { int ret = 0; RoleDataCmdT <RoleArmorData> data = DataHelper.BytesToObject <RoleDataCmdT <RoleArmorData> >(cmdParams, 0, count); if (data != null && data.RoleID > 0) { DBManager dbMgr = DBManager.getInstance(); DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref data.RoleID); if (null != dbRoleInfo) { if (dbRoleInfo.ArmorData.Armor != data.Value.Armor || dbRoleInfo.ArmorData.Exp != data.Value.Exp) { dbRoleInfo.ArmorData.Armor = data.Value.Armor; dbRoleInfo.ArmorData.Exp = data.Value.Exp; using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("update t_roles set armor={1},armorexp={2} where rid={0}", data.RoleID, data.Value.Armor, data.Value.Exp); ret = conn.ExecuteSql(cmdText, new MySQLParameter[0]); } } } } client.sendCmd(nID, string.Format("{0}", ret)); }
public void processCmd(GameServerClient client, int nID, byte[] cmdParams, int count) { JingJiChallengeResultData data = DataHelper.BytesToObject <JingJiChallengeResultData>(cmdParams, 0, count); int ranking = JingJiChangManager.getInstance().onChallengeEnd(data); client.sendCmd <int>(10144, ranking); }
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); }
private void GetJieRiHongBaoRankList(GameServerClient client, int nID, byte[] cmdParams, int count) { List <JieriHongBaoKingItemData> list = new List <JieriHongBaoKingItemData>(); try { List <string> args = DataHelper.BytesToObject <List <string> >(cmdParams, 0, count); using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("SELECT `rid`,`count`,`getawardtimes`,`lasttime`,`rname` FROM `t_hongbao_jieri_recv` WHERE `keystr`='{0}' ORDER BY `count` DESC,`lasttime` ASC,rid ASC limit {1};", args[0], args[1]); using (MySQLDataReader reader = conn.ExecuteReader(cmdText, new MySQLParameter[0])) { int ranking = 1; while (reader.Read()) { list.Add(new JieriHongBaoKingItemData { RoleID = Global.SafeConvertToInt32(reader[0].ToString(), 10), TotalRecv = Global.SafeConvertToInt32(reader[1].ToString(), 10), GetAwardTimes = Global.SafeConvertToInt32(reader[2].ToString(), 10), Rolename = reader[4].ToString(), Rank = ranking++ }); } } } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } client.sendCmd <List <JieriHongBaoKingItemData> >(nID, list); }
private void RecvZhanMengHongBao(GameServerClient client, int nID, byte[] cmdParams, int count) { int ret = 0; try { HongBaoRecvData args = DataHelper.BytesToObject <HongBaoRecvData>(cmdParams, 0, count); if (args != null) { using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("replace into `t_hongbao_recv` (`hongbaoid`, `rid`, `bhid`, `zuanshi`, `recvtime`, `rname`) values('{0}','{1}','{2}','{3}','{4}','{5}');", new object[] { args.HongBaoID, args.RoleId, args.BhId, args.ZuanShi, args.RecvTime, args.RoleName }); ret = conn.ExecuteSql(cmdText, new MySQLParameter[0]); } } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } client.sendCmd <int>(nID, ret); }