From 2f8535b2df7a820d949e0ce522bd340ba84a8cb9 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Tue, 16 Aug 2022 03:33:48 +0300
Subject: [PATCH 38/38] sdl2: Fix diplomacy dialog gold widgets

See osdn #45032

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 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 debd303cf6..6e91f53afe 100644
--- a/client/gui-sdl2/diplodlg.c
+++ b/client/gui-sdl2/diplodlg.c
@@ -385,42 +385,40 @@ static int techs_callback(struct widget *pwidget)
 **************************************************************************/
 static int gold_callback(struct widget *pwidget)
 {
-  if (PRESSED_EVENT(main_data.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