--- a/src/viewport.cpp Tue Jun 17 10:32:49 2008 +0000
+++ b/src/viewport.cpp Tue Jun 17 13:22:13 2008 +0000
@@ -81,7 +81,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 {
@@ -103,7 +103,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
};
@@ -677,10 +676,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;
}
@@ -718,17 +716,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 */
@@ -1375,8 +1378,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);
}
}
@@ -1895,7 +1900,7 @@
y < si->sign.top + 12 &&
x >= si->sign.left &&
x < si->sign.left + si->sign.width_1) {
- ShowRenameSignWindow(si);
+ HandleClickOnSign(si);
return true;
}
}
@@ -1909,7 +1914,7 @@
y < si->sign.top + 24 &&
x >= si->sign.left &&
x < si->sign.left + si->sign.width_1 * 2) {
- ShowRenameSignWindow(si);
+ HandleClickOnSign(si);
return true;
}
}
@@ -1925,7 +1930,7 @@
y < si->sign.top + ScaleByZoom(12, vp->zoom) &&
x >= si->sign.left &&
x < si->sign.left + ScaleByZoom(si->sign.width_2, vp->zoom)) {
- ShowRenameSignWindow(si);
+ HandleClickOnSign(si);
return true;
}
}