fix(content): a game model of content.modelOf missing a Tex/ texture is warned of, not refused #3288
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3288
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/content-game-model-textures"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
content.modelOfrefused some of the game's own models. A mod giving adult Link Dark Link's model,changeActor({ actor: "Player_Adult", model: modelOf("Enemy_MiddleBoss_DarkLink") }), was left out at the start with"its materials name the texture ..., which neither the mod nor the game has". The content stage's model check looked up
each texture the model's materials name as a RomFS
Tex/file. Some of the game's own models name a texture that is noTex/file, and the game draws them anyway. The docs' own example,modelOf("Enemy_Octorok")on a pot, was refusedtoo: the Octorok's model names
Mt_Shell_Enemy_Octorok_Mtl, which is noTex/file either.On
main: put that call in a mod's content module and start the game. The log saysPlayer_Adult (a copy of Player_Adult) is not added: its model ...: its materials name the texture ..., and adult Link keeps his own model.With this change a missing texture no longer leaves out a game model: a
game-modelline in the pack spec, whichonly
modelOfwrites, served from the game's own bytes. A mod's file served at that model's path is checked as a mod'smodel is, textures and all. Instead the log warns of the first such texture at warn level, so the mod's author looks
at the actor in the game:
[warn] mods: <mod>: content: <actor>: its game model <file>'s materials name the texture <name>, which is no Tex/ file of the game's: the actor is added, .... The warning is worked out at every start, madepack or not, so a mod that serves the texture, turned on or off, is followed. The model's name, its skeleton against
the copied actor's model, and the bones its components, animations and trees use are still checked. A mod's own model
(
content.model) is checked as before. A game model's pack key has a mark of its own, so a pack made by this PR'searlier commits (where a mod's file at the path skipped the check too) is made and checked again; other packs keep
their keys. Read
game/crates/content/src/merge.rs(pack_checks,game_model_missing_textureand their caller)first.
The changeActor crash on Player_Adult is fixed on
mainalready, by #3172. AchangeActorofPlayer_Adultwithcomponents: { ModelInfo }androws: { ActorInfo }crashed the game when adult Link was made: a null write inBaseProcCreateAndDeleteThread, in a guest BYML reader. The crashing runs were on a build from before #3172. That packadds a member,
Component/ModelInfo/Player_Adult.engine__component__ModelInfo.bgyml, and grows the ActorParam, andthat build's size table had no entry for either. With #3172 each gets one (
entry 0 -> 12288and6232 -> 11136inthe log). The same pack, byte for byte (same cache key), now loads, and adult Link plays. This PR adds no test for that
crash; #3172's own tests cover a member new to a game pack and a grown BYML member.
The docs now say what a game run has shown for a changed game actor and for
modelOf: Preview notes indocs/modding/content.mdanddocs/dev/reference/content.md, and the model check indocs/modding/assets.md.Testing
Tested: Windows 11, RTX 5080, driver 621.47, this branch's runtime over the shared base of
mainde091ae29, thecastle-gatesave, switched to adult (longshot_ctl age adult), Hyrule Field:changeActor({ actor: "Player_Adult", model: modelOf("Enemy_MiddleBoss_DarkLink") }).On
mainthe actor is not added (the log line above) and adult Link is his usual self. On this branch it is added.Adult Link is drawn with Dark Link's model and runs with Link's animations. No crash in about 1,200 frames of play.
Compared with the game's own Dark Link, spawned beside him by a test script (
actors.spawn): the same body, the samedark material and the same red eyes (screenshots in the comment).
cc69b5986, the cached pack removed): the start's log has[warn] mods: local/dl-modelof: content: Player_Adult: its game model Model/Player_Adult_Dark.Player_Adult_Dark.bfres.zs's materials name the texture Body_Player_Adult_Dark_Mtl, which is no Tex/ file of the game's: the actor is added, ....7c8b4f867, child, Hyrule Field: the docs' example,actor({ id: "OctoPot", from: "Obj_Pot_A_01", model: modelOf("Enemy_Octorok") }), spawned in front of Link by a test script. It is added (with the warning, forMt_Shell_Enemy_Octorok_Mtl) and drawn with the Octorok's model and textures.components: { ModelInfo }androws: { ActorInfo }set to Dark Link's model): thepack loads (
Pack/Actor/Player_Adult.pack.zs <- ...in the log), adult Link is drawn with that model and runs. Nocrash.
cargo test -p content(288 passed),cargo clippy -p content --all-targets -- -D warningsandcargo fmt -p content --check, gnullvm. The new testa_game_models_textures_are_not_checked_its_bones_arefails on the test commit(
(0, 1)against(1, 0): the actor is refused) and passes with the fix. It also asserts the warn-level line, saidagain for the pack made before; no warning while a mod serves the texture and a warning again once that mod is off,
the pack the same; a mod's file served at the game model's path, with a texture nobody has, refused and not warned
of; and no warning for a game model whose textures are all
Tex/files. Each part fails with its line undone: thelog::warncall taken out (0warnings against1), the exemption by the spec's line alone ((1, 0)against(0, 1)), the warning only for a pack made now (1against2). Its last part (a game model lacking a bone thecopied actor's model has and a component names) is refused before and after.
mise run test(Windows, 12 at once): 883 passed, 18 failed, 55 skipped. 17 of the 18 fail onmainde091ae29too,run with
--exact:test_lifter(api,build-driverandmodtooldon't compile; content is not among them),test_aim_invert,test_cheat_items,test_dlssg,test_fallback_depth_hold,test_i18n_complete,test_input_background,test_nvn_bind_span,test_nvn_watch_tex,test_present_image_free,test_present_semaphores,test_present_held_image,test_present_acquire_ahead,test_settings_area_keys,test_thread_lookup,test_vk_draw_overhead_lean,test_walk_key. The 18th,test_renderer_new_handler, passeson its own here; in the full run it failed after 144 s while a game ran on the same PC.
Still to test:
assets/saves, and the debugteleport reaches only the temple's entrance): the fight with the Dark Link mod on. Expect the boss and the fight as
before: the mod changes only
Player_Adult's model names (a spawned Dark Link looked unchanged).Measurements
Verdict: the fix works: a game model of
modelOfis added and drawn. There is no speed to measure (the contentstage checks one file less for a game model at start-up, and nothing in a frame changes).
Setup: Windows 11, RTX 5080, driver 621.47; the castle-gate save, adult, Hyrule Field; a local mod with
changeActor({ actor: "Player_Adult", model: modelOf("Enemy_MiddleBoss_DarkLink") }); the log and a screenshot.de091ae29f80d6a29bPlayer_Adult (a copy of Player_Adult) is not added: its model ...: its materials name the texture ..., which neither the mod nor the game hasa_game_models_textures_are_not_checked_its_bones_are(0, 1)against(1, 0)Risks
A game model whose texture really is missing is now added, with the warning in the log, instead of left out. The game
then draws it as it draws any model whose texture it cannot find. A mod's own models are still refused. A revert
restores the refusal. Nothing changes for a player without a content mod that uses
modelOf.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
modelOf("Enemy_MiddleBoss_DarkLink") was refused ("its materials name the texture ..., which neither the mod nor the game has"), though the game draws Dark Link with that model: some of the game's own models name textures that are no Tex/ file. A game model's textures are the game's to find: the model check leaves them out for a game-model line, and still holds the model's name, its skeleton and the bones its actor uses. The docs say what a game run has now shown: adult Link (Player_Adult) changed in place to Dark Link's model, by modelOf and by components and rows, drawn and running with Link's animations. Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in game: Windows 11, RTX 5080, driver 621.47, this branch's runtime over main de091ae29's base, castle-gate save switched to adult, Hyrule Field. changeActor Player_Adult with modelOf(Enemy_MiddleBoss_DarkLink): added (refused on main), adult Link drawn with Dark Link's model and running with Link's animations, matching the game's own Dark Link spawned beside him. changeActor with components ModelInfo and rows ActorInfo (the call that crashed before #3172): the same pack loads, no crash.
Screenshots, Windows 11, RTX 5080, castle-gate save switched to adult, Hyrule Field, a local mod with changeActor({ actor: "Player_Adult", model: modelOf("Enemy_MiddleBoss_DarkLink") }):
de091ae29: the actor is refused (the texture check), adult Link keeps his own model.c99ae2747: adult Link drawn with Dark Link's model, running with Link's animations.3 and 4. This PR, with the game's own Dark Link spawned beside him by a test script (the boss on the left): the same body, material and red eyes.
cc69b5986: a game model's texture that is no Tex/ file no longer passes silently. The log warns of the first one at warn level, and a start that reuses the pack says it again (the pack's check record keeps it), so a mod's author looks at the actor in the game. Tested in the game: the start's log has the [warn] line naming Body_Player_Adult_Dark_Mtl; the test asserts the warning, its repeat and its absence when every texture is a Tex/ file.fix(content): a game model of content.modelOf skips the texture check, keeps the bone checksto fix(content): a game model of content.modelOf missing a Tex/ texture is warned of, not refused@review
Recommendation: Request changes. The fix allows the reported Dark Link model to load, but it also bypasses texture validation when another mod replaces that game model with its own file. Cached warnings can also become stale when texture-providing mods change.
A game model selected through modelOf is added despite a missing Tex/ file, with a warning; the model name and bone checks remain. The reported game run shows the intended result, at the cost of relaxing texture validation for model files supplied by other mods too.
Blocking (1): must change before merging.
game/crates/content/src/merge.rs:1401: The exemption follows the spec's game-model flag even when the model actually served is a mod's replacement. (more on the line) Do: Retain the source returned by served() and apply the exemption only to the game's own model bytes; validate a mod-supplied replacement as a mod model. Add a test with an overridden game-model path.Should fix (1): not blocking, but worth doing before merging.
game/crates/content/src/merge.rs:1299: The cached warning depends on texture availability, but the pack key does not include that availability and the check is skipped on a cache hit. (more on the line) Do: Recheck texture availability when reusing a game-model pack, or include the relevant texture state in the cached check's identity. Test both enabling and disabling a texture-providing layer across starts.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1 and L2.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. On Windows 11 with an RTX 5080, the author reports that main refused the Dark Link model while this branch drew adult Link with it for about 1,200 frames. The game-free test reportedly fails on main and passes on the branch.
Other systems: The change affects content-mod pack checks at startup on both Windows and Linux, including copied and changed actors. It does not change per-frame rendering; the copied-actor path and the Dark Link fight remain untested in game.
Switches: None.
Reviewed:
cc69b59864againstde091ae295: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the diff and commit messages, the changed model-check and cache code and its callers, and the relevant asset and content documentation. Skimmed the remainder of the large merge.rs file and modding documentation; no review-checklist.md or adjacent Tooling checkout was present. Read the supplied comments and CI status; screenshots and CI logs were not available in the closed network.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no build, test or project script was run. The author's reported Windows game run and content crate checks are evidence; CI remains in progress.
Overlaps and merge order: Unknown; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -1298,2 +1298,2 @@let note = if existed {// (checked when it was made: its note said again)let (note, warn) = if existed {// (checked when it was made: its note and its warning said again)L2 (should fix): The cached warning depends on texture availability, but the pack key does not include that availability and the check is skipped on a cache hit.
When: Start with a mod supplying a model's Tex/ file, then disable that mod without changing the actor pack or model. The same cached record has no warning, so the now-missing texture is not reported; enabling a texture mod after a warning was recorded conversely repeats a stale warning.
Do: Recheck texture availability when reusing a game-model pack, or include the relevant texture state in the cached check's identity. Test both enabling and disabling a texture-providing layer across starts.
@ -1381,0 +1398,4 @@clash_name(t.as_bytes()));}let has: Option<&mut dyn FnMut(&str) -> bool> = if *game { None } else { Some(&mut has) };L1 (blocking): The exemption follows the spec's game-model flag even when the model actually served is a mod's replacement.
When: If one mod uses modelOf for a game model and another overrides that Model/ path with a model whose material names a missing texture, served() returns the override but the game flag still disables the texture check. The actor is added with the broken replacement where it was previously refused.
Do: Retain the source returned by served() and apply the exemption only to the game's own model bytes; validate a mod-supplied replacement as a mod model. Add a test with an overridden game-model path.
The docs' own example, a pot copied from Obj_Pot_A_01 with modelOf("Enemy_Octorok"), spawned in Hyrule Field and drawn with the Octorok's model and textures. Co-Authored-By: Claude Opus 5.5 <[email protected]>Review answered (
7c8b4f867,6e337c7b4):pack_checkskeeps the sourceserved()reports, and only the game's own bytes skip the texture check (games_own). A mod's file served at the game model's path is checked as a mod's model, textures and all, and is not warned of as the game's. The test now serves such a file with a texture nobody has: refused,(0, 1). With the exemption back on the spec's line alone it fails,(1, 0)against(0, 1).noteline).game_model_missing_texturelooks the game model's textures up again at every start, made pack or not. The test turns a mod serving the texture on, then off, with the same pack: no warning while it is on, the warning again once it is off, nothing made again.7c8b4f867. The docs' own example,actor({ id: "OctoPot", from: "Obj_Pot_A_01", model: modelOf("Enemy_Octorok") }), spawned in Hyrule Field: added, and drawn with the Octorok's model and textures. Onmainit would have been refused too: the Octorok's model namesMt_Shell_Enemy_Octorok_Mtl, which is noTex/file. The Dark Link fight is still to test by hand: no save near his room is inassets/saves, and the debug teleport reaches only the Water Temple's entrance.cargo test -p content288 passed; clippy (-D warnings) and fmt clean (gnullvm). The description says the same.@review
Recommendation: Request changes. A pack cached before the fix can still let a mod’s replacement model bypass the texture check. The copied-actor case has been exercised, but the Dark Link encounter remains untested.
Game models named by modelOf can be added despite material names that do not correspond to Tex/ files, with a warning for the mod author. The fix keeps bone checks and intends to retain texture checks for mod replacements.
Blocking (1): must change before merging.
game/crates/content/src/merge.rs:1401: Previously cached packs can retain the old exemption for a mod’s replacement model. When: A mod replacement with a missing texture was accepted and cached before this fix. On a later start with the same model and pack, the unchanged key finds that pack and skips pack_checks, so the replacement is still accepted. Do: Invalidate packs checked under the earlier exemption, for example by changing the pack cache key version, so replacements are checked again.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
cc69b59864)Resolved: L2 (The cached warning depends on texture availability, but the pack key does not include that…)
Still open: L1 (Previously cached packs can retain the old exemption for a mod’s replacement model.); L3 (The original Dark Link encounter has not yet been exercised with the mod enabled.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The reported Windows run shows adult Link using Dark Link’s model where main refused the actor; the copied Octorok example was also added and drawn. The game-free test is reported to fail before the fix and pass after it.
Other systems: The content-stage checks affect modded actors on Windows and Linux, independently of GPU rendering. The reported game runs are on Windows; the original Dark Link fight remains untested.
Switches: None.
Reviewed:
6e337c7b43againstde091ae295: Read the repository rules, PR template, standards, diff, changed documentation and relevant merge.rs paths and tests; skimmed the remaining merge.rs code. The separate Tooling checkout and docs/review-checklist.md were absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The author reports 288 content tests passing, clean clippy and formatting checks, and game runs on Windows; CI is still running.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
Re-review answered (
f80d6a29b):"game model 2"), so a pack made while a mod's file at a game model's path also skipped the texture check is never taken again: it is made and checked once more. Packs without a game model keep their keys, so no other cached pack is made again. Only this PR's earlier commits could make such a pack:mainrefused every game model whose textures are noTex/file. No new test: the key's mark has no behaviour of its own to assert game-free beyond "a different key"; the checks it leads back to are the ones the test covers.cargo test -p content288 passed, clippy (-D warnings) and fmt clean (gnullvm). Not run in the game: the start makes the pack again, the same path the earlier runs took on a fresh cache.assets/saves, and the debug teleport reaches only the temple's entrance.@review
Recommendation: Approve. The code is ready: only testing is left (a run of the change itself). The cache-key change makes previously accepted replacement-model packs go through the corrected checks. The original Dark Link encounter still needs an in-game run with the mod enabled, and CI is running. Recommend approval; not approved on the forge.
Game models selected with modelOf can be added when their materials name textures without Tex/ files, while mod replacements remain subject to texture checks. The change adds a startup warning and a one-time rebuild of cached game-model packs.
Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
Since the last review (on
6e337c7b43)Resolved: L1 (Previously cached packs can retain the old exemption for a mod’s replacement model.)
Still open: L3 (The original Dark Link encounter has not yet been exercised with the mod enabled.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The reported Windows run reproduced the refusal on main and drew adult Link with Dark Link’s model on the branch; the game-free test also reportedly fails before the fix and passes after it.
Other systems: The content stage and its cache run on Windows and Linux. The reported game runs were on Windows; the change does not alter per-frame rendering, and the original Dark Link encounter remains untested.
Switches: None.
Reviewed:
f80d6a29bcagainstde091ae295: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the full diff, the changed portions of merge.rs and their cache, source-selection and model-checking paths, plus the reported runs and comments. Skimmed the changed documentation and remaining merge.rs; the Tooling AGENTS.md and docs/review-checklist.md were absent. Screenshots and CI results were not available for inspection.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The author reports 288 content tests passing, clippy and formatting checks clean, and successful Windows game runs; the Dark Link fight remains untested. CI is still running.
Overlaps and merge order: None found in the supplied material.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.