#textdomain wesnoth
###########################################
#######   LAYOUT   ########################
###########################################
#define TRACK_CONNECT TERRAINLIST FLAG R0 R1 R2 R3 R4 R5 S0 S1 S2 S3 S4 S5
    [terrain_graphics]
        map="
,  {S1}
{S0},   {S2}
,  1
{S5},   {S3}
,  {S4}"
        [tile]
            #main bridge
            pos=1
            type={TERRAINLIST}
            set_flag={FLAG}-connect-{R0}
        [/tile]
        [tile]
            pos=2
            type={TERRAINLIST}
        [/tile]
    [/terrain_graphics]
#enddef

#define TRACK_AWAY TERRAINLIST ADJACENT FLAG R1 R2 R3 R4 R5 R6 S0 S1 S2 S3 S4 S5
    [terrain_graphics]
        map="
,  {S1}
{S0},   {S2}
,  1
{S5},   {S3}
,  {S4}"
        [tile]
            #main track
            pos=1
            type={TERRAINLIST}
            no_flag={FLAG},{FLAG}-connect-{R4}
            set_flag={FLAG}-away-{R4}
        [/tile]
        [tile]
            #exit side
            pos=2
            type={ADJACENT}
            no_flag={FLAG}-away-{R3}
        [/tile]
        [tile]
            #side where we should have exited, but don't
            pos=3
            set_flag={FLAG}-away-{R1}
            no_flag={FLAG}-connect-{R1}
        [/tile]
    [/terrain_graphics]
#enddef

#define TRACK_CONNECT_ALL TERRAINLIST FLAG R0 R1 R2 R3 R4 R5 S0 S1 S2 S3 S4 S5
    [terrain_graphics]
        map="
,  {S1}
{S0},   {S2}
,  1
{S5},   {S3}
,  {S4}"
        [tile]
            #exit side
            pos=2
            no_flag={FLAG}-away-{R3}
        [/tile]
        [tile]
            #main bridge
            pos=1
            type={TERRAINLIST}
            set_flag={FLAG}-connect-{R0}
            no_flag={FLAG}-away-{R0}
        [/tile]
    [/terrain_graphics]
#enddef

#define TRACK_FINAL TERRAIN FLAG
    [terrain_graphics]
        map="
, 2
* , *
, 1
* , *
, *"

        [tile]
            pos=2
            type={TERRAIN}
            has_flag={FLAG}-connect-@R3
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            set_flag={FLAG}-connect-@R0
        [/tile]
        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
#enddef

###########################################
#######   DRAWING   #######################
###########################################

#define TRACK_SINGLE_PLFB TERRAIN ADJACENT1 ADJACENT2 ADJACENT3 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
, 2
3 , 3
, 1
3 , 3
, 4"

        [tile]
            pos=2
            type={ADJACENT1}
            no_flag={FLAG}-connect-@R3
        [/tile]
        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=4
            type={ADJACENT3}
            no_flag={FLAG}-connect-@R0
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R1,{FLAG}-connect-@R2,{FLAG}-connect-@R4,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R3
            set_flag={FLAG}
        [/tile]
        probability={PROB}
        rotations=n,ne,se,s,sw,nw
        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0@R3}
            layer={LAYER}
            center=90,144
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED_PLFB TERRAIN ADJACENT1 ADJACENT2 ADJACENT3 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   3
,  1
3,   3
,  4"

        [tile]
            # bridge connected side
            pos=2
            type={ADJACENT1}
            has_flag={FLAG}-connect-@R3
        [/tile]
        [tile]
            # not connected side
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            # opposite of connection
            pos=4
            type={ADJACENT3}
            no_flag={FLAG}-connect-@R0
        [/tile]

        [tile]
            pos=1
            type={TERRAIN}
            #The layout don't decide where to put terminations, we put them where termination should go, but the exit side isn't a bridge
            #terminations only go where straight bridge should have gone
            no_flag={FLAG},{FLAG}-connect-@R1,{FLAG}-connect-@R2,{FLAG}-connect-@R4,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R3
            set_flag={FLAG},{FLAG}-connected-@R0
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED2_N_NE_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   2
,  1
3,   3
,  3"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]
        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R2,{FLAG}-connect-@R3,{FLAG}-connect-@R4,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R1
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R1
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R1}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED2_N_SE_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   3
,  1
3,   2
,  3"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]
        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R1,{FLAG}-connect-@R3,{FLAG}-connect-@R4,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R2
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R2
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R2}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED2_N_S_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   3
,  1
3,   3
,  4"

        [tile]
            pos=2
            type={ADJACENT1}
            has_flag={FLAG}-connect-@R3
        [/tile]
        [tile]
            #here we must be a bit more restrictive to detect bridge termination properly
            #but the emergency catchups will solve any problem anyway
            pos=4
            type={ADJACENT1}
            has_flag={FLAG}-connect-@R0
        [/tile]
        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R1,{FLAG}-connect-@R2,{FLAG}-connect-@R4,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R3
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R3
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R3}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#
# TERRAIN is next to at least two ADJACENT-hexes
#
#define TRACK_RESTRICTED2_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    {TRACK_RESTRICTED2_N_NE_PLFB ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
    {TRACK_RESTRICTED2_N_SE_PLFB ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
    {TRACK_RESTRICTED2_N_S_PLFB  ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
#enddef

#define TRACK_RESTRICTED3_N_NE_SE_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   2
,  1
3,   2
,  3"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]
        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R3,{FLAG}-connect-@R4,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R1,{FLAG}-connect-@R2
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R1,{FLAG}-connected-@R2
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R1-@R2}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED3_N_NE_S_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   2
,  1
3,   3
,  2"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]
        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R2,{FLAG}-connect-@R4,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R1,{FLAG}-connect-@R3
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R1,{FLAG}-connected-@R3
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R1-@R3}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED3_N_NE_SW_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   2
,  1
2,   3
,  3"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]

        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R2,{FLAG}-connect-@R3,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R1,{FLAG}-connect-@R4
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R1,{FLAG}-connected-@R4
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R1-@R4}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED3_N_SE_SW_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   3
,  1
2,   2
,  3"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]
        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R1,{FLAG}-connect-@R3,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R2,{FLAG}-connect-@R4
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R2,{FLAG}-connected-@R4
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R2-@R4}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#
# TERRAIN ist next to at least three ADJACENT-hexes
#
#define TRACK_RESTRICTED3_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    {TRACK_RESTRICTED3_N_NE_SE_PLFB ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
    {TRACK_RESTRICTED3_N_NE_S_PLFB  ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
    {TRACK_RESTRICTED3_N_NE_SW_PLFB ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
    {TRACK_RESTRICTED3_N_SE_SW_PLFB ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
#enddef

#define TRACK_RESTRICTED4_N_NE_SE_S_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   2
,  1
3,   2
,  2"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]

        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R4,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R1,{FLAG}-connect-@R2,{FLAG}-connect-@R3
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R1,{FLAG}-connected-@R2,{FLAG}-connected-@R3
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R1-@R2-@R3}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED4_N_NE_SE_SW_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   2
,  1
2,   2
,  3"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]

        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R3,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R1,{FLAG}-connect-@R2,{FLAG}-connect-@R4
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R1,{FLAG}-connected-@R2,{FLAG}-connected-@R4
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R1-@R2-@R4}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED4_N_NE_S_SW_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   2
,  1
2,   3
,  2"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]

        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R2,{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R1,{FLAG}-connect-@R3,{FLAG}-connect-@R4
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R1,{FLAG}-connected-@R3,{FLAG}-connected-@R4
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R1-@R3-@R4}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#
# TERRAIN is next to at least four ADJACENT-hexes
#
#define TRACK_RESTRICTED4_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    {TRACK_RESTRICTED4_N_NE_SE_S_PLFB  ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
    {TRACK_RESTRICTED4_N_NE_SE_SW_PLFB ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
    {TRACK_RESTRICTED4_N_NE_S_SW_PLFB  ({TERRAIN}) {ADJACENT1} {ADJACENT2} {PROB} {LAYER} {FLAG} {BUILDER} {IMAGESTEM}}
#enddef

#define TRACK_RESTRICTED5_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
3,   2
,  1
2,   2
,  2"
        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]

        [tile]
            pos=3
            type={ADJACENT2}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG},{FLAG}-connect-@R5
            has_flag={FLAG}-connect-@R0,{FLAG}-connect-@R1,{FLAG}-connect-@R2,{FLAG}-connect-@R3,{FLAG}-connect-@R4
            set_flag={FLAG},{FLAG}-connected-@R0,{FLAG}-connected-@R1,{FLAG}-connected-@R2,{FLAG}-connected-@R3,{FLAG}-connected-@R4
        [/tile]

        probability={PROB}
        rotations=n,ne,se,s,sw,nw

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -@R0-@R1-@R2-@R3-@R4}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_RESTRICTED6_PLFB TERRAIN ADJACENT1 ADJACENT2 PROB LAYER FLAG BUILDER IMAGESTEM
    [terrain_graphics]
        map="
,  2
2,   2
,  1
2,   2
,  2"

        [tile]
            pos=2
            type={ADJACENT1}
        [/tile]
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG}
            has_flag={FLAG}-connect-n,{FLAG}-connect-ne,{FLAG}-connect-se,{FLAG}-connect-s,{FLAG}-connect-sw,{FLAG}-connect-nw
            set_flag={FLAG},{FLAG}-connected-n,{FLAG}-connected-ne,{FLAG}-connected-se,{FLAG}-connected-s,{FLAG}-connected-sw,{FLAG}-connected-nw
        [/tile]

        probability={PROB}

        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -n-ne-se-s-sw-nw}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef

#define TRACK_EMERGENCY_PLFB TERRAIN PROB LAYER FLAG BUILDER R0 R3 IMAGESTEM
    [terrain_graphics]
        map="
,  *
*,   *
,  1
*,   *
,  *"
        [tile]
            pos=1
            type={TERRAIN}
            no_flag={FLAG}
            set_flag={FLAG},{FLAG}-connected-{R0},{FLAG}-connected-{R3}
        [/tile]

        probability={PROB}
        [image]
            name={BUILD_IMAGE {BUILDER} {IMAGESTEM}@V -{R0}-{R3}}
            center=90,144
            layer={LAYER}
            variations=";2;3"
        [/image]
    [/terrain_graphics]
#enddef
#define TRACK_COMPLETE SE_NW_VALUE N_S_VALUE NE_SW_VALUE FLAG IMAGESTEM
    {TRACK_RESTRICTED6_PLFB ({SE_NW_VALUE},{N_S_VALUE},{NE_SW_VALUE}) * *   100 -80 {FLAG} IMAGE_SINGLE {IMAGESTEM}}
    {TRACK_RESTRICTED5_PLFB ({SE_NW_VALUE},{N_S_VALUE},{NE_SW_VALUE}) * *   100 -80 {FLAG} IMAGE_SINGLE {IMAGESTEM}}
    {TRACK_RESTRICTED4_PLFB ({SE_NW_VALUE},{N_S_VALUE},{NE_SW_VALUE}) * *   100 -80 {FLAG} IMAGE_SINGLE {IMAGESTEM}}
    {TRACK_RESTRICTED3_PLFB ({SE_NW_VALUE},{N_S_VALUE},{NE_SW_VALUE}) * *   100 -80 {FLAG} IMAGE_SINGLE {IMAGESTEM}}
    {TRACK_RESTRICTED2_PLFB ({SE_NW_VALUE},{N_S_VALUE},{NE_SW_VALUE}) * *   100 -80 {FLAG} IMAGE_SINGLE {IMAGESTEM}}
    {TRACK_RESTRICTED_PLFB  ({SE_NW_VALUE},{N_S_VALUE},{NE_SW_VALUE}) * * * 100 -80 {FLAG} IMAGE_SINGLE {IMAGESTEM}}
    {TRACK_SINGLE_PLFB ({SE_NW_VALUE},{N_S_VALUE},{NE_SW_VALUE}) * * * 100 -80 {FLAG} IMAGE_SINGLE {IMAGESTEM}}

    #emergency catch all (mainly for missing images)
    {TRACK_EMERGENCY_PLFB {SE_NW_VALUE} 100 -80 {FLAG} IMAGE_SINGLE se nw {IMAGESTEM}}
    {TRACK_EMERGENCY_PLFB {N_S_VALUE}   100 -80 {FLAG} IMAGE_SINGLE n  s  {IMAGESTEM}}
    {TRACK_EMERGENCY_PLFB {NE_SW_VALUE} 100 -80 {FLAG} IMAGE_SINGLE ne sw {IMAGESTEM}}
#enddef

#define TRACK_TEST_FLAG TERRAIN FLAG
    [terrain_graphics]
        map="
, *
* , *
, 1
* , *
, *"

        [tile]
            pos=1
            type={TERRAIN}
            has_flag={FLAG}-@R0
            [image]
                name={BUILD_IMAGE IMAGE_SINGLE test/test -@R0}
                layer=40
            [/image]
        [/tile]
        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
#enddef

###########################################
#######   TRANSITIONS   ###################
###########################################
#define TRACK_BORDER_RESTRICTED_PLF TERRAINLIST ADJACENT PROB LAYER FLAG IMAGESTEM
    [terrain_graphics]
        map="
, 2
* , *
, 1
* , *
, *"
        [tile]
            pos=1
            type={ADJACENT}
            no_flag={FLAG}-@R0,{FLAG}-connected-@R0
            set_flag={FLAG}-@R0
        [/tile]
        [tile]
            pos=2
            type={TERRAINLIST}
            has_flag={FLAG}-connected-@R3
        [/tile]

        [image]
            layer={LAYER}
            center=90,144
            name={BUILD_IMAGE IMAGE_SINGLE {IMAGESTEM}@V -@R0}
            variations=";2;3"
        [/image]
        probability={PROB}
        rotations=n,ne,se,s,sw,nw
    [/terrain_graphics]
#enddef
