Scan in multiple folders

This commit is contained in:
Vasilii Rogin 2024-04-19 13:40:15 +03:00
parent 7f2e4cb1e6
commit 3eb054fb77
1 changed files with 28 additions and 16 deletions

View File

@ -21,6 +21,7 @@
#include "platform_compat.h" #include "platform_compat.h"
#include "sfall_global_scripts.h" #include "sfall_global_scripts.h"
#include "svga.h" #include "svga.h"
#include <vector>
namespace fallout { namespace fallout {
@ -2523,9 +2524,18 @@ static void opLookupStringProc(Program* program)
void checkScriptsOpcodes() void checkScriptsOpcodes()
{ {
auto SCRIPTS_FOLDER_PATH = "master.dat/scripts";
printf("Checking scripts opcodes in %s\n", SCRIPTS_FOLDER_PATH); std::vector<char*> SCRIPTS_FOLDER_PATHS = {
"master.dat/scripts",
"data/scripts",
"patch000.dat/scripts",
"MODS/INVENTORYFILTER.DAT/SCRIPTS"
};
printf("Checking scripts opcodes in:\n");
for (auto f : SCRIPTS_FOLDER_PATHS) {
printf(" - %s\n", f);
}
std::map<opcode_t, std::set<std::string>> unknown_opcodes; std::map<opcode_t, std::set<std::string>> unknown_opcodes;
@ -2586,21 +2596,23 @@ void checkScriptsOpcodes()
}; };
int checked_files = 0; int checked_files = 0;
for (auto dirEntry : std::filesystem::directory_iterator(SCRIPTS_FOLDER_PATH)) { for (auto dirPath : SCRIPTS_FOLDER_PATHS) {
if (!dirEntry.is_regular_file()) { for (auto dirEntry : std::filesystem::directory_iterator(dirPath)) {
continue; if (!dirEntry.is_regular_file()) {
}; continue;
auto file = dirEntry.path(); };
auto ext = file.extension().string(); auto file = dirEntry.path();
for (char& ch : ext) { auto ext = file.extension().string();
ch = std::tolower(ch); for (char& ch : ext) {
}; ch = std::tolower(ch);
if (ext != ".int") { };
continue; if (ext != ".int") {
}; continue;
};
check_file(file.string()); check_file(file.string());
checked_files++; checked_files++;
};
}; };
if (unknown_opcodes.size() == 0) { if (unknown_opcodes.size() == 0) {