MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / readFromQueue

Function readFromQueue

TheForceEngine/TFE_FrontEndUI/modLoader.cpp:922–1078  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

920 }
921
922 void readFromQueue(size_t itemsPerFrame)
923 {
924 FileList gobFiles, txtFiles, imgFiles;
925 const size_t readEnd = min(s_readIndex + itemsPerFrame, s_readQueue.size());
926 const QueuedRead* reads = s_readQueue.data();
927 bool updateFilter = false;
928 for (size_t i = s_readIndex; i < readEnd; i++, s_readIndex++)
929 {
930 updateFilter = true;
931 if (reads[i].type == QREAD_DIR)
932 {
933 // Clear doesn't deallocate in most implementations, so doing it this way should reduce memory allocations.
934 gobFiles.clear();
935 txtFiles.clear();
936 imgFiles.clear();
937
938 const char* subDir = reads[i].path.c_str();
939 FileUtil::readDirectory(subDir, "gob", gobFiles);
940 FileUtil::readDirectory(subDir, "txt", txtFiles);
941 FileUtil::readDirectory(subDir, "jpg", imgFiles);
942
943 // No gob files = no mod.
944 if (gobFiles.size() != 1)
945 {
946 continue;
947 }
948 s_mods.push_back({});
949 ModData& mod = s_mods.back();
950
951 mod.gobFiles = gobFiles;
952 mod.textFile = txtFiles.empty() ? "" : txtFiles[0];
953 mod.imageFile = imgFiles.empty() ? "" : imgFiles[0];
954 mod.text = "";
955
956 size_t fullDirLen = strlen(subDir);
957 for (size_t i = 0; i < fullDirLen; i++)
958 {
959 if (strncasecmp("Mods", &subDir[i], 4) == 0)
960 {
961 mod.relativePath = &subDir[i + 5];
962 break;
963 }
964 }
965
966 if (mod.imageFile.empty())
967 {
968 if (!extractPosterFromMod(subDir, mod.gobFiles[0].c_str(), &mod.image))
969 {
970 s_mods.pop_back();
971 continue;
972 }
973 mod.invertImage = true;
974 }
975 else
976 {
977 extractPosterFromImage(subDir, nullptr, mod.imageFile.c_str(), &mod.image);
978 mod.invertImage = false;
979 }

Callers 2

modLoader_preLoadFunction · 0.85
modLoader_selectionUIFunction · 0.85

Calls 15

minFunction · 0.85
extractPosterFromModFunction · 0.85
extractPosterFromImageFunction · 0.85
parseNameFromTextFunction · 0.85
fixupNameFunction · 0.85
filterModsFunction · 0.85
dataMethod · 0.80
c_strMethod · 0.80
push_backMethod · 0.80
readDirectoryFunction · 0.50
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected