That entire function has been refactored already. [Link](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/overmap.cpp#L3595).