From 0262be38dbd7db82c61e7f5c2640e41eaf68d662 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 27 Dec 2022 23:45:14 +0200 Subject: [PATCH 30/30] gtk: Fix dead 'bg' assignment in create_tech_tree() See osdn #45687 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.22/helpdlg.c | 27 ++++++++++++++++----------- client/gui-gtk-4.0/helpdlg.c | 27 ++++++++++++++++----------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/client/gui-gtk-3.22/helpdlg.c b/client/gui-gtk-3.22/helpdlg.c index e90df5de2d..01687a3245 100644 --- a/client/gui-gtk-3.22/helpdlg.c +++ b/client/gui-gtk-3.22/helpdlg.c @@ -203,6 +203,7 @@ 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) { @@ -226,17 +227,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-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index a4eeca7bb2..455b12e518 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -202,6 +202,7 @@ 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) { @@ -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