Make PERSISTENT_ID more reusable

This commit is contained in:
Nightkingale 2024-07-31 20:21:39 -06:00
parent e30893b7d0
commit bad393a8ba
3 changed files with 9 additions and 10 deletions

View File

@ -8,11 +8,11 @@
const int BUFFER_SIZE = 0x2000; // The buffer size allocated for reading and writing files. const int BUFFER_SIZE = 0x2000; // The buffer size allocated for reading and writing files.
extern unsigned int PERSISTENT_ID; // The current user persistant ID.
extern bool INKAY_EXISTS; // Whether the Inkay plugin config exists. extern bool INKAY_EXISTS; // Whether the Inkay plugin config exists.
extern std::string NNID_BACKUP; // The backup path to the Nintendo Network ID account.dat. extern std::string NNID_BACKUP; // The backup path to the Nintendo Network ID account.dat.
extern std::string PNID_BACKUP; // The backup path to the Pretendo Network ID account.dat. extern std::string PNID_BACKUP; // The backup path to the Pretendo Network ID account.dat.
extern std::string MII_NICKNAME; // The current user's Mii nickname. extern std::string MII_NICKNAME; // The current user's Mii nickname.
extern std::string PERSISTENT_ID; // The current user persistant ID.
extern std::string ACCOUNT_ID; // The current user's account name. extern std::string ACCOUNT_ID; // The current user's account name.
extern std::string ACCOUNT_FILE; // The path to the current account.dat. extern std::string ACCOUNT_FILE; // The path to the current account.dat.
extern std::string INKAY_CONFIG; // The path to the Inkay configuration file. extern std::string INKAY_CONFIG; // The path to the Inkay configuration file.

View File

@ -20,11 +20,11 @@
#include "utils.hpp" #include "utils.hpp"
unsigned int PERSISTENT_ID; // The current user persistant ID.
bool INKAY_EXISTS; // Whether the Inkay plugin config exists. bool INKAY_EXISTS; // Whether the Inkay plugin config exists.
std::string NNID_BACKUP; // The backup path to the Nintendo Network ID account.dat. std::string NNID_BACKUP; // The backup path to the Nintendo Network ID account.dat.
std::string PNID_BACKUP; // The backup path to the Pretendo Network ID account.dat. std::string PNID_BACKUP; // The backup path to the Pretendo Network ID account.dat.
std::string MII_NICKNAME; // The current user's Mii nickname. std::string MII_NICKNAME; // The current user's Mii nickname.
std::string PERSISTENT_ID; // The current user persistent ID.
std::string ACCOUNT_ID; // The current user's account name. std::string ACCOUNT_ID; // The current user's account name.
std::string ACCOUNT_FILE; // The path to the current account.dat. std::string ACCOUNT_FILE; // The path to the current account.dat.
std::string INKAY_CONFIG; // The path to the Inkay configuration file. std::string INKAY_CONFIG; // The path to the Inkay configuration file.
@ -50,16 +50,17 @@ get_user_information()
ACCOUNT_ID = std::string(account_id); ACCOUNT_ID = std::string(account_id);
// Get the user's persistent ID. // Get the user's persistent ID.
PERSISTENT_ID = nn::act::GetPersistentId(); unsigned int persistent_id_result = nn::act::GetPersistentId();
char persistent_id_hex[9]; char persistent_id_hex[9];
snprintf(persistent_id_hex, sizeof persistent_id_hex, "%08x", PERSISTENT_ID); snprintf(persistent_id_hex, sizeof persistent_id_hex, "%08x", persistent_id_result);
PERSISTENT_ID = std::string(persistent_id_hex);
// Set the account file path. // Set the account file path.
ACCOUNT_FILE = "storage_mlc:/usr/save/system/act/" + std::string(persistent_id_hex) + "/account.dat"; ACCOUNT_FILE = "storage_mlc:/usr/save/system/act/" + PERSISTENT_ID + "/account.dat";
// Set the backup file paths. // Set the backup file paths.
NNID_BACKUP = "fs:/vol/external01/wiiu/accounts/" + std::string(persistent_id_hex) + "/nnid_account.dat"; NNID_BACKUP = "fs:/vol/external01/wiiu/accounts/" + PERSISTENT_ID + "/nnid_account.dat";
PNID_BACKUP = "fs:/vol/external01/wiiu/accounts/" + std::string(persistent_id_hex) + "/pnid_account.dat"; PNID_BACKUP = "fs:/vol/external01/wiiu/accounts/" + PERSISTENT_ID + "/pnid_account.dat";
// Get the environment path and set the Inkay configuration file path. // Get the environment path and set the Inkay configuration file path.
char environment_path_buffer[0x100]; char environment_path_buffer[0x100];

View File

@ -57,9 +57,7 @@ user_check(FILE* backup, account account_type)
} }
// Prepare the search string, including the user's persistent ID. // Prepare the search string, including the user's persistent ID.
char persistent_id_hex[9]; std::string search_string = "PersistentId=" + PERSISTENT_ID;
snprintf(persistent_id_hex, sizeof persistent_id_hex, "%08x", PERSISTENT_ID);
std::string search_string = "PersistentId=" + std::string(persistent_id_hex);
bool found = false; bool found = false;
rewind(backup); rewind(backup);