diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -186,8 +186,9 @@ static void BuildAirportPickerWndProc(Wi DrawWindowWidgets(w); // strings such as 'Size' and 'Coverage Area' // 'Coverage Area' - int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad) + 4; - if (text_end > w->widget[6].bottom) { + int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad, false); + text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4; + if (text_end != w->widget[6].bottom) { SetWindowDirty(w); ResizeWindowForWidget(w, 6, 0, text_end - w->widget[6].bottom); SetWindowDirty(w); diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -254,8 +254,9 @@ static void BuildDockStationWndProc(Wind SetTileSelectSize(1, 1); } - int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad) + 4; - if (text_end > w->widget[2].bottom) { + int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad, false); + text_end = DrawStationCoverageAreaText(4, text_end + 4, SCT_ALL, rad, true) + 4; + if (text_end != w->widget[2].bottom) { SetWindowDirty(w); ResizeWindowForWidget(w, 2, 0, text_end - w->widget[2].bottom); SetWindowDirty(w); diff --git a/src/lang/english.txt b/src/lang/english.txt --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -18,6 +18,7 @@ STR_0009 STR_EN_ROUTE_FROM :{YELLOW}({SHORTCARGO} en-route from {STATION}) STR_000C_ACCEPTS :{BLACK}Accepts: {WHITE} STR_000D_ACCEPTS :{BLACK}Accepts: {GOLD} +STR_SUPPLIES :{BLACK}Supplies: {GOLD} STR_000E : STR_000F_PASSENGERS :Passengers STR_0010_COAL :Coal diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -763,12 +763,12 @@ void GuiShowTooltipsWithArgs(StringID st } -static int DrawStationCoverageText(const AcceptedCargo accepts, - int str_x, int str_y, StationCoverageType sct) +static int DrawStationCoverageText(const AcceptedCargo cargo, + int str_x, int str_y, StationCoverageType sct, bool supplies) { bool first = true; - char *b = InlineString(_userstring, STR_000D_ACCEPTS); + char *b = InlineString(_userstring, supplies ? STR_SUPPLIES : STR_000D_ACCEPTS); for (CargoID i = 0; i < NUM_CARGO; i++) { if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode() @@ -778,7 +778,7 @@ static int DrawStationCoverageText(const case SCT_ALL: break; default: NOT_REACHED(); } - if (accepts[i] >= 8) { + if (cargo[i] >= (supplies ? 1 : 8)) { if (first) { first = false; } else { @@ -801,13 +801,26 @@ static int DrawStationCoverageText(const return DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); } -int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad) +/** + * Calculates and draws the accepted or supplied cargo around the selected tile(s) + * @param sx x position where the string is to be drawn + * @param sy y position where the string is to be drawn + * @param sct which type of cargo is to be displayed (passengers/non-passengers) + * @param rad radius around selected tile(s) to be searched + * @param supplies if supplied cargos should be drawn, else accepted cargos + * @return Returns the y value below the string that was drawn + */ +int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies) { TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); - AcceptedCargo accepts; + AcceptedCargo cargo; if (tile < MapSize()) { - GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); - return sy + DrawStationCoverageText(accepts, sx, sy, sct); + if (supplies) { + GetProductionAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); + } else { + GetAcceptanceAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); + } + return sy + DrawStationCoverageText(cargo, sx, sy, sct, supplies); } return sy; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -936,8 +936,9 @@ static void StationBuildWndProc(Window * DrawStringCentered(74, 101 + y_offset, STR_3004_PLATFORM_LENGTH, TC_FROMSTRING); DrawStringCentered(74, 141 + y_offset, STR_3066_COVERAGE_AREA_HIGHLIGHT, TC_FROMSTRING); - int text_end = DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad) + 4; - if (text_end > w->widget[BRSW_BACKGROUND].bottom) { + int text_end = DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad, false); + text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4; + if (text_end != w->widget[BRSW_BACKGROUND].bottom) { SetWindowDirty(w); ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom); SetWindowDirty(w); diff --git a/src/road_gui.cpp b/src/road_gui.cpp --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -882,7 +882,10 @@ static void RoadStationPickerWndProc(Win int text_end = DrawStationCoverageAreaText(2, 146, (w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY, - 3) + 4; + 3, false); + text_end = DrawStationCoverageAreaText(2, text_end + 4, + (w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY, + 3, true) + 4; if (text_end > w->widget[BRSW_BACKGROUND].bottom) { SetWindowDirty(w); ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -465,12 +465,13 @@ void GetProductionAroundTiles(AcceptedCa for (int yc = y1; yc != y2; yc++) { for (int xc = x1; xc != x2; xc++) { - if (!(IsInsideBS(xc, x, w) && IsInsideBS(yc, y, h))) { - TileIndex tile = TileXY(xc, yc); - + TileIndex tile = TileXY(xc, yc); + + if (!IsTileType(tile, MP_STATION)) { GetProducedCargoProc *gpc = _tile_type_procs[GetTileType(tile)]->get_produced_cargo_proc; if (gpc != NULL) { - CargoID cargos[2] = { CT_INVALID, CT_INVALID }; + CargoID cargos[256]; // Required for CBID_HOUSE_PRODUCE_CARGO. + memset(cargos, CT_INVALID, 256); gpc(tile, cargos); for (uint i = 0; i < lengthof(cargos); ++i) { diff --git a/src/station_gui.h b/src/station_gui.h --- a/src/station_gui.h +++ b/src/station_gui.h @@ -58,7 +58,7 @@ enum StationCoverageType { SCT_ALL }; -int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad); +int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies); void CheckRedrawStationCoverage(const Window *w); extern bool _station_show_coverage; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -529,6 +529,33 @@ static CommandCost ClearTile_Town(TileIn return cost; } +static void GetProducedCargo_Town(TileIndex tile, CargoID *b) +{ + HouseID house_id = GetHouseType(tile); + const HouseSpec *hs = GetHouseSpecs(house_id); + Town *t = GetTownByTile(tile); + + if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) { + for (uint i = 0; i < 256; i++) { + uint16 callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, 0, house_id, t, tile); + + if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break; + + CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile); + + if (cargo == CT_INVALID) continue; + *(b++) = cargo; + } + } else { + if (hs->population > 0) { + *(b++) = CT_PASSENGERS; + } + if (hs->mail_generation > 0) { + *(b++) = CT_MAIL; + } + } +} + static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac) { const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); @@ -2529,7 +2556,7 @@ extern const TileTypeProcs _tile_type_to AnimateTile_Town, /* animate_tile_proc */ TileLoop_Town, /* tile_loop_clear */ ChangeTileOwner_Town, /* change_tile_owner_clear */ - NULL, /* get_produced_cargo_proc */ + GetProducedCargo_Town, /* get_produced_cargo_proc */ NULL, /* vehicle_enter_tile_proc */ GetFoundation_Town, /* get_foundation_proc */ TerraformTile_Town, /* terraform_tile_proc */