mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 03:39:57 -04:00
Log RivaTuner Statistics Server's own settings for the game while it lists the game.
rtss_limit.c writes and reads back only FramerateLimit and FramerateLimitDenominator, but RTSS's [Framerate] section holds more that limits or paces the frames: a frame time limit (LimitTime over LimitTimeDenominator), scanline sync (SyncScanline0/1), display sync, its own Reflex sleep and passive waiting. A player with any of them set in Global gets an RTSS that holds the game to more than the game's limit, and no log said so. While RTSS lists the game, the worker's reader (read_settings, the system's ini reader on Profiles\<exe>.cfg, else Profiles\Global, read again only when either file's write time changes) now also takes SyncDisplay, ReflexSleep and PassiveWait, and watch logs "RivaTuner Statistics Server's settings for the game (<file>): limit L/D, frame time limit T/TD, scanline sync S0/S1, display sync X, Reflex sleep R, passive wait P" once per change, 40 lines at most. It reads only, makes no call into RTSS's hooks library and changes nothing RTSS or the game does; whether the game should keep RTSS out when one of these is set is left for approval. Not reproduced before the change: it needs RTSS's settings in a play-test. tests/rtss_limit_check.c checks the text with and without the modes and that a short buffer cuts it; tests/rtss_worker_check.c gains settings_logged (nothing read while the game is not listed, then one line for the game's profile with what it took from Global, and one more after the limit changes). Both pass, with a compile of every runtime file; -Wall adds no warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ static int fails;
|
||||
|
||||
// RTSS's own settings: which of them hold the game's frames, and the log's text of them.
|
||||
static void settings(void) {
|
||||
RtssSettings none = {0, 1, 0, 0, 0, 0};
|
||||
RtssSettings none = {0, 1, 0, 0, 0, 0, 1, 1, 1};
|
||||
CHECK(!rtss_settings_limit(&none), "no limit, no frame time limit, no scanline sync: RTSS holds nothing");
|
||||
RtssSettings s = none;
|
||||
s.limit = 50;
|
||||
@@ -23,13 +23,20 @@ static void settings(void) {
|
||||
CHECK(rtss_settings_limit(&s), "the second scanline sync holds the frames");
|
||||
s = none, s.limit_den = 1000, s.time_den = 7;
|
||||
CHECK(!rtss_settings_limit(&s), "denominators alone hold nothing");
|
||||
char text[128];
|
||||
s = (RtssSettings){59940, 1000, 16667, 1, -40, 0};
|
||||
rtss_settings_text(text, sizeof text, &s);
|
||||
CHECK(!rtss_settings_limit(&none), "display sync, Reflex sleep and passive wait alone hold nothing");
|
||||
char text[192];
|
||||
s = (RtssSettings){59940, 1000, 16667, 1, -40, 0, 1, 2, 0};
|
||||
rtss_settings_text(text, sizeof text, &s, 0);
|
||||
CHECK(!strcmp(text, "limit 59940/1000, frame time limit 16667/1, scanline sync -40/0"), "text: %s", text);
|
||||
char small[16];
|
||||
rtss_settings_text(small, sizeof small, &s);
|
||||
rtss_settings_text(text, sizeof text, &s, 1);
|
||||
CHECK(!strcmp(text, "limit 59940/1000, frame time limit 16667/1, scanline sync -40/0, display sync 1, Reflex sleep 2, "
|
||||
"passive wait 0"),
|
||||
"text with the modes: %s", text);
|
||||
char small[16], mid[70];
|
||||
rtss_settings_text(small, sizeof small, &s, 1);
|
||||
CHECK(strlen(small) == sizeof small - 1, "a short buffer is cut, not overrun");
|
||||
rtss_settings_text(mid, sizeof mid, &s, 1);
|
||||
CHECK(strlen(mid) == sizeof mid - 1 && !strncmp(mid, text, sizeof mid - 1), "the modes cut at the buffer's end");
|
||||
}
|
||||
|
||||
// The kept-out reasons, for the log.
|
||||
|
||||
@@ -52,10 +52,10 @@ static int fails;
|
||||
typedef struct {
|
||||
int exists;
|
||||
DWORD limit, denom; // FramerateLimit and FramerateLimitDenominator: Limit and LimitDenominator in the file
|
||||
int time, time_den, scan0, scan1;
|
||||
int time, time_den, scan0, scan1, sync_display, reflex, passive;
|
||||
DWORD stamp;
|
||||
} Prof;
|
||||
static Prof global = {1, 0, 1, 0, 0, 0, 0, 1}, own, loaded;
|
||||
static Prof global = {1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1}, own, loaded;
|
||||
static int no_denominator; // an RTSS that does not know FramerateLimitDenominator
|
||||
static int readonly; // SaveProfile does not reach the file (no administrator rights)
|
||||
static volatile LONG saves, deletes, updates, loads, created, removed;
|
||||
@@ -190,6 +190,9 @@ DWORD stub_GetPrivateProfileStringA(LPCSTR sec, LPCSTR key, LPCSTR def, LPSTR ou
|
||||
else if (!strcmp(key, "LimitTimeDenominator")) v = f->time_den;
|
||||
else if (!strcmp(key, "SyncScanline0")) v = f->scan0;
|
||||
else if (!strcmp(key, "SyncScanline1")) v = f->scan1;
|
||||
else if (!strcmp(key, "SyncDisplay")) v = f->sync_display;
|
||||
else if (!strcmp(key, "ReflexSleep")) v = f->reflex;
|
||||
else if (!strcmp(key, "PassiveWait")) v = f->passive;
|
||||
else have = 0;
|
||||
}
|
||||
if (have) return (DWORD)snprintf(out, n, "%ld", v);
|
||||
@@ -307,7 +310,7 @@ static void restore_race(void) {
|
||||
|
||||
// The same with the player's own profile: it keeps the player's limit.
|
||||
static void restore_player(void) {
|
||||
own = (Prof){1, 30, 1, 0, 0, 0, 0, 1};
|
||||
own = (Prof){1, 30, 1, 0, 0, 0, 0, 0, 0, 0, 1};
|
||||
app_set(1, 0xA, 1000, 2000, 60);
|
||||
ask(60000);
|
||||
poll();
|
||||
@@ -383,7 +386,7 @@ static void kept_two(void) {
|
||||
// Low latency keeps RTSS out from the first present, with scanline sync set in the game's own profile (a negative line
|
||||
// counts from the bottom); once low latency is off, a limit starts RTSS's part as usual.
|
||||
static void kept_lowlat_then_limit(void) {
|
||||
own = (Prof){1, 0, 1, 0, 0, -40, 0, 1};
|
||||
own = (Prof){1, 0, 1, 0, 0, -40, 0, 0, 0, 0, 1};
|
||||
app_set(0, 0xA, 1000, 2000, 60);
|
||||
ask(RTSS_OUT_LOWLAT);
|
||||
poll();
|
||||
@@ -494,6 +497,33 @@ static void not_installed(void) {
|
||||
CHECK(!loads && !saves && !own.exists, "nothing loaded or written");
|
||||
}
|
||||
|
||||
// While RTSS lists the game, its settings for the game are logged once per change: Global's before the game has a
|
||||
// profile of its own, then the game's own with the limit it wrote, frame time limit, scanline sync and the modes.
|
||||
static int count(const char *text) {
|
||||
int n = 0;
|
||||
for (const char *p = logged_lines; (p = strstr(p, text)); p++) n++;
|
||||
return n;
|
||||
}
|
||||
static void settings_logged(void) {
|
||||
global.time = 16667, global.time_den = 1, global.sync_display = 1, global.reflex = 1, global.passive = 1;
|
||||
app_set(0, 0xA, 1000, 2000, 60);
|
||||
ask(60000);
|
||||
poll();
|
||||
CHECK(!count("settings for the game"), "not listed: nothing read");
|
||||
app_set(1, 0xA, 1000, 2000, 60);
|
||||
poll();
|
||||
poll();
|
||||
CHECK(logged("frame rate: RivaTuner Statistics Server's settings for the game (Profiles\\ocarina.exe.cfg): limit "
|
||||
"60/1, frame time limit 16667/1, scanline sync 0/0, display sync 1, Reflex sleep 1, passive wait 1\n"),
|
||||
"the game's profile, with what it took from Global");
|
||||
CHECK(count("settings for the game") == 1, "logged once while nothing changes (%d)", count("settings for the game"));
|
||||
ask(144000);
|
||||
poll();
|
||||
poll();
|
||||
CHECK(logged("(Profiles\\ocarina.exe.cfg): limit 144/1, frame time limit 16667/1"), "logged again on a change");
|
||||
CHECK(count("settings for the game") == 2, "once per change (%d)", count("settings for the game"));
|
||||
}
|
||||
|
||||
static const struct { const char *name; void (*run)(void); } scenarios[] = {
|
||||
{"restore_race", restore_race},
|
||||
{"restore_player", restore_player},
|
||||
@@ -508,6 +538,7 @@ static const struct { const char *name; void (*run)(void); } scenarios[] = {
|
||||
{"round_logged_whole", round_logged_whole},
|
||||
{"start_off_present", start_off_present},
|
||||
{"not_installed", not_installed},
|
||||
{"settings_logged", settings_logged},
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
Reference in New Issue
Block a user