Skip to content

Commit ba1f11f

Browse files
authored
Merge pull request scp-fs2open#7280 from Goober5000/campaign_optional_string_fred
optional_string_fred fixes
2 parents 7de1884 + cbb30f9 commit ba1f11f

2 files changed

Lines changed: 31 additions & 24 deletions

File tree

code/missioneditor/campaignsave.cpp

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,19 @@ int Fred_campaign_save::save_campaign_file(const char* pathname, const SCP_vecto
5555

5656
// campaign flags - Goober5000
5757
if (save_config.save_format != MissionFormat::RETAIL) {
58-
optional_string_fred("$Flags:");
59-
parse_comments();
60-
fout(" %d\n", Campaign.flags);
58+
if (optional_string_fred("$Flags:")) {
59+
parse_comments();
60+
} else {
61+
fout("\n$Flags:");
62+
}
63+
fout(" %d", Campaign.flags);
6164
}
6265

6366
if (save_config.save_format != MissionFormat::RETAIL && !Campaign.custom_data.empty()) {
6467
if (optional_string_fred("$begin_custom_data_map")) {
6568
parse_comments(2);
6669
} else {
67-
fout("\n$begin_custom_data_map");
70+
fout("\n\n$begin_custom_data_map");
6871
}
6972

7073
for (const auto& pair : Campaign.custom_data) {
@@ -79,21 +82,29 @@ int Fred_campaign_save::save_campaign_file(const char* pathname, const SCP_vecto
7982
}
8083

8184
// write out the ships and weapons which the player can start the campaign with
82-
optional_string_fred("+Starting Ships: (");
83-
parse_comments(2);
85+
if (optional_string_fred("+Starting Ships:")) {
86+
parse_comments(2);
87+
} else {
88+
fout("\n\n+Starting Ships:");
89+
}
90+
fout(" (");
8491
for (int i = 0; i < ship_info_size(); i++) {
8592
if (Campaign.ships_allowed[i])
86-
fout(" \"%s\" ", Ship_info[i].name);
93+
fout(" \"%s\"", Ship_info[i].name);
8794
}
88-
fout(")\n");
95+
fout(" )");
8996

90-
optional_string_fred("+Starting Weapons: (");
91-
parse_comments();
97+
if (optional_string_fred("+Starting Weapons:")) {
98+
parse_comments(2);
99+
} else {
100+
fout("\n\n+Starting Weapons:");
101+
}
102+
fout(" (");
92103
for (int i = 0; i < weapon_info_size(); i++) {
93104
if (Campaign.weapons_allowed[i])
94-
fout(" \"%s\" ", Weapon_info[i].name);
105+
fout(" \"%s\"", Weapon_info[i].name);
95106
}
96-
fout(")\n");
107+
fout(" )");
97108

98109
fred_parse_flag = 0;
99110
for (int i = 0; i < Campaign.num_missions; i++) {
@@ -105,7 +116,7 @@ int Fred_campaign_save::save_campaign_file(const char* pathname, const SCP_vecto
105116
parse_comments(2);
106117
fout(" %s", cm.name);
107118

108-
if (strlen(cm.briefing_cutscene)) {
119+
if (strlen(cm.briefing_cutscene) > 0) {
109120
if (optional_string_fred("+Briefing Cutscene:", "$Mission"))
110121
parse_comments();
111122
else
@@ -196,9 +207,9 @@ int Fred_campaign_save::save_campaign_file(const char* pathname, const SCP_vecto
196207
// now save campaign loop sexp
197208
if (mission_loop || mission_fork) {
198209
if (mission_loop)
199-
required_string_fred("\n+Mission Loop:");
210+
required_string_fred("+Mission Loop:");
200211
else
201-
required_string_fred("\n+Mission Fork:");
212+
required_string_fred("+Mission Fork:");
202213
parse_comments();
203214

204215
int num_mission_special = 0;
@@ -274,7 +285,7 @@ int Fred_campaign_save::save_campaign_file(const char* pathname, const SCP_vecto
274285
if (optional_string_fred("+Level:", "$Mission:")) {
275286
parse_comments();
276287
} else {
277-
fout("\n\n+Level:");
288+
fout("\n+Level:");
278289
}
279290

280291
fout(" %d", cm.level);

code/missioneditor/missionsave.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,8 +2158,7 @@ int Fred_mission_save::save_fiction()
21582158
else
21592159
fout("\n$Font:");
21602160
fout(" %s", stage.font_filename);
2161-
} else
2162-
optional_string_fred("$Font:");
2161+
}
21632162

21642163
// save voice
21652164
if (strlen(stage.voice_filename) > 0) //-V805
@@ -2169,8 +2168,7 @@ int Fred_mission_save::save_fiction()
21692168
else
21702169
fout("\n$Voice:");
21712170
fout(" %s", stage.voice_filename);
2172-
} else
2173-
optional_string_fred("$Voice:");
2171+
}
21742172

21752173
// save UI
21762174
if (strlen(stage.ui_name) > 0) {
@@ -2179,8 +2177,7 @@ int Fred_mission_save::save_fiction()
21792177
else
21802178
fout("\n$UI:");
21812179
fout(" %s", stage.ui_name);
2182-
} else
2183-
optional_string_fred("$UI:");
2180+
}
21842181

21852182
// save background
21862183
save_custom_bitmap("$Background 640:",
@@ -2198,8 +2195,7 @@ int Fred_mission_save::save_fiction()
21982195
else
21992196
fout("\n$Formula:");
22002197
fout(" %s", sexp_out.c_str());
2201-
} else
2202-
optional_string_fred("$Formula:");
2198+
}
22032199
}
22042200
} else {
22052201
SCP_string msg = "Warning: This mission contains fiction viewer data, but you are saving in the retail "

0 commit comments

Comments
 (0)