Greater Rift: confirm before the next-level door (#25), robust return to a finished run, top bar capped at level 100 (#29), monster life clamp; Mac: close X on the rift page
The top-bar fix (#29) was reported and diagnosed by Joe Hu, who also sent a fix along the same lines (#30). Co-authored-by: Joe Hu <12777592+hubeiqiao@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,8 @@ run: \
|
||||
$(B)/t_oe \
|
||||
$(B)/t_padmap \
|
||||
$(B)/t_rift_clock \
|
||||
$(B)/t_rift_next \
|
||||
$(B)/t_rift_oldrun \
|
||||
$(B)/t_romfs_validate \
|
||||
$(B)/t_rwlv \
|
||||
$(B)/t_swkbd \
|
||||
@@ -44,6 +46,8 @@ run: \
|
||||
python3 ../../i18n/scan_literals.py
|
||||
$(B)/t_thread_leak
|
||||
$(B)/t_rift_clock
|
||||
$(B)/t_rift_next
|
||||
$(B)/t_rift_oldrun
|
||||
$(B)/t_textbox
|
||||
$(B)/t_rwlv
|
||||
$(B)/t_touch
|
||||
@@ -142,5 +146,9 @@ $(B)/t_target_rank: t_target_rank.c ../hle_target.c ../dm.h | $(B)
|
||||
clang -O1 -Wno-unused-function -I.. -o $@ t_target_rank.c ../hle_target.c
|
||||
$(B)/t_rift_clock: t_rift_clock.c ../dm_rift.c ../dm_rift.h ../hle_os.c ../hle.h ../dm.h | $(B)
|
||||
clang -O1 -Wall -Wno-unused-function -ffunction-sections -fdata-sections -Wl,-dead_strip -I.. -o $@ t_rift_clock.c ../hle_os.c
|
||||
$(B)/t_rift_next: t_rift_next.c ../dm_rift.c ../dm_rift.h ../hle_os.c ../hle.h ../dm.h | $(B)
|
||||
clang -O1 -Wall -Wno-unused-function -ffunction-sections -fdata-sections -Wl,-dead_strip -I.. -o $@ t_rift_next.c ../hle_os.c
|
||||
$(B)/t_rift_oldrun: t_rift_oldrun.c ../dm_rift.c ../dm_rift.h ../hle_os.c ../hle.h ../dm.h | $(B)
|
||||
clang -O1 -Wall -Wno-unused-function -ffunction-sections -fdata-sections -Wl,-dead_strip -I.. -o $@ t_rift_oldrun.c ../hle_os.c
|
||||
$(B)/t_thread_leak: t_thread_leak.c ../thread.c ../dm.h | $(B)
|
||||
clang -O1 -Wall -Wno-unused-function -I.. -I../../ios/Sources -o $@ t_thread_leak.c
|
||||
|
||||
@@ -41,7 +41,7 @@ else:
|
||||
|
||||
# ---- 2 ----
|
||||
PADMODE = {'host/dm_cursor.c': 9, 'host/dm_custom.c': 2, 'host/dm_kills.c': 2, 'host/dm_rift_ui.c': 4, 'host/dm_runeword.c': 3, 'host/dm_vault_ui.c': 1, 'host/dm_update.c': 2, 'host/hle_tact.c': 1}
|
||||
AUTOKEY = {'host/dm_cursor.c': 38, 'host/dm_rift_ui.c': 6, 'host/hle_hid.c': 2, 'ios/Sources/front_ios.m': 4}
|
||||
AUTOKEY = {'host/dm_cursor.c': 38, 'host/dm_rift_ui.c': 8, 'host/hle_hid.c': 2, 'ios/Sources/front_ios.m': 4}
|
||||
def count(pat, skip_defs):
|
||||
out = {}
|
||||
for f in sorted(glob.glob(os.path.join(root, 'host', '*.c')) + glob.glob(os.path.join(root, 'ios', 'Sources', '*.m')) + glob.glob(os.path.join(root, 'ios', 'Sources', '*.c'))):
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// 秘境「下一层」层号的单测(公开仓库 第 100 层限时通关后顶部条写「下次第 103 层」):直接包含真的 dm_rift.c,不调任何原版地址。
|
||||
// 要证明的事:算下一层只有宿主一处、封顶 100;顶部进度条拿到的 next 就是这个数(显示方不再自己用 tier + inc 算)。
|
||||
// 期望值手写:下一层 = min(层 + 晋级量, 100),晋级量 0(超时)时等于本层。逐格列出,不用被测公式生成。
|
||||
// 不覆盖:屏上那行字选哪一句(在 iOS 壳 dm_rift_hud.m 里:next > tier → 「下次第 N 层」;晋级了但 next = tier → 「已通关最高层」;没晋级 → 「下次仍是这一层」)。
|
||||
// Unit test for the rift "next level" number (after a timed clear of level 100 the top bar wrote "next: level 103"): includes the real dm_rift.c directly and calls no original address.
|
||||
// What is to be proved: the next level is computed in one place in the host and capped at 100; the next the top progress bar receives is that number (the display no longer computes tier + inc itself).
|
||||
// Expected values are written by hand: next level = min(level + increase, 100), equal to this level when the increase is 0 (overtime). Listed cell by cell, not generated with the formula under test.
|
||||
// Not covered: which sentence the line on screen picks (in the iOS shell's dm_rift_hud.m: next > tier -> "next: level N"; advanced but next = tier -> "highest level cleared"; not advanced -> "next: this level again").
|
||||
#include "../dm_rift.c"
|
||||
|
||||
void (*g_dm_pre_commit_hook[4])(const char *);
|
||||
uint64_t dm_fs_commit_count(void) { return 0; }
|
||||
|
||||
int main(void) {
|
||||
static const struct { int tier, inc, want; } c[] = {
|
||||
{ 1, 0, 1 }, { 1, 1, 2 }, { 1, 2, 3 }, { 1, 3, 4 },
|
||||
{ 96, 3, 99 }, { 97, 0, 97 }, { 97, 1, 98 }, { 97, 2, 99 }, { 97, 3, 100 },
|
||||
{ 98, 0, 98 }, { 98, 1, 99 }, { 98, 2, 100 }, { 98, 3, 100 },
|
||||
{ 99, 0, 99 }, { 99, 1, 100 }, { 99, 2, 100 }, { 99, 3, 100 },
|
||||
{ 100, 0, 100 }, { 100, 1, 100 }, { 100, 2, 100 }, { 100, 3, 100 },
|
||||
};
|
||||
int fails = 0, n = (int)(sizeof c / sizeof *c);
|
||||
atomic_store(&K.st, ST_DONE);
|
||||
for (int i = 0; i < n; i++) {
|
||||
K.tier = c[i].tier; K.inc = c[i].inc; dm_rift_hud_t h = {0}; int ok = dm_rift_hud(&h);
|
||||
if (!ok || next_tier() != c[i].want || h.next != c[i].want || h.next > 100 || h.tier != c[i].tier || h.inc != c[i].inc) {
|
||||
fails++; printf(" ✗ 第 %d 层 晋级 %d:下一层应为 %d,宿主 %d、顶部条 %d(取到 %d)\n", c[i].tier, c[i].inc, c[i].want, next_tier(), h.next, ok); }
|
||||
}
|
||||
// 生命基础项的可写上限(hp_base_limit):写到这个数时,合计 = 基础 × (合计 ÷ 基础) 不能过属性上限 0x7fffff00 = 2147483392。期望值手算:
|
||||
// 没加成(合计 = 基础)→ 2147483392;+77%(1000 / 1770)→ 2147483392 × 1000 ÷ 1770 = 1213267453;+100%(256 / 512)→ 1073741696;
|
||||
// 随从实例(基础 27000 点 = 6912000,合计 47790 点 = 12234240)→ 1213267453;减益(合计小于基础)与读不到基础项(0)→ 2147483392
|
||||
// The writable limit of the life base entry (hp_base_limit): when written to this number, the total = base x (total / base) must not exceed the stat limit 0x7fffff00 = 2147483392. Expected values worked out by hand:
|
||||
// no bonus (total = base) -> 2147483392; +77% (1000 / 1770) -> 2147483392 x 1000 / 1770 = 1213267453; +100% (256 / 512) -> 1073741696;
|
||||
// a minion instance (base 27000 points = 6912000, total 47790 points = 12234240) -> 1213267453; a debuff (total smaller than base) and an unreadable base entry (0) -> 2147483392
|
||||
static const struct { int base, full; long long want; } hc[] = {
|
||||
{ 2147483392, 2147483392, 2147483392LL }, { 1000, 1770, 1213267453LL }, { 256, 512, 1073741696LL },
|
||||
{ 6912000, 12234240, 1213267453LL }, { 100, 90, 2147483392LL }, { 0, 500, 2147483392LL },
|
||||
};
|
||||
int hn = (int)(sizeof hc / sizeof *hc);
|
||||
for (int i = 0; i < hn; i++) { long long got = hp_base_limit(hc[i].base, hc[i].full), tot = hc[i].base > 0 ? got * hc[i].full / hc[i].base : got;
|
||||
if (got != hc[i].want || (hc[i].full > hc[i].base && hc[i].base > 0 && tot > 2147483392LL)) { fails++; printf(" ✗ 基础 %d 合计 %d:可写上限应为 %lld,得 %lld(写满后合计 %lld)\n", hc[i].base, hc[i].full, hc[i].want, got, tot); } }
|
||||
printf("hp_base_limit %s:%d 格,带百分比加成时写满基础项合计不过属性上限\n", fails ? "失败" : "OK", hn);
|
||||
printf("t_rift_next %s:%d 格(层 × 晋级量)下一层 = 手写期望且 ≤ 100,宿主与顶部条同值\n", fails ? "失败" : "OK", n);
|
||||
return fails != 0;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// 秘境「有没有可回去的场」与新局重置的单测(公开仓库 里与玩法无关的两处):直接包含真的 dm_rift.c,不调任何原版地址。
|
||||
// 要证明的事:
|
||||
// 1. 城里入口给哪一页只看「状态 + 旧场位置」,不看守护者处那扇门的单位号:打完了、位置记着、门没开出来(单位号 0)→ 仍给「继续 / 放弃」页(原先给选层页,回不去捡东西);
|
||||
// 打完了但位置没记(结算时读不到玩家位置)→ 选层页,哪怕门的单位号非 0。
|
||||
// 2. 新局重置把上一局留下的 开始 / 继续 / 放弃 请求和待开的页都清掉。
|
||||
// 期望值按规则手写。不覆盖:真局里「继续」落回旧场位置、开新场 / 放弃时清位置(那两处在 start_rift / dm_rift_tick 里,要真局)。
|
||||
// Unit test for the rift's "is there a run to go back to" and the new-game reset: includes the real dm_rift.c directly and calls no original address.
|
||||
// What is to be proved:
|
||||
// 1. Which page the town entrance gives depends only on "state + the old run's position", not on the unit id of the door at the Guardian: finished, position recorded, door not placed (unit id 0) -> still the "Continue / Abandon" page (it used to give level selection, with no way back to pick things up);
|
||||
// finished but position not recorded (the player's position could not be read at completion) -> level selection, even if the door's unit id is non-zero.
|
||||
// 2. The new-game reset clears the start / continue / abandon requests and the pending page left by the previous game.
|
||||
// Expected values written by hand from the rules. Not covered: "Continue" landing back at the old run's position in a real game, and clearing the position when a new run starts / on abandon (those two are in start_rift / dm_rift_tick and need a real game).
|
||||
#include "../dm_rift.c"
|
||||
|
||||
void (*g_dm_pre_commit_hook[4])(const char *);
|
||||
uint64_t dm_fs_commit_count(void) { return 0; }
|
||||
|
||||
int main(void) {
|
||||
static const struct { int st, nd_lv; unsigned next_door; int want; const char *what; } c[] = {
|
||||
{ ST_IDLE, 0, 0, MENU_SELECT, "没在打" }, { ST_IDLE, 120, 5, MENU_SELECT, "没在打(位置与门号是残留)" },
|
||||
{ ST_RUN, 0, 0, MENU_CHOICE, "正在打" },
|
||||
{ ST_DONE, 120, 5, MENU_CHOICE, "打完,位置在,门在" }, { ST_DONE, 120, 0, MENU_CHOICE, "打完,位置在,门没开出来" },
|
||||
{ ST_DONE, 0, 5, MENU_SELECT, "打完,位置没记,门号非 0" }, { ST_DONE, 0, 0, MENU_SELECT, "打完,位置没记,门也没有" },
|
||||
};
|
||||
int fails = 0, n = (int)(sizeof c / sizeof *c);
|
||||
for (int i = 0; i < n; i++) { atomic_store(&K.st, c[i].st); L.nd_lv = c[i].nd_lv; L.next_door = c[i].next_door; dm_rift_menu_t m = {0}; dm_rift_menu_peek(&m);
|
||||
if (town_menu(c[i].st) != c[i].want || m.menu != c[i].want) { fails++; printf(" ✗ %s:应给页 %d,town_menu %d、peek %d\n", c[i].what, c[i].want, town_menu(c[i].st), m.menu); } }
|
||||
atomic_store(&M.req_start, 7); atomic_store(&M.req_cont, 1); atomic_store(&M.req_abandon, 1); atomic_store(&M.menu, MENU_CHOICE); menu_reset();
|
||||
if (atomic_load(&M.req_start) || atomic_load(&M.req_cont) || atomic_load(&M.req_abandon) || atomic_load(&M.menu) != MENU_NONE) { fails++; printf(" ✗ 新局重置后仍有残留:开始 %d 继续 %d 放弃 %d 页 %d\n", atomic_load(&M.req_start), atomic_load(&M.req_cont), atomic_load(&M.req_abandon), atomic_load(&M.menu)); }
|
||||
printf("t_rift_oldrun %s:%d 格城里入口给页 + 新局重置清请求\n", fails ? "失败" : "OK", n);
|
||||
return fails != 0;
|
||||
}
|
||||
Reference in New Issue
Block a user