From d46b07803c80c6f05ae1738254ec98c7d50529a9 Mon Sep 17 00:00:00 2001 From: Duff <19514584+Dufftwt@users.noreply.github.com> Date: Tue, 24 Nov 2026 02:32:25 +0100 Subject: [PATCH] XUser: a gamertag without a suffix has an empty modern suffix XUserGetGamertag returned the name for every component, the modern suffix included. The GDK documents the suffix as empty when there is none, and a title that shows "name#suffix" whenever the suffix is not empty showed "Player#Player". The modern suffix (component 2) is now empty; the classic, modern and unique modern components are still the name. --- crates/victory-hle/src/modules/xuser.rs | 32 ++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/crates/victory-hle/src/modules/xuser.rs b/crates/victory-hle/src/modules/xuser.rs index 33c05d6..8b48dfc 100644 --- a/crates/victory-hle/src/modules/xuser.rs +++ b/crates/victory-hle/src/modules/xuser.rs @@ -154,16 +154,23 @@ extern "system" fn get_is_guest(_: This, _: Handle, out: *mut bool) -> HRESULT { extern "system" fn get_state(_: This, _: Handle, out: *mut u32) -> HRESULT { put(out, 0) } -/// The same name for every component (classic, modern, suffix, unique). +/// The user's gamertag as the component asked for (`XUserGamertagComponent`): +/// it has no suffix, so the modern suffix is empty and every other component +/// (classic, modern, unique modern) is the name itself. extern "system" fn get_gamertag( _: This, _: Handle, - _component: u32, + component: u32, size: usize, buffer: *mut u8, used: *mut usize, ) -> HRESULT { - put_string(GAMERTAG, size, buffer, used) + const MODERN_SUFFIX: u32 = 2; + let text = match component { + MODERN_SUFFIX => "", + _ => GAMERTAG, + }; + put_string(text, size, buffer, used) } /// Granted; deny reason 0 (none). extern "system" fn check_privilege( @@ -322,6 +329,25 @@ mod tests { use crate::modules::xasync::E_NOT_SUFFICIENT_BUFFER; use crate::modules::xgameruntime::method as slot; + #[test] + fn a_gamertag_without_a_suffix_has_an_empty_modern_suffix() { + type Gamertag = + extern "system" fn(This, Handle, u32, usize, *mut u8, *mut usize) -> HRESULT; + let this: This = &OBJECT; + let user = std::ptr::null(); + // Classic, modern, modern suffix, unique modern; through both slots. + let expected: [&[u8]; 4] = [b"Player\0", b"Player\0", b"\0", b"Player\0"]; + for (object, at) in [(&GAMERTAG_OBJECT, 0x18), (&OBJECT, 0x78)] { + let get = slot::(object, at); + for (component, expected) in (0..).zip(expected) { + let (mut name, mut used) = ([0xff_u8; 16], 0); + let hr = get(this, user, component, 16, name.as_mut_ptr(), &mut used); + assert_eq!(hr, S_OK); + assert_eq!(&name[..used], expected, "component {component}"); + } + } + } + #[test] fn startup_adds_the_user_and_reads_its_id() { type Add = extern "system" fn(This, u32, *mut AsyncBlock) -> HRESULT;