Fix an old optimization of off-screen rectangular invalidations.
We already had a mechanism to avoid invalidating adjacent hexes during the update of a big or not aligned off-screen sprite. But a flaw with the handling of empty intersection with the screen prevented it to fully work. (and in some cases caused few incorrect invalidations at the edge of the screen, which was very bad because it caused blitting)
This commit is contained in:
parent
41584ceb3f
commit
0ba4ffa078
1 changed files with 11 additions and 0 deletions
|
@ -381,6 +381,17 @@ const display::rect_of_hexes display::hexes_under_rect(const SDL_Rect& r) const
|
|||
{
|
||||
rect_of_hexes res;
|
||||
|
||||
if (r.w<=0 || r.h<=0) {
|
||||
// empty rect, return dummy values giving begin=end
|
||||
res.left = 0;
|
||||
res.right = -1; // end is right+1
|
||||
res.top[0] = 0;
|
||||
res.top[1] = 0;
|
||||
res.bottom[0] = 0;
|
||||
res.bottom[1] = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
SDL_Rect map_rect = map_area();
|
||||
// translate rect coordinates from screen-based to map_area-based
|
||||
int x = xpos_ - map_rect.x + r.x;
|
||||
|
|
Loading…
Add table
Reference in a new issue