From e8256e2774beccc7d6f26b8f13dc7657f328e431 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 24 Dec 2022 09:01:06 +0200 Subject: [PATCH 10/10] Do not count dead players towards ready/unready players in pregame Server and clients: - Dead players do not affect whether game can start or not Gtk- and Qt-clients: - "Start" button is never sensitive for dead players See osdn #44621 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/pages.c | 10 +++++----- client/gui-gtk-3.0/pages.c | 10 +++++----- client/gui-gtk-3.22/pages.c | 10 +++++----- client/gui-qt/pages.cpp | 10 +++++----- server/srv_main.c | 7 ++++--- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/client/gui-gtk-2.0/pages.c b/client/gui-gtk-2.0/pages.c index 670e602774..a1a471e76d 100644 --- a/client/gui-gtk-2.0/pages.c +++ b/client/gui-gtk-2.0/pages.c @@ -2114,17 +2114,17 @@ static void update_start_page_buttons(void) /*** Ready button. ***/ if (can_client_control()) { - sensitive = TRUE; + sensitive = client_player()->is_alive; if (client_player()->is_ready) { text = _("Not _ready"); } else { int num_unready = 0; - players_iterate(pplayer) { + players_iterate_alive(pplayer) { if (is_human(pplayer) && !pplayer->is_ready) { num_unready++; } - } players_iterate_end; + } players_iterate_alive_end; if (num_unready > 1) { text = _("_Ready"); @@ -2138,14 +2138,14 @@ static void update_start_page_buttons(void) text = _("_Start"); if (can_client_access_hack()) { sensitive = TRUE; - players_iterate(plr) { + players_iterate_alive(plr) { if (is_human(plr)) { /* There's human controlled player(s) in game, so it's their * job to start the game. */ sensitive = FALSE; break; } - } players_iterate_end; + } players_iterate_alive_end; } else { sensitive = FALSE; } diff --git a/client/gui-gtk-3.0/pages.c b/client/gui-gtk-3.0/pages.c index 3e3ef3cd4f..c8c1366eb9 100644 --- a/client/gui-gtk-3.0/pages.c +++ b/client/gui-gtk-3.0/pages.c @@ -2185,17 +2185,17 @@ static void update_start_page_buttons(void) /*** Ready button. ***/ if (can_client_control()) { - sensitive = TRUE; + sensitive = client_player()->is_alive; if (client_player()->is_ready) { text = _("Not _ready"); } else { int num_unready = 0; - players_iterate(pplayer) { + players_iterate_alive(pplayer) { if (is_human(pplayer) && !pplayer->is_ready) { num_unready++; } - } players_iterate_end; + } players_iterate_alive_end; if (num_unready > 1) { text = _("_Ready"); @@ -2209,14 +2209,14 @@ static void update_start_page_buttons(void) text = _("_Start"); if (can_client_access_hack()) { sensitive = TRUE; - players_iterate(plr) { + players_iterate_alive(plr) { if (is_human(plr)) { /* There's human controlled player(s) in game, so it's their * job to start the game. */ sensitive = FALSE; break; } - } players_iterate_end; + } players_iterate_alive_end; } else { sensitive = FALSE; } diff --git a/client/gui-gtk-3.22/pages.c b/client/gui-gtk-3.22/pages.c index ec72a33e2d..94765c13f1 100644 --- a/client/gui-gtk-3.22/pages.c +++ b/client/gui-gtk-3.22/pages.c @@ -2185,17 +2185,17 @@ static void update_start_page_buttons(void) /*** Ready button. ***/ if (can_client_control()) { - sensitive = TRUE; + sensitive = client_player()->is_alive; if (client_player()->is_ready) { text = _("Not _ready"); } else { int num_unready = 0; - players_iterate(pplayer) { + players_iterate_alive(pplayer) { if (is_human(pplayer) && !pplayer->is_ready) { num_unready++; } - } players_iterate_end; + } players_iterate_alive_end; if (num_unready > 1) { text = _("_Ready"); @@ -2209,14 +2209,14 @@ static void update_start_page_buttons(void) text = _("_Start"); if (can_client_access_hack()) { sensitive = TRUE; - players_iterate(plr) { + players_iterate_alive(plr) { if (is_human(plr)) { /* There's human controlled player(s) in game, so it's their * job to start the game. */ sensitive = FALSE; break; } - } players_iterate_end; + } players_iterate_alive_end; } else { sensitive = FALSE; } diff --git a/client/gui-qt/pages.cpp b/client/gui-qt/pages.cpp index c9d4e2fb1d..b85e54afa9 100644 --- a/client/gui-qt/pages.cpp +++ b/client/gui-qt/pages.cpp @@ -1877,17 +1877,17 @@ void fc_client::update_buttons() /* Ready button */ if (can_client_control()) { - sensitive = true; + sensitive = client_player()->is_alive; if (client_player()->is_ready) { text = _("Not ready"); } else { int num_unready = 0; - players_iterate(pplayer) { + players_iterate_alive(pplayer) { if (is_human(pplayer) && !pplayer->is_ready) { num_unready++; } - } players_iterate_end; + } players_iterate_alive_end; if (num_unready > 1) { text = _("Ready"); @@ -1901,14 +1901,14 @@ void fc_client::update_buttons() text = _("Start"); if (can_client_access_hack() && client.conn.observer) { sensitive = true; - players_iterate(plr) { + players_iterate_alive(plr) { if (is_human(plr)) { /* There's human controlled player(s) in game, so it's their * job to start the game. */ sensitive = false; break; } - } players_iterate_end; + } players_iterate_alive_end; } else { sensitive = false; } diff --git a/server/srv_main.c b/server/srv_main.c index 4410425733..8e09e39ab0 100644 --- a/server/srv_main.c +++ b/server/srv_main.c @@ -2300,7 +2300,7 @@ void handle_player_ready(struct player *requestor, if (is_ready) { int num_ready = 0, num_unready = 0; - players_iterate(other_player) { + players_iterate_alive(other_player) { if (other_player->is_connected) { if (other_player->is_ready) { num_ready++; @@ -2308,10 +2308,11 @@ void handle_player_ready(struct player *requestor, num_unready++; } } - } players_iterate_end; + } players_iterate_alive_end; + if (num_unready > 0) { notify_conn(NULL, NULL, E_SETTING, ftc_server, - _("Waiting to start game: %d out of %d players " + _("Waiting to start game: %d out of %d alive players " "are ready to start."), num_ready, num_ready + num_unready); } else { -- 2.35.1