Merge branch 'v0' of https://git.spbr.net/Spacebar/rust-nex into v0
All checks were successful
Build and Test / splatoon (push) Successful in 3m21s
Build and Test / friends (push) Successful in 3m44s

This commit is contained in:
red binder 2026-04-26 03:21:46 +02:00
commit 6e47874c1f
3 changed files with 29 additions and 5 deletions

Binary file not shown.

View file

@ -139,6 +139,9 @@ impl Friends for FriendsUser {
let Ok(any_self_fr_info) = Any::new(&self_fr_info) else {
return Err(ErrorCode::RendezVous_ControlScriptFailure);
};
let Ok(any_self_presence) = Any::new(&self_fr_info.presence) else {
return Err(ErrorCode::RendezVous_ControlScriptFailure);
};
drop(data);
let mut fr_list = vec![FriendInfo {
@ -197,6 +200,9 @@ impl Friends for FriendsUser {
println!("acquiring user and current friends locks");
let users = self.fm.users.read().await;
if users.len() >= 100 {
return Err(ErrorCode::RendezVous_ConnectionFailure);
}
println!("started summing users");
for u in users.deref().iter().filter_map(|u| u.upgrade()) {
let data = u.data.read().await;
@ -227,6 +233,18 @@ impl Friends for FriendsUser {
.await;
});
} else {
let data = any_self_presence.clone();
let u = u.clone();
let sender = self.pid;
spawn(async move {
u.remote
.process_nintendo_notification_event_2(NintendoNotificationEvent {
event_type: 24,
sender,
data,
})
.await;
});
drop(fr);
}
}
@ -263,18 +281,22 @@ impl Friends for FriendsUser {
}
async fn update_presence(&self, presence: NintendoPresenceV2) -> Result<(), ErrorCode> {
info!("user updated presence: {:?}", presence);
let mut data = self.data.write().await;
let Some(inner_data) = data.as_mut() else {
log::error!("unable to get presence data");
return Err(ErrorCode::RendezVous_PermissionDenied);
};
inner_data.presence = presence;
let Ok(any_self_fr_info) = Any::new(&inner_data.presence) else {
log::error!("unable to create presence any data holder");
return Err(ErrorCode::RendezVous_ControlScriptFailure);
};
drop(data);
let users = self.fm.users.read().await;
for u in users.deref().iter().filter_map(|u| u.upgrade()) {
info!("sending presence update");
u.remote
.process_nintendo_notification_event_2(NintendoNotificationEvent {
event_type: 24,
@ -308,6 +330,10 @@ impl Secure for FriendsUser {
station_urls: Vec<StationUrl>,
) -> Result<(QResult, u32, StationUrl), ErrorCode> {
let cid = self.fm.next_cid();
let users = self.fm.users.read().await;
if users.len() >= 100 {
return Err(ErrorCode::RendezVous_ConnectionFailure);
}
Ok((
QResult::success(ErrorCode::Core_Unknown),
cid,

View file

@ -230,11 +230,9 @@ impl MatchmakeExtension for User {
.await?;
let mut session = session.lock().await;
if session.session.user_password_enabled {
if join_session_param.user_password != session.session.user_password {
return Err(ErrorCode::RendezVous_InvalidPassword);
}
}
session
.connected_players
@ -656,7 +654,7 @@ impl Ranking for User {
let team_votes = fetch_team_votes(fest_id)?;
let mut wins = vec![0u32, 0u32];
for r in &results {
let won_team = r.team_id ^ (!r.team_win);
let won_team = (r.team_id ^ (!r.team_win)) & 1;
if let Some(team) = wins.get_mut(won_team as usize) {
*team += 1
};