dufriphepr Posted February 27, 2016 Posted February 27, 2016 I have a weird issue with a user defined function that works fine initially, but after a while will simply fail when called. No CTD or anything, it just returns 0 without executing anything written in the function body. This is the code snippet where I call the function: [some irrelevant stuff] ref someActor int someValue Set someValue to 1 Set someActor to GetFirstRef 200 1 PrintC "Debug A: %i / %n is someActor" someActor someActor Let someValue := Call SomeFunction someActor someValue if (someValue == 1) PrintC "Debug D: %i / %n is valid actor" someActor someActor else PrintC "Debug D: %i / %n is invalid actor" someActor someActor endif [some more irrelevant stuff] And this is the function (note that I had to replace some periods with commas because I'm "not allowed to post links"): scn SomeFunction ref someActor int someValue Begin Function {someActor, someValue} PrintC "Debug B: %i / %n is being validated" someActor someActor if (someValue == 1) if (IsReference someActor == 0) PrintC "Debug C: %i / %n is not a reference" someActor someActor Set someValue to 0 elseif (someActor == 0) PrintC "Debug C: %i / %n is null" someActor someActor Set someValue to 0 elseif (someActor,IsActor == 0) PrintC "Debug C: %i / %n is not an actor" someActor someActor Set someValue to 0 elseif (someActor,GetDisabled == 1) PrintC "Debug C: %i / %n is disabled" someActor someActor Set someValue to 0 else PrintC "Debug C: %i / %n is valid actor" someActor someActor endif endif SetFunctionValue someValue End Normally, it prints the following output to the console: Debug A: 0011847A / Cazador is someActor Debug B: 0011847A / Cazador is being validated Debug C: 0011847A / Cazador is valid actor Debug D: 0011847A / Cazador is valid actor Or if there's something wrong with the actor e.g. because it's disabled, this gets printed instead: Debug A: 0011847A / Cazador is someActor Debug B: 0011847A / Cazador is being validated Debug C: 0011847A / Cazador is disabled Debug D: 0011847A / Cazador is invalid actor However, after a couple of minutes into the game (in which I run a lot of scripts on actors in lists) the output for all actors instead looks like this: Debug A: 0011847A / Cazador is someActor Debug D: 0011847A / Cazador is invalid actor As you can see, the function fails to load (as nothing from the function gets printed, not even the very first line) and returns a value of 0. I have for a while been trying to track down this issue which is why I there are all the debug print commands everywhere. Discovering that the function simply didn't execute seemed like a breakthrough at first, but now I have literally no idea how to proceed from here since there is nothing wrong with the function itself, and even if there was something wrong with it the function should either never execute, or it should at least always execute the first PrintC command. What the hell could possibly be going on here?
Guest Posted February 27, 2016 Posted February 27, 2016 My guess is that or the "irrelevant stuff" it not so much irrelevant, or the instance of the script fails and it won't be executed again till you reload the game. Out of curiosity, if you have the full log you could look for something like this: ... Debug A: 0011847A / Cazador is someActor Debug B: 0011847A / Cazador is being validated Debug A: 0011847A / Cazador is someActor Debug D: 0011847A / Cazador is invalid actor Debug A: 0011847A / Cazador is someActor Debug D: 0011847A / Cazador is invalid actor ...
dufriphepr Posted March 8, 2016 Author Posted March 8, 2016 the instance of the script fails and it won't be executed again till you reload the game.This is definitely what's happening. Thanks for the advice to check the full log. Unfortunately, I discovered that if I print a lot of stuff every frame then when the function fails for the first time, the entire log gets flushed and the file created with the scof command only contains everything from that point onwards. However, this gave me some ideas how to narrow down the issue. Long story short, I changed the failing function so that if the actor is valid it returns 1 and if the actor is invalid it returns -1, so only if the function actually fails do I get a return value of 0; and also I created a duplicate of the function (100% identical code except the name) which gets called only if the original function returns 0. Guess what happens? The duplicate function runs just fine on the exact same actor in the exact same frame the original function fails. Only if I let the game run for another couple of minutes the duplicate function eventually fails, too. So one possible solution would be to have like 100 of these duplicate functions which should allow the game to run for at least an hour or so without any problems. A better solution would be to somehow force the original function to reload. Is something like that possible? Also, why does the function fail in the first place? There's nothing wrong with the actors involved. The part of the script where the function is called is inside a GetFirstRef->GetNextRef Goto/Label loop, by the way.
Guest Posted March 8, 2016 Posted March 8, 2016 Are you SCOFing inside a script or manually via console from the main menu before reloading your save?
dufriphepr Posted March 8, 2016 Author Posted March 8, 2016 Manually, but after loading the save. Is that wrong?
Guest Posted March 9, 2016 Posted March 9, 2016 Manually, but after loading the save. Is that wrong? No, I was just excluding everything. Personally I'm at a loss, especially because I can't reproduce the issue. I messaged to someone one hundred times more competent, I hope they'll have a clue on this.
dufriphepr Posted April 25, 2016 Author Posted April 25, 2016 Update: I solved the issue by setting iNumHWThreads to 1. Whoever wrote this engine should be shot.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.