2018-08-15 03:54 EDT


View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002178FSSCPgameplaypublic2010-04-18 23:48
ReporterThe_E 
Assigned Toiss_mneur 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version3.6.12 RC1 
Target VersionFixed in Version3.6.12 
Summary0002178: Assert in missiontraining.cpp, line 924 for empty training messages
DescriptionTo work around the "only one sound may be played via play-sound-from-file" rule, General Battuta used empty training messages.

However, these cause asserts on debug builds, which I believe are caused by a faulty check.

The assertion reads:
"Assert(Training_num_lines > 0);"
Training_num_lines is determined by running the message that is to be sent through split_str, which may return 0 on empty messages (that is, messages consisting entirely of whitespace).
Changing the check to Assert(Training_num_lines >= 0) fixes this.
TagsNo tags attached.
Attached Files
  • patch file icon 2178_patch.patch (1,576 bytes) 2010-04-18 13:33 -
    Index: code/mission/missiontraining.cpp
    ===================================================================
    --- code/mission/missiontraining.cpp	(revision 6057)
    +++ code/mission/missiontraining.cpp	(working copy)
    @@ -785,6 +785,8 @@
     	training_process_message(Training_buf);
     	Training_num_lines = split_str(Training_buf, TRAINING_LINE_WIDTH, Training_line_sizes, Training_lines, MAX_TRAINING_MESSAGE_LINES);
     
    +	Assert( Training_num_lines >= 0, "split_str encountered an error" );
    +
     	if (message_play_training_voice(Messages[m].wave_info.index) < 0) {
     		if (length > 0)
     			Training_message_timestamp = timestamp(length * 1000);
    @@ -917,20 +919,18 @@
     		return;
     	}
     
    -	// next two lines moved to message_training_setup() - taylor
    -//	training_process_message(Training_buf);
    -//	Training_num_lines = split_str(Training_buf, TRAINING_LINE_WIDTH, Training_line_sizes, Training_lines, MAX_TRAINING_MESSAGE_LINES);
    +	// the code that preps the training message and counts the number of lines
    +	// has been moved to message_training_setup()
     
    -	Assert(Training_num_lines > 0);
    +	if (Training_num_lines <= 0){
    +		return;
    +	}
    +
     	for (i=0; i<Training_num_lines; i++) {
     		Training_lines[i][Training_line_sizes[i]] = 0;
     		drop_leading_white_space(Training_lines[i]);
     	}
     
    -	if (Training_num_lines <= 0){
    -		return;
    -	}
    -
     	height = gr_get_font_height();
     	gr_set_shader(&Training_msg_glass);
     	gr_shade(Training_message_window_coords[gr_screen.res][0], Training_message_window_coords[gr_screen.res][1], TRAINING_MESSAGE_WINDOW_WIDTH, Training_num_lines * height + height);
    
    patch file icon 2178_patch.patch (1,576 bytes) 2010-04-18 13:33 +

-Relationships
+Relationships

-Notes

~0011888

iss_mneur (developer)

Attached a fix. It moves the Assert to the location that the split_str is actually called. Also, moves the number of lines guard to before the number of lines is used for anything.

~0011891

Goober5000 (administrator)

Patch added in revision 6062.
+Notes

-Issue History
Date Modified Username Field Change
2010-04-09 15:04 The_E New Issue
2010-04-18 13:33 iss_mneur File Added: 2178_patch.patch
2010-04-18 13:43 iss_mneur Note Added: 0011888
2010-04-18 23:48 Goober5000 Note Added: 0011891
2010-04-18 23:48 Goober5000 Assigned To => iss_mneur
2010-04-18 23:48 Goober5000 Status new => resolved
2010-04-18 23:48 Goober5000 Resolution open => fixed
2010-04-18 23:48 Goober5000 Fixed in Version => 3.6.12
+Issue History