View Issue Details

IDProjectCategoryView StatusLast Update
0002009FSSCPFREDpublic2012-12-11 01:11
ReporterFUBAR-BDHR Assigned ToCommanderDJ  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.14 
Summary0002009: No warning if reinforcements exceed limit
DescriptionThere is no warning if you exceeded MAX_REINFORCEMENTS (currently 10 but hoping to bump that). It will let you click the checkbox in the ship and wing editor as many times as you like. It apparently avoids going over the limit (good) by removing a previous reinforcement but it doesn't tell you it does it (bad). You find out the hard way when you go to play the mission and have only a sampling of your expected reinforcements.
Additional Information3.6.11 r5620. Probably another one for wxFRED.
TagsNo tags attached.

Relationships

related to 0002745 resolvedValathil FRED will let you add individual ships in a wing as reinforcement units 

Activities

CommanderDJ

2012-11-29 14:08

developer   ~0014227

Tested with current FRED, the issue no longer exists. The Add button is greyed out when you hit the reinforcement limit, and the code contains measures to prevent more reinforcements being added even if a user somehow got past the greyed out button.

FUBAR-BDHR

2012-11-29 17:54

developer   ~0014229

Issue still exists. Simple to reproduce. Add 33 ships to a mission (the limit was bumped to 32) select them all (you can do it one ship at a time if your bored), open the ship editor, go to misc, and toggle reinforcement on. It will only add 32 to the list but will let you select and set as many as you want with no warning that they are not actually being set.

CommanderDJ

2012-11-29 23:46

developer   ~0014231

Ack. Okay, my bad. I'll take a look at this over the weekend.

CommanderDJ

2012-12-03 02:41

developer   ~0014264

FUBAR, could you please test the attached patch and see if it resolves the issue? Thanks.

FUBAR-BDHR

2012-12-03 03:34

developer   ~0014265

Last edited: 2012-12-03 03:35

Looks like the patch still needs some work. If you are at the limit in ships and add a wing the wing will add to the list. To reproduce open 2009.fs2, go to the wing editor and add click the reinforcement checkbox. Hit next. Now the wing is added to the reinforcement list making 33 on the list. If you attempt to hit next or previous you will now get the warning. Now for the really bad part. If you close the window you get a loop of warnings. If you keep hitting OK you eventually get out of that loop but the wing is still added.

Now I seem to have reproduced this one time with ships as well but can't get it to happen again. It may have been because of the issue above already expanding the list to 33.

Note when looking through the mission somehow reinforcement number 14 is ship 33. Perfectly legal just a FYI when counting.

Now for the bad part I found another bug while testing this. Will file that one and relate it to this one.

FUBAR-BDHR

2012-12-03 03:35

developer  

2009.fs2 (27,929 bytes)

CommanderDJ

2012-12-06 09:41

developer   ~0014337

I've uploaded a new patch. This should fix both the wing problem and the infinite loop problem. Let me know what you find.

FUBAR-BDHR

2012-12-06 17:52

developer   ~0014339

Seems to be working.

The only thing I would change if it's even possible is unchecking the flag in the wing editor automatically if it exceeds.

CommanderDJ

2012-12-07 00:47

developer  

2009.patch (1,927 bytes)   
Index: code/fred2/shipflagsdlg.cpp
===================================================================
--- code/fred2/shipflagsdlg.cpp	(revision 9405)
+++ code/fred2/shipflagsdlg.cpp	(working copy)
@@ -419,7 +419,20 @@
 	object *objp = &Objects[shipp->objnum];
 
 	if (m_reinforcement.GetCheck() != 2)
-		set_reinforcement(shipp->ship_name, m_reinforcement.GetCheck());
+	{
+		//Check if we're trying to add more and we've got too many.
+		if( (Num_reinforcements >= MAX_REINFORCEMENTS) && (m_reinforcement.GetCheck() == 1))
+		{
+			char error_message[256];
+			sprintf(error_message, "Too many reinforcements; could not add ship '%s' to reinforcement list!", shipp->ship_name); 
+			MessageBox(error_message);
+		}
+		//Otherwise, just update as normal.
+		else
+		{
+			set_reinforcement(shipp->ship_name, m_reinforcement.GetCheck());	
+		}
+	}
 
 	switch (m_cargo_known.GetCheck()) {
 		case 1:
Index: code/fred2/wing_editor.cpp
===================================================================
--- code/fred2/wing_editor.cpp	(revision 9405)
+++ code/fred2/wing_editor.cpp	(working copy)
@@ -701,7 +701,28 @@
 			Update_window = 1;
 		}
 
-		if (set_reinforcement(str, m_reinforcement) == 1) {
+		//Check if we're trying to add more and we've got too many.
+		if( (Num_reinforcements >= MAX_REINFORCEMENTS) && (m_reinforcement == 1))
+		{
+			if (bypass_errors)
+				return 1;
+
+			bypass_errors = 1;
+
+			char error_message[256];
+			sprintf(error_message, "Too many reinforcements; could not add wing '%s' to reinforcement list!", str); 
+			MessageBox(error_message, "Error", MB_ICONEXCLAMATION | MB_OK);
+
+			//clear the flag
+			m_reinforcement = 0;
+			UpdateData(FALSE);
+
+			return -1;
+
+		}
+		//Otherwise, just update as normal.
+		else if (set_reinforcement(str, m_reinforcement) == 1) 
+		{
 			free_sexp2(Wings[cur_wing].arrival_cue);
 			Wings[cur_wing].arrival_cue = Locked_sexp_false;
 		}
2009.patch (1,927 bytes)   

CommanderDJ

2012-12-07 00:48

developer   ~0014343

There we go. All done. Now we just have to wait for someone with commit access to put this in.

The_E

2012-12-08 19:55

administrator   ~0014359

Committed to trunk in 9408

Issue History

Date Modified Username Field Change
2009-10-27 05:48 FUBAR-BDHR New Issue
2012-11-29 14:08 CommanderDJ Note Added: 0014227
2012-11-29 14:08 CommanderDJ Status new => closed
2012-11-29 14:08 CommanderDJ Assigned To => CommanderDJ
2012-11-29 14:08 CommanderDJ Resolution open => no change required
2012-11-29 14:08 CommanderDJ Fixed in Version => 3.6.14
2012-11-29 17:54 FUBAR-BDHR Note Added: 0014229
2012-11-29 17:54 FUBAR-BDHR Status closed => feedback
2012-11-29 17:54 FUBAR-BDHR Resolution no change required => reopened
2012-11-29 23:46 CommanderDJ Note Added: 0014231
2012-12-03 02:40 CommanderDJ File Added: 2009.patch
2012-12-03 02:41 CommanderDJ Note Added: 0014264
2012-12-03 02:41 CommanderDJ Status feedback => code review
2012-12-03 02:42 CommanderDJ Product Version 3.6.11 => 3.6.14
2012-12-03 02:42 CommanderDJ Fixed in Version 3.6.14 =>
2012-12-03 03:34 FUBAR-BDHR Note Added: 0014265
2012-12-03 03:35 FUBAR-BDHR File Added: 2009.fs2
2012-12-03 03:35 FUBAR-BDHR Note Edited: 0014265
2012-12-03 03:44 FUBAR-BDHR Relationship added related to 0002745
2012-12-06 09:40 CommanderDJ File Deleted: 2009.patch
2012-12-06 09:40 CommanderDJ File Added: 2009.patch
2012-12-06 09:41 CommanderDJ Note Added: 0014337
2012-12-06 17:52 FUBAR-BDHR Note Added: 0014339
2012-12-07 00:46 CommanderDJ File Deleted: 2009.patch
2012-12-07 00:47 CommanderDJ File Added: 2009.patch
2012-12-07 00:48 CommanderDJ Note Added: 0014343
2012-12-08 19:55 The_E Note Added: 0014359
2012-12-08 19:55 The_E Status code review => resolved
2012-12-08 19:55 The_E Resolution reopened => fixed
2012-12-11 01:11 Goober5000 Summary No warning if reinforements exceede limit => No warning if reinforcements exceed limit