mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 21:39:58 -04:00
Keep co-op's private settings out of the log and out of bug reports.
This line logs every setting nx2navi.ini sets, and a bug report takes a copy of nx2navi.ini along: with co-op both would have carried a room's secret, the relay's address and the player's name to whoever reads the report, and the secret lets anyone into the room. One list (runtime/cfg_private.h: the room's secret, the offer number, the relay, the name, the key a maker removes, the menu's test hook) now serves the log's line, "Copy system info" and the report's copy of the file, in the game and in the launcher: such a key reads "(set, not shown)", every other byte of the file stays. Also: the last leftovers of the restorations that were left out with the puppets (their settings prefix and section), main.c's byte order mark as it was, and two comments that cited files this tree does not have. Checked: with a room, a relay and a name in nx2navi.ini the log's line shows all three as set and none of their values; the same text gives the same bytes through the game's scrub and the launcher's (a launcher test, and the C function built alone); the launcher tests, the co-op probe, the relay tests and the tab check pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "cfg_private.h"
|
||||
#include "coop_app.h"
|
||||
#include "discord_app.h"
|
||||
#include "host.h"
|
||||
@@ -315,8 +316,7 @@ static const CfgMeta metas[] = {
|
||||
static int is_known(const char *key) {
|
||||
for (size_t i = 0; i < sizeof known / sizeof *known; i++)
|
||||
if (!strcmp(known[i], key)) return 1;
|
||||
return !strncmp(key, "CHEAT_", 6) // cheats.c and the cheat patch sets (tools/cheats.py)
|
||||
|| !strncmp(key, "RESTORE_", 8); // restore.c: one key per restoration
|
||||
return !strncmp(key, "CHEAT_", 6); // cheats.c and the cheat patch sets (tools/cheats.py)
|
||||
}
|
||||
|
||||
// The keys of the file's lines that are not settings of this version (add), lower-case, ", " between them, each once;
|
||||
@@ -817,7 +817,6 @@ static const char *section_of(const char *key) {
|
||||
for (size_t i = 0; i < sizeof sections / sizeof *sections; i++)
|
||||
if (!strcmp(sections[i].key, key)) return sections[i].section;
|
||||
if (!strncmp(key, "CHEAT_", 6)) return "cheats"; // cheats.c: one key per cheat of the cheat file
|
||||
if (!strncmp(key, "RESTORE_", 8)) return "restorations"; // restore.c: one key per restoration
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1004,13 +1003,15 @@ static void log_file_settings(void) {
|
||||
char key[64];
|
||||
snprintf(key, sizeof key, "%s", entries[i].key);
|
||||
for (char *p = key; *p; p++) *p = (char)tolower((unsigned char)*p);
|
||||
size_t vl = strlen(entries[i].value);
|
||||
// a co-op room's secret, the relay, the player's name: only that they are set (cfg_private.h)
|
||||
const char *value = cfg_private_key(entries[i].key) && entries[i].value[0] ? CFG_PRIVATE_SHOWN : entries[i].value;
|
||||
size_t vl = strlen(value);
|
||||
if (vl > 200) vl = 200; // a long value (a list of mods) is cut: the line shows that the key is set
|
||||
if (k && k + strlen(key) + vl + 5 > 900) {
|
||||
rt_log("cfg: nx2navi.ini sets: %s", line);
|
||||
k = 0;
|
||||
}
|
||||
k += (size_t)snprintf(line + k, sizeof line - k, "%s%s = %.*s", k ? ", " : "", key, (int)vl, entries[i].value);
|
||||
k += (size_t)snprintf(line + k, sizeof line - k, "%s%s = %.*s", k ? ", " : "", key, (int)vl, value);
|
||||
}
|
||||
if (k) rt_log("cfg: nx2navi.ini sets: %s", line);
|
||||
if (n_unknown)
|
||||
|
||||
Reference in New Issue
Block a user