1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-25 00:37:24 +02:00

Implement some TODO's, fix sonar warnings

This commit is contained in:
Ivan Savenko
2024-11-18 14:40:15 +00:00
parent 5ca65f14bd
commit 879eb2184f
6 changed files with 39 additions and 72 deletions

View File

@ -103,7 +103,7 @@ double ModsState::getInstalledModSizeMegabytes(const TModID & modName) const
sizeBytes += boost::filesystem::file_size(*it);
}
double sizeMegabytes = sizeBytes / double(1024*1024);
double sizeMegabytes = sizeBytes / static_cast<double>(1024*1024);
return sizeMegabytes;
}
@ -150,20 +150,19 @@ std::vector<TModID> ModsState::scanModsDirectory(const std::string & modDir) con
///////////////////////////////////////////////////////////////////////////////
static JsonNode loadModSettings(const JsonPath & path)
{
if(CResourceHandler::get("local")->existsResource(ResourcePath(path)))
{
return JsonNode(path);
}
// Probably new install. Create initial configuration
CResourceHandler::get("local")->createResource(path.getOriginalName() + ".json");
return JsonNode();
}
ModsPresetState::ModsPresetState()
{
modConfig = loadModSettings(JsonPath::builtin("config/modSettings.json"));
static const JsonPath settingsPath = JsonPath::builtin("config/modSettings.json");
if(CResourceHandler::get("local")->existsResource(ResourcePath(settingsPath)))
{
modConfig = JsonNode(settingsPath);
}
else
{
// Probably new install. Create initial configuration
CResourceHandler::get("local")->createResource(settingsPath.getOriginalName() + ".json");
}
if(modConfig["presets"].isNull())
{
@ -365,7 +364,6 @@ ModManager::ModManager(const JsonNode & repositoryList)
: modsState(std::make_unique<ModsState>())
, modsPreset(std::make_unique<ModsPresetState>())
{
//TODO: load only active mods & all their submods in game mode?
modsStorage = std::make_unique<ModsStorage>(modsState->getInstalledMods(), repositoryList);
eraseMissingModsFromPreset();