From 09e5b1f92a1738e3a969bb82bed2d883659a88d3 Mon Sep 17 00:00:00 2001 From: Maple Date: Fri, 24 Apr 2026 22:38:25 +0200 Subject: [PATCH] try fixing matchmaking again really hopefully --- rnex-core/src/nex/matchmake.rs | 7 ++-- rnex-core/src/nex/user.rs | 58 ++++++++++++++++------------------ 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/rnex-core/src/nex/matchmake.rs b/rnex-core/src/nex/matchmake.rs index e1afa21..dbaf9c0 100644 --- a/rnex-core/src/nex/matchmake.rs +++ b/rnex-core/src/nex/matchmake.rs @@ -234,10 +234,10 @@ impl ExtendedMatchmakeSession { joining_pid == self.session.gathering.owner_pid{ continue; }*/ - + /* if other_conn.pid != self.session.gathering.host_pid { continue; - } + } */ for pid in &list_of_connected_pids { other_conn @@ -258,9 +258,10 @@ impl ExtendedMatchmakeSession { let Some(old_conns) = old_conns.upgrade() else { continue; }; + /* if old_conns.pid != self.session.gathering.host_pid { continue; - } + } */ for new_conn_pid in conns.iter().filter_map(Weak::upgrade).map(|c| c.pid) { old_conns .remote diff --git a/rnex-core/src/nex/user.rs b/rnex-core/src/nex/user.rs index c86ae73..29d5332 100644 --- a/rnex-core/src/nex/user.rs +++ b/rnex-core/src/nex/user.rs @@ -5,15 +5,12 @@ use crate::nex::remote_console::RemoteConsole; use crate::rmc::protocols::matchmake::{ Matchmake, RawMatchmake, RawMatchmakeInfo, RemoteMatchmake, }; -use serde::{Serialize, Deserialize}; -use std::env; -use std::str::FromStr; use crate::rmc::protocols::nat_traversal::{ NatTraversal, RawNatTraversal, RawNatTraversalInfo, RemoteNatTraversal, RemoteNatTraversalConsole, }; -use rnex_core::kerberos::KerberosDateTime; use rnex_core::PID; +use rnex_core::kerberos::KerberosDateTime; use rnex_core::prudp::station_url::StationUrl; use rnex_core::prudp::station_url::UrlOptions::{ Address, NatFiltering, NatMapping, Port, RVConnectionID, @@ -31,17 +28,22 @@ use rnex_core::rmc::structures::any::Any; use rnex_core::rmc::structures::matchmake::{ AutoMatchmakeParam, CreateMatchmakeSessionParam, JoinMatchmakeSessionParam, MatchmakeSession, }; +use serde::{Deserialize, Serialize}; +use std::env; +use std::str::FromStr; use crate::rmc::protocols::notifications::{NotificationEvent, RemoteNotification}; -use log::{info, error}; +use log::{error, info}; use macros::rmc_struct; -use rnex_core::rmc::structures::qbuffer::QBuffer; 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::structures::qbuffer::QBuffer; use rnex_core::rmc::structures::qresult::QResult; +use rnex_core::rmc::structures::ranking::UploadCompetitionData; 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}; define_rmc_proto!( @@ -617,10 +619,7 @@ fn fetch_team_votes(fest_id: u32) -> Result, ErrorCode> { })?; let body = body.trim().trim_start_matches('[').trim_end_matches(']'); - let votes: Result, _> = body - .split(',') - .map(|s| u32::from_str(s.trim())) - .collect(); + let votes: Result, _> = body.split(',').map(|s| u32::from_str(s.trim())).collect(); votes.map_err(|e| { error!("failed to parse votes: {:?}", e); @@ -635,23 +634,19 @@ impl Ranking for User { ) -> Result, ErrorCode> { let fest_id = param.festival_ids.get(0).copied().unwrap_or(0); - let endpoint_results = env::var("RNEX_SPLATOON_RESULTS_GET") - .map_err(|_| { - error!("RNEX_SPLATOON_RESULTS_GET not set"); - ErrorCode::RendezVous_InvalidConfiguration - })?; + let endpoint_results = env::var("RNEX_SPLATOON_RESULTS_GET").map_err(|_| { + error!("RNEX_SPLATOON_RESULTS_GET not set"); + ErrorCode::RendezVous_InvalidConfiguration + })?; let url_results = format!("{}?splatfest_id={}", endpoint_results, fest_id); let response_results = ureq::get(&url_results).call(); let results: Vec = match response_results { - Ok(mut res) => res - .body_mut() - .read_json() - .map_err(|e| { - error!("failed to parse JSON: {:?}", e); - ErrorCode::RendezVous_InvalidConfiguration - })?, + Ok(mut res) => res.body_mut().read_json().map_err(|e| { + error!("failed to parse JSON: {:?}", e); + ErrorCode::RendezVous_InvalidConfiguration + })?, Err(e) => { error!("GET failed: {:?}", e); return Err(ErrorCode::RendezVous_InvalidConfiguration); @@ -661,9 +656,8 @@ impl Ranking for User { let team_votes = fetch_team_votes(fest_id)?; let mut wins = vec![0u32, 0u32]; for r in &results { - if r.team_win == 1 && (r.team_id == 0 || r.team_id == 1) { - wins[r.team_id as usize] += 1; - } + let won_team = r.team_id ^ (!r.team_win); + wins[won_team as usize] += 1; } let score_data: Vec = results @@ -677,7 +671,7 @@ impl Ranking for User { appdata: QBuffer(vec![]), }) .collect(); - + let info = CompetitionRankingScoreInfo { fest_id, score_data, @@ -689,7 +683,10 @@ impl Ranking for User { Ok(vec![info]) } - async fn upload_competition_ranking_score(&self, param: UploadCompetitionData) -> Result { + async fn upload_competition_ranking_score( + &self, + param: UploadCompetitionData, + ) -> Result { info!("fest results for user {:?}:", self.pid); info!("fest id: {:?}", param.splatfest_id); info!("score: {:?}", param.score); @@ -732,8 +729,7 @@ impl Ranking for User { error!("POST borked: {:?}", e); } } - + Ok(true) } } -