A bunch of minor tweaks from cppcheck

This commit is contained in:
Pk11
2021-03-26 06:01:37 -05:00
parent e06d475131
commit c95d66f0e4
19 changed files with 110 additions and 204 deletions
+2 -14
View File
@@ -49,7 +49,6 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms
int selection = 0, sPos = 0;
std::vector<DirEntry> dirContents;
dirContents.clear();
/* Make sure. */
if (access((oldDir + std::string("/")).c_str(), F_OK) == 0) {
@@ -60,12 +59,7 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms
chdir("sdmc:/");
}
std::vector<DirEntry> dirContentsTemp;
getDirectoryContents(dirContentsTemp, {"/"});
for(uint i = 0; i < dirContentsTemp.size(); i++) {
dirContents.push_back(dirContentsTemp[i]);
}
getDirectoryContents(dirContents, {"/"});
while(1) {
Gui::clearTextBufs();
@@ -110,13 +104,7 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms
selection = 0;
sPos = 0;
dirContents.clear();
std::vector<DirEntry> dirContentsTemp;
getDirectoryContents(dirContentsTemp, {"/"});
for(uint i = 0; i < dirContentsTemp.size(); i++) {
dirContents.push_back(dirContentsTemp[i]);
}
getDirectoryContents(dirContents, {"/"});
}
+48 -52
View File
@@ -119,39 +119,37 @@ static bool DownloadStore() {
if (storeJson.is_discarded())
storeJson = { };
if (doSheet) {
if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) {
const std::vector<std::string> locs = storeJson["storeInfo"]["sheetURL"].get<std::vector<std::string>>();
const std::vector<std::string> sht = storeJson["storeInfo"]["sheet"].get<std::vector<std::string>>();
if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) {
const std::vector<std::string> locs = storeJson["storeInfo"]["sheetURL"].get<std::vector<std::string>>();
const std::vector<std::string> sht = storeJson["storeInfo"]["sheet"].get<std::vector<std::string>>();
if (locs.size() == sht.size()) {
for (int i = 0; i < (int)sht.size(); i++) {
if (!(sht[i].find("/") != std::string::npos)) {
char msg[150];
snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size());
Msg::DisplayMsg(msg);
DownloadSpriteSheet(locs[i], sht[i]);
if (locs.size() == sht.size()) {
for (int i = 0; i < (int)sht.size(); i++) {
if (!(sht[i].find("/") != std::string::npos)) {
char msg[150];
snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size());
Msg::DisplayMsg(msg);
DownloadSpriteSheet(locs[i], sht[i]);
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
}
}
}
} else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) {
const std::string fl = storeJson["storeInfo"]["sheetURL"];
const std::string fl2 = storeJson["storeInfo"]["sheet"];
} else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) {
const std::string fl = storeJson["storeInfo"]["sheetURL"];
const std::string fl2 = storeJson["storeInfo"]["sheet"];
if (!(fl2.find("/") != std::string::npos)) {
Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET"));
DownloadSpriteSheet(fl, fl2);
if (!(fl2.find("/") != std::string::npos)) {
Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET"));
DownloadSpriteSheet(fl, fl2);
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
}
}
@@ -177,39 +175,37 @@ static bool UpdateStore(const std::string &URL) {
if (storeJson.is_discarded())
storeJson = { };
if (doSheet) {
if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) {
const std::vector<std::string> locs = storeJson["storeInfo"]["sheetURL"].get<std::vector<std::string>>();
const std::vector<std::string> sht = storeJson["storeInfo"]["sheet"].get<std::vector<std::string>>();
if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_array()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_array()) {
const std::vector<std::string> locs = storeJson["storeInfo"]["sheetURL"].get<std::vector<std::string>>();
const std::vector<std::string> sht = storeJson["storeInfo"]["sheet"].get<std::vector<std::string>>();
if (locs.size() == sht.size()) {
for (int i = 0; i < (int)sht.size(); i++) {
if (!(sht[i].find("/") != std::string::npos)) {
char msg[150];
snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size());
Msg::DisplayMsg(msg);
DownloadSpriteSheet(locs[i], sht[i]);
if (locs.size() == sht.size()) {
for (int i = 0; i < (int)sht.size(); i++) {
if (!(sht[i].find("/") != std::string::npos)) {
char msg[150];
snprintf(msg, sizeof(msg), Lang::get("DOWNLOADING_SPRITE_SHEET2").c_str(), i + 1, sht.size());
Msg::DisplayMsg(msg);
DownloadSpriteSheet(locs[i], sht[i]);
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
}
}
}
} else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) {
const std::string fl = storeJson["storeInfo"]["sheetURL"];
const std::string fl2 = storeJson["storeInfo"]["sheet"];
} else if (storeJson["storeInfo"].contains("sheetURL") && storeJson["storeInfo"]["sheetURL"].is_string()) {
if (storeJson["storeInfo"].contains("sheet") && storeJson["storeInfo"]["sheet"].is_string()) {
const std::string fl = storeJson["storeInfo"]["sheetURL"];
const std::string fl2 = storeJson["storeInfo"]["sheet"];
if (!(fl2.find("/") != std::string::npos)) {
Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET"));
DownloadSpriteSheet(fl, fl2);
if (!(fl2.find("/") != std::string::npos)) {
Msg::DisplayMsg(Lang::get("DOWNLOADING_SPRITE_SHEET"));
DownloadSpriteSheet(fl, fl2);
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
} else {
Msg::waitMsg(Lang::get("SHEET_SLASH"));
}
}
}
@@ -275,10 +271,10 @@ void Overlays::SelectStore() {
if (sPos + i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, UIThemes->MarkSelected());
Gui::DrawStringCentered(10 - 160 + (300 / 2), mainButtons[i].y + 4, 0.45f, UIThemes->TextColor(), info[sPos + i].FileName, 295, 0, font);
}
} else {
GFX::DrawBottom(); // Otherwise we'd draw on top.
}
if (info.size() <= 0) GFX::DrawBottom(); // Otherwise we'd draw on top.
GFX::DrawIcon(sprites_delete_idx, mainButtons[6].x, mainButtons[6].y, UIThemes->TextColor());
GFX::DrawIcon(sprites_update_idx, mainButtons[7].x, mainButtons[7].y, UIThemes->TextColor());
GFX::DrawIcon(sprites_add_idx, mainButtons[8].x, mainButtons[8].y, UIThemes->TextColor());