Skip to content

Commit

Permalink
Cleanup guildless characters who were offline during disband
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokya committed Aug 14, 2024
1 parent d276d93 commit 9ab8d0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/sql/cleanup_guildless_characters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE `Character`
SET `guild_rank` = NULL, `guild_rank_string` = NULL
WHERE `guild_id` IS NULL;
10 changes: 7 additions & 3 deletions src/world/world/disband_guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ impl World {
map.kick_from_guild(player_id);
}

// Wait a few seconds to ensure all characters have been saved.
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;

let mut conn = match pool.get_conn().await {
Ok(conn) => conn,
Err(e) => {
Expand All @@ -54,6 +51,13 @@ impl World {
{
error!("Error deleting guild: {}", e);
}

if let Err(e) = conn
.query_drop(include_str!("../../sql/cleanup_guildless_characters.sql"))
.await
{
error!("Error deleting guild: {}", e);
}
});
}
}

0 comments on commit 9ab8d0f

Please sign in to comment.