implement friendships

This commit is contained in:
Maple 2026-04-25 14:15:42 +02:00
commit 20fc294a36
7 changed files with 196 additions and 21 deletions

View file

@ -29,14 +29,14 @@ pub struct NNAInfo {
pub unk2: u8,
}
#[derive(RmcSerialize)]
#[derive(RmcSerialize, Clone, Copy, Debug)]
#[rmc_struct(0)]
pub struct GameKey {
pub tid: u64,
pub version: u16,
}
#[derive(RmcSerialize)]
#[derive(RmcSerialize, Clone, Debug)]
#[rmc_struct(0)]
pub struct NintendoPresenceV2 {
pub changed_flags: u32,
@ -143,6 +143,8 @@ pub trait Friends {
),
ErrorCode,
>;
#[method_id(13)]
async fn update_presence(&self, presence: NintendoPresenceV2) -> Result<(), ErrorCode>;
#[method_id(19)]
async fn check_setting_status(&self) -> Result<u8, ErrorCode>;
}

View file

@ -7,6 +7,7 @@ pub mod matchmake;
pub mod matchmake_ext;
pub mod matchmake_extension;
pub mod nat_traversal;
pub mod nintendo_notification;
pub mod notifications;
pub mod ranking;
pub mod secure;

View file

@ -0,0 +1,39 @@
use macros::{RmcSerialize, method_id, rmc_proto};
use rnex_core::PID;
use rnex_core::rmc::structures::any::Any;
#[derive(RmcSerialize)]
#[rmc_struct(0)]
pub struct NintendoNotificationEvent {
pub event_type: u32,
pub sender: PID,
pub data: Any,
}
#[derive(RmcSerialize)]
#[rmc_struct(0)]
pub struct NintendoNotificationEventGeneral {
pub param1: u32,
pub param2: u64,
pub param3: u64,
pub str_param: String,
}
#[derive(RmcSerialize)]
#[rmc_struct(0)]
pub struct NintendoNotificationEventProfile {
pub region: u8,
pub country: u8,
pub area: u8,
pub language: u8,
pub platform: u8,
}
#[rmc_proto(3, NoReturn)]
pub trait NintendoNotification {
#[method_id(1)]
async fn process_nintendo_notification_event_1(&self, notif: NintendoNotificationEvent);
#[method_id(2)]
async fn process_nintendo_notification_event_2(&self, notif: NintendoNotificationEvent);
}

View file

@ -1,8 +1,8 @@
use rnex_core::rmc::structures::{Result, RmcSerialize};
use std::io::{Read, Write};
use std::io::{Cursor, Read, Write};
use v_byte_helpers::{IS_BIG_ENDIAN, ReadExtensions};
#[derive(Debug, Default)]
#[derive(Debug, Default, Clone)]
pub struct Any {
pub name: String,
pub data: Vec<u8>,
@ -14,7 +14,7 @@ impl RmcSerialize for Any {
let u32_len = self.data.len() as u32;
u32_len.serialize(writer)?;
(u32_len + 4).serialize(writer)?;
u32_len.serialize(writer)?;
self.data.serialize(writer)?;
@ -35,3 +35,18 @@ impl RmcSerialize for Any {
Ok(Any { name, data })
}
}
impl Any {
pub fn try_get<T: RmcSerialize>(&self) -> Option<Result<T>> {
if self.name != T::name() {
return None;
}
return Some(T::deserialize(&mut Cursor::new(&self.data[..])));
}
pub fn new<T: RmcSerialize>(val: &T) -> Result<Self> {
return Ok(Self {
name: T::name().to_owned(),
data: val.to_data()?,
});
}
}

View file

@ -61,6 +61,9 @@ pub trait RmcSerialize {
Ok(data)
}
fn name() -> &'static str {
"NoNameSpecified"
}
}
impl RmcSerialize for () {