try fixing matchmaking again really hopefully

This commit is contained in:
Maple 2026-04-24 22:38:25 +02:00
commit 09e5b1f92a
2 changed files with 31 additions and 34 deletions

View file

@ -234,10 +234,10 @@ impl ExtendedMatchmakeSession {
joining_pid == self.session.gathering.owner_pid{ joining_pid == self.session.gathering.owner_pid{
continue; continue;
}*/ }*/
/*
if other_conn.pid != self.session.gathering.host_pid { if other_conn.pid != self.session.gathering.host_pid {
continue; continue;
} } */
for pid in &list_of_connected_pids { for pid in &list_of_connected_pids {
other_conn other_conn
@ -258,9 +258,10 @@ impl ExtendedMatchmakeSession {
let Some(old_conns) = old_conns.upgrade() else { let Some(old_conns) = old_conns.upgrade() else {
continue; continue;
}; };
/*
if old_conns.pid != self.session.gathering.host_pid { if old_conns.pid != self.session.gathering.host_pid {
continue; continue;
} } */
for new_conn_pid in conns.iter().filter_map(Weak::upgrade).map(|c| c.pid) { for new_conn_pid in conns.iter().filter_map(Weak::upgrade).map(|c| c.pid) {
old_conns old_conns
.remote .remote

View file

@ -5,15 +5,12 @@ use crate::nex::remote_console::RemoteConsole;
use crate::rmc::protocols::matchmake::{ use crate::rmc::protocols::matchmake::{
Matchmake, RawMatchmake, RawMatchmakeInfo, RemoteMatchmake, Matchmake, RawMatchmake, RawMatchmakeInfo, RemoteMatchmake,
}; };
use serde::{Serialize, Deserialize};
use std::env;
use std::str::FromStr;
use crate::rmc::protocols::nat_traversal::{ use crate::rmc::protocols::nat_traversal::{
NatTraversal, RawNatTraversal, RawNatTraversalInfo, RemoteNatTraversal, NatTraversal, RawNatTraversal, RawNatTraversalInfo, RemoteNatTraversal,
RemoteNatTraversalConsole, RemoteNatTraversalConsole,
}; };
use rnex_core::kerberos::KerberosDateTime;
use rnex_core::PID; use rnex_core::PID;
use rnex_core::kerberos::KerberosDateTime;
use rnex_core::prudp::station_url::StationUrl; use rnex_core::prudp::station_url::StationUrl;
use rnex_core::prudp::station_url::UrlOptions::{ use rnex_core::prudp::station_url::UrlOptions::{
Address, NatFiltering, NatMapping, Port, RVConnectionID, Address, NatFiltering, NatMapping, Port, RVConnectionID,
@ -31,17 +28,22 @@ use rnex_core::rmc::structures::any::Any;
use rnex_core::rmc::structures::matchmake::{ use rnex_core::rmc::structures::matchmake::{
AutoMatchmakeParam, CreateMatchmakeSessionParam, JoinMatchmakeSessionParam, MatchmakeSession, AutoMatchmakeParam, CreateMatchmakeSessionParam, JoinMatchmakeSessionParam, MatchmakeSession,
}; };
use serde::{Deserialize, Serialize};
use std::env;
use std::str::FromStr;
use crate::rmc::protocols::notifications::{NotificationEvent, RemoteNotification}; use crate::rmc::protocols::notifications::{NotificationEvent, RemoteNotification};
use log::{info, error}; use log::{error, info};
use macros::rmc_struct; use macros::rmc_struct;
use rnex_core::rmc::structures::qbuffer::QBuffer;
use rnex_core::prudp::socket_addr::PRUDPSockAddr; use rnex_core::prudp::socket_addr::PRUDPSockAddr;
use rnex_core::rmc::protocols::ranking::{
CompetitionRankingGetParam, CompetitionRankingScoreData, CompetitionRankingScoreInfo,
};
use rnex_core::rmc::response::ErrorCode::{Core_InvalidArgument, RendezVous_AccountExpired}; use rnex_core::rmc::response::ErrorCode::{Core_InvalidArgument, RendezVous_AccountExpired};
use rnex_core::rmc::structures::qbuffer::QBuffer;
use rnex_core::rmc::structures::qresult::QResult; use rnex_core::rmc::structures::qresult::QResult;
use rnex_core::rmc::structures::ranking::UploadCompetitionData;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use rnex_core::rmc::protocols::ranking::{CompetitionRankingScoreData, CompetitionRankingGetParam, CompetitionRankingScoreInfo};
use rnex_core::rmc::structures::ranking::{UploadCompetitionData};
use tokio::sync::{Mutex, RwLock}; use tokio::sync::{Mutex, RwLock};
define_rmc_proto!( define_rmc_proto!(
@ -617,10 +619,7 @@ fn fetch_team_votes(fest_id: u32) -> Result<Vec<u32>, ErrorCode> {
})?; })?;
let body = body.trim().trim_start_matches('[').trim_end_matches(']'); let body = body.trim().trim_start_matches('[').trim_end_matches(']');
let votes: Result<Vec<u32>, _> = body let votes: Result<Vec<u32>, _> = body.split(',').map(|s| u32::from_str(s.trim())).collect();
.split(',')
.map(|s| u32::from_str(s.trim()))
.collect();
votes.map_err(|e| { votes.map_err(|e| {
error!("failed to parse votes: {:?}", e); error!("failed to parse votes: {:?}", e);
@ -635,23 +634,19 @@ impl Ranking for User {
) -> Result<Vec<CompetitionRankingScoreInfo>, ErrorCode> { ) -> Result<Vec<CompetitionRankingScoreInfo>, ErrorCode> {
let fest_id = param.festival_ids.get(0).copied().unwrap_or(0); let fest_id = param.festival_ids.get(0).copied().unwrap_or(0);
let endpoint_results = env::var("RNEX_SPLATOON_RESULTS_GET") let endpoint_results = env::var("RNEX_SPLATOON_RESULTS_GET").map_err(|_| {
.map_err(|_| { error!("RNEX_SPLATOON_RESULTS_GET not set");
error!("RNEX_SPLATOON_RESULTS_GET not set"); ErrorCode::RendezVous_InvalidConfiguration
ErrorCode::RendezVous_InvalidConfiguration })?;
})?;
let url_results = format!("{}?splatfest_id={}", endpoint_results, fest_id); let url_results = format!("{}?splatfest_id={}", endpoint_results, fest_id);
let response_results = ureq::get(&url_results).call(); let response_results = ureq::get(&url_results).call();
let results: Vec<CompetitionPostResults> = match response_results { let results: Vec<CompetitionPostResults> = match response_results {
Ok(mut res) => res Ok(mut res) => res.body_mut().read_json().map_err(|e| {
.body_mut() error!("failed to parse JSON: {:?}", e);
.read_json() ErrorCode::RendezVous_InvalidConfiguration
.map_err(|e| { })?,
error!("failed to parse JSON: {:?}", e);
ErrorCode::RendezVous_InvalidConfiguration
})?,
Err(e) => { Err(e) => {
error!("GET failed: {:?}", e); error!("GET failed: {:?}", e);
return Err(ErrorCode::RendezVous_InvalidConfiguration); return Err(ErrorCode::RendezVous_InvalidConfiguration);
@ -661,9 +656,8 @@ impl Ranking for User {
let team_votes = fetch_team_votes(fest_id)?; let team_votes = fetch_team_votes(fest_id)?;
let mut wins = vec![0u32, 0u32]; let mut wins = vec![0u32, 0u32];
for r in &results { for r in &results {
if r.team_win == 1 && (r.team_id == 0 || r.team_id == 1) { let won_team = r.team_id ^ (!r.team_win);
wins[r.team_id as usize] += 1; wins[won_team as usize] += 1;
}
} }
let score_data: Vec<CompetitionRankingScoreData> = results let score_data: Vec<CompetitionRankingScoreData> = results
@ -677,7 +671,7 @@ impl Ranking for User {
appdata: QBuffer(vec![]), appdata: QBuffer(vec![]),
}) })
.collect(); .collect();
let info = CompetitionRankingScoreInfo { let info = CompetitionRankingScoreInfo {
fest_id, fest_id,
score_data, score_data,
@ -689,7 +683,10 @@ impl Ranking for User {
Ok(vec![info]) Ok(vec![info])
} }
async fn upload_competition_ranking_score(&self, param: UploadCompetitionData) -> Result<bool, ErrorCode> { async fn upload_competition_ranking_score(
&self,
param: UploadCompetitionData,
) -> Result<bool, ErrorCode> {
info!("fest results for user {:?}:", self.pid); info!("fest results for user {:?}:", self.pid);
info!("fest id: {:?}", param.splatfest_id); info!("fest id: {:?}", param.splatfest_id);
info!("score: {:?}", param.score); info!("score: {:?}", param.score);
@ -732,8 +729,7 @@ impl Ranking for User {
error!("POST borked: {:?}", e); error!("POST borked: {:?}", e);
} }
} }
Ok(true) Ok(true)
} }
} }