GUI: prevent division by zero

This commit is contained in:
tildearrow 2022-04-29 04:42:18 -05:00
parent dbf4635646
commit aeea8a4912

View file

@ -66,16 +66,24 @@ void FurnaceGUI::drawNewSong() {
ImGui::EndTable(); ImGui::EndTable();
} }
if (ImGui::Button("Cancel")) { if (ImGui::Button("I'm feeling lucky")) {
if (sysCategories.size()==0) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} else {
FurnaceGUISysCategory* newSystemCat=&sysCategories[rand()%sysCategories.size()];
if (newSystemCat->systems.size()==0) {
ImGui::CloseCurrentPopup();
} else {
nextDesc=newSystemCat->systems[rand()%newSystemCat->systems.size()].definition.data();
accepted=true;
}
}
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("I'm feeling lucky")) { if (ImGui::Button("Cancel")) {
FurnaceGUISysCategory* newSystemCat=&sysCategories[rand()%sysCategories.size()]; ImGui::CloseCurrentPopup();
nextDesc=newSystemCat->systems[rand()%newSystemCat->systems.size()].definition.data();
accepted=true;
} }
if (accepted) { if (accepted) {