private Character toObject(MySqlDataReader reader) { Character character = new Character(); character.Id = reader.GetUInt32(0); character.Slot = reader.GetByte(2); character.Name = reader.GetString(3); character.Faction = reader.GetByte(4); character.Gender = reader.GetByte(5); character.Rank = reader.GetUInt32(6); character.Money = reader.GetUInt32(7); character.Threat = reader.GetByte(8); character.Playtime = reader.GetUInt32(9); character.Clan = reader.GetString(10); character.Version = reader.GetUInt32(11); character.Appearence = reader.GetString(12); character.Custom = reader.GetString(13); character.WorldId = reader.GetUInt32(14); return character; }
public void Create(Character character) { MySqlCommand command = create; command.Prepare(); command.Parameters.AddWithValue("@account", AccountId); command.Parameters.AddWithValue("@slot", character.Slot); command.Parameters.AddWithValue("@name", character.Name); command.Parameters.AddWithValue("@faction", character.Faction); command.Parameters.AddWithValue("@gender", character.Gender); command.Parameters.AddWithValue("@rank", 9); command.Parameters.AddWithValue("@money", character.Money); command.Parameters.AddWithValue("@threat", 1); command.Parameters.AddWithValue("@playtime", character.Playtime); command.Parameters.AddWithValue("@clan", character.Clan); command.Parameters.AddWithValue("@version", character.Version); command.Parameters.AddWithValue("@appearence", character.Appearence); command.Parameters.AddWithValue("@custom", character.Custom); command.Parameters.AddWithValue("@world", character.WorldId); try { if (command.ExecuteNonQuery() == 0) throw (new Exception("Failed to create a character")); else { busySlots[character.Slot - 1] = true; characters.Add(character.Slot, character); } } finally { command.Dispose(); } }