Hard Light Productions Forums

Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: xenocartographer on February 21, 2017, 04:07:22 pm

Title: Hard CTD on write to custom HUD gauge text
Post by: xenocartographer on February 21, 2017, 04:07:22 pm
Title says it all. The following are minimal *-sct.tbm and *-hdg.tbm files to reproduce the issue, adapted from my actual mod files:

Code: [Select]
#Conditional Hooks

$Application: FS2_Open

$State: GS_STATE_GAME_PLAY
$On Frame: [
if mn.getMissionTime() > 5 then --rule out some sort of first-frame issue
local gauge = hu.getHUDGaugeHandle("TBeamStatus")
if gauge then gauge.Text = "DEBUG" end
end
]

#End

Code: [Select]
#Gauge Config
$Base:       (1024,768)
$Gauges:
+Custom:
Scale Gauge: NO
Origin: (1, 0.5)
Offset: (-159, 0)
Name: TBeamHeader
Text: Tractor Beam
X Offset: 2
Y Offset: 2
Gauge Type: CENTER_RETICLE
Slew: NO
Active by default: YES
Filename: escort1
+Custom:
Scale Gauge: NO
Origin: (1, 0.5)
Offset: (-159, 13)
Name: TBeamTarget
Text:
X Offset: 4
Y Offset: 1
Gauge Type: CENTER_RETICLE
Slew: NO
Active by default: YES
Filename: escort2
+Custom:
Scale Gauge: NO
Origin: (1, 0.5)
Offset: (-159, 24)
Name: TBeamStatus
Text:
X Offset: 4
Y Offset: 1
Gauge Type: CENTER_RETICLE
Slew: NO
Active by default: YES
Filename: escort3
$End Gauges
#End

As soon as the mission clock hits 5 seconds (well, right before that frame is drawn, I think), the game either hangs for a bit and crashes, or just immediately crashes. In either case, the usual FSO error popup is missing, even with debug builds. I've attached a log generated by a debug build.

[attachment stolen by Russian hackers]
Title: Re: Hard CTD on write to custom HUD gauge text
Post by: xenocartographer on February 21, 2017, 04:39:29 pm
Found a workaround with help from IRC folks, and a recent nightly's actually fixed the issue, so /shrug
Title: Re: Hard CTD on write to custom HUD gauge text
Post by: chief1983 on February 21, 2017, 06:41:22 pm
Heh, if it's the timer code fix, you're welcome :)

Well, not for the fix, but for calling attention to what needed to be fixed.
Title: Re: Hard CTD on write to custom HUD gauge text
Post by: AdmiralRalwood on February 21, 2017, 07:45:42 pm
Heh, if it's the timer code fix, you're welcome :)

Well, not for the fix, but for calling attention to what needed to be fixed.
Doubt the timer code would cause a crash there; 5 seconds isn't long enough for an overflow, an overflow shouldn't cause a crash anyway, and the mn.getMissionTime() call clearly works because it waits until the correct amount of time has elapsed before crashing. Unfortunately, diagnosing exactly why it did crash would require figuring out when the problem went away, and that's an awful lot of troubleshooting for a bug that appears to have already been fixed...
Title: Re: Hard CTD on write to custom HUD gauge text
Post by: chief1983 on February 21, 2017, 07:50:02 pm
Yeah it seemed awfully short to me too.
Title: Re: Hard CTD on write to custom HUD gauge text
Post by: xenocartographer on February 21, 2017, 08:16:55 pm
I'm pretty sure it was a bug with the C code backing up the Lua API. In the actual mod, not the minimal test case version, the HUD change was triggered by weapons fire.

Regardless, it's not a problem in the nightlies and I've worked around it for people who prefer not to use them, so I'm not concerned. I hope I didn't waste anyone's time too badly.
Title: Re: Hard CTD on write to custom HUD gauge text
Post by: m!m on March 04, 2017, 07:32:48 am
Does your scripting code actually update the text of the HUD gauge when you use the nightlies?

I have fixed another bug that may be related to the crash you were experiencing but while fixing that I noticed that the scripting API used a copy of the custom HUD gauge instead of the actual HUD gauge so, as far as I can tell, it wasn't possible to actually change the values of the HUD gauge through the scripting API.