[XAM] Implemented SPA XRPT

This commit is contained in:
Adrian
2025-11-19 12:41:32 +00:00
committed by Radosław Gliński
parent 605bfd0e72
commit d915dd808d
6 changed files with 192 additions and 1 deletions

View File

@@ -102,6 +102,7 @@ GameInfoDatabase::Context GameInfoDatabase::GetContext(
context.default_value = xdbf_context->default_value;
context.max_value = xdbf_context->max_value;
context.is_system = xam::UserData::is_system_property(xdbf_context->id);
context.is_presence = GetPresence().property_bag.contexts.contains(id);
context.description = GetLocalizedString(xdbf_context->string_id);
return context;
}
@@ -122,6 +123,7 @@ GameInfoDatabase::Property GameInfoDatabase::GetProperty(
property.id = xdbf_property->id;
property.data_size = xdbf_property->data_size;
property.is_system = xam::UserData::is_system_property(xdbf_property->id);
property.is_presence = GetPresence().property_bag.properties.contains(id);
property.description = GetLocalizedString(xdbf_property->string_id);
return property;
}
@@ -231,6 +233,41 @@ GameInfoDatabase::StatsView GameInfoDatabase::GetStatsView(
return stats_view;
}
GameInfoDatabase::Presence GameInfoDatabase::GetPresence() const {
Presence presence;
if (!is_valid_) {
return presence;
}
const auto xdbf_presence = spa_gamedata_->GetPresence();
presence.property_bag = GetPropertyBag(xdbf_presence->property_bag);
presence.presence_modes = GetPresenceModes();
return presence;
}
GameInfoDatabase::PresenceMode GameInfoDatabase::GetPresenceMode(
const uint32_t context_value) const {
PresenceMode presence_mode = {};
if (!is_valid_) {
return presence_mode;
}
const auto xdbf_presence_mode = spa_gamedata_->GetPresenceMode(context_value);
if (!xdbf_presence_mode.has_value()) {
return presence_mode;
}
presence_mode.context_value = context_value;
presence_mode.property_bag = GetPropertyBag(xdbf_presence_mode.value());
return presence_mode;
}
std::vector<uint32_t> GameInfoDatabase::GetMatchmakingAttributes(
const uint32_t id) const {
// TODO(Gliniak): Implement when we will fully understand how to read it from
@@ -378,6 +415,25 @@ std::vector<GameInfoDatabase::StatsView> GameInfoDatabase::GetStatsViews()
return stats_views;
}
std::vector<GameInfoDatabase::PresenceMode> GameInfoDatabase::GetPresenceModes()
const {
std::vector<PresenceMode> presence_modes;
if (!is_valid_) {
return presence_modes;
}
const auto& xdbf_presence_modes =
spa_gamedata_->GetPresence()->presence_modes;
for (uint32_t context_value = 0; context_value < xdbf_presence_modes.size();
context_value++) {
presence_modes.push_back(GetPresenceMode(context_value));
}
return presence_modes;
}
} // namespace util
} // namespace kernel
} // namespace xe

View File

@@ -33,6 +33,7 @@ class GameInfoDatabase {
uint32_t max_value;
uint32_t default_value;
bool is_system;
bool is_presence;
std::string description;
};
@@ -40,6 +41,7 @@ class GameInfoDatabase {
uint32_t id;
uint32_t data_size;
bool is_system;
bool is_presence;
std::string description;
};
@@ -53,6 +55,16 @@ class GameInfoDatabase {
uint32_t flags;
};
struct PresenceMode {
uint32_t context_value;
PropertyBag property_bag;
};
struct Presence {
PropertyBag property_bag;
std::vector<PresenceMode> presence_modes;
};
struct Query {
uint32_t id;
std::string name;
@@ -136,6 +148,10 @@ class GameInfoDatabase {
PropertyBag GetPropertyBag(const xam::PropertyBag& property_bag) const;
Field GetField(const xam::ViewFieldEntry& field_entry) const;
StatsView GetStatsView(const uint32_t id) const;
Presence GetPresence() const;
PresenceMode GetPresenceMode(const uint32_t context_value) const;
std::vector<PresenceMode> GetPresenceModes(
const std::vector<xam::PropertyBag> property_bags) const;
// TODO: Implement it in the future.
std::vector<uint32_t> GetMatchmakingAttributes(const uint32_t id) const;
@@ -149,6 +165,7 @@ class GameInfoDatabase {
std::vector<Context> GetContexts() const;
std::vector<Property> GetProperties() const;
std::vector<Achievement> GetAchievements() const;
std::vector<PresenceMode> GetPresenceModes() const;
std::vector<StatsView> GetStatsViews() const;
private: