Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/window/empire.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ 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) {
Expand All @@ -185,6 +188,9 @@ 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) {
Expand All @@ -205,6 +211,9 @@ 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;
}
Expand All @@ -214,6 +223,9 @@ 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;
}
Expand Down Expand Up @@ -515,6 +527,9 @@ 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);
Expand Down Expand Up @@ -570,7 +585,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 (empire_object_city_sells_resource(object_id, r) && trade_route_limit(city->route_id, r) > 0) {
if (is_mouse_hit(c, x_offset + 60 + item_offset, y_offset + 33, 26)) {
return r;
}
Expand All @@ -579,7 +594,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 (empire_object_city_buys_resource(object_id, r) && trade_route_limit(city->route_id, r) > 0) {
if (is_mouse_hit(c, x_offset + 110 + item_offset, y_offset + 33, 26)) {
return r;
}
Expand Down
Loading