hendrikgit / nwn_sqlite

Extracts information from a Neverwinter Nights module and saves it to a sqlite3 database
14 stars 1 forks source link

Value out of range exception #3

Closed LucidPixels closed 1 year ago

LucidPixels commented 1 year ago

Getting this when attempting to use the tool (on an admittedly quite bloated module). Results are the same in Win10 and Linux.

Creatures (utc) found: 2787 fatal.nim(54) sysFatal Error: unhandled exception: value out of range: 255 notin 0 .. 100 [RangeDefect]

hendrikgit commented 1 year ago

Hello.

Have you run a version from the releases here on GitHub or compiled yourself?

Please try running a debug build like you can find here (down by artifacts, the ones starting with debug.) https://github.com/hendrikgit/nwn_sqlite/actions/runs/4295494733 or compile the tool yourself without the -d:releasecompiler flag.

If you run the debug build with the same options and input as you did before it hopefully leads to a more useful error message. Please post that output here and I'll see what I can find out from that.

LucidPixels commented 1 year ago

Hello, and thanks for the quick reply. I ran the version from releases here.

This is the output from the debug build:

Creatures (utc) found: 2785 /home/runner/work/nwn_sqlite/nwn_sqlite/src/nwn_sqlite.nim(167) nwn_sqlite /home/runner/work/nwn_sqlite/nwn_sqlite/src/creature.nim(124) creatureList /home/runner/work/nwn_sqlite/nwn_sqlite/nim/nim-1.6.10/lib/system/fatal.nim(54) sysFatal Error: unhandled exception: value out of range: 255 notin 0 .. 100 [RangeDefect]

hendrikgit commented 1 year ago

I think I see it. I figured it might be something like this. The tool reads an alignment value from a creature. Alignment are two integer numbers, one for the axis lawful to chaotic, and one for good to evil. With the information I had so far I assumed these alignment values would be between 0 .. 100.

Alignment in the creature .utc file is a byte, uint8, though. So technically that value can go from 0 to 255.

One of your creatures has an alignment above 100, I assume, and when the tool tries to fit that into its internal alignment type that only allows values up to 100 it breaks.

That leads me to think (again) I'd like to have nicer error handling, so that the tool outputs on what creature, item, and so on the issue occurs and the user has an option to fix the, for example, creature. Or remove it, so that at least the tool finishes running.

Anyway, for now I pushed a possible fix. If what I wrote above is actually what is happening ;) Alignment above 100 will just considered to be 100.

Check the output of this action/build https://github.com/hendrikgit/nwn_sqlite/actions/runs/4470583443. It might still be running when you look. Once it is done try one of the binaries under artifacts there. Ideally it fixes this issue.

LucidPixels commented 1 year ago

That did the trick! Thanks again.