diff --git a/dm/PRODUCT b/dm/PRODUCT index 66c4f3c..e77f2f3 100644 --- a/dm/PRODUCT +++ b/dm/PRODUCT @@ -1 +1 @@ -3.3.94012-r43 +3.3.94012-r44 diff --git a/dm/host/Makefile b/dm/host/Makefile index dd2bb96..643e6e6 100644 --- a/dm/host/Makefile +++ b/dm/host/Makefile @@ -96,8 +96,8 @@ dm_bright_levels.inc: ../tools/gen_bright_levels.py ../ios/tools/touch_layout.py $(NEED_ROMFS) python3 ../tools/gen_bright_levels.py "$(ROMFS)" > $@.tmp && mv $@.tmp $@ dmhost: $(SRC) $(GFX) $(LIBDEFLATE) dm.h hle.h dm_input.h front.h touch_mac.h dm_cursor.h dm_i18n_tab.h ../ios/Sources/dm_touch_controls.[ch] $(GFX_H) $(GENH) - clang $(CFLAGS) -I. -I../gfx/nvn/include -fobjc-arc -o $@ $(SRC) $(GFX) $(LIBDEFLATE) -framework Cocoa -framework QuartzCore -framework Metal -framework AudioToolbox -framework ImageIO -framework UniformTypeIdentifiers -framework GameController + clang $(CFLAGS) -I. -I../gfx/nvn/include -fobjc-arc -o $@ $(SRC) $(GFX) $(LIBDEFLATE) -framework Cocoa -framework QuartzCore -framework Metal -framework AudioToolbox -framework ImageIO -framework UniformTypeIdentifiers -framework GameController -framework Network # 老接口版宿主(图形后端不用 Metal 4,目标 macOS 15.0):同一棵树、同一份源码,只多一个编译开关;不在缺省目标里,要用时 make dmhost_m3 # Older-API host (graphics backend without Metal 4, target macOS 15.0): the same tree and the same source, with just one more compile switch; not in the default targets, run make dmhost_m3 when needed dmhost_m3: $(SRC) $(GFX) $(LIBDEFLATE) dm.h hle.h dm_input.h front.h touch_mac.h dm_cursor.h dm_i18n_tab.h ../ios/Sources/dm_touch_controls.[ch] $(GFX_H) $(GENH) - clang $(CFLAGS_M3) -I. -I../gfx/nvn/include -fobjc-arc -o $@ $(SRC) $(GFX) $(LIBDEFLATE) -framework Cocoa -framework QuartzCore -framework Metal -framework AudioToolbox -framework ImageIO -framework UniformTypeIdentifiers -framework GameController + clang $(CFLAGS_M3) -I. -I../gfx/nvn/include -fobjc-arc -o $@ $(SRC) $(GFX) $(LIBDEFLATE) -framework Cocoa -framework QuartzCore -framework Metal -framework AudioToolbox -framework ImageIO -framework UniformTypeIdentifiers -framework GameController -framework Network diff --git a/dm/host/diag.c b/dm/host/diag.c index 82b04d7..edfdfd6 100644 --- a/dm/host/diag.c +++ b/dm/host/diag.c @@ -971,8 +971,10 @@ static void hud_tick(uint64_t G) { // 每拍:受控玩家等级 / 本 LOG("DM_TEST_GIVE:拍 %u 在玩家旁生成「%s」品质 %d:%d / %d 件成功(物品类号 %u,第一件单位 id %u)%s", tq, code, q, ok, n, cls, id0, !getenv("DM_TEST_GIVE_INV") ? "" : inv == ok ? ",已全部捡进背包" : ",【注意】有没捡进背包的(留在地上)"); } } } } if (main && player) dm_elysium_stash_step(G, player, (uint8_t *)main->base); // 新建极乐世界角色后补齐共享仓库(dm_elysium.c) | Fill in the shared stash after a new Elysium character is created (dm_elysium.c) { void dm_townwp_tick(uint64_t, uint64_t, uint8_t *); if (main && player) dm_townwp_tick(G, player, (uint8_t *)main->base); } // 进局落在城镇小站旁(dm_townwp.c) | Land next to the town waypoint on joining a run (dm_townwp.c) - { int dm_cloud_conflict_take(void); static int shown; // iCloud 同步拦下了共享仓库的覆盖(dm_cloudsync.c):进局后弹一次原版系统提示(每次启动一次) | iCloud sync blocked an overwrite of the shared stash (dm_cloudsync.c): show the original game's system prompt once after joining a run (once per launch) - if (main && player && !shown && dm_cloud_conflict_take()) { shown = 1; dm_game_notice((uint8_t *)main->base, dm_str((uint8_t *)main->base, "dmCloudConflict")); LOG("iCloud 同步:弹了共享仓库不一致的提示"); } } + { int dm_cloud_conflict_take(void); static int shown; // iCloud 共享仓库分叉、本机那份收进了待合并收件箱(dm_cloudsync.c):进局后弹一次原版系统提示(每次启动一次) | the iCloud shared stash forked and the local copy was put in the to-merge inbox (dm_cloudsync.c): one original system notice after entering a run (once per launch) + if (main && player && !shown && dm_cloud_conflict_take()) { shown = 1; dm_game_notice((uint8_t *)main->base, dm_str((uint8_t *)main->base, "dmCloudConflict")); LOG("iCloud 同步:弹了共享仓库收进收件箱的提示"); } } + { int dm_cloud_char_conflict_take(char *, size_t); char nm[256], msg[400]; // iCloud 首次同步遇到同名角色、用了云端那份(dm_cloudsync.c):进局后提示一次 | iCloud first sync met a character with the same name and used the cloud copy (dm_cloudsync.c): one notice after entering a run + if (main && player && dm_cloud_char_conflict_take(nm, sizeof nm)) { snprintf(msg, sizeof msg, dm_str((uint8_t *)main->base, "dmCloudCharConflict"), nm); dm_game_notice((uint8_t *)main->base, msg); LOG("iCloud 同步:弹了同名角色用云端那份的提示(%s)", nm); } } if (main && player) dm_bossrush_tick(G, player, (uint8_t *)main->base); // 首领连战(dm_bossrush.c) | Boss rush (dm_bossrush.c) if (main && player) { void dm_rift_tick(uint64_t, uint64_t, uint8_t *); dm_rift_tick(G, player, (uint8_t *)main->base); } // 秘境爬塔(dm_rift.c) | Rift tower climb (dm_rift.c) { void dm_pages_tick(uint64_t, uint64_t, uint8_t *); if (main) dm_pages_tick(G, player, (uint8_t *)main->base); } // 个人仓库 2–5 页(dm_pages.c);不在局内 player 为 0,模块自己清状态 | Personal stash pages 2–5 (dm_pages.c); player is 0 when not in a run, and the module clears its own state diff --git a/dm/host/dm.h b/dm/host/dm.h index 38ac7e8..db84aa2 100644 --- a/dm/host/dm.h +++ b/dm/host/dm.h @@ -54,7 +54,7 @@ module_t *module_of(const void *p); uint64_t gate_dispatch(uint64_t ret_addr, uint64_t *regs); // 观测门(改写器 OBS 表;编号与 patch_nso.py 一致):只读回调,挂上即在门命中时调用 // Observation gates (rewriter OBS table; numbering matches patch_nso.py): read-only callbacks, called on a gate hit once attached -enum { OBS_UIMSG = 1, OBS_TICK = 2, OBS_C2S = 3, OBS_C2S_SYS = 4, OBS_SETLANG = 5, OBS_TARGET_RANK = 7, OBS_UI_PROJECT = 8, OBS_FREEZE_WORLD = 10, OBS_FREEZE_CLIENT = 11, OBS_FREEZE_ANIM = 12, OBS_FREEZE_RENDER = 13, OBS_TEXTBOX = 14, OBS_EVENT_MSG = 15, OBS_LEVEL_WARP = 16, OBS_QUEST_KILL = 17, OBS_NOTICE_INPUT = 18, OBS_ERR_SMOOTH = 19, OBS_MODEL_YAW = 20, OBS_TOOLTIP = 21, OBS_MAX = 22 }; // 6 = iOS 绑定读取(dm_touch_game_bridge.c) | 6 = iOS binding read (dm_touch_game_bridge.c) +enum { OBS_UIMSG = 1, OBS_TICK = 2, OBS_C2S = 3, OBS_C2S_SYS = 4, OBS_SETLANG = 5, OBS_TARGET_RANK = 7, OBS_UI_PROJECT = 8, OBS_FREEZE_WORLD = 10, OBS_FREEZE_CLIENT = 11, OBS_FREEZE_ANIM = 12, OBS_FREEZE_RENDER = 13, OBS_TEXTBOX = 14, OBS_EVENT_MSG = 15, OBS_LEVEL_WARP = 16, OBS_QUEST_KILL = 17, OBS_NOTICE_INPUT = 18, OBS_ERR_SMOOTH = 19, OBS_MODEL_YAW = 20, OBS_TOOLTIP = 21, OBS_PRESET_SPAWN = 22, OBS_MAX = 23 }; // 6 = iOS 绑定读取(dm_touch_game_bridge.c) | 6 = iOS binding read (dm_touch_game_bridge.c) void gate_obs_set(int id, void (*fn)(const uint64_t *regs)); int gate_obs_present(int id); void dm_quiet_difficulty_msg(int on); // 秘境局里拦原版「游戏难度设为 N」提示(观测门 15,diag.c) | In a rift run, block the original game's 「游戏难度设为 N」(Game difficulty set to N) message (observation gate 15, diag.c) diff --git a/dm/host/dm_cloudsync.c b/dm/host/dm_cloudsync.c index 52ecbf0..e06f94a 100644 --- a/dm/host/dm_cloudsync.c +++ b/dm/host/dm_cloudsync.c @@ -13,7 +13,16 @@ // · 首次同步(这一单位没有状态记录)且两边内容不同:一律以云端为准(本地那份照常整份进备份);运行中(allow_down = 0)不传不改,等下次启动下载。云端没有才上传本地。 // · 共享仓库(_stash)再加一道:要被覆盖的一方「明显更多」就不覆盖——任一共享仓库档(.d2i)的编年史段变短(编年史只增不减;新装的空仓库编年史最短)、 // 或要盖上去的是没东西的新档(0 件且编年史还是新建大小)而另一份有物品,或编年史仓库侧文件(.swvault)有件而另一份根本没有这个文件(新装 / 旧版本)。 -// 物品变少、编年史仓库取空都是正常玩法,不拦(只有从没记过编年史的仓库被取空会被当成新档拦下,宁可不同步也不丢)。拦下时本地与云端都不动、状态不记,日志记红,进局后弹系统提示(dm_cloud_conflict_take)。 +// 物品变少、编年史仓库取空都是正常玩法,不算(只有从没记过编年史的仓库被取空会被当成新档)。 +// 共享仓库分叉(iCloud 离线冲突第 1 条第一笔,不丢、不永久拦):首次同步两边不同、或上面那道保险判出「会丢东西」时,不再永久拦住—— +// 启动时一律以云端为现行版(换下的本机那份照常整份进备份),本机那份有东西(物品 / 金币 / 编年史 / 编年史仓库任一项,预置与新建空档不算)就另存进 +// 待合并收件箱 <存档>/_cloudinbox/<时刻>-<序号>/(在存档目录里:局内并回时与角色档、共享仓库同一次存盘提交原子换入,被杀不会复制也不会丢; +// 下划线开头不算角色、也不是共享仓库文件,iCloud 不同步它——收件箱是这台设备自己的):mine.pack = 本机那份;base.pack = 上次同步成功时的共享仓库(状态文件旁的 .stash_base,摘要对得上才带), +// 以后在局内并回:云端是基准的后代(编年史只增不减,基准的编年史条目云端都有)时按「云端 + 本机新增 − 本机取走」,分不清来历时按同一件取一份的并集 +// (单机游戏里少数情况下多出一件比丢一件好)。收不进收件箱就这次不动。 +// 运行中(allow_down = 0)遇到分叉不动、等下次启动。新收进一份就进局提示一次(dm_cloud_conflict_take)。 +// 每次共享仓库同步成功(上传 / 下载 / 一致)都把那一刻的内容写进 <状态文件>.stash_base,给下次分叉当基准。 +// iCloud 自己的同名文件冲突版本(cloud_ios.m 读出来)也走收件箱:dm_cloud_inbox_add。 // Core of iCloud save sync (synced by character name, the later write overwrites the earlier one, and the shared stash works the same way). // This only does the file comparison and moving for "local save directory ↔ one cloud directory" and does not touch the iCloud API: the iOS side (cloud_ios.m) provides the directory in the ubiquity container, confirms the packs have finished downloading, and then calls dm_cloud_sync. // The host unit test (tests/t_cloudsync.c) uses a local directory as the cloud. @@ -28,7 +37,16 @@ // - First sync (this unit has no state record) and the two sides differ: the cloud is always authoritative (the local copy goes into the backup whole as usual); while running (allow_down = 0) nothing is uploaded or changed, and the download waits for the next launch. Local is uploaded only if the cloud has nothing. // - The shared stash (_stash) gets one more check: do not overwrite if the side to be overwritten "clearly has more" -- the chronicle segment of any shared stash save (.d2i) gets shorter (the chronicle only grows, never shrinks; a freshly installed empty stash has the shortest chronicle), // or what would overwrite is an empty new save (0 items and the chronicle still at the freshly-created size) while the other copy has items, or the chronicle vault side file (.swvault) has items while the other copy does not have this file at all (fresh install / old version). -// Fewer items and an emptied chronicle vault are both normal play and are not blocked (only a stash that never recorded any chronicle being emptied is treated as a new save and blocked; better not to sync than to lose data). When blocked, neither local nor cloud is touched, no state is recorded, a failure line is logged, and a system notification is shown after entering a run (dm_cloud_conflict_take). +// Fewer items and an emptied chronicle vault are both normal play and do not count (only a stash that never recorded any chronicle being emptied is treated as a new save). +// Shared stash fork (iCloud offline conflict item 1, first step: nothing lost, nothing blocked forever): when the two sides differ at first sync, or the check above finds that "something would be lost", it is no longer blocked forever - +// at launch the cloud is always taken as the current version (the local copy it replaces goes into the backup whole as usual), and if the local copy has anything (items / gold / chronicle / chronicle vault, any of them; the preset and freshly created empty saves do not count) it is also stored in +// the to-merge inbox /_cloudinbox/-/ (inside the save directory: when merged back in a run it is swapped in atomically in the same save commit as the character saves and the shared stash, so being killed neither duplicates nor loses anything; +// names starting with an underscore are not characters and not shared stash files, and iCloud does not sync it - the inbox belongs to this device): mine.pack = the local copy; base.pack = the shared stash at the last successful sync (.stash_base next to the state file, included only if its digest matches), +// to be merged back in a run later: when the cloud is a descendant of the base (the chronicle only grows; the cloud has every chronicle entry of the base) as "cloud + added locally - taken out locally"; when the origin cannot be told apart, as a union taking one of each identical item +// (in a single-player game, one extra item in rare cases is better than one lost). If it cannot be stored in the inbox, nothing is touched this time. +// While running (allow_down = 0) a fork is left alone until the next launch. Each newly stored copy gives one notice after entering a run (dm_cloud_conflict_take). +// Every successful shared stash sync (upload / download / identical) writes the content at that moment to .stash_base, as the base for the next fork. +// iCloud's own same-name file conflict versions (read out by cloud_ios.m) also go to the inbox: dm_cloud_inbox_add. #include #include #include @@ -39,6 +57,7 @@ #include #include #include +#include #include "dm.h" #define MAXF 64 @@ -68,7 +87,7 @@ static int read_dir(const char *root, const char *rel, cs_unit *u) { // rel } // ---- 共享仓库的内容量(只认结构,不解物品):.d2i 按 55 AA 55 AA 分段,段内 +64 是 'JM' 的是物品页(+66 物品数),其余段是编年史;.swvault 头 'SWVT'、+6 件数 // ---- Content volume of the shared stash (structure only, items are not decoded): .d2i is split into segments by 55 AA 55 AA; a segment with 'JM' at +64 is an item page (+66 item count), the other segments are the chronicle; .swvault has the header 'SWVT', +6 item count -typedef struct { int kind, items, chron, vault; } cs_rich; +typedef struct { int kind, items, chron, vault; long long gold; } cs_rich; // 游戏新建的空共享仓库:物品 0 件、编年史段 148 字节(三份新建档、rf3 的专家仓库都是这个值)。「0 件且编年史还是新建大小」= 没东西的新档, // 不许盖掉有物品的一份(rf3:云端专家仓库 2 件、编年史 148,本机新建的空档同样 148,只比编年史拦不住);编年史长过新建的仓库被玩家取空照常同步 // An empty shared stash newly created by the game: 0 items, chronicle segment 148 bytes (three freshly created saves and rf3's hardcore stash all have this value). "0 items and the chronicle still at the freshly-created size" = an empty new save, @@ -91,7 +110,7 @@ static cs_rich rich_of(const cs_file *f) { if (f->size == sizeof g_stash_seed && !memcmp(f->data, g_stash_seed, sizeof g_stash_seed)) { r.chron = FRESH_CHRON; return r; } // 预置:0 件、新建大小 | seed: 0 items, freshly-created size #endif for (uint32_t o = 0; o + 68 <= f->size && !memcmp(f->data + o, "\x55\xaa\x55\xaa", 4); ) { uint32_t ln; memcpy(&ln, f->data + o + 16, 4); if (ln < 68 || o + ln > f->size) break; - if (!memcmp(f->data + o + 64, "JM", 2)) { uint16_t c; memcpy(&c, f->data + o + 66, 2); r.items += c; } else r.chron += (int)ln; o += ln; } } + if (!memcmp(f->data + o + 64, "JM", 2)) { uint16_t c; uint32_t g; memcpy(&c, f->data + o + 66, 2); memcpy(&g, f->data + o + 12, 4); r.items += c; r.gold += g; } else r.chron += (int)ln; o += ln; } } else if (L > 8 && !strcmp(f->path + L - 8, ".swvault")) { r.kind = 2; if (f->size >= 8 && !memcmp(f->data, "SWVT", 4)) { uint16_t c; memcpy(&c, f->data + 6, 2); r.vault = c; } } return r; } @@ -106,7 +125,18 @@ static const char *stash_shrinks(const cs_unit *w, const cs_unit *x, char *why, return NULL; } static _Atomic int g_conflict; -int dm_cloud_conflict_take(void) { return __atomic_exchange_n((int *)&g_conflict, 0, __ATOMIC_SEQ_CST); } // 进局后取一次:有拦下的共享仓库覆盖就弹系统提示(diag.c) | taken once after entering a run: if a shared stash overwrite was blocked, show a system notification (diag.c) +int dm_cloud_conflict_take(void) { return __atomic_exchange_n((int *)&g_conflict, 0, __ATOMIC_SEQ_CST); } // 进局后取一次:这次启动有共享仓库收进了待合并收件箱就弹系统提示(diag.c) | taken once after entering a run: if a shared stash was put in the to-merge inbox during this launch, show the system notice (diag.c) +static int stash_has_stuff(const cs_unit *u) { // 共享仓库这份有没有东西值得留:任一 .d2i 有物品 / 金币 / 编年史长过新建,或编年史仓库有件(预置与新建空档不算) | whether this shared stash copy has anything worth keeping: any .d2i with items / gold / a chronicle longer than freshly created, or the chronicle vault has items (the preset and freshly created empty saves do not count) + for (int i = 0; i < u->n; i++) { cs_rich r = rich_of(&u->f[i]); if ((r.kind == 1 && (r.items || r.gold || r.chron > FRESH_CHRON)) || (r.kind == 2 && r.vault)) return 1; } + return 0; +} +// 同名角色(iCloud 离线冲突第 3 条):首次同步两边都有同名角色、内容不同 → 照旧以云端为准、本机那份整份进备份,另外记下名字,进局后提示一次(diag.c)。 +// 两份角色档没法合并(等级、任务、身上装备各是一条独立的历史);改名留两份要改 .d2s 头与校验和,不做。 +// Same-name character (iCloud offline conflict item 3): at first sync both sides have a character with the same name and different content -> as before the cloud is authoritative and the local copy goes into the backup whole; the name is also recorded and one notice is shown after entering a run (diag.c). +// Two character saves cannot be merged (level, quests and equipment are each an independent history); keeping both under different names would need changes to the .d2s header and checksum, not done. +static char g_char_conf[256]; static pthread_mutex_t g_cc_mu = PTHREAD_MUTEX_INITIALIZER; +static void char_conf_add(const char *nm) { pthread_mutex_lock(&g_cc_mu); size_t l = strlen(g_char_conf); if (l + strlen(nm) + 3 < sizeof g_char_conf) snprintf(g_char_conf + l, sizeof g_char_conf - l, "%s%s", l ? "、" : "", nm); pthread_mutex_unlock(&g_cc_mu); } +int dm_cloud_char_conflict_take(char *out, size_t n) { pthread_mutex_lock(&g_cc_mu); int r = g_char_conf[0] != 0; if (r) strlcpy(out, g_char_conf, n); g_char_conf[0] = 0; pthread_mutex_unlock(&g_cc_mu); return r; } static int is_stash(const char *nm) { return !strncmp(nm, "SharedStash", 11) || !strncmp(nm, "ModernSharedStash", 17); } static int is_char_dir(const char *save, const char *nm) { char p[1600]; struct stat st; snprintf(p, sizeof p, "%s/%s/%s.d2s", save, nm, nm); return nm[0] != '.' && nm[0] != '_' && !stat(p, &st) && S_ISREG(st.st_mode); } @@ -215,6 +245,42 @@ static cs_state *state_get(cs_state *s, int *n, int cap, const char *unit, int a } static void add_name(char (*names)[64], int *n, const char *nm) { for (int i = 0; i < *n; i++) if (!strcmp(names[i], nm)) return; if (*n < 256 && strlen(nm) < 64) strlcpy(names[(*n)++], nm, 64); } +// ---- 待合并收件箱与基准(见文件头「共享仓库分叉」) +// ---- To-merge inbox and base (see "Shared stash fork" in the file header) +static void base_path(const char *statef, char *o, size_t n) { snprintf(o, n, "%s.stash_base", statef); } +static int base_missing(const char *statef) { char bp[1300]; struct stat st; base_path(statef, bp, sizeof bp); return stat(bp, &st) != 0; } // 升级上来的设备第一次补写 | first write-out on a device upgraded from an older version +static void base_put(const char *statef, const cs_unit *u) { // 共享仓库同步成功那一刻的内容,下次分叉时当基准 | the content at the moment of a successful shared stash sync, used as the base at the next fork + char bp[1300]; base_path(statef, bp, sizeof bp); cs_unit t = *u; t.tomb = 0; + if (pack_write(bp, &t)) LOG("【红】iCloud 同步:共享仓库基准写不进 %s errno=%d", bp, errno); } +// 收件箱新条目:<存档>/_cloudinbox/<时刻>-<序号>/mine.pack(+ base.pack:摘要等于 base_hash 时才带;base_hash = 0 不带)。返回 0 = 收好了 +// New inbox entry: /_cloudinbox/-/mine.pack (+ base.pack: included only when its digest equals base_hash; not included when base_hash = 0). Returns 0 = stored +static int inbox_put(const char *save, const char *statef, const cs_unit *u, uint64_t base_hash, const char *why, const char *who) { + char ib[1300], d[1400], f[1500]; snprintf(ib, sizeof ib, "%s/_cloudinbox", save); mkdir(ib, 0755); + int k = 0; do snprintf(d, sizeof d, "%s/%llu-%d", ib, (unsigned long long)u->stamp, k++); while (mkdir(d, 0755) && errno == EEXIST && k < 100); + snprintf(f, sizeof f, "%s/mine.pack", d); cs_unit t = *u; t.tomb = 0; + if (pack_write(f, &t)) { LOG("【红】iCloud 同步:共享仓库收件箱写不进 %s errno=%d", f, errno); rm_rf(d); return -1; } + int nb = 0; if (base_hash) { char bp[1300]; base_path(statef, bp, sizeof bp); cs_unit *B = calloc(1, sizeof *B); + if (B && pack_read(bp, B) == 1 && B->hash == base_hash) { snprintf(f, sizeof f, "%s/base.pack", d); if (pack_write(f, B)) { LOG("【红】iCloud 同步:收件箱基准写不进 %s errno=%d", f, errno); unit_free(B); free(B); rm_rf(d); return -1; } nb = 1; } + if (B) { unit_free(B); free(B); } } + LOG("iCloud 同步:_stash %s,%s那份收进待合并收件箱 %s(%d 个文件,%s)", why, who, d, u->n, nb ? "带上次同步的基准" : "没有基准:两份当独立来历"); + __atomic_store_n((int *)&g_conflict, 1, __ATOMIC_SEQ_CST); return 0; +} +// iCloud 冲突版本(cloud_ios.m):把一份共享仓库包收进收件箱,基准用本机上次同步的那份。返回 0 = 收好了(或没东西不用收),-1 = 坏包 / 写不进 +// iCloud conflict version (cloud_ios.m): store one shared stash pack in the inbox, with the copy from this device's last sync as the base. Returns 0 = stored (or nothing worth storing), -1 = bad pack / cannot write +int dm_cloud_inbox_add(const char *save, const char *statef, const char *pack) { + cs_unit *u = calloc(1, sizeof *u); if (!u) return -1; int r = pack_read(pack, u), ret = -1; + if (r == 1 && !u->tomb) { if (!stash_has_stuff(u)) ret = 0; else { char bp[1300]; base_path(statef, bp, sizeof bp); cs_unit *B = calloc(1, sizeof *B); uint64_t bh = B && pack_read(bp, B) == 1 ? B->hash : 0; if (B) { unit_free(B); free(B); } + ret = inbox_put(save, statef, u, bh, "iCloud 冲突版本", "冲突版本"); } } + else if (r == 1) ret = 0; else LOG("【红】iCloud 同步:冲突版本 %s 读不了", pack); + unit_free(u); free(u); return ret; +} +// 角色包的 iCloud 冲突版本(cloud_ios.m):包头时刻(游戏最后写它的时刻)、整份进备份、记名进局提示 +// iCloud conflict version of a character pack (cloud_ios.m): the pack header timestamp (the moment the game last wrote it), the whole copy goes into the backup, the name is recorded for a notice after entering a run +uint64_t dm_cloud_pack_stamp(const char *pack) { cs_unit *u = calloc(1, sizeof *u); uint64_t t = u && pack_read(pack, u) == 1 ? u->stamp : 0; if (u) { unit_free(u); free(u); } return t; } +int dm_cloud_bak_pack(const char *bak, const char *unit, const char *pack, const char *why) { + cs_unit *u = calloc(1, sizeof *u); int r = u && pack_read(pack, u) == 1 ? (u->tomb ? 0 : backup_copy(bak, unit, u, why)) : -1; if (u) { unit_free(u); free(u); } return r; } +void dm_cloud_char_conflict_note(const char *unit) { char_conf_add(unit); } + // 返回本次动作数(上传 + 下载 + 删除),-1 = 参数错。ready(单位) 返回 0 = 云端那份还没下载好(iCloud 占位),这一单位本次跳过。now_ms = 写删除标记用的时刻 // Returns the number of actions this time (uploads + downloads + deletions), -1 = bad arguments. ready(unit) returning 0 = the cloud copy has not finished downloading yet (iCloud placeholder), and this unit is skipped this time. now_ms = the timestamp used when writing a deletion marker int dm_cloud_sync(const char *save, const char *cloud, const char *bak, const char *statef, int allow_down, uint64_t now_ms, int (*ready)(const char *unit)) { @@ -245,19 +311,27 @@ int dm_cloud_sync(const char *save, const char *cloud, const char *bak, const ch else if (lchg && !cchg) act = UP; else act = C->stamp > L->stamp ? (C->tomb ? DEL_LOCAL : DOWN) : UP; // 两边都改了(或从没同步过且内容不同):后写的赢 | both sides changed (or never synced and the contents differ): the later write wins if ((act == DOWN || act == DEL_LOCAL) && !allow_down) { act = NONE; goto next; } // 运行中不改本地:等下次启动,状态不动 | do not change local data while running: wait for the next launch, state untouched - if (!strcmp(un, "_stash") && ((act == DOWN && hl) || (act == UP && hc && !C->tomb))) { char why[400]; // 共享仓库:要被覆盖的一方明显更多就不覆盖(见文件头) | shared stash: do not overwrite if the side to be overwritten clearly has more (see the file header) - if (act == DOWN ? stash_shrinks(C, L, why, sizeof why) : stash_shrinks(L, C, why, sizeof why)) { - LOG("【红】iCloud 同步:_stash %s会丢东西(%s),不覆盖、两边都不动", act == DOWN ? "下载云端那份" : "上传本机那份", why); - __atomic_store_n((int *)&g_conflict, 1, __ATOMIC_SEQ_CST); act = NONE; goto next; } } + if (!strcmp(un, "_stash") && hl && hc && !C->tomb && L->hash != C->hash) { char why[400] = ""; // 共享仓库分叉(见文件头):云端为现行版,本机那份有东西就进收件箱 | shared stash fork (see the file header): the cloud is the current version; the local copy goes into the inbox if it has anything + int fork = 0; + if (!S) { snprintf(why, sizeof why, "首次同步两边不同"); fork = 1; } + else if (act == DOWN) fork = stash_shrinks(C, L, why, sizeof why) != NULL; + else if (act == UP) fork = stash_shrinks(L, C, why, sizeof why) != NULL; + if (fork) { + if (!allow_down) { LOG("iCloud 同步:_stash 分叉(%s),运行中不动,等下次启动收进收件箱", why); goto next; } + if (stash_has_stuff(L) && inbox_put(save, statef, L, S ? S->hash : 0, why, "本机")) goto next; // 收不进收件箱:这次不动 | cannot store it in the inbox: leave everything this time + act = DOWN; } } if (act == UP) { if (hc && !C->tomb && C->hash != L->hash && cchg && backup_copy(bak, un, C, "云端(被本机后写覆盖)")) goto next; L->tomb = 0; if (pack_write(cp, L)) { LOG("【红】iCloud 同步:%s 上传失败 errno=%d", un, errno); goto next; } LOG("iCloud 同步:%s 上传(时刻 %llu,%d 个文件)", un, (unsigned long long)L->stamp, L->n); acts++; W = state_get(st, &ns, 256, un, 1); if (W) { W->hash = L->hash; W->stamp = L->stamp; W->tomb = 0; } + if (!strcmp(un, "_stash")) base_put(statef, L); } else if (act == DOWN) { if (local_apply(save, bak, un, hl ? L : NULL, C)) { LOG("【红】iCloud 同步:%s 下载后换进本地失败 errno=%d(本地不变)", un, errno); goto next; } LOG("iCloud 同步:%s 下载(时刻 %llu,%d 个文件)", un, (unsigned long long)C->stamp, C->n); acts++; + if (!S && hl && strcmp(un, "_stash")) { char_conf_add(un); LOG("iCloud 同步:%s 两台设备各有一份同名角色,用云端那份,本机那份已进备份;进局提示", un); } W = state_get(st, &ns, 256, un, 1); if (W) { W->hash = C->hash; W->stamp = C->stamp; W->tomb = 0; } + if (!strcmp(un, "_stash")) base_put(statef, C); } else if (act == DEL_LOCAL) { { char d[1300]; if (move_to_bak(save, bak, un, L, "本机(另一台删了这个角色)", d, sizeof d)) goto next; } // 删 = 整份挪进备份,挪不动就不删 | delete = move the whole copy into the backup; if it cannot be moved, do not delete LOG("iCloud 同步:%s 另一台删了,本机也删(备份已留)", un); acts++; @@ -266,7 +340,8 @@ int dm_cloud_sync(const char *save, const char *cloud, const char *bak, const ch cs_unit t = { .tomb = 1, .stamp = now_ms }; if (pack_write(cp, &t)) { LOG("【红】iCloud 同步:%s 写删除标记失败 errno=%d", un, errno); goto next; } LOG("iCloud 同步:%s 本机删了,云端记删除标记", un); acts++; W = state_get(st, &ns, 256, un, 1); if (W) { W->hash = 0; W->stamp = now_ms; W->tomb = 1; } - } else if (hc) { W = state_get(st, &ns, 256, un, 1); if (W) { W->hash = C->tomb ? 0 : C->hash; W->stamp = C->stamp; W->tomb = C->tomb; } } // 一致:记成已同步 | identical: record as synced + } else if (hc) { W = state_get(st, &ns, 256, un, 1); if (W) { W->hash = C->tomb ? 0 : C->hash; W->stamp = C->stamp; W->tomb = C->tomb; } // 一致:记成已同步 | identical: record as synced + if (!strcmp(un, "_stash") && !C->tomb && (!S || S->hash != C->hash || base_missing(statef))) base_put(statef, C); } next: unit_free(L); unit_free(C); free(L); free(C); } diff --git a/dm/host/dm_cursor.c b/dm/host/dm_cursor.c index 91389f9..85b63a8 100644 --- a/dm/host/dm_cursor.c +++ b/dm/host/dm_cursor.c @@ -1938,6 +1938,73 @@ int dm_ui_minimap_rect(float r[4]) { if (!atomic_load(&g_mm_have)) return 0; uin // and if the flip waited for the per-frame check of the panel tree in the next frame, the UI would still be laid out centered in the frame the loading screen is removed (in that frame the health globe is at the centered position and the area name is not lifted). -1 = no message received yet, go by the panel tree. static _Atomic int g_load_up = -1; static uint64_t g_lift_next; +// 系统提示框(NotificationPanel)的停靠高度分两态。布局里写的是没开面板时的高度(gen_romfs_overlay.py:上提到让开底栏上方的生命 / 法力数值); +// 开着大面板时那行数值被面板盖住,上提后的框反而压在背包格子上,所以面板态改停到 NOTE_PANEL_Y(布局单位,同 json 的 y):大面板底边框那一带,在金币 / 存放那排下面。 +// 大面板 = 下面名单里的界面根直接子可见(NPC 讲话框、对话菜单这类小框不算:那时底栏还在,框要留在上提位)。名单漏了的面板照无面板处理(= 上一版行为) +// 改的是对象 +0x19c「停靠目标 y」:原版重排(main+0x3d7e1c)按布局把矩形 y 抄进去,每帧更新(main+0x3d7fbc)滑入滑出时按 (1-t)·目标 插值写 +0x74、 +// 自己从不写 +0x19c——所以改它不跟动画抢坐标(用位置守卫改 +0x74 就是被动画每帧盖回)。单位换算:矩形高 +0x7c 对应布局高 244。 +// 写回由我们确定性做(把写 +0x19c 登记成例外的条件;原版控件规则见 tests/native_write_scan.py NATIVE_FIELD_OK): +// 我们记下原值,停靠条件一结束——面板关、读取画面开(切场景)、保存并退出、回到前端——当场写回,不靠游戏重排;重排只是第二道保险 +// (现值不是我们上次写的 = 游戏重排过(换模式 / 改分辨率),当新原值)。消息路(dm_ui_on_uimsg)在消息到达那一刻写,每帧路兜着。 +// 保存并退出 / 回到前端之后到下一次进局之前不再停靠(暂停菜单在退出那几帧还挂着,不压住的话下一帧又停回面板态)。 +// 测试开关 DM_TEST_NOTE_PANEL_Y=<单位> 试别的高度 +// The docking height of the system notice box (NotificationPanel) has two states. The layout holds the height with no panel open (gen_romfs_overlay.py: raised out of the way of the life / mana numbers above the bottom bar); +// with a large panel open that row of numbers is covered by the panel, and the raised box would sit on the inventory cells instead, so in panel state it docks at NOTE_PANEL_Y (layout units, like y in the json): the band of the large panel's bottom frame, below the gold / Store row. +// Large panel = a root of the list below being a visible direct child (small boxes such as the NPC speech box and dialogue menu do not count: the bottom bar is still there then, and the box stays in the raised position). A panel missing from the list is treated as no panel (= the previous behaviour) +// What is changed is the object's +0x19c "docking target y": the original relayout (main+0x3d7e1c) copies the rectangle y into it from the layout, and the per-frame update (main+0x3d7fbc) writes +0x74 interpolated as (1-t)*target during slide-in / slide-out, +// never writing +0x19c itself - so changing it does not fight the animation for the position (changing +0x74 with a position guard just gets overwritten by the animation every frame). Unit conversion: rectangle height +0x7c corresponds to layout height 244. +// Writing back is done deterministically by us (the condition for registering writes to +0x19c as an exception; the rule for original widgets is in tests/native_write_scan.py NATIVE_FIELD_OK): +// we record the original value, and as soon as the docking condition ends - panel closed, loading screen open (scene change), save and exit, back to the front end - it is written back on the spot, without relying on the game's relayout; the relayout is only a second safety net +// (current value is not what we last wrote = the game relaid it out (mode change / resolution change), taken as the new original). The message path (dm_ui_on_uimsg) writes the moment the message arrives; the per-frame path covers the rest. +// After save and exit / back to the front end, no docking until the next time a game is entered (the pause menu is still up for those few frames of exiting; without holding it, the next frame would dock to the panel state again). +// Test switch DM_TEST_NOTE_PANEL_Y= tries another height +#define NOTE_PANEL_Y -310 +// 停靠目标切换的那一刻框已停稳(+0x198 显示中、矩形 y +0x74 正等于旧目标):原版停稳时不再写坐标,只改 +0x19c 它会一直留在旧位置—— +// 开面板时压着背包格、关面板时压着底栏数值(两个方向都被退回过)。所以两个方向都顺手把 +0x74 一次写成新目标(登记的第二处例外, +// 只许 note_dock_snap 写)。滑入滑出期间 +0x74 不等于旧目标、不写;滑出刚开始那一帧即使相等,之后的插值用的也是已改的 +0x19c,同向不打架。 +// 写完下一帧核:+0x74 还是新目标 = 没在动画期写;被改了记红(g_nd_ychk) +// At the moment the docking target switches, the box has already settled (+0x198 showing, rectangle y +0x74 exactly equal to the old target): once settled the original no longer writes the position, and changing only +0x19c leaves it at the old place - +// over the inventory cells when a panel opens, over the bottom-bar numbers when it closes (both directions were sent back). So both directions also write +0x74 to the new target in one go (the second registered exception, +// written only by note_dock_snap). During slide-in / slide-out +0x74 is not equal to the old target, so nothing is written; even if equal on the first frame of slide-out, the interpolation after that uses the already changed +0x19c, so they move the same way. +// Check on the next frame after writing: +0x74 still the new target = not written during animation; if it was changed, log red (g_nd_ychk) +static uint64_t g_nd_w; static int32_t g_nd_orig, g_nd_mine; static int g_nd_on = -1, g_nd_hold; // g_nd_hold:1 = 退出中(等出局),2 = 已出局(等进局) | g_nd_hold: 1 = leaving (waiting to be out of the game), 2 = out of the game (waiting to enter) +static int g_nd_ychk; static int32_t g_nd_ywant; static unsigned g_nd_ywr, g_nd_ybad; // 写过 +0x74 待下一帧核(核它还是 g_nd_ywant);累计写入次数 / 动画期写入(被改)次数 | +0x74 was written, check it next frame (that it is still g_nd_ywant); total writes / writes during animation (overwritten) +static int note_dock_snap(uint64_t w, int32_t from, int32_t to) { // 框已停稳在 from:矩形 y 一次写成 to。返回 1 = 写了 | the box has settled at from: write the rectangle y as to in one go. Returns 1 = written + int32_t *ry = (int32_t *)(w + 0x74); if (!*(uint8_t *)(w + 0x198) || *ry != from || from == to) return 0; + *ry = to; g_nd_ychk = 1; g_nd_ywant = to; g_nd_ywr++; return 1; +} +static void note_dock_restore(uint64_t root, const char *why) { // 只许游戏主线程 | game main thread only + uint64_t w = root ? ui_find(root, "NotificationPanel", 0) : 0; if (!w || w != g_nd_w) return; // 不在树里 / 不是记下的那个对象:不碰 | not in the tree / not the object we recorded: do not touch + int32_t *t = (int32_t *)(w + 0x19c); + if (*t == g_nd_mine && g_nd_mine != g_nd_orig) { + *t = g_nd_orig; int still = note_dock_snap(w, g_nd_mine, g_nd_orig); + static int lg; if (lg++ < 60) LOG("提示框停靠:%s → 写回原值 y %d%s", why, g_nd_orig, still ? "(框已停稳,矩形 y 一并写回)" : ""); } + g_nd_mine = *t; g_nd_on = 0; +} +static void ui_note_dock_pump(uint64_t root) { + static const char *const big[] = { "PlayerInventoryExpansionLayout", "SkillsTreePanel", "CharacterStatsPanel", "QuestLogPanelExpansion", "BankExpansionLayout", "HoradricCubeLayout", + "WaypointsPanelExpansion", "VendorPanelLayout", "HirelingInventoryPanel", "ImbueItemsPanel", "ChroniclePanel", "MessageLogPanel", "PauseLayout", "PauseLayoutGarden", + "SettingsPanel", "SoundOptionsPanel", "VideoOptionsPanel", "GameplayOptionsPanel" }; + static int py = 1; + if (py > 0) { const char *e = getenv("DM_TEST_NOTE_PANEL_Y"); py = e ? atoi(e) : NOTE_PANEL_Y; } + uint64_t w = ui_find(root, "NotificationPanel", 0); if (!w) { g_nd_w = 0; return; } + int32_t *t = (int32_t *)(w + 0x19c), h = *(int32_t *)(w + 0x7c); + if (g_nd_ychk) { g_nd_ychk = 0; int32_t y = *(int32_t *)(w + 0x74); static int lg; + if (w != g_nd_w) { if (lg++ < 60) LOG("提示框停靠:写回矩形 y 后提示框对象已换(出局 / 重建),不核"); } + else if (y != g_nd_ywant) { g_nd_ybad++; LOG("【红】提示框停靠:矩形 y 写成 %d 后下一帧被改成 %d(动画期写入,第 %u 次)", g_nd_ywant, y, g_nd_ybad); } + else if (lg++ < 60) LOG("提示框停靠:停稳的框下一帧在 y %d(%s;矩形 y 写入第 %u 次,动画期 %u 次)", y, y == g_nd_orig ? "原位" : "面板态位", g_nd_ywr, g_nd_ybad); } + if (w != g_nd_w || *t != g_nd_mine) { g_nd_w = w; g_nd_orig = *t; g_nd_mine = *t; } + int ing = dm_uiscreen_ingame(); if (g_nd_hold == 1 && !ing) g_nd_hold = 2; else if (g_nd_hold == 2 && ing) g_nd_hold = 0; + int panel = 0; uint64_t ch = *(uint64_t *)(root + 0x58), n = *(uint64_t *)(root + 0x60); // 名单里的面板在屏上(可见且有可见内容)= 面板态;两种模式通用 | a panel on the list is on screen (visible and with visible content) = panel state; same for both modes + for (uint64_t j = 0; ing && !g_nd_hold && j < n && !panel; j++) { uint64_t c = *(uint64_t *)(ch + 8 * j); const char *nm = c ? (const char *)*(uint64_t *)(c + 8) : NULL; + if (!nm || !*(uint8_t *)(c + 0x50)) continue; + for (unsigned i = 0; i < sizeof big / sizeof *big && !panel; i++) panel = !strcmp(nm, big[i]) && has_visible_leaf(c, 1); } + int32_t pv = h > 0 ? (int32_t)lroundf(py * h / 244.0f) : g_nd_orig; + if (!(panel && pv > g_nd_orig)) { if (g_nd_on) note_dock_restore(root, ing ? "面板关了" : "不在局内"); } // 只往下挪:布局本来就不低于面板态高度时不动 | only move it down: if the layout is already no higher than the panel-state height, leave it + else if (*t != pv) { int32_t was = *t; *t = pv; g_nd_mine = pv; + if (note_dock_snap(w, was, pv)) { static int lg; if (lg++ < 60) LOG("提示框停靠:开面板时框已停稳在 y %d,矩形 y 一并写成面板态位 %d", was, pv); } } + if (panel != g_nd_on) { g_nd_on = panel; static int lg; if (lg++ < 40) LOG("提示框停靠:%s,目标 y %d(布局原值 %d,矩形高 %d)", panel ? "面板态" : "无面板", *t, g_nd_orig, h); } +} static void ui_lift_pump(uint64_t root, uint64_t fr) { if (fr < g_lift_next) return; g_lift_next = fr + 6; int x, y, w, h; dm_ui_rect(&x, &y, &w, &h); int lift = h > 0 && dm_uiscreen_ingame() ? (int)((long)y * 2160 / h) : 0; @@ -2430,7 +2497,7 @@ static void ui_panel_state_pump(uint64_t root) { // 游戏主线程,每帧 | // 触屏专属(带 if (tm)):请求全部来自触摸手势——点世界 / 佣兵头像、长按取物、双击使用、点货买、拖放、点技能绑定、副手组页签、开佣兵页。 // 手柄模式与切换事务进行中不跑;在途的请求由切换清理作废(dm_ui_cache_mode_leave)。 // 两种模式都跑:ui_target_pump(鉴定目标,含手柄按住 A)、ui_item_pump(命中查询,宿主自己也问)、ui_ptr_pump(指针事件,宿主合成的点击也走)、 -// ui_safe_pump / ui_lift_pump / ui_trove_tabs_pump / ui_minimap_pump / ui_map_pump / ui_map_geom_pump / ui_map_center(屏幕几何,与输入方式无关)、ui_boss_pct_pump、ui_npcdlg_pump、 +// ui_safe_pump / ui_lift_pump / ui_note_dock_pump / ui_trove_tabs_pump / ui_minimap_pump / ui_map_pump / ui_map_geom_pump / ui_map_center(屏幕几何,与输入方式无关)、ui_boss_pct_pump、ui_npcdlg_pump、 // ui_widestash_pump、mv_audit_pump、ui_pages_pump(含手柄 L / R 翻页)、ui_watch_pump、ui_panel_heal、ui_panel_state_pump、rs_pump(一键重开,在前端泵里调) // 物品说明框停靠(观测门 OBS_TOOLTIP,挂在说明框面板的「提交一条说明」函数入口 main+0xb0d560(面板, 文字, 目标矩形左上 x2, 目标矩形宽高 x3, 样式, 文字 2))。 // 说明框是即时式的:悬停着的控件每帧重新提交、画完就清,宿主在自己的时机读面板里的记录数一直是 0,所以只能在提交那一刻改输入。 @@ -2444,7 +2511,7 @@ static void ui_panel_state_pump(uint64_t root) { // 游戏主线程,每帧 | // Touch only (with if (tm)): all requests come from touch gestures - tapping the world / the mercenary portrait, long press to take, double tap to use, tap goods to buy, drag and drop, tap to bind a skill, the off-hand set tab, opening the mercenary page. // Not run in gamepad mode or while a switching transaction is in progress; requests in flight are voided by the switch cleanup (dm_ui_cache_mode_leave). // Run in both modes: ui_target_pump (identify target, including holding A on a gamepad), ui_item_pump (hit queries, also asked by the host itself), ui_ptr_pump (pointer events, also used by clicks synthesised by the host), -// ui_safe_pump / ui_lift_pump / ui_trove_tabs_pump / ui_minimap_pump / ui_map_pump / ui_map_geom_pump / ui_map_center (screen geometry, independent of input method), ui_boss_pct_pump, ui_npcdlg_pump, +// ui_safe_pump / ui_lift_pump / ui_note_dock_pump / ui_trove_tabs_pump / ui_minimap_pump / ui_map_pump / ui_map_geom_pump / ui_map_center (screen geometry, independent of input method), ui_boss_pct_pump, ui_npcdlg_pump, // ui_widestash_pump, mv_audit_pump, ui_pages_pump (including gamepad L / R paging), ui_watch_pump, ui_panel_heal, ui_panel_state_pump, rs_pump (one-tap restart, called in the front-end pump) // Item tooltip docking (observation gate OBS_TOOLTIP, hooked at the entry of the tooltip panel's "submit one tooltip" function main+0xb0d560(panel, text, top-left of target rect x2, size of target rect x3, style, text 2)). // The tooltip is immediate-mode: the hovered widget resubmits it every frame and it is cleared once drawn, so the record count in the panel is always 0 whenever the host reads it; the input can only be changed at the moment of submission. @@ -2520,7 +2587,7 @@ void dm_ui_mouse_pump(void) { // 游戏取手柄处调(hle_hid fill,主线 else fix = 0; } if (th) { ui_auto_key(th); tnext = fr + 8; } } } } { module_t *pm = main_module(); uint64_t proot = 0; if (pm) { memcpy(&proot, pm->base + 0x2f05458, 8); int32_t pw = *(int32_t *)(pm->base + 0x211da38), phh = *(int32_t *)(pm->base + 0x211da3c); - static uint64_t pf = UINT64_MAX; if (proot && pw > 0 && phh > 0 && pf != fr) { pf = fr; { static int dd; const char *dn; if (!dd && (dn = getenv("DM_UI_DUMP")) && atomic_load(&g_taps_base) && fr >= atomic_load(&g_taps_base) + (getenv("DM_UI_DUMP_AT") ? atoi(getenv("DM_UI_DUMP_AT")) : 45)) { dd = 1; ui_dump(proot, 0, dn, 0, pm); } } int tm = ui_touch_mode(); if (tm) ui_wtap_pump(pm, proot, pw, phh); if (tm) ui_long_pump(); ui_target_pump(pm, fr); if (tm) ui_use_pump(); if (tm) ui_buy_pump(pw, phh); ui_item_pump(proot, pw, phh); ui_ptr_pump(pm, proot, pw, phh); if (tm) ui_drag_pump(pm, proot, pw, phh); UI_MOUSE_ITEM_PUMPS(pm, proot, pw, phh); { int lu = atomic_load(&g_load_up); dm_uiscreen_set_ingame(ui_panel(proot, "HUDPanel") && !(lu < 0 ? ui_find(proot, "LoadScreenPanel", 0) != 0 : lu)); } ui_safe_pump(pm, proot, fr); ui_lift_pump(proot, fr); ui_trove_tabs_pump(pm, proot, fr); ui_minimap_pump(pm, proot, pw, phh, fr); ui_map_pump(pm); ui_map_geom_pump(pm, proot); ui_boss_pct_pump(pm, proot); ui_npcdlg_pump(proot); ui_map_center(pm, proot, *(volatile int32_t *)(pm->base + 0x2d5c748)); if (tm) ui_bind_pump(proot, fr); if (tm) swaptab_pump(proot); if (tm) ui_mercpg_pump(pm, proot, fr); ui_widestash_pump(proot); mv_audit_pump(proot, fr); ui_pages_pump(pm, proot); } } } + static uint64_t pf = UINT64_MAX; if (proot && pw > 0 && phh > 0 && pf != fr) { pf = fr; { static int dd; const char *dn; if (!dd && (dn = getenv("DM_UI_DUMP")) && atomic_load(&g_taps_base) && fr >= atomic_load(&g_taps_base) + (getenv("DM_UI_DUMP_AT") ? atoi(getenv("DM_UI_DUMP_AT")) : 45)) { dd = 1; ui_dump(proot, 0, dn, 0, pm); } } int tm = ui_touch_mode(); if (tm) ui_wtap_pump(pm, proot, pw, phh); if (tm) ui_long_pump(); ui_target_pump(pm, fr); if (tm) ui_use_pump(); if (tm) ui_buy_pump(pw, phh); ui_item_pump(proot, pw, phh); ui_ptr_pump(pm, proot, pw, phh); if (tm) ui_drag_pump(pm, proot, pw, phh); UI_MOUSE_ITEM_PUMPS(pm, proot, pw, phh); { int lu = atomic_load(&g_load_up); dm_uiscreen_set_ingame(ui_panel(proot, "HUDPanel") && !(lu < 0 ? ui_find(proot, "LoadScreenPanel", 0) != 0 : lu)); } ui_safe_pump(pm, proot, fr); ui_lift_pump(proot, fr); ui_note_dock_pump(proot); ui_trove_tabs_pump(pm, proot, fr); ui_minimap_pump(pm, proot, pw, phh, fr); ui_map_pump(pm); ui_map_geom_pump(pm, proot); ui_boss_pct_pump(pm, proot); ui_npcdlg_pump(proot); ui_map_center(pm, proot, *(volatile int32_t *)(pm->base + 0x2d5c748)); if (tm) ui_bind_pump(proot, fr); if (tm) swaptab_pump(proot); if (tm) ui_mercpg_pump(pm, proot, fr); ui_widestash_pump(proot); mv_audit_pump(proot, fr); ui_pages_pump(pm, proot); } } } if (atomic_load(&g_fe_name_open) && atomic_load(&g_ut_phase) == 2) { // 起名页:点输入框(底板 / 文本框)= 重新弹系统键盘,不发鼠标点击 | naming page: tapping the input box (backplate / text box) = pop up the system keyboard again, no mouse click is sent module_t *nm = main_module(); uint64_t nroot = 0; if (nm) memcpy(&nroot, nm->base + 0x2f05458, 8); uint64_t pn = nroot ? ui_find(nroot, "CharacterCreateNamePanel", 0) : 0; if (pn && nm) { int32_t w = *(int32_t *)(nm->base + 0x211da38), h = *(int32_t *)(nm->base + 0x211da3c); uint64_t v = atomic_load(&g_ut_xy); @@ -2677,6 +2744,10 @@ void dm_ui_on_uimsg(const char *cat, const char *act, const char *arg) { if (!strcmp(cat, "PanelManager") && arg && !strcmp(arg, "LoadScreenPanel") && (!strcmp(act, "OpenPanel") || !strcmp(act, "UnloadPanel"))) { int up = act[0] == 'O'; atomic_store(&g_load_up, up); module_t *pm = main_module(); uint64_t root = 0; if (pm) memcpy(&root, pm->base + 0x2f05458, 8); if (root) { dm_uiscreen_set_ingame(!up && ui_find(root, "HUDPanel", 0)); g_lift_next = 0; ui_lift_pump(root, 0); } } + { int ex = (!strcmp(cat, "PausePanelMessage") && !strcmp(act, "ExitGame")) || (!strcmp(cat, "FrontEndNavigation") && !strcmp(act, "ToFrontEnd")), + ld = !strcmp(cat, "PanelManager") && arg && !strcmp(arg, "LoadScreenPanel") && !strcmp(act, "OpenPanel"); + if (ex || ld) { module_t *pm = main_module(); uint64_t root = 0; if (pm) memcpy(&root, pm->base + 0x2f05458, 8); if (ex) g_nd_hold = 1; // 提示框停靠:停靠条件结束,当场写回原值 | notice docking: the docking condition ended, write the original value back on the spot + note_dock_restore(root, ex ? (act[0] == 'E' ? "保存并退出" : "回到前端") : "读取画面(切场景)"); } } if (!strcmp(cat, "QuestLogPanelMessage") && !strcmp(act, "DialogueFinished")) atomic_store(&g_speech_end, dm_guest_frame()); if (!strcmp(cat, "PanelManager")) ui_panel_note(act, arg ? arg : ""); if (!strcmp(cat, "ChroniclePanelMessage") && !strcmp(act, "ToggleChildPanel") && arg && arg[0]) { int c = 0; while (c < 8 && g_chr_child[c][0] && strcmp(g_chr_child[c], arg)) c++; if (c < 8 && !g_chr_child[c][0]) strlcpy(g_chr_child[c], arg, sizeof g_chr_child[c]); } diff --git a/dm/host/dm_i18n_tab.h b/dm/host/dm_i18n_tab.h index 84c3bbb..8664861 100644 --- a/dm/host/dm_i18n_tab.h +++ b/dm/host/dm_i18n_tab.h @@ -262,7 +262,8 @@ static const struct { const char *k, *zh, *en; } k_dm_i18n[] = { { "dmKbRiftFast", "最快 %d:%02d", "Best Time %d:%02d" }, { "dmKbRiftMsGot", "首通奖励已领取", "First clear reward claimed" }, { "dmKbRiftTotal", "最高 %d 层", "Best Level: %d" }, - { "dmCloudConflict", "iCloud 共享仓库两边不一致,已保留本机,请联系我们", "iCloud shared stash mismatch: kept this device. Please contact us" }, + { "dmCloudConflict", "iCloud:两台设备的共享仓库各有内容,已用云端那份,本机那份已完整保存待并回", "iCloud: both devices had shared stash contents. Using the cloud copy; this device's copy is kept to be merged back" }, + { "dmCloudCharConflict", "iCloud:角色 %s 两台设备各有一份,已用云端那份,本机那份已备份", "iCloud: both devices had character %s. Using the cloud copy; this device's copy is backed up" }, { "dmRiftHudTitle", "秘境", "Rift" }, { "dmRiftHudDone", "第 %d 层完成", "Level %d complete" }, { "dmRiftHudLate", "第 %d 层超时", "Level %d overtime" }, diff --git a/dm/host/dm_rift.c b/dm/host/dm_rift.c index 10f912a..33f7bc4 100644 --- a/dm/host/dm_rift.c +++ b/dm/host/dm_rift.c @@ -304,7 +304,7 @@ int dm_rift_hud(dm_rift_hud_t *o) { o->secs_left = st == ST_DONE ? g_left_done : RIFT_SECS - el; o->done = st == ST_DONE; o->guardian = K.guard != 0 && !atomic_load(&K.guard_dead); o->inc = K.inc; o->next = next_tier(); o->overtime = rift_overtime(); // 第二行写哪一句在这里定(一个来源):超时优先说明「已超时」,守护者在场就把「击败守护者」合进同一句;两位以上带(已倒 / 总数) // Which sentence the second line shows is decided here (one source): overtime takes priority with "Overtime", and when Guardians are present "Slay the Rift Guardian" is merged into the same sentence; with two or more it carries (fallen / total) - o->gdead = atomic_load(&K.gdead); o->gtotal = atomic_load(&K.gtotal); o->wave = K.wave + 1; o->nwave = K.nwave; + o->gdead = atomic_load(&K.gdead); o->gtotal = atomic_load(&K.gtotal); o->wave = K.wave + 1 - (K.wave_t != 0); o->nwave = K.nwave; o->goal = o->overtime ? (o->guardian ? (o->gtotal >= 2 ? 5 : 4) : 3) : o->guardian ? (o->gtotal >= 2 ? 2 : 1) : 0; return 1; } @@ -895,7 +895,37 @@ static void rift_quest_obs(const uint64_t *regs) { static int n; if (n++ < 6 || (g_suseq_id && *(uint32_t *)(uintptr_t)(mon + 8) == g_suseq_id)) LOG("秘境:怪物类号 %u(单位 id %u)死在秘境图里,不走原版任务事件", *(uint32_t *)(uintptr_t)(mon + 4), *(uint32_t *)(uintptr_t)(mon + 8)); ((uint64_t *)(uintptr_t)regs)[1] = (uint64_t)(uintptr_t)stand_in; } +// 90 层起秘境图里不放普通预设怪(90 层以上没有其它怪、全是特殊精英)。观测门 OBS_PRESET_SPAWN 挂在「放一条预设单位记录」main+0x7ce800(游戏, 房间, 记录) 的入口, +// 它只由房间激活时的放预设单位 0x7ce930 调(8 处);我们自己刷守护者 / 闯入首领直接调 0x7ce630,刷特殊精英调 0x69b310,都不经过这里。 +// 记录 {+0 模式, +4 类号, +8 / +0x24 房内坐标, +0x18 地图 AI, +0x20 单位类型 1 怪 / 2 物件};怪的类号分三段(原版 0x6910d0): +// 小于 monstats 行数(表 +0xf98)= 普通怪,再往上超级独特行数(表 +0x10b8)以内 = 超级独特,再往上 = monplace 放置码。 +// 拦的:会打人 / 刷怪的普通怪(投石车 497–500、观察员 516–519、邪恶小屋 528);放置码里的随机怪群、金怪群、冠军、营地、group25–100 等。 +// 留的:超级独特;门 / 墙 / 攻城塔 / 监狱门 / 陷阱 / 友军野蛮人(场景,拿掉会改通行);放置码 0 空、4 / 14–16 NPC、5 血鸦、29–31 尸体。 +// 拦法:x2 换成一份类号 −1 的副本,原版 0x6910d0 入口自己返回空(tbnz w2, #31),0x7ce630 / 0x7ce800 随之走各自的收尾,不碰任何状态;原记录不动。 +// From level 90, no ordinary preset monsters are placed in rift maps (above level 90 there are no other monsters, only special elites). Observation gate OBS_PRESET_SPAWN is hooked at the entry of "place one preset unit record" main+0x7ce800(game, room, record); +// it is only called by the room-activation preset placement 0x7ce930 (8 call sites); our own Guardian / invading boss spawns call 0x7ce630 directly and special elite spawns call 0x69b310, neither goes through here. +// Record {+0 mode, +4 class id, +8 / +0x24 in-room coordinates, +0x18 map AI, +0x20 unit type 1 monster / 2 object}; monster class ids fall into three ranges (original 0x6910d0): +// below the monstats row count (table +0xf98) = ordinary monster, above that within the super unique row count (table +0x10b8) = super unique, above that = monplace placement code. +// Blocked: ordinary monsters that attack or spawn monsters (catapults 497–500, watchers 516–519, evil hut 528); in the placement codes, random monster packs, unique packs, champions, camps, group25–100 etc. +// Kept: super uniques; doors / walls / siege towers / prison doors / traps / friendly barbarians (scenery; removing them changes passability); placement codes 0 empty, 4 / 14–16 NPCs, 5 Blood Raven, 29–31 corpses. +// How it is blocked: x2 is replaced by a copy with class id -1, the original 0x6910d0 entry returns null by itself (tbnz w2, #31), 0x7ce630 / 0x7ce800 then go through their own exits without touching any state; the original record is untouched. +static void rift_preset_obs(const uint64_t *regs) { + static uint8_t stand_in[0x40]; static int n_blk; uint64_t G = regs[0], room = regs[1], rec = regs[2]; int st = atomic_load(&K.st); + if ((st != ST_RUN && st != ST_DONE) || !G || G != L.G || !room || !rec || *(int32_t *)(uintptr_t)(rec + 0x20) != 1 || !hi_on("pre", 90)) return; + uint64_t ex = rd(room + 0x18), lv = ex ? rd(ex + 0x90) : 0; int lvno = lv ? *(int32_t *)(uintptr_t)(lv + 0x1f8) : 0; if (!in_rift_map(lvno)) return; + uint64_t T = tables(G); if (!T) return; int N = *(int32_t *)(uintptr_t)(T + 0xf98), S = *(int32_t *)(uintptr_t)(T + 0x10b8), c = *(int32_t *)(uintptr_t)(rec + 4), blk; + if (c < 0) return; + if (c < N) blk = (c >= 497 && c <= 500) || (c >= 516 && c <= 519) || c == 528; + else if (c < N + S) blk = 0; + else { int p = c - N - S; blk = !(p == 0 || p == 4 || p == 5 || (p >= 14 && p <= 16) || (p >= 29 && p <= 31)); } + if (!blk) return; + memcpy(stand_in, (const void *)(uintptr_t)rec, 0x30); *(int32_t *)(stand_in + 4) = -1; *(uint64_t *)(stand_in + 0x18) = 0; + ((uint64_t *)(uintptr_t)regs)[2] = (uint64_t)(uintptr_t)stand_in; + static int all = -1; if (all < 0) all = getenv("DM_RIFT_TEST_TOUR") != NULL; + if (n_blk++ < 6 || n_blk % 100 == 0 || all) LOG("秘境:第 %d 层 关卡 %d 不放预设怪 类号 %d(%s %d;monstats %d 行、超级独特 %d 行;本进程累计 %d 条)", K.tier, lvno, c, c < N ? "普通" : "放置码", c < N ? c : c - N - S, N, S, n_blk); +} static void rift_gates(void) { static int once; if (once) return; once = 1; + if (gate_obs_present(OBS_PRESET_SPAWN)) gate_obs_set(OBS_PRESET_SPAWN, rift_preset_obs); else LOG("秘境:这个产物不带放预设单位的门(r44 起的 touch 产物才带),90 层起普通预设怪照原版放"); if (gate_obs_present(OBS_QUEST_KILL)) gate_obs_set(OBS_QUEST_KILL, rift_quest_obs); else LOG("秘境:这个产物不带任务事件的门(r36 起的 touch 产物才带),秘境里的首领死亡会走原版任务"); if (gate_obs_present(OBS_LEVEL_WARP)) gate_obs_set(OBS_LEVEL_WARP, rift_level_obs); else LOG("秘境:这个产物不带出口换目的地的门(只有 r36 起的 touch 产物带),走出口会先落到原版的下一关、再由每拍检测送进下一张图"); } @@ -1411,6 +1441,22 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { if (il && t % 250 == 0) { int n = 0, mn = 999, mx = 0; for (int bb = 0; bb < 128; bb++) for (uint64_t it = rd(G + 0x2e30 + 8 * bb); it; it = rd(it + 0x158)) { uint64_t d = rd(it + 0x10); if (!d || *(uint32_t *)(uintptr_t)(it + 0xc) != 3) continue; int v = *(int32_t *)(uintptr_t)(d + 0x38); n++; if (v < mn) mn = v; if (v > mx) mx = v; } LOG("秘境:测试读数 拍 %u 地上物品 %d 件,物品等级 %d–%d", t, n, n ? mn : 0, mx); } } + // 测试开关 DM_RIFT_TEST_TOUR=1:秘境进行中每秒用原版传送把人放到本图房间链里的下一间(中心附近的空地),整张图的房间都激活一遍——验「90 层起不放普通预设怪」要整图的读数 + // Test switch DM_RIFT_TEST_TOUR=1: during a rift, every second the original teleport puts the player in the next room of this map's room chain (open ground near the centre), so every room of the whole map gets activated - verifying "no ordinary preset monsters from level 90" needs readings from the whole map + { static int tour = -1, k; if (tour < 0) tour = getenv("DM_RIFT_TEST_TOUR") != NULL; + if (tour && t % 25 == 0 && in_rift_map(lv) && atomic_load(&K.st) == ST_RUN) { uint64_t lvp = level_of(player), r = dm_level_rooms(lvp); int i = 0, nr = 0; + for (uint64_t q = r; q && nr < 2000; q = rd(q + 0x48)) nr++; + for (; r && i < k % (nr ? nr : 1); r = rd(r + 0x48)) i++; + if (r) { int32_t pos[2] = { *(int32_t *)(uintptr_t)(r + 0x60) * 5 + *(int32_t *)(uintptr_t)(r + 0x68) * 5 / 2, *(int32_t *)(uintptr_t)(r + 0x64) * 5 + *(int32_t *)(uintptr_t)(r + 0x6c) * 5 / 2 }; + uint64_t rs = room_load(G, lvp, pos[0], pos[1]), rr = rs ? free_spot(G, rs, pos) : 0; int ok = rr && dm_teleport(B, G, player, rr, pos[0], pos[1]); + static int ln; if (ln++ < 3 || k == nr - 1) LOG("秘境:测试逐间跳 第 %d / %d 间 → %d,%d %s", k + 1, nr, pos[0], pos[1], ok ? "成" : "不成"); } + { static uint32_t seen[8192]; static int scls[8192], sfl[8192], ns; /* 逐间跳全程:本图出现过的怪按单位 id 去重累计;走完一轮后 5 秒按类号报 | over the whole room-by-room jump: monsters seen in this map are accumulated, de-duplicated by unit id; 5 seconds after a full round, reported by class id */ + for (int b = 0; b < 128; b++) for (uint64_t v = rd(G + 0x2230 + 1 * 0x400 + 8 * b); v; v = rd(v + 0x158)) { uint32_t id = *(uint32_t *)(uintptr_t)(v + 8); if (any_level(v) != lv) continue; int q = 0; for (; q < ns && seen[q] != id; q++) {} + if (q == ns && ns < 8192) { uint64_t md = rd(v + 0x10); uint32_t mo = *(uint32_t *)(uintptr_t)(v + 0xc); seen[ns] = id; scls[ns] = *(int32_t *)(uintptr_t)(v + 4); sfl[ns] = (md ? *(uint8_t *)(uintptr_t)(md + 0x1a) : 0) | (mo == 0 || mo == 12 ? 0x100 : 0); ns++; } } + if (k == nr + 5) { static int cl[1024], cn[1024], cf[1024]; int nc = 0; + for (int q = 0; q < ns; q++) { int j2 = 0; for (; j2 < nc && cl[j2] != scls[q]; j2++) {} if (j2 == nc && nc < 1024) { cl[nc] = scls[q]; cn[nc] = cf[nc] = 0; nc++; } if (j2 < 1024) { cn[j2]++; cf[j2] |= sfl[q]; } } + LOG("[逐间跳读数] 关卡 %d 出现过的怪 %d 只、%d 种", lv, ns, nc); for (int j2 = 0; j2 < nc; j2++) LOG("[逐间跳读数] 类号 %d ×%d 标志 0x%03x(0x100 = 有一只首次见到时已是死的)", cl[j2], cn[j2], cf[j2]); } } + k++; } } // 测试开关 DM_RIFT_TEST_PULL=1:每 3 秒用原版传送 0x7cc530 把人放到一只还活着的敌对怪(客户端认的)旁边——脚本按主攻击键就能一路打(验计分 / 守护者) // Test switch DM_RIFT_TEST_PULL=1: every 3 seconds use the original game's teleport 0x7cc530 to put the player next to a still-living hostile monster (as recognized by the client) -- a script only has to press the main attack button to fight all the way through (verifies scoring / guardian) { static int pull = -1; if (pull < 0) pull = getenv("DM_RIFT_TEST_PULL") != NULL; @@ -1539,7 +1585,7 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { guard_wave(G, player, t, lowhp); } // 两波之间:上一波全倒 WAVE_GAP 拍后刷下一波 // Between two waves: WAVE_GAP ticks after the previous wave is all down, the next wave is spawned - if (K.wave_t && t >= K.wave_t + WAVE_GAP && atomic_load(&K.st) == ST_RUN) { K.wave_t = 0; guard_wave(G, player, t, lowhp); } + if (K.wave_t && t >= K.wave_t + WAVE_GAP && atomic_load(&K.st) == ST_RUN) { guard_wave(G, player, t, lowhp); K.wave_t = 0; } /* 先刷、再清「两波之间」:顶部条在两波之间报刚打完的那一波,刷出来才跳到下一波 | spawn first, then clear "between two waves": between waves the top bar reports the wave just finished, and moves to the next wave only once it has spawned */ // 测试替身 DM_RIFT_TEST_DUMMY=<每秒点数>:对在场的每位守护者按固定输出扣当前生命(留 1 点,由随从补最后一下)——人物不用真打,用来出「承伤每秒峰值」的相对值 // Test stand-in DM_RIFT_TEST_DUMMY=: deduct current life from every Guardian present at a fixed output (leaving 1 point, with a minion delivering the last hit) - the character does not have to fight for real; used to obtain relative values of the "per-second peak of damage taken" { static int dps = -1; if (dps < 0) { const char *e = getenv("DM_RIFT_TEST_DUMMY"); dps = e ? atoi(e) : 0; } @@ -1552,7 +1598,7 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { if (K.guard && !atomic_load(&K.guard_dead)) { int alive = 0, deadn = 0; uint64_t last = 0; for (int i = 0; i < 3; i++) { if (!K.guards[i]) continue; uint64_t u = find_unit(G, 1, K.guards[i]); if (!u) { alive++; continue; } /* 不在单位表里(房间卸载):不当它死了 | not in the unit table (room unloaded): do not treat it as dead */ uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); if (m == 0 || m == 12) { last = u; deadn++; static uint32_t said[3]; if (said[i] != K.guards[i]) { said[i] = K.guards[i]; LOG("秘境:拍 %u 守护者死亡(类号 %d id %u)", t, K.gcls[i], K.guards[i]); } } else alive++; } - atomic_store(&K.gdead, deadn); - if (!alive && last && K.wave + 1 < K.nwave) { memset(K.guards, 0, sizeof K.guards); K.wave++; K.wave_t = t; atomic_store(&K.gdead, 0); atomic_store(&K.gtotal, 0); LOG("秘境:拍 %u 守护者第 %d 波全部倒下,%d 拍后刷第 %d 波", t, K.wave, WAVE_GAP, K.wave + 1); } + if (!K.wave_t) atomic_store(&K.gdead, deadn); /* 两波之间 guards 已清空,计数留着上一波的(全倒)给顶部条 | between two waves guards is already cleared; the count keeps the previous wave's (all down) for the top bar */ + if (!alive && last && K.wave + 1 < K.nwave) { memset(K.guards, 0, sizeof K.guards); K.wave++; K.wave_t = t; LOG("秘境:拍 %u 守护者第 %d 波全部倒下,%d 拍后刷第 %d 波", t, K.wave, WAVE_GAP, K.wave + 1); } else if (!alive && last) { atomic_store(&K.guard_dead, 1); LOG("秘境:拍 %u 守护者全部死亡 → 结算", t); finish(G, player, last); } } } diff --git a/dm/host/tests/native_write_scan.py b/dm/host/tests/native_write_scan.py index 0f3eb62..a13bc96 100644 --- a/dm/host/tests/native_write_scan.py +++ b/dm/host/tests/native_write_scan.py @@ -41,18 +41,32 @@ def vis_scan(text, where): # 直接写可见位的行;在带守卫的函数 # Third check (position guard): in dm_cursor.c, writing a widget rectangle (+0x70 x, +0x74 y, +0x78 width, +0x7c height) is allowed only in mv_offset (original-game widgets, allow list + record original value + must write back) # and in ui_move_ours (only names starting with Touch). Two forms are recognized: a direct *(int32_t *)(... + 0x7?) = ...; or, within the same function, first taking int32_t *name = (int32_t *)(... + 0x7?) and then writing name[k] = / *name = RECT_OK = ('mv_offset', 'ui_move_ours') -RECT_PTR = re.compile(r'int32_t\s*\*\s*(\w+)\s*=\s*\(int32_t\s*\*\)\s*\([^;]*\+\s*0x7[0-9a-c]\b') -RECT_DIRECT = re.compile(r'\*\s*\(int32_t\s*\*\)\s*\([^)]*\+\s*0x7[0-9a-c]\)\s*=(?!=)') -def rect_scan(text, where): +RECT_OFFS = ['0x7%x' % i for i in range(13)] # 0x70–0x7c +# 原版控件字段写入的登记例外(一项一行:文件、字段、只许在哪些函数里写、理由)。名单外的函数写这些字段一律报红 +# Registered exceptions for writes to original widget fields (one per line: file, field, which functions may write it, reason). Writes to these fields from functions not on the list are always red +NATIVE_FIELD_OK = { + ('dm_cursor.c', '0x19c'): (('ui_note_dock_pump', 'note_dock_restore'), 'NotificationPanel 停靠目标 y:原版只在重排时按布局抄进、滑入滑出按它插值写 +0x74;' + '改 +0x74 会被动画每帧盖回(试过)。原值我们自己记、停靠条件一结束当场写回(面板关 / 读取画面 / 保存并退出 / 回到前端)'), + ('dm_cursor.c', '0x74'): (('note_dock_snap',), 'NotificationPanel 矩形 y:停靠目标切换(开 / 关面板)那一刻框已停稳(原版停稳不写坐标)才写成新目标一次,动画期不写;写后下一帧核'), +} +def field_write_scan(text, where, off, ok, what): + ptr = re.compile(r'(?:int32_t|,)\s*\*\s*(\w+)\s*=\s*\(int32_t\s*\*\)\s*\([^;)]*\+\s*%s' % off) # 基址只看本括号:同一行别的变量读别的字段不算;逗号后的第二个声明也认 | the base only counts within its own parentheses: other variables on the same line reading other fields do not count; a second declaration after a comma is recognised too + direct = re.compile(r'\*\s*\(int32_t\s*\*\)\s*\([^)]*\+\s*%s\)\s*=(?!=)' % off) bad, fn, ptrs = [], None, set() for no, line in enumerate(text.split('\n'), 1): m = re.match(r'(?:static\s+)?\w+\s+\*?(\w+)\(', line) if m and not line.startswith(' '): fn, ptrs = m.group(1), set() code = line.split('//', 1)[0] - for pm in RECT_PTR.finditer(code): ptrs.add(pm.group(1)) - code = RECT_PTR.sub('', code) # 声明那一处(int32_t *名 = …)本身不算写 | the declaration itself (int32_t *name = ...) does not count as a write - hit = RECT_DIRECT.search(code) or any(re.search(r'(?])(?:\*\s*%s|%s\s*\[\s*\d\s*\])\s*=(?!=)' % (q, q), code) for q in ptrs) - if hit and fn not in RECT_OK: bad.append('%s:%d 在 %s 里直接写了控件矩形(原版控件走 mv_offset、我们的走 ui_move_ours):%s' % (where, no, fn, line.strip()[:120])) + for pm in ptr.finditer(code): ptrs.add(pm.group(1)) + code = ptr.sub('', code) # 声明那一处(int32_t *名 = …)本身不算写 | the declaration itself (int32_t *name = ...) does not count as a write + hit = direct.search(code) or any(re.search(r'(?])(?:\*\s*%s|%s\s*\[\s*\d\s*\])\s*=(?!=)' % (q, q), code) for q in ptrs) + if hit and fn not in ok: bad.append('%s:%d 在 %s 里直接写了%s:%s' % (where, no, fn, what, line.strip()[:120])) + return bad +def rect_scan(text, where): + exc = [off for (f, off) in NATIVE_FIELD_OK if where.startswith(f) and off in RECT_OFFS] # 矩形字段的登记例外:从矩形扫描里拿出来,按例外单独扫 | registered exceptions for rectangle fields: taken out of the rectangle scan and scanned separately as exceptions + bad = field_write_scan(text, where, '(?:%s)\\b' % '|'.join(o for o in RECT_OFFS if o not in exc), RECT_OK, '控件矩形(原版控件走 mv_offset、我们的走 ui_move_ours)') + for (f, off), (fns, why) in NATIVE_FIELD_OK.items(): + if where.startswith(f): bad += field_write_scan(text, where, re.escape(off) + r'\b', fns + (RECT_OK if off in RECT_OFFS else ()), '原版控件字段 +%s(登记例外只许在 %s 里写)' % (off, ' / '.join(fns))) return bad def pages_pump(src): @@ -66,6 +80,9 @@ def main(): if not scan(' vu_show(vu_find(bk, "grid", 2), 0);', 'selftest') or scan(' vu_show(vu_find(vt, "TouchV_Back", 0), 1); // "grid" 只在注释里', 'selftest') \ or not vis_scan('static void f(uint64_t w) {\n *(uint8_t *)(w + 0x50) = 0;\n}', 'selftest') or vis_scan('static void ui_show_ours(uint64_t w, int on) {\n *(uint8_t *)(w + 0x50) = 1;\n}\n if (*(uint8_t *)(w + 0x50) == 1) x();', 'selftest') \ or not rect_scan('static void f(uint64_t w) {\n int32_t *r = (int32_t *)(w + 0x70); r[0] = 5;\n}', 'selftest') or not rect_scan('static void g(uint64_t w) {\n *(int32_t *)(w + 0x74) = 3;\n}', 'selftest') \ + or rect_scan('static void ui_note_dock_pump(uint64_t w) {\n int32_t *t = (int32_t *)(w + 0x19c), h = *(int32_t *)(w + 0x7c); *t = h;\n}', 'dm_cursor.c') \ + or not rect_scan('static void n(uint64_t w) {\n int32_t *t = (int32_t *)(w + 0x19c); *t = 1;\n}', 'dm_cursor.c') \ + or not rect_scan('static void n2(uint64_t w) {\n int32_t *t = (int32_t *)(w + 0x19c), *ry = (int32_t *)(w + 0x74); *ry = 1;\n}', 'dm_cursor.c') \ or rect_scan('static void k(uint64_t w) {\n int32_t *rx = (int32_t *)(w + 0x70), ww = *(int32_t *)(w + 0x78); if (*rx) x();\n}\nstatic void mv_offset(uint64_t w) {\n int32_t *v = (int32_t *)(w + 0x70); *v = 1;\n}\nstatic int h(float *r) {\n r[0] = 1.0f; int x = *(int32_t *)(w + 0x70); return x;\n}', 'selftest'): print('✗ native_write_scan 自检失败:该报的没报或不该报的报了'); return 1 print('✓ native_write_scan 自检:违规行会报红、注释里的名字不算') diff --git a/dm/host/tests/t_cloudsync.c b/dm/host/tests/t_cloudsync.c index 713bb64..7a8fb08 100644 --- a/dm/host/tests/t_cloudsync.c +++ b/dm/host/tests/t_cloudsync.c @@ -10,6 +10,8 @@ #include int dm_cloud_sync(const char *save, const char *cloud, const char *bak, const char *statef, int allow_down, uint64_t now_ms, int (*ready)(const char *unit)); int dm_cloud_conflict_take(void); +int dm_cloud_char_conflict_take(char *out, size_t n); +int dm_cloud_inbox_add(const char *save, const char *statef, const char *pack); #if __has_include("../stash_seed.h") // 公开仓库不带这份预置(它是游戏生成的一份存档的字节):不在时跳过用到它的 ⑱ ⑲ 两组 | the public repository does not ship this seed (it is the bytes of a save the game generated): when it is absent, the two groups that use it, 18 and 19, are skipped #include "../stash_seed.h" #define T_HAVE_STASH_SEED 1 @@ -41,6 +43,10 @@ static void put_d2i(const char *dev, int items, int chron, long sec) { put_bin(dev, "save/ModernSharedStashSoftCoreV2/ModernSharedStashSoftCoreV2.d2i", b, 68 + l2, sec); } static void put_vault(const char *dev, int n, long sec) { uint8_t b[8] = { 'S', 'W', 'V', 'T', 1, 0, (uint8_t)n, 0 }; put_bin(dev, "save/ModernSharedStashSoftCoreV2.swvault", b, 8, sec); } +static int inbox_n(const char *dev) { char d[1024]; path(d, dev, "save/_cloudinbox"); DIR *dp = opendir(d); struct dirent *e; int n = 0; while (dp && (e = readdir(dp))) n += e->d_name[0] != '.'; if (dp) closedir(dp); return n; } +static int inbox_has(const char *dev, const char *f) { // 收件箱里有没有哪个条目带这个文件 | whether any inbox entry carries this file + char d[1024]; path(d, dev, "save/_cloudinbox"); DIR *dp = opendir(d); struct dirent *e; int k = 0; struct stat st; + while (dp && (e = readdir(dp))) { if (e->d_name[0] == '.') continue; char p[1400]; snprintf(p, sizeof p, "%s/%s/%s", d, e->d_name, f); k |= !stat(p, &st); } if (dp) closedir(dp); return k; } static int d2i_items(const char *dev, const char *rel) { char p[1024]; path(p, dev, rel); FILE *f = fopen(p, "rb"); if (!f) return -1; uint8_t b[70]; size_t n = fread(b, 1, 70, f); fclose(f); return n >= 67 ? b[66] : -1; } int main(void) { @@ -139,20 +145,24 @@ int main(void) { CHECK(S3("H", 0) == 0 && d2i_items("H", D2I) == 0, "⑪ 新设备运行中首次同步:不传不改(不能拿空仓库盖云端)"); CHECK(S3("H", 1) == 1 && d2i_items("H", D2I) == 5 && get("H", "save/ModernSharedStashSoftCoreV2.swvault"), "⑪ 新设备启动首次同步:以云端为准,拿到 5 件与编年史仓库"); CHECK(count_bak("H", "_stash-") == 1, "⑪ 新设备本来那份空仓库进备份"); - CHECK(!dm_cloud_conflict_take(), "⑪ 正常首次同步不算冲突"); + CHECK(!dm_cloud_conflict_take() && inbox_n("H") == 0, "⑪ 本机那份是新建空档:不进收件箱、不提示"); put_d2i("G", 6, 400, 6000); CHECK(S3("G", 0) == 1, "⑭ G 编年史变长(400)照常上传"); CHECK(S3("H", 1) == 1 && d2i_items("H", D2I) == 6, "⑭ H 启动拿到 G 的新版"); put_d2i("H", 0, 148, 7000); // H 上的共享仓库不知为何变空(编年史 148、0 件),时刻更新 | the shared stash on H somehow became empty (chronicle 148, 0 items), with a newer timestamp - CHECK(S3("H", 0) == 0, "⑬ H 运行中要上传变空的那份:拦下"); - CHECK(dm_cloud_conflict_take() == 1, "⑬ 拦下记冲突(进局弹提示)"); + CHECK(S3("H", 0) == 0, "⑬ H 运行中要上传变空的那份:分叉,运行中不动"); + CHECK(!dm_cloud_conflict_take(), "⑬ 运行中不提示(不再永久拦)"); CHECK(S3("G", 1) == 0 && d2i_items("G", D2I) == 6, "⑬ 云端没被盖:G 仍是 6 件"); + CHECK(S3("H", 1) == 1 && d2i_items("H", D2I) == 6, "⑬ H 启动:云端为现行版,拿回 6 件"); + CHECK(inbox_n("H") == 1 && dm_cloud_conflict_take() == 1, "⑬ 本机那份共享仓库空了、但编年史仓库侧文件还有 3 件:进收件箱、提示一次"); put_d2i("H", 7, 500, 7500); CHECK(S3("H", 0) == 1, "⑮ H 正常玩:编年史 500 上传"); put_d2i("G", 6, 450, 7600); // G 没同步到 H 的 500 就自己写了 450(两边都改,G 后写) | G wrote 450 itself without having synced H's 500 (both sides changed, G wrote later) - CHECK(S3("G", 0) == 0, "⑮ G 运行中要拿编年史 450 盖云端的 500:拦下"); - CHECK(S3("G", 1) == 0 && d2i_items("G", D2I) == 6, "⑮ G 启动:云端 500 比本机 450 时刻早但编年史长——按后写赢会上传,被拦;本机不动"); - CHECK(dm_cloud_conflict_take() == 1, "⑮ 记冲突"); + CHECK(S3("G", 0) == 0, "⑮ G 运行中要拿编年史 450 盖云端的 500:分叉,运行中不动"); + CHECK(S3("G", 1) == 1 && d2i_items("G", D2I) == 7, "⑮ G 启动:云端(7 件、500)为现行版"); + CHECK(inbox_n("G") == 1 && inbox_has("G", "mine.pack") && inbox_has("G", "base.pack"), "⑮ G 本机那份(6 件、450)进收件箱,带上次同步的基准(6 件、400)"); + CHECK(dm_cloud_conflict_take() == 1, "⑮ 收进收件箱:进局提示一次"); + CHECK(S3("G", 1) == 0 && inbox_n("G") == 1, "⑮ 再启动:一致、无动作、不再收(不是永久状态)"); { char p3[1024]; path(p3, "H", "save/ModernSharedStashSoftCoreV2.swvault"); unlink(p3); } put_d2i("H", 7, 500, 8000); - CHECK(S3("H", 0) == 0 && dm_cloud_conflict_take() == 1, "⑬ 编年史仓库侧文件没了(云端有 3 件):拦下"); + CHECK(S3("H", 0) == 0 && !dm_cloud_conflict_take(), "⑬ 编年史仓库侧文件没了(云端有 3 件):分叉,运行中不动"); put_vault("H", 0, 8100); put_d2i("H", 0, 500, 8100); CHECK(S3("H", 0) == 1 && !dm_cloud_conflict_take(), "⑯ 正常玩法:共享仓库物品取空、编年史仓库取空(文件还在,0 件),编年史没变短——照常上传"); // ⑰ rf3 那个形状:云端专家仓库 2 件、编年史还是新建的 148;本机这份被换成游戏新建的空档(0 件、148),状态记录还在、云端没变 = 走「只本机改了」的上传 @@ -161,8 +171,8 @@ int main(void) { #define S4(dev, down) (path(s3, dev, "save"), path(b3, dev, "bak"), path(t3, dev, "state"), dm_cloud_sync(s3, cd, b3, t3, down, 0, NULL)) put_d2i("J", 2, 148, 1000); CHECK(S4("J", 1) == 1, "⑰ 准备:J 上传 2 件、编年史 148 的仓库"); put_d2i("J", 0, 148, 2000); dm_cloud_conflict_take(); - CHECK(S4("J", 0) == 0 && dm_cloud_conflict_take() == 1, "⑰ 运行中要拿新建空档(0 件、148)盖 2 件的那份:拦下"); - CHECK(S4("J", 1) == 0, "⑰ 启动时同样拦下(不上传)"); + CHECK(S4("J", 0) == 0 && !dm_cloud_conflict_take(), "⑰ 运行中要拿新建空档(0 件、148)盖 2 件的那份:分叉,运行中不动"); + CHECK(S4("J", 1) == 1 && d2i_items("J", D2I) == 2 && inbox_n("J") == 0, "⑰ 启动:拿回云端 2 件;本机空档不进收件箱"); put_d2i("J", 0, 300, 3000); CHECK(S4("J", 0) == 1, "⑰ 编年史长过新建大小的仓库取空:照常上传"); // ⑱ rf3 真形状:云端专家仓库是另一台的预置(stash_seed.h),本机还没有专家仓库档(启动同步跑在写预置之前)→ 不拦、不弹;本机写了预置后上传也不拦 // (18) The real rf3 shape: the cloud hardcore stash is another device's preset (stash_seed.h), and the local device has no hardcore stash file yet (startup sync runs before the preset is written) -> not blocked, no prompt; uploading after the local device writes the preset is not blocked either @@ -180,7 +190,7 @@ int main(void) { { uint8_t big[700]; memset(big, 0, sizeof big); uint32_t l1 = 68, l2 = 300; memcpy(big, "\x55\xaa\x55\xaa", 4); memcpy(big + 16, &l1, 4); memcpy(big + 64, "JM", 2); big[66] = 9; memcpy(big + 68, "\x55\xaa\x55\xaa", 4); memcpy(big + 84, &l2, 4); big[132] = 0xc0; put_bin("K", HC, big, 68 + 300, 5000); CHECK(S5("K", 0) == 1, "⑲ 准备:专家仓库有 9 件、编年史 300 上传"); } put_bin("K", HC, g_stash_seed, sizeof g_stash_seed, 6000); - CHECK(S5("K", 0) == 0 && dm_cloud_conflict_take() == 1, "⑲ 本机变回预置要盖 9 件的那份:拦下"); + CHECK(S5("K", 0) == 0 && !dm_cloud_conflict_take(), "⑲ 本机变回预置要盖 9 件的那份:分叉,运行中不动"); #undef HC #undef S5 } @@ -192,6 +202,61 @@ int main(void) { #undef D2I #undef S3 } + // ⑳ 同名角色(iCloud 离线冲突第 3 条):云端有 P 的 Foo(1000 秒);新设备 Q 从没同步过、离线建了同名 Foo(5000 秒)和 Bar → 首次同步:Foo 用云端那份、 + // 本机 Foo 整份进备份 Foo-5000000、记下名字待进局提示(取一次后清空);Bar 上传、不进提示 + // (20) Same-name character (iCloud offline conflict item 3): the cloud has P's Foo (1000 s); new device Q has never synced and created a Foo with the same name (5000 s) and a Bar offline -> first sync: Foo uses the cloud copy, + // the local Foo goes into the backup whole as Foo-5000000, the name is recorded for a notice after entering a run (cleared once taken); Bar is uploaded and not part of the notice + { char c6[1024], s6[1024], b6[1024], t6[1024]; snprintf(c6, sizeof c6, "%s/cloud6", R); mkdir(c6, 0755); char nm[256]; + #define S6(dev, down) (path(s6, dev, "save"), path(b6, dev, "bak"), path(t6, dev, "state"), dm_cloud_sync(s6, c6, b6, t6, down, 0, NULL)) + put("P", "save/Foo/Foo.d2s", "fooP", 1000); CHECK(S6("P", 1) == 1, "⑳ 准备:P 上传 Foo"); + dm_cloud_char_conflict_take(nm, sizeof nm); + put("Q", "save/Foo/Foo.d2s", "fooQ", 5000); put("Q", "save/Bar/Bar.d2s", "barQ", 5000); + CHECK(S6("Q", 1) == 2, "⑳ Q 首次同步:Foo 下载、Bar 上传,共 2 个动作"); + CHECK(get("Q", "save/Foo/Foo.d2s") && !strcmp(get("Q", "save/Foo/Foo.d2s"), "fooP"), "⑳ Q 的 Foo 应换成云端那份 fooP"); + CHECK(count_bak("Q", "Foo-5000000") == 1, "⑳ Q 本机那份 Foo 应进备份 Foo-5000000"); + CHECK(dm_cloud_char_conflict_take(nm, sizeof nm) == 1 && !strcmp(nm, "Foo"), "⑳ 记下同名角色 Foo 待提示,实为「%s」", nm); + CHECK(dm_cloud_char_conflict_take(nm, sizeof nm) == 0, "⑳ 取过一次后清空"); + CHECK(S6("Q", 1) == 0 && dm_cloud_char_conflict_take(nm, sizeof nm) == 0, "⑳ 再同步无动作、不再提示"); + #undef S6 + } + // ㉑ iCloud 离线冲突三个场景(第一笔口径:两台设备的全部数据都在——仓库或收件箱,且没有永久拦截)。老设备 A:10 件、编年史 600,已上云 + // (21) Three iCloud offline conflict scenarios (first-step criterion: all data of both devices is kept - in the stash or the inbox - and nothing is blocked forever). Old device A: 10 items, chronicle 600, already in the cloud + { char c7[1024], s7[1024], b7[1024], t7[1024], cq[1024]; snprintf(c7, sizeof c7, "%s/cloud7", R); mkdir(c7, 0755); snprintf(cq, sizeof cq, "%s/cloud7q", R); mkdir(cq, 0755); + #define S7(dev, cl, down) (path(s7, dev, "save"), path(b7, dev, "bak"), path(t7, dev, "state"), dm_cloud_sync(s7, cl, b7, t7, down, 0, NULL)) + #define D2I7 "save/ModernSharedStashSoftCoreV2/ModernSharedStashSoftCoreV2.d2i" + put_d2i("A7", 10, 600, 1000); CHECK(S7("A7", c7, 1) == 1, "㉑ 准备:A 上传 10 件"); + dm_cloud_conflict_take(); + // ① 新设备 N 没登录时离线玩(3 件、编年史 300),之后登录、启动同步 + // (1) new device N plays offline while not signed in (3 items, chronicle 300), then signs in and syncs at launch + put_d2i("N7", 3, 300, 5000); + CHECK(S7("N7", c7, 1) == 1 && d2i_items("N7", D2I7) == 10, "㉑① N 首次同步:仓库是云端的 10 件"); + CHECK(inbox_n("N7") == 1 && inbox_has("N7", "mine.pack") && !inbox_has("N7", "base.pack") && dm_cloud_conflict_take() == 1, "㉑① N 本机 3 件进收件箱(没有基准)、提示一次"); + CHECK(S7("N7", c7, 1) == 0 && inbox_n("N7") == 1 && d2i_items("A7", D2I7) == 10, "㉑① 再启动无动作(没有永久状态);A 的 10 件不动"); + // ② 新设备 M 离线期间编年史比云端长(900 > 600):原先永久拦住,现在同样云端为现行版 + 收件箱 + // (2) new device M's chronicle grew longer than the cloud's while offline (900 > 600): previously blocked forever, now likewise the cloud is the current version + inbox + put_d2i("M7", 3, 900, 5000); + CHECK(S7("M7", c7, 0) == 0 && inbox_n("M7") == 0, "㉑② M 运行中:不动、不收(等启动)"); + CHECK(S7("M7", c7, 1) == 1 && d2i_items("M7", D2I7) == 10 && inbox_n("M7") == 1 && dm_cloud_conflict_take() == 1, "㉑② M 启动:仓库 10 件,本机 3 件进收件箱"); + CHECK(S7("M7", c7, 1) == 0 && S7("M7", c7, 0) == 0 && inbox_n("M7") == 1, "㉑② 再启动、再运行中都无动作:不是永久拦截"); + // ③ 新设备 Q 登录但离线、看到的云端是空的(cloud7q),上传了 3 件;联网后 iCloud 拿 Q 的包当现行版(盖到 cloud7 上) + // (3) new device Q signs in but is offline and sees an empty cloud (cloud7q), uploads 3 items; once online, iCloud takes Q's pack as the current version (overwriting cloud7) + put_d2i("Q7", 3, 300, 5000); CHECK(S7("Q7", cq, 1) == 1, "㉑③ 准备:Q 往看着是空的云端传了 3 件"); + char sp[1300], dp[1300], keep[1300]; snprintf(sp, sizeof sp, "%s/_stash.pack", cq); snprintf(dp, sizeof dp, "%s/_stash.pack", c7); snprintf(keep, sizeof keep, "%s/a_old.pack", R); + rename(dp, keep); { FILE *fi = fopen(sp, "rb"), *fo = fopen(dp, "wb"); char buf[8192]; size_t k; while ((k = fread(buf, 1, sizeof buf, fi)) > 0) fwrite(buf, 1, k, fo); fclose(fi); fclose(fo); } + CHECK(S7("A7", c7, 1) == 1 && d2i_items("A7", D2I7) == 3, "㉑③ A 启动:云端(Q 的 3 件)为现行版"); + CHECK(inbox_n("A7") == 1 && inbox_has("A7", "base.pack") && dm_cloud_conflict_take() == 1, "㉑③ A 本机 10 件进收件箱,带上次同步的基准"); + CHECK(S7("A7", c7, 1) == 0 && inbox_n("A7") == 1, "㉑③ 再启动无动作"); + // iCloud 冲突版本:A 那台读出被换下的旧版本(a_old.pack,10 件)收进收件箱;只有预置 / 空档的版本不收 + // iCloud conflict version: device A reads out the replaced old version (a_old.pack, 10 items) and stores it in the inbox; a version with only the preset / an empty save is not stored + { char ts7[1100]; path(s7, "A7", "save"); path(ts7, "A7", "state"); + CHECK(dm_cloud_inbox_add(s7, ts7, keep) == 0 && inbox_n("A7") == 2 && dm_cloud_conflict_take() == 1, "㉑③ 冲突版本(10 件)收进收件箱"); + put_d2i("E7", 0, 148, 100); { char e7[1100], ee[1100], et[1100], pk[1300]; path(e7, "E7", "save"); path(ee, "E7", "bak"); path(et, "E7", "state"); char ce[1300]; snprintf(ce, sizeof ce, "%s/cloud7e", R); mkdir(ce, 0755); + dm_cloud_sync(e7, ce, ee, et, 1, 0, NULL); snprintf(pk, sizeof pk, "%s/_stash.pack", ce); + CHECK(dm_cloud_inbox_add(s7, ts7, pk) == 0 && inbox_n("A7") == 2, "㉑③ 空档的冲突版本:没东西,不收"); } + CHECK(dm_cloud_inbox_add(s7, ts7, "/nonexistent.pack") == -1, "㉑③ 读不了的冲突版本:返回 -1"); } + #undef S7 + #undef D2I7 + } printf("t_cloudsync: %d 项,%d 失败\n", checks, fails); return fails != 0; } diff --git a/dm/i18n/ui_text.tsv b/dm/i18n/ui_text.tsv index cfc416d..7d6ddae 100644 --- a/dm/i18n/ui_text.tsv +++ b/dm/i18n/ui_text.tsv @@ -260,7 +260,8 @@ dmKbRiftMsAll 已全部领取 All claimed 积分牌秘境项(dm_kills.c) dmKbRiftFast 最快 %d:%02d Best Time %d:%02d 积分牌秘境项(dm_kills.c);英文:拟(同积分牌 dmKbTimes 的 Best);暗黑 3 排行榜列名为 Time Spent(意思是用时,不是最快),未采用,留 Best Time dmKbRiftMsGot 首通奖励已领取 First clear reward claimed 积分牌秘境项(dm_kills.c);英文:拟 dmKbRiftTotal 最高 %d 层 Best Level: %d 积分牌秘境项(dm_kills.c);英文:拟 -dmCloudConflict iCloud 共享仓库两边不一致,已保留本机,请联系我们 iCloud shared stash mismatch: kept this device. Please contact us iCloud 同步冲突提示(diag.c) +dmCloudConflict iCloud:两台设备的共享仓库各有内容,已用云端那份,本机那份已完整保存待并回 iCloud: both devices had shared stash contents. Using the cloud copy; this device's copy is kept to be merged back iCloud 共享仓库分叉提示(diag.c;本机那份在待合并收件箱) +dmCloudCharConflict iCloud:角色 %s 两台设备各有一份,已用云端那份,本机那份已备份 iCloud: both devices had character %s. Using the cloud copy; this device's copy is backed up iCloud 首次同步同名角色提示(diag.c,%s = 角色名) dmRiftHudTitle 秘境 Rift 秘境顶部进度条(dm_rift_hud.m,UIKit) dmRiftHudDone 第 %d 层完成 Level %d complete 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:见 dmRiftSayDoneBoth dmRiftHudLate 第 %d 层超时 Level %d overtime 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:拟 diff --git a/dm/ios/Sources/cloud_ios.m b/dm/ios/Sources/cloud_ios.m index 0014944..33371a5 100644 --- a/dm/ios/Sources/cloud_ios.m +++ b/dm/ios/Sources/cloud_ios.m @@ -21,6 +21,7 @@ #if TARGET_OS_IPHONE #import #endif +#import #include #include #include @@ -28,6 +29,8 @@ #include "hle.h" int dm_cloud_sync(const char *save, const char *cloud, const char *bak, const char *statef, int allow_down, uint64_t now_ms, int (*ready)(const char *unit)); +int dm_cloud_inbox_add(const char *save, const char *statef, const char *pack); uint64_t dm_cloud_pack_stamp(const char *pack); +int dm_cloud_bak_pack(const char *bak, const char *unit, const char *pack, const char *why); void dm_cloud_char_conflict_note(const char *unit); int dm_custom_get(const char *key); extern void (*g_dm_save_commit_hook)(const char *commit_dir); @@ -54,10 +57,39 @@ static int pending_downloads(int start) { // 还没下载好的包数;start } return n; } +// iCloud 自己的同名文件冲突(两台各写了一份同名包、系统挑了一份当现行版,其余成「未解决的冲突版本」;iCloud 离线冲突第 1 条)。启动同步前在文件协调里做: +// 共享仓库:每个冲突版本收进待合并收件箱(dm_cloud_inbox_add,现行版照常走同步); +// 角色:包头时刻(游戏最后写它的时刻)最新的那份当现行版(不是系统挑的就换上去),其余整份进备份,记名进局提示。 +// 全部收好才把冲突标成已解决并删掉其余版本;有一份收不进就都留着,下次启动再来(宁可多留不丢)。 +// iCloud's own same-name file conflict (two devices each wrote a same-name pack, the system picked one as the current version and the rest became "unresolved conflict versions"; iCloud offline conflict item 1). Done inside file coordination before the launch sync: +// shared stash: each conflict version is stored in the to-merge inbox (dm_cloud_inbox_add; the current version goes through sync as usual); +// character: the copy with the newest pack header timestamp (the moment the game last wrote it) becomes the current version (swapped in if it is not the one the system picked), the rest go into the backup whole, and the name is recorded for a notice after entering a run. +// Only once everything is stored are the conflicts marked resolved and the other versions deleted; if any one cannot be stored, all are kept and tried again at the next launch (better keep extra than lose any). +static void take_conflicts(NSString *save) { + NSFileManager *fm = NSFileManager.defaultManager; + for (NSString *f in [fm contentsOfDirectoryAtPath:g_cloud error:nil] ?: @[]) { + if ([f hasPrefix:@"."] || ![f hasSuffix:@".pack"]) continue; + NSURL *u = [NSURL fileURLWithPath:[g_cloud stringByAppendingPathComponent:f]]; NSArray *vs = [NSFileVersion unresolvedConflictVersionsOfItemAtURL:u]; + if (!vs.count) continue; + NSString *unit = f.stringByDeletingPathExtension; int bad = 0; + if ([unit isEqualToString:@"_stash"]) { for (NSFileVersion *v in vs) bad |= dm_cloud_inbox_add(save.fileSystemRepresentation, g_state.fileSystemRepresentation, v.URL.fileSystemRepresentation) != 0; } + else { uint64_t best = dm_cloud_pack_stamp(u.fileSystemRepresentation); NSFileVersion *win = nil; + for (NSFileVersion *v in vs) { uint64_t t = dm_cloud_pack_stamp(v.URL.fileSystemRepresentation); if (t > best) { best = t; win = v; } } + if (win) { NSError *e = nil; bad |= dm_cloud_bak_pack(g_bak.fileSystemRepresentation, unit.UTF8String, u.fileSystemRepresentation, "iCloud 冲突里较旧的现行版") != 0; + if (!bad && ![win replaceItemAtURL:u options:0 error:&e]) { bad = 1; LOG("【红】iCloud 同步:%s 换上较新的冲突版本失败 %s", unit.UTF8String, e.localizedDescription.UTF8String ?: "?"); } } + for (NSFileVersion *v in vs) if (v != win) bad |= dm_cloud_bak_pack(g_bak.fileSystemRepresentation, unit.UTF8String, v.URL.fileSystemRepresentation, "iCloud 冲突版本") != 0; + if (!bad) dm_cloud_char_conflict_note(unit.UTF8String); } + if (bad) { LOG("【红】iCloud 同步:%s 有 %lu 个冲突版本没收好,留着下次启动再来", unit.UTF8String, (unsigned long)vs.count); continue; } + for (NSFileVersion *v in vs) v.resolved = YES; + NSError *e = nil; if (![NSFileVersion removeOtherVersionsOfItemAtURL:u error:&e]) LOG("iCloud 同步:%s 冲突已标解决,删其余版本没成(%s),不影响", unit.UTF8String, e.localizedDescription.UTF8String ?: "?"); + LOG("iCloud 同步:%s 的 %lu 个 iCloud 冲突版本已收好(%s)", unit.UTF8String, (unsigned long)vs.count, [unit isEqualToString:@"_stash"] ? "进待合并收件箱" : "最新的当现行版、其余进备份"); + } +} static int run_sync(NSString *save, int down) { // 在文件协调里做:iCloud 守护进程同时在写这个目录时不会读到半个文件 | Done inside file coordination: half-written files are not read while the iCloud daemon is writing this directory at the same time __block int r = -1; NSError *err = nil; [[[NSFileCoordinator alloc] initWithFilePresenter:nil] coordinateWritingItemAtURL:[NSURL fileURLWithPath:g_cloud] options:NSFileCoordinatorWritingForMerging error:&err byAccessor:^(NSURL *u) { - (void)u; r = dm_cloud_sync(save.fileSystemRepresentation, g_cloud.fileSystemRepresentation, g_bak.fileSystemRepresentation, g_state.fileSystemRepresentation, down, now_ms(), pack_ready); }]; + (void)u; if (down) take_conflicts(save); // 只在启动那次(运行中 save 是提交快照目录,不放收件箱) | only at launch (while running, save is the commit snapshot directory; nothing goes into the inbox) + r = dm_cloud_sync(save.fileSystemRepresentation, g_cloud.fileSystemRepresentation, g_bak.fileSystemRepresentation, g_state.fileSystemRepresentation, down, now_ms(), pack_ready); }]; if (err) LOG("【红】iCloud 同步:文件协调失败 %s", err.localizedDescription.UTF8String); return r; } @@ -187,6 +219,51 @@ static int migrate_v2(NSString *docs, double deadline) { LOG("【红】iCloud 同步:旧目录 saves 复制到 saves_v2 失败(%s),本次不同步", (err ?: e2).localizedDescription.UTF8String ?: "?"); return 0; } LOG("iCloud 同步:旧目录 saves 已复制到 saves_v2(%d 个文件,清单 %lu 个包),旧目录留给旧包用", copied, (unsigned long)[list componentsSeparatedByString:@"\n"].count - 1); return 1; } +// 从没同步成功过的设备先看清云端再同步(iCloud 离线冲突第 2 条):新设备断网首启时,系统还没把云端条目列到本机,云端目录看着是空的—— +// 照常同步会把本机全部当「云端没有」上传(离线时新建的穷共享仓库联网后与云端同名包冲突、盖掉云端),迁移那步还会新建一个空的 saves_v2。 +// 所以状态文件里一条记录都没有(从没同步成功过)时,先问系统的云端条目列表(NSMetadataQuery,收集完成才算数): +// 列出了包 → 这些包都已出现在本机目录(下好的或 iCloud 占位)才同步;列表是空的 → 网络通才同步(世界上第一台设备就是这种)。都不满足 = 本次整套跳过,下次启动再看。 +// 列表收集完成在断网时怎么表现、联网时空列表会不会滞后,要真机断网跑才知道(排给池);滞后漏过去的那种由冲突版本合并兜住(第 1 条)。 +// 测试开关 DM_TEST_ICLOUD_FIRST=<收集完成>,<列出几个>,<到本机几个>,<网络通>:不问系统,按给的值判(Mac 宿主 / 本地测试云端验分支用) +// A device that has never synced successfully first gets a clear view of the cloud before syncing (iCloud offline conflict item 2): on a new device's first launch without network, the system has not yet listed the cloud entries locally, so the cloud directory looks empty - +// a normal sync would upload everything local as "not in the cloud" (a poor shared stash newly created offline conflicts with the cloud's same-name pack once online and overwrites the cloud), and the migration step would also create an empty saves_v2. +// So when the state file has no record at all (never synced successfully), first ask the system for its list of cloud entries (NSMetadataQuery, counted only once gathering has finished): +// packs are listed -> sync only once all of them have appeared in the local directory (downloaded or as iCloud placeholders); the list is empty -> sync only if the network is reachable (the very first device in the world is like this). Neither = skip the whole thing this time and look again at the next launch. +// How gathering completes with no network, and whether an empty list can lag behind when online, can only be known by running on a device with the network cut (queued for the pool); the lagging case that slips through is covered by merging conflict versions (item 1). +// Test switch DM_TEST_ICLOUD_FIRST=,,,: does not ask the system and decides by the given values (for verifying the branches on the Mac host / a local test cloud) +static int never_synced(NSString *statef) { + NSString *t = [NSString stringWithContentsOfFile:statef encoding:NSUTF8StringEncoding error:nil]; + return !t || [t rangeOfString:@"\t"].location == NSNotFound; +} +static int first_listing_ok(double deadline) { + int got = 0, listed = 0, present = 0, net = 0; const char *e = getenv("DM_TEST_ICLOUD_FIRST"); + if (e) { sscanf(e, "%d,%d,%d,%d", &got, &listed, &present, &net); } + else { + __block int g = 0, n = 0, pr = 0; dispatch_semaphore_t sem = dispatch_semaphore_create(0); __block NSMetadataQuery *q = nil; __block id obs = nil; + dispatch_async(dispatch_get_main_queue(), ^{ // 元数据查询要挂在有运行循环的线程上 | the metadata query has to be attached to a thread with a run loop + q = [NSMetadataQuery new]; q.searchScopes = @[NSMetadataQueryUbiquitousDocumentsScope]; + q.predicate = [NSPredicate predicateWithFormat:@"%K LIKE '*.pack'", NSMetadataItemFSNameKey]; + obs = [NSNotificationCenter.defaultCenter addObserverForName:NSMetadataQueryDidFinishGatheringNotification object:q queue:nil usingBlock:^(NSNotification *note) { (void)note; + [q disableUpdates]; n = (int)q.resultCount; NSFileManager *fm = NSFileManager.defaultManager; + for (NSUInteger i = 0; i < q.resultCount; i++) { NSURL *u = [[q resultAtIndex:i] valueForAttribute:NSMetadataItemURLKey]; if (!u) continue; + NSString *ph = [u.path.stringByDeletingLastPathComponent stringByAppendingPathComponent:[NSString stringWithFormat:@".%@.icloud", u.lastPathComponent]]; + if ([fm fileExistsAtPath:u.path] || [fm fileExistsAtPath:ph]) pr++; } + g = 1; [q stopQuery]; [NSNotificationCenter.defaultCenter removeObserver:obs]; dispatch_semaphore_signal(sem); }]; + if (![q startQuery]) { [NSNotificationCenter.defaultCenter removeObserver:obs]; dispatch_semaphore_signal(sem); } }); + double left = deadline - CFAbsoluteTimeGetCurrent(); if (left < 0.5) left = 0.5; + if (dispatch_semaphore_wait(sem, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(left * NSEC_PER_SEC)))) + dispatch_async(dispatch_get_main_queue(), ^{ if (q) { [q stopQuery]; if (obs) [NSNotificationCenter.defaultCenter removeObserver:obs]; } }); + got = g; listed = n; present = pr; + __block int ns = 0; dispatch_semaphore_t ps = dispatch_semaphore_create(0); nw_path_monitor_t m = nw_path_monitor_create(); + nw_path_monitor_set_queue(m, dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0)); + nw_path_monitor_set_update_handler(m, ^(nw_path_t path) { if (!ns) { ns = nw_path_get_status(path) == nw_path_status_satisfied ? 1 : 2; dispatch_semaphore_signal(ps); } }); + nw_path_monitor_start(m); dispatch_semaphore_wait(ps, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC))); nw_path_monitor_cancel(m); net = ns == 1; + } + int ok = got && (listed ? present >= listed : net); + LOG("iCloud 同步:本机从没同步成功过,先看云端条目列表:收集%s、列出 %d 个包、已到本机 %d 个、网络%s → %s", got ? "完成" : "未完成", listed, present, net ? "通" : "不通", + ok ? "看清了,同步" : "没看清,本次不同步(不上传、不建 saves_v2),下次启动再看"); + return ok; +} void dm_cloud_boot(void) { const char *sv = getenv("DM_SAVE"), *sub = getenv("DM_TEST_ICLOUD_SUB"), *ldir = getenv("DM_TEST_ICLOUD_DIR"), *lroot = getenv("DM_TEST_ICLOUD_ROOT"); if (!sv) return; NSString *doc = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject; @@ -215,6 +292,7 @@ void dm_cloud_boot(void) { if (ldir) g_cloud = test_path(ldir); // 测试:本地目录当云端(没有 iCloud 权限的开发包也能验整条链) | Test: use a local directory as the cloud (a dev build without iCloud entitlement can also verify the whole chain) else if (sub) { NSURL *ct = container(limit); if (!ct) return; g_cloud = [[ct.path stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@(sub)]; } else { NSString *docs = test_path(lroot); if (!lroot) { NSURL *ct = container(limit); if (!ct) return; docs = [ct.path stringByAppendingPathComponent:@"Documents"]; } + if (never_synced([save stringByAppendingString:@".cloudstate"]) && (!lroot || getenv("DM_TEST_ICLOUD_FIRST")) && !first_listing_ok(t0 + limit)) return; if (!migrate_v2(docs, t0 + limit)) return; NSString *nw = [docs stringByAppendingPathComponent:@"saves_v2"]; if (!v2_ready(nw, [save stringByAppendingString:@".cloudv2ok"])) return; g_cloud = nw; } diff --git a/dm/ios/project.yml b/dm/ios/project.yml index d8684e3..28abc98 100644 --- a/dm/ios/project.yml +++ b/dm/ios/project.yml @@ -94,6 +94,7 @@ targets: dependencies: - target: RomfsDownloader # 苹果托管资源包要求的下载扩展(系统缺省实现) | Download extension required by Apple-hosted asset packs (system default implementation) - sdk: BackgroundAssets.framework + - sdk: Network.framework # iCloud 首次同步看网络通不通(cloud_ios.m first_listing_ok) | iCloud first sync checks whether the network is reachable (cloud_ios.m first_listing_ok) settings: PRODUCT_BUNDLE_IDENTIFIER: ${DM_BUNDLE_ID} ENABLE_USER_SCRIPT_SANDBOXING: NO # 构建前脚本「从游戏文件生成资源」要读工程外的 RomFS(沙盒里读不到) | The pre-build script 「从游戏文件生成资源」(Generate assets from game files) needs to read the RomFS outside the project (unreadable inside the sandbox) diff --git a/dm/ios/tools/gen_romfs_overlay.py b/dm/ios/tools/gen_romfs_overlay.py index a149308..c58839f 100644 --- a/dm/ios/tools/gen_romfs_overlay.py +++ b/dm/ios/tools/gen_romfs_overlay.py @@ -28,10 +28,14 @@ with tempfile.TemporaryDirectory() as t: nw=round((x1-x0)*k); nx=round(((x0+x1)/2-ref_w/2)*k)-1 # 系统提示框:整份自己写、不继承原版那份——原版带一个铺满的 Confirm 按钮(继承来的子控件删不掉),提示在屏上时它接住功能键和点击: # 按功能键 / 点它压着的地方都只是把提示关掉(面板开不了、下面的格子点不到)。触屏上提示到点自己消失,不要这个按钮 - # System notification: written entirely by ourselves, not inheriting the original game's one -- the original carries a full-cover Confirm button (an inherited child widget cannot be deleted), which catches the function key and taps while the notification is on screen: - # pressing the function key / tapping where it covers only dismisses the notification (the panel cannot open, the cells beneath cannot be tapped). On a touchscreen the notification disappears by itself when its time is up, so this button is not wanted + # 停靠高度 y −790(原版 −500;先前为让开经验条提到 −600,仍压着底栏上方那行「生命 / 法力」数值——数值位数多时字伸进框里,触屏版那行更高、直接叠在框中间): + # 框的下沿要高过数值行的上沿,触屏版需再上提约 173 单位、手柄版约 77 单位,取一个两版都让开的值。只改布局里的停靠位置,滑入滑出仍是游戏自己的动画 + # System notice box: written entirely by us, not inheriting the original - the original has a full-size Confirm button (inherited child widgets cannot be removed), which takes the function keys and taps while a notice is on screen: + # pressing a function key / tapping where it covers only dismisses the notice (panels cannot be opened, the cells below cannot be tapped). On touch the notice disappears by itself on time, and this button is not wanted + # Docking height y -790 (original -500; it was raised to -600 earlier to clear the experience bar, but still covered the "life / mana" numbers above the bottom bar - with many digits the text ran into the box, and the touch layout's row is higher and sat right in the middle of the box): + # the lower edge of the box has to be above the upper edge of the number row; the touch layout needs about 173 more units, the gamepad layout about 77, so one value that clears both is taken. Only the docking position in the layout changes; slide-in and slide-out are still the game's own animation note={'type':'NotificationPanel','name':'NotificationPanel', - 'fields':{'priority':9002,'notificationSeconds':5.0,'transitionSeconds':0.8,'rect':{'x':nx,'y':-600,'width':nw,'height':244},'anchor':{'x':0.5,'y':1.0}}, + 'fields':{'priority':9002,'notificationSeconds':5.0,'transitionSeconds':0.8,'rect':{'x':nx,'y':-790,'width':nw,'height':244},'anchor':{'x':0.5,'y':1.0}}, 'children':[{'type':'NineTileImageWidget','name':'NotificationBorder', 'fields':{'rect':{'x':0,'y':0,'width':nw,'height':244},'anchor':{'x':-0.5,'y':0.0},'filename':'PANEL/TooltipBorder/TooltipBorder','backgroundColor':[0.0,0.0,0.0,0.70],'tileScale':1}, 'children':[{'type':'TextBoxWidget','name':'Prompt','fields':{'fitToParent':True,'style':'$StyleNotification'}}]}]} @@ -68,9 +72,11 @@ with tempfile.TemporaryDirectory() as t: for rel,gd in (('controller/pauselayoutgardenhd.json',1),('controller/pauselayouthd.json',0)): # 手柄版暂停菜单:一键重开 / 切换难度 / 存放 / 分享诊断日志 | Controller pause menu: one-tap restart / change difficulty / Deposit / Share Diagnostics lp,lt=touch_layout.read_layout(romfs,rel); o=os.path.join(tpad,'pad_pause%d.json'%gd); open(o,'w',encoding='utf-8').write(touch_layout.pad_pause(lt,gd,share=not os.environ.get('DM_OVERLAY_MAC'))); PR[lp.lower()]=o # 大秘境面板(借「消息记录」面板外壳,touch_layout._rift_panel):手柄版同一份。少了它手柄模式点秘境门开出来的是空的原版消息记录面板、进不了秘境;手柄键在 dm_rift_ui.c - # Greater Rift panel (borrows the shell of the "Message Log" panel, touch_layout._rift_panel): the controller version uses the same one. Without it, - # tapping the Rift portal in controller mode opens an empty original Message Log panel and the Rift cannot be entered; the controller keys are in - # dm_rift_ui.c + # 手柄版的系统提示框:原版那份(停靠 y −500)下沿压着底栏上方那行「生命 / 法力」数值,数值位数多时字伸进框里。只把停靠位置上提 90 单位(下沿高过数值行),其余原样 + # Greater Rift panel (borrowing the shell of the "message log" panel, touch_layout._rift_panel): the same for the gamepad layout. Without it, tapping a rift door in gamepad mode opens the empty original message log panel and the rift cannot be entered; gamepad keys are in dm_rift_ui.c + # The gamepad layout's system notice box: in the original (docked at y -500) its lower edge sits on the "life / mana" numbers above the bottom bar, and with many digits the text runs into the box. Only the docking position is raised by 90 units (lower edge above the number row); everything else as in the original + lp,lt=touch_layout.read_layout(romfs,'controller/notificationpanelhd.json'); assert lt.count('"y": -500')==1, lp # 原版手柄版提示框的停靠位置应是 y -500(原包变了就停在这里) | the original gamepad notice box should dock at y -500 (if the original package changes, stop here) + o=os.path.join(tpad,'pad_notification.json'); open(o,'w',encoding='utf-8').write(lt.replace('"y": -500','"y": -590')); PR[lp.lower()]=o lp,lt=touch_layout.read_layout(romfs,'controller/messagelogpanelhd.json'); o=os.path.join(tpad,'pad_rift.json'); open(o,'w',encoding='utf-8').write(touch_layout._rift_panel(lt)[0]); PR[lp.lower()]=o PR.update(merc_slots.build_pad(romfs,tpad)) # 手柄版佣兵面板:同样加六个装备位 | Controller layout mercenary panel: likewise add six equipment slots # 手柄版职业选择页:八个职业的点击矩形同样改成按实际站位分的竖条(touch_layout.CLASS_STRIPS,原因见那里)。手柄用左右键选、原版没暴露; @@ -161,7 +167,7 @@ with tempfile.TemporaryDirectory() as t: # 手柄专用清单:手柄模式下不是原版字节的布局就这几份,一份不许多、一份不许少(改上面某一行时把相邻一行整行替掉过,商人页的刷新钮就从包里掉了) # Controller-only list: these are the only layouts that are not original bytes in controller mode, not one more and not one fewer (once, when a line above was edited, the adjacent line was replaced whole, and the vendor page's refresh button dropped out of the package) PAD_PAGES=('controller/bankexpansionlayouthd.json','controller/console/charactercreatepanelhd.json','controller/console/characteroptionspanelhd.json','controller/console/mainmenubuttonribbonhd.json','controller/console/mainmenupanelhd.json','controller/console/settingspanelhd.json','controller/console/switch/playerinventoryexpansionlayouthd.json','controller/console/videooptionspanelhd.json', - 'controller/controlleroverlayhd.json','controller/hirelinginventorypanelhd.json','controller/hudmonsterhealthhd.json','controller/messagelogpanelhd.json','controller/pauselayoutgardenhd.json','controller/pauselayouthd.json','controller/vendorpanellayouthd.json') + 'controller/controlleroverlayhd.json','controller/hirelinginventorypanelhd.json','controller/hudmonsterhealthhd.json','controller/messagelogpanelhd.json','controller/notificationpanelhd.json','controller/pauselayoutgardenhd.json','controller/pauselayouthd.json','controller/vendorpanellayouthd.json') if sorted(k[len(LAY):] for k in PADLAY)!=sorted(PAD_PAGES): raise SystemExit('gen_romfs_overlay:手柄专用布局与清单 PAD_PAGES 不一致:多 %s,少 %s' % (sorted(set(k[len(LAY):] for k in PADLAY)-set(PAD_PAGES)), sorted(set(PAD_PAGES)-set(k[len(LAY):] for k in PADLAY)))) def emit(repl, dst, tag, prebuilt=None): # repl → 覆盖层(新 .build.config + 一个新数据档)写到 dst/data | repl → overlay (a new .build.config + one new data archive) written to dst/data repl=to_touch(repl); repl.update(PADLAY) diff --git a/dm/tools/patch_nso.py b/dm/tools/patch_nso.py index 0a97409..780e4ce 100644 --- a/dm/tools/patch_nso.py +++ b/dm/tools/patch_nso.py @@ -642,6 +642,7 @@ if RULE_RUN and PRIVATE_GATES: obs.append((0x9da5b0, 20, "d104c3ff", "model yaw component per-frame update entry (x1 = argument block: +8 component, +0x20 -> +8 unit): the body turn speed is instance data on the component (+0x10..+0x2c min / max degrees per second for controller / mouse, +0x34 spring parameter); the host only reads them for the local player when a test switch is set")) obs.append((0x2f7664, 7, "6dbb23e9", "touch target rank: candidate compare entry (closure, unit, kind, s0=score); host raises Boss/elite score, native eligibility unchanged")) obs.append((0xb0d560, 21, "fc1a0fe8", "TooltipsPanel add-tooltip entry (panel, text, target position x2 / x3, style, text2): tooltips are immediate-mode (re-submitted by the hovered widget every frame and cleared after drawing, so the host cannot reach the record at its own time); on touch, in panel state, for an item the player just tapped, the host swaps the target position so the game lays the tooltip out beside the panel instead of over the item grid; everything else passes through unchanged")) + obs.append((0x7ce800, 22, "d100c3ff", "server place-one-preset-unit entry (game, room, record), only called by the room-activation preset loop 0x7ce930 (8 sites): in a rift game at tier 90+ on a rift map, for a monster record that is not a superunique and not scenery / NPC, the host swaps x2 to a copy whose class is -1 so 0x6910d0 takes its own early return (tbnz w2, #31) and nothing is spawned; the real record is untouched; rift guardian / invader / superunique spawns call 0x7ce630 / 0x69b310 directly and never pass here")) for off, oid, ow, why in obs: w = struct.unpack_from('