branch | noai |
changeset 9722 | ebf0ece7d8f6 |
parent 9718 | f82a4facea8b |
child 9723 | eee46cb39750 |
9721:9a27928bcd5e | 9722:ebf0ece7d8f6 |
---|---|
18 #include "command.h" |
18 #include "command.h" |
19 #include "town.h" |
19 #include "town.h" |
20 #include "sound.h" |
20 #include "sound.h" |
21 #include "variables.h" |
21 #include "variables.h" |
22 #include "genworld.h" |
22 #include "genworld.h" |
23 #include "transparency.h" |
|
23 |
24 |
24 /** |
25 /** |
25 * List of tree placer algorithm. |
26 * List of tree placer algorithm. |
26 * |
27 * |
27 * This enumeration defines all possible tree placer algorithm in the game. |
28 * This enumeration defines all possible tree placer algorithm in the game. |
106 |
107 |
107 for (i = 0; i < 1000; i++) { |
108 for (i = 0; i < 1000; i++) { |
108 uint32 r = Random(); |
109 uint32 r = Random(); |
109 int x = GB(r, 0, 5) - 16; |
110 int x = GB(r, 0, 5) - 16; |
110 int y = GB(r, 8, 5) - 16; |
111 int y = GB(r, 8, 5) - 16; |
111 uint dist = myabs(x) + myabs(y); |
112 uint dist = abs(x) + abs(y); |
112 TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y)); |
113 TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y)); |
113 |
114 |
114 if (dist <= 13 && |
115 if (dist <= 13 && |
115 IsTileType(cur_tile, MP_CLEAR) && |
116 IsTileType(cur_tile, MP_CLEAR) && |
116 !IsBridgeAbove(cur_tile) && |
117 !IsBridgeAbove(cur_tile) && |
152 int x = GB(r, 0, 5) - 16; |
153 int x = GB(r, 0, 5) - 16; |
153 int y = GB(r, 8, 5) - 16; |
154 int y = GB(r, 8, 5) - 16; |
154 TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y)); |
155 TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y)); |
155 |
156 |
156 /* Keep in range of the existing tree */ |
157 /* Keep in range of the existing tree */ |
157 if (myabs(x) + myabs(y) > 16) continue; |
158 if (abs(x) + abs(y) > 16) continue; |
158 |
159 |
159 /* Clear tile, no farm-tiles or rocks */ |
160 /* Clear tile, no farm-tiles or rocks */ |
160 if (!IsTileType(cur_tile, MP_CLEAR) || |
161 if (!IsTileType(cur_tile, MP_CLEAR) || |
161 IsClearGround(cur_tile, CLEAR_FIELDS) || |
162 IsClearGround(cur_tile, CLEAR_FIELDS) || |
162 IsClearGround(cur_tile, CLEAR_ROCKS)) |
163 IsClearGround(cur_tile, CLEAR_ROCKS)) |
425 s = _tree_layout_sprite[index]; |
426 s = _tree_layout_sprite[index]; |
426 } |
427 } |
427 |
428 |
428 StartSpriteCombine(); |
429 StartSpriteCombine(); |
429 |
430 |
430 if (!HASBIT(_transparent_opt, TO_TREES) || !_patches.invisible_trees) { |
431 if (!(IsTransparencySet(TO_TREES) && _patches.invisible_trees)) { |
431 TreeListEnt te[4]; |
432 TreeListEnt te[4]; |
432 uint i; |
433 uint i; |
433 |
434 |
434 /* put the trees to draw in a list */ |
435 /* put the trees to draw in a list */ |
435 i = GetTreeCount(ti->tile) + 1; |
436 i = GetTreeCount(ti->tile) + 1; |
458 } |
459 } |
459 } while (i); |
460 } while (i); |
460 |
461 |
461 if (tep == NULL) break; |
462 if (tep == NULL) break; |
462 |
463 |
463 AddSortableSpriteToDraw(tep->image, tep->pal, ti->x + tep->x, ti->y + tep->y, 16 - tep->x, 16 - tep->y, 0x30, z, HASBIT(_transparent_opt, TO_TREES), -tep->x, -tep->y); |
464 AddSortableSpriteToDraw(tep->image, tep->pal, ti->x + tep->x, ti->y + tep->y, 16 - tep->x, 16 - tep->y, 0x30, z, IsTransparencySet(TO_TREES), -tep->x, -tep->y); |
464 tep->image = 0; |
465 tep->image = 0; |
465 } |
466 } |
466 } |
467 } |
467 |
468 |
468 EndSpriteCombine(); |
469 EndSpriteCombine(); |