How does a Doom engine work?
The closest segs are drawn first, so that the closest subsectors are drawn by order of distance from the camera, which is what the Doom engine does. segs are stored in a linked list as the segs are drawn. There is a map of areas where solid walls have been reached.