equal
deleted
inserted
replaced
1 #include "stdafx.h" |
1 #include "stdafx.h" |
2 #include "ttd.h" |
2 #include "ttd.h" |
3 #include "table/strings.h" |
3 #include "table/strings.h" |
|
4 #include "table/tree_land.h" |
4 #include "map.h" |
5 #include "map.h" |
5 #include "tile.h" |
6 #include "tile.h" |
6 #include "viewport.h" |
7 #include "viewport.h" |
7 #include "command.h" |
8 #include "command.h" |
8 #include "town.h" |
9 #include "town.h" |
140 do { |
141 do { |
141 PlaceTreesRandomly(); |
142 PlaceTreesRandomly(); |
142 } while (--i); |
143 } while (--i); |
143 } |
144 } |
144 |
145 |
145 /* Plant a tree |
146 /** Plant a tree. |
146 * p1 = tree type, -1 means random. |
147 * @param x,y start tile of area-drag of tree plantation |
147 * p2 = end tile |
148 * @param p1 tree type, -1 means random. |
|
149 * @param p2 end tile of area-drag |
148 */ |
150 */ |
149 |
|
150 int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) |
151 int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) |
151 { |
152 { |
152 int32 cost; |
153 int32 cost; |
153 int sx; |
154 int sx; |
154 int sy; |
155 int sy; |
155 int x; |
156 int x; |
156 int y; |
157 int y; |
157 |
158 |
158 if (p2 >= MapSize()) return CMD_ERROR; |
159 if (p2 > MapSize()) return CMD_ERROR; |
|
160 /* Check the tree type. It can be random or some valid value within the current climate */ |
|
161 if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_opt.landscape] >= _tree_count_by_landscape[_opt.landscape]) return CMD_ERROR; |
159 |
162 |
160 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
163 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
161 |
164 |
162 // make sure sx,sy are smaller than ex,ey |
165 // make sure sx,sy are smaller than ex,ey |
163 sx = TileX(p2) * 16; |
166 sx = TileX(p2) * 16; |
252 break; |
255 break; |
253 } |
256 } |
254 } |
257 } |
255 } |
258 } |
256 |
259 |
257 if (cost == 0) return CMD_ERROR; |
260 return (cost == 0) ? CMD_ERROR : cost; |
258 return cost; |
|
259 } |
261 } |
260 |
262 |
261 typedef struct TreeListEnt { |
263 typedef struct TreeListEnt { |
262 uint32 image; |
264 uint32 image; |
263 byte x,y; |
265 byte x,y; |
264 } TreeListEnt; |
266 } TreeListEnt; |
265 |
|
266 |
|
267 #include "table/tree_land.h" |
|
268 |
|
269 |
267 |
270 static void DrawTile_Trees(TileInfo *ti) |
268 static void DrawTile_Trees(TileInfo *ti) |
271 { |
269 { |
272 uint16 m2; |
270 uint16 m2; |
273 const uint32 *s; |
271 const uint32 *s; |