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