Preinit File Not Found Exception

Stuck.

Here’s the makefile:

-I liblite
-D LANGUAGE=english
-Fy obj
-Fo obj
-FI /usr/local/share/frobtads/tads3/include
-FL /usr/local/share/frobtads/tads3/lib
-we
-v

##sources
-lib system
-lib adv3Lite/adv3Lite
-source gameMain.t

-res
GameInfo.txt
cache/warp512.dat

I have a data file at cache/warp512.dat, which opens fine if I am in debug mode, but when I try packing it with my game file, the compiler throws an error:

file not found
fatal error: 
An runtime error or other unhandled exception was thrown during
pre-initialization.

Here’s the preinit code that calls for the resource:

// Read the 512-table caches from resource file
local extTables = File.openRawResource('cache/warp512.dat');
local bothLists = extTables.unpackBytes('l1022');
extTables.close();

I have read the docs on any related subject twice now, and have tried a lot, including:

  1. Renaming the folder (tablecache/warp512.dat)
  2. Renaming the file (cache/warp.dat)
  3. Giving it different extensions, in case bundling resources filters by extension:
    • .txt
    • .bmp
    • no extension
  4. Using a file alias: cache/warp512.dat=warp512table
  5. t3make -clean followed by t3make -a

I keep getting this error. Again, I can confirm that in debug mode, every opens, and the file contents are correct. This is just when preinit happens outside of debug mode.

Any help is greatly appreciated. I don’t know what else to do.

If anyone wants the hex format of warp512.dat, in case I have a file that TADS 3 considers “malformed”, then here you go:

warphex.txt (17.0 KB)

Well, resources don’t actually get packed into the game file until after Preinit is done. But according to the docs it shouldn’t really matter (it should just load the original files from disk). I couldn’t find any info about file safety levels in the compiler that might be interfering during preinit…

Where does the compiler create the .t3 file, and what is your current working directory when you invoke it? Are they both the same directory that has cache in it?

1 Like

…oh wait, that’s interesting!

Because if I am just loading this file to write its contents into a Vector for preinit caching, then I guess I don’t really need to bundle the file with the game, do I…? …I, uh, had not considered this

People on this forum are amazing.

Yup! gameMain.t, gameMain.t3, and cache/ are in the same directory!

(Though, after your previous point, this might not relevant anymore lol)

Why are you packing the file into the t3 file if you’re reading it during preinit anyway? You’re including an unneeded file with the t3. The file is not needed anymore when shipping the game since you’ve already read it in preinit.

Or am I missing something? :stuck_out_tongue:

2 Likes

Nope, this is exactly correct, and something I realized already lol

Had a bit of tunnel vision while setting some stuff up, apparently, lol

1 Like