Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripting regression in hudgauge #4171

Closed
EatThePath opened this issue Apr 13, 2022 · 4 comments · Fixed by #4177
Closed

Scripting regression in hudgauge #4171

EatThePath opened this issue Apr 13, 2022 · 4 comments · Fixed by #4177
Assignees
Labels
bug An issue from unintended consequences HUD A feature or issue related to the HUD regression A bug introduced by a new feature that breaks something which used to work. scripting A feature or issue related to LUA scripting
Milestone

Comments

@EatThePath
Copy link
Contributor

Axem's prompt-box script broke on the 20220207 nightly, bisecting a blue planet crash narrowed down to there. As a reproduction download blue planet and play Age of Aquarius, the prompt box is used immediately on the start of the first non-cutscene mission.

@Goober5000 #4003 looks like the most likely cause, but I'm not immediately sure of why.

The error in question is

[Window Title]
Error!

[Content]
LUA ERROR: [string "proBox-sct.tbm - On Game Init"]:87: attempt to index a nil value

------------------------------------------------------------------

stack traceback:
	[C]: ?
	[string "proBox-sct.tbm - On Game Init"]:87: in function 'GetTextFromGauges'
	[string "proBox-sct.tbm - On Game Init"]:64: in function 'UpdateText'
	[string "proBox-sct.tbm - On Game Init"]:54: in function 'MakeList'
	[string "proBox-sct.tbm - On Game Init"]:198: in function 'proBoxOn'
	[string "String: proBoxOn()"]:1: in main chunk
------------------------------------------------------------------

------------------------------------------------------------------


[ This info is in the clipboard so you can paste it somewhere now ]


[Debug] [Continue] [Exit]

and the function in question,


function PromptBox:GetTextFromGauges()
	
	local t = {}
	for i, v in pairs(self.Gauges) do
		local gauge = hu.getHUDGaugeHandle(v).Text
			if gauge:gsub("%s+", "") ~= "" and not self.Locked[i] then
				t[i] = ">> " .. gauge
			else
				t[i] = ""
			end
	end
	
	return t

end

The gauges are there in the files, and 20220205 displays them just fine.

@EatThePath EatThePath added bug An issue from unintended consequences regression A bug introduced by a new feature that breaks something which used to work. HUD A feature or issue related to the HUD scripting A feature or issue related to LUA scripting labels Apr 13, 2022
@TRBlount TRBlount added this to the Release 22.2 milestone Apr 13, 2022
@Goober5000 Goober5000 self-assigned this Apr 13, 2022
@z64555
Copy link
Member

z64555 commented Apr 14, 2022

whats the line numbers of the function?

@Goober5000
Copy link
Contributor

The problem is that hu.getHUDGaugeHandle(v) is returning nullptr when it previously didn't.

I already tracked down the proximate cause, but now I want to figure out why it's doing that.

@z64555
Copy link
Member

z64555 commented Apr 14, 2022

Presumably when empty its supposed to be \0 instead of nullptr, so it looks like an init or copy error. One other thing is that a guage may have been std::move'd thus invalidating the data in the old position.

@Goober5000
Copy link
Contributor

No, it's because different hud gauges are stored in different collections. The implementation of that scripting function isn't checking the collection where that particular gauge was stored.

Goober5000 added a commit to Goober5000/fs2open.github.com that referenced this issue Apr 17, 2022
1) Fix part of the lookup logic in `hud_get_default_gauge_index`
2) Add back part of the lookup that was removed in scp-fs2open#4003
3) Use custom checks with the `default_hud_gauges` list
4) Add a clarification comment to `default_hud_gauges`

Fixes scp-fs2open#4171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue from unintended consequences HUD A feature or issue related to the HUD regression A bug introduced by a new feature that breaks something which used to work. scripting A feature or issue related to LUA scripting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants