Skip to content

Port: leave a map piece's texture set with the map that entered it - #131

Merged
Adubbz merged 1 commit into
TheMoonPeople:masterfrom
FredTheSlug:fix/map-piece-texture-sets
Oct 20, 2026
Merged

Adubbz merged 1 commit into
TheMoonPeople:masterfrom
FredTheSlug:fix/map-piece-texture-sets

Conversation

@FredTheSlug

Copy link
Copy Markdown
Contributor

Fixes a crash in Palm Brinks when you walk out of Maximilian's House and straight back in. Found in playtesting.

Before: since c0f07fe, model_assets::LoadModel enters each embedded texture set from block 0. Map pieces embed the same set their map already entered into its own blocks. In Palm Brinks Residence the m04 pieces carry e04's water (e04_water to e04_water7), so loading the grounds (map 1, blocks 24-31) also put a second copy of the water into blocks 3-5. Those belong to the town map (map 0) and never get deleted with the grounds. After going inside and back out, the grounds' #texanime found those copies by name and attached its animation to block 4, allocated from the grounds map's stack. Walking back in loads map 1 over that stack, block 4 still points into it, and the next frame crashes in RestoreAnimatedTextures or mgCTextureAnime::TexAnime reading float data as list nodes.

After: a plain model (no character) skips an embedded set when every picture in it is already registered under its name, so map pieces use their map's textures by name the way the retail MDS pieces do. Sets with pictures that aren't registered yet get entered the same as before. The grounds' water animation also gets registered once now instead of twice.

Tests:

  • NativeModel.ModelLeavesATextureSetItsMapAlreadyEnteredWithTheMap enters a document at block 24 and then loads a model that embeds the same set. Without the fix it ends up with a second copy in block 0 (2 textures), with it the model uses the block 24 texture.
  • Full ctest on Windows passes except PcOptionsAudio.MissingCustomTrackFallsBackToThePs2Sequence, which fails under -j8 on a temp dir lock and passes on its own.
  • In game: Palm Brinks Residence, into Maximilian's House, out, back in. Crashed every time before this change, fine with it.
  • Seeded headless runs (--jump dungeon:1:1 and dungeon:0:2, --seed 1, screenshots at frames 3000 and 7800) match master.

Since c0f07fe, LoadModel enters each embedded texture set from block 0. A map
piece embeds the set its map already entered into the map's own blocks, so the
copy landed in another map's blocks: the Palm Brinks residence pieces put e04's
water into the town map's blocks 3-5, which the grounds map never deletes. When
the grounds loaded again, the water's texture animation found those copies by
name and attached to block 4 with memory from the grounds map's stack. Walking
back into Maximilian's House reused that memory, and the next frame crashed in
RestoreAnimatedTextures or TexAnime.

A plain model now leaves a set alone when every picture in it is already
registered under its name, the way retail map models only look their textures
up. Sets with pictures nobody has entered are entered as before.
@Adubbz
Adubbz merged commit b88cc5c into TheMoonPeople:master Oct 20, 2026
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants