MCPcopy Create free account
hub / github.com/ZDoom/gzdoom / LoadLanguage

Method LoadLanguage

src/common/engine/stringtable.cpp:286–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284//==========================================================================
285
286void FStringTable::LoadLanguage (int lumpnum, const char* buffer, size_t size)
287{
288 bool errordone = false;
289 TArray<uint32_t> activeMaps;
290 FScanner sc;
291 bool hasDefaultEntry = false;
292
293 sc.OpenMem("LANGUAGE", buffer, (int)size);
294 sc.SetCMode (true);
295 while (sc.GetString ())
296 {
297 if (sc.Compare ("["))
298 { // Process language identifiers
299 activeMaps.Clear();
300 hasDefaultEntry = false;
301 sc.MustGetString ();
302 do
303 {
304 size_t len = sc.StringLen;
305 if (len != 2 && len != 3)
306 {
307 if (len == 1 && sc.String[0] == '~')
308 {
309 // deprecated and ignored
310 sc.ScriptMessage("Deprecated option '~' found in language list");
311 sc.MustGetString ();
312 continue;
313 }
314 if (len == 1 && sc.String[0] == '*')
315 {
316 activeMaps.Clear();
317 activeMaps.Push(global_table);
318 }
319 else if (len == 7 && stricmp (sc.String, "default") == 0)
320 {
321 activeMaps.Clear();
322 activeMaps.Push(default_table);
323 hasDefaultEntry = true;
324 }
325 else
326 {
327 sc.ScriptError ("The language code must be 2 or 3 characters long.\n'%s' is %zu characters long.",
328 sc.String, len);
329 }
330 }
331 else
332 {
333 if (activeMaps.Size() != 1 || (activeMaps[0] != default_table && activeMaps[0] != global_table))
334 activeMaps.Push(MAKE_ID(tolower(sc.String[0]), tolower(sc.String[1]), tolower(sc.String[2]), 0));
335 }
336 sc.MustGetString ();
337 } while (!sc.Compare ("]"));
338 }
339 else
340 { // Process string definitions.
341 if (activeMaps.Size() == 0)
342 {
343 // LANGUAGE lump is bad. We need to check if this is an old binary

Callers

nothing calls this directly

Calls 14

stricmpFunction · 0.85
PrintfFunction · 0.85
SetCModeMethod · 0.80
MustGetStringMethod · 0.80
ScriptMessageMethod · 0.80
ScriptErrorMethod · 0.80
isTextMethod · 0.80
MustGetStringNameMethod · 0.80
OpenMemMethod · 0.45
GetStringMethod · 0.45
CompareMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected