Compare commits

..

No commits in common. "aa019d4ea976bc9850935061cd8be60299336a90" and "13c6592438b782a70cf0aaf2cd36bc2b98864b7b" have entirely different histories.

3 changed files with 9 additions and 11 deletions

View File

@ -1,2 +0,0 @@
alter table player_character
add created_at timestamptz default current_timestamp not null;

View File

@ -244,7 +244,7 @@ impl From<PgCharacter> for CharacterEntity {
prop_y: other.prop_y,
},
techs: CharacterTechniques {
techs: other.techs.iter().enumerate().take(19).filter(|(_, t)| **t != 0xFF).map(|(i, t)| (tech::Technique::from_value(i as u8), TechLevel(*t + 1)) ).collect()
techs: other.techs.iter().enumerate().take(19).filter(|(_, t)| **t != 0xFF).map(|(i, t)| (tech::Technique::from_value(i as u8), TechLevel(*t)) ).collect()
},
config: CharacterConfig {
raw_data: vec_to_array(other.config)

View File

@ -276,17 +276,17 @@ async fn create_character(conn: &mut sqlx::PgConnection, char: NewCharacterEntit
async fn get_characters_by_user(conn: &mut sqlx::PgConnection, user: &UserAccountEntity) -> Result<[Option<CharacterEntity>; 4], GatewayError>
{
let stream = sqlx::query_as::<_, PgCharacter>("select * from player_character where user_account = $1 and slot < 4 order by created_at;")
let mut stream = sqlx::query_as::<_, PgCharacter>("select * from player_character where user_account = $1 and slot < 4 order by slot")
.bind(user.id.0)
.fetch(conn);
const NONE: Option<CharacterEntity> = None;
let mut result = [NONE; 4];
while let Some(character) = stream.try_next().await? {
let index = character.slot as usize;
result[index] = Some(character.into())
}
Ok(stream.fold(core::array::from_fn(|_| None), |mut acc, char| {
if let Ok(char) = char {
let slot = char.slot as usize;
acc[slot] = Some(char.into())
}
acc
}).await)
Ok(result)
}
async fn save_character(conn: &mut sqlx::PgConnection, char: &CharacterEntity) -> Result<(), GatewayError>