From cc34221892bb92bcf0ed8c44f7a1d92a12bea7b9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 25 Jun 2023 14:19:16 +0300 Subject: [PATCH 3/3] gtk: Make it possible to offer techs even without embassy Tech trading was not possible unless there was an embassy, as the player didn't know if the other can receive offered tech. It should be possible to offer tech unless one is sure that the other cannot receive it. See osdn #45552 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/diplodlg.c | 8 +++++--- client/gui-gtk-3.0/diplodlg.c | 6 ++++-- client/gui-gtk-3.22/diplodlg.c | 10 +++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/client/gui-gtk-2.0/diplodlg.c b/client/gui-gtk-2.0/diplodlg.c index fe23f6ba5b..92b3b567ff 100644 --- a/client/gui-gtk-2.0/diplodlg.c +++ b/client/gui-gtk-2.0/diplodlg.c @@ -261,7 +261,7 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_object_set_data(G_OBJECT(item), "plr", pgiver); g_signal_connect(item, "activate", - G_CALLBACK(diplomacy_dialog_seamap_callback), pdialog); + G_CALLBACK(diplomacy_dialog_seamap_callback), pdialog); item = gtk_menu_item_new_with_mnemonic(_("_Maps")); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu); @@ -274,6 +274,7 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) const struct research *oresearch = research_get(pother); GtkWidget *advance_item; GList *sorting_list = NULL; + bool embassy = player_has_embassy(pgiver, pother); advance_item = gtk_menu_item_new_with_mnemonic(_("_Advances")); gtk_menu_shell_append(GTK_MENU_SHELL(parent), advance_item); @@ -282,8 +283,9 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) Tech_type_id i = advance_number(padvance); if (research_invention_state(gresearch, i) == TECH_KNOWN - && research_invention_gettable(oresearch, i, - game.info.tech_trade_allow_holes) + && (!embassy /* We don't know what the other could actually receive */ + || research_invention_gettable(oresearch, i, + game.info.tech_trade_allow_holes)) && (research_invention_state(oresearch, i) == TECH_UNKNOWN || research_invention_state(oresearch, i) == TECH_PREREQS_KNOWN)) { diff --git a/client/gui-gtk-3.0/diplodlg.c b/client/gui-gtk-3.0/diplodlg.c index 6ae3363eb8..88cce4bce3 100644 --- a/client/gui-gtk-3.0/diplodlg.c +++ b/client/gui-gtk-3.0/diplodlg.c @@ -274,6 +274,7 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) const struct research *oresearch = research_get(pother); GtkWidget *advance_item; GList *sorting_list = NULL; + bool embassy = player_has_embassy(pgiver, pother); advance_item = gtk_menu_item_new_with_mnemonic(_("_Advances")); gtk_menu_shell_append(GTK_MENU_SHELL(parent), advance_item); @@ -282,8 +283,9 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) Tech_type_id i = advance_number(padvance); if (research_invention_state(gresearch, i) == TECH_KNOWN - && research_invention_gettable(oresearch, i, - game.info.tech_trade_allow_holes) + && (!embassy /* We don't know what the other could actually receive */ + || research_invention_gettable(oresearch, i, + game.info.tech_trade_allow_holes)) && (research_invention_state(oresearch, i) == TECH_UNKNOWN || research_invention_state(oresearch, i) == TECH_PREREQS_KNOWN)) { diff --git a/client/gui-gtk-3.22/diplodlg.c b/client/gui-gtk-3.22/diplodlg.c index 4e706f07a3..d036e9cbf5 100644 --- a/client/gui-gtk-3.22/diplodlg.c +++ b/client/gui-gtk-3.22/diplodlg.c @@ -274,6 +274,7 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) const struct research *oresearch = research_get(pother); GtkWidget *advance_item; GList *sorting_list = NULL; + bool embassy = player_has_embassy(pgiver, pother); advance_item = gtk_menu_item_new_with_mnemonic(_("_Advances")); gtk_menu_shell_append(GTK_MENU_SHELL(parent), advance_item); @@ -282,8 +283,9 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) Tech_type_id i = advance_number(padvance); if (research_invention_state(gresearch, i) == TECH_KNOWN - && research_invention_gettable(oresearch, i, - game.info.tech_trade_allow_holes) + && (!embassy /* We don't know what the other could actually receive */ + || research_invention_gettable(oresearch, i, + game.info.tech_trade_allow_holes)) && (research_invention_state(oresearch, i) == TECH_UNKNOWN || research_invention_state(oresearch, i) == TECH_PREREQS_KNOWN)) { @@ -317,8 +319,7 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) for (list_item = sorting_list; NULL != list_item; list_item = g_list_next(list_item)) { padvance = (const struct advance *) list_item->data; - item = - gtk_menu_item_new_with_label(advance_name_translation(padvance)); + item = gtk_menu_item_new_with_label(advance_name_translation(padvance)); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); g_object_set_data(G_OBJECT(item), "player_from", GINT_TO_POINTER(player_number(pgiver))); @@ -336,7 +337,6 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) gtk_widget_show_all(advance_item); } - /* Trading: cities. */ /**************************************************************** -- 2.40.1