]> err.no Git - mapper/commitdiff
Bail instantly if the requested tile to render is outside our current view.
authorKaj-Michael Lang <milang@tal.org>
Tue, 18 Mar 2008 11:17:24 +0000 (13:17 +0200)
committerKaj-Michael Lang <milang@tal.org>
Tue, 18 Mar 2008 11:17:24 +0000 (13:17 +0200)
src/map.c

index 0e58605a5123d0eb83b331c746445e70fb74b503..93c6b7e01c6d0922fe34cde9e1223c32a05eb4f7 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -438,29 +438,30 @@ map_render_tile(guint tilex, guint tiley, guint destx, guint desty, gboolean fas
 GdkPixbuf *pixbuf=NULL;
 gint zoff;
 
-g_debug("MAP RT: %d %d %d %d (%d, %d)", tilex, tiley, destx, desty, buf_width_tiles, buf_height_tiles);
-
 if (destx > buf_width_pixels || desty > buf_height_pixels)
        return FALSE;
 
-if (tilex<_world_size_tiles && tiley<_world_size_tiles) {
-       /* The tile is possible. */
-       for (zoff = (_curr_repo->double_size ? 1 : 0); !pixbuf && (_zoom + zoff) <= MAX_ZOOM && zoff <= TILE_SIZE_P2; zoff += 1) {
-               pixbuf=map_tile_load(tilex, tiley, zoff, !fast_fail);
-               if (!pixbuf) {
-                       if (!fast_fail)
-                               fast_fail=TRUE;
-               } else {
-                       /* Check if we need to trim. */
-                       if (gdk_pixbuf_get_width(pixbuf) != TILE_SIZE_PIXELS || gdk_pixbuf_get_height(pixbuf) != TILE_SIZE_PIXELS)
-                               pixbuf = pixbuf_trim(pixbuf);
-
-                       /* Check if we need to blit. */
-                       if (zoff) {
-                               map_pixbuf_scale_inplace(pixbuf, zoff,
-                                                (tilex - ((tilex >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff),
-                                                (tiley - ((tiley >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff));
-                       }
+if (tilex > _world_size_tiles || tiley > _world_size_tiles)
+       return FALSE;
+
+g_debug("MAP RT: %u %u (%u) %u %u (%u, %u)", tilex, tiley, _world_size_tiles, destx, desty, buf_width_tiles, buf_height_tiles);
+
+/* The tile is possible. */
+for (zoff = (_curr_repo->double_size ? 1 : 0); !pixbuf && (_zoom + zoff) <= MAX_ZOOM && zoff <= TILE_SIZE_P2; zoff += 1) {
+       pixbuf=map_tile_load(tilex, tiley, zoff, !fast_fail);
+       if (!pixbuf) {
+               if (!fast_fail)
+                       fast_fail=TRUE;
+       } else {
+               /* Check if we need to trim. */
+               if (gdk_pixbuf_get_width(pixbuf) != TILE_SIZE_PIXELS || gdk_pixbuf_get_height(pixbuf) != TILE_SIZE_PIXELS)
+                       pixbuf = pixbuf_trim(pixbuf);
+
+               /* Check if we need to blit. */
+               if (zoff) {
+                       map_pixbuf_scale_inplace(pixbuf, zoff,
+                                        (tilex - ((tilex >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff),
+                                        (tiley - ((tiley >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff));
                }
        }
 }