Skip to content

Commit

Permalink
Show "getting" food icon on Granary main panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouaz committed Apr 23, 2024
1 parent bf0c7df commit 81d4acb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/building/granary.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ int building_getting_granary_for_storing(int x, int y, int resource, int road_ne
return min_building_id;
}

int building_granary_amount_can_get_from(building *destination, building *origin)
int building_granary_amount_can_get_from(building *destination, building *origin, int resource)
{
int amount_gettable = 0;
for (resource_type food = RESOURCE_MIN_FOOD; food < RESOURCE_MAX_FOOD; food++) {
Expand All @@ -518,7 +518,7 @@ int building_granary_amount_can_get_from(building *destination, building *origin
return amount_gettable;
}

int building_granary_for_getting(building *src, map_point *dst, int min_amount)
int building_granary_for_getting(building *src, int resource, map_point *dst, int min_amount)
{
const building_storage *s_src = building_storage_get(src->storage_id);
if (s_src->empty_all) {
Expand All @@ -543,7 +543,7 @@ int building_granary_for_getting(building *src, map_point *dst, int min_amount)
continue;
}
}
if (building_granary_amount_can_get_from(b, src) >= min_amount) {
if (building_granary_amount_can_get_from(b, src, resource) >= min_amount) {
int dist = calc_maximum_distance(b->x + 1, b->y + 1, src->x + 1, src->y + 1);
if (dist < min_dist) {
min_dist = dist;
Expand Down
4 changes: 2 additions & 2 deletions src/building/granary.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ int building_granary_for_storing(int x, int y, int resource, int road_network_id

int building_getting_granary_for_storing(int x, int y, int resource, int road_network_id, map_point *dst);

int building_granary_amount_can_get_from(building *destination, building *origin);
int building_granary_amount_can_get_from(building *destination, building *origin, int resource);

int building_granary_for_getting(building *src, map_point *dst, int min_amount);
int building_granary_for_getting(building *src, int resource, map_point *dst, int min_amount);

void building_granary_bless(void);

Expand Down
6 changes: 3 additions & 3 deletions src/figuretype/cartpusher.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static int should_change_destination(const figure *f, int building_id, int x_dst
}
break;
case FIGURE_ACTION_54_WAREHOUSEMAN_GETTING_FOOD:
if (building_granary_amount_can_get_from(current_destination, building_get(f->building_id)) == 0) {
if (building_granary_amount_can_get_from(current_destination, building_get(f->building_id), f->collecting_item_id) == 0) {
return 1;
}
break;
Expand Down Expand Up @@ -529,9 +529,9 @@ static void determine_granaryman_destination(figure *f, int road_network_id, int
building *granary = building_get(f->building_id);
if (!f->resource_id) {
// getting granaryman
dst_building_id = building_granary_for_getting(granary, &dst, 400);
dst_building_id = building_granary_for_getting(granary, f->collecting_item_id, &dst, 400);
if (!dst_building_id) {
dst_building_id = building_granary_for_getting(granary, &dst, 0);
dst_building_id = building_granary_for_getting(granary, f->collecting_item_id, &dst, 0);
}
if (dst_building_id) {
f->loads_sold_or_carrying = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/window/building/distribution.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ void window_building_draw_granary(building_info_context *c)
BLOCK_SIZE * (c->width_blocks - 5), FONT_NORMAL_BROWN);
}
} else {
image_draw(resource_get_data(f->collecting_item_id)->image.icon,
c->x_offset + 32, c->y_offset + y_offset + 60, COLOR_MASK_NONE, SCALE_NONE);
text_draw_multiline(translation_for(TR_WINDOW_BUILDING_DISTRIBUTION_GRANARY_CART_PUSHER_GETTING),
c->x_offset + 64, c->y_offset + y_offset + 63,
BLOCK_SIZE * (c->width_blocks - 5), FONT_NORMAL_BROWN, 0);
Expand Down

0 comments on commit 81d4acb

Please sign in to comment.