#245

Stash pages: up to 64 personal and 99 shared pages through stash_pages.txt, instant page turns, the item in hand survives a turn / 仓库页数:用 stash_pages.txt 调到个人 64 页、共享 99 页,翻页即时,手上物品翻页不丢

Openvertanomwants to merge intofrom

Fixes: the item held in the hand (cursor) disappearing / 修复:手上(光标上)的物品消失

While holding an item on the cursor, any time the host put items into one of the player's containers, the client dropped the held item: it vanished from the hand on screen while the server's cursor still held it, until a restart. The client's "item put into a container" handler (0x46a490) removes whatever is on the cursor, because in the original only "put down from the cursor" reaches it. Host placements reach it too:

  • personal stash page turns;
  • Chronicle withdraw;
  • the pouch;
  • iCloud merge-back.

A cut at 0x46a768 now removes the cursor item only when it is the item being put in. Separately, after a page turn to an empty page the held item's cursor picture is restored. This fix applies with the default settings too, not only with extra pages.

What changed

More stash pages, off by default. With no stash_pages.txt everything stays as the original: 5 personal pages and 5 shared pages, and the files are written byte-identical to what current builds write.

stash_pages.txt in the Custom settings folder (next to sw_custom.txt) turns it on:

personal_pages=10   # 1..64
shared_pages=20     # 5..99

Lowering either number never hides a page that still holds items.

  • Personal pages (dm_pages.c)
    • Up to 64 pages per character.
    • The side file .swpage keeps the old format while pages 6+ are empty, and switches to a newer format with the page count once they are used.
    • Page turns are instant.
  • Item in hand on a page turn
    • The cursor picture of a held item is restored after a turn to an empty page (dm_cursor.c, ui_pages_pump).
    • The client no longer drops the held item when the host puts items into a container: a cut at 0x46a768 only removes the cursor item if it is the one being put in. Before, turning a page could leave the item on the server's cursor but gone from the client's hand until a restart.
  • Shared pages (dm_sharedpages.c)
    • The entry of 0x1d2ce0, whose return value the 7 call sites add to the page count, becomes host call 0x91 (registered in hle.h). The host answers the extra page count: the larger of shared_pages and the pages the save already has. The original always returns 0, so the default answers 0.
  • Shared-page backup
    • While a shared stash has more than 5 pages, every commit also writes a full side copy <name>.swshared.
    • When the save is mounted and the .d2i has fewer pages than the copy (it was saved by a build with fewer pages), the missing pages are put back from it. The previous file is kept as .d2i.before-restore.
  • Docs: docs/STASH_PAGES.md / .zh-CN.md
    • how to turn it on;
    • what it changes in the saves and the mixed-build caveat;
    • how to go back to the original format.

Why

Collectors run out of stash space quickly on the 5 + 5 layout, and the only workaround was mule characters. This keeps the original layout as the default and makes more pages an explicit opt-in, with the save-format consequences written down.

Checks run

No game files needed:

  • python3 dm/i18n/scan_literals.py — I18N OK:中文字面量 474 条全在白名单(111 行),其余走中英表
  • python3 dm/ios/tools/dm_i18n.py --check — dm_i18n OK 486 条

Game files and a workspace prepared by ./setup.sh needed:

  • make -C dm/host/tests run — all pass, including the new t_pages (side file versions 1/2/3, read-only above the cap, never hiding a page with items) and t_sharedpages (backup and restore)
  • make -C dm/gfx/tests run — not run cleanly: t_defer_chain fails to link (_dm_cam_want_dir undefined) on untouched main too; this PR changes nothing under dm/gfx
  • make -C dm/ios/tests test — pass
  • dm/verify/regress.sh --fresh — partly: the fresh output is identical to the shared output, EQUIV main/sdk/subsdk0 OK (0 diverging sites) and GATEFN OK 门=126 失败=0. structck did not run, because this machine has no llvm-objcopy
  • cd dm/ios && ./run.sh build — 构建完成
  • dm/ios/tools/smoke_mac.sh 1 — not usable here: the free signing profile does not cover running the iOS package on the Mac (系统没有给 … 建容器)
  • dm/ios/tools/check_hud_gen.sh — HUDGEN OK:生成物没有入库

Anything else you ran, and on what:

  • Mac host, headless, on a copy of a save that already had 30 shared pages and no stash_pages.txt: 共享仓库:页数 30(设定 shared_pages=5,存档里已有 30 页…), the game entered with no 【红】 line. A save with extra pages keeps them under the default.
  • iPhone 13 Pro Max and Mac App: played for several days with 10 personal and 20–30 shared pages, turning pages with items in hand.

No game content is included.

🤖 Generated with Claude Code

https://claude.ai/code/session_016nAYaDVZyVnAezntgFc4Fx