@@ -395,6 +395,128 @@ SCP_string get_asteroid_table_text(const asteroid_info* aip)
395395 return result;
396396}
397397
398+ SCP_string get_prop_table_text (const prop_info* pip)
399+ {
400+ char line[256 ], line2[256 ], file_text[82 ];
401+ int i, j, n, found = 0 , comment = 0 , num_files = 0 ;
402+ SCP_vector<SCP_string> tbl_file_names;
403+ SCP_string result;
404+
405+ auto fp = cfopen (" props.tbl" , " r" );
406+ if (!fp)
407+ return " No props.tbl found.\r\n " ;
408+
409+ while (cfgets (line, 255 , fp)) {
410+ while (line[strlen (line) - 1 ] == ' \n ' )
411+ line[strlen (line) - 1 ] = 0 ;
412+
413+ for (i = j = 0 ; line[i]; i++) {
414+ if (line[i] == ' /' && line[i + 1 ] == ' /' )
415+ break ;
416+ if (line[i] == ' /' && line[i + 1 ] == ' *' ) {
417+ comment = 1 ;
418+ i++;
419+ continue ;
420+ }
421+ if (line[i] == ' *' && line[i + 1 ] == ' /' ) {
422+ comment = 0 ;
423+ i++;
424+ continue ;
425+ }
426+ if (!comment)
427+ line2[j++] = line[i];
428+ }
429+
430+ line2[j] = 0 ;
431+ if (!strnicmp (line2, " $Name:" , 6 )) {
432+ drop_trailing_white_space (line2);
433+ found = 0 ;
434+ i = 6 ;
435+
436+ while (line2[i] == ' ' || line2[i] == ' \t ' || line2[i] == ' @' )
437+ i++;
438+
439+ if (!stricmp (line2 + i, pip->name )) {
440+ result += " -- props.tbl -------------------------------\r\n " ;
441+ found = 1 ;
442+ }
443+ }
444+
445+ if (found) {
446+ result += line;
447+ result += " \r\n " ;
448+ }
449+ }
450+
451+ cfclose (fp);
452+
453+ num_files = cf_get_file_list (tbl_file_names, CF_TYPE_TABLES, NOX (" *-prp.tbm" ), CF_SORT_REVERSE);
454+
455+ for (n = 0 ; n < num_files; n++) {
456+ tbl_file_names[n] += " .tbm" ;
457+
458+ fp = cfopen (tbl_file_names[n].c_str (), " r" );
459+ if (!fp)
460+ continue ;
461+
462+ memset (line, 0 , sizeof (line));
463+ memset (line2, 0 , sizeof (line2));
464+ found = 0 ;
465+ comment = 0 ;
466+
467+ while (cfgets (line, 255 , fp)) {
468+ while (line[strlen (line) - 1 ] == ' \n ' )
469+ line[strlen (line) - 1 ] = 0 ;
470+
471+ for (i = j = 0 ; line[i]; i++) {
472+ if (line[i] == ' /' && line[i + 1 ] == ' /' )
473+ break ;
474+ if (line[i] == ' /' && line[i + 1 ] == ' *' ) {
475+ comment = 1 ;
476+ i++;
477+ continue ;
478+ }
479+ if (line[i] == ' *' && line[i + 1 ] == ' /' ) {
480+ comment = 0 ;
481+ i++;
482+ continue ;
483+ }
484+ if (!comment)
485+ line2[j++] = line[i];
486+ }
487+
488+ line2[j] = 0 ;
489+ if (!strnicmp (line2, " $Name:" , 6 )) {
490+ drop_trailing_white_space (line2);
491+ found = 0 ;
492+ i = 6 ;
493+
494+ while (line2[i] == ' ' || line2[i] == ' \t ' || line2[i] == ' @' )
495+ i++;
496+
497+ if (!stricmp (line2 + i, pip->name )) {
498+ memset (file_text, 0 , sizeof (file_text));
499+ snprintf (file_text,
500+ sizeof (file_text) - 1 ,
501+ " -- %s -------------------------------\r\n " ,
502+ tbl_file_names[n].c_str ());
503+ result += file_text;
504+ found = 1 ;
505+ }
506+ }
507+
508+ if (found) {
509+ result += line;
510+ result += " \r\n " ;
511+ }
512+ }
513+
514+ cfclose (fp);
515+ }
516+
517+ return result;
518+ }
519+
398520SCP_string get_directory_or_vp (const char * path)
399521{
400522 SCP_string result (path);
0 commit comments