--- deliantra/server/socket/request.C 2007/01/08 18:18:36 1.61 +++ deliantra/server/socket/request.C 2007/01/10 01:16:54 1.62 @@ -1554,6 +1554,28 @@ return result; } +// prefetch (and touch) all maps within a specific distancd +static void +prefetch_surrounding_maps (maptile *map, int distance) +{ + map->last_access = runtime; + + if (--distance) + for (int dir = 4; --dir; ) + if (const shstr &path = map->tile_path [dir]) + if (maptile *&neigh = map->tile_map [dir]) + prefetch_surrounding_maps (neigh, distance); + else + neigh = maptile::find_async (path, map); +} + +// prefetch a generous area around the player +static void +prefetch_surrounding_maps (object *op) +{ + prefetch_surrounding_maps (op->map, 3); +} + /** * This function uses the new map1 protocol command to send the map * to the client. It is necessary because the old map command supports @@ -1594,6 +1616,7 @@ return; check_map_change (pl->contr); + prefetch_surrounding_maps (pl); packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); packet esl;