summaryrefslogtreecommitdiff
path: root/viewport.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-07-29 13:06:00 +0000
committertron <tron@openttd.org>2006-07-29 13:06:00 +0000
commitb3ab20fccb45f41f4e2d7a968bb32eec92b53c73 (patch)
tree81011765145ba6a878b7ee703fc81005366ae450 /viewport.c
parent711794031c54e8ab5c0999c9704845f171ef1195 (diff)
downloadopenttd-b3ab20fccb45f41f4e2d7a968bb32eec92b53c73.tar.xz
(svn r5631) Don't allocate memory for information about a sprite which isn't drawn
Diffstat (limited to 'viewport.c')
-rw-r--r--viewport.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/viewport.c b/viewport.c
index b1c3173fe..eb0cbe51e 100644
--- a/viewport.c
+++ b/viewport.c
@@ -463,6 +463,15 @@ void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz,
return;
}
+ pt = RemapCoords(x, y, z);
+ spr = GetSprite(image & SPRITE_MASK);
+ if ((ps->left = (pt.x += spr->x_offs)) >= vd->dpi.left + vd->dpi.width ||
+ (ps->right = (pt.x + spr->width )) <= vd->dpi.left ||
+ (ps->top = (pt.y += spr->y_offs)) >= vd->dpi.top + vd->dpi.height ||
+ (ps->bottom = (pt.y + spr->height)) <= vd->dpi.top) {
+ return;
+ }
+
vd->spritelist_mem += sizeof(ParentSpriteToDraw);
ps->image = image;
@@ -475,16 +484,6 @@ void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz,
ps->zmin = z;
ps->zmax = z + dz - 1;
- pt = RemapCoords(x, y, z);
-
- spr = GetSprite(image & SPRITE_MASK);
- if ((ps->left = (pt.x += spr->x_offs)) >= vd->dpi.left + vd->dpi.width ||
- (ps->right = (pt.x + spr->width )) <= vd->dpi.left ||
- (ps->top = (pt.y += spr->y_offs)) >= vd->dpi.top + vd->dpi.height ||
- (ps->bottom = (pt.y + spr->height)) <= vd->dpi.top) {
- return;
- }
-
ps->unk16 = 0;
ps->child = NULL;
vd->last_child = &ps->child;