From 6fd25f8f4f9cf5550945f5c945f8d8106e2cd6ba Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 14 Jun 2025 08:59:43 -0500 Subject: [PATCH] Fix range check for import town choice --- src/scenedit/scen.townout.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scenedit/scen.townout.cpp b/src/scenedit/scen.townout.cpp index f9b9f21d..c6cf2f4c 100644 --- a/src/scenedit/scen.townout.cpp +++ b/src/scenedit/scen.townout.cpp @@ -460,7 +460,7 @@ void edit_sign(sign_loc_t& which_sign,short num,short picture) { sign_dlg.run(); } -static bool save_town_num(cDialog& me, std::string, eKeyMod) { +static bool save_town_num(cDialog& me, std::string, eKeyMod, cScenario& scenario) { using namespace std::placeholders; me["town"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, scenario.towns.size() - 1, "Town number")); if(me.toast(true)) me.setResult(me["town"].getTextAsNum()); @@ -492,12 +492,13 @@ static bool create_town_num(cDialog& me, std::string, eKeyMod) { } short pick_town_num(std::string which_dlog,short def,cScenario& scenario) { + using namespace std::placeholders; cDialog town_dlg(*ResMgr::dialogs.get(which_dlog)); town_dlg["prompt"].replaceText("{{max-num}}", std::to_string(scenario.towns.size() - 1)); town_dlg["prompt"].replaceText("{{next-num}}", std::to_string(scenario.towns.size())); town_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &town_dlg, false)); - town_dlg["okay"].attachClickHandler(save_town_num); + town_dlg["okay"].attachClickHandler(std::bind(save_town_num, _1, _2, _3, std::ref(scenario))); town_dlg["choose"].attachClickHandler([&scenario](cDialog& me, std::string, eKeyMod) -> bool { int i = me["town"].getTextAsNum(); if(&scenario != &::scenario)