v3.0.1: SpotPass-Test-Aufgabe aufräumen (Start/Ende, 24-h-Abstand), Werkzeuge nur für vom Server bestätigte Admins (MBMNET-Platz, Antwort an die PID gebunden)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f5fc0861c7
commit
29f2c556c2
+15
-6
@@ -1,6 +1,6 @@
|
||||
// Entwickler-Werkzeuge nur für Admins: Die App fragt bei MBMNET, ob die verknüpfte NNID einem Admin
|
||||
// gehört (GET /mbmnet/app-info?pid=...). Die Antwort wird auf der SD gemerkt, damit die Werkzeuge
|
||||
// auch im Nintendo-Modus und ohne Verbindung da sind.
|
||||
// Entwickler-Werkzeuge nur für Admins: Die App fragt bei MBMNET, ob die im MBMNET-Platz verknüpfte ID einem
|
||||
// Admin gehört (GET /mbmnet/app-info?pid=...). Ohne verknüpfte MBMNET-ID gibt es keine Werkzeuge.
|
||||
// Die Antwort wird mit der Kennung (PID) auf der SD gemerkt: Ohne Verbindung gilt sie nur für dasselbe Konto.
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -12,11 +12,12 @@
|
||||
static volatile bool isAdmin;
|
||||
static Thread thread;
|
||||
static char url[128];
|
||||
static u32 currentPid;
|
||||
|
||||
static void remember(bool on)
|
||||
{
|
||||
FILE *f = fopen(CACHE_FILE, "w");
|
||||
if (f) { fputs(on ? "1" : "0", f); fclose(f); }
|
||||
if (f) { fprintf(f, "%lu %d\n", (unsigned long)currentPid, on ? 1 : 0); fclose(f); }
|
||||
}
|
||||
|
||||
static void worker(void *arg)
|
||||
@@ -38,9 +39,17 @@ static void worker(void *arg)
|
||||
|
||||
void admin_start(const char *server, u32 pid)
|
||||
{
|
||||
currentPid = pid;
|
||||
isAdmin = false;
|
||||
if (!pid) { remove(CACHE_FILE); return; } // keine MBMNET-ID verknüpft: keine Werkzeuge
|
||||
// Gemerkte Antwort nur, wenn sie zu genau diesem Konto gehört (alte Dateien ohne PID zählen nicht)
|
||||
FILE *f = fopen(CACHE_FILE, "r");
|
||||
if (f) { isAdmin = fgetc(f) == '1'; fclose(f); }
|
||||
if (!pid) return;
|
||||
if (f) {
|
||||
unsigned long cachedPid = 0;
|
||||
int on = 0;
|
||||
if (fscanf(f, "%lu %d", &cachedPid, &on) == 2 && cachedPid == pid) isAdmin = on == 1;
|
||||
fclose(f);
|
||||
}
|
||||
snprintf(url, sizeof(url), "http://%s/mbmnet/app-info?pid=%lu", server, (unsigned long)pid);
|
||||
s32 prio = 0x30;
|
||||
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
|
||||
|
||||
Reference in New Issue
Block a user