(svn r9414) [gamebalance] -Feature: The cost of purchasing land off a town depends on the wealth level of a town.
[gamebalance] -Fix (r9386): Town::GetRadiusGroupForTile returned the wrong towns
--- a/src/clear_cmd.cpp Thu Mar 22 11:11:36 2007 +0000
+++ b/src/clear_cmd.cpp Fri Mar 23 12:03:41 2007 +0000
@@ -438,9 +438,7 @@
MarkTileDirtyByTile(tile);
}
- uint rad;
- Town::GetRadiusGroupForTile(tile, rad);
- return cost + (_price.purchase_land * 10) * rad * rad;
+ return cost + Town::GetTilePrice(tile);
}
@@ -488,9 +486,7 @@
if (flags & DC_EXEC) DoClearSquare(tile);
- uint rad;
- Town::GetRadiusGroupForTile(tile, rad);
- return -(_price.purchase_land * 10) * rad * rad;
+ return -Town::GetTilePrice(tile);
}
--- a/src/town.cpp Thu Mar 22 11:11:36 2007 +0000
+++ b/src/town.cpp Fri Mar 23 12:03:41 2007 +0000
@@ -9,6 +9,18 @@
#include "town_map.h"
/* static */
+int64 Town::GetTilePrice(TileIndex tile)
+{
+ uint rad;
+ const Town *t = GetRadiusGroupForTile(tile, rad);
+ FixedT<int64, 16> price = t->GetActivity();
+ DEBUG(eco, 6, "Getting price for tile 0x%x at %f (authority at 0x%x)", tile, (double)price, t->xy);
+ price *= _price.purchase_land * rad * rad * 10;
+
+ return price;
+}
+
+/* static */
const Town *Town::GetRadiusGroupForTile(TileIndex tile, uint &group)
{
const Town *t;
@@ -27,11 +39,19 @@
return t;
}
+ uint best_dist = UINT_MAX;
FOR_ALL_TOWNS(t) {
if (1 + t->GetRadiusGroup(tile, true) > group) {
group = t->GetRadiusGroup(tile, true) + 1;
DEBUG(eco, 7, "Higher group (%d) found for town at 0x%x", group, t->xy);
best_town = t;
+ if (best_dist > DistanceSquare(tile, t->xy)) best_dist = DistanceSquare(tile, t->xy);
+ } else if (1 + t->GetRadiusGroup(tile, true) == group) {
+ DEBUG(eco, 7, "Same group found town at 0x%x is closer", t->xy);
+ if (best_dist > DistanceSquare(tile, t->xy)) {
+ best_dist = DistanceSquare(tile, t->xy);
+ best_town = t;
+ }
}
}
--- a/src/town.h Thu Mar 22 11:11:36 2007 +0000
+++ b/src/town.h Fri Mar 23 12:03:41 2007 +0000
@@ -170,6 +170,15 @@
}
/**
+ * Computes the cost of a single tile should the player
+ * want to purcase or sell it.
+ * @param t The tile which is to be purcahsed
+ * @return The cost for the purcahse
+ * @todo Incorporate the factor of 10 in the base price
+ */
+ static int64 GetTilePrice(TileIndex tile);
+
+ /**
* Adjusts the activity level of a town dependent
* on player performance. Towns with a high share of
* transported passengers are increasing the EAL, those