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

Function CreateStringTable

Descent3/localization.cpp:264–425  ·  view source on GitHub ↗

Given a filename, pointer to a char * array and a pointer to an int, it will load the string table and fill in the information returns true on success

Source from the content-addressed store, hash-verified

262// it will load the string table and fill in the information
263// returns true on success
264bool CreateStringTable(const char *filename, char ***table, int *size) {
265 ASSERT(filename);
266 ASSERT(Localization_language != -1);
267 if (!filename) {
268 if (table)
269 *table = NULL;
270 if (size)
271 *size = 0;
272 return false;
273 }
274 CFILE *file;
275
276 char fname[_MAX_PATH];
277 FixFilenameCase(filename, fname);
278 file = cfopen(fname, "rt");
279 if (!file) {
280 if (table)
281 *table = NULL;
282 if (size)
283 *size = 0;
284 return false;
285 }
286
287 int old_language, scount;
288 char tempbuffer[MAX_STRING_LENGTH];
289
290 old_language = Localization_language;
291
292try_english:
293
294 // first found out how many strings total in the file
295 scount = 0;
296
297 while (!cfeof(file)) {
298 cf_ReadString(tempbuffer, MAX_LINE_LENGTH + 1, file);
299 if (_parse_line_information(tempbuffer) == Localization_language)
300 scount++;
301 }
302 cfclose(file);
303
304 if (scount == 0) {
305 // no strings found, if we are searching a non-English version, then
306 // load english versions
307 if (Localization_language != LANGUAGE_ENGLISH) {
308 Localization_language = LANGUAGE_ENGLISH;
309 // open the file again
310 file = cfopen(fname, "rt");
311 goto try_english;
312 }
313
314 // no strings found
315 Localization_language = old_language;
316 mprintf(0, "Localization: Warning, 0 strings found in %s\n", filename);
317 *table = NULL;
318 *size = 0;
319 return true;
320 }
321

Callers 5

LocalizeLevelNameFunction · 0.85
LoadLevelTextFunction · 0.85
Osiris_LoadLevelModuleFunction · 0.85
Osiris_LoadGameModuleFunction · 0.85
Localize_ctl_bindingsFunction · 0.85

Calls 10

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

Tested by

no test coverage detected