Compare commits

..

8 commits

Author SHA1 Message Date
e027da24c6 Update Rust crate async-trait to v0.1.89
Some checks failed
Build and Test / friends (pull_request) Successful in 7m2s
Build and Test / wii-u-chat (push) Successful in 6m52s
Build and Test / wii-u-chat (pull_request) Successful in 8m25s
Build and Test / splatoon (pull_request) Failing after 16m19s
Build and Test / splatoon (push) Failing after 18m3s
Build and Test / friends (push) Successful in 15m15s
Build and Test / super-mario-maker (pull_request) Has been cancelled
Build and Test / super-mario-maker (push) Has been cancelled
2026-04-28 14:20:23 +00:00
6daf271cbd add more 3.3.0 support
Some checks failed
Build and Test / friends (push) Has been cancelled
Build and Test / wii-u-chat (push) Has been cancelled
Build and Test / splatoon (push) Has been cancelled
Build and Test / super-mario-maker (push) Has been cancelled
2026-04-28 15:30:42 +02:00
c8626564d4 Merge branch 'v0' of ssh://ssh.spbr.net:51122/spacebar/rust-nex into v0
Some checks are pending
Build and Test / wii-u-chat (push) Waiting to run
Build and Test / splatoon (push) Waiting to run
Build and Test / friends (push) Waiting to run
Build and Test / super-mario-maker (push) Waiting to run
2026-04-28 15:23:04 +02:00
b9bfac8c70 implement find by single id 2026-04-28 15:22:42 +02:00
3b933501f0 Merge pull request 'Update Rust crate chrono to v0.4.44' (#13) from renovate/chrono-0.x-lockfile into v0
Some checks are pending
Build and Test / wii-u-chat (push) Waiting to run
Build and Test / splatoon (push) Waiting to run
Build and Test / friends (push) Waiting to run
Build and Test / super-mario-maker (push) Waiting to run
2026-04-28 15:07:59 +02:00
c19f859bcc Merge branch 'v0' of ssh://ssh.spbr.net:51122/spacebar/rust-nex into v0
Some checks are pending
Build and Test / wii-u-chat (push) Waiting to run
Build and Test / splatoon (push) Waiting to run
Build and Test / friends (push) Waiting to run
Build and Test / super-mario-maker (push) Waiting to run
2026-04-28 15:07:47 +02:00
747e37409f fix issues 2026-04-28 15:07:33 +02:00
48ace5124b Update Rust crate chrono to v0.4.44
Some checks failed
Build and Test / wii-u-chat (push) Successful in 17m1s
Build and Test / splatoon (push) Failing after 21m4s
Build and Test / super-mario-maker (push) Failing after 28m35s
Build and Test / splatoon (pull_request) Failing after 28m7s
Build and Test / friends (push) Failing after 43m10s
Build and Test / friends (pull_request) Successful in 32m13s
Build and Test / wii-u-chat (pull_request) Successful in 46m6s
Build and Test / super-mario-maker (pull_request) Failing after 39m38s
2026-04-28 13:04:07 +00:00
6 changed files with 53 additions and 44 deletions

13
Cargo.lock generated
View file

@ -14,12 +14,6 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@ -644,16 +638,15 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.41" version = "0.4.44"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0"
dependencies = [ dependencies = [
"android-tzdata",
"iana-time-zone", "iana-time-zone",
"js-sys", "js-sys",
"num-traits", "num-traits",
"wasm-bindgen", "wasm-bindgen",
"windows-link 0.1.3", "windows-link 0.2.1",
] ]
[[package]] [[package]]

View file

@ -52,6 +52,8 @@ use rnex_core::rmc::structures::ranking::UploadCompetitionData;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use tokio::sync::{Mutex, RwLock}; use tokio::sync::{Mutex, RwLock};
use crate::rmc::structures::Error;
cfg_if! { cfg_if! {
if #[cfg(feature = "datastore")] { if #[cfg(feature = "datastore")] {
use rnex_core::rmc::protocols::datastore::{DataStore, RawDataStore, RawDataStoreInfo, RemoteDataStore}; use rnex_core::rmc::protocols::datastore::{DataStore, RawDataStore, RawDataStoreInfo, RemoteDataStore};
@ -180,11 +182,14 @@ impl MatchmakeExtension for User {
} }
async fn update_progress_score(&self, gid: u32, progress: u8) -> Result<(), ErrorCode> { async fn update_progress_score(&self, gid: u32, progress: u8) -> Result<(), ErrorCode> {
let session = self.matchmake_manager.get_session(gid).await?; #[cfg(feature = "v3-5-0")]
{
let session = self.matchmake_manager.get_session(gid).await?;
let mut session = session.lock().await; let mut session = session.lock().await;
session.session.progress_score = progress; session.session.progress_score = progress;
}
Ok(()) Ok(())
} }
@ -495,7 +500,7 @@ impl MatchmakeExtension for User {
gid: u32, gid: u32,
message: String, message: String,
dont_care_block_list: bool, dont_care_block_list: bool,
participation_count: u16, //participation_count: u16,
) -> Result<Vec<u8>, ErrorCode> { ) -> Result<Vec<u8>, ErrorCode> {
let sess = self.matchmake_manager.get_session(gid).await?; let sess = self.matchmake_manager.get_session(gid).await?;
let mut sess = sess.lock().await; let mut sess = sess.lock().await;
@ -506,6 +511,15 @@ impl MatchmakeExtension for User {
} }
impl Matchmake for User { impl Matchmake for User {
async fn find_by_single_id(&self, gid: u32) -> Result<(bool, Any), ErrorCode> {
let s = self.matchmake_manager.get_session(gid).await?;
let s = s.lock().await;
Ok((
true,
Any::new(&s.session).map_err(|_| ErrorCode::Custom_Unknown)?,
))
}
async fn unregister_gathering(&self, _gid: u32) -> Result<bool, ErrorCode> { async fn unregister_gathering(&self, _gid: u32) -> Result<bool, ErrorCode> {
Ok(true) Ok(true)
} }

View file

@ -4,10 +4,14 @@ use rnex_core::rmc::response::ErrorCode;
use rnex_core::PID; use rnex_core::PID;
use crate::rmc::structures::any::Any;
#[rmc_proto(21)] #[rmc_proto(21)]
pub trait Matchmake { pub trait Matchmake {
#[method_id(2)] #[method_id(2)]
async fn unregister_gathering(&self, gid: u32) -> Result<bool, ErrorCode>; async fn unregister_gathering(&self, gid: u32) -> Result<bool, ErrorCode>;
#[method_id(21)]
async fn find_by_single_id(&self, gid: u32) -> Result<(bool, Any), ErrorCode>;
#[method_id(41)] #[method_id(41)]
async fn get_session_urls(&self, gid: u32) -> Result<Vec<StationUrl>, ErrorCode>; async fn get_session_urls(&self, gid: u32) -> Result<Vec<StationUrl>, ErrorCode>;
#[method_id(42)] #[method_id(42)]

View file

@ -42,7 +42,8 @@ pub trait MatchmakeExtension {
gid: u32, gid: u32,
message: String, message: String,
dont_care_block_list: bool, dont_care_block_list: bool,
participation_count: u16, // this is to cheat support for v3-3-0
//participation_count: u16,
) -> Result<Vec<u8>, ErrorCode>; ) -> Result<Vec<u8>, ErrorCode>;
#[method_id(8)] #[method_id(8)]

View file

@ -1,4 +1,3 @@
use log::{info, warn};
use rnex_core::rmc::structures::{Result, RmcSerialize}; use rnex_core::rmc::structures::{Result, RmcSerialize};
use std::io::{Cursor, Read, Write}; use std::io::{Cursor, Read, Write};
use v_byte_helpers::{IS_BIG_ENDIAN, ReadExtensions}; use v_byte_helpers::{IS_BIG_ENDIAN, ReadExtensions};
@ -12,32 +11,21 @@ pub struct Any {
impl RmcSerialize for Any { impl RmcSerialize for Any {
fn serialize(&self, writer: &mut impl Write) -> Result<()> { fn serialize(&self, writer: &mut impl Write) -> Result<()> {
self.name.serialize(writer)?; self.name.serialize(writer)?;
let u32_len = self.data.len() as u32 - 1;
let u32_len = self.data.len() as u32;
(u32_len + 4).serialize(writer)?; (u32_len + 4).serialize(writer)?;
u32_len.serialize(writer)?; self.data.serialize(writer)?;
writer.write_all(&self.data)?;
Ok(()) Ok(())
} }
fn deserialize(reader: &mut impl Read) -> Result<Self> { fn deserialize(reader: &mut impl Read) -> Result<Self> {
let name = String::deserialize(reader)?; let name = String::deserialize(reader)?;
let size = u32::deserialize(reader)? as usize + 1; // also length ?
let mut buf = vec![0; size]; let _len2: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
reader.read_exact(&mut buf[..])?; let data = Vec::deserialize(reader)?;
let mut cursor = Cursor::new(&buf);
let len2: u32 = cursor.read_struct(IS_BIG_ENDIAN)?;
if len2 as usize + 3 != size { Ok(Any { name, data })
warn!("mismatched sizes on any: {} vs {}", size, len2 + 1);
}
info!("any data: {}", hex::encode(&buf));
Ok(Any {
name,
data: (&buf[4..]).to_owned(),
})
} }
} }
@ -58,8 +46,6 @@ impl Any {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use std::io::Cursor;
use crate::rmc::structures::{ use crate::rmc::structures::{
RmcSerialize, RmcSerialize,
any::Any, any::Any,
@ -68,6 +54,21 @@ mod test {
#[test] #[test]
fn test() { fn test() {
let any = Any {
name: "MatchmakeSession".into(),
data: [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 98, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0,
0, 0, 0, 0, 0, 20, 0, 68, 111, 111, 114, 115, 32, 70, 114, 105, 101, 110, 100, 32,
73, 110, 118, 105, 116, 101, 0, 0, 0, 0, 0, 6, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 1, 2, 3, 0,
0, 0, 0, 0, 0, 0, 0, 0,
]
.into(),
};
println!("{}", hex::encode(&any.data));
let _: MatchmakeSession = any.try_get().unwrap().unwrap();
let sess = MatchmakeSession { let sess = MatchmakeSession {
gathering: Gathering { gathering: Gathering {
self_gid: 0, self_gid: 0,
@ -87,18 +88,15 @@ mod test {
matchmake_system_type: 2, matchmake_system_type: 2,
application_buffer: [1, 2, 3].into(), application_buffer: [1, 2, 3].into(),
participation_count: 0, participation_count: 0,
#[cfg(feature = "v3-5-0")]
progress_score: 0, progress_score: 0,
session_key: [].into(), session_key: [].into(),
}; };
let any = Any::new(&sess).unwrap().to_data().unwrap(); let any = Any::new(&sess).unwrap();
let sess2: MatchmakeSession = Any::deserialize(&mut Cursor::new(any)) let sess2: MatchmakeSession = any.try_get().unwrap().unwrap();
.unwrap()
.try_get()
.unwrap()
.unwrap();
assert_eq!(sess, sess2); assert_eq!(sess, sess2)
} }
} }

View file

@ -67,7 +67,6 @@ cfg_if! {
pub matchmake_system_type: u32, pub matchmake_system_type: u32,
pub application_buffer: Vec<u8>, pub application_buffer: Vec<u8>,
pub participation_count: u32, pub participation_count: u32,
pub progress_score: u8,
pub session_key: Vec<u8>, pub session_key: Vec<u8>,
} }
} }