… | |
… | |
884 | return 0; |
884 | return 0; |
885 | } |
885 | } |
886 | |
886 | |
887 | //-GPL |
887 | //-GPL |
888 | |
888 | |
889 | // prefetch (and touch) all maps within a specific distancd |
889 | // prefetch maps in an area of PREFETCH x PREFETCH around the player |
890 | static void |
890 | #define PREFETCH 40 |
891 | prefetch_surrounding_maps (maptile *map, int distance) |
|
|
892 | { |
|
|
893 | map->touch (); |
|
|
894 | |
|
|
895 | if (--distance) |
|
|
896 | for (int dir = 4; dir--; ) |
|
|
897 | if (const shstr &path = map->tile_path [dir]) |
|
|
898 | if (maptile *&neigh = map->tile_map [dir]) |
|
|
899 | prefetch_surrounding_maps (neigh, distance); |
|
|
900 | else |
|
|
901 | neigh = maptile::find_async (path, map); |
|
|
902 | } |
|
|
903 | |
891 | |
904 | // prefetch a generous area around the player |
892 | // prefetch a generous area around the player |
905 | static void |
893 | static void |
906 | prefetch_surrounding_maps (object *op) |
894 | prefetch_surrounding_maps (object *op) |
907 | { |
895 | { |
908 | prefetch_surrounding_maps (op->map, 3); |
896 | for (maprect *rect = op->map->split_to_tiles (mapwalk_buf, |
|
|
897 | op->x - PREFETCH , op->y - PREFETCH , |
|
|
898 | op->x + PREFETCH + 1, op->y + PREFETCH + 1); |
|
|
899 | rect->m; |
|
|
900 | ++rect) |
|
|
901 | rect->m->touch (); |
909 | } |
902 | } |
910 | |
903 | |
911 | //+GPL |
904 | //+GPL |
912 | |
905 | |
913 | /** |
906 | /** |