| 819 | static MasterReader master_reader; |
| 820 | |
| 821 | bool CGameConfig::Reparse(char *error, size_t maxlength) |
| 822 | { |
| 823 | /* Reset cached data */ |
| 824 | m_Offsets.clear(); |
| 825 | m_Props.clear(); |
| 826 | m_Keys.clear(); |
| 827 | m_Addresses.clear(); |
| 828 | |
| 829 | char path[PLATFORM_MAX_PATH]; |
| 830 | |
| 831 | /* See if we can use the extended gamedata format. */ |
| 832 | g_pSM->BuildPath(Path_SM, path, sizeof(path), "gamedata/%s/master.games.txt", m_File); |
| 833 | if (!libsys->PathExists(path)) |
| 834 | { |
| 835 | /* Nope, use the old mechanism. */ |
| 836 | ke::SafeSprintf(path, sizeof(path), "%s.txt", m_File); |
| 837 | if (!EnterFile(path, error, maxlength)) |
| 838 | { |
| 839 | return false; |
| 840 | } |
| 841 | |
| 842 | /* Allow customization. */ |
| 843 | g_pSM->BuildPath(Path_SM, path, sizeof(path), "gamedata/custom/%s.txt", m_File); |
| 844 | if (libsys->PathExists(path)) |
| 845 | { |
| 846 | ke::SafeSprintf(path, sizeof(path), "custom/%s.txt", m_File); |
| 847 | bool success = EnterFile(path, error, maxlength); |
| 848 | if (success) |
| 849 | { |
| 850 | rootmenu->ConsolePrint("[SM] Parsed custom gamedata override file: %s", path); |
| 851 | } |
| 852 | return success; |
| 853 | } |
| 854 | return true; |
| 855 | } |
| 856 | |
| 857 | /* Otherwise, it's time to parse the master. */ |
| 858 | SMCError err; |
| 859 | SMCStates state = {0, 0}; |
| 860 | List<String> fileList; |
| 861 | master_reader.fileList = &fileList; |
| 862 | const char *pEngine[2] = { m_pBaseEngine, m_pEngine }; |
| 863 | |
| 864 | for (unsigned char iter = 0; iter < SM_ARRAYSIZE(pEngine); ++iter) |
| 865 | { |
| 866 | if (pEngine[iter] == NULL) |
| 867 | { |
| 868 | continue; |
| 869 | } |
| 870 | |
| 871 | this->SetParseEngine(pEngine[iter]); |
| 872 | err = textparsers->ParseSMCFile(path, &master_reader, &state, error, maxlength); |
| 873 | if (err != SMCError_Okay) |
| 874 | { |
| 875 | const char *msg = textparsers->GetSMCErrorString(err); |
| 876 | |
| 877 | logger->LogError("[SM] Error parsing master gameconf file \"%s\":", path); |
| 878 | logger->LogError("[SM] Error %d on line %d, col %d: %s", |
no test coverage detected