Skip to content

Commit 7acecd3

Browse files
authored
Merge pull request #767 from HyperJeanJean/julius/advisor-wharfs
Display the number of active wharfs in resource settings
2 parents 8d21585 + 9f4de0e commit 7acecd3

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/city/buildings.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ void city_buildings_add_working_dock(int building_id)
160160
++city_data.building.working_docks;
161161
}
162162

163+
int city_buildings_working_wharfs(void)
164+
{
165+
return city_data.building.working_wharfs;
166+
}
167+
163168
int city_buildings_shipyard_boats_requested(void)
164169
{
165170
return city_data.building.shipyard_boats_requested;

src/city/buildings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void city_buildings_remove_dock(void);
3333
void city_buildings_reset_dock_wharf_counters(void);
3434
void city_buildings_add_working_wharf(int needs_fishing_boat);
3535
void city_buildings_add_working_dock(int building_id);
36+
int city_buildings_working_wharfs(void);
3637
int city_buildings_shipyard_boats_requested(void);
3738
int city_buildings_has_working_dock(void);
3839
int city_buildings_get_working_dock(int index);

src/window/resource_settings.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "resource_settings.h"
22

33
#include "building/count.h"
4+
#include "city/buildings.h"
45
#include "city/resource.h"
56
#include "core/calc.h"
67
#include "core/image_group.h"
@@ -101,7 +102,18 @@ static void draw_foreground(void)
101102
lang_text_draw(54, 13, 98 + width, 172, FONT_NORMAL_BLACK);
102103
}
103104
}
104-
} else if (data.resource != RESOURCE_MEAT || !scenario_building_allowed(BUILDING_WHARF)) {
105+
} else if (data.resource == RESOURCE_MEAT && scenario_building_allowed(BUILDING_WHARF)) {
106+
int active_wharfs = city_buildings_working_wharfs() - city_buildings_shipyard_boats_requested();
107+
if (active_wharfs > 0) {
108+
// some wharfs are working and have boats
109+
int width = text_draw_number(active_wharfs, '@', " ", 98, 172, FONT_NORMAL_BLACK);
110+
if (active_wharfs == 1) {
111+
lang_text_draw(54, 8, 98 + width, 172, FONT_NORMAL_BLACK);
112+
} else {
113+
lang_text_draw(54, 9, 98 + width, 172, FONT_NORMAL_BLACK);
114+
}
115+
}
116+
} else {
105117
// we cannot produce this good
106118
lang_text_draw(54, 25, 98, 172, FONT_NORMAL_BLACK);
107119
}

0 commit comments

Comments
 (0)