View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update | 
|---|---|---|---|---|---|
| 0002178 | FSSCP | gameplay | public | 2010-04-09 19:04 | 2010-04-19 03:48 | 
| Reporter | The_E | Assigned To | iss_mneur | ||
| Priority | normal | Severity | minor | Reproducibility | always | 
| Status | resolved | Resolution | fixed | ||
| Product Version | 3.6.12 RC1 | ||||
| Fixed in Version | 3.6.12 | ||||
| Summary | 0002178: Assert in missiontraining.cpp, line 924 for empty training messages | ||||
| Description | To 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. | ||||
| Tags | No tags attached. | ||||
| 
 2010-04-18 17:33 
 |  2178_patch.patch (1,576 bytes)   
 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);
 | 
|  | 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. | 
|  | Patch added in revision 6062. | 
| Date Modified | Username | Field | Change | 
|---|---|---|---|
| 2010-04-09 19:04 | The_E | New Issue | |
| 2010-04-18 17:33 | iss_mneur | File Added: 2178_patch.patch | |
| 2010-04-18 17:43 | iss_mneur | Note Added: 0011888 | |
| 2010-04-19 03:48 | Goober5000 | Note Added: 0011891 | |
| 2010-04-19 03:48 | Goober5000 | Assigned To | => iss_mneur | 
| 2010-04-19 03:48 | Goober5000 | Status | new => resolved | 
| 2010-04-19 03:48 | Goober5000 | Resolution | open => fixed | 
| 2010-04-19 03:48 | Goober5000 | Fixed in Version | => 3.6.12 | 
