From b08a2ab02328cb874db3844dc9cf843526d2561d Mon Sep 17 00:00:00 2001 From: lassombra Date: Sat, 22 Feb 2025 01:56:23 -0600 Subject: [PATCH] Checklist File Crash fix Fix the MFD to not cause a crash with a bad checklist file. This is an incomplete fix for crashing as it's still possible to crash if there is something wrong with the checklist state in the scenario. More work is needed. --- .../src_mfd/ProjectApolloChecklistMFD.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Orbitersdk/samples/ProjectApollo/src_mfd/ProjectApolloChecklistMFD.cpp b/Orbitersdk/samples/ProjectApollo/src_mfd/ProjectApolloChecklistMFD.cpp index af0bccbc41..3c1fbc8aae 100644 --- a/Orbitersdk/samples/ProjectApollo/src_mfd/ProjectApolloChecklistMFD.cpp +++ b/Orbitersdk/samples/ProjectApollo/src_mfd/ProjectApolloChecklistMFD.cpp @@ -1087,6 +1087,17 @@ bool ProjectApolloChecklistMFD::Update (oapi::Sketchpad* skp) // Make sure that the HiLghtdLine is shown actually bool hiLghtdLineShown = false, redo = true; + if (NumChkLsts == 0) { + //If we end up here, we need to not try to iterate through the screen + //and instead effectively abort - somehow we have no checklists to show + //This would likely be caused by a parsing error when loading the checklist file + redo = false; + TopStep = 0; + skp->SetTextColor(RGB(225, 0, 0)); // red + skp->SetTextAlign(oapi::Sketchpad::CENTER); + line = "No Checklists Available"; + skp->Text((int)(width * .5), (int)(height * 0.10), line.c_str(), line.size()); + } while (redo) { grpcnt = 0; for (cnt = 0; cnt < NLINES; cnt++) {