From f50b5d60597168529d40d0f214daef149905cff5 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 17 Dec 2012 19:40:48 +0100 Subject: [PATCH] changed format of the countryflags index file to json --- data/countryflags/index.json | 1024 +++++++++++++++++++ data/countryflags/index.txt | 769 -------------- src/game/client/components/countryflags.cpp | 134 +-- 3 files changed, 1097 insertions(+), 830 deletions(-) create mode 100644 data/countryflags/index.json delete mode 100644 data/countryflags/index.txt diff --git a/data/countryflags/index.json b/data/countryflags/index.json new file mode 100644 index 000000000..da510af55 --- /dev/null +++ b/data/countryflags/index.json @@ -0,0 +1,1024 @@ +{"country codes": + {"custom": [ + { + "id": "SS", + "code": 737 + }, + { + "id": "XEN", + "code": 901 + }, + { + "id": "XNI", + "code": 902 + }, + { + "id": "XSC", + "code": 903 + }, + { + "id": "XWA", + "code": 904 + }, + { + "id": "default", + "code": -1 + } + ], + "ISO 3166-1": [ + { + "id": "AD", + "code": 20 + }, + { + "id": "AE", + "code": 784 + }, + { + "id": "AF", + "code": 4 + }, + { + "id": "AG", + "code": 28 + }, + { + "id": "AI", + "code": 660 + }, + { + "id": "AL", + "code": 8 + }, + { + "id": "AM", + "code": 51 + }, + { + "id": "AO", + "code": 24 + }, + { + "id": "AR", + "code": 32 + }, + { + "id": "AS", + "code": 16 + }, + { + "id": "AT", + "code": 40 + }, + { + "id": "AU", + "code": 36 + }, + { + "id": "AW", + "code": 533 + }, + { + "id": "AX", + "code": 248 + }, + { + "id": "AZ", + "code": 31 + }, + { + "id": "BA", + "code": 70 + }, + { + "id": "BB", + "code": 52 + }, + { + "id": "BD", + "code": 50 + }, + { + "id": "BE", + "code": 56 + }, + { + "id": "BF", + "code": 854 + }, + { + "id": "BG", + "code": 100 + }, + { + "id": "BH", + "code": 48 + }, + { + "id": "BI", + "code": 108 + }, + { + "id": "BJ", + "code": 204 + }, + { + "id": "BL", + "code": 652 + }, + { + "id": "BM", + "code": 60 + }, + { + "id": "BN", + "code": 96 + }, + { + "id": "BO", + "code": 68 + }, + { + "id": "BR", + "code": 76 + }, + { + "id": "BS", + "code": 44 + }, + { + "id": "BT", + "code": 64 + }, + { + "id": "BW", + "code": 72 + }, + { + "id": "BY", + "code": 112 + }, + { + "id": "BZ", + "code": 84 + }, + { + "id": "CA", + "code": 124 + }, + { + "id": "CC", + "code": 166 + }, + { + "id": "CD", + "code": 180 + }, + { + "id": "CF", + "code": 140 + }, + { + "id": "CG", + "code": 178 + }, + { + "id": "CH", + "code": 756 + }, + { + "id": "CI", + "code": 384 + }, + { + "id": "CK", + "code": 184 + }, + { + "id": "CL", + "code": 152 + }, + { + "id": "CM", + "code": 120 + }, + { + "id": "CN", + "code": 156 + }, + { + "id": "CO", + "code": 170 + }, + { + "id": "CR", + "code": 188 + }, + { + "id": "CU", + "code": 192 + }, + { + "id": "CV", + "code": 132 + }, + { + "id": "CW", + "code": 531 + }, + { + "id": "CX", + "code": 162 + }, + { + "id": "CY", + "code": 196 + }, + { + "id": "CZ", + "code": 203 + }, + { + "id": "DE", + "code": 276 + }, + { + "id": "DJ", + "code": 262 + }, + { + "id": "DK", + "code": 208 + }, + { + "id": "DM", + "code": 212 + }, + { + "id": "DO", + "code": 214 + }, + { + "id": "DZ", + "code": 12 + }, + { + "id": "EC", + "code": 218 + }, + { + "id": "EE", + "code": 233 + }, + { + "id": "EG", + "code": 818 + }, + { + "id": "EH", + "code": 732 + }, + { + "id": "ER", + "code": 232 + }, + { + "id": "ES", + "code": 724 + }, + { + "id": "ET", + "code": 231 + }, + { + "id": "FI", + "code": 246 + }, + { + "id": "FJ", + "code": 242 + }, + { + "id": "FK", + "code": 238 + }, + { + "id": "FM", + "code": 583 + }, + { + "id": "FO", + "code": 234 + }, + { + "id": "FR", + "code": 250 + }, + { + "id": "GA", + "code": 266 + }, + { + "id": "GB", + "code": 826 + }, + { + "id": "GD", + "code": 308 + }, + { + "id": "GE", + "code": 268 + }, + { + "id": "GF", + "code": 254 + }, + { + "id": "GG", + "code": 831 + }, + { + "id": "GH", + "code": 288 + }, + { + "id": "GI", + "code": 292 + }, + { + "id": "GL", + "code": 304 + }, + { + "id": "GM", + "code": 270 + }, + { + "id": "GN", + "code": 324 + }, + { + "id": "GP", + "code": 312 + }, + { + "id": "GQ", + "code": 226 + }, + { + "id": "GR", + "code": 300 + }, + { + "id": "GS", + "code": 239 + }, + { + "id": "GT", + "code": 320 + }, + { + "id": "GU", + "code": 316 + }, + { + "id": "GW", + "code": 624 + }, + { + "id": "GY", + "code": 328 + }, + { + "id": "HK", + "code": 344 + }, + { + "id": "HN", + "code": 340 + }, + { + "id": "HR", + "code": 191 + }, + { + "id": "HT", + "code": 332 + }, + { + "id": "HU", + "code": 348 + }, + { + "id": "ID", + "code": 360 + }, + { + "id": "IE", + "code": 372 + }, + { + "id": "IL", + "code": 376 + }, + { + "id": "IM", + "code": 833 + }, + { + "id": "IN", + "code": 356 + }, + { + "id": "IO", + "code": 86 + }, + { + "id": "IQ", + "code": 368 + }, + { + "id": "IR", + "code": 364 + }, + { + "id": "IS", + "code": 352 + }, + { + "id": "IT", + "code": 380 + }, + { + "id": "JE", + "code": 832 + }, + { + "id": "JM", + "code": 388 + }, + { + "id": "JO", + "code": 400 + }, + { + "id": "JP", + "code": 392 + }, + { + "id": "KE", + "code": 404 + }, + { + "id": "KG", + "code": 417 + }, + { + "id": "KH", + "code": 116 + }, + { + "id": "KI", + "code": 296 + }, + { + "id": "KM", + "code": 174 + }, + { + "id": "KN", + "code": 659 + }, + { + "id": "KP", + "code": 408 + }, + { + "id": "KR", + "code": 410 + }, + { + "id": "KW", + "code": 414 + }, + { + "id": "KY", + "code": 136 + }, + { + "id": "KZ", + "code": 398 + }, + { + "id": "LA", + "code": 418 + }, + { + "id": "LB", + "code": 422 + }, + { + "id": "LC", + "code": 662 + }, + { + "id": "LI", + "code": 438 + }, + { + "id": "LK", + "code": 144 + }, + { + "id": "LR", + "code": 430 + }, + { + "id": "LS", + "code": 426 + }, + { + "id": "LT", + "code": 440 + }, + { + "id": "LU", + "code": 442 + }, + { + "id": "LV", + "code": 428 + }, + { + "id": "LY", + "code": 434 + }, + { + "id": "MA", + "code": 504 + }, + { + "id": "MC", + "code": 492 + }, + { + "id": "MD", + "code": 498 + }, + { + "id": "ME", + "code": 499 + }, + { + "id": "MF", + "code": 663 + }, + { + "id": "MG", + "code": 450 + }, + { + "id": "MH", + "code": 584 + }, + { + "id": "MK", + "code": 807 + }, + { + "id": "ML", + "code": 466 + }, + { + "id": "MM", + "code": 104 + }, + { + "id": "MN", + "code": 496 + }, + { + "id": "MO", + "code": 446 + }, + { + "id": "MP", + "code": 580 + }, + { + "id": "MQ", + "code": 474 + }, + { + "id": "MR", + "code": 478 + }, + { + "id": "MS", + "code": 500 + }, + { + "id": "MT", + "code": 470 + }, + { + "id": "MU", + "code": 480 + }, + { + "id": "MV", + "code": 462 + }, + { + "id": "MW", + "code": 454 + }, + { + "id": "MX", + "code": 484 + }, + { + "id": "MY", + "code": 458 + }, + { + "id": "MZ", + "code": 508 + }, + { + "id": "NA", + "code": 516 + }, + { + "id": "NC", + "code": 540 + }, + { + "id": "NE", + "code": 562 + }, + { + "id": "NF", + "code": 574 + }, + { + "id": "NG", + "code": 566 + }, + { + "id": "NI", + "code": 558 + }, + { + "id": "NL", + "code": 528 + }, + { + "id": "NO", + "code": 578 + }, + { + "id": "NP", + "code": 524 + }, + { + "id": "NR", + "code": 520 + }, + { + "id": "NU", + "code": 570 + }, + { + "id": "NZ", + "code": 554 + }, + { + "id": "OM", + "code": 512 + }, + { + "id": "PA", + "code": 591 + }, + { + "id": "PE", + "code": 604 + }, + { + "id": "PF", + "code": 258 + }, + { + "id": "PG", + "code": 598 + }, + { + "id": "PH", + "code": 608 + }, + { + "id": "PK", + "code": 586 + }, + { + "id": "PL", + "code": 616 + }, + { + "id": "PM", + "code": 666 + }, + { + "id": "PN", + "code": 612 + }, + { + "id": "PR", + "code": 630 + }, + { + "id": "PT", + "code": 620 + }, + { + "id": "PW", + "code": 585 + }, + { + "id": "PY", + "code": 600 + }, + { + "id": "QA", + "code": 634 + }, + { + "id": "RE", + "code": 638 + }, + { + "id": "RO", + "code": 642 + }, + { + "id": "RS", + "code": 688 + }, + { + "id": "RU", + "code": 643 + }, + { + "id": "RW", + "code": 646 + }, + { + "id": "SA", + "code": 682 + }, + { + "id": "SB", + "code": 90 + }, + { + "id": "SC", + "code": 690 + }, + { + "id": "SD", + "code": 736 + }, + { + "id": "SE", + "code": 752 + }, + { + "id": "SG", + "code": 702 + }, + { + "id": "SH", + "code": 654 + }, + { + "id": "SI", + "code": 705 + }, + { + "id": "SK", + "code": 703 + }, + { + "id": "SL", + "code": 694 + }, + { + "id": "SM", + "code": 674 + }, + { + "id": "SN", + "code": 686 + }, + { + "id": "SO", + "code": 706 + }, + { + "id": "SR", + "code": 740 + }, + { + "id": "ST", + "code": 678 + }, + { + "id": "SV", + "code": 222 + }, + { + "id": "SX", + "code": 534 + }, + { + "id": "SY", + "code": 760 + }, + { + "id": "SZ", + "code": 748 + }, + { + "id": "TC", + "code": 796 + }, + { + "id": "TD", + "code": 148 + }, + { + "id": "TF", + "code": 260 + }, + { + "id": "TG", + "code": 768 + }, + { + "id": "TH", + "code": 764 + }, + { + "id": "TJ", + "code": 762 + }, + { + "id": "TK", + "code": 772 + }, + { + "id": "TL", + "code": 626 + }, + { + "id": "TM", + "code": 795 + }, + { + "id": "TN", + "code": 788 + }, + { + "id": "TO", + "code": 776 + }, + { + "id": "TR", + "code": 792 + }, + { + "id": "TT", + "code": 780 + }, + { + "id": "TV", + "code": 798 + }, + { + "id": "TW", + "code": 158 + }, + { + "id": "TZ", + "code": 834 + }, + { + "id": "UA", + "code": 804 + }, + { + "id": "UG", + "code": 800 + }, + { + "id": "US", + "code": 840 + }, + { + "id": "UY", + "code": 858 + }, + { + "id": "UZ", + "code": 860 + }, + { + "id": "VA", + "code": 336 + }, + { + "id": "VC", + "code": 670 + }, + { + "id": "VE", + "code": 862 + }, + { + "id": "VG", + "code": 92 + }, + { + "id": "VI", + "code": 850 + }, + { + "id": "VN", + "code": 704 + }, + { + "id": "VU", + "code": 548 + }, + { + "id": "WF", + "code": 876 + }, + { + "id": "WS", + "code": 882 + }, + { + "id": "YE", + "code": 887 + }, + { + "id": "ZA", + "code": 710 + }, + { + "id": "ZM", + "code": 894 + }, + { + "id": "ZW", + "code": 716 + } + ], + "not used": [ + { + "id": "AQ", + "code": 10 + }, + { + "id": "BQ", + "code": 535 + }, + { + "id": "BV", + "code": 74 + }, + { + "id": "HM", + "code": 334 + }, + { + "id": "PS", + "code": 275 + }, + { + "id": "SJ", + "code": 744 + }, + { + "id": "UM", + "code": 581 + }, + { + "id": "YT", + "code": 175 + } + ]}, +} diff --git a/data/countryflags/index.txt b/data/countryflags/index.txt deleted file mode 100644 index 3b60f1b29..000000000 --- a/data/countryflags/index.txt +++ /dev/null @@ -1,769 +0,0 @@ - -##### country codes ##### - -##### custom ##### - -default -== -1 - -XEN -== 901 - -XNI -== 902 - -XSC -== 903 - -XWA -== 904 - -#south sudan, non official code# -SS -== 737 - -##### ISO 3166-1 based ##### - -AF -== 4 - -AX -== 248 - -AL -== 8 - -DZ -== 12 - -AS -== 16 - -AD -== 20 - -AO -== 24 - -AI -== 660 - -#AQ -#== 10 - -AG -== 28 - -AR -== 32 - -AM -== 51 - -AW -== 533 - -AU -== 36 - -AT -== 40 - -AZ -== 31 - -BS -== 44 - -BH -== 48 - -BD -== 50 - -BB -== 52 - -BY -== 112 - -BE -== 56 - -BZ -== 84 - -BJ -== 204 - -BM -== 60 - -BT -== 64 - -BO -== 68 - -#BQ -#== 535 - -BA -== 70 - -BW -== 72 - -#BV -#== 74 - -BR -== 76 - -IO -== 86 - -BN -== 96 - -BG -== 100 - -BF -== 854 - -BI -== 108 - -KH -== 116 - -CM -== 120 - -CA -== 124 - -CV -== 132 - -KY -== 136 - -CF -== 140 - -TD -== 148 - -CL -== 152 - -CN -== 156 - -CX -== 162 - -CC -== 166 - -CO -== 170 - -KM -== 174 - -CG -== 178 - -CD -== 180 - -CK -== 184 - -CR -== 188 - -CI -== 384 - -HR -== 191 - -CU -== 192 - -CW -== 531 - -CY -== 196 - -CZ -== 203 - -DK -== 208 - -DJ -== 262 - -DM -== 212 - -DO -== 214 - -EC -== 218 - -EG -== 818 - -SV -== 222 - -GQ -== 226 - -ER -== 232 - -EE -== 233 - -ET -== 231 - -FK -== 238 - -FO -== 234 - -FJ -== 242 - -FI -== 246 - -FR -== 250 - -GF -== 254 - -PF -== 258 - -TF -== 260 - -GA -== 266 - -GM -== 270 - -GE -== 268 - -DE -== 276 - -GH -== 288 - -GI -== 292 - -GR -== 300 - -GL -== 304 - -GD -== 308 - -GP -== 312 - -GU -== 316 - -GT -== 320 - -GG -== 831 - -GN -== 324 - -GW -== 624 - -GY -== 328 - -HT -== 332 - -#HM -#== 334 - -VA -== 336 - -HN -== 340 - -HK -== 344 - -HU -== 348 - -IS -== 352 - -IN -== 356 - -ID -== 360 - -IR -== 364 - -IQ -== 368 - -IE -== 372 - -IM -== 833 - -IL -== 376 - -IT -== 380 - -JM -== 388 - -JP -== 392 - -JE -== 832 - -JO -== 400 - -KZ -== 398 - -KE -== 404 - -KI -== 296 - -KP -== 408 - -KR -== 410 - -KW -== 414 - -KG -== 417 - -LA -== 418 - -LV -== 428 - -LB -== 422 - -LS -== 426 - -LR -== 430 - -LY -== 434 - -LI -== 438 - -LT -== 440 - -LU -== 442 - -MO -== 446 - -MK -== 807 - -MG -== 450 - -MW -== 454 - -MY -== 458 - -MV -== 462 - -ML -== 466 - -MT -== 470 - -MH -== 584 - -MQ -== 474 - -MR -== 478 - -MU -== 480 - -#YT -#== 175 - -MX -== 484 - -FM -== 583 - -MD -== 498 - -MC -== 492 - -MN -== 496 - -ME -== 499 - -MS -== 500 - -MA -== 504 - -MZ -== 508 - -MM -== 104 - -NA -== 516 - -NR -== 520 - -NP -== 524 - -NL -== 528 - -NC -== 540 - -NZ -== 554 - -NI -== 558 - -NE -== 562 - -NG -== 566 - -NU -== 570 - -NF -== 574 - -MP -== 580 - -NO -== 578 - -OM -== 512 - -PK -== 586 - -PW -== 585 - -#PS -#== 275 - -PA -== 591 - -PG -== 598 - -PY -== 600 - -PE -== 604 - -PH -== 608 - -PN -== 612 - -PL -== 616 - -PT -== 620 - -PR -== 630 - -QA -== 634 - -RE -== 638 - -RO -== 642 - -RU -== 643 - -RW -== 646 - -BL -== 652 - -SH -== 654 - -KN -== 659 - -LC -== 662 - -MF -== 663 - -PM -== 666 - -VC -== 670 - -WS -== 882 - -SM -== 674 - -ST -== 678 - -SA -== 682 - -SN -== 686 - -RS -== 688 - -SC -== 690 - -SL -== 694 - -SG -== 702 - -SX -== 534 - -SK -== 703 - -SI -== 705 - -SB -== 90 - -SO -== 706 - -ZA -== 710 - -GS -== 239 - -ES -== 724 - -LK -== 144 - -SD -== 736 - -SR -== 740 - -#SJ -#== 744 - -SZ -== 748 - -SE -== 752 - -CH -== 756 - -SY -== 760 - -TW -== 158 - -TJ -== 762 - -TZ -== 834 - -TH -== 764 - -TL -== 626 - -TG -== 768 - -TK -== 772 - -TO -== 776 - -TT -== 780 - -TN -== 788 - -TR -== 792 - -TM -== 795 - -TC -== 796 - -TV -== 798 - -UG -== 800 - -UA -== 804 - -AE -== 784 - -GB -== 826 - -US -== 840 - -#UM -#== 581 - -UY -== 858 - -UZ -== 860 - -VU -== 548 - -VE -== 862 - -VN -== 704 - -VG -== 92 - -VI -== 850 - -WF -== 876 - -EH -== 732 - -YE -== 887 - -ZM -== 894 - -ZW -== 716 diff --git a/src/game/client/components/countryflags.cpp b/src/game/client/components/countryflags.cpp index aa4f898ea..68ba9b83d 100644 --- a/src/game/client/components/countryflags.cpp +++ b/src/game/client/components/countryflags.cpp @@ -7,88 +7,100 @@ #include #include #include +#include #include -#include #include "countryflags.h" void CCountryFlags::LoadCountryflagsIndexfile() { - IOHANDLE File = Storage()->OpenFile("countryflags/index.txt", IOFLAG_READ, IStorage::TYPE_ALL); + // read file data into buffer + IOHANDLE File = Storage()->OpenFile("countryflags/index.json", IOFLAG_READ, IStorage::TYPE_ALL); if(!File) { Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", "couldn't open index file"); return; } + int FileSize = (int)io_length(File); + char *pFileData = (char *)mem_alloc(FileSize+1, 1); + io_read(File, pFileData, FileSize); + pFileData[FileSize] = 0; + io_close(File); - char aOrigin[128]; - CLineReader LineReader; - LineReader.Init(File); - char *pLine; - while((pLine = LineReader.Get())) + // parse json data + json_settings JsonSettings; + mem_zero(&JsonSettings, sizeof(JsonSettings)); + char aError[256]; + json_value *pJsonData = json_parse_ex(&JsonSettings, pFileData, aError); + if(pJsonData == 0) { - if(!str_length(pLine) || pLine[0] == '#') // skip empty lines and comments - continue; + Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aError); + return; + } - str_copy(aOrigin, pLine, sizeof(aOrigin)); - char *pReplacement = LineReader.Get(); - if(!pReplacement) + // extract data + const json_value &rInit = (*pJsonData)["country codes"]; + if(rInit.type == json_object) + { + enum { - Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", "unexpected end of index file"); - break; - } - - if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ') + NUM_INDICES = 2, + }; + char *paIndices[NUM_INDICES] = {"custom", "ISO 3166-1"}; + for(int Index = 0; Index < NUM_INDICES; ++Index) { - char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "malform replacement for index '%s'", aOrigin); - Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); - continue; - } - - int CountryCode = str_toint(pReplacement+3); - if(CountryCode < CODE_LB || CountryCode > CODE_UB) - { - char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "country code '%i' not within valid code range [%i..%i]", CountryCode, CODE_LB, CODE_UB); - Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); - continue; - } - - // load the graphic file - char aBuf[128]; - CImageInfo Info; - if(g_Config.m_ClLoadCountryFlags) - { - str_format(aBuf, sizeof(aBuf), "countryflags/%s.png", aOrigin); - if(!Graphics()->LoadPNG(&Info, aBuf, IStorage::TYPE_ALL)) + const json_value &rStart = rInit[paIndices[Index]]; + if(rStart.type == json_array) { - char aMsg[128]; - str_format(aMsg, sizeof(aMsg), "failed to load '%s'", aBuf); - Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aMsg); - continue; + for(int i = 0; i < rStart.u.array.length; ++i) + { + char aBuf[64]; + + // validate country code + int CountryCode = (long)rStart[i]["code"]; + if(CountryCode < CODE_LB || CountryCode > CODE_UB) + { + str_format(aBuf, sizeof(aBuf), "country code '%i' not within valid code range [%i..%i]", CountryCode, CODE_LB, CODE_UB); + Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); + continue; + } + + // add entry + const char *pCountryName = rStart[i]["id"]; + CCountryFlag CountryFlag; + CountryFlag.m_CountryCode = CountryCode; + str_copy(CountryFlag.m_aCountryCodeString, pCountryName, sizeof(CountryFlag.m_aCountryCodeString)); + if(g_Config.m_ClLoadCountryFlags) + { + // load the graphic file + CImageInfo Info; + str_format(aBuf, sizeof(aBuf), "countryflags/%s.png", pCountryName); + if(!Graphics()->LoadPNG(&Info, aBuf, IStorage::TYPE_ALL)) + { + char aMsg[64]; + str_format(aMsg, sizeof(aMsg), "failed to load '%s'", aBuf); + Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aMsg); + continue; + } + CountryFlag.m_Texture = Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0); + mem_free(Info.m_pData); + } + m_aCountryFlags.add_unsorted(CountryFlag); + + // print message + if(g_Config.m_Debug) + { + str_format(aBuf, sizeof(aBuf), "loaded country flag '%s'", pCountryName); + Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); + } + } } } - - // add entry - CCountryFlag CountryFlag; - CountryFlag.m_CountryCode = CountryCode; - str_copy(CountryFlag.m_aCountryCodeString, aOrigin, sizeof(CountryFlag.m_aCountryCodeString)); - if(g_Config.m_ClLoadCountryFlags) - { - CountryFlag.m_Texture = Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0); - mem_free(Info.m_pData); - } - - if(g_Config.m_Debug) - { - str_format(aBuf, sizeof(aBuf), "loaded country flag '%s'", aOrigin); - Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); - } - m_aCountryFlags.add_unsorted(CountryFlag); } - io_close(File); + + // clean up + json_value_free(pJsonData); m_aCountryFlags.sort_range(); // find index of default item