This commit is contained in:
Alexander Wang 2023-03-02 19:32:31 -08:00
parent 78c3f3f797
commit e13be5c09a
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE

View file

@ -752,37 +752,36 @@ func (c *compiler) validateBoardLinks(g *d2graph.Graph) {
} }
func hasBoard(root *d2graph.Graph, ida []string) bool { func hasBoard(root *d2graph.Graph, ida []string) bool {
for i := 0; i < len(ida); i += 2 { if len(ida) == 0 {
id := ida[i] return true
if i == 0 && id == "root" { }
i-- if ida[0] == "root" {
continue return hasBoard(root, ida[1:])
} }
if i == len(ida)-1 { id := ida[0]
return root.Name == id if len(ida) == 1 {
} return root.Name == id
nextID := ida[i+1] }
switch id { nextID := ida[1]
case "layers": switch id {
for _, b := range root.Layers { case "layers":
if b.Name == nextID { for _, b := range root.Layers {
return hasBoard(b, ida[i+1:]) if b.Name == nextID {
} return hasBoard(b, ida[2:])
} }
case "scenarios": }
for _, b := range root.Scenarios { case "scenarios":
if b.Name == nextID { for _, b := range root.Scenarios {
return hasBoard(b, ida[i+1:]) if b.Name == nextID {
} return hasBoard(b, ida[2:])
} }
case "steps": }
for _, b := range root.Steps { case "steps":
if b.Name == nextID { for _, b := range root.Steps {
return hasBoard(b, ida[i+1:]) if b.Name == nextID {
} return hasBoard(b, ida[2:])
} }
} }
break
} }
return false return false
} }