MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / ReparseFile

Method ReparseFile

core/logic/Translator.cpp:110–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110void CPhraseFile::ReparseFile()
111{
112 m_PhraseLookup.clear();
113
114 m_LangCount = m_pTranslator->GetLanguageCount();
115
116 if (!m_LangCount)
117 {
118 return;
119 }
120
121 SMCError err;
122 char path[PLATFORM_MAX_PATH];
123 g_pSM->BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "translations/%s", m_File.c_str());
124
125 //backwards compatibility shim
126 /* :HACKHACK: Change .cfg/.txt and vice versa for compatibility */
127 if (!libsys->PathExists(path))
128 {
129 if (m_File.compare("common.cfg") == 0)
130 {
131 UTIL_ReplaceAll(path, sizeof(path), "common.cfg", "common.phrases.txt", true);
132 } else if (strstr(path, ".cfg")) {
133 UTIL_ReplaceAll(path, sizeof(path), ".cfg", ".txt", true);
134 } else if (strstr(path, ".txt")) {
135 UTIL_ReplaceAll(path, sizeof(path), ".txt", ".cfg", true);
136 }
137 }
138
139 SMCStates states;
140
141 if ((err=textparsers->ParseFile_SMC(path, this, &states)) != SMCError_Okay)
142 {
143 const char *msg = textparsers->GetSMCErrorString(err);
144 if (!msg)
145 {
146 msg = m_ParseError.c_str();
147 }
148
149 logger->LogError("[SM] Fatal error encountered parsing translation file \"%s\"", m_File.c_str());
150 logger->LogError("[SM] Error (line %d, column %d): %s", states.line, states.col, msg);
151 }
152
153 const char *code;
154 for (unsigned int i = 1; i < m_LangCount; i++)
155 {
156 if (!m_pTranslator->GetLanguageInfo(i, &code, NULL))
157 {
158 continue;
159 }
160
161 g_pSM->BuildPath(Path_SM,
162 path,
163 PLATFORM_MAX_PATH,
164 "translations/%s/%s",
165 code,
166 m_File.c_str());
167

Callers 2

FindOrAddPhraseFileMethod · 0.80

Calls 10

UTIL_ReplaceAllFunction · 0.85
GetLanguageCountMethod · 0.80
BuildPathMethod · 0.80
PathExistsMethod · 0.80
GetLanguageInfoMethod · 0.80
clearMethod · 0.45
c_strMethod · 0.45
ParseFile_SMCMethod · 0.45
GetSMCErrorStringMethod · 0.45
LogErrorMethod · 0.45

Tested by

no test coverage detected