Get the required information by returning it in the proper places.
Also clean up some pointless modulo operations.
This is pulled out of the Silk Road code (#4314), this part is independent of everything else and related to some patch you merged/finished quite some time ago.
The remaining WIP code there goes quite some of the way for actually implementing trade routes (#1207 and #3872), but ignores the whole GUI issue. It also does not (yet?) consider routes/waypoints at all.