From 7e8c8b1d565ca44a8fe5a4313dcfcce528bcf8c6 Mon Sep 17 00:00:00 2001 From: Kirk Lazarus <7864917+kirklandsig@users.noreply.github.com> Date: Tue, 6 Oct 2026 21:14:15 -0400 Subject: [PATCH] Menus: no save file read each frame The server and LAN browsers name each visible row's map every frame (map_display_name), and the lobby shows its map every frame (lobby_map_show). Both went through ui_widget_port_multiplayer_maps, which also reads the map used last from z:\lastmpmp.txt. Until a game has been hosted there is no such file, and each failed read also writes two lines to debug.txt. The map used last is now looked up only when the caller asks for it (last_used not NULL), as the menus that open a map list do. profile_name_show read the last-used profile at most once a second when the read worked, but read one that could not be read again every frame. That one is now tried again a second later too. Co-Authored-By: Claude --- port/linux/game/menu_functions.c | 21 ++++++++++++------- .../ui_widget_event_handler_functions.c | 6 +++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/port/linux/game/menu_functions.c b/port/linux/game/menu_functions.c index 0c85e5e6..e4616354 100644 --- a/port/linux/game/menu_functions.c +++ b/port/linux/game/menu_functions.c @@ -813,6 +813,7 @@ static void profile_name_show(struct widget_instance *description) static struct player_profile profile; static long read_index = NONE; static unsigned long read_time; + static boolean read_good; long index = player_ui_get_active_player_profile_index(0); if (!description) @@ -824,13 +825,17 @@ static void profile_name_show(struct widget_instance *description) } else if ((index = player_ui_get_player1_last_used_profile_index()) == NONE) return; - else if (index != read_index || system_milliseconds() - read_time > 1000) + else { - read_index = NONE; - if (!player_profile_get(index, &profile)) + /* (one that cannot be read too: tried again a second later) */ + if (index != read_index || system_milliseconds() - read_time > 1000) + { + read_index = index; + read_good = player_profile_get(index, &profile); + read_time = system_milliseconds(); + } + if (!read_good) return; - read_index = index; - read_time = system_milliseconds(); } text_set(named(description, "current_profile_name", 0), profile.player_name); } @@ -3103,8 +3108,8 @@ scenario's path or name */ static void map_display_name(char const *map_name, wchar_t *text) { char const *const *names; - short last, index; - short count = ui_widget_port_multiplayer_maps(&names, &last); + short index; + short count = ui_widget_port_multiplayer_maps(&names, NULL); for (index = 0; index < count; index++) { @@ -4037,7 +4042,7 @@ static void lobby_row_text(short row, wchar_t *text) static void lobby_map_show(struct widget_instance *description, char const *map_name) { char const *const *names; - short last, count = ui_widget_port_multiplayer_maps(&names, &last), map = 19, index; + short count = ui_widget_port_multiplayer_maps(&names, NULL), map = 19, index; short level = campaign_level_of(map_name); struct widget_instance *widget; diff --git a/source/interface/ui_widget_event_handler_functions.c b/source/interface/ui_widget_event_handler_functions.c index 45147d92..2d2dca43 100644 --- a/source/interface/ui_widget_event_handler_functions.c +++ b/source/interface/ui_widget_event_handler_functions.c @@ -5881,7 +5881,9 @@ static boolean solo_level_initialize_list_single_player( /* port: the PC version's multiplayer menus (port/linux/game/menu_functions.c), on our lists rather than the Xbox's spinners: */ -/* the multiplayer maps (the Xbox's 13), and the one used last (else 0) */ +/* the multiplayer maps (the Xbox's 13), and the one used last (else 0), +unless last_used is NULL: it is read from a file of the save root, which the +menus that name maps each frame need not do */ short ui_widget_port_multiplayer_maps( char const *const **names, short *last_used) @@ -5890,6 +5892,8 @@ short ui_widget_port_multiplayer_maps( short level_index; *names = (char const *const *)event_handler_functions.multiplayer_levels; + if (!last_used) + return 13; *last_used = 0; if (saved_game_file_retrieve_last_used_multiplayer_map(map_name)) {