From ddd2837f738d1675b2db03a09068c023ae6d7de2 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 16 Aug 2022 03:55:55 +0300 Subject: [PATCH 17/17] sdl2: Fix diplomacy dialog gold widgets See osdn #45032 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/diplodlg.c | 56 ++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/client/gui-sdl2/diplodlg.c b/client/gui-sdl2/diplodlg.c index 533eb91e81..94a87a7aac 100644 --- a/client/gui-sdl2/diplodlg.c +++ b/client/gui-sdl2/diplodlg.c @@ -385,43 +385,41 @@ static int techs_callback(struct widget *pWidget) **************************************************************************/ static int gold_callback(struct widget *pWidget) { - if (PRESSED_EVENT(Main.event)) { - int amount; - struct diplomacy_dialog *pdialog; - - if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) { - pdialog = get_diplomacy_dialog(pWidget->data.cont->id0); - } + int amount; + struct diplomacy_dialog *pdialog; - if (pWidget->string_utf8->text != NULL) { - sscanf(pWidget->string_utf8->text, "%d", &amount); + if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) { + pdialog = get_diplomacy_dialog(pWidget->data.cont->id0); + } - if (amount > pWidget->data.cont->value) { - /* max player gold */ - amount = pWidget->data.cont->value; - } + if (pWidget->string_utf8->text != NULL) { + sscanf(pWidget->string_utf8->text, "%d", &amount); - } else { - amount = 0; + if (amount > pWidget->data.cont->value) { + /* max player gold */ + amount = pWidget->data.cont->value; } - if (amount > 0) { - dsend_packet_diplomacy_create_clause_req(&client.conn, - player_number(pdialog->treaty.plr1), - pWidget->data.cont->id0, - CLAUSE_GOLD, amount); + } else { + amount = 0; + } + + if (amount > 0) { + dsend_packet_diplomacy_create_clause_req(&client.conn, + player_number(pdialog->treaty.plr1), + pWidget->data.cont->id0, + CLAUSE_GOLD, amount); - } else { - output_window_append(ftc_client, - _("Invalid amount of gold specified.")); - } + } else { + output_window_append(ftc_client, + _("Invalid amount of gold specified.")); + } - if (amount || pWidget->string_utf8->text == NULL) { - copy_chars_to_utf8_str(pWidget->string_utf8, "0"); - widget_redraw(pWidget); - widget_flush(pWidget); + if (amount || pWidget->string_utf8->text == NULL) { + copy_chars_to_utf8_str(pWidget->string_utf8, "0"); + widget_redraw(pWidget); + widget_flush(pWidget); } - } return -1; } -- 2.35.1