author | rubidium |
Mon, 24 Sep 2007 20:56:33 +0000 | |
changeset 8123 | 2f8dfb527d7c |
parent 8097 | 68eefbb4ff46 |
child 8206 | 573a2d359695 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6683
diff
changeset
|
3 |
/** @file tree_cmd.cpp */ |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6683
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1784
diff
changeset
|
6 |
#include "openttd.h" |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
7 |
#include "bridge_map.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3079
diff
changeset
|
8 |
#include "clear_map.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
9 |
#include "table/strings.h" |
2148
47ba4a1b1c3b
(svn r2658) -Codechange: Use MAKE_TRANSPARENT to display a transparented sprite
celestar
parents:
2118
diff
changeset
|
10 |
#include "table/sprites.h" |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1370
diff
changeset
|
11 |
#include "table/tree_land.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2153
diff
changeset
|
12 |
#include "functions.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
541
diff
changeset
|
13 |
#include "map.h" |
6669
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6574
diff
changeset
|
14 |
#include "landscape.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1202
diff
changeset
|
15 |
#include "tile.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3079
diff
changeset
|
16 |
#include "tree_map.h" |
0 | 17 |
#include "viewport.h" |
18 |
#include "command.h" |
|
19 |
#include "town.h" |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
20 |
#include "sound.h" |
2153
91e89aa8c299
(svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents:
2148
diff
changeset
|
21 |
#include "variables.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
22 |
#include "genworld.h" |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
23 |
|
8093
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
24 |
/** |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
25 |
* List of tree placer algorithm. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
26 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
27 |
* This enumeration defines all possible tree placer algorithm in the game. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
28 |
*/ |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
29 |
enum TreePlacer { |
8093
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
30 |
TP_NONE, ///< No tree placer algorithm |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
31 |
TP_ORIGINAL, ///< The original algorithm |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
32 |
TP_IMPROVED, ///< A 'improved' algorithm |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
33 |
}; |
0 | 34 |
|
8093
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
35 |
/** |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
36 |
* Get a random TreeType for the given tile based on a given seed |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
37 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
38 |
* This function returns a random TreeType which can be placed on the given tile. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
39 |
* The seed for randomness must be less or equal 256, use #GB on the value of Random() |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
40 |
* to get such a value. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
41 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
42 |
* @param tile The tile to get a random TreeType from |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
43 |
* @param seed The seed for randomness, must be less or equal 256 |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
44 |
* @return The random tree type |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
45 |
*/ |
2981 | 46 |
static TreeType GetRandomTreeType(TileIndex tile, uint seed) |
0 | 47 |
{ |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
48 |
switch (_opt.landscape) { |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
49 |
case LT_TEMPERATE: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
50 |
return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE); |
0 | 51 |
|
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
52 |
case LT_ARCTIC: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
53 |
return (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC); |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
54 |
|
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
55 |
case LT_TROPIC: |
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3271
diff
changeset
|
56 |
switch (GetTropicZone(tile)) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
57 |
case TROPICZONE_INVALID: return (TreeType)(seed * TREE_COUNT_SUB_TROPICAL / 256 + TREE_SUB_TROPICAL); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
58 |
case TROPICZONE_DESERT: return (TreeType)((seed > 12) ? TREE_INVALID : TREE_CACTUS); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
59 |
default: return (TreeType)(seed * TREE_COUNT_RAINFOREST / 256 + TREE_RAINFOREST); |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
60 |
} |
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
61 |
|
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
62 |
default: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
63 |
return (TreeType)(seed * TREE_COUNT_TOYLAND / 256 + TREE_TOYLAND); |
0 | 64 |
} |
65 |
} |
|
66 |
||
8093
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
67 |
/** |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
68 |
* Make a random tree tile of the given tile |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
69 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
70 |
* Create a new tree-tile for the given tile. The second parameter is used for |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
71 |
* randomness like type and number of trees. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
72 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
73 |
* @param tile The tile to make a tree-tile from |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
74 |
* @param r The randomness value from a Random() value |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
75 |
*/ |
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2957
diff
changeset
|
76 |
static void PlaceTree(TileIndex tile, uint32 r) |
0 | 77 |
{ |
2981 | 78 |
TreeType tree = GetRandomTreeType(tile, GB(r, 24, 8)); |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
79 |
|
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
80 |
if (tree != TREE_INVALID) { |
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
81 |
MakeTree(tile, tree, GB(r, 22, 2), min(GB(r, 16, 3), 6), TREE_GROUND_GRASS, 0); |
0 | 82 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6683
diff
changeset
|
83 |
/* above snowline? */ |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
84 |
if (_opt.landscape == LT_ARCTIC && GetTileZ(tile) > GetSnowLine()) { |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
85 |
SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, 3); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
86 |
SetTreeCounter(tile, (TreeGround)GB(r, 24, 3)); |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
87 |
} else { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
88 |
SetTreeGroundDensity(tile, (TreeGround)GB(r, 28, 1), 0); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
89 |
SetTreeCounter(tile, (TreeGround)GB(r, 24, 4)); |
0 | 90 |
} |
91 |
} |
|
92 |
} |
|
93 |
||
8093
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
94 |
/** |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
95 |
* Place some amount of trees around a given tile. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
96 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
97 |
* This function adds some trees around a given tile. As this function use |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
98 |
* the Random() call it depends on the random how many trees are actually placed |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
99 |
* around the given tile. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
100 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
101 |
* @param tile The center of the trees to add |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
102 |
*/ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
103 |
static void DoPlaceMoreTrees(TileIndex tile) |
0 | 104 |
{ |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
105 |
uint i; |
0 | 106 |
|
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
107 |
for (i = 0; i < 1000; i++) { |
0 | 108 |
uint32 r = Random(); |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
109 |
int x = GB(r, 0, 5) - 16; |
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
110 |
int y = GB(r, 8, 5) - 16; |
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
111 |
uint dist = myabs(x) + myabs(y); |
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
112 |
TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y)); |
0 | 113 |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
114 |
if (dist <= 13 && |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
115 |
IsTileType(cur_tile, MP_CLEAR) && |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
116 |
!IsBridgeAbove(cur_tile) && |
3447 | 117 |
!IsClearGround(cur_tile, CLEAR_FIELDS) && |
118 |
!IsClearGround(cur_tile, CLEAR_ROCKS)) { |
|
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2957
diff
changeset
|
119 |
PlaceTree(cur_tile, r); |
0 | 120 |
} |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
121 |
} |
0 | 122 |
} |
123 |
||
8093
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
124 |
/** |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
125 |
* Place more trees on the map. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
126 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
127 |
* This function add more trees to the map. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
128 |
*/ |
6573 | 129 |
static void PlaceMoreTrees() |
0 | 130 |
{ |
2243 | 131 |
uint i = ScaleByMapSize(GB(Random(), 0, 5) + 25); |
0 | 132 |
do { |
2051 | 133 |
DoPlaceMoreTrees(RandomTile()); |
0 | 134 |
} while (--i); |
135 |
} |
|
136 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
137 |
/** |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
138 |
* Place a tree at the same height as an existing tree. |
8093
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
139 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
140 |
* Add a new tree around the given tile which is at the same |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
141 |
* height or at some offset (2 units) of it. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
142 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
143 |
* @param tile The base tile to add a new tree somewhere around |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
144 |
* @param height The height (like the one from the tile) |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
145 |
*/ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
146 |
void PlaceTreeAtSameHeight(TileIndex tile, uint height) |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
147 |
{ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
148 |
uint i; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
149 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
150 |
for (i = 0; i < 1000; i++) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
151 |
uint32 r = Random(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
152 |
int x = GB(r, 0, 5) - 16; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
153 |
int y = GB(r, 8, 5) - 16; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
154 |
TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y)); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
155 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
156 |
/* Keep in range of the existing tree */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
157 |
if (myabs(x) + myabs(y) > 16) continue; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
158 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
159 |
/* Clear tile, no farm-tiles or rocks */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
160 |
if (!IsTileType(cur_tile, MP_CLEAR) || |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
161 |
IsClearGround(cur_tile, CLEAR_FIELDS) || |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
162 |
IsClearGround(cur_tile, CLEAR_ROCKS)) |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
163 |
continue; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
164 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
165 |
/* Not too much height difference */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
166 |
if (delta(GetTileZ(cur_tile), height) > 2) continue; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
167 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
168 |
/* Place one tree and quit */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
169 |
PlaceTree(cur_tile, r); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
170 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
171 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
172 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
173 |
|
8093
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
174 |
/** |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
175 |
* Place some trees randomly |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
176 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
177 |
* This function just place some trees randomly on the map. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
178 |
*/ |
6573 | 179 |
void PlaceTreesRandomly() |
0 | 180 |
{ |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
181 |
uint i, j, ht; |
0 | 182 |
|
1202
7d8b86bd8ba2
(svn r1706) Implement ScaleByMapSize() and ScaleByMapSize1D()
tron
parents:
1093
diff
changeset
|
183 |
i = ScaleByMapSize(1000); |
0 | 184 |
do { |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
185 |
uint32 r = Random(); |
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
186 |
TileIndex tile = RandomTileSeed(r); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
187 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
188 |
IncreaseGeneratingWorldProgress(GWP_TREE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
189 |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
190 |
if (IsTileType(tile, MP_CLEAR) && |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
191 |
!IsBridgeAbove(tile) && |
3447 | 192 |
!IsClearGround(tile, CLEAR_FIELDS) && |
193 |
!IsClearGround(tile, CLEAR_ROCKS)) { |
|
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2957
diff
changeset
|
194 |
PlaceTree(tile, r); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
195 |
if (_patches.tree_placer != TP_IMPROVED) continue; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
196 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
197 |
/* Place a number of trees based on the tile height. |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
198 |
* This gives a cool effect of multiple trees close together. |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
199 |
* It is almost real life ;) */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
200 |
ht = GetTileZ(tile); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
201 |
/* The higher we get, the more trees we plant */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
202 |
j = GetTileZ(tile) / TILE_HEIGHT * 2; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
203 |
while (j--) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
204 |
/* Above snowline more trees! */ |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
205 |
if (_opt.landscape == LT_ARCTIC && ht > GetSnowLine()) { |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
206 |
PlaceTreeAtSameHeight(tile, ht); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
207 |
PlaceTreeAtSameHeight(tile, ht); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
208 |
}; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
209 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
210 |
PlaceTreeAtSameHeight(tile, ht); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
211 |
} |
0 | 212 |
} |
213 |
} while (--i); |
|
214 |
||
215 |
/* place extra trees at rainforest area */ |
|
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
216 |
if (_opt.landscape == LT_TROPIC) { |
1202
7d8b86bd8ba2
(svn r1706) Implement ScaleByMapSize() and ScaleByMapSize1D()
tron
parents:
1093
diff
changeset
|
217 |
i = ScaleByMapSize(15000); |
0 | 218 |
|
219 |
do { |
|
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
220 |
uint32 r = Random(); |
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
221 |
TileIndex tile = RandomTileSeed(r); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
222 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
223 |
IncreaseGeneratingWorldProgress(GWP_TREE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
224 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
225 |
if (IsTileType(tile, MP_CLEAR) && |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
226 |
!IsBridgeAbove(tile) && |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
227 |
!IsClearGround(tile, CLEAR_FIELDS) && |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
228 |
GetTropicZone(tile) == TROPICZONE_RAINFOREST) { |
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2957
diff
changeset
|
229 |
PlaceTree(tile, r); |
0 | 230 |
} |
231 |
} while (--i); |
|
232 |
} |
|
233 |
} |
|
234 |
||
8093
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
235 |
/** |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
236 |
* Place new trees. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
237 |
* |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
238 |
* This function takes care of the selected tree placer algorithm and |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
239 |
* place randomly the trees for a new game. |
6f0fa5c9dacc
(svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents:
8005
diff
changeset
|
240 |
*/ |
6573 | 241 |
void GenerateTrees() |
0 | 242 |
{ |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
243 |
uint i, total; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
244 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
245 |
if (_patches.tree_placer == TP_NONE) return; |
0 | 246 |
|
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
247 |
if (_opt.landscape != LT_TOYLAND) PlaceMoreTrees(); |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
248 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
249 |
switch (_patches.tree_placer) { |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
250 |
case TP_ORIGINAL: i = _opt.landscape == LT_ARCTIC ? 15 : 6; break; |
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
251 |
case TP_IMPROVED: i = _opt.landscape == LT_ARCTIC ? 4 : 2; break; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
252 |
default: NOT_REACHED(); return; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
253 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
254 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
255 |
total = ScaleByMapSize(1000); |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
256 |
if (_opt.landscape == LT_TROPIC) total += ScaleByMapSize(15000); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
257 |
total *= i; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
258 |
SetGeneratingWorldProgress(GWP_TREE, total); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
259 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
260 |
for (; i != 0; i--) { |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
261 |
PlaceTreesRandomly(); |
0 | 262 |
} |
263 |
} |
|
264 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1370
diff
changeset
|
265 |
/** Plant a tree. |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
266 |
* @param tile start tile of area-drag of tree plantation |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6683
diff
changeset
|
267 |
* @param flags type of operation |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1370
diff
changeset
|
268 |
* @param p1 tree type, -1 means random. |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1370
diff
changeset
|
269 |
* @param p2 end tile of area-drag |
0 | 270 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7179
diff
changeset
|
271 |
CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 272 |
{ |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3144
diff
changeset
|
273 |
StringID msg = INVALID_STRING_ID; |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7179
diff
changeset
|
274 |
CommandCost cost; |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
275 |
int ex; |
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
276 |
int ey; |
2118
c73d32cc0b5e
(svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents:
2088
diff
changeset
|
277 |
int sx, sy, x, y; |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
278 |
|
2892
390125af7685
(svn r3446) - Fix: incorrect validating of tree-planting command which can allow a buffer-overflow (Tron)
Darkvater
parents:
2654
diff
changeset
|
279 |
if (p2 >= MapSize()) return CMD_ERROR; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1370
diff
changeset
|
280 |
/* Check the tree type. It can be random or some valid value within the current climate */ |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1370
diff
changeset
|
281 |
if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_opt.landscape] >= _tree_count_by_landscape[_opt.landscape]) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
282 |
|
0 | 283 |
SET_EXPENSES_TYPE(EXPENSES_OTHER); |
284 |
||
285 |
// make sure sx,sy are smaller than ex,ey |
|
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
286 |
ex = TileX(tile); |
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
287 |
ey = TileY(tile); |
2118
c73d32cc0b5e
(svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents:
2088
diff
changeset
|
288 |
sx = TileX(p2); |
c73d32cc0b5e
(svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents:
2088
diff
changeset
|
289 |
sy = TileY(p2); |
6432 | 290 |
if (ex < sx) Swap(ex, sx); |
291 |
if (ey < sy) Swap(ey, sy); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
292 |
|
2118
c73d32cc0b5e
(svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents:
2088
diff
changeset
|
293 |
for (x = sx; x <= ex; x++) { |
c73d32cc0b5e
(svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents:
2088
diff
changeset
|
294 |
for (y = sy; y <= ey; y++) { |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
295 |
TileIndex tile = TileXY(x, y); |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
296 |
|
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
297 |
switch (GetTileType(tile)) { |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
298 |
case MP_TREES: |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6683
diff
changeset
|
299 |
/* no more space for trees? */ |
3003 | 300 |
if (_game_mode != GM_EDITOR && GetTreeCount(tile) == 3) { |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3144
diff
changeset
|
301 |
msg = STR_2803_TREE_ALREADY_HERE; |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
302 |
continue; |
0 | 303 |
} |
304 |
||
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
305 |
if (flags & DC_EXEC) { |
2981 | 306 |
AddTreeCount(tile, 1); |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
307 |
MarkTileDirtyByTile(tile); |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
308 |
} |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6683
diff
changeset
|
309 |
/* 2x as expensive to add more trees to an existing tile */ |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
310 |
cost.AddCost(_price.build_trees * 2); |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
311 |
break; |
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
312 |
|
8005
9f7a95e84682
(svn r11024) -Fix [FS#1173]: give a more correct error when building some things on tile 0; "Can't build on water" or "Too close to the edge" instead of "Vehicle in the way". Patch by SmatZ.
rubidium
parents:
7990
diff
changeset
|
313 |
case MP_WATER: |
9f7a95e84682
(svn r11024) -Fix [FS#1173]: give a more correct error when building some things on tile 0; "Can't build on water" or "Too close to the edge" instead of "Vehicle in the way". Patch by SmatZ.
rubidium
parents:
7990
diff
changeset
|
314 |
msg = STR_3807_CAN_T_BUILD_ON_WATER; |
9f7a95e84682
(svn r11024) -Fix [FS#1173]: give a more correct error when building some things on tile 0; "Can't build on water" or "Too close to the edge" instead of "Vehicle in the way". Patch by SmatZ.
rubidium
parents:
7990
diff
changeset
|
315 |
continue; |
9f7a95e84682
(svn r11024) -Fix [FS#1173]: give a more correct error when building some things on tile 0; "Can't build on water" or "Too close to the edge" instead of "Vehicle in the way". Patch by SmatZ.
rubidium
parents:
7990
diff
changeset
|
316 |
break; |
9f7a95e84682
(svn r11024) -Fix [FS#1173]: give a more correct error when building some things on tile 0; "Can't build on water" or "Too close to the edge" instead of "Vehicle in the way". Patch by SmatZ.
rubidium
parents:
7990
diff
changeset
|
317 |
|
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
318 |
case MP_CLEAR: |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
319 |
if (!IsTileOwner(tile, OWNER_NONE) || |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
320 |
IsBridgeAbove(tile)) { |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3144
diff
changeset
|
321 |
msg = STR_2804_SITE_UNSUITABLE; |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
322 |
continue; |
0 | 323 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
324 |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
325 |
switch (GetClearGround(tile)) { |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
326 |
case CLEAR_FIELDS: cost.AddCost(_price.clear_3); break; |
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
327 |
case CLEAR_ROCKS: cost.AddCost(_price.clear_2); break; |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
328 |
default: break; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
329 |
} |
0 | 330 |
|
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
331 |
if (flags & DC_EXEC) { |
2981 | 332 |
TreeType treetype; |
3079
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
3076
diff
changeset
|
333 |
uint growth; |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
334 |
|
4850
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4559
diff
changeset
|
335 |
if (_game_mode != GM_EDITOR && IsValidPlayer(_current_player)) { |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
336 |
Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority); |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
337 |
if (t != NULL) |
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
338 |
ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM); |
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
339 |
} |
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
340 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
341 |
treetype = (TreeType)p1; |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
342 |
if (treetype == TREE_INVALID) { |
2981 | 343 |
treetype = GetRandomTreeType(tile, GB(Random(), 24, 8)); |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
344 |
if (treetype == TREE_INVALID) treetype = TREE_CACTUS; |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
345 |
} |
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
346 |
|
3079
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
3076
diff
changeset
|
347 |
growth = _game_mode == GM_EDITOR ? 3 : 0; |
2981 | 348 |
switch (GetClearGround(tile)) { |
3447 | 349 |
case CLEAR_ROUGH: MakeTree(tile, treetype, 0, growth, TREE_GROUND_ROUGH, 0); break; |
350 |
case CLEAR_SNOW: MakeTree(tile, treetype, 0, growth, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break; |
|
351 |
default: MakeTree(tile, treetype, 0, growth, TREE_GROUND_GRASS, 0); break; |
|
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
352 |
} |
3003 | 353 |
MarkTileDirtyByTile(tile); |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
354 |
|
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
355 |
if (_game_mode == GM_EDITOR && IS_INT_INSIDE(treetype, TREE_RAINFOREST, TREE_CACTUS)) |
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3271
diff
changeset
|
356 |
SetTropicZone(tile, TROPICZONE_RAINFOREST); |
0 | 357 |
} |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
358 |
cost.AddCost(_price.build_trees); |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
359 |
break; |
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
360 |
|
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
361 |
default: |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3144
diff
changeset
|
362 |
msg = STR_2804_SITE_UNSUITABLE; |
1286
da05e4dc75b5
(svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents:
1209
diff
changeset
|
363 |
break; |
0 | 364 |
} |
365 |
} |
|
366 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
367 |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
368 |
if (cost.GetCost() == 0) { |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3144
diff
changeset
|
369 |
return_cmd_error(msg); |
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3144
diff
changeset
|
370 |
} else { |
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3144
diff
changeset
|
371 |
return cost; |
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3144
diff
changeset
|
372 |
} |
0 | 373 |
} |
374 |
||
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
375 |
struct TreeListEnt { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
376 |
SpriteID image; |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
377 |
SpriteID pal; |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6923
diff
changeset
|
378 |
byte x, y; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
379 |
}; |
0 | 380 |
|
381 |
static void DrawTile_Trees(TileInfo *ti) |
|
382 |
{ |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
383 |
const PalSpriteID *s; |
2654
df351c3ddd59
(svn r3196) Use structs instead of magic offsets into arrays
tron
parents:
2644
diff
changeset
|
384 |
const TreePos* d; |
0 | 385 |
byte z; |
386 |
||
2981 | 387 |
switch (GetTreeGround(ti->tile)) { |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
388 |
case TREE_GROUND_GRASS: DrawClearLandTile(ti, 3); break; |
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
389 |
case TREE_GROUND_ROUGH: DrawHillyLandTile(ti); break; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
390 |
default: DrawGroundSprite(_tree_sprites_1[GetTreeDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); break; |
0 | 391 |
} |
392 |
||
2220 | 393 |
DrawClearLandFence(ti); |
0 | 394 |
|
395 |
z = ti->z; |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
396 |
if (ti->tileh != SLOPE_FLAT) { |
0 | 397 |
z += 4; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
398 |
if (IsSteepSlope(ti->tileh)) z += 4; |
0 | 399 |
} |
400 |
||
401 |
{ |
|
402 |
uint16 tmp = ti->x; |
|
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
926
diff
changeset
|
403 |
uint index; |
0 | 404 |
|
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
405 |
tmp = ROR(tmp, 2); |
0 | 406 |
tmp -= ti->y; |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
407 |
tmp = ROR(tmp, 3); |
0 | 408 |
tmp -= ti->x; |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
409 |
tmp = ROR(tmp, 1); |
0 | 410 |
tmp += ti->y; |
411 |
||
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
412 |
d = _tree_layout_xy[GB(tmp, 4, 2)]; |
0 | 413 |
|
2981 | 414 |
index = GB(tmp, 6, 2) + (GetTreeType(ti->tile) << 2); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
415 |
|
0 | 416 |
/* different tree styles above one of the grounds */ |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
417 |
if (GetTreeGround(ti->tile) == TREE_GROUND_SNOW_DESERT && |
2981 | 418 |
GetTreeDensity(ti->tile) >= 2 && |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
419 |
IS_INT_INSIDE(index, TREE_SUB_ARCTIC << 2, TREE_RAINFOREST << 2)) { |
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
420 |
index += 164 - (TREE_SUB_ARCTIC << 2); |
2981 | 421 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
422 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
423 |
assert(index < lengthof(_tree_layout_sprite)); |
0 | 424 |
s = _tree_layout_sprite[index]; |
425 |
} |
|
426 |
||
427 |
StartSpriteCombine(); |
|
428 |
||
6923
6913c8a82cc0
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6918
diff
changeset
|
429 |
if (!HASBIT(_transparent_opt, TO_TREES) || !_patches.invisible_trees) { |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
430 |
TreeListEnt te[4]; |
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
431 |
uint i; |
0 | 432 |
|
433 |
/* put the trees to draw in a list */ |
|
3271
0e796a2b7c9e
(svn r3983) Use existing functions to access tree and road info
tron
parents:
3183
diff
changeset
|
434 |
i = GetTreeCount(ti->tile) + 1; |
0 | 435 |
do { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
436 |
SpriteID image = s[0].sprite + (--i == 0 ? GetTreeGrowth(ti->tile) : 3); |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7813
diff
changeset
|
437 |
SpriteID pal = s[0].pal; |
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7813
diff
changeset
|
438 |
|
0 | 439 |
te[i].image = image; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
440 |
te[i].pal = pal; |
2654
df351c3ddd59
(svn r3196) Use structs instead of magic offsets into arrays
tron
parents:
2644
diff
changeset
|
441 |
te[i].x = d->x; |
df351c3ddd59
(svn r3196) Use structs instead of magic offsets into arrays
tron
parents:
2644
diff
changeset
|
442 |
te[i].y = d->y; |
0 | 443 |
s++; |
2654
df351c3ddd59
(svn r3196) Use structs instead of magic offsets into arrays
tron
parents:
2644
diff
changeset
|
444 |
d++; |
0 | 445 |
} while (i); |
446 |
||
447 |
/* draw them in a sorted way */ |
|
2952 | 448 |
for (;;) { |
0 | 449 |
byte min = 0xFF; |
450 |
TreeListEnt *tep = NULL; |
|
451 |
||
3271
0e796a2b7c9e
(svn r3983) Use existing functions to access tree and road info
tron
parents:
3183
diff
changeset
|
452 |
i = GetTreeCount(ti->tile) + 1; |
0 | 453 |
do { |
2644 | 454 |
if (te[--i].image != 0 && te[i].x + te[i].y < min) { |
0 | 455 |
min = te[i].x + te[i].y; |
456 |
tep = &te[i]; |
|
457 |
} |
|
458 |
} while (i); |
|
459 |
||
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
460 |
if (tep == NULL) break; |
0 | 461 |
|
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8093
diff
changeset
|
462 |
AddSortableSpriteToDraw(tep->image, tep->pal, ti->x + tep->x, ti->y + tep->y, 16 - tep->x, 16 - tep->y, 0x30, z, HASBIT(_transparent_opt, TO_TREES), -tep->x, -tep->y); |
0 | 463 |
tep->image = 0; |
464 |
} |
|
465 |
} |
|
466 |
||
467 |
EndSpriteCombine(); |
|
468 |
} |
|
469 |
||
470 |
||
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4157
diff
changeset
|
471 |
static uint GetSlopeZ_Trees(TileIndex tile, uint x, uint y) |
2537 | 472 |
{ |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4157
diff
changeset
|
473 |
uint z; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
474 |
Slope tileh = GetTileSlope(tile, &z); |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4157
diff
changeset
|
475 |
|
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4157
diff
changeset
|
476 |
return z + GetPartialZ(x & 0xF, y & 0xF, tileh); |
0 | 477 |
} |
478 |
||
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
479 |
static Foundation GetFoundation_Trees(TileIndex tile, Slope tileh) |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2537
diff
changeset
|
480 |
{ |
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
481 |
return FOUNDATION_NONE; |
39 | 482 |
} |
483 |
||
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7179
diff
changeset
|
484 |
static CommandCost ClearTile_Trees(TileIndex tile, byte flags) |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
485 |
{ |
2243 | 486 |
uint num; |
0 | 487 |
|
4850
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4559
diff
changeset
|
488 |
if ((flags & DC_EXEC) && IsValidPlayer(_current_player)) { |
0 | 489 |
Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
490 |
if (t != NULL) |
1005 | 491 |
ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM); |
0 | 492 |
} |
493 |
||
2981 | 494 |
num = GetTreeCount(tile) + 1; |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
495 |
if (IS_INT_INSIDE(GetTreeType(tile), TREE_RAINFOREST, TREE_CACTUS)) num *= 4; |
0 | 496 |
|
2243 | 497 |
if (flags & DC_EXEC) DoClearSquare(tile); |
0 | 498 |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
499 |
return CommandCost(num * _price.remove_trees); |
0 | 500 |
} |
501 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
502 |
static void GetAcceptedCargo_Trees(TileIndex tile, AcceptedCargo ac) |
0 | 503 |
{ |
504 |
/* not used */ |
|
505 |
} |
|
506 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
507 |
static void GetTileDesc_Trees(TileIndex tile, TileDesc *td) |
0 | 508 |
{ |
2981 | 509 |
TreeType tt = GetTreeType(tile); |
510 |
||
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
511 |
if (IS_INT_INSIDE(tt, TREE_RAINFOREST, TREE_CACTUS)) { |
2981 | 512 |
td->str = STR_280F_RAINFOREST; |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
513 |
} else if (tt == TREE_CACTUS) { |
2981 | 514 |
td->str = STR_2810_CACTUS_PLANTS; |
515 |
} else { |
|
516 |
td->str = STR_280E_TREES; |
|
517 |
} |
|
0 | 518 |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
519 |
td->owner = GetTileOwner(tile); |
0 | 520 |
} |
521 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
522 |
static void AnimateTile_Trees(TileIndex tile) |
0 | 523 |
{ |
524 |
/* not used */ |
|
525 |
} |
|
526 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
527 |
static void TileLoopTreesDesert(TileIndex tile) |
0 | 528 |
{ |
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3271
diff
changeset
|
529 |
switch (GetTropicZone(tile)) { |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3271
diff
changeset
|
530 |
case TROPICZONE_DESERT: |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
531 |
if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT) { |
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
532 |
SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, 3); |
2981 | 533 |
MarkTileDirtyByTile(tile); |
534 |
} |
|
535 |
break; |
|
2243 | 536 |
|
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3271
diff
changeset
|
537 |
case TROPICZONE_RAINFOREST: { |
2981 | 538 |
static const SoundFx forest_sounds[] = { |
539 |
SND_42_LOON_BIRD, |
|
540 |
SND_43_LION, |
|
541 |
SND_44_MONKEYS, |
|
542 |
SND_48_DISTANT_BIRD |
|
543 |
}; |
|
544 |
uint32 r = Random(); |
|
0 | 545 |
|
2981 | 546 |
if (CHANCE16I(1, 200, r)) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile); |
547 |
break; |
|
0 | 548 |
} |
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3271
diff
changeset
|
549 |
|
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3271
diff
changeset
|
550 |
default: break; |
0 | 551 |
} |
552 |
} |
|
553 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
554 |
static void TileLoopTreesAlps(TileIndex tile) |
0 | 555 |
{ |
6669
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6574
diff
changeset
|
556 |
int k = GetTileZ(tile) - GetSnowLine() + TILE_HEIGHT; |
0 | 557 |
|
4157
0c3210247472
(svn r5581) Slightly alter some snow line related calculations to make them a bit clearer
tron
parents:
3977
diff
changeset
|
558 |
if (k < 0) { |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
559 |
if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT) return; |
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
560 |
SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 0); |
0 | 561 |
} else { |
4157
0c3210247472
(svn r5581) Slightly alter some snow line related calculations to make them a bit clearer
tron
parents:
3977
diff
changeset
|
562 |
uint density = min((uint)k / TILE_HEIGHT, 3); |
2981 | 563 |
|
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
564 |
if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT || |
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
565 |
GetTreeDensity(tile) != density) { |
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
566 |
SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, density); |
2981 | 567 |
} else { |
568 |
if (GetTreeDensity(tile) == 3) { |
|
569 |
uint32 r = Random(); |
|
570 |
if (CHANCE16I(1, 200, r)) { |
|
571 |
SndPlayTileFx((r & 0x80000000) ? SND_39_HEAVY_WIND : SND_34_WIND, tile); |
|
572 |
} |
|
0 | 573 |
} |
574 |
return; |
|
575 |
} |
|
576 |
} |
|
577 |
MarkTileDirtyByTile(tile); |
|
578 |
} |
|
579 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
580 |
static void TileLoop_Trees(TileIndex tile) |
0 | 581 |
{ |
2981 | 582 |
switch (_opt.landscape) { |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
583 |
case LT_TROPIC: TileLoopTreesDesert(tile); break; |
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
584 |
case LT_ARCTIC: TileLoopTreesAlps(tile); break; |
0 | 585 |
} |
586 |
||
587 |
TileLoopClearHelper(tile); |
|
588 |
||
2981 | 589 |
if (GetTreeCounter(tile) < 15) { |
590 |
AddTreeCounter(tile, 1); |
|
591 |
return; |
|
592 |
} |
|
593 |
SetTreeCounter(tile, 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
594 |
|
2981 | 595 |
switch (GetTreeGrowth(tile)) { |
596 |
case 3: /* regular sized tree */ |
|
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
597 |
if (_opt.landscape == LT_TROPIC && |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
598 |
GetTreeType(tile) != TREE_CACTUS && |
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3271
diff
changeset
|
599 |
GetTropicZone(tile) == TROPICZONE_DESERT) { |
2981 | 600 |
AddTreeGrowth(tile, 1); |
601 |
} else { |
|
602 |
switch (GB(Random(), 0, 3)) { |
|
603 |
case 0: /* start destructing */ |
|
604 |
AddTreeGrowth(tile, 1); |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
605 |
break; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
606 |
|
2981 | 607 |
case 1: /* add a tree */ |
608 |
if (GetTreeCount(tile) < 3) { |
|
609 |
AddTreeCount(tile, 1); |
|
610 |
SetTreeGrowth(tile, 0); |
|
611 |
break; |
|
612 |
} |
|
613 |
/* FALL THROUGH */ |
|
0 | 614 |
|
2981 | 615 |
case 2: { /* add a neighbouring tree */ |
616 |
TreeType treetype = GetTreeType(tile); |
|
0 | 617 |
|
7813
49fbe41f8a04
(svn r10672) -Codechange: typify some parameters/variables.
rubidium
parents:
7446
diff
changeset
|
618 |
tile += TileOffsByDir((Direction)(Random() & 7)); |
0 | 619 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
620 |
if (!IsTileType(tile, MP_CLEAR) || IsBridgeAbove(tile)) return; |
2981 | 621 |
|
622 |
switch (GetClearGround(tile)) { |
|
3447 | 623 |
case CLEAR_GRASS: |
2981 | 624 |
if (GetClearDensity(tile) != 3) return; |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
625 |
MakeTree(tile, treetype, 0, 0, TREE_GROUND_GRASS, 0); |
2981 | 626 |
break; |
627 |
||
3447 | 628 |
case CLEAR_ROUGH: MakeTree(tile, treetype, 0, 0, TREE_GROUND_ROUGH, 0); break; |
629 |
case CLEAR_SNOW: MakeTree(tile, treetype, 0, 0, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break; |
|
2981 | 630 |
default: return; |
631 |
} |
|
632 |
break; |
|
633 |
} |
|
634 |
||
635 |
default: |
|
636 |
return; |
|
637 |
} |
|
0 | 638 |
} |
2981 | 639 |
break; |
640 |
||
641 |
case 6: /* final stage of tree destruction */ |
|
642 |
if (GetTreeCount(tile) > 0) { |
|
643 |
/* more than one tree, delete it */ |
|
644 |
AddTreeCount(tile, -1); |
|
645 |
SetTreeGrowth(tile, 3); |
|
646 |
} else { |
|
647 |
/* just one tree, change type into MP_CLEAR */ |
|
648 |
switch (GetTreeGround(tile)) { |
|
3447 | 649 |
case TREE_GROUND_GRASS: MakeClear(tile, CLEAR_GRASS, 3); break; |
650 |
case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break; |
|
651 |
default: MakeClear(tile, CLEAR_SNOW, GetTreeDensity(tile)); break; |
|
2981 | 652 |
} |
0 | 653 |
} |
2981 | 654 |
break; |
655 |
||
656 |
default: |
|
657 |
AddTreeGrowth(tile, 1); |
|
658 |
break; |
|
0 | 659 |
} |
660 |
||
661 |
MarkTileDirtyByTile(tile); |
|
662 |
} |
|
663 |
||
6573 | 664 |
void OnTick_Trees() |
0 | 665 |
{ |
666 |
uint32 r; |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
667 |
TileIndex tile; |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
668 |
ClearGround ct; |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
3003
diff
changeset
|
669 |
TreeType tree; |
0 | 670 |
|
671 |
/* place a tree at a random rainforest spot */ |
|
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
672 |
if (_opt.landscape == LT_TROPIC && |
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3271
diff
changeset
|
673 |
(r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) && |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1005
diff
changeset
|
674 |
IsTileType(tile, MP_CLEAR) && |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
675 |
!IsBridgeAbove(tile) && |
3447 | 676 |
(ct = GetClearGround(tile), ct == CLEAR_GRASS || ct == CLEAR_ROUGH) && |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
677 |
(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) { |
3447 | 678 |
MakeTree(tile, tree, 0, 0, ct == CLEAR_ROUGH ? TREE_GROUND_ROUGH : TREE_GROUND_GRASS, 0); |
0 | 679 |
} |
680 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6683
diff
changeset
|
681 |
/* byte underflow */ |
2088
f290b54c97cb
(svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents:
2085
diff
changeset
|
682 |
if (--_trees_tick_ctr != 0) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
160
diff
changeset
|
683 |
|
0 | 684 |
/* place a tree at a random spot */ |
685 |
r = Random(); |
|
686 |
tile = TILE_MASK(r); |
|
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1005
diff
changeset
|
687 |
if (IsTileType(tile, MP_CLEAR) && |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4850
diff
changeset
|
688 |
!IsBridgeAbove(tile) && |
3447 | 689 |
(ct = GetClearGround(tile), ct == CLEAR_GRASS || ct == CLEAR_ROUGH || ct == CLEAR_SNOW) && |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
690 |
(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) { |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
691 |
switch (ct) { |
3447 | 692 |
case CLEAR_GRASS: MakeTree(tile, tree, 0, 0, TREE_GROUND_GRASS, 0); break; |
693 |
case CLEAR_ROUGH: MakeTree(tile, tree, 0, 0, TREE_GROUND_ROUGH, 0); break; |
|
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3422
diff
changeset
|
694 |
default: MakeTree(tile, tree, 0, 0, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break; |
0 | 695 |
} |
696 |
} |
|
697 |
} |
|
698 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
699 |
static void ClickTile_Trees(TileIndex tile) |
0 | 700 |
{ |
701 |
/* not used */ |
|
702 |
} |
|
703 |
||
7179
3e123c2b7c93
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents:
6987
diff
changeset
|
704 |
static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode) |
0 | 705 |
{ |
706 |
return 0; |
|
707 |
} |
|
708 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2243
diff
changeset
|
709 |
static void ChangeTileOwner_Trees(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 710 |
{ |
711 |
/* not used */ |
|
712 |
} |
|
713 |
||
6573 | 714 |
void InitializeTrees() |
0 | 715 |
{ |
716 |
_trees_tick_ctr = 0; |
|
717 |
} |
|
718 |
||
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7831
diff
changeset
|
719 |
static CommandCost TerraformTile_Trees(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7831
diff
changeset
|
720 |
{ |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7831
diff
changeset
|
721 |
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7831
diff
changeset
|
722 |
} |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7831
diff
changeset
|
723 |
|
0 | 724 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
725 |
extern const TileTypeProcs _tile_type_trees_procs = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
726 |
DrawTile_Trees, /* draw_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
727 |
GetSlopeZ_Trees, /* get_slope_z_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
728 |
ClearTile_Trees, /* clear_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
729 |
GetAcceptedCargo_Trees, /* get_accepted_cargo_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
730 |
GetTileDesc_Trees, /* get_tile_desc_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
731 |
GetTileTrackStatus_Trees, /* get_tile_track_status_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
732 |
ClickTile_Trees, /* click_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
733 |
AnimateTile_Trees, /* animate_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
734 |
TileLoop_Trees, /* tile_loop_clear */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
735 |
ChangeTileOwner_Trees, /* change_tile_owner_clear */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
736 |
NULL, /* get_produced_cargo_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
737 |
NULL, /* vehicle_enter_tile_proc */ |
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
738 |
GetFoundation_Trees, /* get_foundation_proc */ |
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7831
diff
changeset
|
739 |
TerraformTile_Trees, /* terraform_tile_proc */ |
0 | 740 |
}; |