public static void LoadRoleData_Item(GameBase.Network.Internal.ROLEDATA_ITEM info) { MySqlCommand command; String _key = String.Format(MysqlString.LOADROLEDATA_ITEM, info.playerid); command = new MySqlCommand(_key, MysqlConn.GetConn()); MysqlConn.Conn_Open(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { if (!reader.HasRows) { break; } GameBase.Network.Internal.RoleData_Item item = new GameBase.Network.Internal.RoleData_Item(); item.id = reader.GetUInt32("id"); item.playerid = reader.GetInt32("playerid"); item.itemid = reader.GetUInt32("itemid"); item.postion = reader.GetUInt16("postion"); item.stronglv = reader.GetByte("stronglv"); item.gem1 = reader.GetByte("gem1"); item.gem2 = reader.GetByte("gem2"); item.forgename = reader.GetString("forgename"); if (item.forgename.Length > 0) { item.forgename = Coding.Latin1ToGB2312(item.forgename); } item.amount = reader.GetUInt16("amount"); item.war_ghost_exp = reader.GetInt32("war_ghost_exp"); item.di_attack = reader.GetByte("di_attack"); item.shui_attack = reader.GetByte("shui_attack"); item.huo_attack = reader.GetByte("huo_attack"); item.feng_attack = reader.GetByte("feng_attack"); item.property = reader.GetInt32("property"); item.gem3 = reader.GetByte("gem3"); item.god_exp = reader.GetInt32("god_exp"); item.god_strong = reader.GetInt32("god_strong"); info.mListItem.Add(item); } MysqlConn.Conn_Close(); command.Dispose(); }
public static void SaveRoleData_Item(GameBase.Network.Internal.ROLEDATA_ITEM info) { try { MySqlCommand command; String sql; for (int i = 0; i < info.mListItem.Count; i++) { GameBase.Network.Internal.RoleData_Item item = info.mListItem[i]; if (item.forgename.Length > 0) { item.forgename = Coding.GB2312ToLatin1(item.forgename); } if (item.id == 0) //id为0就插入 { sql = String.Format(MysqlString.SAVEROLE_ITEM, info.playerid, item.itemid, item.postion, item.stronglv, item.gem1, item.gem2, item.forgename, item.amount, item.war_ghost_exp, item.di_attack, item.shui_attack, item.huo_attack, item.feng_attack, item.property, item.gem3, item.god_exp, item.god_strong); } else { sql = String.Format(MysqlString.UPDATEROLE_ITEM, item.itemid, item.postion, item.stronglv, item.gem1, item.gem2, item.forgename, item.amount, item.war_ghost_exp, item.di_attack, item.shui_attack, item.huo_attack, item.feng_attack, item.property, item.gem3, item.god_exp, item.god_strong, info.playerid, item.id); } command = new MySqlCommand(sql, MysqlConn.GetConn()); MysqlConn.Conn_Open(); command.ExecuteNonQuery(); MysqlConn.Conn_Close(); command.Dispose(); } } catch (System.Exception ex) { Log.Instance().WriteLog("---------------------------------------------------------------------------"); Log.Instance().WriteLog("保存角色道具信息失败.角色id:" + info.playerid.ToString()); Log.Instance().WriteLog(ex.Message); Log.Instance().WriteLog(ex.StackTrace); Log.Instance().WriteLog("---------------------------------------------------------------------------"); } }
public uint sortid; //临时表的id #endregion Fields #region Constructors public AddRoleData_Item() { mParam = Define.ADDROLEDATA_ITEM; item = new RoleData_Item(); }
public void Create(byte[] msg) { PackIn inpack = new PackIn(msg); inpack.ReadUInt16(); playerid = inpack.ReadInt32(); key = inpack.ReadInt32(); key2 = inpack.ReadInt32(); int count = inpack.ReadInt32(); for (int i = 0; i < count; i++) { RoleData_Item item = new RoleData_Item(); item.Create(null, inpack); //----------------------------------------------- //item.id = inpack.ReadUInt32(); //item.itemid = inpack.ReadUInt32(); //item.postion = inpack.ReadUInt16(); //item.stronglv = inpack.ReadByte(); //item.gemcount = inpack.ReadByte(); //item.gem1 = inpack.ReadUInt32(); //item.gem2 = inpack.ReadUInt32(); //item.forgename = inpack.ReadString(); //item.amount = inpack.ReadUInt16(); //item.war_ghost_exp = inpack.ReadInt32(); //item.di_attack = inpack.ReadByte(); //item.shui_attack = inpack.ReadByte(); //item.huo_attack = inpack.ReadByte(); //item.feng_attack = inpack.ReadByte(); //item.property = inpack.ReadInt32(); //item.gem3 = inpack.ReadByte(); //item.god_strong = inpack.ReadInt32(); //item.god_exp = inpack.ReadInt32(); //------------------------------------------------ mListItem.Add(item); } }
public static void LoadRoleData_Item(GameBase.Network.Internal.ROLEDATA_ITEM info) { MySqlCommand command; String _key = String.Format(MysqlString.LOADROLEDATA_ITEM, info.playerid); command = new MySqlCommand(_key, MysqlConn.GetConn()); MysqlConn.Conn_Open(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { if (!reader.HasRows) break; GameBase.Network.Internal.RoleData_Item item = new GameBase.Network.Internal.RoleData_Item(); item.id = reader.GetUInt32("id"); item.playerid = reader.GetInt32("playerid"); item.itemid = reader.GetUInt32("itemid"); item.postion = reader.GetUInt16("postion"); item.stronglv = reader.GetByte("stronglv"); item.gem1 = reader.GetByte("gem1"); item.gem2 = reader.GetByte("gem2"); item.forgename = reader.GetString("forgename"); if (item.forgename.Length > 0) { item.forgename = Coding.Latin1ToGB2312(item.forgename); } item.amount = reader.GetUInt16("amount"); item.war_ghost_exp = reader.GetInt32("war_ghost_exp"); item.di_attack = reader.GetByte("di_attack"); item.shui_attack = reader.GetByte("shui_attack"); item.huo_attack = reader.GetByte("huo_attack"); item.feng_attack = reader.GetByte("feng_attack"); item.property = reader.GetInt32("property"); item.gem3 = reader.GetByte("gem3"); item.god_exp = reader.GetInt32("god_exp"); item.god_strong = reader.GetInt32("god_strong"); info.mListItem.Add(item); } MysqlConn.Conn_Close(); command.Dispose(); }
//保存 public void DB_Save() { if (mDicItem.Count <= 0) return; GameBase.Network.Internal.ROLEDATA_ITEM item = new GameBase.Network.Internal.ROLEDATA_ITEM(); item.SetSaveTag(); item.playerid = play.GetBaseAttr().player_id; foreach (GameStruct.RoleItemInfo info in mDicItem.Values) { GameBase.Network.Internal.RoleData_Item _item = new GameBase.Network.Internal.RoleData_Item(); _item.id = info.id; _item.itemid = info.itemid; _item.postion = info.postion; _item.stronglv = info.stronglv; _item.gem1 = info.gem1; _item.gem2 = info.gem2; _item.forgename = info.forgename; _item.amount = info.amount; _item.war_ghost_exp = info.war_ghost_exp; _item.di_attack = info.di_attack; _item.shui_attack = info.shui_attack; _item.huo_attack = info.huo_attack; _item.feng_attack = info.feng_attack; _item.property = info.property; _item.gem3 = info.gem3; _item.god_exp = info.god_exp; _item.god_strong = info.god_strong; item.mListItem.Add(_item); } DBServer.Instance().GetDBClient().SendData(item.GetBuffer()); }