mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-05 08:39:05 +00:00
Fix Crashes when touching non existing entry positions.
This commit is contained in:
@@ -45,12 +45,12 @@ std::string maxScripts;
|
|||||||
|
|
||||||
void fixInfo(nlohmann::json &json) {
|
void fixInfo(nlohmann::json &json) {
|
||||||
for(uint i=0;i<json.size();i++) {
|
for(uint i=0;i<json.size();i++) {
|
||||||
if(!json[i].contains("title")) json[i]["title"] = "TITLE";
|
if(!json[i].contains("title")) json[i]["title"] = "TITLE";
|
||||||
if(!json[i].contains("author")) json[i]["author"] = "AUTHOR";
|
if(!json[i].contains("author")) json[i]["author"] = "AUTHOR";
|
||||||
if(!json[i].contains("shortDesc")) json[i]["shortDesc"] = "SHORTDESC";
|
if(!json[i].contains("shortDesc")) json[i]["shortDesc"] = "SHORTDESC";
|
||||||
if(!json[i].contains("revision")) json[i]["revision"] = 0;
|
if(!json[i].contains("revision")) json[i]["revision"] = 0;
|
||||||
if(!json[i].contains("curRevision")) json[i]["curRevision"] = 0;
|
if(!json[i].contains("curRevision")) json[i]["curRevision"] = 0;
|
||||||
if(!json[i].contains("version")) json[i]["revision"] = 0;
|
if(!json[i].contains("version")) json[i]["revision"] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
|
|
||||||
if (hDown & KEY_TOUCH) {
|
if (hDown & KEY_TOUCH) {
|
||||||
if (Config::viewMode == 0) {
|
if (Config::viewMode == 0) {
|
||||||
for(int i=0;i<ENTRIES_PER_SCREEN;i++) {
|
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)infoJson.size();i++) {
|
||||||
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
|
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
|
||||||
if (infoJson.size() != 0) {
|
if (infoJson.size() != 0) {
|
||||||
std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPos + i]["title"]);
|
std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPos + i]["title"]);
|
||||||
@@ -241,11 +241,11 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
downloadToFile(infoJson[screenPos + i]["url"], Config::ScriptPath + titleFix + ".json");
|
downloadToFile(infoJson[screenPos + i]["url"], Config::ScriptPath + titleFix + ".json");
|
||||||
infoJson[screenPos + i]["curRevision"] = infoJson[screenPos + i]["revision"];
|
infoJson[screenPos + i]["curRevision"] = infoJson[screenPos + i]["revision"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Config::viewMode == 1) {
|
} else if (Config::viewMode == 1) {
|
||||||
for(int i=0;i<ENTRIES_PER_LIST;i++) {
|
for(int i=0;i<ENTRIES_PER_LIST && i<(int)infoJson.size();i++) {
|
||||||
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||||
if (infoJson.size() != 0) {
|
if (infoJson.size() != 0) {
|
||||||
std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPosList + i]["title"]);
|
std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPosList + i]["title"]);
|
||||||
std::string titleFix = infoJson[screenPosList + i]["title"];
|
std::string titleFix = infoJson[screenPosList + i]["title"];
|
||||||
@@ -258,7 +258,7 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
downloadToFile(infoJson[screenPosList + i]["url"], Config::ScriptPath + titleFix + ".json");
|
downloadToFile(infoJson[screenPosList + i]["url"], Config::ScriptPath + titleFix + ".json");
|
||||||
infoJson[screenPosList + i]["curRevision"] = infoJson[screenPosList + i]["revision"];
|
infoJson[screenPosList + i]["curRevision"] = infoJson[screenPosList + i]["revision"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ void checkForValidate(void) {
|
|||||||
nlohmann::json openScriptFile() {
|
nlohmann::json openScriptFile() {
|
||||||
FILE* file = fopen(currentFile.c_str(), "rt");
|
FILE* file = fopen(currentFile.c_str(), "rt");
|
||||||
nlohmann::json jsonFile;
|
nlohmann::json jsonFile;
|
||||||
if(file) jsonFile = nlohmann::json::parse(file, nullptr, false);
|
if(file) jsonFile = nlohmann::json::parse(file, nullptr, false);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return jsonFile;
|
return jsonFile;
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ void runFunctions(nlohmann::json &json) {
|
|||||||
bool missing = false;
|
bool missing = false;
|
||||||
std::string file, message;
|
std::string file, message;
|
||||||
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||||
else missing = true;
|
else missing = true;
|
||||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||||
if(!missing) ScriptHelper::removeFile(file, message);
|
if(!missing) ScriptHelper::removeFile(file, message);
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ void runFunctions(nlohmann::json &json) {
|
|||||||
bool missing = false;
|
bool missing = false;
|
||||||
std::string file, message;
|
std::string file, message;
|
||||||
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||||
else missing = true;
|
else missing = true;
|
||||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||||
if(!missing) ScriptHelper::installFile(file, message);
|
if(!missing) ScriptHelper::installFile(file, message);
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
|
|
||||||
if (hDown & KEY_TOUCH) {
|
if (hDown & KEY_TOUCH) {
|
||||||
if (Config::viewMode == 0) {
|
if (Config::viewMode == 0) {
|
||||||
for(int i=0;i<ENTRIES_PER_SCREEN; i++) {
|
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo.size(); i++) {
|
||||||
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
|
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
|
||||||
if (dirContents[screenPos + i].isDirectory) {
|
if (dirContents[screenPos + i].isDirectory) {
|
||||||
} else if (fileInfo.size() != 0) {
|
} else if (fileInfo.size() != 0) {
|
||||||
@@ -424,7 +424,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Config::viewMode == 1) {
|
} else if (Config::viewMode == 1) {
|
||||||
for(int i=0;i<ENTRIES_PER_LIST; i++) {
|
for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo.size(); i++) {
|
||||||
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||||
if (dirContents[screenPosList + i].isDirectory) {
|
if (dirContents[screenPosList + i].isDirectory) {
|
||||||
} else if (fileInfo.size() != 0) {
|
} else if (fileInfo.size() != 0) {
|
||||||
@@ -541,7 +541,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
|
|
||||||
if (hDown & KEY_TOUCH) {
|
if (hDown & KEY_TOUCH) {
|
||||||
if (Config::viewMode == 0) {
|
if (Config::viewMode == 0) {
|
||||||
for(int i=0;i<ENTRIES_PER_SCREEN; i++) {
|
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo2.size(); i++) {
|
||||||
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
|
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
|
||||||
if (fileInfo2.size() != 0) {
|
if (fileInfo2.size() != 0) {
|
||||||
choice = fileInfo2[screenPos2 + i];
|
choice = fileInfo2[screenPos2 + i];
|
||||||
@@ -550,7 +550,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Config::viewMode == 1) {
|
} else if (Config::viewMode == 1) {
|
||||||
for(int i=0;i<ENTRIES_PER_LIST; i++) {
|
for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo2.size(); i++) {
|
||||||
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||||
if (fileInfo2.size() != 0) {
|
if (fileInfo2.size() != 0) {
|
||||||
choice = fileInfo2[screenPosList2 + i];
|
choice = fileInfo2[screenPosList2 + i];
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ TinyDB::TinyDB() {
|
|||||||
selectedOption = tinyDBList[0];
|
selectedOption = tinyDBList[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// To-Do.
|
|
||||||
void TinyDB::Draw(void) const {
|
void TinyDB::Draw(void) const {
|
||||||
std::string info;
|
std::string info;
|
||||||
Gui::setDraw(top);
|
Gui::setDraw(top);
|
||||||
@@ -228,7 +227,7 @@ void TinyDB::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
|
|
||||||
if (hDown & KEY_TOUCH) {
|
if (hDown & KEY_TOUCH) {
|
||||||
if (Config::viewMode == 0) {
|
if (Config::viewMode == 0) {
|
||||||
for(int i=0;i<ENTRIES_PER_SCREEN;i++) {
|
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)tinyDBList.size();i++) {
|
||||||
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
|
if(touch.py > (i+1)*57 && touch.py < (i+2)*57) {
|
||||||
selection = screenPos + i;
|
selection = screenPos + i;
|
||||||
selectedOption = tinyDBList[screenPos + i];
|
selectedOption = tinyDBList[screenPos + i];
|
||||||
@@ -236,7 +235,7 @@ void TinyDB::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Config::viewMode == 1) {
|
} else if (Config::viewMode == 1) {
|
||||||
for(int i=0;i<ENTRIES_PER_LIST;i++) {
|
for(int i=0;i<ENTRIES_PER_LIST && i<(int)tinyDBList.size();i++) {
|
||||||
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||||
selection = screenPosList + i;
|
selection = screenPosList + i;
|
||||||
selectedOption = tinyDBList[screenPosList + i];
|
selectedOption = tinyDBList[screenPosList + i];
|
||||||
@@ -258,7 +257,7 @@ void TinyDB::execute() {
|
|||||||
bool missing = false;
|
bool missing = false;
|
||||||
std::string file, message;
|
std::string file, message;
|
||||||
if(tinyDBJson.at(selectedOption).at("script").at(i).contains("file")) file = tinyDBJson.at(selectedOption).at("script").at(i).at("file");
|
if(tinyDBJson.at(selectedOption).at("script").at(i).contains("file")) file = tinyDBJson.at(selectedOption).at("script").at(i).at("file");
|
||||||
else missing = true;
|
else missing = true;
|
||||||
if(tinyDBJson.at(selectedOption).at("script").at(i).contains("message")) message = tinyDBJson.at(selectedOption).at("script").at(i).at("message");
|
if(tinyDBJson.at(selectedOption).at("script").at(i).contains("message")) message = tinyDBJson.at(selectedOption).at("script").at(i).at("message");
|
||||||
if(!missing) ScriptHelper::removeFile(file, message);
|
if(!missing) ScriptHelper::removeFile(file, message);
|
||||||
|
|
||||||
@@ -276,7 +275,7 @@ void TinyDB::execute() {
|
|||||||
bool missing = false;
|
bool missing = false;
|
||||||
std::string file, message;
|
std::string file, message;
|
||||||
if(tinyDBJson.at(selectedOption).at("script").at(i).contains("file")) file = tinyDBJson.at(selectedOption).at("script").at(i).at("file");
|
if(tinyDBJson.at(selectedOption).at("script").at(i).contains("file")) file = tinyDBJson.at(selectedOption).at("script").at(i).at("file");
|
||||||
else missing = true;
|
else missing = true;
|
||||||
if(tinyDBJson.at(selectedOption).at("script").at(i).contains("message")) message = tinyDBJson.at(selectedOption).at("script").at(i).at("message");
|
if(tinyDBJson.at(selectedOption).at("script").at(i).contains("message")) message = tinyDBJson.at(selectedOption).at("script").at(i).at("message");
|
||||||
if(!missing) ScriptHelper::installFile(file, message);
|
if(!missing) ScriptHelper::installFile(file, message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user