Skip to content

Commit 40bbced

Browse files
authored
Reset hotkey lines before populating (#6318)
* reset hotkey lines before building * clang is the most high maintenance partner i've ever had
1 parent a84941e commit 40bbced

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

code/mission/missionhotkey.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,12 @@ int get_ship_hotkeys(int n)
506506
return Hotkey_bits[Hotkey_lines[n].index];
507507
}
508508

509+
void hotkey_lines_reset_all() {
510+
for (auto& line : Hotkey_lines) {
511+
line = hotkey_line();
512+
}
513+
}
514+
509515
// add a line of hotkey smuck to end of list
510516
int hotkey_line_add(const char *text, HotkeyLineType type, int index, int y)
511517
{
@@ -1014,6 +1020,7 @@ void mission_hotkey_init()
10141020

10151021
Scroll_offset = 0;
10161022
Selected_line = 1;
1023+
hotkey_lines_reset_all();
10171024
hotkey_build_listing();
10181025
}
10191026

code/mission/missionhotkey.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ void mission_hotkey_mf_add( int set, int objnum, int how_to_add );
4646

4747
void mission_hotkey_exit();
4848

49+
// function to reset the hotkey list
50+
void hotkey_lines_reset_all();
51+
4952
// function to build the hotkey listing
5053
void hotkey_build_listing();
5154

code/scripting/api/libs/ui.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,7 @@ ADE_FUNC(initHotkeysList,
19211921

19221922
reset_hotkeys();
19231923
hotkey_set_selected_line(1);
1924+
hotkey_lines_reset_all();
19241925
hotkey_build_listing();
19251926

19261927
// We want to allow the API to handle expanding wings on its own,

0 commit comments

Comments
 (0)