From ed42060beb07dc9f4f21d433fb92d7a4ed793b40 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 27 Dec 2022 23:45:14 +0200 Subject: [PATCH 16/16] gtk: Fix dead 'bg' assignment in create_tech_tree() See osdn #45687 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/helpdlg.c | 29 +++++++++++++++++------------ client/gui-gtk-3.0/helpdlg.c | 29 +++++++++++++++++------------ client/gui-gtk-3.22/helpdlg.c | 29 +++++++++++++++++------------ 3 files changed, 51 insertions(+), 36 deletions(-) diff --git a/client/gui-gtk-2.0/helpdlg.c b/client/gui-gtk-2.0/helpdlg.c index 4121441a93..b045618fa4 100644 --- a/client/gui-gtk-2.0/helpdlg.c +++ b/client/gui-gtk-2.0/helpdlg.c @@ -202,9 +202,10 @@ static void create_tech_tree(int tech, int levels, GtkTreeIter *parent) bool original; GtkTreeIter l; GValue value = { 0, }; + enum tech_state state; if (advance_required(tech, AR_ONE) == A_LAST - && advance_required(tech, AR_TWO) == A_LAST) { + && advance_required(tech, AR_TWO) == A_LAST) { bg = COLOR_REQTREE_UNKNOWN; gtk_tree_store_append(tstore, &l, parent); @@ -225,17 +226,21 @@ static void create_tech_tree(int tech, int levels, GtkTreeIter *parent) presearch = research_get(client_player()); - bg = COLOR_REQTREE_BACKGROUND; - switch (research_invention_state(presearch, tech)) { - case TECH_UNKNOWN: - bg = COLOR_REQTREE_UNKNOWN; - break; - case TECH_KNOWN: - bg = COLOR_REQTREE_KNOWN; - break; - case TECH_PREREQS_KNOWN: - bg = COLOR_REQTREE_PREREQS_KNOWN; - break; + state = research_invention_state(presearch, tech); + if (tech_state_is_valid(state)) { + switch (state) { + case TECH_UNKNOWN: + bg = COLOR_REQTREE_UNKNOWN; + break; + case TECH_KNOWN: + bg = COLOR_REQTREE_KNOWN; + break; + case TECH_PREREQS_KNOWN: + bg = COLOR_REQTREE_PREREQS_KNOWN; + break; + } + } else { + bg = COLOR_REQTREE_BACKGROUND; } turns_to_tech = research_goal_unknown_techs(presearch, tech); diff --git a/client/gui-gtk-3.0/helpdlg.c b/client/gui-gtk-3.0/helpdlg.c index 0570c036ef..0dcd2af55e 100644 --- a/client/gui-gtk-3.0/helpdlg.c +++ b/client/gui-gtk-3.0/helpdlg.c @@ -202,9 +202,10 @@ static void create_tech_tree(int tech, int levels, GtkTreeIter *parent) bool original; GtkTreeIter l; GValue value = { 0, }; + enum tech_state state; if (advance_required(tech, AR_ONE) == A_LAST - && advance_required(tech, AR_TWO) == A_LAST) { + && advance_required(tech, AR_TWO) == A_LAST) { bg = COLOR_REQTREE_UNKNOWN; gtk_tree_store_append(tstore, &l, parent); @@ -225,17 +226,21 @@ static void create_tech_tree(int tech, int levels, GtkTreeIter *parent) presearch = research_get(client_player()); - bg = COLOR_REQTREE_BACKGROUND; - switch (research_invention_state(presearch, tech)) { - case TECH_UNKNOWN: - bg = COLOR_REQTREE_UNKNOWN; - break; - case TECH_KNOWN: - bg = COLOR_REQTREE_KNOWN; - break; - case TECH_PREREQS_KNOWN: - bg = COLOR_REQTREE_PREREQS_KNOWN; - break; + state = research_invention_state(presearch, tech); + if (tech_state_is_valid(state)) { + switch (state) { + case TECH_UNKNOWN: + bg = COLOR_REQTREE_UNKNOWN; + break; + case TECH_KNOWN: + bg = COLOR_REQTREE_KNOWN; + break; + case TECH_PREREQS_KNOWN: + bg = COLOR_REQTREE_PREREQS_KNOWN; + break; + } + } else { + bg = COLOR_REQTREE_BACKGROUND; } turns_to_tech = research_goal_unknown_techs(presearch, tech); diff --git a/client/gui-gtk-3.22/helpdlg.c b/client/gui-gtk-3.22/helpdlg.c index 5bc981fcce..ee94f8c55a 100644 --- a/client/gui-gtk-3.22/helpdlg.c +++ b/client/gui-gtk-3.22/helpdlg.c @@ -202,9 +202,10 @@ static void create_tech_tree(int tech, int levels, GtkTreeIter *parent) bool original; GtkTreeIter l; GValue value = { 0, }; + enum tech_state state; if (advance_required(tech, AR_ONE) == A_LAST - && advance_required(tech, AR_TWO) == A_LAST) { + && advance_required(tech, AR_TWO) == A_LAST) { bg = COLOR_REQTREE_UNKNOWN; gtk_tree_store_append(tstore, &l, parent); @@ -225,17 +226,21 @@ static void create_tech_tree(int tech, int levels, GtkTreeIter *parent) presearch = research_get(client_player()); - bg = COLOR_REQTREE_BACKGROUND; - switch (research_invention_state(presearch, tech)) { - case TECH_UNKNOWN: - bg = COLOR_REQTREE_UNKNOWN; - break; - case TECH_KNOWN: - bg = COLOR_REQTREE_KNOWN; - break; - case TECH_PREREQS_KNOWN: - bg = COLOR_REQTREE_PREREQS_KNOWN; - break; + state = research_invention_state(presearch, tech); + if (tech_state_is_valid(state)) { + switch (state) { + case TECH_UNKNOWN: + bg = COLOR_REQTREE_UNKNOWN; + break; + case TECH_KNOWN: + bg = COLOR_REQTREE_KNOWN; + break; + case TECH_PREREQS_KNOWN: + bg = COLOR_REQTREE_PREREQS_KNOWN; + break; + } + } else { + bg = COLOR_REQTREE_BACKGROUND; } turns_to_tech = research_goal_unknown_techs(presearch, tech); -- 2.35.1