MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / LoadBanks

Function LoadBanks

engine/Poseidon/Core/GameState.cpp:158–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158static void LoadBanks(const char* path, const char* fullPath, bool emptyPrefix, bool parseConfig = false)
159{
160 FindArrayRStringCI bankNames;
161 FindBank find;
162 if (find.First(fullPath))
163 {
164 do
165 {
166 char prefix[256];
167 snprintf(prefix, sizeof(prefix), "%s", (const char*)find.GetName());
168 strlwr(prefix);
169 char* ext = strrchr(prefix, '.');
170 PoseidonAssert(ext);
171 *ext = 0;
172 bankNames.AddUnique(prefix);
173 } while (find.Next());
174 find.Close();
175 }
176 RString bankPrefix = RString(path) + RString("\\");
177 const char* langSuffix = GetLanguagePboSuffix(GLanguage);
178 for (int i = 0; i < bankNames.Size(); i++)
179 {
180 const RString& bName = bankNames[i];
181 // Skip base PBO when language-specific variant exists (e.g., skip "1985" when "1985.cz" exists)
182 if (langSuffix)
183 {
184 RString langVariant = bName + RString(".") + RString(langSuffix);
185 if (bankNames.Find(langVariant) >= 0)
186 continue;
187 }
188 RString prefix;
189 if (emptyPrefix)
190 {
191 prefix = bName;
192 }
193 else
194 {
195 prefix = bankPrefix + bName;
196 }
197 // Runtime bank prefix remapping for language-specific PBOs
198 if (stricmp(GLanguage, "Czech") == 0 && stricmp(prefix, "fonts.cz") == 0)
199 prefix = "fonts";
200 else if (stricmp(GLanguage, "Russian") == 0 && stricmp(prefix, "fonts.russian") == 0)
201 prefix = "fonts";
202 else if (stricmp(GLanguage, "Polish") == 0 && stricmp(prefix, "fonts.polish") == 0)
203 prefix = "fonts";
204 // Strip language PBO suffix to remap to base prefix (e.g., "campaigns\1985.cz""campaigns\1985")
205 if (langSuffix)
206 {
207 char dotSuffix[16];
208 snprintf(dotSuffix, sizeof(dotSuffix), ".%s", langSuffix);
209 int sLen = (int)strlen(dotSuffix);
210 int pLen = (int)strlen(prefix);
211 if (pLen > sLen && stricmp((const char*)prefix + pLen - sLen, dotSuffix) == 0)
212 {
213 char buf[256];
214 memcpy(buf, (const char*)prefix, pLen - sLen);
215 buf[pLen - sLen] = 0;

Callers 1

LoadBanksCallbackFunction · 0.85

Calls 13

GetLanguagePboSuffixFunction · 0.85
strlwrFunction · 0.70
stricmpFunction · 0.70
RStringClass · 0.50
FirstMethod · 0.45
GetNameMethod · 0.45
AddUniqueMethod · 0.45
NextMethod · 0.45
CloseMethod · 0.45
SizeMethod · 0.45
FindMethod · 0.45

Tested by

no test coverage detected