Skip to content

Commit a2b05f0

Browse files
committed
even more fixes for the skip-training-mission crash
As noted in #4412, it's possible for `Campaign.current_mission` to be -1 even in campaign mode. This explictly checks for that.
1 parent cc2b9fc commit a2b05f0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

code/mission/missioncampaign.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ void mission_campaign_store_goals_and_events()
951951
int cur, i;
952952
cmission *mission_obj;
953953

954-
if (!(Game_mode & GM_CAMPAIGN_MODE))
954+
if (!(Game_mode & GM_CAMPAIGN_MODE) || (Campaign.current_mission < 0))
955955
return;
956956

957957
cur = Campaign.current_mission;
@@ -1030,7 +1030,7 @@ void mission_campaign_store_variables(int persistence_type, bool store_red_alert
10301030
int cur, i, j;
10311031
cmission *mission_obj;
10321032

1033-
if (!(Game_mode & GM_CAMPAIGN_MODE))
1033+
if (!(Game_mode & GM_CAMPAIGN_MODE) || (Campaign.current_mission < 0))
10341034
return;
10351035

10361036
cur = Campaign.current_mission;
@@ -1098,7 +1098,7 @@ void mission_campaign_store_variables(int persistence_type, bool store_red_alert
10981098
// jg18 - adapted from mission_campaign_store_variables()
10991099
void mission_campaign_store_containers(ContainerType persistence_type, bool store_red_alert)
11001100
{
1101-
if (!(Game_mode & GM_CAMPAIGN_MODE))
1101+
if (!(Game_mode & GM_CAMPAIGN_MODE) || (Campaign.current_mission < 0))
11021102
return;
11031103

11041104
if (!sexp_container_has_persistent_non_eternal_containers()) {
@@ -1901,7 +1901,7 @@ void mission_campaign_save_on_close_variables()
19011901
int i;
19021902

19031903
// make sure we are actually playing a single-player campaign
1904-
if (!(Game_mode & GM_CAMPAIGN_MODE) || (Campaign.type != CAMPAIGN_TYPE_SINGLE))
1904+
if (!(Game_mode & GM_CAMPAIGN_MODE) || (Campaign.type != CAMPAIGN_TYPE_SINGLE) || (Campaign.current_mission < 0))
19051905
return;
19061906

19071907
// now save variables
@@ -1941,7 +1941,7 @@ void mission_campaign_save_on_close_variables()
19411941
void mission_campaign_save_on_close_containers()
19421942
{
19431943
// make sure we are actually playing a single-player campaign
1944-
if (!(Game_mode & GM_CAMPAIGN_MODE) || (Campaign.type != CAMPAIGN_TYPE_SINGLE))
1944+
if (!(Game_mode & GM_CAMPAIGN_MODE) || (Campaign.type != CAMPAIGN_TYPE_SINGLE) || (Campaign.current_mission < 0))
19451945
return;
19461946

19471947
// now save containers

0 commit comments

Comments
 (0)