MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / findVersions

Method findVersions

Source/ResourceMan.cpp:133–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133void cResourceMan::findVersions() {
134 bool haveRetail = false;
135
136 mReleasePath.clear();
137 mReleaseFiles.clear();
138
139 // Loop each path
140 for (auto& ValidPath : mValidPaths) {
141 // Loop all known versions
142 for (auto& KnownVersion : KnownGameVersions) {
143 // If this release has files, continue on
144 if (mReleaseFiles.find(&KnownVersion) != mReleaseFiles.end())
145 continue;
146
147 std::string base = ValidPath + PathGenerate(KnownVersion.mDataPath, eData) + "/";
148 tStringMap ReleaseFiles;
149
150 // Loop all files in the data directory
151 auto baseFiles = DirectoryList(base, "");
152 for (auto& baseFile : baseFiles) {
153 std::string baseFileLower = baseFile;
154 transform(baseFileLower.begin(), baseFileLower.end(), baseFileLower.begin(), ::tolower);
155
156 // Loop each file of known version
157 for (auto& File : KnownVersion.mFiles) {
158 std::string FileLower = File.mName;
159 transform(FileLower.begin(), FileLower.end(), FileLower.begin(), ::tolower);
160
161 // See if we match
162 if (baseFileLower == FileLower) {
163 std::string MD5 = FileMD5(base + baseFile);
164
165 ReleaseFiles.insert(std::make_pair(FileLower, base + baseFile));
166
167 if (MD5 != File.mChecksum) {
168 if (MD5.length() == 0) {
169 //std::cout << KnownVersion.mName << ": " << KnownVersion.mFiles[FileNo].mName;
170 //std::cout << " File not found\n";
171 } else {
172 //std::cout << "{ \"" << File.mName << "\", \"" << MD5 << "\" }, \n";
173 std::cout << KnownVersion.mName << ": " << File.mName;
174 std::cout << " Unknown MD5: " << MD5 << "\n";
175 }
176 }
177
178 break;
179 }
180 }
181 }
182
183 // A very hacky method for ensuring a retail version is available, before allowing Customs
184 if (KnownVersion.isCustom()) {
185 if (g_Fodder->mParams->mDefaultGame == KnownVersion.mGame) {
186 if (haveRetail)
187 mReleasePath.insert(std::make_pair(&KnownVersion, base));
188 }
189 } else {
190

Callers

nothing calls this directly

Calls 8

findMethod · 0.80
insertMethod · 0.80
isRetailMethod · 0.80
clearMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
isCustomMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected