From d6c9566c6961802cdaaf994ba94a46f72889bd67 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Wed, 10 Jan 2024 22:00:50 +0100 Subject: [PATCH 1/2] [Misc] Fixed discord presence --- src/xenia/app/discord/discord_presence.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xenia/app/discord/discord_presence.cc b/src/xenia/app/discord/discord_presence.cc index f70b7d68bc0..4140a90767c 100644 --- a/src/xenia/app/discord/discord_presence.cc +++ b/src/xenia/app/discord/discord_presence.cc @@ -29,7 +29,7 @@ void DiscordPresence::Initialize() { handlers.joinGame = &HandleDiscordJoinGame; handlers.joinRequest = &HandleDiscordJoinRequest; handlers.spectateGame = &HandleDiscordSpectateGame; - Discord_Initialize("616128086999695367", &handlers, 0, ""); + Discord_Initialize("1193272084797849762", &handlers, 0, ""); } void DiscordPresence::NotPlaying() { From 49d44600e8769fa39fefe7d5b8fddd92fbe40308 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Wed, 10 Jan 2024 22:03:27 +0100 Subject: [PATCH 2/2] [XDBF] Added support for reading compressed XLast XML file To decompress it we need gzip and then some library for XML to read it --- src/xenia/kernel/util/xdbf_utils.cc | 28 ++++++++++++++++++++++++++++ src/xenia/kernel/util/xdbf_utils.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/xenia/kernel/util/xdbf_utils.cc b/src/xenia/kernel/util/xdbf_utils.cc index c483d9160a1..6fc1bb7dd40 100644 --- a/src/xenia/kernel/util/xdbf_utils.cc +++ b/src/xenia/kernel/util/xdbf_utils.cc @@ -22,6 +22,7 @@ constexpr fourcc_t kXdbfSignatureXprp = make_fourcc("XPRP"); constexpr fourcc_t kXdbfSignatureXcxt = make_fourcc("XCXT"); constexpr fourcc_t kXdbfSignatureXvc2 = make_fourcc("XVC2"); constexpr fourcc_t kXdbfSignatureXmat = make_fourcc("XMAT"); +constexpr fourcc_t kXdbfSignatureXsrc = make_fourcc("XSRC"); constexpr uint64_t kXdbfIdTitle = 0x8000; constexpr uint64_t kXdbfIdXstc = 0x58535443; @@ -30,6 +31,7 @@ constexpr uint64_t kXdbfIdXprp = 0x58505250; constexpr uint64_t kXdbfIdXctx = 0x58435854; constexpr uint64_t kXdbfIdXvc2 = 0x58564332; constexpr uint64_t kXdbfIdXmat = 0x584D4154; +constexpr uint64_t kXdbfIdXsrc = 0x58535243; XdbfWrapper::XdbfWrapper(const uint8_t* data, size_t data_size) : data_(data), data_size_(data_size) { @@ -213,6 +215,32 @@ std::vector XdbfWrapper::GetStatsView() const { return entries; } +const uint8_t* XdbfWrapper::ReadXLast(uint32_t& compressed_size, + uint32_t& decompressed_size) const { + auto xlast_table = GetEntry(XdbfSection::kMetadata, kXdbfIdXsrc); + if (!xlast_table) { + return nullptr; + } + + auto xlast_head = + reinterpret_cast(xlast_table.buffer); + assert_true(xlast_head->magic == kXdbfSignatureXsrc); + assert_true(xlast_head->version == 1); + + const uint8_t* ptr = xlast_table.buffer + sizeof(XdbfSectionHeader); + + const uint32_t filename_length = xe::byte_swap(*(uint32_t*)ptr); + ptr += sizeof(uint32_t) + filename_length; + + decompressed_size = xe::byte_swap(*(uint32_t*)ptr); + ptr += sizeof(uint32_t); + + compressed_size = xe::byte_swap(*(uint32_t*)ptr); + ptr += sizeof(uint32_t); + + return ptr; +} + XdbfAchievementTableEntry XdbfWrapper::GetAchievement(const uint32_t id) const { const auto achievements = GetAchievements(); diff --git a/src/xenia/kernel/util/xdbf_utils.h b/src/xenia/kernel/util/xdbf_utils.h index 104e3cf2939..010fcc745bf 100644 --- a/src/xenia/kernel/util/xdbf_utils.h +++ b/src/xenia/kernel/util/xdbf_utils.h @@ -196,6 +196,8 @@ class XdbfWrapper { XdbfPropertyBag GetMatchCollection() const; + const uint8_t* ReadXLast(uint32_t& compressed_size, uint32_t& decompressed_size) const; + private: const uint8_t* data_ = nullptr; size_t data_size_ = 0;