bool InsertSpecialSkillsEx(MySqlConnection connection, IInfoProvider2 dbq) { IDataSpecialSkillCollection collection = dbq.createDatabaseSpecialSkillCollection(); try { //LOAD ALL SKILL INFORMATION byte[] buffer = new byte[64]; for (int i = 0; i < 16; i++) { Skill skill = collection.specialSkillCollection[i]; if (skill != null) Array.Copy(BitConverter.GetBytes(skill.info.skillid), 0, buffer, i * 4, 4); } MySqlCommand command = new MySqlCommand(_query_88, connection); command.Parameters.AddWithValue("CharId", collection.CharacterId); command.Parameters.AddWithValue("Skills", buffer); return command.ExecuteNonQuery() > 0; } catch (Exception e) { __dbtracelog.WriteError("Database", e.Message); return false; } }
bool LoadSpecialSkillsEx(MySqlConnection connection, IInfoProvider2 dbq, bool continueOnError) { MySqlDataReader reader = null; IDataSpecialSkillCollection collection = dbq.createDatabaseSpecialSkillCollection(); try { //LOAD ALL SKILL INFORMATION MySqlCommand command = new MySqlCommand(_query_67, connection); command.Parameters.AddWithValue("CharId", collection.CharacterId); reader = command.ExecuteReader(CommandBehavior.SequentialAccess); while (reader.Read()) { byte[] buffer = new byte[64]; if (reader.IsDBNull(0) == false) reader.GetBytes(0, 0, buffer, 0, 64); for (int i = 0; i < 16; i++) { uint skillid = BitConverter.ToUInt32(buffer, i * 4); Skill skill = new Skill(); skill.Id = skillid; if (Singleton.SpellManager.spells.TryGetValue(skillid, out skill.info)) collection.specialSkillCollection[i] = skill; } return true; } __dbtracelog.WriteError("Database", "player specialskill-data of player with id {0} is missing", collection.CharacterId); return continueOnError; } catch (Exception e) { __dbtracelog.WriteError("Database", e.Message); return false; } finally { //ALWAYS CLOSE THE READ RESULT if (reader != null) reader.Close(); } }