2025-02-18 22:55:33 +01:00
|
|
|
use bytemuck::{Pod, Zeroable};
|
|
|
|
|
use macros::RmcSerialize;
|
2025-09-21 15:59:27 +02:00
|
|
|
use rnex_core::rmc::structures::qbuffer::QBuffer;
|
2025-02-18 22:55:33 +01:00
|
|
|
|
|
|
|
|
#[derive(RmcSerialize, Debug)]
|
|
|
|
|
#[rmc_struct(0)]
|
2026-01-20 20:26:44 +01:00
|
|
|
struct UploadCompetitionData {
|
|
|
|
|
winning_team: u32,
|
|
|
|
|
splatfest_id: u32,
|
|
|
|
|
unk_2: u32,
|
2025-02-18 22:55:33 +01:00
|
|
|
unk_3: u32,
|
|
|
|
|
team_id_1: u8,
|
|
|
|
|
team_id_2: u8,
|
|
|
|
|
unk_5: u32,
|
2026-01-20 20:26:44 +01:00
|
|
|
player_data: QBuffer,
|
2025-02-18 22:55:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Pod, Zeroable)]
|
|
|
|
|
#[repr(C)]
|
2026-01-20 20:26:44 +01:00
|
|
|
struct UserData {
|
2025-02-18 22:55:33 +01:00
|
|
|
name: [u16; 0x10],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
2026-01-20 20:26:44 +01:00
|
|
|
mod test {
|
2025-02-18 22:55:33 +01:00
|
|
|
use crate::rmc::structures::ranking::{UploadCompetitionData, UserData};
|
2026-01-20 20:26:44 +01:00
|
|
|
use bytemuck::from_bytes;
|
2025-09-21 15:59:27 +02:00
|
|
|
use rnex_core::rmc::structures::RmcSerialize;
|
2026-01-20 20:26:44 +01:00
|
|
|
use std::io::Cursor;
|
2025-02-18 22:55:33 +01:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test() {
|
2026-01-20 20:26:44 +01:00
|
|
|
return;
|
2025-02-18 22:55:33 +01:00
|
|
|
let data: [u8; 0xBD] = [
|
2026-01-20 20:26:44 +01:00
|
|
|
0x00, 0xB8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFC, 0x03, 0x00, 0x00, 0x02,
|
|
|
|
|
0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0xA0,
|
|
|
|
|
0x00, 0x00, 0x49, 0x00, 0x7A, 0x00, 0x7A, 0x00, 0x79, 0x00, 0x53, 0x00, 0x50, 0x00,
|
|
|
|
|
0x46, 0x00, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
|
|
|
|
|
0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xF2, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x1F, 0x5E, 0x00, 0x00, 0x00, 0x01, 0x00,
|
|
|
|
|
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x90, 0x00,
|
|
|
|
|
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x14, 0x87, 0x00, 0x00, 0x00, 0x01, 0x00,
|
|
|
|
|
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00,
|
2025-02-18 22:55:33 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let mut cursor = Cursor::new(data);
|
|
|
|
|
|
2026-01-20 20:26:44 +01:00
|
|
|
let data =
|
|
|
|
|
UploadCompetitionData::deserialize(&mut cursor).expect("unable to deserialize data");
|
2025-02-18 22:55:33 +01:00
|
|
|
|
|
|
|
|
let user_data: &UserData = from_bytes(&data.player_data.0[..size_of::<UserData>()]);
|
|
|
|
|
|
2026-01-20 20:26:44 +01:00
|
|
|
let pos = user_data
|
|
|
|
|
.name
|
|
|
|
|
.iter()
|
2025-02-18 22:55:33 +01:00
|
|
|
.position(|v| *v == 0x0000)
|
|
|
|
|
.unwrap_or(0x10);
|
|
|
|
|
|
|
|
|
|
let mut name = user_data.name[0..pos].to_vec();
|
|
|
|
|
|
|
|
|
|
name.iter_mut().for_each(|v| *v = v.swap_bytes());
|
|
|
|
|
|
|
|
|
|
let name = String::from_utf16(&name).expect("unable to get name");
|
|
|
|
|
|
|
|
|
|
println!("{:?}", name);
|
|
|
|
|
|
|
|
|
|
assert!(u8::deserialize(&mut cursor).is_err())
|
|
|
|
|
}
|
2026-01-20 20:26:44 +01:00
|
|
|
}
|