Imho the patch doubles some code in wegbauer.cc, which is not nice from a maintaining perspective. It should be possible to obtain the same behavior by modifying just the essential parts. Also you do not need a second instance of marker_t.
I wonder whether it is possible to make a grund_t obj which means there is no obj, and which contains only the coordinates as meaningful information.
If it's possible, I don't need the second instance of marker_t and reduce some double coding easily.
If it's not possible, I need it because it has to distinguish the two situations that the tile is visited as "lower" or "upper" layers.
I reduced part of doubled coding.(Not all!)
Changing general source to search ways, it might cause a problem related to groundway/bridge/tunnels/... construction.