niv / neverwinter.nim

CLI tools and nim library used in Neverwinter Nights: Enhanced Edition development
MIT License
131 stars 29 forks source link

NWN_GFF Assert Defects with gff output in stdout [Windows] #93

Open WilliamDraco opened 11 months ago

WilliamDraco commented 11 months ago

Running self-built neverwinter 1.6.3 (core-master/d1a3a5, nim 2.0.0) on Windows 11.

Attempting to output to stdout fails, as below:

> nwn_gff -i module.ifo.json -k gff
IFO V3.2fatal.nim(53)            sysFatal
Error: unhandled exception: gff.nim(700, 9) `io.getPosition == 8 + ioPosStart`  [AssertionDefect]

(Notice it succeed at outputting the result of lines 698 and 699 before failing) Trying to direct output to a file results in similar but different failure

fatal.nim(53)            sysFatal
Error: unhandled exception: gff.nim(757, 9) `io.getPosition == ioPosStart + 56 + structs.len * 12 + fields.len * 12`  [AssertionDefect]

Attempting the reverse (nwn_gff -i module.ifo -k json) operates as expected. Identified trying to accommodate stdin/stdout for @nwnt, which utilities the same write function. I've not tried stdout before to know if this is new.

WilliamDraco commented 11 months ago

in the same vein, trying to pipe in a gff also fails

> Get-Content module.ifo | nwn_gff -l gff -o moduletest.json
util.nim(11)             readStrOrErr
Error: unhandled exception: wanted to read 16 but only got 9 [IOError]

This traces back to these lines. - Again occurred in my nwnt test and then replicates with nwn_gff.

niv commented 11 months ago
WilliamDraco commented 11 months ago

Using the downloaded win32 i386 build, 1) The first error still occurs in the same way (i.e. just trying to print to the terminal) 2) the second error does not occur, redirecting stdout to a file does not error nwn_gff -i module.ifo.json -k gff > test.txt. text.txt is not binary identical to the original module.ifo, and renaming test.txt to an test.ifo and attempting to jsonify it (or nwnt it) fails with the error:

util.nim(11)             readStrOrErr
Error: unhandled exception: wanted to read 16 but only got 0 [IOError]

3) Trying to pipe in the gff continues to fail with the same error as my earlier comment (wanted 16 but got 9) as opposed to trying to pipe in this output above where it's 'gets' 0.

Using the linux build, via WSL (don't have a linux box) 1) different error, but still a failure

nwn_gff -i module.ifo.json -k gff
io.nim(153)              raiseEIO
Error: unhandled exception: cannot retrieve file position [IOError]

2) Pushing to a file instead of stdout successfully creates a test.txt that is binary-identical to the original module.ifo. nwn_gff -i module.ifo.json -k gff >test.txt

3) cat module.ifo | nwn_gff -l gff -o moduletest.json also works as expected - Output json is the same as simply using -i module.ifo

Happy to accept that outputting gff to terminal (as in 1) is not actually useful, but would expect windows to act as linux for 2) and 3). I'm also a windows scrub though, so maybe I'm misunderstanding piping somewhere.