//Third generation methods character bool LoadCharacterEx(MySqlConnection connection, IInfoProvider2 dbq) { MySqlDataReader reader = null; IDataCharacter character = dbq.createDataCharacter(); try { MySqlCommand command = new MySqlCommand(_query_12, connection); command.Parameters.AddWithValue("CharId", character.CharacterId); reader = command.ExecuteReader(); while (reader.Read()) { WorldCoordinate position = new WorldCoordinate(); position.coords = new Point(reader.GetFloat(13), reader.GetFloat(14), reader.GetFloat(15)); position.map = reader.GetByte(7); WorldCoordinate savePosition = new WorldCoordinate(); savePosition.coords = new Point(reader.GetFloat(16), reader.GetFloat(17), reader.GetFloat(18)); savePosition.map = reader.GetByte(19); character.CharacterName = reader.GetString(1); reader.GetBytes(2, 0, character.CharacterFace, 0, 11); character.CharacterExperience = reader.GetUInt32(4); character.JobExperience = reader.GetUInt32(5); character.Job = reader.GetByte(6); character.HP = reader.GetUInt16(9); character.SP = reader.GetUInt16(10); character.LP = reader.GetByte(11); character.Oxygen = reader.GetByte(12); character.Position = position; character.SavePosition = savePosition; character.Strength = reader.GetByte(20); character.Dexterity = reader.GetByte(21); character.Intellect = reader.GetByte(22); character.Concentration = reader.GetByte(23); character.Luck = reader.GetByte(24); character.Remaining = reader.GetByte(25); character.Zeny = reader.GetUInt32(26); return true; } return false; } catch (MySqlException e) { __dbtracelog.WriteError("database", e.Message); return false; } finally { //ALWAYS CLOSE THE READ RESULT if (reader != null) reader.Close(); } }
bool ExistsZoneEx(MySqlConnection connection, IInfoProvider2 dbq) { IDataCharacter character = dbq.createDataCharacter(); try { MySqlCommand command = new MySqlCommand(_query_83, connection); command.Parameters.AddWithValue("CharId", character.CharacterId); return Convert.ToInt32(command.ExecuteScalar()) > 0; } catch (MySqlException e) { __dbtracelog.WriteError("Database", e.Message); return false; } }
bool InsertCharacterEx(MySqlConnection connection, IInfoProvider2 dbq) { IDataCharacter character = dbq.createDataCharacter(); MySqlCommand command; try { //LOAD ALL SKILL INFORMATION if (character.CharacterId > 0) { command = new MySqlCommand(_query_84, connection); command.Parameters.AddWithValue("CharId", character.CharacterId); } else { command = new MySqlCommand(_query_85, connection); } command.Parameters.AddWithValue("Cexp", character.CharacterExperience); command.Parameters.AddWithValue("Jexp", character.JobExperience); command.Parameters.AddWithValue("Job", character.Job); command.Parameters.AddWithValue("Map", character.Position.map); command.Parameters.AddWithValue("HP", character.HP); command.Parameters.AddWithValue("SP", character.SP); command.Parameters.AddWithValue("LP", character.LP); command.Parameters.AddWithValue("LC", character.Oxygen); command.Parameters.AddWithValue("Posx", character.Position.x); command.Parameters.AddWithValue("Posy", character.Position.y); command.Parameters.AddWithValue("Posz", character.Position.z); command.Parameters.AddWithValue("Savex", character.SavePosition.x); command.Parameters.AddWithValue("Savey", character.SavePosition.y); command.Parameters.AddWithValue("Savez", character.SavePosition.z); command.Parameters.AddWithValue("Savemap", character.SavePosition.map); command.Parameters.AddWithValue("Str", character.Strength); command.Parameters.AddWithValue("Dex", character.Dexterity); command.Parameters.AddWithValue("Int", character.Intellect); command.Parameters.AddWithValue("Con", character.Concentration); command.Parameters.AddWithValue("Luc", character.Luck); command.Parameters.AddWithValue("Pending", character.Remaining); command.Parameters.AddWithValue("Rufi", character.Zeny); command.Parameters.AddWithValue("CharName", character.CharacterName); command.Parameters.AddWithValue("UppercasedCharName", character.CharacterName); command.Parameters.AddWithValue("CharFace", character.CharacterFace); command.Parameters.AddWithValue("UserId", dbq.OwnerId); if (character.CharacterId > 0) { return command.ExecuteNonQuery() > 0; } else { bool result = command.ExecuteNonQuery() > 0; character.CharacterId = (uint)command.LastInsertedId; return result && character.CharacterId > 0; } } catch (MySqlException e) { __dbtracelog.WriteError("Database", e.Message); return false; } }
bool SaveCharacterEx(MySqlConnection connection, IInfoProvider2 dbq) { IDataCharacter character = dbq.createDataCharacter(); try { //LOAD ALL SKILL INFORMATION MySqlCommand command = new MySqlCommand(_query_13, connection); command.Parameters.AddWithValue("CharId", character.CharacterId); command.Parameters.AddWithValue("Cexp", character.CharacterExperience); command.Parameters.AddWithValue("Jexp", character.JobExperience); command.Parameters.AddWithValue("Job", character.Job); command.Parameters.AddWithValue("Map", character.Position.map); command.Parameters.AddWithValue("HP", character.HP); command.Parameters.AddWithValue("SP", character.SP); command.Parameters.AddWithValue("LP", character.LP); command.Parameters.AddWithValue("LC", character.Oxygen); command.Parameters.AddWithValue("Posx", character.Position.x); command.Parameters.AddWithValue("Posy", character.Position.y); command.Parameters.AddWithValue("Posz", character.Position.z); command.Parameters.AddWithValue("Savex", character.SavePosition.x); command.Parameters.AddWithValue("Savey", character.SavePosition.y); command.Parameters.AddWithValue("Savez", character.SavePosition.z); command.Parameters.AddWithValue("Savemap", character.SavePosition.map); command.Parameters.AddWithValue("Str", character.Strength); command.Parameters.AddWithValue("Dex", character.Dexterity); command.Parameters.AddWithValue("Int", character.Intellect); command.Parameters.AddWithValue("Con", character.Concentration); command.Parameters.AddWithValue("Luc", character.Luck); command.Parameters.AddWithValue("Pending", character.Remaining); command.Parameters.AddWithValue("Rufi", character.Zeny); return command.ExecuteNonQuery() > 0; } catch (MySqlException e) { __dbtracelog.WriteError("Database", e.Message); return false; } }