diff options
| author | historia <[not public]> | 2026-06-30 04:43:54 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-30 04:43:54 -0400 |
| commit | 98bdef072c843fdd8ccdf85a9b54ab9d32d34187 (patch) | |
| tree | d4c5c4955ba8e02e895ae0713a2c3439bc93868a /internal/admin/api_map.go | |
| parent | 712072209ab5e3b3a14ebc0c770b020afe544560 (diff) | |
| download | thehouseoficarus-98bdef072c843fdd8ccdf85a9b54ab9d32d34187.tar.gz | |
slop refactor
Diffstat (limited to 'internal/admin/api_map.go')
| -rw-r--r-- | internal/admin/api_map.go | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/internal/admin/api_map.go b/internal/admin/api_map.go index 5de41a7..7298f1e 100644 --- a/internal/admin/api_map.go +++ b/internal/admin/api_map.go @@ -44,7 +44,6 @@ func (s *AdminServer) handleMap(w http.ResponseWriter, r *http.Request) { Y int `json:"y"` Name string `json:"name"` Color string `json:"color"` - Symbol string `json:"symbol"` } type LinkEntry struct { @@ -249,47 +248,22 @@ func findDisconnectedRooms(s *AdminServer, dir string, seed int, g world.RoomGri func listRoomIDsInDir(s *AdminServer, dir string) []int { base := filepath.Join(s.dataDir, "rooms") - var dirs []string - if dir == "" { - dirs = append(dirs, base) - entries, err := os.ReadDir(base) - if err != nil { - return nil - } - for _, e := range entries { - if e.IsDir() { - dirs = append(dirs, filepath.Join(base, e.Name())) - subE, err := os.ReadDir(filepath.Join(base, e.Name())) - if err != nil { - continue - } - for _, se := range subE { - if se.IsDir() { - dirs = append(dirs, filepath.Join(base, e.Name(), se.Name())) - } - } - } - } - } else { - dirs = append(dirs, filepath.Join(base, dir)) + walkRoot := base + if dir != "" { + walkRoot = filepath.Join(base, dir) } var ids []int - for _, d := range dirs { - entries, err := os.ReadDir(d) - if err != nil { - continue + filepath.WalkDir(walkRoot, func(path string, d os.DirEntry, err error) error { + if err != nil || d.IsDir() || filepath.Ext(d.Name()) != ".yaml" { + return nil } - for _, e := range entries { - if e.IsDir() || filepath.Ext(e.Name()) != ".yaml" { - continue - } - id, err := strconv.Atoi(e.Name()[:len(e.Name())-5]) - if err != nil { - continue - } + name := d.Name() + id, convErr := strconv.Atoi(name[:len(name)-5]) + if convErr == nil && id > 0 { ids = append(ids, id) } - } + return nil + }) return ids } |
