From 218dfafae4c0e6d1c5b684ac31d91af0650d4f90 Mon Sep 17 00:00:00 2001 From: HyperJeanJean <75644348+HyperJeanJean@users.noreply.github.com> Date: Sat, 30 Aug 2025 18:30:59 +0200 Subject: [PATCH 1/2] Revert "Hide resources that cannot be traded in empire screen" This commit also hid the resources that cities have stopped trading, even though they still appear in the trade advisor and we can still technically export/import it. If we did not open the trade route, this means that a new resource could be added to the trade advisor without knowing where it comes from. --- src/window/empire.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/window/empire.c b/src/window/empire.c index e0a9f93f78..a7f0b5da0a 100644 --- a/src/window/empire.c +++ b/src/window/empire.c @@ -164,9 +164,6 @@ static void draw_trade_city_info(const empire_object *object, const empire_city continue; } int trade_max = trade_route_limit(city->route_id, resource); - if (trade_max <= 0) { - continue; - } draw_trade_resource(resource, trade_max, x_offset + 104 * index + 120, y_offset + 31); int trade_now = trade_route_traded(city->route_id, resource); if (trade_now > trade_max) { @@ -188,9 +185,6 @@ static void draw_trade_city_info(const empire_object *object, const empire_city continue; } int trade_max = trade_route_limit(city->route_id, resource); - if (trade_max <= 0) { - continue; - } draw_trade_resource(resource, trade_max, x_offset + 104 * index + 120, y_offset + 62); int trade_now = trade_route_traded(city->route_id, resource); if (trade_now > trade_max) { @@ -211,9 +205,6 @@ static void draw_trade_city_info(const empire_object *object, const empire_city continue; } int trade_max = trade_route_limit(city->route_id, resource); - if (trade_max <= 0) { - continue; - } draw_trade_resource(resource, trade_max, x_offset + index + 60, y_offset + 33); index += 32; } @@ -223,9 +214,6 @@ static void draw_trade_city_info(const empire_object *object, const empire_city continue; } int trade_max = trade_route_limit(city->route_id, resource); - if (trade_max <= 0) { - continue; - } draw_trade_resource(resource, trade_max, x_offset + index + 110, y_offset + 33); index += 32; } @@ -527,9 +515,6 @@ static void handle_input(const mouse *m, const hotkeys *h) // we only want to handle resource buttons that the selected city trades for (int resource = RESOURCE_MIN; resource < RESOURCE_MAX; resource++) { - if (trade_route_limit(city->route_id, resource) <= 0) { - continue; - } if (empire_object_city_sells_resource(obj->id, resource)) { generic_buttons_handle_mouse(m, x_offset + 120 + 104 * index_sell, y_offset + 31, generic_button_trade_resource + resource - 1, 1, &button_id); @@ -585,7 +570,7 @@ static int get_tooltip_resource(tooltip_context *c) int item_offset = lang_text_get_width(47, 5, FONT_NORMAL_GREEN); for (int r = RESOURCE_MIN; r < RESOURCE_MAX; r++) { - if (empire_object_city_sells_resource(object_id, r) && trade_route_limit(city->route_id, r) > 0) { + if (empire_object_city_sells_resource(object_id, r)) { if (is_mouse_hit(c, x_offset + 60 + item_offset, y_offset + 33, 26)) { return r; } @@ -594,7 +579,7 @@ static int get_tooltip_resource(tooltip_context *c) } item_offset += lang_text_get_width(47, 4, FONT_NORMAL_GREEN); for (int r = RESOURCE_MIN; r <= RESOURCE_MAX; r++) { - if (empire_object_city_buys_resource(object_id, r) && trade_route_limit(city->route_id, r) > 0) { + if (empire_object_city_buys_resource(object_id, r)) { if (is_mouse_hit(c, x_offset + 110 + item_offset, y_offset + 33, 26)) { return r; } From a7e1098dc0317e8074e7c30a179a771353c2a5d9 Mon Sep 17 00:00:00 2001 From: HyperJeanJean <75644348+HyperJeanJean@users.noreply.github.com> Date: Sat, 30 Aug 2025 18:39:31 +0200 Subject: [PATCH 2/2] Hide resources that cannot be traded in empire screen This notably affects Damascus where a city could export 0 marble. With that change, that resource import is now hidden. --- src/window/empire.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/window/empire.c b/src/window/empire.c index a7f0b5da0a..32a5ef6a2f 100644 --- a/src/window/empire.c +++ b/src/window/empire.c @@ -160,7 +160,7 @@ static void draw_trade_city_info(const empire_object *object, const empire_city lang_text_draw(47, 10, x_offset + 44, y_offset + 40, FONT_NORMAL_GREEN); int index = 0; for (int resource = RESOURCE_MIN; resource < RESOURCE_MAX; resource++) { - if (!empire_object_city_sells_resource(object->id, resource)) { + if (!city->sells_resource[resource]) { continue; } int trade_max = trade_route_limit(city->route_id, resource); @@ -181,7 +181,7 @@ static void draw_trade_city_info(const empire_object *object, const empire_city lang_text_draw(47, 9, x_offset + 44, y_offset + 71, FONT_NORMAL_GREEN); index = 0; for (int resource = RESOURCE_MIN; resource < RESOURCE_MAX; resource++) { - if (!empire_object_city_buys_resource(object->id, resource)) { + if (!city->buys_resource[resource]) { continue; } int trade_max = trade_route_limit(city->route_id, resource); @@ -201,7 +201,7 @@ static void draw_trade_city_info(const empire_object *object, const empire_city } else { // trade is closed int index = lang_text_draw(47, 5, x_offset + 50, y_offset + 42, FONT_NORMAL_GREEN); for (int resource = RESOURCE_MIN; resource < RESOURCE_MAX; resource++) { - if (!empire_object_city_sells_resource(object->id, resource)) { + if (!city->sells_resource[resource]) { continue; } int trade_max = trade_route_limit(city->route_id, resource); @@ -210,7 +210,7 @@ static void draw_trade_city_info(const empire_object *object, const empire_city } index += lang_text_draw(47, 4, x_offset + index + 100, y_offset + 42, FONT_NORMAL_GREEN); for (int resource = RESOURCE_MIN; resource < RESOURCE_MAX; resource++) { - if (!empire_object_city_buys_resource(object->id, resource)) { + if (!city->buys_resource[resource]) { continue; } int trade_max = trade_route_limit(city->route_id, resource); @@ -515,11 +515,11 @@ static void handle_input(const mouse *m, const hotkeys *h) // we only want to handle resource buttons that the selected city trades for (int resource = RESOURCE_MIN; resource < RESOURCE_MAX; resource++) { - if (empire_object_city_sells_resource(obj->id, resource)) { + if (city->sells_resource[resource]) { generic_buttons_handle_mouse(m, x_offset + 120 + 104 * index_sell, y_offset + 31, generic_button_trade_resource + resource - 1, 1, &button_id); index_sell++; - } else if (empire_object_city_buys_resource(obj->id, resource)) { + } else if (city->buys_resource[resource]) { generic_buttons_handle_mouse(m, x_offset + 120 + 104 * index_buy, y_offset + 62, generic_button_trade_resource + resource - 1, 1, &button_id); index_buy++; @@ -570,7 +570,7 @@ static int get_tooltip_resource(tooltip_context *c) int item_offset = lang_text_get_width(47, 5, FONT_NORMAL_GREEN); for (int r = RESOURCE_MIN; r < RESOURCE_MAX; r++) { - if (empire_object_city_sells_resource(object_id, r)) { + if (city->sells_resource[r]) { if (is_mouse_hit(c, x_offset + 60 + item_offset, y_offset + 33, 26)) { return r; } @@ -579,7 +579,7 @@ static int get_tooltip_resource(tooltip_context *c) } item_offset += lang_text_get_width(47, 4, FONT_NORMAL_GREEN); for (int r = RESOURCE_MIN; r <= RESOURCE_MAX; r++) { - if (empire_object_city_buys_resource(object_id, r)) { + if (city->buys_resource[r]) { if (is_mouse_hit(c, x_offset + 110 + item_offset, y_offset + 33, 26)) { return r; }