2018-09-22 02:13 EDT


View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0003050FSSCPFREDpublic2014-09-24 02:37
ReporterAxem 
Assigned ToCommanderDJ 
PrioritynormalSeveritycrashReproducibilityalways
StatusresolvedResolutionfixed 
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.
Attached Files
  • patch file icon 3050.patch (884 bytes) 2014-06-09 18:10 -
    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);
    
    patch file icon 3050.patch (884 bytes) 2014-06-09 18:10 +

-Relationships
+Relationships

-Notes

~0015826

CommanderDJ (developer)

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?

~0015828

CommanderDJ (developer)

Patch updated, credit to niffiwan for the suggestion.

~0015831

niffiwan (developer)

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());

~0015832

CommanderDJ (developer)

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.

~0016292

Goober5000 (administrator)

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

+Related Changesets

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