summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordP <dp@dpointer.org>2020-09-06 01:57:42 +0300
committerCharles Pigott <charlespigott@googlemail.com>2020-09-24 17:57:09 +0100
commit3ad4a6e3dae62395be100ef44ea498f301ae98b1 (patch)
tree88cbbb80f519b335ea9363ff581bfb8daddb1ad5
parentbeaa7c7894c1a9ebe72eebb64ebbbc3fc2c8de33 (diff)
downloadopenttd-3ad4a6e3dae62395be100ef44ea498f301ae98b1.tar.xz
Fix 380fd8c: Only check houses for cargo when generating subsidies with towns
-rw-r--r--src/subsidy.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/subsidy.cpp b/src/subsidy.cpp
index 0a1af3c66..ff420455d 100644
--- a/src/subsidy.cpp
+++ b/src/subsidy.cpp
@@ -23,6 +23,7 @@
#include "game/game.hpp"
#include "command_func.h"
#include "string_func.h"
+#include "tile_cmd.h"
#include "table/strings.h"
@@ -328,7 +329,14 @@ bool FindSubsidyTownCargoRoute()
const Town *src_town = Town::GetRandom();
if (src_town->cache.population < SUBSIDY_CARGO_MIN_POPULATION) return false;
- CargoArray town_cargo_produced = GetProductionAroundTiles(src_town->xy, 1, 1, SUBSIDY_TOWN_CARGO_RADIUS);
+ /* Calculate the produced cargo of houses around town center. */
+ CargoArray town_cargo_produced;
+ TileArea ta = TileArea(src_town->xy, 1, 1).Expand(SUBSIDY_TOWN_CARGO_RADIUS);
+ TILE_AREA_LOOP(tile, ta) {
+ if (IsTileType(tile, MP_HOUSE)) {
+ AddProducedCargo(tile, town_cargo_produced);
+ }
+ }
/* Passenger subsidies are not handled here. */
town_cargo_produced[CT_PASSENGERS] = 0;
@@ -431,7 +439,15 @@ bool FindSubsidyCargoDestination(CargoID cid, SourceType src_type, SourceID src)
case ST_TOWN: {
/* Select a random town. */
const Town *dst_town = Town::GetRandom();
- CargoArray town_cargo_accepted = GetAcceptanceAroundTiles(dst_town->xy, 1, 1, SUBSIDY_TOWN_CARGO_RADIUS);
+
+ /* Calculate cargo acceptance of houses around town center. */
+ CargoArray town_cargo_accepted;
+ TileArea ta = TileArea(dst_town->xy, 1, 1).Expand(SUBSIDY_TOWN_CARGO_RADIUS);
+ TILE_AREA_LOOP(tile, ta) {
+ if (IsTileType(tile, MP_HOUSE)) {
+ AddAcceptedCargo(tile, town_cargo_accepted, nullptr);
+ }
+ }
/* Check if the town can accept this cargo. */
if (town_cargo_accepted[cid] < 8) return false;