Okay, I have no idea why but the inexplicable force quit on trying to load any script has stopped, allowing me to go back to tracking down the other bug.
I've determined that it's force closing when it tries to load a common data area. It's used in multiple places so it could already exist or not - I'm in the process of tracking down the exact conditions, but here's the code it's crashing on:
if(!IsCommonDataAreaExists("cutin_History")){CreateCommonDataArea("cutin_History");}
LoadCommonDataAreaA1("cutin_History"); // <-- force quits here
I've commented out one of the two places I found this but it still happens; possibly a third place?
(Edit: I checked with find in files and those were the only two places. It still happens if I change the name entirely in one place and remove the others, and still happens with only the second line. It seems like any use of LoadCommonDataAreaA1 is causing it??? Which is weird because while I only recently added that snippet to a second place, it's been hanging out in the cutin function for ages without issue.)
Elsewhere I have this, which has caused no problems, but I'm pretty sure this is the only place I try to load that one:
let isconfig = LoadCommonDataAreaA2("CONFIG",dirdat~"config.dat");
if(!isconfig){
CreateCommonDataArea("CONFIG");
SetAreaCommonData("CONFIG","Difficulty",NORMAL);
SetAreaCommonData("CONFIG","MainEquip",EQ_CAMERA);
SaveCommonDataAreaA2("CONFIG",dirdat~"config.dat");
}
I don't really understand under which conditions creating or loading common data areas causes issues; if someone could explain that to me I could probably figure it out from there.
Edit: the following also crashes:
let path = dirdat~GetScriptInfoA1(GetMainStgScriptPath, INFO_SCRIPT_ID)~"_common_cutin_History.dat";
LoadCommonDataAreaA2("cutin_History",path);
but THIS doesn't:
let path = dirdat~GetScriptInfoA1(GetMainStgScriptPath, INFO_SCRIPT_ID)~"_common_cutin_History_asdf.dat";
LoadCommonDataAreaA2("cutin_History",path);
I don't get it
Edit: I changed the path to use for it everywhere, which made it work once. The second time, after it had already saved the info there, it crashed as usual.