diff --git a/src/nex/user.rs b/src/nex/user.rs index b25061c..e5edc00 100644 --- a/src/nex/user.rs +++ b/src/nex/user.rs @@ -12,6 +12,7 @@ use crate::prudp::station_url::{nat_types, StationUrl, Type}; use crate::rmc::protocols::matchmake::{ Matchmake, RawMatchmake, RawMatchmakeInfo, RemoteMatchmake, }; +use crate::rmc::protocols::ranking::{Ranking, RawRanking, RawRankingInfo, RemoteRanking}; use crate::rmc::protocols::matchmake_extension::{ MatchmakeExtension, RawMatchmakeExtension, RawMatchmakeExtensionInfo, RemoteMatchmakeExtension, }; @@ -28,6 +29,7 @@ use std::sync::{Arc, Weak}; use log::{error, info}; use rocket::http::ext::IntoCollection; use tokio::sync::{Mutex, RwLock}; +use tonic::Code::InvalidArgument; use crate::prudp::station_url::nat_types::PUBLIC; use crate::rmc::protocols::notifications::{NotificationEvent, RemoteNotification}; use crate::rmc::response::ErrorCode::{Core_Exception, Core_InvalidArgument, RendezVous_AccountExpired, RendezVous_SessionVoid}; @@ -38,7 +40,8 @@ define_rmc_proto!( MatchmakeExtension, MatchmakeExt, Matchmake, - NatTraversal + NatTraversal, + Ranking } ); @@ -195,6 +198,16 @@ impl MatchmakeExtension for User { Ok(()) } + async fn open_participation(&self, gid: u32) -> Result<(), ErrorCode> { + let session = self.matchmake_manager.get_session(gid).await?; + + let mut session = session.lock().await; + + session.session.open_participation = true; + + Ok(()) + } + async fn get_playing_session(&self, pids: Vec) -> Result, ErrorCode> { Ok(Vec::new()) } @@ -360,6 +373,15 @@ impl MatchmakeExtension for User { Ok(session.session.clone()) } + + async fn modify_current_game_attribute(&self, gid: u32, attrib_index: u32, attrib_val: u32) -> Result<(), ErrorCode> { + let session = self.matchmake_manager.get_session(gid).await?; + let mut session = session.lock().await; + + session.session.attributes[attrib_index as usize] = attrib_val; + + Ok(()) + } } impl Matchmake for User { @@ -433,6 +455,32 @@ impl Matchmake for User { Ok(()) } + + async fn migrate_gathering_ownership(&self, gid: u32, candidates: Vec, participants_only: bool) -> Result<(), ErrorCode> { + let session = self.matchmake_manager.get_session(gid).await?; + let mut session = session.lock().await; + + let candidate = candidates.get(0).ok_or(Core_InvalidArgument)?; + + session.session.gathering.owner_pid = *candidate; + + for player in &session.connected_players { + let Some(player) = player.upgrade() else { + continue; + }; + + player.remote.process_notification_event(NotificationEvent { + notif_type: 4000, + pid_source: self.pid, + param_1: gid, + param_2: *candidate, + param_3: 0, + str_param: "".to_string(), + }).await; + } + + Ok(()) + } } impl MatchmakeExt for User { @@ -444,6 +492,8 @@ impl MatchmakeExt for User { Ok(true) } + + } impl NatTraversal for User { @@ -507,3 +557,7 @@ impl NatTraversal for User { Ok(()) } } + +impl Ranking for User{ + +} \ No newline at end of file diff --git a/src/rmc/protocols/matchmake.rs b/src/rmc/protocols/matchmake.rs index bec8d8f..1c2d5e5 100644 --- a/src/rmc/protocols/matchmake.rs +++ b/src/rmc/protocols/matchmake.rs @@ -11,4 +11,7 @@ pub trait Matchmake{ #[method_id(42)] async fn update_session_host(&self, gid: u32, change_owner: bool) -> Result<(), ErrorCode>; + + #[method_id(44)] + async fn migrate_gathering_ownership(&self, gid: u32, candidates: Vec, participants_only: bool) -> Result<(), ErrorCode>; } \ No newline at end of file diff --git a/src/rmc/protocols/matchmake_extension.rs b/src/rmc/protocols/matchmake_extension.rs index be922d2..cd3f281 100644 --- a/src/rmc/protocols/matchmake_extension.rs +++ b/src/rmc/protocols/matchmake_extension.rs @@ -7,6 +7,12 @@ pub trait MatchmakeExtension{ #[method_id(1)] async fn close_participation(&self, gid: u32) -> Result<(), ErrorCode>; + #[method_id(2)] + async fn open_participation(&self, gid: u32) -> Result<(), ErrorCode>; + + #[method_id(8)] + async fn modify_current_game_attribute(&self, gid: u32, attrib_index: u32, attrib_val: u32) -> Result<(), ErrorCode>; + #[method_id(16)] async fn get_playing_session(&self, pids: Vec) -> Result, ErrorCode>; diff --git a/src/rmc/protocols/mod.rs b/src/rmc/protocols/mod.rs index a09fad8..4ea73df 100644 --- a/src/rmc/protocols/mod.rs +++ b/src/rmc/protocols/mod.rs @@ -7,6 +7,7 @@ pub mod matchmake; pub mod matchmake_extension; pub mod nat_traversal; pub mod matchmake_ext; +pub mod ranking; use crate::prudp::socket::{ExternalConnection, SendingConnection}; use crate::rmc::message::RMCMessage; diff --git a/src/rmc/protocols/ranking.rs b/src/rmc/protocols/ranking.rs new file mode 100644 index 0000000..974af41 --- /dev/null +++ b/src/rmc/protocols/ranking.rs @@ -0,0 +1,5 @@ +use macros::{method_id, rmc_proto}; + +#[rmc_proto(112)] +pub trait Ranking{ +} \ No newline at end of file