[Kernel] Remove redundant 'Xdbf' from names
This commit is contained in:
parent
c1eaf6879a
commit
fa61106984
|
@ -70,7 +70,7 @@ X_RESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
|
|||
bool modified = false;
|
||||
auto* achievement =
|
||||
(X_XUSER_ACHIEVEMENT*)memory_->TranslateVirtual(achievements_ptr);
|
||||
xdbf::XdbfAchievement ach;
|
||||
xdbf::Achievement ach;
|
||||
for (uint32_t i = 0; i < achievement_count; i++, achievement++) {
|
||||
if (game_gpd->GetAchievement(achievement->achievement_id, &ach)) {
|
||||
if (!ach.IsUnlocked()) {
|
||||
|
|
|
@ -117,7 +117,7 @@ void UserProfile::LoadGpdFiles() {
|
|||
dash_gpd_.Read(mmap_->data(), mmap_->size());
|
||||
mmap_->Close();
|
||||
|
||||
std::vector<xdbf::XdbfTitlePlayed> titles;
|
||||
std::vector<xdbf::TitlePlayed> titles;
|
||||
dash_gpd_.GetTitles(&titles);
|
||||
|
||||
for (auto title : titles) {
|
||||
|
@ -150,11 +150,11 @@ void UserProfile::LoadGpdFiles() {
|
|||
xdbf::GpdFile* UserProfile::SetTitleSpaData(const xdbf::SpaFile& spa_data) {
|
||||
uint32_t spa_title = spa_data.GetTitleId();
|
||||
|
||||
std::vector<xdbf::XdbfAchievement> spa_achievements;
|
||||
std::vector<xdbf::Achievement> spa_achievements;
|
||||
// TODO: let user choose locale?
|
||||
spa_data.GetAchievements(spa_data.GetDefaultLocale(), &spa_achievements);
|
||||
|
||||
xdbf::XdbfTitlePlayed title_info;
|
||||
xdbf::TitlePlayed title_info;
|
||||
|
||||
auto gpd = title_gpds_.find(spa_title);
|
||||
if (gpd != title_gpds_.end()) {
|
||||
|
@ -232,7 +232,7 @@ xdbf::GpdFile* UserProfile::SetTitleSpaData(const xdbf::SpaFile& spa_data) {
|
|||
// Try copying achievement images if we can...
|
||||
for (auto ach : spa_achievements) {
|
||||
auto* image_entry = spa_data.GetEntry(
|
||||
static_cast<uint16_t>(xdbf::XdbfSpaSection::kImage), ach.image_id);
|
||||
static_cast<uint16_t>(xdbf::SpaSection::kImage), ach.image_id);
|
||||
if (image_entry) {
|
||||
title_gpd.UpdateEntry(*image_entry);
|
||||
}
|
||||
|
@ -240,18 +240,18 @@ xdbf::GpdFile* UserProfile::SetTitleSpaData(const xdbf::SpaFile& spa_data) {
|
|||
|
||||
// Try adding title image & name
|
||||
auto* title_image =
|
||||
spa_data.GetEntry(static_cast<uint16_t>(xdbf::XdbfSpaSection::kImage),
|
||||
static_cast<uint64_t>(xdbf::XdbfSpaID::Title));
|
||||
spa_data.GetEntry(static_cast<uint16_t>(xdbf::SpaSection::kImage),
|
||||
static_cast<uint64_t>(xdbf::SpaID::Title));
|
||||
if (title_image) {
|
||||
title_gpd.UpdateEntry(*title_image);
|
||||
}
|
||||
|
||||
auto title_name = xe::to_wstring(spa_data.GetTitleName());
|
||||
if (title_name.length()) {
|
||||
xdbf::XdbfEntry title_name_ent;
|
||||
xdbf::Entry title_name_ent;
|
||||
title_name_ent.info.section =
|
||||
static_cast<uint16_t>(xdbf::XdbfGpdSection::kString);
|
||||
title_name_ent.info.id = static_cast<uint64_t>(xdbf::XdbfSpaID::Title);
|
||||
static_cast<uint16_t>(xdbf::GpdSection::kString);
|
||||
title_name_ent.info.id = static_cast<uint64_t>(xdbf::SpaID::Title);
|
||||
title_name_ent.data.resize((title_name.length() + 1) * 2);
|
||||
xe::copy_and_swap((wchar_t*)title_name_ent.data.data(),
|
||||
title_name.c_str(), title_name.length());
|
||||
|
@ -272,7 +272,7 @@ xdbf::GpdFile* UserProfile::SetTitleSpaData(const xdbf::SpaFile& spa_data) {
|
|||
|
||||
// Print achievement list to log, ATM there's no other way for users to see
|
||||
// achievement status...
|
||||
std::vector<xdbf::XdbfAchievement> achievements;
|
||||
std::vector<xdbf::Achievement> achievements;
|
||||
if (curr_gpd_->GetAchievements(&achievements)) {
|
||||
XELOGI("Achievement list:");
|
||||
|
||||
|
@ -375,9 +375,9 @@ bool UserProfile::UpdateGpd(uint32_t title_id, xdbf::GpdFile& gpd_data) {
|
|||
} else {
|
||||
// Check if we need to update dashboard data...
|
||||
if (title_id != kDashboardID) {
|
||||
xdbf::XdbfTitlePlayed title_info;
|
||||
xdbf::TitlePlayed title_info;
|
||||
if (dash_gpd_.GetTitle(title_id, &title_info)) {
|
||||
std::vector<xdbf::XdbfAchievement> gpd_achievements;
|
||||
std::vector<xdbf::Achievement> gpd_achievements;
|
||||
gpd_data.GetAchievements(&gpd_achievements);
|
||||
|
||||
uint32_t num_ach_total = 0;
|
||||
|
|
|
@ -599,7 +599,7 @@ dword_result_t XamUserCreateAchievementEnumerator(dword_t title_id,
|
|||
xe::copy_and_swap(place_addr, placeholder_val, wcslen(placeholder_val));
|
||||
}
|
||||
|
||||
std::vector<xdbf::XdbfAchievement> achievements;
|
||||
std::vector<xdbf::Achievement> achievements;
|
||||
game_gpd->GetAchievements(&achievements);
|
||||
|
||||
for (auto ach : achievements) {
|
||||
|
|
|
@ -36,7 +36,7 @@ bool XdbfFile::Read(const uint8_t* data, size_t data_size) {
|
|||
(uint8_t*)free_ptr + (sizeof(X_XDBF_FILELOC) * header_.free_count);
|
||||
|
||||
for (uint32_t i = 0; i < header_.entry_used; i++) {
|
||||
XdbfEntry entry;
|
||||
Entry entry;
|
||||
memcpy(&entry.info, ptr, sizeof(X_XDBF_ENTRY));
|
||||
entry.data.resize(entry.info.size);
|
||||
memcpy(entry.data.data(), data_ptr + entry.info.offset, entry.info.size);
|
||||
|
@ -111,9 +111,9 @@ bool XdbfFile::Write(uint8_t* data, size_t* data_size) {
|
|||
return true;
|
||||
}
|
||||
|
||||
XdbfEntry* XdbfFile::GetEntry(uint16_t section, uint64_t id) const {
|
||||
Entry* XdbfFile::GetEntry(uint16_t section, uint64_t id) const {
|
||||
for (size_t i = 0; i < entries_.size(); i++) {
|
||||
auto* entry = (XdbfEntry*)&entries_[i];
|
||||
auto* entry = (Entry*)&entries_[i];
|
||||
if (entry->info.section != section || entry->info.id != id) {
|
||||
continue;
|
||||
}
|
||||
|
@ -124,9 +124,9 @@ XdbfEntry* XdbfFile::GetEntry(uint16_t section, uint64_t id) const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool XdbfFile::UpdateEntry(XdbfEntry entry) {
|
||||
bool XdbfFile::UpdateEntry(Entry entry) {
|
||||
for (size_t i = 0; i < entries_.size(); i++) {
|
||||
auto* ent = (XdbfEntry*)&entries_[i];
|
||||
auto* ent = (Entry*)&entries_[i];
|
||||
if (ent->info.section != entry.info.section ||
|
||||
ent->info.id != entry.info.id) {
|
||||
continue;
|
||||
|
@ -137,7 +137,7 @@ bool XdbfFile::UpdateEntry(XdbfEntry entry) {
|
|||
return true;
|
||||
}
|
||||
|
||||
XdbfEntry new_entry;
|
||||
Entry new_entry;
|
||||
new_entry.info.section = entry.info.section;
|
||||
new_entry.info.id = entry.info.id;
|
||||
new_entry.info.size = (uint32_t)entry.data.size();
|
||||
|
@ -162,10 +162,9 @@ std::string GetStringTableEntry_(const uint8_t* table_start, uint16_t string_id,
|
|||
return "";
|
||||
}
|
||||
|
||||
std::string SpaFile::GetStringTableEntry(XdbfLocale locale,
|
||||
std::string SpaFile::GetStringTableEntry(Locale locale,
|
||||
uint16_t string_id) const {
|
||||
auto xstr_table =
|
||||
GetEntry(static_cast<uint16_t>(XdbfSpaSection::kStringTable),
|
||||
auto xstr_table = GetEntry(static_cast<uint16_t>(SpaSection::kStringTable),
|
||||
static_cast<uint64_t>(locale));
|
||||
if (!xstr_table) {
|
||||
return "";
|
||||
|
@ -173,7 +172,7 @@ std::string SpaFile::GetStringTableEntry(XdbfLocale locale,
|
|||
|
||||
auto xstr_head =
|
||||
reinterpret_cast<const X_XDBF_TABLE_HEADER*>(xstr_table->data.data());
|
||||
assert_true(xstr_head->magic == static_cast<uint32_t>(XdbfSpaID::Xstr));
|
||||
assert_true(xstr_head->magic == static_cast<uint32_t>(SpaID::Xstr));
|
||||
assert_true(xstr_head->version == 1);
|
||||
|
||||
const uint8_t* ptr = xstr_table->data.data() + sizeof(X_XDBF_TABLE_HEADER);
|
||||
|
@ -182,20 +181,19 @@ std::string SpaFile::GetStringTableEntry(XdbfLocale locale,
|
|||
}
|
||||
|
||||
uint32_t SpaFile::GetAchievements(
|
||||
XdbfLocale locale, std::vector<XdbfAchievement>* achievements) const {
|
||||
auto xach_table = GetEntry(static_cast<uint16_t>(XdbfSpaSection::kMetadata),
|
||||
static_cast<uint64_t>(XdbfSpaID::Xach));
|
||||
Locale locale, std::vector<Achievement>* achievements) const {
|
||||
auto xach_table = GetEntry(static_cast<uint16_t>(SpaSection::kMetadata),
|
||||
static_cast<uint64_t>(SpaID::Xach));
|
||||
if (!xach_table) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto xach_head =
|
||||
reinterpret_cast<const X_XDBF_TABLE_HEADER*>(xach_table->data.data());
|
||||
assert_true(xach_head->magic == static_cast<uint32_t>(XdbfSpaID::Xach));
|
||||
assert_true(xach_head->magic == static_cast<uint32_t>(SpaID::Xach));
|
||||
assert_true(xach_head->version == 1);
|
||||
|
||||
auto xstr_table =
|
||||
GetEntry(static_cast<uint16_t>(XdbfSpaSection::kStringTable),
|
||||
auto xstr_table = GetEntry(static_cast<uint16_t>(SpaSection::kStringTable),
|
||||
static_cast<uint64_t>(locale));
|
||||
if (!xstr_table) {
|
||||
return 0;
|
||||
|
@ -203,7 +201,7 @@ uint32_t SpaFile::GetAchievements(
|
|||
|
||||
auto xstr_head =
|
||||
reinterpret_cast<const X_XDBF_TABLE_HEADER*>(xstr_table->data.data());
|
||||
assert_true(xstr_head->magic == static_cast<uint32_t>(XdbfSpaID::Xstr));
|
||||
assert_true(xstr_head->magic == static_cast<uint32_t>(SpaID::Xstr));
|
||||
assert_true(xstr_head->version == 1);
|
||||
|
||||
const uint8_t* xstr_ptr =
|
||||
|
@ -213,7 +211,7 @@ uint32_t SpaFile::GetAchievements(
|
|||
auto* ach_data =
|
||||
reinterpret_cast<const X_XDBF_SPA_ACHIEVEMENT*>(xach_head + 1);
|
||||
for (uint32_t i = 0; i < xach_head->count; i++) {
|
||||
XdbfAchievement ach;
|
||||
Achievement ach;
|
||||
ach.id = ach_data->id;
|
||||
ach.image_id = ach_data->image_id;
|
||||
ach.gamerscore = ach_data->gamerscore;
|
||||
|
@ -236,47 +234,47 @@ uint32_t SpaFile::GetAchievements(
|
|||
return xach_head->count;
|
||||
}
|
||||
|
||||
XdbfEntry* SpaFile::GetIcon() const {
|
||||
return GetEntry(static_cast<uint16_t>(XdbfSpaSection::kImage),
|
||||
static_cast<uint64_t>(XdbfSpaID::Title));
|
||||
Entry* SpaFile::GetIcon() const {
|
||||
return GetEntry(static_cast<uint16_t>(SpaSection::kImage),
|
||||
static_cast<uint64_t>(SpaID::Title));
|
||||
}
|
||||
|
||||
XdbfLocale SpaFile::GetDefaultLocale() const {
|
||||
auto block = GetEntry(static_cast<uint16_t>(XdbfSpaSection::kMetadata),
|
||||
static_cast<uint64_t>(XdbfSpaID::Xstc));
|
||||
Locale SpaFile::GetDefaultLocale() const {
|
||||
auto block = GetEntry(static_cast<uint16_t>(SpaSection::kMetadata),
|
||||
static_cast<uint64_t>(SpaID::Xstc));
|
||||
if (!block) {
|
||||
return XdbfLocale::kEnglish;
|
||||
return Locale::kEnglish;
|
||||
}
|
||||
|
||||
auto xstc = reinterpret_cast<const X_XDBF_XSTC_DATA*>(block->data.data());
|
||||
assert_true(xstc->magic == static_cast<uint32_t>(XdbfSpaID::Xstc));
|
||||
assert_true(xstc->magic == static_cast<uint32_t>(SpaID::Xstc));
|
||||
|
||||
return static_cast<XdbfLocale>(static_cast<uint32_t>(xstc->default_language));
|
||||
return static_cast<Locale>(static_cast<uint32_t>(xstc->default_language));
|
||||
}
|
||||
|
||||
std::string SpaFile::GetTitleName() const {
|
||||
return GetStringTableEntry(GetDefaultLocale(),
|
||||
static_cast<uint16_t>(XdbfSpaID::Title));
|
||||
static_cast<uint16_t>(SpaID::Title));
|
||||
}
|
||||
|
||||
uint32_t SpaFile::GetTitleId() const {
|
||||
auto block = GetEntry(static_cast<uint16_t>(XdbfSpaSection::kMetadata),
|
||||
static_cast<uint64_t>(XdbfSpaID::Xthd));
|
||||
auto block = GetEntry(static_cast<uint16_t>(SpaSection::kMetadata),
|
||||
static_cast<uint64_t>(SpaID::Xthd));
|
||||
if (!block) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto xthd = reinterpret_cast<const X_XDBF_XTHD_DATA*>(block->data.data());
|
||||
assert_true(xthd->magic == static_cast<uint32_t>(XdbfSpaID::Xthd));
|
||||
assert_true(xthd->magic == static_cast<uint32_t>(SpaID::Xthd));
|
||||
|
||||
return xthd->title_id;
|
||||
}
|
||||
|
||||
bool GpdFile::GetAchievement(uint16_t id, XdbfAchievement* dest) {
|
||||
bool GpdFile::GetAchievement(uint16_t id, Achievement* dest) {
|
||||
for (size_t i = 0; i < entries_.size(); i++) {
|
||||
auto* entry = (XdbfEntry*)&entries_[i];
|
||||
auto* entry = (Entry*)&entries_[i];
|
||||
if (entry->info.section !=
|
||||
static_cast<uint16_t>(XdbfGpdSection::kAchievement) ||
|
||||
static_cast<uint16_t>(GpdSection::kAchievement) ||
|
||||
entry->info.id != id) {
|
||||
continue;
|
||||
}
|
||||
|
@ -294,13 +292,13 @@ bool GpdFile::GetAchievement(uint16_t id, XdbfAchievement* dest) {
|
|||
}
|
||||
|
||||
uint32_t GpdFile::GetAchievements(
|
||||
std::vector<XdbfAchievement>* achievements) const {
|
||||
std::vector<Achievement>* achievements) const {
|
||||
uint32_t ach_count = 0;
|
||||
|
||||
for (size_t i = 0; i < entries_.size(); i++) {
|
||||
auto* entry = (XdbfEntry*)&entries_[i];
|
||||
auto* entry = (Entry*)&entries_[i];
|
||||
if (entry->info.section !=
|
||||
static_cast<uint16_t>(XdbfGpdSection::kAchievement)) {
|
||||
static_cast<uint16_t>(GpdSection::kAchievement)) {
|
||||
continue;
|
||||
}
|
||||
if (entry->info.id == 0x100000000 || entry->info.id == 0x200000000) {
|
||||
|
@ -313,7 +311,7 @@ uint32_t GpdFile::GetAchievements(
|
|||
auto* ach_data =
|
||||
reinterpret_cast<const X_XDBF_GPD_ACHIEVEMENT*>(entry->data.data());
|
||||
|
||||
XdbfAchievement ach;
|
||||
Achievement ach;
|
||||
ach.ReadGPD(ach_data);
|
||||
|
||||
achievements->push_back(ach);
|
||||
|
@ -323,10 +321,10 @@ uint32_t GpdFile::GetAchievements(
|
|||
return ach_count;
|
||||
}
|
||||
|
||||
bool GpdFile::GetTitle(uint32_t title_id, XdbfTitlePlayed* dest) {
|
||||
bool GpdFile::GetTitle(uint32_t title_id, TitlePlayed* dest) {
|
||||
for (size_t i = 0; i < entries_.size(); i++) {
|
||||
auto* entry = (XdbfEntry*)&entries_[i];
|
||||
if (entry->info.section != static_cast<uint16_t>(XdbfGpdSection::kTitle) ||
|
||||
auto* entry = (Entry*)&entries_[i];
|
||||
if (entry->info.section != static_cast<uint16_t>(GpdSection::kTitle) ||
|
||||
entry->info.id != title_id) {
|
||||
continue;
|
||||
}
|
||||
|
@ -342,12 +340,12 @@ bool GpdFile::GetTitle(uint32_t title_id, XdbfTitlePlayed* dest) {
|
|||
return false;
|
||||
}
|
||||
|
||||
uint32_t GpdFile::GetTitles(std::vector<XdbfTitlePlayed>* titles) const {
|
||||
uint32_t GpdFile::GetTitles(std::vector<TitlePlayed>* titles) const {
|
||||
uint32_t title_count = 0;
|
||||
|
||||
for (size_t i = 0; i < entries_.size(); i++) {
|
||||
auto* entry = (XdbfEntry*)&entries_[i];
|
||||
if (entry->info.section != static_cast<uint16_t>(XdbfGpdSection::kTitle)) {
|
||||
auto* entry = (Entry*)&entries_[i];
|
||||
if (entry->info.section != static_cast<uint16_t>(GpdSection::kTitle)) {
|
||||
continue;
|
||||
}
|
||||
if (entry->info.id == 0x100000000 || entry->info.id == 0x200000000) {
|
||||
|
@ -360,7 +358,7 @@ uint32_t GpdFile::GetTitles(std::vector<XdbfTitlePlayed>* titles) const {
|
|||
auto* title_data =
|
||||
reinterpret_cast<const X_XDBF_GPD_TITLEPLAYED*>(entry->data.data());
|
||||
|
||||
XdbfTitlePlayed title;
|
||||
TitlePlayed title;
|
||||
title.ReadGPD(title_data);
|
||||
titles->push_back(title);
|
||||
}
|
||||
|
@ -369,9 +367,9 @@ uint32_t GpdFile::GetTitles(std::vector<XdbfTitlePlayed>* titles) const {
|
|||
return title_count;
|
||||
}
|
||||
|
||||
bool GpdFile::UpdateAchievement(XdbfAchievement ach) {
|
||||
XdbfEntry ent;
|
||||
ent.info.section = static_cast<uint16_t>(XdbfGpdSection::kAchievement);
|
||||
bool GpdFile::UpdateAchievement(Achievement ach) {
|
||||
Entry ent;
|
||||
ent.info.section = static_cast<uint16_t>(GpdSection::kAchievement);
|
||||
ent.info.id = ach.id;
|
||||
|
||||
// calculate entry size...
|
||||
|
@ -387,7 +385,7 @@ bool GpdFile::UpdateAchievement(XdbfAchievement ach) {
|
|||
ent.data.resize(est_size);
|
||||
memset(ent.data.data(), 0, est_size);
|
||||
|
||||
// convert XdbfAchievement to GPD achievement
|
||||
// convert Achievement to GPD achievement
|
||||
auto* ach_data = reinterpret_cast<X_XDBF_GPD_ACHIEVEMENT*>(ent.data.data());
|
||||
ach_data->id = ach.id;
|
||||
ach_data->image_id = ach.image_id;
|
||||
|
@ -410,9 +408,9 @@ bool GpdFile::UpdateAchievement(XdbfAchievement ach) {
|
|||
return UpdateEntry(ent);
|
||||
}
|
||||
|
||||
bool GpdFile::UpdateTitle(XdbfTitlePlayed title) {
|
||||
XdbfEntry ent;
|
||||
ent.info.section = static_cast<uint16_t>(XdbfGpdSection::kTitle);
|
||||
bool GpdFile::UpdateTitle(TitlePlayed title) {
|
||||
Entry ent;
|
||||
ent.info.section = static_cast<uint16_t>(GpdSection::kTitle);
|
||||
ent.info.id = title.title_id;
|
||||
|
||||
// calculate entry size...
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace xdbf {
|
|||
// https://github.com/oukiar/freestyledash/blob/master/Freestyle/Tools/XEX/SPA.h
|
||||
// https://github.com/oukiar/freestyledash/blob/master/Freestyle/Tools/XEX/SPA.cpp
|
||||
|
||||
enum class XdbfSpaID : uint64_t {
|
||||
enum class SpaID : uint64_t {
|
||||
Xach = 'XACH',
|
||||
Xstr = 'XSTR',
|
||||
Xstc = 'XSTC',
|
||||
|
@ -34,13 +34,13 @@ enum class XdbfSpaID : uint64_t {
|
|||
Title = 0x8000,
|
||||
};
|
||||
|
||||
enum class XdbfSpaSection : uint16_t {
|
||||
enum class SpaSection : uint16_t {
|
||||
kMetadata = 0x1,
|
||||
kImage = 0x2,
|
||||
kStringTable = 0x3,
|
||||
};
|
||||
|
||||
enum class XdbfGpdSection : uint16_t {
|
||||
enum class GpdSection : uint16_t {
|
||||
kAchievement = 0x1,
|
||||
kImage = 0x2,
|
||||
kSetting = 0x3,
|
||||
|
@ -50,7 +50,7 @@ enum class XdbfGpdSection : uint16_t {
|
|||
};
|
||||
|
||||
// Found by dumping the kSectionStringTable sections of various games:
|
||||
enum class XdbfLocale : uint32_t {
|
||||
enum class Locale : uint32_t {
|
||||
kUnknown = 0,
|
||||
kEnglish = 1,
|
||||
kJapanese = 2,
|
||||
|
@ -73,7 +73,7 @@ inline std::wstring ReadNullTermString(const wchar_t* ptr) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
struct XdbfTitlePlayed {
|
||||
struct TitlePlayed {
|
||||
uint32_t title_id = 0;
|
||||
std::wstring title_name;
|
||||
uint32_t achievements_possible = 0;
|
||||
|
@ -123,7 +123,7 @@ struct XdbfTitlePlayed {
|
|||
}
|
||||
};
|
||||
|
||||
enum class XdbfAchievementType : uint32_t {
|
||||
enum class AchievementType : uint32_t {
|
||||
kCompletion = 1,
|
||||
kLeveling = 2,
|
||||
kUnlock = 3,
|
||||
|
@ -133,14 +133,14 @@ enum class XdbfAchievementType : uint32_t {
|
|||
kOther = 7,
|
||||
};
|
||||
|
||||
enum class XdbfAchievementFlags : uint32_t {
|
||||
enum class AchievementFlags : uint32_t {
|
||||
kTypeMask = 0x7,
|
||||
kShowUnachieved = 0x8,
|
||||
kAchievedOnline = 0x10000,
|
||||
kAchieved = 0x20000
|
||||
};
|
||||
|
||||
struct XdbfAchievement {
|
||||
struct Achievement {
|
||||
uint16_t id = 0;
|
||||
std::wstring label;
|
||||
std::wstring description;
|
||||
|
@ -150,32 +150,31 @@ struct XdbfAchievement {
|
|||
uint32_t flags = 0;
|
||||
uint64_t unlock_time = 0;
|
||||
|
||||
XdbfAchievementType GetType() {
|
||||
return static_cast<XdbfAchievementType>(
|
||||
flags & static_cast<uint32_t>(XdbfAchievementFlags::kTypeMask));
|
||||
AchievementType GetType() {
|
||||
return static_cast<AchievementType>(
|
||||
flags & static_cast<uint32_t>(AchievementFlags::kTypeMask));
|
||||
}
|
||||
|
||||
bool IsUnlocked() {
|
||||
return flags & static_cast<uint32_t>(XdbfAchievementFlags::kAchieved);
|
||||
return flags & static_cast<uint32_t>(AchievementFlags::kAchieved);
|
||||
}
|
||||
|
||||
bool IsUnlockedOnline() {
|
||||
return flags & static_cast<uint32_t>(XdbfAchievementFlags::kAchievedOnline);
|
||||
return flags & static_cast<uint32_t>(AchievementFlags::kAchievedOnline);
|
||||
}
|
||||
|
||||
void Unlock(bool online = false) {
|
||||
flags |= static_cast<uint32_t>(XdbfAchievementFlags::kAchieved);
|
||||
flags |= static_cast<uint32_t>(AchievementFlags::kAchieved);
|
||||
if (online) {
|
||||
flags |= static_cast<uint32_t>(XdbfAchievementFlags::kAchievedOnline);
|
||||
flags |= static_cast<uint32_t>(AchievementFlags::kAchievedOnline);
|
||||
}
|
||||
|
||||
unlock_time = Clock::QueryHostSystemTime();
|
||||
}
|
||||
|
||||
void Lock() {
|
||||
flags = flags & ~(static_cast<uint32_t>(XdbfAchievementFlags::kAchieved));
|
||||
flags =
|
||||
flags & ~(static_cast<uint32_t>(XdbfAchievementFlags::kAchievedOnline));
|
||||
flags = flags & ~(static_cast<uint32_t>(AchievementFlags::kAchieved));
|
||||
flags = flags & ~(static_cast<uint32_t>(AchievementFlags::kAchievedOnline));
|
||||
unlock_time = 0;
|
||||
}
|
||||
|
||||
|
@ -198,7 +197,7 @@ struct XdbfAchievement {
|
|||
}
|
||||
};
|
||||
|
||||
struct XdbfEntry {
|
||||
struct Entry {
|
||||
X_XDBF_ENTRY info;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
@ -215,26 +214,26 @@ class XdbfFile {
|
|||
bool Read(const uint8_t* data, size_t data_size);
|
||||
bool Write(uint8_t* data, size_t* data_size);
|
||||
|
||||
XdbfEntry* GetEntry(uint16_t section, uint64_t id) const;
|
||||
Entry* GetEntry(uint16_t section, uint64_t id) const;
|
||||
|
||||
// Updates (or adds) an entry
|
||||
bool UpdateEntry(XdbfEntry entry);
|
||||
bool UpdateEntry(Entry entry);
|
||||
|
||||
protected:
|
||||
X_XDBF_HEADER header_;
|
||||
std::vector<XdbfEntry> entries_;
|
||||
std::vector<Entry> entries_;
|
||||
std::vector<X_XDBF_FILELOC> free_entries_;
|
||||
};
|
||||
|
||||
class SpaFile : public XdbfFile {
|
||||
public:
|
||||
std::string GetStringTableEntry(XdbfLocale locale, uint16_t string_id) const;
|
||||
std::string GetStringTableEntry(Locale locale, uint16_t string_id) const;
|
||||
|
||||
uint32_t GetAchievements(XdbfLocale locale,
|
||||
std::vector<XdbfAchievement>* achievements) const;
|
||||
uint32_t GetAchievements(Locale locale,
|
||||
std::vector<Achievement>* achievements) const;
|
||||
|
||||
XdbfEntry* GetIcon() const;
|
||||
XdbfLocale GetDefaultLocale() const;
|
||||
Entry* GetIcon() const;
|
||||
Locale GetDefaultLocale() const;
|
||||
std::string GetTitleName() const;
|
||||
uint32_t GetTitleId() const;
|
||||
};
|
||||
|
@ -244,17 +243,17 @@ class GpdFile : public XdbfFile {
|
|||
GpdFile() : title_id_(-1) {}
|
||||
GpdFile(uint32_t title_id) : title_id_(title_id) {}
|
||||
|
||||
bool GetAchievement(uint16_t id, XdbfAchievement* dest);
|
||||
uint32_t GetAchievements(std::vector<XdbfAchievement>* achievements) const;
|
||||
bool GetAchievement(uint16_t id, Achievement* dest);
|
||||
uint32_t GetAchievements(std::vector<Achievement>* achievements) const;
|
||||
|
||||
bool GetTitle(uint32_t title_id, XdbfTitlePlayed* title);
|
||||
uint32_t GetTitles(std::vector<XdbfTitlePlayed>* titles) const;
|
||||
bool GetTitle(uint32_t title_id, TitlePlayed* title);
|
||||
uint32_t GetTitles(std::vector<TitlePlayed>* titles) const;
|
||||
|
||||
// Updates (or adds) an achievement
|
||||
bool UpdateAchievement(XdbfAchievement ach);
|
||||
bool UpdateAchievement(Achievement ach);
|
||||
|
||||
// Updates (or adds) a title
|
||||
bool UpdateTitle(XdbfTitlePlayed title);
|
||||
bool UpdateTitle(TitlePlayed title);
|
||||
|
||||
uint32_t GetTitleId() { return title_id_; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue