2018-06-19 17:01 EDT


View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0003126FSSCPtablespublic2014-10-24 16:20
ReporterAxem 
Assigned ToMageKing17 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target Version3.7.2Fixed in Version 
Summary0003126: FreeSpace can't load more than 32 of a modular table type
DescriptionI had a modular scripting table that suddenly stopped working without any warning. On looking in the debug log, the table wasn't being loaded, despite being in the root data/tables.

Counting the number of loaded tables, there was 32 entries. I added one more modular scripting table to the bunch and re-ran debug. There were still 32 entries!

I brought it up in #scp and Mageking seems to have found the limitation and has a patch to fix it. The test build does appear to fix the problem.
TagsNo tags attached.
Attached Files
  • patch file icon tbm_fix.patch (3,393 bytes) 2014-10-18 18:39 -
    Index: code/fred2/textviewdlg.cpp
    ===================================================================
    --- code/fred2/textviewdlg.cpp	(revision 11150)
    +++ code/fred2/textviewdlg.cpp	(working copy)
    @@ -52,8 +52,7 @@
     {
     	char line[256], line2[256], file_text[82];
     	int i, j, n, found = 0, comment = 0, num_files = 0;
    -	char tbl_file_arr[MAX_TBL_PARTS][MAX_FILENAME_LEN];
    -	char *tbl_file_names[MAX_TBL_PARTS];
    +	SCP_vector<SCP_string> tbl_file_names;
     	CFILE *fp;
     
     	if (ship_class < 0)
    @@ -112,12 +111,12 @@
     
     
     	// done with ships.tbl, so now check all modular ship tables...
    -	num_files = cf_get_file_list_preallocated(MAX_TBL_PARTS, tbl_file_arr, tbl_file_names, CF_TYPE_TABLES, NOX("*-shp.tbm"), CF_SORT_REVERSE);
    +	num_files = cf_get_file_list(tbl_file_names, CF_TYPE_TABLES, NOX("*-shp.tbm"), CF_SORT_REVERSE);
     
     	for (n = 0; n < num_files; n++){
    -		strcat(tbl_file_names[n], ".tbm");
    +		tbl_file_names[n] += ".tbm";
     
    -		fp = cfopen(tbl_file_names[n], "r");
    +		fp = cfopen(tbl_file_names[n].c_str(), "r");
     		Assert(fp);
     
     		memset( line, 0, sizeof(line) );
    @@ -160,7 +159,7 @@
     
     				if (!stricmp(line2 + i, Ship_info[ship_class].name)) {
     					memset( file_text, 0, sizeof(file_text) );
    -					snprintf(file_text, sizeof(file_text)-1, "--  %s  -------------------------------\r\n", tbl_file_names[n]);
    +					snprintf(file_text, sizeof(file_text)-1, "--  %s  -------------------------------\r\n", tbl_file_names[n].c_str());
     					m_edit += file_text;
     					found = 1;
     				}
    Index: code/parse/parselo.cpp
    ===================================================================
    --- code/parse/parselo.cpp	(revision 11150)
    +++ code/parse/parselo.cpp	(working copy)
    @@ -4369,23 +4369,22 @@
     // parse a modular table of type "name_check" and parse it using the specified function callback
     int parse_modular_table(const char *name_check, void (*parse_callback)(const char *filename), int path_type, int sort_type)
     {
    -	char tbl_file_arr[MAX_TBL_PARTS][MAX_FILENAME_LEN];
    -	char *tbl_file_names[MAX_TBL_PARTS];
    +	SCP_vector<SCP_string> tbl_file_names;
     	int i, num_files = 0;
     
     	if ( (name_check == NULL) || (parse_callback == NULL) || ((*name_check) != '*') ) {
    -		Int3();
    +		Assertion(false, "parse_modular_table() called with invalid arguments; get a coder!\n");
     		return 0;
     	}
     
    -	num_files = cf_get_file_list_preallocated(MAX_TBL_PARTS, tbl_file_arr, tbl_file_names, path_type, name_check, sort_type);
    +	num_files = cf_get_file_list(tbl_file_names, path_type, name_check, sort_type);
     
     	Parsing_modular_table = true;
     
     	for (i = 0; i < num_files; i++){
    -		strcat(tbl_file_names[i], ".tbm");
    -		mprintf(("TBM  =>  Starting parse of '%s' ...\n", tbl_file_names[i]));
    -		(*parse_callback)(tbl_file_names[i]);
    +		tbl_file_names[i] += ".tbm";
    +		mprintf(("TBM  =>  Starting parse of '%s' ...\n", tbl_file_names[i].c_str()));
    +		(*parse_callback)(tbl_file_names[i].c_str());
     	}
     
     	Parsing_modular_table = false;
    Index: code/parse/parselo.h
    ===================================================================
    --- code/parse/parselo.h	(revision 11150)
    +++ code/parse/parselo.h	(working copy)
    @@ -49,10 +49,6 @@
     
     #define PARSE_BUF_SIZE			4096
     
    -//For modular TBL files -C
    -#define MAX_TBL_PARTS 32
    -
    -
     #define	SHIP_TYPE			0	// used to identify which kind of array to do a search for a name in
     #define	SHIP_INFO_TYPE		1
     #define	WEAPON_LIST_TYPE	2	//	to parse an int_list of weapons
    
    patch file icon tbm_fix.patch (3,393 bytes) 2014-10-18 18:39 +

-Relationships
+Relationships

-Notes

~0016342

MageKing17 (developer)

Basically, we had a hardcoded limitation for no immediately apparent reason. There was existing code to do the same thing with a vector, so I tried it, and apparently it worked. Patch attached.

~0016347

niffiwan (developer)

looks good to me; I'll commit... soon (tm)

~0016349

niffiwan (developer)

Fix committed to trunk@11156.
+Notes

+Related Changesets

-Issue History
Date Modified Username Field Change
2014-10-18 18:38 Axem New Issue
2014-10-18 18:39 MageKing17 File Added: tbm_fix.patch
2014-10-18 18:39 MageKing17 Note Added: 0016342
2014-10-18 18:39 MageKing17 Assigned To => MageKing17
2014-10-18 18:39 MageKing17 Status new => code review
2014-10-22 22:53 MageKing17 Target Version => 3.7.2
2014-10-24 03:03 niffiwan Note Added: 0016347
2014-10-24 16:20 niffiwan Changeset attached => fs2open trunk r11156
2014-10-24 16:20 niffiwan Note Added: 0016349
2014-10-24 16:20 niffiwan Status code review => resolved
2014-10-24 16:20 niffiwan Resolution open => fixed
+Issue History