Author: cazfi Date: Mon May 8 13:02:51 2017 New Revision: 35453 URL: http://svn.gna.org/viewcvs/freeciv?rev=35453&view=rev Log: Fix "Manual Turn Done in AI mode"
Reported by Jacob Nevins <jtn> See hrm Bug #657412 Modified: branches/S2_5/client/client_main.c branches/S2_5/client/mapctrl_common.c branches/S2_5/client/mapctrl_common.h branches/S2_5/client/options.c branches/S2_5/client/packhand.c branches/S2_5/server/srv_main.c Modified: branches/S2_5/client/client_main.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/client_main.c?rev=35453&r1=35452&r2=35453&view=diff ============================================================================== --- branches/S2_5/client/client_main.c (original) +++ branches/S2_5/client/client_main.c Mon May 8 13:02:51 2017 @@ -726,12 +726,12 @@ **************************************************************************/ void send_turn_done(void) { - log_debug("send_turn_done() turn_done_button_state=%d", - get_turn_done_button_state()); - - if (!get_turn_done_button_state()) { + log_debug("send_turn_done() can_end_turn=%d", + can_end_turn()); + + if (!can_end_turn()) { /* - * The turn done button is disabled but the user may have press + * The turn done button is disabled but the user may have pressed * the return key. */ Modified: branches/S2_5/client/mapctrl_common.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/mapctrl_common.c?rev=35453&r1=35452&r2=35453&view=diff ============================================================================== --- branches/S2_5/client/mapctrl_common.c (original) +++ branches/S2_5/client/mapctrl_common.c Mon May 8 13:02:51 2017 @@ -512,8 +512,16 @@ **************************************************************************/ bool get_turn_done_button_state(void) { + return can_end_turn() + && (!client.conn.playing->ai_controlled || ai_manual_turn_done); +} + +/************************************************************************** + Return TRUE iff client can end turn. +**************************************************************************/ +bool can_end_turn(void) +{ return (can_client_issue_orders() - && !client.conn.playing->ai_controlled && client.conn.playing->is_alive && !client.conn.playing->phase_done && !is_server_busy() @@ -615,7 +623,7 @@ } /************************************************************************** - Update the turn done button state. + Update the turn done button state. **************************************************************************/ void update_turn_done_button_state(void) { @@ -623,11 +631,8 @@ set_turn_done_button_state(turn_done_state); - if (turn_done_state) { - if (waiting_for_end_turn - || (NULL != client.conn.playing - && client.conn.playing->ai_controlled - && !ai_manual_turn_done)) { + if (can_end_turn()) { + if (waiting_for_end_turn) { send_turn_done(); } else { update_turn_done_button(TRUE); Modified: branches/S2_5/client/mapctrl_common.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/mapctrl_common.h?rev=35453&r1=35452&r2=35453&view=diff ============================================================================== --- branches/S2_5/client/mapctrl_common.h (original) +++ branches/S2_5/client/mapctrl_common.h Mon May 8 13:02:51 2017 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 2002 - The Freeciv Project This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -57,6 +57,7 @@ void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y); bool get_turn_done_button_state(void); +bool can_end_turn(void); void scroll_mapview(enum direction8 gui_dir); void action_button_pressed(int canvas_x, int canvas_y, enum quickselect_type qtype); Modified: branches/S2_5/client/options.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/options.c?rev=35453&r1=35452&r2=35453&view=diff ============================================================================== --- branches/S2_5/client/options.c (original) +++ branches/S2_5/client/options.c Mon May 8 13:02:51 2017 @@ -53,6 +53,7 @@ #include "climisc.h" #include "connectdlg_common.h" #include "global_worklist.h" +#include "mapctrl_common.h" #include "mapview_common.h" #include "overview_common.h" #include "packhand_gen.h" @@ -1714,6 +1715,7 @@ /* Some changed callbacks. */ static void reqtree_show_icons_callback(struct option *poption); static void view_option_changed_callback(struct option *poption); +static void manual_turn_done_callback(struct option *poption); static void voteinfo_bar_callback(struct option *poption); static void font_changed_callback(struct option *poption); static void mapimg_changed_callback(struct option *poption); @@ -1980,7 +1982,7 @@ N_("Disable this option if you do not want to " "press the Turn Done button manually when watching " "an AI player."), - COC_INTERFACE, GUI_STUB, TRUE, NULL), + COC_INTERFACE, GUI_STUB, TRUE, manual_turn_done_callback), GEN_BOOL_OPTION(auto_center_on_unit, N_("Auto center on units"), N_("Set this option to have the active unit centered " "automatically when the unit focus changes."), @@ -5528,6 +5530,19 @@ } /**************************************************************************** + Callback for when ai_manual_turn_done is changed. +****************************************************************************/ +static void manual_turn_done_callback(struct option *poption) +{ + update_turn_done_button_state(); + if (!ai_manual_turn_done && client.conn.playing->ai_controlled) { + if (can_end_turn()) { + user_ended_turn(); + } + } +} + +/**************************************************************************** Callback for when any voteinfo bar option is changed. ****************************************************************************/ static void voteinfo_bar_callback(struct option *poption) Modified: branches/S2_5/client/packhand.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/packhand.c?rev=35453&r1=35452&r2=35453&view=diff ============================================================================== --- branches/S2_5/client/packhand.c (original) +++ branches/S2_5/client/packhand.c Mon May 8 13:02:51 2017 @@ -2159,6 +2159,10 @@ if (pplayer == my_player) { if (my_player->ai_controlled) { output_window_append(ftc_client, _("AI mode is now ON.")); + if (!ai_manual_turn_done && !pplayer->phase_done) { + /* End turn immediately */ + user_ended_turn(); + } } else { output_window_append(ftc_client, _("AI mode is now OFF.")); } Modified: branches/S2_5/server/srv_main.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/srv_main.c?rev=35453&r1=35452&r2=35453&view=diff ============================================================================== --- branches/S2_5/server/srv_main.c (original) +++ branches/S2_5/server/srv_main.c Mon May 8 13:02:51 2017 @@ -1783,7 +1783,8 @@ * timeout is set to -1 this function call is skipped entirely and the * server will run rampant. */ players_iterate_alive(pplayer) { - if (pplayer->is_connected && !pplayer->ai_controlled) { + if (pplayer->is_connected + && (!pplayer->ai_controlled || pplayer->phase_done)) { connected = TRUE; break; } @@ -1795,12 +1796,12 @@ phase_players_iterate(pplayer) { if (game.server.turnblock && !pplayer->ai_controlled && pplayer->is_alive - && !pplayer->phase_done) { + && !pplayer->phase_done) { /* If turnblock is enabled check for human players, connected * or not. */ return; } else if (pplayer->is_connected && pplayer->is_alive - && !pplayer->phase_done) { + && !pplayer->phase_done) { /* In all cases, we wait for any connected players. */ return; } _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits