2018-10-15 14:26 EDT


View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001680FSSCPFREDpublic2008-10-28 14:15
ReporterFUBAR-BDHR 
Assigned Tokarajorma 
PriorityhighSeveritycrashReproducibilityalways
StatusresolvedResolutionfixed 
Product Version3.6.9 
Target VersionFixed in Version3.6.10 
Summary0001680: Disbanding wing results in "Assert: (wing < MAX_WINGS) && Wings[wing].wave_count"
DescriptionAttempting to disbanding a wing that is referenced in an event I get the usual yes no cancel window. I am going to delete the event so I said yes. Second window pops up for the same event and again I say yes. Then I receive a window with a $ and 2 squares. Clicking OK (only option) gave me a message something like wave threshold to high setting to -1. That results in an infinite loop of that same error over and over.

Tried running debug build and instead of the $ and 2 box message I received one with a bunch of exclamation points followed by this:

Assert: (wing < MAX_WINGS) && Wings[wing].wave_count
File: d:\c++\freespace\fs2_open 3.6.9 - btrl\code\fred2\shipeditordlg.cpp
Line: 1419
[This filename points to the location of a file on the computer that built this executable]

Call stack:
------------------------------------------------------------------
    fred2_open_3_6_9_debug_INF.exe 00458bce()
    fred2_open_3_6_9_debug_INF.exe 0043fd2a()
    fred2_open_3_6_9_debug_INF.exe 0094f9ed()
    fred2_open_3_6_9_debug_INF.exe 0094f184()
    fred2_open_3_6_9_debug_INF.exe 0094cd29()
    fred2_open_3_6_9_debug_INF.exe 0094d1c5()
    USER32.dll 7e418734()
    USER32.dll 7e418816()
    USER32.dll 7e41c63f()
    USER32.dll 7e41c665()
    OPENGL32.dll 5ed2699b()
    USER32.dll 7e418734()
    USER32.dll 7e418816()
    USER32.dll 7e41b4c0()
    USER32.dll 7e41b50c()
------------------------------------------------------------------
Additional InformationTBP build of FRED 3.6.9 dated 3/30/08. To reproduce the error load the attached mission, open the wing editor, select maint bot wing 4 and hit disband.
TagsNo tags attached.
Attached Files
  • ? file icon FUBAR_M02.fs2 (36,476 bytes) 2008-05-01 04:25
  • log file icon fs2_open.log (81,272 bytes) 2008-05-01 04:25
  • ? file icon Disband Me.fs2 (4,036 bytes) 2008-10-24 18:04
  • diff file icon 1680.diff (3,443 bytes) 2008-10-25 06:24 -
    Index: code/fred2/wing_editor.cpp
    ===================================================================
    --- code/fred2/wing_editor.cpp	(revision 4926)
    +++ code/fred2/wing_editor.cpp	(working copy)
    @@ -1007,26 +1007,26 @@
     
     	if (m_threshold >= Wings[cur_wing].wave_count) {
     		m_threshold = Wings[cur_wing].wave_count - 1;
    -		if (!bypass_errors)
    +		if (!bypass_errors) {
     			sprintf(buf, "Wave threshold is set too high.  Value has been lowered to %d", (int) m_threshold);
    -
    -		MessageBox(buf);
    +			MessageBox(buf);
    +		}
     	}
     
     	if (m_threshold + Wings[cur_wing].wave_count > MAX_SHIPS_PER_WING) {
     		m_threshold = MAX_SHIPS_PER_WING - Wings[cur_wing].wave_count;
    -		if (!bypass_errors)
    +		if (!bypass_errors) {
     			sprintf(buf, "Wave threshold is set too high.  Value has been lowered to %d", (int) m_threshold);
    -
    -		MessageBox(buf);
    +			MessageBox(buf);
    +		}
     	}
     
     	if (m_waves < 1) {
     		m_waves = 1;
    -		if (!bypass_errors)
    +		if (!bypass_errors) {
     			sprintf(buf, "Number of waves illegal.  Has been set to 1.", (int) m_waves);
    -
    -		MessageBox(buf);
    +			MessageBox(buf);
    +		}
     	}
     
     	MODIFY(Wings[cur_wing].special_ship, m_special_ship);
    @@ -1036,10 +1036,11 @@
     	MODIFY(Wings[cur_wing].departure_location, m_departure_location);
     	MODIFY(Wings[cur_wing].arrival_delay, m_arrival_delay);
     	if (m_arrival_delay_min > m_arrival_delay_max) {
    -		if (!bypass_errors)
    +		if (!bypass_errors) {
     			sprintf(buf, "Arrival delay minimum greater than maximum.  Value lowered to %d", m_arrival_delay_max);
    +			MessageBox(buf);
    +		}
     
    -		MessageBox(buf);
     		m_arrival_delay_min = m_arrival_delay_max;
     	}
     
    @@ -1054,12 +1055,14 @@
     		if (((m_arrival_location != ARRIVE_AT_LOCATION) && (m_arrival_location != ARRIVE_FROM_DOCK_BAY)) && (i >= 0) && !(i & SPECIAL_ARRIVAL_ANCHOR_FLAG)) {
     			d = int(min(500, 2.0f * Objects[Ships[i].objnum].radius));
     			if ((Wings[cur_wing].arrival_distance < d) && (Wings[cur_wing].arrival_distance > -d)) {
    -				if (!bypass_errors)
    +				if (!bypass_errors) {
     					sprintf(buf, "Ship must arrive at least %d meters away from target.\n"
     						"Value has been reset to this.  Use with caution!\r\n"
     						"Reccomended distance is %d meters.\r\n", d, (int)(2.0f * Objects[Ships[i].objnum].radius) );
     
    -				MessageBox(buf);
    +					MessageBox(buf);
    +				}
    +
     				if (Wings[cur_wing].arrival_distance < 0)
     					Wings[cur_wing].arrival_distance = -d;
     				else
    Index: code/fred2/wing.cpp
    ===================================================================
    --- code/fred2/wing.cpp	(revision 4926)
    +++ code/fred2/wing.cpp	(working copy)
    @@ -337,12 +337,17 @@
     	for (i=0; i<total; i++) {
     		ptr = &Objects[wing_objects[wing_num][i]];
     		if (ptr->type == OBJ_SHIP)
    -			remove_ship_from_wing(ptr->instance);
    +			remove_ship_from_wing(ptr->instance, 0);
     		else if (ptr->type == OBJ_START)
    -			remove_player_from_wing(ptr->instance);
    +			remove_player_from_wing(ptr->instance, 0);
     	}
     
     	Assert(!Wings[wing_num].wave_count);
    +
    +	Wings[wing_num].wave_count = 0;
    +	Wings[wing_num].wing_squad_filename[0] = '\0';
    +	Wings[wing_num].wing_insignia_texture = -1;
    +
     	Ship_editor_dialog.initialize_data(1);
     	Ship_editor_dialog.bypass_errors = Wing_editor_dialog.bypass_errors = 0;
     
    @@ -350,6 +355,13 @@
     		set_cur_wing(cur_wing = -1);  // yes, one '=' is correct.
     	}
     
    +	free_sexp2(Wings[wing_num].arrival_cue);
    +	free_sexp2(Wings[wing_num].departure_cue);
    +
    +	Num_wings--;
    +
    +	update_custom_wing_indexes();
    +
     	set_modified();
     }
     
    
    diff file icon 1680.diff (3,443 bytes) 2008-10-25 06:24 +

-Relationships
+Relationships

-Notes

~0009334

karajorma (administrator)

Does this only occur if you disband the wing with the ships editor open?

~0009337

FUBAR-BDHR (developer)

When I was trying it I did not have the ships editor open just the wing editor. I may have had it opened the first time I crashed but the next time and the time I ran debug I did not. Just opened the mission, went to the wing editor and started disbanding the wings. I can try it with the ship editor open lather and see what happens.

~0009882

chief1983 (administrator)

Definitely happens in the most recent 4670 revision, regardless of VS2008 or VC6 as a compiler. Crashes the same in both. Gonna bump priority and confirm. Kara, I'm guessing you'll be taking another look at this, but if you think it's not worth fixing in the immediate future then feel free to bump priority back down.

~0010063

chief1983 (administrator)

Reading my last note, I must have meant 4870 and not 4670. Had to be a typo.

~0010117

karajorma (administrator)

I'll be damned if I can figure out what the hell is going on here. I managed to chase the error down to somewhere in MessageBox()

Somewhere in afxcomctl32 this function is being called.

 AFX_ISOLATIONAWARE_STATICLINK_FUNC(int ,MessageBoxA,(HWND hWnd,LPCSTR lpText,LPCSTR lpCaption,UINT uType),(hWnd,lpText,lpCaption,uType),0)

The data going in doesn't look particularly dodgy so I have no idea what is causing it at all.

What's really strange is that error is coming from sexp_reference_handler() from the first of these two lines

r = Fred_main_wnd->MessageBox(msg, "Warning", MB_YESNOCANCEL | MB_ICONEXCLAMATION);
if (r == IDNO)

Yet if I breakpoint both lines I can still get the code to give the "Disbanding wing results in "Assert: (wing < MAX_WINGS) && Wings[wing].wave_count"" error. Without hitting the second breakpoint! I have no explanation for this. After the weird error message the program is somehow leaving the Messagebox() code and somehow continuing to execute FRED2 code without passing any intervening code.

Anyway I'm attaching a much simpler mission that displays the exact same behaviour.

~0010121

taylor (administrator)

The attached diff seems to fix it, though it really needs more of a test than what I put it through before it gets committed.

The first problem is that dialog that just gives garbage characters. That is a simple one to deal with. When it gets to one particular function that bypasses errors, the bypass skips the creation of the error message, but still tries to show the popup. Simply putting the popup in the same bypass check makes sure that it will skip both and then avoid giving you a popup with garbage text (or possibly even crashing).

The second problem is Volition, who wrote some crappy code. ;) The delete wing and disband wing buttons actually did the same thing. The double "referenced an event" message is simply because the function that generates it got called twice, once in the disband function and once in the delete function. This issue not only caused the weird error messages, and the Assert() call getting called when it never should have gotten that far, but also made disbanding a wing also delete the ships that were in said wing. The fix for this is to make the disband function actually do the wing cleanup like the delete wing function does. The trick is merely passing a 0 to remove_ship_from_wing() so that it avoids calling the delete wing function once the wing would be empty. Now you get the wing removed, but the ships remain intact (other than being renamed).

~0010133

taylor (administrator)

No objections. No complaints. So...


Fixered.
+Notes

-Issue History
Date Modified Username Field Change
2008-05-01 04:25 FUBAR-BDHR New Issue
2008-05-01 04:25 FUBAR-BDHR File Added: FUBAR_M02.fs2
2008-05-01 04:25 FUBAR-BDHR File Added: fs2_open.log
2008-05-15 16:07 karajorma Note Added: 0009334
2008-05-15 19:55 FUBAR-BDHR Note Added: 0009337
2008-10-09 01:01 chief1983 Note Added: 0009882
2008-10-09 01:01 chief1983 Priority normal => high
2008-10-09 01:01 chief1983 Status new => confirmed
2008-10-19 13:29 karajorma Status confirmed => assigned
2008-10-19 13:29 karajorma Assigned To => karajorma
2008-10-20 02:46 chief1983 Note Added: 0010063
2008-10-24 18:03 karajorma Note Added: 0010117
2008-10-24 18:04 karajorma File Added: Disband Me.fs2
2008-10-25 06:24 taylor File Added: 1680.diff
2008-10-25 06:33 taylor Note Added: 0010121
2008-10-28 14:15 taylor Status assigned => resolved
2008-10-28 14:15 taylor Fixed in Version => 3.6.10
2008-10-28 14:15 taylor Resolution open => fixed
2008-10-28 14:15 taylor Note Added: 0010133
+Issue History