Profile: add support for reading OS unlocks.
This commit is contained in:
parent
8ab9933f2f
commit
1084d8e132
2 changed files with 56 additions and 0 deletions
|
@ -111,6 +111,7 @@ void Profile::refreshValues() {
|
|||
getCarbonizedSkin();
|
||||
|
||||
getEngineUnlocks();
|
||||
getOsUnlocks();
|
||||
}
|
||||
|
||||
auto Profile::companyName() const -> std::string const& {
|
||||
|
@ -1054,3 +1055,54 @@ void Profile::getEngineUnlocks() {
|
|||
_lastError = "The profile save seems to be corrupted or the game didn't release the handle on the file.";
|
||||
}
|
||||
}
|
||||
|
||||
auto Profile::osInventory() -> Containers::ArrayView<Int> {
|
||||
return _osInventory;
|
||||
}
|
||||
|
||||
auto Profile::moduleInventory() -> Containers::ArrayView<Int> {
|
||||
return _moduleInventory;
|
||||
}
|
||||
|
||||
void Profile::getOsUnlocks() {
|
||||
auto mmap = Utility::Directory::map(Utility::Directory::join(_profileDirectory, _filename));
|
||||
|
||||
auto iter = std::search(mmap.begin(), mmap.end(), &os_inventory_locator[0], &os_inventory_locator[29]);
|
||||
|
||||
if(iter != mmap.end()) {
|
||||
Int* int_iter = reinterpret_cast<Int*>(iter + 0x37);
|
||||
Int size = *(int_iter++);
|
||||
|
||||
if(size > 0) {
|
||||
_osInventory = Containers::Array<Int>{DefaultInit, std::size_t(size)};
|
||||
std::copy_n(int_iter, size, _osInventory.data());
|
||||
|
||||
Utility::Debug{} << "_osInventory:" << _osInventory;
|
||||
|
||||
iter = std::search(mmap.begin(), mmap.end(), &module_inventory_locator[0], &module_inventory_locator[33]);
|
||||
|
||||
if(iter == mmap.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int_iter = reinterpret_cast<Int*>(iter + 0x3B);
|
||||
size = *(int_iter++);
|
||||
|
||||
if(size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_moduleInventory = Containers::Array<Int>{DefaultInit, std::size_t(size)};
|
||||
std::copy_n(int_iter, size, _moduleInventory.data());
|
||||
|
||||
Utility::Debug{} << "_moduleInventory:" << _moduleInventory;
|
||||
}
|
||||
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.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,6 +147,10 @@ class Profile {
|
|||
auto gearInventory() -> Containers::ArrayView<Int>;
|
||||
void getEngineUnlocks();
|
||||
|
||||
auto osInventory() -> Containers::ArrayView<Int>;
|
||||
auto moduleInventory() -> Containers::ArrayView<Int>;
|
||||
void getOsUnlocks();
|
||||
|
||||
private:
|
||||
std::string _profileDirectory;
|
||||
std::string _filename;
|
||||
|
|
Loading…
Reference in a new issue