Evolve icon indicating copy to clipboard operation
Evolve copied to clipboard

Equilibrium Feat issue

Open mrcaboom opened this issue 2 years ago • 5 comments

When rendering the feats page in the wiki, js crash at Equilibrium. The error : Cannot read properties of undefined (reading 'localeCompare')

I've checked the game data in debug mode and found that for some reason my custom race is set to {} This cause the game to crash because races[a].name doesn't exist

https://github.com/pmotschmann/Evolve/blob/05285c0fe632915a06704e4f9d06edd6f46f4ac3/src/wiki/achieve.js#L374C50-L374C50

I do not know if the empty object on the custom race is normal or not. I've never edited the gamefile or anything.

mrcaboom avatar Jul 06 '23 16:07 mrcaboom

What locale do you use? Which browser and version?

StoneCypher avatar Oct 31 '23 23:10 StoneCypher

I had the same bug in Chrome, but not in Firefox. I analyzed the problem and it is indeed in the linked line. On a fresh start, custom race is just an empty object. Internally sort performs a number of comparisons between elements of the array (here Object.keys(races)) and it happens that the function inside did not work when the custom race happened to be on the left side of the comparison (trying to get localeCompare from undefined races[a].name), but worked fine when it was on the right (races[b].name being correctly undefined). When I reversed the direction of the check, it stopped working in Firefox too, as expected. A simple workaround here is to use coalescing operator ?? here on races[a].name, though it is not used elsewhere in the project, so I'll just use || to maintain maximum compatibility with old EcmaScript. I'll make a pull request with a quick fix.

xilexio avatar Nov 22 '23 08:11 xilexio

This patch makes sense.

Equilibrium might be further in the game than I am. Why would there be no race name?

StoneCypher avatar Nov 23 '23 16:11 StoneCypher

Specifically the custom race did not have the name. Custom race had races[a] equal to {}. My guess is that before it is set the first time or maybe even in the runs where it is not the active one, it is not set. However, I haven't actually seen where it is set.

xilexio avatar Nov 23 '23 21:11 xilexio

The issue was already fixed in 1.3.10.

xilexio avatar Jan 04 '24 09:01 xilexio