summaryrefslogtreecommitdiff
path: root/src/tree_cmd.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-01-09 17:47:05 +0000
committerglx <glx@openttd.org>2008-01-09 17:47:05 +0000
commit785572ea32e11064375e9de0a789f46c73acac75 (patch)
tree1d841ecd272ea4bb508f03002e59308992257cbf /src/tree_cmd.cpp
parentd133edd026b031ff45916f33bc2bed525e3c2f0b (diff)
downloadopenttd-785572ea32e11064375e9de0a789f46c73acac75.tar.xz
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
Diffstat (limited to 'src/tree_cmd.cpp')
-rw-r--r--src/tree_cmd.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index e73de21cb..aacfe21d2 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -328,16 +328,15 @@ CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
default: break;
}
+ if (_game_mode != GM_EDITOR && IsValidPlayer(_current_player)) {
+ Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
+ if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM);
+ }
+
if (flags & DC_EXEC) {
TreeType treetype;
uint growth;
- if (_game_mode != GM_EDITOR && IsValidPlayer(_current_player)) {
- Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
- if (t != NULL)
- ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM);
- }
-
treetype = (TreeType)p1;
if (treetype == TREE_INVALID) {
treetype = GetRandomTreeType(tile, GB(Random(), 24, 8));
@@ -486,10 +485,9 @@ static CommandCost ClearTile_Trees(TileIndex tile, byte flags)
{
uint num;
- if ((flags & DC_EXEC) && IsValidPlayer(_current_player)) {
+ if (IsValidPlayer(_current_player)) {
Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
- if (t != NULL)
- ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
+ if (t != NULL) ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
}
num = GetTreeCount(tile) + 1;