Converts most map->grid accesses to wrapper functions.

This'll make it easier to scale this up to 3d, and also to change the way submaps are stored and accessed.

Preliminary work for #6818