From a915b988c0e9aa86cd75d0bfd54bbd1bfad0e8ed Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 25 Jun 2023 14:07:45 +0300 Subject: [PATCH 20/20] 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-3.0/diplodlg.c | 6 ++++-- client/gui-gtk-3.22/diplodlg.c | 10 +++++----- client/gui-gtk-4.0/diplodlg.c | 6 ++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/client/gui-gtk-3.0/diplodlg.c b/client/gui-gtk-3.0/diplodlg.c index 80e250aa66..860a974a94 100644 --- a/client/gui-gtk-3.0/diplodlg.c +++ b/client/gui-gtk-3.0/diplodlg.c @@ -290,6 +290,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 team_embassy = team_has_embassy(pgiver->team, pother); advance_item = gtk_menu_item_new_with_mnemonic(_("_Advances")); gtk_menu_shell_append(GTK_MENU_SHELL(parent), advance_item); @@ -298,8 +299,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) + && (!team_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 2196a30e87..1cffb31274 100644 --- a/client/gui-gtk-3.22/diplodlg.c +++ b/client/gui-gtk-3.22/diplodlg.c @@ -290,6 +290,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 team_embassy = team_has_embassy(pgiver->team, pother); advance_item = gtk_menu_item_new_with_mnemonic(_("_Advances")); gtk_menu_shell_append(GTK_MENU_SHELL(parent), advance_item); @@ -298,8 +299,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) + && (!team_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)) { @@ -333,8 +335,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))); @@ -352,7 +353,6 @@ static void popup_add_menu(GtkMenuShell *parent, gpointer data) gtk_widget_show_all(advance_item); } - /* Trading: cities. */ /**************************************************************** diff --git a/client/gui-gtk-4.0/diplodlg.c b/client/gui-gtk-4.0/diplodlg.c index 8d4c162f0d..78cd93299d 100644 --- a/client/gui-gtk-4.0/diplodlg.c +++ b/client/gui-gtk-4.0/diplodlg.c @@ -319,6 +319,7 @@ static GMenu *create_clause_menu(GActionGroup *group, const struct research *gresearch = research_get(pgiver); const struct research *oresearch = research_get(pother); GList *sorting_list = NULL; + bool team_embassy = team_has_embassy(pgiver->team, pother); int i; submenu = g_menu_new(); @@ -327,8 +328,9 @@ static GMenu *create_clause_menu(GActionGroup *group, Tech_type_id tech = advance_number(padvance); if (research_invention_state(gresearch, tech) == TECH_KNOWN - && research_invention_gettable(oresearch, tech, - game.info.tech_trade_allow_holes) + && (!team_embassy /* We don't know what the other could actually receive */ + || research_invention_gettable(oresearch, tech, + game.info.tech_trade_allow_holes)) && (research_invention_state(oresearch, tech) == TECH_UNKNOWN || research_invention_state(oresearch, tech) == TECH_PREREQS_KNOWN)) { -- 2.40.1