View Issue Details

IDProjectCategoryView StatusLast Update
0003050FSSCPFREDpublic2014-09-24 06:37
ReporterAxem Assigned ToCommanderDJ  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.7.2 RC2 
Target Version3.7.2Fixed in Version3.7.2 
Summary0003050: Custom mainhall text is limited to 10 chars in the campaign editor
DescriptionDespite the actual game allowing long main hall text names, the FRED campaign editor will throw a fit if the name is over 10 characters long.

In campaign_editor::mission_selected(), mainhalltext is an array of 10 characters, but the actual main hall names are stored as SCP_Strings which I think can be quite a bit more than 10 characters.
Steps To ReproduceMake a new campaign
Set the mainhall name to something long like 12345678900
Get this error when you click on the mission again

---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Error!

Program: C:\Games\FreeSpace\fred2_open_3_7_2_RC2-DEBUG.exe
Module: C:\Games\FreeSpace\fred2_open_3_7_2_RC2-DEBUG.exe
File:

Run-Time Check Failure 0000002 - Stack around the variable 'mainhalltext' was corrupted.

(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
TagsNo tags attached.

Activities

CommanderDJ

2014-06-09 09:40

developer   ~0015826

Should be an easy fix - I evidently missed this when doing the mainhall stuff all the way back in 2012.

Is a patch enough for you to test with, or would you like a build?

CommanderDJ

2014-06-09 12:20

developer   ~0015828

Patch updated, credit to niffiwan for the suggestion.

niffiwan

2014-06-09 21:20

developer   ~0015831

Er - just noticed that the assignment seems to be the wrong way around?
  Campaign.missions[num].main_hall = mainhalltext;
should be this?
  mainhalltext = Campaign.missions[num].main_hall;

Or maybe get rid of the temp SCP_string entirely and just have this?

bc_hall->SetWindowText(Campaign.missions[num].main_hall.c_str());

CommanderDJ

2014-06-09 22:10

developer  

3050.patch (884 bytes)   
Index: code/fred2/campaigneditordlg.cpp
===================================================================
--- code/fred2/campaigneditordlg.cpp	(revision 10788)
+++ code/fred2/campaigneditordlg.cpp	(working copy)
@@ -246,7 +246,6 @@
 void campaign_editor::mission_selected(int num)
 {
 	CEdit *bc_dialog, *bc_hall, *bc_persona;
-	char mainhalltext[10];
 	char personatext[10];
 
 	bc_dialog = (CEdit *) GetDlgItem(IDC_BRIEFING_CUTSCENE);
@@ -259,8 +258,7 @@
 		bc_dialog->SetWindowText(Campaign.missions[num].briefing_cutscene);
 
 	// new main hall stuff
-	sprintf(mainhalltext, "%s", const_cast<char*>(Campaign.missions[num].main_hall.c_str()));
-	bc_hall->SetWindowText(CString(mainhalltext));
+	bc_hall->SetWindowText(Campaign.missions[num].main_hall.c_str());
 
 	// new debriefing persona stuff
 	sprintf(personatext, "%d", Campaign.missions[num].debrief_persona_index);
3050.patch (884 bytes)   

CommanderDJ

2014-06-09 22:11

developer   ~0015832

Whoops - you're right, patch updated. Also, upon further testing it seems that there is a different limit somewhere else in the code of 31 characters - so we can get names higher than 10 with the current patch but not more than 31. I'll look into this further.

Goober5000

2014-09-24 06:36

administrator   ~0016292

The 31-character limit is beyond the scope of this bug. The patch looks fine, and that's sufficient for now I think.

Related Changesets

fs2open: trunk r11081

2014-09-24 03:12

Goober5000


Ported: N/A

Details Diff
CommanderDJ's patch for Mantis 0003050 (Custom mainhall text is limited to 10 chars in the campaign editor) Affected Issues
0003050
mod - /trunk/fs2_open/code/fred2/campaigneditordlg.cpp Diff File

Issue History

Date Modified Username Field Change
2014-05-29 22:11 Axem New Issue
2014-06-09 09:39 CommanderDJ Assigned To => CommanderDJ
2014-06-09 09:39 CommanderDJ Status new => assigned
2014-06-09 09:39 CommanderDJ File Added: 3050.patch
2014-06-09 09:40 CommanderDJ Note Added: 0015826
2014-06-09 12:18 CommanderDJ File Deleted: 3050.patch
2014-06-09 12:18 CommanderDJ File Added: 3050.patch
2014-06-09 12:20 CommanderDJ Note Added: 0015828
2014-06-09 12:20 CommanderDJ Status assigned => code review
2014-06-09 21:20 niffiwan Note Added: 0015831
2014-06-09 22:10 CommanderDJ File Deleted: 3050.patch
2014-06-09 22:10 CommanderDJ File Added: 3050.patch
2014-06-09 22:11 CommanderDJ Note Added: 0015832
2014-06-09 22:11 CommanderDJ Status code review => assigned
2014-06-29 23:09 Goober5000 Target Version => 3.7.2
2014-09-24 06:36 Goober5000 Note Added: 0016292
2014-09-24 06:36 Goober5000 Changeset attached => fs2open trunk r11081
2014-09-24 06:37 Goober5000 Status assigned => resolved
2014-09-24 06:37 Goober5000 Resolution open => fixed
2014-09-24 06:37 Goober5000 Fixed in Version => 3.7.2