MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / LoadStringFile

Function LoadStringFile

Descent3/localization.cpp:470–554  ·  view source on GitHub ↗

Loads a string table file, returns number of strings read if everything went ok,else 0

Source from the content-addressed store, hash-verified

468
469// Loads a string table file, returns number of strings read if everything went ok,else 0
470int LoadStringFile(const char *filename, int starting_offset) {
471 ASSERT(filename);
472 ASSERT(Localization_language != -1);
473 if (!filename)
474 return 0;
475
476 CFILE *file;
477 char fname[_MAX_PATH];
478 FixFilenameCase(filename, fname);
479 file = cfopen(fname, "rt");
480 if (!file)
481 return 0;
482
483 int scount = 0;
484 char buffer[MAX_STRING_LENGTH];
485
486 bool reading_string = false;
487
488 GrowString string;
489 int line_info;
490
491 while (!cfeof(file)) {
492 cf_ReadString(buffer, MAX_STRING_LENGTH, file);
493 if (scount >= 198)
494 scount = scount;
495
496 line_info = _parse_line_information(buffer);
497
498 switch (line_info) {
499 case STAG_CONTINUE:
500 if (reading_string) {
501 // we need to add on to the working buffer
502 string += _parse_escape_chars(buffer);
503 }
504 break;
505 case STAG_EMPTY:
506 // empty line !ACK! What should I do...do a new line char or skip?...skip for now
507 break;
508 case STAG_COMMENT:
509 // ignore this line
510 if (reading_string) {
511 // ok we're done with the string, finish it and put it in the string table
512 string.GetString(&String_table[scount + starting_offset]);
513 scount++;
514 string.Destroy();
515 }
516 reading_string = false;
517 break;
518 default: {
519 if (line_info >= 0 && line_info < Num_languages) {
520 if (reading_string) {
521 // ok we're done with the string, finish it and put it in the string table
522 string.GetString(&String_table[scount + starting_offset]);
523 scount++;
524 string.Destroy();
525 reading_string = false;
526 }
527

Callers 1

LoadStringTablesFunction · 0.85

Calls 10

FixFilenameCaseFunction · 0.85
cfopenFunction · 0.85
cfeofFunction · 0.85
cf_ReadStringFunction · 0.85
_parse_line_informationFunction · 0.85
_parse_escape_charsFunction · 0.85
_parse_string_tagFunction · 0.85
cfcloseFunction · 0.85
GetStringMethod · 0.80
DestroyMethod · 0.45

Tested by

no test coverage detected