Mercurial > hg > openttd
changeset 9534:564d5fd5a247 draft
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
author | frosch <frosch@openttd.org> |
---|---|
date | Mon, 16 Jun 2008 20:08:30 +0000 |
parents | 176a9fe1018f |
children | bacc4ca0dd38 |
files | src/viewport.cpp |
diffstat | 1 files changed, 18 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -80,7 +80,7 @@ const SubSprite *sub; ///< only draw a rectangular part of the sprite int32 x; int32 y; - ChildScreenSpriteToDraw *next; + int next; ///< next child to draw (-1 at the end) }; struct ParentSpriteToDraw { @@ -102,7 +102,6 @@ int zmax; ///< maximal world Z coordinate of bounding box int first_child; ///< the first child to draw. - int last_child; ///< the last sprite to draw. bool comparison_done; ///< Used during sprite sorting: true if sprite has been compared with all other sprites }; @@ -676,10 +675,9 @@ ps->zmax = z + max(bb_offset_z, dz) - 1; ps->comparison_done = false; - ps->first_child = _vd.child_screen_sprites_to_draw.items; - ps->last_child = _vd.child_screen_sprites_to_draw.items; - - _vd.last_child = &ps->last_child; + ps->first_child = -1; + + _vd.last_child = &ps->first_child; if (_vd.combine_sprites == 1) _vd.combine_sprites = 2; } @@ -717,17 +715,22 @@ pal = PALETTE_TO_TRANSPARENT; } - /* Append the sprite to the active ChildSprite list. - * If the active ParentSprite is a foundation, update last_foundation_child as well. */ + *_vd.last_child = _vd.child_screen_sprites_to_draw.items; + ChildScreenSpriteToDraw *cs = _vd.child_screen_sprites_to_draw.Append(); cs->image = image; cs->pal = pal; cs->sub = sub; cs->x = x; cs->y = y; - cs->next = NULL; - - *_vd.last_child = _vd.child_screen_sprites_to_draw.items; + cs->next = -1; + + /* Append the sprite to the active ChildSprite list. + * If the active ParentSprite is a foundation, update last_foundation_child as well. + * Note: ChildSprites of foundations are NOT sequential in the vector, as selection sprites are added at last. */ + if (_vd.last_foundation_child[0] == _vd.last_child) _vd.last_foundation_child[0] = &cs->next; + if (_vd.last_foundation_child[1] == _vd.last_child) _vd.last_foundation_child[1] = &cs->next; + _vd.last_child = &cs->next; } /* Returns a StringSpriteToDraw */ @@ -1350,8 +1353,10 @@ const ParentSpriteToDraw *ps = *it; if (ps->image != SPR_EMPTY_BOUNDING_BOX) DrawSprite(ps->image, ps->pal, ps->x, ps->y, ps->sub); - const ChildScreenSpriteToDraw *last = csstdv->Get(ps->last_child); - for (const ChildScreenSpriteToDraw *cs = csstdv->Get(ps->first_child); cs != last; cs++) { + int child_idx = ps->first_child; + while (child_idx >= 0) { + const ChildScreenSpriteToDraw *cs = csstdv->Get(child_idx); + child_idx = cs->next; DrawSprite(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub); } }