@@ -374,7 +374,7 @@ extern fix game_get_overall_frametime(); // for texture animation
374374
375375// local prototypes
376376void parse_player_info2 (mission *pm);
377- void post_process_mission ();
377+ bool post_process_mission ();
378378int allocate_subsys_status ();
379379void parse_common_object_data (p_object *objp);
380380void parse_asteroid_fields (mission *pm);
@@ -5598,7 +5598,7 @@ void parse_variables()
55985598 }
55995599}
56005600
5601- int parse_mission (mission *pm, int flags)
5601+ bool parse_mission (mission *pm, int flags)
56025602{
56035603 int saved_warning_count = Global_warning_count;
56045604 int saved_error_count = Global_error_count;
@@ -5639,7 +5639,7 @@ int parse_mission(mission *pm, int flags)
56395639 Current_file_checksum = netmisc_calc_checksum (pm,MISSION_CHECKSUM_SIZE );
56405640
56415641 if (flags & MPF_ONLY_MISSION_INFO )
5642- return 0 ;
5642+ return true ;
56435643
56445644 parse_plot_info (pm);
56455645 parse_variables ();
@@ -5666,7 +5666,7 @@ int parse_mission(mission *pm, int flags)
56665666 // if running on standalone server, just print to the log
56675667 if (Game_mode & GM_STANDALONE_SERVER ) {
56685668 mprintf ((" Warning! Could not load %d ship classes!" , Num_unknown_ship_classes));
5669- return - 2 ;
5669+ return false ;
56705670 }
56715671 // don't do this in FRED; we will display a separate popup
56725672 else if (!Fred_running) {
@@ -5708,12 +5708,14 @@ int parse_mission(mission *pm, int flags)
57085708 // now display the popup
57095709 int popup_rval = popup (PF_TITLE_BIG | PF_TITLE_RED , 2 , POPUP_NO , POPUP_YES , text);
57105710 if (popup_rval == 0 ) {
5711- return - 2 ;
5711+ return false ;
57125712 }
57135713 }
57145714 }
57155715
5716- post_process_mission ();
5716+ if (!post_process_mission ()) {
5717+ return false ;
5718+ }
57175719
57185720 if ((saved_warning_count - Global_warning_count) > 10 || (saved_error_count - Global_error_count) > 0 ) {
57195721 char text[512 ];
@@ -5724,10 +5726,10 @@ int parse_mission(mission *pm, int flags)
57245726 log_printf (LOGFILE_EVENT_LOG , " Mission %s loaded.\n " , pm->name );
57255727
57265728 // success
5727- return 0 ;
5729+ return true ;
57285730}
57295731
5730- void post_process_mission ()
5732+ bool post_process_mission ()
57315733{
57325734 int i;
57335735 int indices[MAX_SHIPS ], objnum;
@@ -5840,21 +5842,18 @@ void post_process_mission()
58405842
58415843 // entering this if statement will result in program termination!!!!!
58425844 // print out an error based on the return value from check_sexp_syntax()
5845+ // G5K: now entering this statement simply aborts the mission load
58435846 if ( result ) {
58445847 SCP_string sexp_str;
58455848 SCP_string error_msg;
58465849
58475850 convert_sexp_to_string (sexp_str, i, SEXP_ERROR_CHECK_MODE );
58485851 truncate_message_lines (sexp_str, 30 );
58495852 sprintf (error_msg, " %s.\n\n In sexpression: %s\n (Error appears to be: %s)" , sexp_error_message (result), sexp_str.c_str (), Sexp_nodes[bad_node].text );
5853+ Warning (LOCATION , " %s" , error_msg.c_str ());
58505854
5851- if (!Fred_running) {
5852- nprintf ((" Error" , " %s" , error_msg.c_str ()));
5853- Error (LOCATION , " %s" , error_msg.c_str ());
5854- } else {
5855- nprintf ((" Warning" , " %s" , error_msg.c_str ()));
5856- Warning (LOCATION , " %s" , error_msg.c_str ());
5857- }
5855+ // syntax errors are unrecoverable, so abort
5856+ return false ;
58585857 }
58595858 }
58605859 }
@@ -5958,6 +5957,9 @@ void post_process_mission()
59585957 mission_hotkey_reset_saved ();
59595958 }
59605959 Last_file_checksum = Current_file_checksum;
5960+
5961+ // success
5962+ return true ;
59615963}
59625964
59635965int get_mission_info (const char *filename, mission *mission_p, bool basic)
@@ -6026,9 +6028,10 @@ void parse_init(bool basic)
60266028// mai parse routine for parsing a mission. The default parameter flags tells us which information
60276029// to get when parsing the mission. 0 means get everything (default). Other flags just gets us basic
60286030// info such as game type, number of players etc.
6029- int parse_main (const char *mission_name, int flags)
6031+ bool parse_main (const char *mission_name, int flags)
60306032{
6031- int rval, i;
6033+ int i;
6034+ bool rval;
60326035
60336036 // reset parse error stuff
60346037 Num_unknown_ship_classes = 0 ;
@@ -6057,7 +6060,7 @@ int parse_main(const char *mission_name, int flags)
60576060 Current_file_length = -1 ;
60586061 Current_file_checksum = 0 ;
60596062
6060- rval = - 1 ;
6063+ rval = false ;
60616064 break ;
60626065 }
60636066
@@ -6083,7 +6086,7 @@ int parse_main(const char *mission_name, int flags)
60836086 catch (const parse::ParseException& e)
60846087 {
60856088 mprintf ((" MISSIONS: Unable to parse '%s'! Error message = %s.\n " , mission_name, e.what ()));
6086- rval = 1 ;
6089+ rval = false ;
60876090 break ;
60886091 }
60896092 } while (0 );
0 commit comments