| 939 | } |
| 940 | |
| 941 | bool CGameConfig::EnterFile(const char *file, char *error, size_t maxlength) |
| 942 | { |
| 943 | SMCError err; |
| 944 | SMCStates state = {0, 0}; |
| 945 | |
| 946 | g_pSM->BuildPath(Path_SM, m_CurFile, sizeof(m_CurFile), "gamedata/%s", file); |
| 947 | |
| 948 | /* Initialize parse states */ |
| 949 | m_IgnoreLevel = 0; |
| 950 | bShouldBeReadingDefault = true; |
| 951 | m_ParseState = PSTATE_NONE; |
| 952 | const char *pEngine[2] = { m_pBaseEngine, m_pEngine }; |
| 953 | |
| 954 | for (unsigned char iter = 0; iter < SM_ARRAYSIZE(pEngine); ++iter) |
| 955 | { |
| 956 | if (pEngine[iter] == NULL) |
| 957 | { |
| 958 | continue; |
| 959 | } |
| 960 | |
| 961 | this->SetParseEngine(pEngine[iter]); |
| 962 | if ((err=textparsers->ParseSMCFile(m_CurFile, this, &state, error, maxlength)) |
| 963 | != SMCError_Okay) |
| 964 | { |
| 965 | const char *msg = textparsers->GetSMCErrorString(err); |
| 966 | |
| 967 | logger->LogError("[SM] Error parsing gameconfig file \"%s\":", m_CurFile); |
| 968 | logger->LogError("[SM] Error %d on line %d, col %d: %s", |
| 969 | err, |
| 970 | state.line, |
| 971 | state.col, |
| 972 | msg ? msg : "Unknown error"); |
| 973 | |
| 974 | if (m_ParseState == PSTATE_GAMEDEFS_CUSTOM) |
| 975 | { |
| 976 | //error occurred while parsing a custom section |
| 977 | m_CustomHandler->ReadSMC_ParseEnd(true, true); |
| 978 | m_CustomHandler = NULL; |
| 979 | m_CustomLevel = 0; |
| 980 | } |
| 981 | |
| 982 | return false; |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | return true; |
| 987 | } |
| 988 | |
| 989 | void CGameConfig::SetBaseEngine(const char *engine) |
| 990 | { |
nothing calls this directly
no test coverage detected