/// <summary> /// 把精灵从精灵背包移动到普通背包 /// </summary> public static CallSpriteResult MovePet(GameClient client, int dbid) { GoodsData goodsData = GetPetByDbID(client, dbid); if (null == goodsData) { return(CallSpriteResult.GoodsNotExist); } // 先判断是否能取到背包中(客户端也有判断) 然后检索到背包中剩余的格子 [7/24/2014 LiaoWei] if (!Global.CanAddGoods(client, goodsData.GoodsID, goodsData.GCount, goodsData.Binding)) { return(CallSpriteResult.BagIsFull); } // 更新道具信息 string[] dbFields = null; string strCmd = Global.FormatUpdateDBGoodsStr(client.ClientData.RoleID, dbid, "*" /*isusing*/, "*", "*", "*", 0, "*", "*", 1, "*", 0, "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*"); TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, (int)TCPGameServerCmds.CMD_DB_UPDATEGOODS_CMD, strCmd, out dbFields, client.ServerId); if (dbRequestResult == TCPProcessCmdResults.RESULT_FAILED) { //strCmd = string.Format("{0}:{1}:{2}:{3}", (int)ElementhrtsError.DBSERVERERROR, dbid, goodsData.Site, goodsData.BagIndex); //GameManager.ClientMgr.SendToClient(client, strCmd, nID); return(CallSpriteResult.DBSERVERERROR); } if (dbFields.Length <= 0 || Convert.ToInt32(dbFields[1]) < 0) { //strCmd = string.Format("{0}:{1}:{2}:{3}", (int)ElementhrtsError.DBSERVERERROR, dbid, goodsData.Site, goodsData.BagIndex); //GameManager.ClientMgr.SendToClient(client, strCmd, nID); return(CallSpriteResult.DBSERVERERROR); } RemovePetGoodsData(client, goodsData); goodsData.Site = 0; Global.AddGoodsData(client, goodsData); return(CallSpriteResult.Success); }
public static CallSpriteResult MovePet(GameClient client, int dbid) { GoodsData goodsData = CallPetManager.GetPetByDbID(client, dbid); CallSpriteResult result; if (null == goodsData) { result = CallSpriteResult.GoodsNotExist; } else if (!Global.CanAddGoods(client, goodsData.GoodsID, goodsData.GCount, goodsData.Binding, "1900-01-01 12:00:00", true, false)) { result = CallSpriteResult.BagIsFull; } else { string[] dbFields = null; string strCmd = Global.FormatUpdateDBGoodsStr(new object[] { client.ClientData.RoleID, dbid, "*", "*", "*", "*", 0, "*", "*", 1, "*", 0, "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*" }); TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 10006, strCmd, out dbFields, client.ServerId); if (dbRequestResult == TCPProcessCmdResults.RESULT_FAILED) { result = CallSpriteResult.DBSERVERERROR; } else if (dbFields.Length <= 0 || Convert.ToInt32(dbFields[1]) < 0) { result = CallSpriteResult.DBSERVERERROR; } else { CallPetManager.RemovePetGoodsData(client, goodsData); goodsData.Site = 0; Global.AddGoodsData(client, goodsData); result = CallSpriteResult.Success; } } return(result); }