From fb1958c674949ef0f189148456633ee1a01828f8 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 22 Sep 2024 02:45:50 +0300 Subject: [PATCH 54/54] Protocol: Communicate about city worklist cancel behavior See osdn #48217 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.22/citydlg.c | 3 ++- client/gui-gtk-4.0/citydlg.c | 3 ++- client/gui-gtk-5.0/citydlg.c | 3 ++- client/gui-qt/citydlg.cpp | 3 ++- client/gui-sdl2/citydlg.c | 8 +++++--- client/gui-sdl3/citydlg.c | 8 +++++--- client/packhand.c | 1 + common/networking/packets.def | 8 +++++--- server/cityhand.c | 4 +++- server/citytools.c | 1 + 10 files changed, 28 insertions(+), 14 deletions(-) diff --git a/client/gui-gtk-3.22/citydlg.c b/client/gui-gtk-3.22/citydlg.c index e44059b661..30429c0727 100644 --- a/client/gui-gtk-3.22/citydlg.c +++ b/client/gui-gtk-3.22/citydlg.c @@ -3412,7 +3412,8 @@ static void cityopt_callback(GtkWidget * w, gpointer data) BV_SET(new_options, CITYO_GOLD_SPECIALISTS); } - dsend_packet_city_options_req(&client.conn, pcity->id,new_options); + dsend_packet_city_options_req(&client.conn, pcity->id, new_options, + pcity->wlcb); } } diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index 9d152770bc..bdcded98e2 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -3528,7 +3528,8 @@ static void cityopt_callback(GtkWidget *w, gpointer data) BV_SET(new_options, CITYO_GOLD_SPECIALISTS); } - dsend_packet_city_options_req(&client.conn, pcity->id,new_options); + dsend_packet_city_options_req(&client.conn, pcity->id, new_options, + pcity->wlcb); } } diff --git a/client/gui-gtk-5.0/citydlg.c b/client/gui-gtk-5.0/citydlg.c index 865e524f9b..7eeeb8a9b2 100644 --- a/client/gui-gtk-5.0/citydlg.c +++ b/client/gui-gtk-5.0/citydlg.c @@ -3529,7 +3529,8 @@ static void cityopt_callback(GtkWidget *w, gpointer data) BV_SET(new_options, CITYO_GOLD_SPECIALISTS); } - dsend_packet_city_options_req(&client.conn, pcity->id,new_options); + dsend_packet_city_options_req(&client.conn, pcity->id, new_options, + pcity->wlcb); } } diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index 4cdd396925..120a86cc4d 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -2760,7 +2760,8 @@ void city_dialog::disband_state_changed(bool allow_disband) } if (!client_is_observer()) { - dsend_packet_city_options_req(&client.conn, dlgcity->id, new_options); + dsend_packet_city_options_req(&client.conn, dlgcity->id, + new_options, dlgcity->wlcb); } } diff --git a/client/gui-sdl2/citydlg.c b/client/gui-sdl2/citydlg.c index d0f50c9567..53484c355c 100644 --- a/client/gui-sdl2/citydlg.c +++ b/client/gui-sdl2/citydlg.c @@ -963,7 +963,8 @@ static int misc_panel_city_dlg_callback(struct widget *pwidget) break; } - dsend_packet_city_options_req(&client.conn, pcity_dlg->pcity->id, new_options); + dsend_packet_city_options_req(&client.conn, pcity_dlg->pcity->id, + new_options, pcity_dlg->pcity->wlcb); } return -1; @@ -986,8 +987,9 @@ static void create_city_options_widget_list(struct city *pcity) pstr->fgcol = *get_theme_color(COLOR_THEME_CHECKBOX_LABEL_TEXT); buf = - create_textcheckbox(pwindow->dst, BV_ISSET(pcity->city_options, CITYO_DISBAND), pstr, - WF_RESTORE_BACKGROUND); + create_textcheckbox(pwindow->dst, + BV_ISSET(pcity->city_options, CITYO_DISBAND), + pstr, WF_RESTORE_BACKGROUND); set_wstate(buf, FC_WS_NORMAL); buf->action = misc_panel_city_dlg_callback; add_to_gui_list(MAX_ID - 0x10, buf); diff --git a/client/gui-sdl3/citydlg.c b/client/gui-sdl3/citydlg.c index 10fbf334de..5676608ce2 100644 --- a/client/gui-sdl3/citydlg.c +++ b/client/gui-sdl3/citydlg.c @@ -959,7 +959,8 @@ static int misc_panel_city_dlg_callback(struct widget *pwidget) break; } - dsend_packet_city_options_req(&client.conn, pcity_dlg->pcity->id, new_options); + dsend_packet_city_options_req(&client.conn, pcity_dlg->pcity->id, + new_options, pcity_dlg->pcity->wlcb); } return -1; @@ -982,8 +983,9 @@ static void create_city_options_widget_list(struct city *pcity) pstr->fgcol = *get_theme_color(COLOR_THEME_CHECKBOX_LABEL_TEXT); buf = - create_textcheckbox(pwindow->dst, BV_ISSET(pcity->city_options, CITYO_DISBAND), pstr, - WF_RESTORE_BACKGROUND); + create_textcheckbox(pwindow->dst, + BV_ISSET(pcity->city_options, CITYO_DISBAND), + pstr, WF_RESTORE_BACKGROUND); set_wstate(buf, FC_WS_NORMAL); buf->action = misc_panel_city_dlg_callback; add_to_gui_list(MAX_ID - 0x10, buf); diff --git a/client/packhand.c b/client/packhand.c index 65ee7a1cc0..bc6c1bc729 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -798,6 +798,7 @@ void handle_city_info(const struct packet_city_info *packet) pcity->city_radius_sq = packet->city_radius_sq; pcity->city_options = packet->city_options; + pcity->wlcb = packet->wl_cb; if (pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE] || pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE] diff --git a/common/networking/packets.def b/common/networking/packets.def index 76d638cf65..78ef2dda0c 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -270,8 +270,9 @@ type CAPITAL = uint8(enum capital_type) type WONDER_VISIB = uint8(enum wonder_visib_type) type TRANSP_DEF_TYPE = uint8(enum transp_def_type) type AI_LEVEL = uint8(enum ai_level) -type COUNTER_TARGET = uint8(enum counter_target) -type COUNTER_BEHAVIOUR = uint8(enum counter_behaviour) +type COUNTER_TARGET = uint8(enum counter_target) +type COUNTER_BEHAVIOUR = uint8(enum counter_behaviour) +type CITY_WL_CB = uint8(enum city_wl_cancel_behavior) # typedefs for bit vectors type BV_ACTIONS = bitvector(bv_actions) @@ -780,6 +781,7 @@ PACKET_CITY_INFO = 31; sc, lsend, is-game-info, force, reset(PACKET_CITY_SHORT_I BV_IMPRS improvements; BV_CITY_OPTIONS city_options; + CITY_WL_CB wl_cb; ESTRING name[MAX_LEN_CITYNAME]; end @@ -869,6 +871,7 @@ end PACKET_CITY_OPTIONS_REQ = 41; cs, dsend, handle-via-fields CITY city_id; BV_CITY_OPTIONS options; + CITY_WL_CB wl_cb; end PACKET_CITY_REFRESH = 42; cs, dsend, handle-via-fields @@ -2310,7 +2313,6 @@ PACKET_EDIT_CITY = 213; cs, handle-per-conn SINT32 built[B_LAST]; diff UINT8 production_kind; UINT8 production_value; - BV_CITY_OPTIONS city_options; end PACKET_EDIT_PLAYER_CREATE = 214; cs, handle-per-conn, dsend, handle-via-fields diff --git a/server/cityhand.c b/server/cityhand.c index c828ca6045..df7fe4c92d 100644 --- a/server/cityhand.c +++ b/server/cityhand.c @@ -507,7 +507,8 @@ void handle_city_rename(struct player *pplayer, int city_id, given city be changed. **************************************************************************/ void handle_city_options_req(struct player *pplayer, int city_id, - bv_city_options options) + bv_city_options options, + enum city_wl_cancel_behavior wlcb) { struct city *pcity = player_city_by_number(pplayer, city_id); @@ -516,6 +517,7 @@ void handle_city_options_req(struct player *pplayer, int city_id, } pcity->city_options = options; + pcity->wlcb = wlcb; send_city_info(pplayer, pcity); } diff --git a/server/citytools.c b/server/citytools.c index f7eb1b688a..d36887eda0 100644 --- a/server/citytools.c +++ b/server/citytools.c @@ -2656,6 +2656,7 @@ void package_city(struct city *pcity, struct packet_city_info *packet, packet->pollution = pcity->pollution; packet->illness_trade = pcity->illness_trade; packet->city_options = pcity->city_options; + packet->wl_cb = pcity->wlcb; packet->production_kind = pcity->production.kind; packet->production_value = universal_number(&pcity->production); -- 2.45.2