From 39ed683c952fd9d6115064570f2703c588bcbac8 Mon Sep 17 00:00:00 2001 From: Nico Meister Date: Mon, 26 Oct 2026 21:26:23 +0100 Subject: [PATCH] =?UTF-8?q?v3.1.5:=20ACT=5FSave=20nach=20SetDefaultAccount?= =?UTF-8?q?=20(Soft-Reboot=20verlor=20die=20Einstellung),=20Admin-Pr=C3=BC?= =?UTF-8?q?fung=20stellt=20act=20auf=20den=20MBMNET-Platz=20und=20zeigt=20?= =?UTF-8?q?beide=20IDs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- Makefile | 2 +- source/admin.c | 27 ++++++++++++++++++++------- source/admin.h | 2 +- source/frdswitch.c | 6 +++++- source/main.c | 4 +++- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index ca33f3b..77522f7 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ SOURCES := source INCLUDES := source # Bei jedem Release erhöhen - das Auto-Update vergleicht diese Nummer -VERSION := 3.1.4 +VERSION := 3.1.5 APP_TITLE := MBMNET APP_DESCRIPTION := Dein eigenes 3DS-Netzwerk diff --git a/source/admin.c b/source/admin.c index 58c8dc7..07b567b 100644 --- a/source/admin.c +++ b/source/admin.c @@ -15,9 +15,10 @@ static volatile bool isAdmin; static char server[64]; -static char why[96] = "Werkzeuge: kein MBMNET-Konto angemeldet."; // warum (noch) keine Werkzeuge +static char why[160] = "Werkzeuge: kein MBMNET-Konto angemeldet."; // warum (noch) keine Werkzeuge static Result lastAct; // letzter Fehler von act (für die Wiederholung) static bool wanted; // MBMNET-Konto angemeldet: prüfen +static u8 mbmnetSlot; // Konto-Platz des MBMNET-Kontos (act) // Liest die Tokens des angemeldeten Kontos aus dem Konto-Dienst (lokal, ohne Server-Anfrage von act) und lässt // sie vom MBMNET-Server prüfen. Die Tokens hat dieser Server beim Anmelden ausgestellt, er kann sie selbst prüfen. @@ -52,9 +53,20 @@ static Result login(u8 slot) static void check_once(void) { lastAct = 0; - u8 slot = 0; - ACT_GetCommonInfo(&slot, sizeof(slot), INFO_TYPE_COMMON_CURRENT_ACCOUNT_SLOT); - if (!slot) ACT_GetCommonInfo(&slot, sizeof(slot), INFO_TYPE_COMMON_DEFAULT_ACCOUNT_SLOT); + u8 current = 0, slot = mbmnetSlot; + ACT_GetCommonInfo(¤t, sizeof(current), INFO_TYPE_COMMON_CURRENT_ACCOUNT_SLOT); + if (!slot) slot = current; + // act steht auf einem anderen Platz (z. B. Pretendo nach einem Soft-Reboot): auf den MBMNET-Platz stellen + Result rs = 0; + if (slot && current != slot) { + snprintf(why, sizeof(why), "Werkzeuge: stelle Konto-Dienst auf Platz %u (war %u) ...", slot, current); + ACTA_UnloadConsoleAccount(); + rs = ACTA_SetDefaultAccount(slot); + if (R_SUCCEEDED(rs)) ACT_Save(); + } + AccountId idHere = { 0 }, idCur = { 0 }; + ACT_GetAccountInfo(idHere, sizeof(idHere), slot, INFO_TYPE_ACCOUNT_ID); + if (current && current != slot) ACT_GetAccountInfo(idCur, sizeof(idCur), current, INFO_TYPE_ACCOUNT_ID); static AccountAccessToken at; // 1. direkt lesen; 2. sonst Konto laden (falls nach dem Umschalten nicht geladen); 3. sonst einloggen // Fortschritt in "why": SELECT zeigt, bei welchem Schritt es gerade ist (oder hängt) @@ -69,8 +81,8 @@ static void check_once(void) } if (!at.accessToken[0] && !at.refreshToken[0]) { lastAct = R_FAILED(r4) ? r4 : r1; - snprintf(why, sizeof(why), "Werkzeuge: Konto nicht eingeloggt.\nPlatz %u L %08lX A %08lX T %08lX/%08lX", - slot, (unsigned long)r2, (unsigned long)r3, (unsigned long)r1, (unsigned long)r4); + snprintf(why, sizeof(why), "Werkzeuge: Konto \"%s\" (Platz %u%s%s) nicht eingeloggt.\nL %08lX A %08lX T %08lX/%08lX", + idHere, slot, idCur[0] ? ", act war auf " : "", idCur, (unsigned long)r2, (unsigned long)r3, (unsigned long)r1, (unsigned long)r4); return; } static char tokens[0x50]; @@ -98,8 +110,9 @@ void admin_progress(const char *step) { if (wanted && !isAdmin && !checked) snpr void admin_skipped(void) { if (wanted && !isAdmin) snprintf(why, sizeof(why), "Werkzeuge: Prüfung ausgefallen (umgeschaltet). App neu öffnen."); } -void admin_prepare(const char *srv, bool mbmnetLoggedIn) +void admin_prepare(const char *srv, bool mbmnetLoggedIn, u8 slot) { + mbmnetSlot = slot; isAdmin = false; wanted = mbmnetLoggedIn; snprintf(why, sizeof(why), mbmnetLoggedIn ? "Werkzeuge: Server prüft noch ..." diff --git a/source/admin.h b/source/admin.h index 2ea7b0f..77dd000 100644 --- a/source/admin.h +++ b/source/admin.h @@ -4,7 +4,7 @@ // Prüft, ob das angemeldete MBMNET-Konto Admin ist (signierter Anmelde-Nachweis, per HTTPS vom Server bestätigt, // siehe admin.c). admin_prepare beim Start; mbmnetLoggedIn = false: keine Werkzeuge. -void admin_prepare(const char *server, bool mbmnetLoggedIn); +void admin_prepare(const char *server, bool mbmnetLoggedIn, u8 mbmnetSlot); // Die eigentliche Prüfung (blockiert, im Hintergrund-Thread aufrufen, nicht gleichzeitig mit anderen act-Anfragen) void admin_check(void); // Prüfung fiel aus (es wurde umgeschaltet) diff --git a/source/frdswitch.c b/source/frdswitch.c index e2fba8e..d30113d 100644 --- a/source/frdswitch.c +++ b/source/frdswitch.c @@ -139,7 +139,11 @@ static Result use_act_slot(u8 friendAccount, u32 *slotOut, bool *created) } if (logf) fprintf(logf, " -> Konto-Platz %lu\n", (unsigned long)slot); *slotOut = slot; - return step("Standard-Konto setzen", ACTA_SetDefaultAccount(slot)); + rc = step("Standard-Konto setzen", ACTA_SetDefaultAccount(slot)); + // Ausdrücklich speichern: Beim Soft-Reboot (seit v2.9.8) ging die Einstellung sonst verloren, dann stand + // act nach dem Neustart noch auf dem alten Platz (z. B. Pretendo) und meldete sich damit bei MBMNET an. + if (R_SUCCEEDED(rc)) note("Konto-Einstellungen speichern", ACT_Save()); + return rc; } bool frdswitch_to(u8 target, bool *created, char *msg, size_t msglen) diff --git a/source/main.c b/source/main.c index e47b509..9c6f206 100644 --- a/source/main.c +++ b/source/main.c @@ -653,7 +653,9 @@ int main(int argc, char **argv) // Das geht nur, solange das MBMNET-Konto angemeldet ist (MBMNET aktiv, ID verknüpft). { char mid[20]; - admin_prepare(server, st == STATE_MBMNET && frdswitch_current() == FRIEND_ACCOUNT_MBMNET && nnid_linked(mid, sizeof(mid))); + u8 mslot = frdswitch_slot_of(FRIEND_ACCOUNT_MBMNET); + admin_prepare(server, st == STATE_MBMNET && frdswitch_current() == FRIEND_ACCOUNT_MBMNET && mslot + && frdswitch_slot_linked(FRIEND_ACCOUNT_MBMNET, mid, sizeof(mid)), mslot); } // Ein SpotPass-Test von früher (App mitten im Test verlassen) darf nicht weiterlaufen spotpass_test_cancel();