redesign, broadcast server crash fix

This commit is contained in:
2026-04-26 12:41:58 +03:00
parent 4ffa6ed970
commit 64b30e9835
20 changed files with 771 additions and 167 deletions
+37
View File
@@ -26,6 +26,8 @@
#include "account.hpp"
#include <main.hpp>
#include <sys/stat.h>
#include <cstdio>
static std::map<AccountUid, User> mUsers;
@@ -85,6 +87,41 @@ std::string Account::username(AccountUid id)
return got->second.name;
}
std::string Account::iconPath(AccountUid id)
{
char path[128];
snprintf(path, sizeof(path), "sdmc:/switch/NXST/cache/%016lX%016lX.jpg",
id.uid[0], id.uid[1]);
struct stat st;
if (stat(path, &st) == 0 && st.st_size > 0) return std::string(path);
mkdir("sdmc:/switch", 0755);
mkdir("sdmc:/switch/NXST", 0755);
mkdir("sdmc:/switch/NXST/cache", 0755);
AccountProfile profile;
if (R_FAILED(accountGetProfile(&profile, id))) return "";
u32 imgSize = 0;
if (R_FAILED(accountProfileGetImageSize(&profile, &imgSize)) || imgSize == 0) {
accountProfileClose(&profile);
return "";
}
std::vector<u8> buf(imgSize);
u32 outSize = 0;
Result r = accountProfileLoadImage(&profile, buf.data(), imgSize, &outSize);
accountProfileClose(&profile);
if (R_FAILED(r) || outSize == 0) return "";
FILE* f = fopen(path, "wb");
if (!f) return "";
fwrite(buf.data(), 1, outSize, f);
fclose(f);
return std::string(path);
}
AccountUid Account::selectAccount(void)
{
LibAppletArgs args;