summaryrefslogtreecommitdiff
path: root/src/town_cmd.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2008-01-16 02:53:55 +0000
committerbelugas <belugas@openttd.org>2008-01-16 02:53:55 +0000
commit7a66d5e21da056c77e482ec7f3f779ba41ff7c53 (patch)
tree09c173d8b36aaf573b2aaa27505e66d547cbe189 /src/town_cmd.cpp
parent77a20eae43dd5363d3ee3ab2a51fedb14d2cebba (diff)
downloadopenttd-7a66d5e21da056c77e482ec7f3f779ba41ff7c53.tar.xz
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r--src/town_cmd.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 3bb6b7d9c..a45928222 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1622,18 +1622,22 @@ static bool CheckBuildHouseMode(TileIndex tile, Slope tileh, int mode)
return CmdSucceeded(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
}
-
-uint GetTownRadiusGroup(const Town* t, TileIndex tile)
+/** Returns the bit corresponding to the town zone of the specified tile
+ * @param t Town on which radius is to be found
+ * @param tile TileIndex where radius needs to be found
+ * @return the bit position of the given zone, as defined in HouseZones
+ */
+HouseZonesBits GetTownRadiusGroup(const Town* t, TileIndex tile)
{
uint dist = DistanceSquare(tile, t->xy);
- uint smallest;
+ HouseZonesBits smallest;
uint i;
- if (t->fund_buildings_months && dist <= 25) return 4;
+ if (t->fund_buildings_months && dist <= 25) return HZB_TOWN_CENTRE;
- smallest = 0;
+ smallest = HZB_TOWN_EDGE;
for (i = 0; i != lengthof(t->radius); i++) {
- if (dist < t->radius[i]) smallest = i;
+ if (dist < t->radius[i]) smallest = (HouseZonesBits)i;
}
return smallest;
@@ -1677,9 +1681,10 @@ static void DoBuildTownHouse(Town *t, TileIndex tile)
/* Above snow? */
slope = GetTileSlope(tile, &z);
- /* Get the town zone type */
+ /* Get the town zone type of the current tile, as well as the climate.
+ * This will allow to easily compare with the specs of the new house to build */
{
- uint rad = GetTownRadiusGroup(t, tile);
+ HouseZonesBits rad = GetTownRadiusGroup(t, tile);
int land = _opt.landscape;
if (land == LT_ARCTIC && z >= _opt.snow_line) land = -1;
@@ -1699,6 +1704,7 @@ static void DoBuildTownHouse(Town *t, TileIndex tile)
/* Generate a list of all possible houses that can be built. */
for (i = 0; i < HOUSE_MAX; i++) {
hs = GetHouseSpecs(i);
+ /* Verify that the candidate house spec matches the current tile status */
if ((~hs->building_availability & bitmask) == 0 && hs->enabled) {
if (_loaded_newgrf_features.has_newhouses) {
probability_max += hs->probability;