//Third generation method equipment bool LoadEquipmentEx(MySqlConnection connection, IInfoProvider2 dbq, bool continueOnError) { IDataEquipmentCollection equipmentCollection = dbq.createEquipmentCollection(); MySqlCommand command = new MySqlCommand(_query_14, connection); MySqlDataReader reader = null; command.Parameters.AddWithValue("CharId", equipmentCollection.CharacterId); try { reader = command.ExecuteReader(CommandBehavior.SequentialAccess); while (reader.Read()) { byte[] buffer = new byte[68]; int offset = 0; for (int i = 0; i < 16; i++) { Rag2Item item; reader.GetBytes(0, offset, buffer, 0, 68); if (Rag2Item.Deserialize(out item, buffer, 0)) { item.active = buffer[67]; equipmentCollection.Equipment[i] = item; } offset += 68; } return true; } return continueOnError; } catch (Exception e) { __dbtracelog.WriteError("Database", e.Message); return false; } finally { if (reader != null) reader.Close(); } }
bool InsertEquipmentEx(MySqlConnection connection, IInfoProvider2 dbq) { IDataEquipmentCollection equipmentCollection = dbq.createEquipmentCollection(); int offset = 0; byte[] buffer = new byte[1088]; for (int i = 0; i < 16; i++) { Rag2Item item = equipmentCollection.Equipment[i]; if (item != null) { Rag2Item.Serialize(item, buffer, offset); buffer[offset + 67] = item.active; } offset += 68; } try { MySqlCommand command = new MySqlCommand(_query_16, connection); command.Parameters.AddWithValue("CharId", equipmentCollection.CharacterId); command.Parameters.AddWithValue("Equipment", buffer); return command.ExecuteNonQuery() > 0; } catch (Exception e) { __dbtracelog.WriteError("Database", e.Message); return false; } }