(svn r9332) [gamebalance] -Codechange: Make TownGetRadiusGroup a method of towns and give it the option to ignore the "fund buildings" option later on
--- a/src/newgrf_house.cpp Mon Mar 19 12:49:55 2007 +0000
+++ b/src/newgrf_house.cpp Mon Mar 19 14:05:08 2007 +0000
@@ -289,7 +289,7 @@
case 0x41: return clamp(_cur_year - GetHouseConstructionYear(tile), 0, 0xFF);
/* Town zone */
- case 0x42: return GetTownRadiusGroup(town, tile);
+ case 0x42: return town->GetRadiusGroup(tile);
/* Terrain type */
case 0x43: return GetTerrainType(tile);
--- a/src/road_cmd.cpp Mon Mar 19 12:49:55 2007 +0000
+++ b/src/road_cmd.cpp Mon Mar 19 14:05:08 2007 +0000
@@ -885,7 +885,7 @@
int grp = 0;
if (t != NULL) {
- grp = GetTownRadiusGroup(t, tile);
+ grp = t->GetRadiusGroup(tile);
// Show an animation to indicate road work
if (t->road_build_months != 0 &&
--- a/src/town.h Mon Mar 19 12:49:55 2007 +0000
+++ b/src/town.h Mon Mar 19 14:05:08 2007 +0000
@@ -202,6 +202,28 @@
DEBUG(eco, 5, "Modifying EAL for town at 0x%x by %f to %f", xy, (double)activity_change, (double)this->GetActivity());
}
+
+ /**
+ * Gets the so ralled "town radius group" of a tile which is a
+ * representation of how close a tile is relative to the town
+ * center depending on the size of the town
+ * @param tile The tile which the town radius is to be computed for
+ * @param ignore_funding When a player opted to fund buildings, select the
+ * appropriate group unless this flag is set.
+ * @return The town radius group
+ */
+ uint GetRadiusGroup(TileIndex tile, bool ignore_funding = false) const
+ {
+ uint dist = DistanceSquare(tile, xy);
+ uint smallest = 0;
+
+ if (!ignore_funding && fund_buildings_months > 0 && dist < 25) return 4;
+
+ for (uint i = 0; i != lengthof(radius); i++) if (dist < radius[i]) smallest = i;
+
+ return smallest;
+ }
+
};
struct HouseSpec {
--- a/src/town_cmd.cpp Mon Mar 19 12:49:55 2007 +0000
+++ b/src/town_cmd.cpp Mon Mar 19 14:05:08 2007 +0000
@@ -1179,22 +1179,6 @@
}
-uint GetTownRadiusGroup(const Town* t, TileIndex tile)
-{
- uint dist = DistanceSquare(tile, t->xy);
- uint smallest;
- uint i;
-
- if (t->fund_buildings_months && dist <= 25) return 4;
-
- smallest = 0;
- for (i = 0; i != lengthof(t->radius); i++) {
- if (dist < t->radius[i]) smallest = i;
- }
-
- return smallest;
-}
-
static bool CheckFree2x2Area(TileIndex tile)
{
int i;
@@ -1235,7 +1219,7 @@
// Get the town zone type
{
- uint rad = GetTownRadiusGroup(t, tile);
+ uint rad = t->GetRadiusGroup(tile);
int land = _opt.landscape;
if (land == LT_HILLY && z >= _opt.snow_line) land = -1;