Skip to content

Keep a pinned fishing float from turning NaN, in a port replacement - #225

Closed
SirFancyBacon wants to merge 1 commit into
TheMoonPeople:masterfrom
SirFancyBacon:fix/fishing-float-nan-port
Closed

SirFancyBacon wants to merge 1 commit into
TheMoonPeople:masterfrom
SirFancyBacon:fix/fishing-float-nan-port

Conversation

@SirFancyBacon

@SirFancyBacon SirFancyBacon commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Carries over #219 by @Tororoi as a PORT_OVERRIDE replacement, so ps2/src stays untouched. Tororoi found the cause and wrote the fix and its test; they're credited as the author of this fix.

Fixes: #224
Requires: #220

The bug

While the fishing float is pinned (FishLineSetUki with a weight of 0 or more, as on every cast), FishLineStep copies uki into both point[18] and ukip[0] at the end of each relaxation pass. On the next pass the length between them is 0, so length * (1 - weight) / length is 0/0.

  • On the EE, that gives a finite result and the float doesn't move.
  • On a PC it gives NaN, which spreads through the float and the line into Toan's position.
    • macOS ARM: the game crashes in CCollisionMDT::PickUpNearPoly (from EdMoveChara) as the line is cast.
    • Linux x86_64: the view turns to a single color, the game says the bait has run out, and leaving the fishing menu crashes.

The fix

FishLineStep is replaced in port/src/fishing.cpp by retail's body with one guard: a zero length is taken as 1, which gives the same zero move the EE does. Nothing else in the copy changes (compared against ps2/src/fishing.cpp, the only difference is the guard), and the two point-pair tables it reads, static in retail's unit, come with it.

docs/PC.md gets a short section, "Arithmetic the EE does differently", listing it, in the style of the pointer replacements' table.

Testing

While the float is pinned (FishLineSetUki with a weight of 0 or more, as on
every cast), FishLineStep copies uki into both point[18] and ukip[0] at the
end of each relaxation pass, so on the next the length between them is 0 and
length * (1 - weight) / length is 0/0. The EE's floating point gives a
finite result and the float stays still; a host's gives NaN, which runs
through the float and the line into Toan's position. On macOS ARM the game
crashes in CCollisionMDT::PickUpNearPoly from EdMoveChara as the line is
cast; on Linux x86_64 the view turns to a single colour and leaving the
fishing menu crashes.

FishLineStep is replaced in port/src/fishing.cpp by retail's body with a
zero length taken as 1, the same zero move the EE makes, and nothing else
changed; ps2/src is untouched. Tororoi found the cause and wrote the guard
and FishingLine.APinnedFloatStaysFinite in TheMoonPeople#219, which this carries over as
a replacement because ps2/src is not edited for the port. docs/PC.md lists
it under a new "Arithmetic the EE does differently".

Co-authored-by: Thomas Cantwell <cantwell.tom@gmail.com>
@Tororoi

Tororoi commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

I recommend merging PR 230 instead

Adubbz added a commit that referenced this pull request Oct 27, 2026
…e open PRs

The port no longer compiles ps2/: the game's code is forked into port/src/game and
port/include/game, and PORT_OVERRIDE is gone. ps2/ stays the byte-matching decomp.

- PS2-only code removed from the fork: MWCC pragmas, code the PC link discarded, SDK calls
  that do nothing on PC, dead conditionals.
- All port code brought to AGENTS.md and C++26: anonymous namespaces, nullptr, C++ casts,
  std containers and strings in place of fixed buffers and C strings, enum class, no goto,
  meaningful names, minimal comments, documented headers.
- Every function in a logical file: the platform layer is in port/src/<subsystem>
  (app, data, platform, render, input, ui, options, title, battlemenu, dialog, quest,
  item, text, localize, save); the old replacement units are merged into their game units;
  no *_port files, stub headers, linknames.cpp or linker aliases remain.
- Namespaces: dc::game for the game, dc::<subsystem> for the platform layer, dc::test for
  the tests. Only main, extern "C" entry points and the symbols Kazarov calls stay global.
- CI per platform: pc.yml (Linux, Windows, Flatpak), macos.yml and switch.yml, with the
  Switch toolchain image cached on ghcr.io. Kazarov compiles pipelines on first use on a
  CPU rasterizer, so lavapipe no longer runs test processes out of memory.
- Merged PRs, simplified and restyled: #186 (autosave on each dungeon floor and resume
  there), #220, #223 (item framework and gameplay documents), #226 (sound publishing),
  #227, #228, #229, #230 (the fishing line's springs divide as the EE does; supersedes
  #219 and #225).

Each step was gated on Windows: build, unit tests, and headless screenshots of ten game
modes, pixel-identical to master's build.

Co-authored-by: Alessandro Suha <plarpoon@zandark.eu>
Co-authored-by: Thomas Cantwell <cantwell.tom@gmail.com>
Co-authored-by: SirFancyBacon <m.johnsondelta@gmail.com>
Co-authored-by: IvanPerrella <ivan.perrella@gmail.com>
@Adubbz

Adubbz commented Oct 27, 2026

Copy link
Copy Markdown
Member

Superseded by #230, which is merged into master in d3666bc (the fishing line's springs divide by their length as the EE does). Thank you!

@Adubbz Adubbz closed this Oct 27, 2026
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.

[BUG] - casting pins the float's distance to zero, causing a NaN on PC that corrupts Toan's position and camera.

3 participants