mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 14:29:58 -04:00
Drop the closed input that rtss_decide.h had and the worker never set.
The review found RtssIn.closed and its RTSS_WHY_CLOSED rule unused in the game: rtss_limit.c worker builds a poll's view with the want alone, after it has skipped the poll under the lock once rtss_limit_restore ran, so the pure check's closed case pinned a rule the worker never reaches. The field, the rule and the reason go; rtss_decide's comment says that no poll decides after the exit and where that is done. The worker's skip stays as it was, and tests/rtss_worker_check.c's restore_* scenarios (restore_inflight among them) keep covering it. The pure check's closed_and_library becomes unset_and_library. No decision changes: rtss_limit_check passes 27 of 27, check_content passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -82,7 +82,6 @@ enum {
|
|||||||
RTSS_WHY_REFUSED, // RTSS refused this limit
|
RTSS_WHY_REFUSED, // RTSS refused this limit
|
||||||
RTSS_WHY_NEWER, // the want changed while the poll ran: nothing decided, the next poll takes the new one
|
RTSS_WHY_NEWER, // the want changed while the poll ran: nothing decided, the next poll takes the new one
|
||||||
RTSS_WHY_UNSET, // no want yet
|
RTSS_WHY_UNSET, // no want yet
|
||||||
RTSS_WHY_CLOSED, // the exit put the profile back (rtss_limit_restore)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// What the worker keeps between polls.
|
// What the worker keeps between polls.
|
||||||
@@ -99,7 +98,6 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t want; // the want the poll read
|
int64_t want; // the want the poll read
|
||||||
int current; // the want is still that one when the poll decides
|
int current; // the want is still that one when the poll decides
|
||||||
int closed; // rtss_limit_restore ran
|
|
||||||
int hooks; // RTSS's hooks library: 1 loaded, 0 failed to load, -1 not tried (rtss_wants_hooks)
|
int hooks; // RTSS's hooks library: 1 loaded, 0 failed to load, -1 not tried (rtss_wants_hooks)
|
||||||
RtssApp app;
|
RtssApp app;
|
||||||
} RtssIn;
|
} RtssIn;
|
||||||
@@ -118,15 +116,15 @@ static inline int rtss_wants_hooks(const RtssState *s, const RtssIn *in) {
|
|||||||
return in->want >= 0 && !s->fail && in->app.running;
|
return in->want >= 0 && !s->fail && in->app.running;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The decision of one poll, in this order: a closed run or no want does nothing; a kept-out want puts back what this
|
// The decision of one poll, in this order: no want does nothing; a kept-out want puts back what this run wrote (once
|
||||||
// run wrote (once the hooks are loaded); a failure lasts the run; RTSS not running leaves the profile for its return; a
|
// the hooks are loaded); a failure lasts the run; RTSS not running leaves the profile for its return; a library that
|
||||||
// library that did not load fails the run; a refused limit stays with the game; a new limit goes into the profile at
|
// did not load fails the run; a refused limit stays with the game; a new limit goes into the profile at once, and RTSS
|
||||||
// once, and RTSS holds it as soon as it lists the game. On an unchanged limit RTSS's own frame count is checked: more
|
// holds it as soon as it lists the game. On an unchanged limit RTSS's own frame count is checked: more than
|
||||||
// than RTSS_CHECK_SLACK times the limit for RTSS_CHECK_POLLS polls in a row puts the profile back for the run.
|
// RTSS_CHECK_SLACK times the limit for RTSS_CHECK_POLLS polls in a row puts the profile back for the run. After the
|
||||||
|
// exit put the profile back (rtss_limit_restore) no poll decides: rtss_limit.c worker skips it under the lock.
|
||||||
static inline RtssOut rtss_decide(RtssState *s, const RtssIn *in) {
|
static inline RtssOut rtss_decide(RtssState *s, const RtssIn *in) {
|
||||||
int64_t w = in->want;
|
int64_t w = in->want;
|
||||||
RtssOut o = {RTSS_DO_NOTHING, w, 0, RTSS_WHY_NOT_LISTED, 0};
|
RtssOut o = {RTSS_DO_NOTHING, w, 0, RTSS_WHY_NOT_LISTED, 0};
|
||||||
if (in->closed) return o.why = RTSS_WHY_CLOSED, o;
|
|
||||||
if (w == RTSS_UNSET) return o.why = RTSS_WHY_UNSET, o;
|
if (w == RTSS_UNSET) return o.why = RTSS_WHY_UNSET, o;
|
||||||
if (w < 0) {
|
if (w < 0) {
|
||||||
if (in->hooks == 1 && s->changed) o.act = RTSS_DO_PUT_BACK;
|
if (in->hooks == 1 && s->changed) o.act = RTSS_DO_PUT_BACK;
|
||||||
|
|||||||
@@ -160,15 +160,15 @@ static void run_init(Run *r) {
|
|||||||
r->running = r->listed = 1, r->t0 = 1000, r->t1 = 2000, r->frames = 60;
|
r->running = r->listed = 1, r->t0 = 1000, r->t1 = 2000, r->frames = 60;
|
||||||
}
|
}
|
||||||
// One poll for want, as rtss_limit.c worker makes it: the hooks library loads on the first poll that wants it and stays.
|
// One poll for want, as rtss_limit.c worker makes it: the hooks library loads on the first poll that wants it and stays.
|
||||||
static RtssOut step_ex(Run *r, int64_t want, int current, int closed) {
|
static RtssOut step_ex(Run *r, int64_t want, int current) {
|
||||||
RtssIn in = {.want = want, .current = current, .closed = closed};
|
RtssIn in = {.want = want, .current = current};
|
||||||
in.app = (RtssApp){r->running, r->running && r->listed, r->t0, r->t1, r->frames};
|
in.app = (RtssApp){r->running, r->running && r->listed, r->t0, r->t1, r->frames};
|
||||||
if (r->st.loaded) in.hooks = 1;
|
if (r->st.loaded) in.hooks = 1;
|
||||||
else if (rtss_wants_hooks(&r->s, &in)) in.hooks = r->st.no_library ? 0 : (r->st.loaded = 1);
|
else if (rtss_wants_hooks(&r->s, &in)) in.hooks = r->st.no_library ? 0 : (r->st.loaded = 1);
|
||||||
else in.hooks = -1;
|
else in.hooks = -1;
|
||||||
return rtss_poll(&r->s, &in, &r->ops);
|
return rtss_poll(&r->s, &in, &r->ops);
|
||||||
}
|
}
|
||||||
static RtssOut step(Run *r, int64_t want) { return step_ex(r, want, 1, 0); }
|
static RtssOut step(Run *r, int64_t want) { return step_ex(r, want, 1); }
|
||||||
|
|
||||||
// RTSS's injection delay: it runs but has not hooked the game for 30 polls. The limit goes into the profile at the
|
// RTSS's injection delay: it runs but has not hooked the game for 30 polls. The limit goes into the profile at the
|
||||||
// first poll, and RTSS holds the game once it lists it, with no second write.
|
// first poll, and RTSS holds the game once it lists it, with no second write.
|
||||||
@@ -289,7 +289,7 @@ static void frame_count(void) {
|
|||||||
r.frames = 144;
|
r.frames = 144;
|
||||||
step(&r, 60000);
|
step(&r, 60000);
|
||||||
step(&r, 60000);
|
step(&r, 60000);
|
||||||
o = step_ex(&r, 60000, 0, 0);
|
o = step_ex(&r, 60000, 0);
|
||||||
CHECK(o.why == RTSS_WHY_NEWER && !o.holds && o.act == RTSS_DO_NOTHING && r.s.over == 1, "a newer want: no count");
|
CHECK(o.why == RTSS_WHY_NEWER && !o.holds && o.act == RTSS_DO_NOTHING && r.s.over == 1, "a newer want: no count");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,17 +337,13 @@ static void movie(void) {
|
|||||||
CHECK(o.act == RTSS_DO_APPLY && o.holds && r.st.applies == 3, "144 written again at its end");
|
CHECK(o.act == RTSS_DO_APPLY && o.holds && r.st.applies == 3, "144 written again at its end");
|
||||||
}
|
}
|
||||||
|
|
||||||
// No want yet, and a closed run: nothing at all. The hooks library that does not load fails the run.
|
// No want yet: nothing at all. The hooks library that does not load fails the run. (A run whose exit put the profile
|
||||||
static void closed_and_library(void) {
|
// back makes no decision: rtss_limit.c worker skips the poll, which tests/rtss_worker_check.c's restore_* check.)
|
||||||
|
static void unset_and_library(void) {
|
||||||
Run r;
|
Run r;
|
||||||
run_init(&r);
|
run_init(&r);
|
||||||
RtssOut o = step(&r, RTSS_UNSET);
|
RtssOut o = step(&r, RTSS_UNSET);
|
||||||
CHECK(o.why == RTSS_WHY_UNSET && o.act == RTSS_DO_NOTHING && !r.st.loaded, "no want");
|
CHECK(o.why == RTSS_WHY_UNSET && o.act == RTSS_DO_NOTHING && !r.st.loaded, "no want");
|
||||||
step(&r, 60000);
|
|
||||||
o = step_ex(&r, 144000, 1, 1);
|
|
||||||
CHECK(o.why == RTSS_WHY_CLOSED && o.act == RTSS_DO_NOTHING && r.st.holds == 60000, "closed: nothing written");
|
|
||||||
o = step_ex(&r, RTSS_OUT_FRAMEGEN, 1, 1);
|
|
||||||
CHECK(o.act == RTSS_DO_NOTHING && !r.st.put_backs, "closed: nothing put back");
|
|
||||||
run_init(&r);
|
run_init(&r);
|
||||||
r.st.no_library = 1;
|
r.st.no_library = 1;
|
||||||
o = step(&r, 60000);
|
o = step(&r, 60000);
|
||||||
@@ -396,7 +392,7 @@ int main(void) {
|
|||||||
kept_out();
|
kept_out();
|
||||||
churn();
|
churn();
|
||||||
movie();
|
movie();
|
||||||
closed_and_library();
|
unset_and_library();
|
||||||
two();
|
two();
|
||||||
printf("rtss_limit_check: %s\n", fails ? "FAIL" : "ok");
|
printf("rtss_limit_check: %s\n", fails ? "FAIL" : "ok");
|
||||||
return fails != 0;
|
return fails != 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user