From 62a81a1eaf26b7e45b420bc462c1c0819e9aa505 Mon Sep 17 00:00:00 2001 From: "NG (Graham)" Date: Mon, 22 Jun 2026 17:16:40 -0400 Subject: [PATCH] Fix clan info not being provided in battle loading screen; fix #132 --- rc_core/src/data/player_data.rs | 15 +++++++++------ rc_core/src/persist/user/account_json.rs | 6 ++++++ rc_core/src/persist/user/multiplayer.rs | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/rc_core/src/data/player_data.rs b/rc_core/src/data/player_data.rs index 62394e9..bbec070 100644 --- a/rc_core/src/data/player_data.rs +++ b/rc_core/src/data/player_data.rs @@ -21,6 +21,7 @@ pub struct PlayerData { pub death_effect: String, pub player_rank: i32, pub weapon_rank: std::collections::HashMap, + pub clan_name: Option, } impl PlayerData { @@ -61,7 +62,7 @@ impl PlayerData { val_ty: polariton::serdes::TypePrefix::Int, items: self.weapon_rank.clone().into_iter().map(|(k, v)| (Typed::Int(k), Typed::Int(v))).collect(), }); - Typed::HashMap(vec![ + let mut entries = vec![ (Typed::Str("name".into()), Typed::Str(self.name.clone().into())), (Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())), (Typed::Str("robotName".into()), Typed::Str(self.robot_name.clone().into())), @@ -83,11 +84,13 @@ impl PlayerData { (Typed::Str("playerRank".into()), Typed::Int(self.player_rank)), (Typed::Str("weaponRanks".into()), weapon_ranks), (Typed::Str("isAI".into()), Typed::Bool(self.is_ai)), - // only required if clanName exists - /*(Typed::Str("clanName".into()), Typed::Str(todo!())), - (Typed::Str("clanUseCustomAvatar".into()), Typed::Bool(todo!())), - (Typed::Str("clanDefaultAvatarID".into()), Typed::Int(todo!())),*/ - ].into()) + ]; + if let Some(clan_name) = &self.clan_name { + entries.push((Typed::Str("clanName".into()), Typed::Str(clan_name.into()))); + entries.push((Typed::Str("clanUseCustomAvatar".into()), Typed::Bool(true))); + entries.push((Typed::Str("clanDefaultAvatarID".into()), Typed::Int(0))); + } + Typed::HashMap(entries.into()) } } diff --git a/rc_core/src/persist/user/account_json.rs b/rc_core/src/persist/user/account_json.rs index 5841f5e..25542e5 100644 --- a/rc_core/src/persist/user/account_json.rs +++ b/rc_core/src/persist/user/account_json.rs @@ -472,6 +472,10 @@ impl UserData { } else { current_slot.total_robot_cpu }; + let clan_opt = self.db.clan_by_user_id(self.account.id).await.map_err(|e| { + log::error!("Failed to retrieve clan for user_id {} (user_player_data): {}", self.account.id, e); + polariton_server::operations::SimpleOpError::with_message(DATABASE_ERR, format!("Could not retrieve clan: {}", e)) + })?; Ok(crate::data::player_data::PlayerData { name: user_uuid, @@ -493,6 +497,7 @@ impl UserData { death_effect: current_slot.death_animation_id, player_rank: 1, // FIXME weapon_rank: weapon_ranks, + clan_name: clan_opt.map(|(clan, _member)| clan.name), }) } @@ -682,6 +687,7 @@ impl UserData { death_effect: enemy_vehicle.death_effect, player_rank: 1, weapon_rank: weapon_ranks, + clan_name: None, }; next_id += 1; players.push(enemy); diff --git a/rc_core/src/persist/user/multiplayer.rs b/rc_core/src/persist/user/multiplayer.rs index ac3acb9..49b4143 100644 --- a/rc_core/src/persist/user/multiplayer.rs +++ b/rc_core/src/persist/user/multiplayer.rs @@ -51,6 +51,7 @@ impl UserData { death_effect: vehicle.death_effect, player_rank: 1, weapon_rank: vehicle.weapon_rank, + clan_name: None, }, fake.implementation );