diff options
author | Darkvater <darkvater@openttd.org> | 2005-05-09 22:33:00 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2005-05-09 22:33:00 +0000 |
commit | ab954a934a20e21dc9e2672c380d8a7ab8531d33 (patch) | |
tree | adf0a3467d8519f1ef67e90a0a06731ea8c4dc1a /tree_cmd.c | |
parent | 4ad80ae872fe2eea09d431a1d9849936ac37223b (diff) | |
download | openttd-ab954a934a20e21dc9e2672c380d8a7ab8531d33.tar.xz |
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
- CodeChange: changed the airport gui airport-type checking. Added function GetValidAirports() that returns bitmasked availibility, is also used for checking.
- CodeChange: to check tree-planting, 2 const arrays have been moved to table/tree_land.h (type and count)
- CodeChange: added IsTownIndex() in following of IsStationIndex(), etc.
- Fix (regression): road tunnels did not work anymore, forgot that their type was 0x200 (documented now)
Diffstat (limited to 'tree_cmd.c')
-rw-r--r-- | tree_cmd.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/tree_cmd.c b/tree_cmd.c index a29663d6f..921878ece 100644 --- a/tree_cmd.c +++ b/tree_cmd.c @@ -1,6 +1,7 @@ #include "stdafx.h" #include "ttd.h" #include "table/strings.h" +#include "table/tree_land.h" #include "map.h" #include "tile.h" #include "viewport.h" @@ -142,11 +143,11 @@ void GenerateTrees(void) } while (--i); } -/* Plant a tree - * p1 = tree type, -1 means random. - * p2 = end tile +/** Plant a tree. + * @param x,y start tile of area-drag of tree plantation + * @param p1 tree type, -1 means random. + * @param p2 end tile of area-drag */ - int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) { int32 cost; @@ -155,7 +156,9 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) int x; int y; - if (p2 >= MapSize()) return CMD_ERROR; + if (p2 > MapSize()) return CMD_ERROR; + /* Check the tree type. It can be random or some valid value within the current climate */ + if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_opt.landscape] >= _tree_count_by_landscape[_opt.landscape]) return CMD_ERROR; SET_EXPENSES_TYPE(EXPENSES_OTHER); @@ -254,8 +257,7 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) } } - if (cost == 0) return CMD_ERROR; - return cost; + return (cost == 0) ? CMD_ERROR : cost; } typedef struct TreeListEnt { @@ -263,10 +265,6 @@ typedef struct TreeListEnt { byte x,y; } TreeListEnt; - -#include "table/tree_land.h" - - static void DrawTile_Trees(TileInfo *ti) { uint16 m2; |