View Issue Details

IDProjectCategoryView StatusLast Update
0002934FSSCPFREDpublic2014-07-01 01:21
ReporterAxem Assigned ToMageKing17  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0002934: FRED too lazy to choose proper alt names
DescriptionIf I have a super super ship and I want to declare that in the mission, I could go change its alt name to be "Super Super Ship."

And if I have just a super ship, I could go change that ship's alt name just to be "Super Ship."

But hold on, FRED changes my "Super Ship" alt name to "Super Super Ship!" even though "Super Ship" is on the list. Similar things happen if I would try to change the alt name to "Supe" "Sup" or even "S"! FRED changes them all to "Super Super Ship".

But doing something like "Super Amazing Ship" will stay intact.

It seems if FRED sees a partial string match to an alt name, it will take the first entry available, instead of making an exact match.
TagsNo tags attached.

Activities

m_m

2013-10-13 15:37

developer   ~0015327

After a first look I tracked the cause of this issue to CShipEditorDlg::ship_alt_name_close which gets called twice after closing the ship editor. At some point between these two calls the contents of the alt name combo box gets reset to another element (I think it's just the first one in the list but I could be wrong) which causes the second ship_alt_name_close call to overwrite the previously set data.
I'll have to see if why this data resets but I have no idea how to find the source as I have checked every direct use of the combobox.

Goober5000

2013-11-15 21:35

administrator   ~0015409

Including searching on IDC_SHIP_ALT? This is re-populated from within ship_alt_name_init, which is called from initialize_data, which is called from a whole bunch of places. (Search for Ship_editor_dialog.initialize_data.)

Goober5000

2014-06-30 03:16

administrator   ~0015950

Assigning to MageKing17 since I think this would be an easy thing to fix.

MageKing17

2014-07-01 01:06

developer  

shipeditordlg.cpp.patch (2,344 bytes)   
Index: code/fred2/shipeditordlg.cpp
===================================================================
--- code/fred2/shipeditordlg.cpp	(revision 10862)
+++ code/fred2/shipeditordlg.cpp	(working copy)
@@ -2037,7 +2037,7 @@
 // alternate ship name stuff
 void CShipEditorDlg::ship_alt_name_init(int base_ship)
 {
-	int idx;
+	int idx, sel_idx;
 	CComboBox *ptr = (CComboBox*)GetDlgItem(IDC_SHIP_ALT);
 	if(ptr == NULL){
 		Int3();
@@ -2054,21 +2054,17 @@
 	// reset the combobox and add all relevant strings
 	ptr->ResetContent();
 	ptr->AddString("<none>");
+	sel_idx = (base_ship < 0 || !strlen(Fred_alt_names[base_ship])) ? -1 : -2;
 	for(idx=0; idx<Mission_alt_type_count; idx++){
 		ptr->AddString(Mission_alt_types[idx]);
+		if (sel_idx == -2 && !strcmp(Mission_alt_types[idx], Fred_alt_names[base_ship])) {
+			sel_idx = idx;
+		}
 	}
+	Assertion(sel_idx >= -1, "Alt name exists but can't be found in Mission_alt_types; get a coder!\n");
 
-	// "none"
-	if(base_ship < 0){
-		ptr->SetCurSel(0);
-	}
-
-	// otherwise look his stuff up
-	if(strlen(Fred_alt_names[base_ship])){
-		ptr->SelectString(0, Fred_alt_names[base_ship]);
-	} else {
-		ptr->SetCurSel(0);
-	}
+	sel_idx += 1;
+	ptr->SetCurSel(sel_idx);
 }
 
 void CShipEditorDlg::ship_alt_name_close(int base_ship)
@@ -2137,7 +2133,7 @@
 // callsign stuff
 void CShipEditorDlg::ship_callsign_init(int base_ship)
 {
-	int idx;
+	int idx, sel_idx;
 	CComboBox *ptr = (CComboBox*)GetDlgItem(IDC_SHIP_CALLSIGN);
 	if(ptr == NULL){
 		Int3();
@@ -2154,21 +2150,17 @@
 	// reset the combobox and add all relevant strings
 	ptr->ResetContent();
 	ptr->AddString("<none>");
+	sel_idx = (base_ship < 0 || !strlen(Fred_callsigns[base_ship])) ? -1 : -2;
 	for(idx=0; idx<Mission_callsign_count; idx++){
 		ptr->AddString(Mission_callsigns[idx]);
+		if (sel_idx == -2 && !strcmp(Mission_callsigns[idx], Fred_callsigns[base_ship])) {
+			sel_idx = idx;
+		}
 	}
+	Assertion(sel_idx >= -1, "Callsign exists but can't be found in Mission_callsigns; get a coder!\n");
 
-	// "none"
-	if(base_ship < 0){
-		ptr->SetCurSel(0);
-	}
-
-	// otherwise look his stuff up
-	if(strlen(Fred_callsigns[base_ship])){
-		ptr->SelectString(0, Fred_callsigns[base_ship]);
-	} else {
-		ptr->SetCurSel(0);
-	}
+	sel_idx += 1;
+	ptr->SetCurSel(sel_idx);
 }
 
 void CShipEditorDlg::ship_callsign_close(int base_ship)
shipeditordlg.cpp.patch (2,344 bytes)   

MageKing17

2014-07-01 01:06

developer  

management.cpp.patch (365 bytes)   
Index: code/fred2/management.cpp
===================================================================
--- code/fred2/management.cpp	(revision 10862)
+++ code/fred2/management.cpp	(working copy)
@@ -933,6 +933,7 @@
 
 	// alternate ship type names
 	mission_parse_reset_alt();
+	mission_parse_reset_callsign();
 
 	strcpy(Cargo_names[0], "Nothing");
 	Num_cargo = 1;
management.cpp.patch (365 bytes)   

MageKing17

2014-07-01 01:08

developer   ~0015984

Issue tracked to usage of CComboBox->SelectString(), which takes a prefix to search for. Cleaned up so that it finds the proper index of the alt type (or callsign; callsigns had the same problem) as it's populating the list, and uses that as an argument to CComboBox->SetCurSel() instead of re-locating it (improperly).

Second patch fixes another issue found while we were testing this issue, that callsigns weren't clearing if you started working on a new mission.

Goober5000

2014-07-01 01:21

administrator   ~0015986

Fix committed to trunk@10864.

Related Changesets

fs2open: trunk r10863

2014-06-30 21:34

Goober5000


Ported: N/A

Details Diff
MageKing17's patch for callsigns not resetting when the mission is cleared (Mantis 0002934) Affected Issues
0002934
mod - /trunk/fs2_open/code/fred2/management.cpp Diff File

fs2open: trunk r10864

2014-06-30 21:42

Goober5000


Ported: N/A

Details Diff
from MageKing17: choose alt_names and callsigns by array index instead of substring; fixes Mantis 0002934 Affected Issues
0002934
mod - /trunk/fs2_open/code/fred2/shipeditordlg.cpp Diff File

Issue History

Date Modified Username Field Change
2013-10-13 14:34 Axem New Issue
2013-10-13 15:37 m_m Note Added: 0015327
2013-11-15 21:35 Goober5000 Note Added: 0015409
2014-06-30 03:16 Goober5000 Note Added: 0015950
2014-06-30 03:16 Goober5000 Assigned To => MageKing17
2014-06-30 03:16 Goober5000 Status new => assigned
2014-07-01 01:06 MageKing17 File Added: shipeditordlg.cpp.patch
2014-07-01 01:06 MageKing17 File Added: management.cpp.patch
2014-07-01 01:08 MageKing17 Note Added: 0015984
2014-07-01 01:08 MageKing17 Status assigned => code review
2014-07-01 01:12 Goober5000 Changeset attached => fs2open trunk r10863
2014-07-01 01:21 Goober5000 Changeset attached => fs2open trunk r10864
2014-07-01 01:21 Goober5000 Note Added: 0015986
2014-07-01 01:21 Goober5000 Status code review => resolved
2014-07-01 01:21 Goober5000 Resolution open => fixed