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

Function ScanModRows

engine/Poseidon/UI/OptionsUIApp.cpp:1259–1296  ·  view source on GitHub ↗

Build the catalog rows from the mods actually on disk: local mods (source=Local) from LocalModsRoot() + downloaded mods (source=Workshop) from WorkshopModsRoot(). A mod whose @ is in the current mod path (ModSystem::GetModList) is Active+ticked, else Downloaded+unticked. The remote catalog is merged on top later (MergeWorkshopMods) for not-yet-downloaded workshop mods.

Source from the content-addressed store, hash-verified

1257
1258// Build the catalog rows from the mods actually on disk: local mods (source=Local)
1259// from LocalModsRoot() + downloaded mods (source=Workshop) from WorkshopModsRoot().
1260// A mod whose @<folder> is in the current mod path (ModSystem::GetModList) is
1261// Active+ticked, else Downloaded+unticked. The remote catalog is merged on top
1262// later (MergeWorkshopMods) for not-yet-downloaded workshop mods.
1263static AutoArray<ModRow> ScanModRows()
1264{
1265 AutoArray<ModRow> rows;
1266
1267 std::set<std::string> active; // lowercased "@folder" basenames currently mounted
1268 std::istringstream ss(std::string((const char*)Poseidon::ModSystem::GetModList()));
1269 std::string seg;
1270 while (std::getline(ss, seg, ';'))
1271 {
1272 if (seg.empty())
1273 continue;
1274 active.insert(LowerStr(std::filesystem::path(seg).filename().string()));
1275 }
1276
1277 std::set<std::string> seen; // lowercased catalog modId/folder id, so both roots list once
1278 auto scan = [&](const std::string& root, ModRowSource source)
1279 {
1280 for (const ScannedMod& sm : ScanLocalMods(root))
1281 {
1282 if (!seen.insert(LowerStr(sm.modId)).second)
1283 continue;
1284 ModRow r;
1285 r.modId = sm.modId.c_str();
1286 r.folderName = sm.folderName.c_str();
1287 r.name = sm.name.c_str();
1288 r.version = sm.version.c_str();
1289 r.sizeBytes = sm.sizeBytes;
1290 r.source = source;
1291 const bool isActive = active.count(LowerStr(sm.folderName)) > 0;
1292 r.state = isActive ? ModRowState::Active : ModRowState::Downloaded;
1293 r.checked = isActive;
1294 rows.Add(r);
1295 }
1296 };
1297 scan(LocalModsRoot(), ModRowSource::Local);
1298 scan(WorkshopModsRoot(), ModRowSource::Workshop);
1299 return rows;

Callers 1

OnCreateCtrlMethod · 0.85

Calls 7

ScanLocalModsFunction · 0.85
LocalModsRootFunction · 0.85
WorkshopModsRootFunction · 0.85
LowerStrFunction · 0.70
emptyMethod · 0.45
countMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected