Skip to content

Fix Gnawnian Express Station phase selection - #354

Open
SoilChang wants to merge 1 commit into
tsitu:masterfrom
SoilChang:fix/gnawnian-express-phase-selection
Open

Fix Gnawnian Express Station phase selection#354
SoilChang wants to merge 1 commit into
tsitu:masterfrom
SoilChang:fix/gnawnian-express-phase-selection

Conversation

@SoilChang

@SoilChang SoilChang commented Sep 6, 2026

Copy link
Copy Markdown

Currently broken

get-data.js:93 Error loading data: TypeError: Cannot set properties of null (setting 'selectedIndex')
    at shared-cre-setup.js:1065:55
    at loadDropdown (shared-cre-setup.js:973:3)
    at phaseChanged (shared-cre-setup.js:1064:5)
    at icebergPhase (cre.js:871:7)
    at baseChanged (cre.js:881:3)
    at loadDropdown (shared-cre-setup.js:973:3)
    at allDataLoaded (cre.js:139:3)
    at checkLoadState (shared-cre-setup.js:1558:5)
    at tryCheckLoadState (get-data.js:123:7)
    at setWisdom (get-data.js:136:5)

How the Iceberg logic leads to the stacktrace

  1. allDataLoaded() populates the Base dropdown with loadDropdown(), whose callback is baseChanged().
  2. baseChanged() calls icebergPhase() for every location; the function originally had no location guard.
  3. At Gnawnian Express Station, a valid phase can be Supply Depot (Supply Rush) or Supply Depot (No Supply Rush). icebergPhase() normalizes every phase using phaseName.split(" (")[0], turning the selected phase into Supply Depot.
  4. Supply Depot is not a valid Gnawnian Express Station phase option. The select therefore loses its value, and icebergPhase() calls phaseChanged().
  5. phaseChanged() converts the empty value to EMPTY_SELECTION (-), finds no popArray[locationName]["-"], and calls loadDropdown() to rebuild the phase list.
  6. The recovery callback then executes document.getElementById("#phase").selectedIndex = 0. Because getElementById() expects phase without the #, it returns null, producing the reported selectedIndex exception.

The fix limits icebergPhase() to the Iceberg location and corrects the phase element lookup.

Summary

  • Restrict Iceberg phase normalization to the Iceberg location.
  • Preserve Gnawnian Express Station phases such as Supply Depot (Supply Rush) when changing bases.
  • Fix the invalid getElementById("#phase") lookup used during phase-dropdown recovery.

Testing

  • git diff --check
  • node --check src/main/cre.js
  • node --check src/main/shared-cre-setup.js
  • npm run population
  • npm run mouse-data
  • npm run trap-data
  • npm run minify
  • Verified the Catch Rate Estimator locally at http://127.0.0.1:8000/cre.html.

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