src/tree_cmd.cpp
author rubidium
Fri, 31 Aug 2007 20:03:50 +0000
changeset 7509 23372ed624e8
parent 7494 ab05bad37410
child 7597 e9ad1ed5c4d5
permissions -rw-r--r--
(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.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6357
diff changeset
     3
/** @file tree_cmd.cpp */
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6357
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1784
diff changeset
     6
#include "openttd.h"
5385
3868f2e6db9b (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
33e42feae531 (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
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 497
diff changeset
     9
#include "table/strings.h"
2148
542ea702738c (svn r2658) -Codechange: Use MAKE_TRANSPARENT to display a transparented sprite
celestar
parents: 2118
diff changeset
    10
#include "table/sprites.h"
1784
d0698aac0c2e (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
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2153
diff changeset
    12
#include "functions.h"
679
04ca2cd69420 (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"
6343
76d17f784c13 (svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents: 6248
diff changeset
    14
#include "landscape.h"
1209
2e00193652b2 (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
33e42feae531 (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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
#include "town.h"
337
cbe0c766c947 (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
ecfc674410b4 (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
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    22
#include "genworld.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    23
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    24
enum TreePlacer {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    25
	TP_NONE,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    26
	TP_ORIGINAL,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    27
	TP_IMPROVED,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    28
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
    30
static TreeType GetRandomTreeType(TileIndex tile, uint seed)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
{
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
    32
	switch (_opt.landscape) {
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
    33
		case LT_TEMPERATE:
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    34
			return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
    36
		case LT_ARCTIC:
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    37
			return (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC);
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
    38
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
    39
		case LT_TROPIC:
3379
50b253bb9819 (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
    40
			switch (GetTropicZone(tile)) {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    41
				case TROPICZONE_INVALID: return (TreeType)(seed * TREE_COUNT_SUB_TROPICAL / 256 + TREE_SUB_TROPICAL);
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    42
				case TROPICZONE_DESERT:  return (TreeType)((seed > 12) ? TREE_INVALID : TREE_CACTUS);
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    43
				default:                 return (TreeType)(seed * TREE_COUNT_RAINFOREST / 256 + TREE_RAINFOREST);
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
    44
			}
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
    45
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
    46
		default:
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    47
			return (TreeType)(seed * TREE_COUNT_TOYLAND / 256 + TREE_TOYLAND);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
2958
ac0a9673b522 (svn r3520) Remove unused parameters from some functions
tron
parents: 2957
diff changeset
    51
static void PlaceTree(TileIndex tile, uint32 r)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
{
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
    53
	TreeType tree = GetRandomTreeType(tile, GB(r, 24, 8));
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
    54
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
    55
	if (tree != TREE_INVALID) {
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
    56
		MakeTree(tile, tree, GB(r, 22, 2), min(GB(r, 16, 3), 6), TREE_GROUND_GRASS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6357
diff changeset
    58
		/* above snowline? */
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
    59
		if (_opt.landscape == LT_ARCTIC && GetTileZ(tile) > GetSnowLine()) {
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
    60
			SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, 3);
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    61
			SetTreeCounter(tile, (TreeGround)GB(r, 24, 3));
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
    62
		} else {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    63
			SetTreeGroundDensity(tile, (TreeGround)GB(r, 28, 1), 0);
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    64
			SetTreeCounter(tile, (TreeGround)GB(r, 24, 4));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
    69
static void DoPlaceMoreTrees(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
{
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
    71
	uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
    73
	for (i = 0; i < 1000; i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
		uint32 r = Random();
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
    75
		int x = GB(r, 0, 5) - 16;
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
    76
		int y = GB(r, 8, 5) - 16;
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
    77
		uint dist = myabs(x) + myabs(y);
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
    78
		TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
2955
24de69e236d2 (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
    80
		if (dist <= 13 &&
24de69e236d2 (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
    81
				IsTileType(cur_tile, MP_CLEAR) &&
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
    82
				!IsBridgeAbove(cur_tile) &&
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
    83
				!IsClearGround(cur_tile, CLEAR_FIELDS) &&
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
    84
				!IsClearGround(cur_tile, CLEAR_ROCKS)) {
2958
ac0a9673b522 (svn r3520) Remove unused parameters from some functions
tron
parents: 2957
diff changeset
    85
			PlaceTree(cur_tile, r);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
		}
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
    87
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6133
diff changeset
    90
static void PlaceMoreTrees()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
{
2243
b7e58afa3616 (svn r2763) Small cleanup and improve a few comments
tron
parents: 2238
diff changeset
    92
	uint i = ScaleByMapSize(GB(Random(), 0, 5) + 25);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	do {
2051
e369160ce2f3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2049
diff changeset
    94
		DoPlaceMoreTrees(RandomTile());
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    98
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    99
 * Place a tree at the same height as an existing tree.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   100
 *  This gives cool effects to the map.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   101
 */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   102
void PlaceTreeAtSameHeight(TileIndex tile, uint height)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   103
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   104
	uint i;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   105
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   106
	for (i = 0; i < 1000; i++) {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   107
		uint32 r = Random();
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   108
		int x = GB(r, 0, 5) - 16;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   109
		int y = GB(r, 8, 5) - 16;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   110
		TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y));
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   111
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   112
		/* Keep in range of the existing tree */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   113
		if (myabs(x) + myabs(y) > 16) continue;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   114
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   115
		/* Clear tile, no farm-tiles or rocks */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   116
		if (!IsTileType(cur_tile, MP_CLEAR) ||
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   117
				IsClearGround(cur_tile, CLEAR_FIELDS) ||
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   118
				IsClearGround(cur_tile, CLEAR_ROCKS))
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   119
			continue;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   120
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   121
		/* Not too much height difference */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   122
		if (delta(GetTileZ(cur_tile), height) > 2) continue;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   123
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   124
		/* Place one tree and quit */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   125
		PlaceTree(cur_tile, r);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   126
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   127
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   128
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   129
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6133
diff changeset
   130
void PlaceTreesRandomly()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
{
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   132
	uint i, j, ht;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
1202
4d2a20c50760 (svn r1706) Implement ScaleByMapSize() and ScaleByMapSize1D()
tron
parents: 1093
diff changeset
   134
	i = ScaleByMapSize(1000);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	do {
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   136
		uint32 r = Random();
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   137
		TileIndex tile = RandomTileSeed(r);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   138
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   139
		IncreaseGeneratingWorldProgress(GWP_TREE);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   140
2955
24de69e236d2 (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
   141
		if (IsTileType(tile, MP_CLEAR) &&
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   142
				!IsBridgeAbove(tile) &&
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   143
				!IsClearGround(tile, CLEAR_FIELDS) &&
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   144
				!IsClearGround(tile, CLEAR_ROCKS)) {
2958
ac0a9673b522 (svn r3520) Remove unused parameters from some functions
tron
parents: 2957
diff changeset
   145
			PlaceTree(tile, r);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   146
			if (_patches.tree_placer != TP_IMPROVED) continue;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   147
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   148
			/* Place a number of trees based on the tile height.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   149
			 *  This gives a cool effect of multiple trees close together.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   150
			 *  It is almost real life ;) */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   151
			ht = GetTileZ(tile);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   152
			/* The higher we get, the more trees we plant */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   153
			j = GetTileZ(tile) / TILE_HEIGHT * 2;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   154
			while (j--) {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   155
				/* Above snowline more trees! */
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   156
				if (_opt.landscape == LT_ARCTIC && ht > GetSnowLine()) {
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   157
					PlaceTreeAtSameHeight(tile, ht);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   158
					PlaceTreeAtSameHeight(tile, ht);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   159
				};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   160
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   161
				PlaceTreeAtSameHeight(tile, ht);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   162
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
	/* place extra trees at rainforest area */
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   167
	if (_opt.landscape == LT_TROPIC) {
1202
4d2a20c50760 (svn r1706) Implement ScaleByMapSize() and ScaleByMapSize1D()
tron
parents: 1093
diff changeset
   168
		i = ScaleByMapSize(15000);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
		do {
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   171
			uint32 r = Random();
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   172
			TileIndex tile = RandomTileSeed(r);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   173
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   174
			IncreaseGeneratingWorldProgress(GWP_TREE);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   175
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   176
			if (IsTileType(tile, MP_CLEAR) &&
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   177
					!IsBridgeAbove(tile) &&
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   178
					!IsClearGround(tile, CLEAR_FIELDS) &&
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   179
					GetTropicZone(tile) == TROPICZONE_RAINFOREST) {
2958
ac0a9673b522 (svn r3520) Remove unused parameters from some functions
tron
parents: 2957
diff changeset
   180
				PlaceTree(tile, r);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
		} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6133
diff changeset
   186
void GenerateTrees()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
{
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   188
	uint i, total;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   189
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   190
	if (_patches.tree_placer == TP_NONE) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   192
	if (_opt.landscape != LT_TOYLAND) PlaceMoreTrees();
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   193
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   194
	switch (_patches.tree_placer) {
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   195
		case TP_ORIGINAL: i = _opt.landscape == LT_ARCTIC ? 15 : 6; break;
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   196
		case TP_IMPROVED: i = _opt.landscape == LT_ARCTIC ?  4 : 2; break;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   197
		default: NOT_REACHED(); return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   198
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   199
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   200
	total = ScaleByMapSize(1000);
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   201
	if (_opt.landscape == LT_TROPIC) total += ScaleByMapSize(15000);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   202
	total *= i;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   203
	SetGeneratingWorldProgress(GWP_TREE, total);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   204
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   205
	for (; i != 0; i--) {
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   206
		PlaceTreesRandomly();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1370
diff changeset
   210
/** Plant a tree.
3491
35d747bb5e82 (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
   211
 * @param tile start tile of area-drag of tree plantation
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6357
diff changeset
   212
 * @param flags type of operation
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1370
diff changeset
   213
 * @param p1 tree type, -1 means random.
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1370
diff changeset
   214
 * @param p2 end tile of area-drag
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
 */
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6683
diff changeset
   216
CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
{
3183
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3144
diff changeset
   218
	StringID msg = INVALID_STRING_ID;
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6683
diff changeset
   219
	CommandCost cost;
3491
35d747bb5e82 (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
   220
	int ex;
35d747bb5e82 (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
   221
	int ey;
2118
aec8042f000b (svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents: 2088
diff changeset
   222
	int sx, sy, x, y;
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   223
2892
db216dc91941 (svn r3446) - Fix: incorrect validating of tree-planting command which can allow a buffer-overflow (Tron)
Darkvater
parents: 2654
diff changeset
   224
	if (p2 >= MapSize()) return CMD_ERROR;
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1370
diff changeset
   225
	/* Check the tree type. It can be random or some valid value within the current climate */
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1370
diff changeset
   226
	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
   227
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
	SET_EXPENSES_TYPE(EXPENSES_OTHER);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
	// make sure sx,sy are smaller than ex,ey
3491
35d747bb5e82 (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
   231
	ex = TileX(tile);
35d747bb5e82 (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
   232
	ey = TileY(tile);
2118
aec8042f000b (svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents: 2088
diff changeset
   233
	sx = TileX(p2);
aec8042f000b (svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents: 2088
diff changeset
   234
	sy = TileY(p2);
6106
2898cd9417fd (svn r8841) -Fix
tron
parents: 5668
diff changeset
   235
	if (ex < sx) Swap(ex, sx);
2898cd9417fd (svn r8841) -Fix
tron
parents: 5668
diff changeset
   236
	if (ey < sy) Swap(ey, sy);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   237
2118
aec8042f000b (svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents: 2088
diff changeset
   238
	for (x = sx; x <= ex; x++) {
aec8042f000b (svn r2628) - Fix: Planting trees does not result in a MapSize() assertion anymore; introduced in r2598
Darkvater
parents: 2088
diff changeset
   239
		for (y = sy; y <= ey; y++) {
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   240
			TileIndex tile = TileXY(x, y);
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   241
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   242
			switch (GetTileType(tile)) {
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   243
				case MP_TREES:
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6357
diff changeset
   244
					/* no more space for trees? */
3003
821180e49591 (svn r3583) Fix 2 glitches in r3556
tron
parents: 2981
diff changeset
   245
					if (_game_mode != GM_EDITOR && GetTreeCount(tile) == 3) {
3183
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3144
diff changeset
   246
						msg = STR_2803_TREE_ALREADY_HERE;
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   247
						continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   250
					if (flags & DC_EXEC) {
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   251
						AddTreeCount(tile, 1);
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   252
						MarkTileDirtyByTile(tile);
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   253
					}
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6357
diff changeset
   254
					/* 2x as expensive to add more trees to an existing tile */
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   255
					cost.AddCost(_price.build_trees * 2);
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   256
					break;
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   257
7509
23372ed624e8 (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: 7494
diff changeset
   258
				case MP_WATER:
23372ed624e8 (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: 7494
diff changeset
   259
					msg = STR_3807_CAN_T_BUILD_ON_WATER;
23372ed624e8 (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: 7494
diff changeset
   260
					continue;
23372ed624e8 (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: 7494
diff changeset
   261
					break;
23372ed624e8 (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: 7494
diff changeset
   262
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   263
				case MP_CLEAR:
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   264
					if (!IsTileOwner(tile, OWNER_NONE) ||
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   265
							IsBridgeAbove(tile)) {
3183
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3144
diff changeset
   266
						msg = STR_2804_SITE_UNSUITABLE;
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   267
						continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
					}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   269
2955
24de69e236d2 (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
   270
					switch (GetClearGround(tile)) {
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   271
						case CLEAR_FIELDS: cost.AddCost(_price.clear_3); break;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   272
						case CLEAR_ROCKS:  cost.AddCost(_price.clear_2); break;
2955
24de69e236d2 (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
   273
						default: break;
24de69e236d2 (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
   274
					}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   276
					if (flags & DC_EXEC) {
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   277
						TreeType treetype;
3079
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 3076
diff changeset
   278
						uint growth;
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   279
4850
93095755db8c (svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents: 4559
diff changeset
   280
						if (_game_mode != GM_EDITOR && IsValidPlayer(_current_player)) {
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   281
							Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   282
							if (t != NULL)
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   283
								ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM);
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   284
						}
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   285
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   286
						treetype = (TreeType)p1;
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   287
						if (treetype == TREE_INVALID) {
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   288
							treetype = GetRandomTreeType(tile, GB(Random(), 24, 8));
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   289
							if (treetype == TREE_INVALID) treetype = TREE_CACTUS;
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   290
						}
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   291
3079
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 3076
diff changeset
   292
						growth = _game_mode == GM_EDITOR ? 3 : 0;
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   293
						switch (GetClearGround(tile)) {
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   294
							case CLEAR_ROUGH: MakeTree(tile, treetype, 0, growth, TREE_GROUND_ROUGH, 0); break;
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   295
							case CLEAR_SNOW:  MakeTree(tile, treetype, 0, growth, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break;
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   296
							default:          MakeTree(tile, treetype, 0, growth, TREE_GROUND_GRASS, 0); break;
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   297
						}
3003
821180e49591 (svn r3583) Fix 2 glitches in r3556
tron
parents: 2981
diff changeset
   298
						MarkTileDirtyByTile(tile);
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   299
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   300
						if (_game_mode == GM_EDITOR && IS_INT_INSIDE(treetype, TREE_RAINFOREST, TREE_CACTUS))
3379
50b253bb9819 (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
   301
							SetTropicZone(tile, TROPICZONE_RAINFOREST);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
					}
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   303
					cost.AddCost(_price.build_trees);
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   304
					break;
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   305
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   306
				default:
3183
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3144
diff changeset
   307
					msg = STR_2804_SITE_UNSUITABLE;
1286
10b9fe28effc (svn r1790) Make CmdPlantTree() and related functions more safe and (hopefully) more readable:
tron
parents: 1209
diff changeset
   308
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   312
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   313
	if (cost.GetCost() == 0) {
3183
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3144
diff changeset
   314
		return_cmd_error(msg);
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3144
diff changeset
   315
	} else {
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3144
diff changeset
   316
		return cost;
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3144
diff changeset
   317
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   320
struct TreeListEnt {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   321
	SpriteID image;
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   322
	SpriteID pal;
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6427
diff changeset
   323
	byte x, y;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   324
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
static void DrawTile_Trees(TileInfo *ti)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
{
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   328
	const PalSpriteID *s;
2654
1370de8783d3 (svn r3196) Use structs instead of magic offsets into arrays
tron
parents: 2644
diff changeset
   329
	const TreePos* d;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
	byte z;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   332
	switch (GetTreeGround(ti->tile)) {
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   333
		case TREE_GROUND_GRASS: DrawClearLandTile(ti, 3); break;
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   334
		case TREE_GROUND_ROUGH: DrawHillyLandTile(ti); break;
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   335
		default: DrawGroundSprite(_tree_sprites_1[GetTreeDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
2220
cacd492f3c1c (svn r2738) Small bit fiddling cleanup
tron
parents: 2186
diff changeset
   338
	DrawClearLandFence(ti);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
	z = ti->z;
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   341
	if (ti->tileh != SLOPE_FLAT) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
		z += 4;
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   343
		if (IsSteepSlope(ti->tileh)) z += 4;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
		uint16 tmp = ti->x;
959
e6a3bbda610f (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 926
diff changeset
   348
		uint index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   350
		tmp = ROR(tmp, 2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
		tmp -= ti->y;
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   352
		tmp = ROR(tmp, 3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
		tmp -= ti->x;
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   354
		tmp = ROR(tmp, 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
		tmp += ti->y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   357
		d = _tree_layout_xy[GB(tmp, 4, 2)];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   359
		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
   360
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
		/* different tree styles above one of the grounds */
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   362
		if (GetTreeGround(ti->tile) == TREE_GROUND_SNOW_DESERT &&
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   363
				GetTreeDensity(ti->tile) >= 2 &&
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   364
				IS_INT_INSIDE(index, TREE_SUB_ARCTIC << 2, TREE_RAINFOREST << 2)) {
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   365
			index += 164 - (TREE_SUB_ARCTIC << 2);
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   366
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   367
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   368
		assert(index < lengthof(_tree_layout_sprite));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
		s = _tree_layout_sprite[index];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
	StartSpriteCombine();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
6427
7dc1012757d8 (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: 6422
diff changeset
   374
	if (!HASBIT(_transparent_opt, TO_TREES) || !_patches.invisible_trees) {
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   375
		TreeListEnt te[4];
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   376
		uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
		/* put the trees to draw in a list */
3271
114243e3465f (svn r3983) Use existing functions to access tree and road info
tron
parents: 3183
diff changeset
   379
		i = GetTreeCount(ti->tile) + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
		do {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   381
			SpriteID image = s[0].sprite + (--i == 0 ? GetTreeGrowth(ti->tile) : 3);
7333
e48228e44be8 (svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents: 7317
diff changeset
   382
			SpriteID pal = s[0].pal;
e48228e44be8 (svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents: 7317
diff changeset
   383
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
			te[i].image = image;
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   385
			te[i].pal   = pal;
2654
1370de8783d3 (svn r3196) Use structs instead of magic offsets into arrays
tron
parents: 2644
diff changeset
   386
			te[i].x = d->x;
1370de8783d3 (svn r3196) Use structs instead of magic offsets into arrays
tron
parents: 2644
diff changeset
   387
			te[i].y = d->y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
			s++;
2654
1370de8783d3 (svn r3196) Use structs instead of magic offsets into arrays
tron
parents: 2644
diff changeset
   389
			d++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
		} while (i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
		/* draw them in a sorted way */
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2912
diff changeset
   393
		for (;;) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
			byte min = 0xFF;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
			TreeListEnt *tep = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
3271
114243e3465f (svn r3983) Use existing functions to access tree and road info
tron
parents: 3183
diff changeset
   397
			i = GetTreeCount(ti->tile) + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
			do {
2644
58206d08cf9d (svn r3186) Unnecessary casts and truncation
tron
parents: 2639
diff changeset
   399
				if (te[--i].image != 0 && te[i].x + te[i].y < min) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
					min = te[i].x + te[i].y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
					tep = &te[i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
			} while (i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   405
			if (tep == NULL) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
7333
e48228e44be8 (svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents: 7317
diff changeset
   407
			AddSortableSpriteToDraw(tep->image, tep->pal, ti->x + tep->x, ti->y + tep->y, 5, 5, 0x10, z, HASBIT(_transparent_opt, TO_TREES));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
			tep->image = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
	EndSpriteCombine();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
4231
2823b3643862 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4157
diff changeset
   416
static uint GetSlopeZ_Trees(TileIndex tile, uint x, uint y)
2537
5e4ca74e995a (svn r3066) Constify the parameter of GetSlopeZ_*()
tron
parents: 2436
diff changeset
   417
{
4231
2823b3643862 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4157
diff changeset
   418
	uint z;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   419
	Slope tileh = GetTileSlope(tile, &z);
4231
2823b3643862 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4157
diff changeset
   420
2823b3643862 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4157
diff changeset
   421
	return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
7335
141c6b86ec1f (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: 7333
diff changeset
   424
static Foundation GetFoundation_Trees(TileIndex tile, Slope tileh)
2548
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2537
diff changeset
   425
{
7335
141c6b86ec1f (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: 7333
diff changeset
   426
	return FOUNDATION_NONE;
39
d177340ed556 (svn r40) Final slope graphics fix
dominik
parents: 0
diff changeset
   427
}
d177340ed556 (svn r40) Final slope graphics fix
dominik
parents: 0
diff changeset
   428
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6683
diff changeset
   429
static CommandCost ClearTile_Trees(TileIndex tile, byte flags)
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   430
{
2243
b7e58afa3616 (svn r2763) Small cleanup and improve a few comments
tron
parents: 2238
diff changeset
   431
	uint num;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
4850
93095755db8c (svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents: 4559
diff changeset
   433
	if ((flags & DC_EXEC) && IsValidPlayer(_current_player)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
		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
   435
		if (t != NULL)
1005
f48b2bdd84fc (svn r1504) enummed town ratings (Jango)
celestar
parents: 988
diff changeset
   436
			ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   439
	num = GetTreeCount(tile) + 1;
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   440
	if (IS_INT_INSIDE(GetTreeType(tile), TREE_RAINFOREST, TREE_CACTUS)) num *= 4;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
2243
b7e58afa3616 (svn r2763) Small cleanup and improve a few comments
tron
parents: 2238
diff changeset
   442
	if (flags & DC_EXEC) DoClearSquare(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   444
	return CommandCost(num * _price.remove_trees);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   447
static void GetAcceptedCargo_Trees(TileIndex tile, AcceptedCargo ac)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
	/* not used */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   452
static void GetTileDesc_Trees(TileIndex tile, TileDesc *td)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
{
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   454
	TreeType tt = GetTreeType(tile);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   455
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   456
	if (IS_INT_INSIDE(tt, TREE_RAINFOREST, TREE_CACTUS)) {
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   457
		td->str = STR_280F_RAINFOREST;
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   458
	} else if (tt == TREE_CACTUS) {
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   459
		td->str = STR_2810_CACTUS_PLANTS;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   460
	} else {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   461
		td->str = STR_280E_TREES;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   462
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
1901
03bf9bf99319 (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
   464
	td->owner = GetTileOwner(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   467
static void AnimateTile_Trees(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
	/* not used */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   472
static void TileLoopTreesDesert(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
{
3379
50b253bb9819 (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
   474
	switch (GetTropicZone(tile)) {
50b253bb9819 (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
   475
		case TROPICZONE_DESERT:
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   476
			if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT) {
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   477
				SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, 3);
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   478
				MarkTileDirtyByTile(tile);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   479
			}
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   480
			break;
2243
b7e58afa3616 (svn r2763) Small cleanup and improve a few comments
tron
parents: 2238
diff changeset
   481
3379
50b253bb9819 (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
   482
		case TROPICZONE_RAINFOREST: {
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   483
			static const SoundFx forest_sounds[] = {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   484
				SND_42_LOON_BIRD,
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   485
				SND_43_LION,
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   486
				SND_44_MONKEYS,
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   487
				SND_48_DISTANT_BIRD
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   488
			};
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   489
			uint32 r = Random();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   491
			if (CHANCE16I(1, 200, r)) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   492
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
		}
3379
50b253bb9819 (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
   494
50b253bb9819 (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
   495
		default: break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   499
static void TileLoopTreesAlps(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
{
6343
76d17f784c13 (svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents: 6248
diff changeset
   501
	int k = GetTileZ(tile) - GetSnowLine() + TILE_HEIGHT;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
4157
8d0051fdde68 (svn r5581) Slightly alter some snow line related calculations to make them a bit clearer
tron
parents: 3977
diff changeset
   503
	if (k < 0) {
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   504
		if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT) return;
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   505
		SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
	} else {
4157
8d0051fdde68 (svn r5581) Slightly alter some snow line related calculations to make them a bit clearer
tron
parents: 3977
diff changeset
   507
		uint density = min((uint)k / TILE_HEIGHT, 3);
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   508
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   509
		if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT ||
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   510
				GetTreeDensity(tile) != density) {
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   511
			SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, density);
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   512
		} else {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   513
			if (GetTreeDensity(tile) == 3) {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   514
				uint32 r = Random();
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   515
				if (CHANCE16I(1, 200, r)) {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   516
					SndPlayTileFx((r & 0x80000000) ? SND_39_HEAVY_WIND : SND_34_WIND, tile);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   517
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
	MarkTileDirtyByTile(tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   525
static void TileLoop_Trees(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
{
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   527
	switch (_opt.landscape) {
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   528
		case LT_TROPIC: TileLoopTreesDesert(tile); break;
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   529
		case LT_ARCTIC: TileLoopTreesAlps(tile);   break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
	TileLoopClearHelper(tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   534
	if (GetTreeCounter(tile) < 15) {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   535
		AddTreeCounter(tile, 1);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   536
		return;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   537
	}
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   538
	SetTreeCounter(tile, 0);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   539
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   540
	switch (GetTreeGrowth(tile)) {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   541
		case 3: /* regular sized tree */
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   542
			if (_opt.landscape == LT_TROPIC &&
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   543
					GetTreeType(tile) != TREE_CACTUS &&
3379
50b253bb9819 (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
   544
					GetTropicZone(tile) == TROPICZONE_DESERT) {
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   545
				AddTreeGrowth(tile, 1);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   546
			} else {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   547
				switch (GB(Random(), 0, 3)) {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   548
					case 0: /* start destructing */
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   549
						AddTreeGrowth(tile, 1);
2955
24de69e236d2 (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
   550
						break;
24de69e236d2 (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
   551
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   552
					case 1: /* add a tree */
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   553
						if (GetTreeCount(tile) < 3) {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   554
							AddTreeCount(tile, 1);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   555
							SetTreeGrowth(tile, 0);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   556
							break;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   557
						}
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   558
						/* FALL THROUGH */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   560
					case 2: { /* add a neighbouring tree */
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   561
						TreeType treetype = GetTreeType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
7317
e61af9d8a2b3 (svn r10672) -Codechange: typify some parameters/variables.
rubidium
parents: 6950
diff changeset
   563
						tile += TileOffsByDir((Direction)(Random() & 7));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   565
						if (!IsTileType(tile, MP_CLEAR) || IsBridgeAbove(tile)) return;
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   566
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   567
						switch (GetClearGround(tile)) {
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   568
							case CLEAR_GRASS:
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   569
								if (GetClearDensity(tile) != 3) return;
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   570
								MakeTree(tile, treetype, 0, 0, TREE_GROUND_GRASS, 0);
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   571
								break;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   572
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   573
							case CLEAR_ROUGH: MakeTree(tile, treetype, 0, 0, TREE_GROUND_ROUGH, 0); break;
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   574
							case CLEAR_SNOW:  MakeTree(tile, treetype, 0, 0, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break;
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   575
							default: return;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   576
						}
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   577
						break;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   578
					}
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   579
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   580
					default:
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   581
						return;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   582
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
			}
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   584
			break;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   585
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   586
		case 6: /* final stage of tree destruction */
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   587
			if (GetTreeCount(tile) > 0) {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   588
				/* more than one tree, delete it */
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   589
				AddTreeCount(tile, -1);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   590
				SetTreeGrowth(tile, 3);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   591
			} else {
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   592
				/* just one tree, change type into MP_CLEAR */
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   593
				switch (GetTreeGround(tile)) {
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   594
					case TREE_GROUND_GRASS: MakeClear(tile, CLEAR_GRASS, 3); break;
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   595
					case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break;
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   596
					default: MakeClear(tile, CLEAR_SNOW, GetTreeDensity(tile)); break;
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   597
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
			}
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   599
			break;
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   600
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   601
		default:
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   602
			AddTreeGrowth(tile, 1);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents: 2968
diff changeset
   603
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
	MarkTileDirtyByTile(tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6133
diff changeset
   609
void OnTick_Trees()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
	uint32 r;
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   612
	TileIndex tile;
2955
24de69e236d2 (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
   613
	ClearGround ct;
3017
a75caf4efa2d (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
   614
	TreeType tree;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   615
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   616
	/* place a tree at a random rainforest spot */
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6343
diff changeset
   617
	if (_opt.landscape == LT_TROPIC &&
3379
50b253bb9819 (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
   618
			(r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) &&
1035
812f837ee03f (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
   619
			IsTileType(tile, MP_CLEAR) &&
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   620
			!IsBridgeAbove(tile) &&
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   621
			(ct = GetClearGround(tile), ct == CLEAR_GRASS || ct == CLEAR_ROUGH) &&
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   622
			(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   623
		MakeTree(tile, tree, 0, 0, ct == CLEAR_ROUGH ? TREE_GROUND_ROUGH : TREE_GROUND_GRASS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6357
diff changeset
   626
	/* byte underflow */
2088
d7a97ef74701 (svn r2598) Small cleanup, especially get rid of a FindLandscapeHeight(), because it was overkill
tron
parents: 2085
diff changeset
   627
	if (--_trees_tick_ctr != 0) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   628
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
	/* place a tree at a random spot */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
	r = Random();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
	tile = TILE_MASK(r);
1035
812f837ee03f (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
   632
	if (IsTileType(tile, MP_CLEAR) &&
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4850
diff changeset
   633
			!IsBridgeAbove(tile) &&
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   634
			(ct = GetClearGround(tile), ct == CLEAR_GRASS || ct == CLEAR_ROUGH || ct == CLEAR_SNOW) &&
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   635
			(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
2955
24de69e236d2 (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
   636
		switch (ct) {
3447
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   637
			case CLEAR_GRASS: MakeTree(tile, tree, 0, 0, TREE_GROUND_GRASS, 0); break;
1c62c085638a (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   638
			case CLEAR_ROUGH: MakeTree(tile, tree, 0, 0, TREE_GROUND_ROUGH, 0); break;
3441
fead68bcb6a3 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3422
diff changeset
   639
			default: MakeTree(tile, tree, 0, 0, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   644
static void ClickTile_Trees(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
	/* not used */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
6683
b88ae30866ce (svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents: 6491
diff changeset
   649
static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   653
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2243
diff changeset
   654
static void ChangeTileOwner_Trees(TileIndex tile, PlayerID old_player, PlayerID new_player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   655
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   656
	/* not used */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6133
diff changeset
   659
void InitializeTrees()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   660
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
	_trees_tick_ctr = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   662
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   663
7494
ab05bad37410 (svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents: 7335
diff changeset
   664
static CommandCost TerraformTile_Trees(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
ab05bad37410 (svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents: 7335
diff changeset
   665
{
ab05bad37410 (svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents: 7335
diff changeset
   666
	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
ab05bad37410 (svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents: 7335
diff changeset
   667
}
ab05bad37410 (svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents: 7335
diff changeset
   668
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   670
extern const TileTypeProcs _tile_type_trees_procs = {
4344
7e123fec5b0b (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
   671
	DrawTile_Trees,           /* draw_tile_proc */
7e123fec5b0b (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
   672
	GetSlopeZ_Trees,          /* get_slope_z_proc */
7e123fec5b0b (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
   673
	ClearTile_Trees,          /* clear_tile_proc */
7e123fec5b0b (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
   674
	GetAcceptedCargo_Trees,   /* get_accepted_cargo_proc */
7e123fec5b0b (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
   675
	GetTileDesc_Trees,        /* get_tile_desc_proc */
7e123fec5b0b (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
   676
	GetTileTrackStatus_Trees, /* get_tile_track_status_proc */
7e123fec5b0b (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
   677
	ClickTile_Trees,          /* click_tile_proc */
7e123fec5b0b (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
   678
	AnimateTile_Trees,        /* animate_tile_proc */
7e123fec5b0b (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
   679
	TileLoop_Trees,           /* tile_loop_clear */
7e123fec5b0b (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
   680
	ChangeTileOwner_Trees,    /* change_tile_owner_clear */
7e123fec5b0b (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
   681
	NULL,                     /* get_produced_cargo_proc */
7e123fec5b0b (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
   682
	NULL,                     /* vehicle_enter_tile_proc */
7335
141c6b86ec1f (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: 7333
diff changeset
   683
	GetFoundation_Trees,      /* get_foundation_proc */
7494
ab05bad37410 (svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents: 7335
diff changeset
   684
	TerraformTile_Trees,      /* terraform_tile_proc */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
};