mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r12073) -Codechange: stop drawing trees a bit earlier when they are invisible
This commit is contained in:
parent
918591c05b
commit
c0c9b80db3
@ -448,6 +448,9 @@ static void DrawTile_Trees(TileInfo *ti)
|
|||||||
|
|
||||||
DrawClearLandFence(ti);
|
DrawClearLandFence(ti);
|
||||||
|
|
||||||
|
/* Do not draw trees when the invisible trees patch and transparency tree are set */
|
||||||
|
if (IsTransparencySet(TO_TREES) && _patches.invisible_trees) return;
|
||||||
|
|
||||||
z = ti->z;
|
z = ti->z;
|
||||||
if (ti->tileh != SLOPE_FLAT) {
|
if (ti->tileh != SLOPE_FLAT) {
|
||||||
z += 4;
|
z += 4;
|
||||||
@ -482,43 +485,40 @@ static void DrawTile_Trees(TileInfo *ti)
|
|||||||
|
|
||||||
StartSpriteCombine();
|
StartSpriteCombine();
|
||||||
|
|
||||||
/* Do not draw trees when the invisible trees patch and transparency tree are set */
|
TreeListEnt te[4];
|
||||||
if (!(IsTransparencySet(TO_TREES) && _patches.invisible_trees)) {
|
uint i;
|
||||||
TreeListEnt te[4];
|
|
||||||
uint i;
|
/* put the trees to draw in a list */
|
||||||
|
i = GetTreeCount(ti->tile) + 1;
|
||||||
|
do {
|
||||||
|
SpriteID image = s[0].sprite + (--i == 0 ? GetTreeGrowth(ti->tile) : 3);
|
||||||
|
SpriteID pal = s[0].pal;
|
||||||
|
|
||||||
|
te[i].image = image;
|
||||||
|
te[i].pal = pal;
|
||||||
|
te[i].x = d->x;
|
||||||
|
te[i].y = d->y;
|
||||||
|
s++;
|
||||||
|
d++;
|
||||||
|
} while (i);
|
||||||
|
|
||||||
|
/* draw them in a sorted way */
|
||||||
|
for (;;) {
|
||||||
|
byte min = 0xFF;
|
||||||
|
TreeListEnt *tep = NULL;
|
||||||
|
|
||||||
/* put the trees to draw in a list */
|
|
||||||
i = GetTreeCount(ti->tile) + 1;
|
i = GetTreeCount(ti->tile) + 1;
|
||||||
do {
|
do {
|
||||||
SpriteID image = s[0].sprite + (--i == 0 ? GetTreeGrowth(ti->tile) : 3);
|
if (te[--i].image != 0 && te[i].x + te[i].y < min) {
|
||||||
SpriteID pal = s[0].pal;
|
min = te[i].x + te[i].y;
|
||||||
|
tep = &te[i];
|
||||||
te[i].image = image;
|
}
|
||||||
te[i].pal = pal;
|
|
||||||
te[i].x = d->x;
|
|
||||||
te[i].y = d->y;
|
|
||||||
s++;
|
|
||||||
d++;
|
|
||||||
} while (i);
|
} while (i);
|
||||||
|
|
||||||
/* draw them in a sorted way */
|
if (tep == NULL) break;
|
||||||
for (;;) {
|
|
||||||
byte min = 0xFF;
|
|
||||||
TreeListEnt *tep = NULL;
|
|
||||||
|
|
||||||
i = GetTreeCount(ti->tile) + 1;
|
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);
|
||||||
do {
|
tep->image = 0;
|
||||||
if (te[--i].image != 0 && te[i].x + te[i].y < min) {
|
|
||||||
min = te[i].x + te[i].y;
|
|
||||||
tep = &te[i];
|
|
||||||
}
|
|
||||||
} while (i);
|
|
||||||
|
|
||||||
if (tep == NULL) break;
|
|
||||||
|
|
||||||
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);
|
|
||||||
tep->image = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EndSpriteCombine();
|
EndSpriteCombine();
|
||||||
|
Loading…
Reference in New Issue
Block a user