Profile: add support for reading arch unlocks.
This commit is contained in:
parent
44ee2f2c35
commit
fee5c2aefd
2 changed files with 56 additions and 0 deletions
|
@ -112,6 +112,7 @@ void Profile::refreshValues() {
|
|||
|
||||
getEngineUnlocks();
|
||||
getOsUnlocks();
|
||||
getArchUnlocks();
|
||||
}
|
||||
|
||||
auto Profile::companyName() const -> std::string const& {
|
||||
|
@ -1106,3 +1107,54 @@ void Profile::getOsUnlocks() {
|
|||
_lastError = "The profile save seems to be corrupted or the game didn't release the handle on the file.";
|
||||
}
|
||||
}
|
||||
|
||||
auto Profile::archInventory() -> Containers::ArrayView<Int> {
|
||||
return _archInventory;
|
||||
}
|
||||
|
||||
auto Profile::techInventory() -> Containers::ArrayView<Int> {
|
||||
return _techInventory;
|
||||
}
|
||||
|
||||
void Profile::getArchUnlocks() {
|
||||
auto mmap = Utility::Directory::map(Utility::Directory::join(_profileDirectory, _filename));
|
||||
|
||||
auto iter = std::search(mmap.begin(), mmap.end(), &arch_inventory_locator[0], &arch_inventory_locator[36]);
|
||||
|
||||
if(iter != mmap.end()) {
|
||||
Int* int_iter = reinterpret_cast<Int*>(iter + 0x3E);
|
||||
Int size = *(int_iter++);
|
||||
|
||||
if(size > 0) {
|
||||
_archInventory = Containers::Array<Int>{DefaultInit, std::size_t(size)};
|
||||
std::copy_n(int_iter, size, _archInventory.data());
|
||||
|
||||
Utility::Debug{} << "_archInventory:" << _archInventory;
|
||||
|
||||
iter = std::search(mmap.begin(), mmap.end(), &tech_inventory_locator[0], &tech_inventory_locator[31]);
|
||||
|
||||
if(iter == mmap.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int_iter = reinterpret_cast<Int*>(iter + 0x39);
|
||||
size = *(int_iter++);
|
||||
|
||||
if(size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_techInventory = Containers::Array<Int>{DefaultInit, std::size_t(size)};
|
||||
std::copy_n(int_iter, size, _techInventory.data());
|
||||
|
||||
Utility::Debug{} << "_techInventory:" << _techInventory;
|
||||
}
|
||||
else {
|
||||
_lastError = "An array can't have a null or negative size.";
|
||||
Utility::Fatal{EXIT_FAILURE} << _lastError.c_str();
|
||||
}
|
||||
}
|
||||
else {
|
||||
_lastError = "The profile save seems to be corrupted or the game didn't release the handle on the file.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,6 +151,10 @@ class Profile {
|
|||
auto moduleInventory() -> Containers::ArrayView<Int>;
|
||||
void getOsUnlocks();
|
||||
|
||||
auto archInventory() -> Containers::ArrayView<Int>;
|
||||
auto techInventory() -> Containers::ArrayView<Int>;
|
||||
void getArchUnlocks();
|
||||
|
||||
private:
|
||||
std::string _profileDirectory;
|
||||
std::string _filename;
|
||||
|
|
Loading…
Reference in a new issue