|
@@ -75,25 +75,25 @@ static void DoPlaceMoreTrees(TileIndex t
|
|
|
|
|
|
/* Only on tiles within 13 squares from tile,
|
|
|
on clear tiles, and NOT on farm-tiles or rocks */
|
|
|
if (dist <= 13 && IsTileType(cur_tile, MP_CLEAR) &&
|
|
|
(_m[cur_tile].m5 & 0x1F) != 0x0F && (_m[cur_tile].m5 & 0x1C) != 8) {
|
|
|
PlaceTree(cur_tile, r, dist <= 6 ? 0xC0 : 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static void PlaceMoreTrees(void)
|
|
|
{
|
|
|
uint i = ScaleByMapSize((Random() & 0x1F) + 25);
|
|
|
uint i = ScaleByMapSize(GB(Random(), 0, 5) + 25);
|
|
|
do {
|
|
|
DoPlaceMoreTrees(RandomTile());
|
|
|
} while (--i);
|
|
|
}
|
|
|
|
|
|
void PlaceTreesRandomly(void)
|
|
|
{
|
|
|
uint i;
|
|
|
|
|
|
i = ScaleByMapSize(1000);
|
|
|
do {
|
|
|
uint32 r = Random();
|
|
@@ -296,25 +296,25 @@ static void DrawTile_Trees(TileInfo *ti)
|
|
|
s = _tree_layout_sprite[index];
|
|
|
}
|
|
|
|
|
|
StartSpriteCombine();
|
|
|
|
|
|
if (!(_display_opt & DO_TRANS_BUILDINGS) || !_patches.invisible_trees) {
|
|
|
TreeListEnt te[4];
|
|
|
uint i;
|
|
|
|
|
|
/* put the trees to draw in a list */
|
|
|
i = (ti->map5 >> 6) + 1;
|
|
|
do {
|
|
|
uint32 image = s[0] + (--i == 0 ? (ti->map5 & 7) : 3);
|
|
|
uint32 image = s[0] + (--i == 0 ? GB(ti->map5, 0, 3) : 3);
|
|
|
if (_display_opt & DO_TRANS_BUILDINGS)
|
|
|
MAKE_TRANSPARENT(image);
|
|
|
te[i].image = image;
|
|
|
te[i].x = d[0];
|
|
|
te[i].y = d[1];
|
|
|
s++;
|
|
|
d += 2;
|
|
|
} while (i);
|
|
|
|
|
|
/* draw them in a sorted way */
|
|
|
for(;;) {
|
|
|
byte min = 0xFF;
|
|
@@ -340,38 +340,36 @@ static void DrawTile_Trees(TileInfo *ti)
|
|
|
|
|
|
|
|
|
static uint GetSlopeZ_Trees(TileInfo *ti) {
|
|
|
return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
|
|
|
}
|
|
|
|
|
|
static uint GetSlopeTileh_Trees(TileInfo *ti) {
|
|
|
return ti->tileh;
|
|
|
}
|
|
|
|
|
|
static int32 ClearTile_Trees(TileIndex tile, byte flags)
|
|
|
{
|
|
|
int num;
|
|
|
uint num;
|
|
|
|
|
|
if (flags & DC_EXEC && _current_player < MAX_PLAYERS) {
|
|
|
Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
|
|
|
if (t != NULL)
|
|
|
ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
|
|
|
}
|
|
|
|
|
|
num = (_m[tile].m5 >> 6) + 1;
|
|
|
if ( (byte)(_m[tile].m3-0x14) <= (0x1A-0x14))
|
|
|
num <<= 2;
|
|
|
num = GB(_m[tile].m5, 6, 2) + 1;
|
|
|
if (IS_INT_INSIDE(_m[tile].m3, 20, 26 + 1)) num *= 4;
|
|
|
|
|
|
if (flags & DC_EXEC)
|
|
|
DoClearSquare(tile);
|
|
|
if (flags & DC_EXEC) DoClearSquare(tile);
|
|
|
|
|
|
return num * _price.remove_trees;
|
|
|
}
|
|
|
|
|
|
static void GetAcceptedCargo_Trees(TileIndex tile, AcceptedCargo ac)
|
|
|
{
|
|
|
/* not used */
|
|
|
}
|
|
|
|
|
|
static void GetTileDesc_Trees(TileIndex tile, TileDesc *td)
|
|
|
{
|
|
|
byte b;
|
|
@@ -382,85 +380,79 @@ static void GetTileDesc_Trees(TileIndex
|
|
|
b = _m[tile].m3;
|
|
|
(str=STR_2810_CACTUS_PLANTS, b==0x1B) ||
|
|
|
(str=STR_280F_RAINFOREST, IS_BYTE_INSIDE(b, 0x14, 0x1A+1)) ||
|
|
|
(str=STR_280E_TREES, true);
|
|
|
td->str = str;
|
|
|
}
|
|
|
|
|
|
static void AnimateTile_Trees(TileIndex tile)
|
|
|
{
|
|
|
/* not used */
|
|
|
}
|
|
|
|
|
|
static SoundFx _desert_sounds[] = {
|
|
|
static void TileLoopTreesDesert(TileIndex tile)
|
|
|
{
|
|
|
static const SoundFx forest_sounds[] = {
|
|
|
SND_42_LOON_BIRD,
|
|
|
SND_43_LION,
|
|
|
SND_44_MONKEYS,
|
|
|
SND_48_DISTANT_BIRD
|
|
|
};
|
|
|
|
|
|
static void TileLoopTreesDesert(TileIndex tile)
|
|
|
{
|
|
|
byte b;
|
|
|
byte b = GetMapExtraBits(tile);
|
|
|
|
|
|
b = GetMapExtraBits(tile);
|
|
|
if (b == 2) {
|
|
|
uint32 r = Random();
|
|
|
|
|
|
if (CHANCE16I(1,200, r)) SndPlayTileFx(_desert_sounds[GB(r, 16, 2)], tile);
|
|
|
if (CHANCE16I(1, 200, r)) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile);
|
|
|
} else if (b == 1) {
|
|
|
if ((_m[tile].m2 & 0x30) != 0x20) {
|
|
|
_m[tile].m2 &= 0xF;
|
|
|
_m[tile].m2 |= 0xE0;
|
|
|
if (GB(_m[tile].m2, 4, 2) != 2) {
|
|
|
SB(_m[tile].m2, 4, 2, 2);
|
|
|
SB(_m[tile].m2, 6, 2, 3);
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static void TileLoopTreesAlps(TileIndex tile)
|
|
|
{
|
|
|
byte tmp, m2;
|
|
|
int k;
|
|
|
|
|
|
/* distance from snow line, in steps of 8 */
|
|
|
k = GetTileZ(tile) - _opt.snow_line;
|
|
|
|
|
|
tmp = _m[tile].m2 & 0xF0;
|
|
|
|
|
|
if (k < -8) {
|
|
|
/* snow_m2_down */
|
|
|
if ((tmp & 0x30) != 0x20) return;
|
|
|
m2 = 0;
|
|
|
m2 = 0; // no snow
|
|
|
} else if (k == -8) {
|
|
|
/* snow_m1 */
|
|
|
m2 = 0x20;
|
|
|
m2 = 0x20; // 1/4 snow
|
|
|
if (tmp == m2) return;
|
|
|
} else if (k < 8) {
|
|
|
/* snow_0 */
|
|
|
m2 = 0x60;
|
|
|
} else if (k == 0) {
|
|
|
m2 = 0x60;// 1/2 snow
|
|
|
if (tmp == m2) return;
|
|
|
} else if (k == 8) {
|
|
|
/* snow_p1 */
|
|
|
m2 = 0xA0;
|
|
|
m2 = 0xA0; // 3/4 snow
|
|
|
if (tmp == m2) return;
|
|
|
} else {
|
|
|
/* snow_p2_up */
|
|
|
if (tmp == 0xE0) {
|
|
|
uint32 r = Random();
|
|
|
if (CHANCE16I(1,200,r)) {
|
|
|
SndPlayTileFx((r & 0x80000000) ? SND_39_HEAVY_WIND : SND_34_WIND, tile);
|
|
|
}
|
|
|
return;
|
|
|
} else {
|
|
|
m2 = 0xE0;
|
|
|
m2 = 0xE0; // full snow
|
|
|
}
|
|
|
}
|
|
|
|
|
|
_m[tile].m2 &= 0xF;
|
|
|
_m[tile].m2 |= m2;
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
}
|
|
|
|
|
|
static void TileLoop_Trees(TileIndex tile)
|
|
|
{
|
|
|
byte m5;
|
|
|
uint16 m2;
|