From b9d88513386d7b82dc2a80d209214d904551c05e Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Sun, 15 Sep 2024 00:37:50 -0400 Subject: [PATCH] Lua API: Avoid looking up the requested scenario twice --- src/gui/dialogs/multiplayer/mp_create_game.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/dialogs/multiplayer/mp_create_game.cpp b/src/gui/dialogs/multiplayer/mp_create_game.cpp index ebd15e5a1ff..fb82f87a215 100644 --- a/src/gui/dialogs/multiplayer/mp_create_game.cpp +++ b/src/gui/dialogs/multiplayer/mp_create_game.cpp @@ -416,9 +416,10 @@ void mp_create_game::pre_show() plugins_context_->set_accessor("find_level", [this](const config& cfg) { const std::string id = cfg["id"].str(); + auto result = create_engine_.find_level_by_id(id); return config { - "index", create_engine_.find_level_by_id(id).second, - "type", level_type::get_string(create_engine_.find_level_by_id(id).first), + "index", result.second, + "type", level_type::get_string(result.first), }; });