Application: fix crash when weapon has no parts.

This commit is contained in:
Guillaume Jacquemin 2024-12-06 19:51:50 +01:00
parent 1dd2be6768
commit a35cddfc0c
Signed by: williamjcm
SSH key fingerprint: SHA256:AYLOg+iTV0ElElnlu4vqM4edFazVdRiuQB0Y5LoKc4A

View file

@ -424,6 +424,11 @@ Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
ImGui::Separator(); ImGui::Separator();
if(weapon.parts.isEmpty()) {
ImGui::TextUnformatted("This weapon has no parts.");
return;
}
if(ImGui::CollapsingHeader("Weapon parts")) { if(ImGui::CollapsingHeader("Weapon parts")) {
drawAlignedText("Viewing/editing part:"); drawAlignedText("Viewing/editing part:");
for(std::int32_t i = 0; std::size_t(i) < weapon.parts.size(); i++) { for(std::int32_t i = 0; std::size_t(i) < weapon.parts.size(); i++) {