Skip to content

Commit 1930943

Browse files
authored
Auto-accept completed campaign mission before exiting game from debriefing screen via options menu (#4450)
1 parent 0121e43 commit 1930943

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

code/menuui/optionsmenu.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "menuui/optionsmenu.h"
2626
#include "menuui/optionsmenumulti.h"
2727
#include "mission/missionbriefcommon.h"
28+
#include "missionui/missiondebrief.h"
2829
#include "missionui/missionscreencommon.h"
2930
#include "nebula/neb.h"
3031
#include "network/multi.h"
@@ -707,8 +708,13 @@ void options_button_pressed(int n)
707708
case ABORT_GAME_BUTTON:
708709
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
709710
choice = popup( PF_NO_NETWORKING | PF_BODY_BIG, 2, POPUP_NO, POPUP_YES, XSTR( "Exit Game?", 374));
710-
if ( choice == 1 )
711+
if ( choice == 1 ) {
712+
if (gameseq_get_state(1) == GS_STATE_DEBRIEF && (Game_mode & GM_CAMPAIGN_MODE)) {
713+
// auto-accept mission outcome before quitting
714+
debrief_maybe_auto_accept();
715+
}
711716
gameseq_post_event(GS_EVENT_QUIT_GAME);
717+
}
712718
break;
713719

714720
case CONTROL_CONFIG_BUTTON:

code/missionui/missiondebrief.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ int Debrief_should_show_popup = 1;
378378
static int Debrief_skip_popup_already_shown = 0;
379379

380380
void debrief_text_init();
381+
bool debrief_can_accept();
381382
void debrief_accept(int ok_to_post_start_game_event = 1);
382383
void debrief_kick_selected_player();
383384

@@ -1268,12 +1269,17 @@ void debrief_assemble_optional_mission_popup_text(char *buffer, char *mission_lo
12681269
strcat(buffer, XSTR("\n\n\nDo you want to play the optional mission?", 1491));
12691270
}
12701271

1272+
bool debrief_can_accept()
1273+
{
1274+
return !(/*Cheats_enabled ||*/ Turned_traitor || Must_replay_mission);
1275+
}
1276+
12711277
// what to do when the accept button is hit
12721278
void debrief_accept(int ok_to_post_start_game_event)
12731279
{
12741280
int go_loop = 0;
12751281

1276-
if ( (/*Cheats_enabled ||*/ Turned_traitor || Must_replay_mission) && (Game_mode & GM_CAMPAIGN_MODE) ) {
1282+
if ( !debrief_can_accept() && (Game_mode & GM_CAMPAIGN_MODE) ) {
12771283
const char *str;
12781284
int z;
12791285

@@ -2556,6 +2562,13 @@ void debrief_handle_player_drop()
25562562
debrief_rebuild_player_list();
25572563
}
25582564

2565+
void debrief_maybe_auto_accept()
2566+
{
2567+
if (debrief_can_accept()) {
2568+
debrief_accept(0);
2569+
}
2570+
}
2571+
25592572
void debrief_disable_accept()
25602573
{
25612574
}

code/missionui/missiondebrief.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void debrief_close();
2525
void debrief_rebuild_player_list();
2626
void debrief_handle_player_drop();
2727

28+
void debrief_maybe_auto_accept();
2829
void debrief_disable_accept();
2930
void debrief_assemble_optional_mission_popup_text(char *buffer, char *mission_loop_desc);
3031

0 commit comments

Comments
 (0)