Skip to content

Commit e567ae7

Browse files
authored
Fix warning of unbound keys for newer controls (#7173)
* Fix warning of unbound keys for newer controls Under some circumstances, FSO will warn the player if a key is unbound if that they need to press to complete a training event. This logic though only works for keys with XSTRs from 507-619. Any control that was added with a different XSTR will not be picked up correctly, and thus the message displayed to the player will be incorrect, confusing, and not helpful. To fix this `missiontraining.cpp` around line 757 needs to account for the newer controls as well. This PR adds those needed checks, and this fixes the issue. This fix is especially needed for mods that use training missions with newer controls such as FotG. Note, we do ship with a full default controls table with all the needed keys bound, but we have found players will be players and simply change all their controls before even starting the training missions. Thus they unbind key training controls, and with this bug they are unable to correct their controls. With this fix they are properly able to update their controls as needed to complete the training missions. Fixes #7172. * var name update
1 parent 46d3e49 commit e567ae7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

code/mission/missiontraining.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,17 @@ SCP_string message_translate_tokens(const char *text)
754754
if (!stricmp(ptr, NOX("none")) && (Training_bind_warning != Missiontime)) {
755755
// check if a warning message should be displayed if the key is unbound
756756
if ( (The_mission.game_type & MISSION_TYPE_TRAINING) || (Always_warn_player_about_unbound_keys && (The_mission.game_type & MISSION_TYPE_SINGLE)) ) {
757+
int xstr_index;
758+
if (Control_config[Failed_key_index].indexXSTR > 1) {
759+
xstr_index = Control_config[Failed_key_index].indexXSTR;
760+
} else if (Control_config[Failed_key_index].indexXSTR == 1) {
761+
xstr_index = CONTROL_CONFIG_XSTR + Failed_key_index;
762+
} else {
763+
xstr_index = -1;
764+
}
757765
r = popup(PF_TITLE_BIG | PF_TITLE_RED, 2, XSTR( "&Bind Control", 424), XSTR( "&Abort mission", 425),
758766
XSTR( "Warning\nYou have no control bound to the action \"%s\". You must do so before you can continue with your training.", 426),
759-
XSTR(Control_config[Failed_key_index].text.c_str(), CONTROL_CONFIG_XSTR + Failed_key_index));
760-
767+
XSTR(Control_config[Failed_key_index].text.c_str(), xstr_index));
761768
if (r) { // do they want to abort the mission?
762769
gameseq_post_event(GS_EVENT_END_GAME);
763770
return buf;

0 commit comments

Comments
 (0)