| 284 | //========================================================================== |
| 285 | |
| 286 | void 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 |
nothing calls this directly
no test coverage detected