@@ -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 );
0 commit comments