I need help again 
Each location in my game can have four exits... north east south and west.
Code: ags
In this fashion they are all interlinked.
Now, say I want to generate a physical map of the location network. I need some kind of formula to position components on a drawing surface. The result would look something like this:

As an aside, the generated map doesn't need long line connectors, only short ones like between the green star and tavern. Here's what I've come up with so far, but it's not ideal:
Code: ags
As I say, it's pretty useless because it only draws the direct satellite locations of the current location. What I need to do is get the satellite locations of the satellite locations of the satellite locations... etc. In this way I create a map of the network, with the current location in the centre.
I would need some kind of concatanating sequence:
Code: ags
But this would be ridiculous, especially as there are 100s of locations. Any ideas for alternatives? :/

Each location in my game can have four exits... north east south and west.
loc[1].nor = 2;
loc[2].sou = 1;
loc[3].eas = 4;
loc[4].wes = 3;
In this fashion they are all interlinked.
Now, say I want to generate a physical map of the location network. I need some kind of formula to position components on a drawing surface. The result would look something like this:

As an aside, the generated map doesn't need long line connectors, only short ones like between the green star and tavern. Here's what I've come up with so far, but it's not ideal:
//Map Components
//Squares
//'you are here' square - 12x12, slot 10
//plain square - 12x12, slot 7
//tavern square...
//stable square...
//Connectors
//1 vertical line - 4x6, slot 8
//1 horizontal line - 6x4, slot 9
DynamicSprite *sprite;
DrawingSurface *surface;
function GenerateMap()
{
sprite = DynamicSprite.CreateFromExistingSprite(Map.Graphic); //Map.Graphic is 162x112, and invisible
surface = sprite.GetDrawingSurface(); surface.Clear();
int x = (Map.Width/2)-6, //find the centre point and -6, because 1 square is 12x12 so it must span the centre
y = (Map.Height/2)-6;
surface.DrawImage(x, y, 10); //mob[0] is the player. draw their location.
if (loc[mob[0].loc].nor != 0) { //ie, there is an exit to the north
surface.DrawImage(x, y-18, 7); //draw a plain square
surface.DrawImage(x+4, y-6, 9); //draw a line connecting the two
}
if (loc[mob[0].loc].eas != 0) {
surface.DrawImage(x+18, y, 7);
surface.DrawImage(x+12, y+4, 8);
}
if (loc[mob[0].loc].sou != 0) {
surface.DrawImage(x, y+18, 7);
surface.DrawImage(x+4, y+12, 9);
}
if (loc[mob[0].loc].wes != 0) {
surface.DrawImage(x-18, y, 7);
surface.DrawImage(x-6, y+4, 8);
}
surface.Release();
Map.NormalGraphic = sprite.Graphic;
}
As I say, it's pretty useless because it only draws the direct satellite locations of the current location. What I need to do is get the satellite locations of the satellite locations of the satellite locations... etc. In this way I create a map of the network, with the current location in the centre.
I would need some kind of concatanating sequence:
if (loc[mob[0].loc].nor != 0) //draw
if (loc[loc[mob[0].loc].nor].nor != 0) //draw
if (loc[loc[loc[mob[0].loc].nor].nor].nor != 0) //draw
But this would be ridiculous, especially as there are 100s of locations. Any ideas for alternatives? :/