nn_act: Fix account endianness (#141)

Also adds some code for enabling multi-user support inside apps maybe, but it's probably hardcoded in more places since Cemu currently only shows the active account.
This commit is contained in:
Crementif 2022-09-02 09:46:19 +02:00 committed by GitHub
parent a3b1af4e3d
commit 86e1a2227c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 9 deletions

View File

@ -29,7 +29,7 @@ typedef struct
/* +0x0C */ uint8 ukn0C[0xA]; /* +0x0C */ uint8 ukn0C[0xA];
/* +0x16 */ uint8 ukn16[2]; /* +0x16 */ uint8 ukn16[2];
/* +0x18 */ uint16 ukn18; /* +0x18 */ uint16 ukn18;
/* +0x1A */ uint16be miiName[10]; /* +0x1A */ uint16le miiName[10];
/* +0x2E */ uint16 ukn2E; /* +0x2E */ uint16 ukn2E;
/* +0x30 */ uint8 ukn30[96 - 0x30]; /* +0x30 */ uint8 ukn30[96 - 0x30];
}FFLData_t; }FFLData_t;
@ -102,7 +102,7 @@ Account::Account(uint32 persistent_id, std::wstring_view mii_name)
FFLData_t* fflData = (FFLData_t*)m_mii_data.data(); FFLData_t* fflData = (FFLData_t*)m_mii_data.data();
const auto tmp_name = GetMiiName(); const auto tmp_name = GetMiiName();
memset(fflData->miiName, 0, sizeof(fflData->miiName)); memset(fflData->miiName, 0, sizeof(fflData->miiName));
std::copy(tmp_name.cbegin(), tmp_name.cend(), fflData->miiName); std::copy(tmp_name.begin(), tmp_name.end(), fflData->miiName);
// calculate checksum // calculate checksum
uint32 crcCounter = 0; uint32 crcCounter = 0;

View File

@ -48,7 +48,7 @@ typedef struct
char country[8]; char country[8];
// Mii // Mii
FFLData_t miiData; FFLData_t miiData;
uint16be miiNickname[ACT_NICKNAME_LENGTH]; uint16le miiNickname[ACT_NICKNAME_LENGTH];
}actAccountData_t; }actAccountData_t;
#define IOSU_ACT_ACCOUNT_MAX_COUNT (0xC) #define IOSU_ACT_ACCOUNT_MAX_COUNT (0xC)
@ -103,6 +103,15 @@ void iosuAct_loadAccounts()
const auto& first_acc = Account::GetAccount(persistent_id); const auto& first_acc = Account::GetAccount(persistent_id);
FillAccountData(first_acc, online_enabled, counter); FillAccountData(first_acc, online_enabled, counter);
++counter; ++counter;
// enable multiple accounts for cafe functions (badly tested)
//for (const auto& account : Account::GetAccounts())
//{
// if (first_acc.GetPersistentId() != account.GetPersistentId())
// {
// FillAccountData(account, online_enabled, counter);
// ++counter;
// }
//}
cemuLog_force(L"IOSU_ACT: using account {} in first slot", first_acc.GetMiiName()); cemuLog_force(L"IOSU_ACT: using account {} in first slot", first_acc.GetMiiName());

View File

@ -25,7 +25,7 @@ typedef struct
/* +0x0C */ uint8 ukn0C[0xA]; /* +0x0C */ uint8 ukn0C[0xA];
/* +0x16 */ uint8 ukn16[2]; /* +0x16 */ uint8 ukn16[2];
/* +0x18 */ uint16 ukn18; /* +0x18 */ uint16 ukn18;
/* +0x1A */ uint16be miiName[MII_FFL_NAME_LENGTH]; /* +0x1A */ uint16le miiName[MII_FFL_NAME_LENGTH];
/* +0x2E */ uint16 ukn2E; /* +0x2E */ uint16 ukn2E;
/* +0x30 */ uint8 ukn30[MII_FFL_STORAGE_SIZE-0x30]; /* +0x30 */ uint8 ukn30[MII_FFL_STORAGE_SIZE-0x30];
}FFLData_t; }FFLData_t;

View File

@ -138,11 +138,9 @@ void nnActExport_GetNumOfAccounts(PPCInterpreter_t* hCPU)
void nnActExport_IsSlotOccupied(PPCInterpreter_t* hCPU) void nnActExport_IsSlotOccupied(PPCInterpreter_t* hCPU)
{ {
forceLogDebug_printf("nn_act.IsSlotOccupied(%d)\n", hCPU->gpr[3]); forceLogDebug_printf("nn_act.IsSlotOccupied(%d)\n", hCPU->gpr[3]);
sint32 slotIndex = (sint32)hCPU->gpr[3] - 1; // first slot is 1 ppcDefineParamU8(slot, 0);
bool isOccupied = false;
if( slotIndex == 0 ) osLib_returnFromFunction(hCPU, nn::act::GetPersistentIdEx(slot) != 0 ? 1 : 0);
isOccupied = true;
osLib_returnFromFunction(hCPU, isOccupied?1:0);
} }
uint32 GetAccountIdEx(char* accountId, uint8 slot) uint32 GetAccountIdEx(char* accountId, uint8 slot)