]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
powerbot: Fix re-saving.
authorRudolf Polzer <divVerent@gmail.com>
Thu, 5 Oct 2023 20:41:24 +0000 (22:41 +0200)
committerRudolf Polzer <divVerent@gmail.com>
Thu, 5 Oct 2023 20:42:35 +0000 (22:42 +0200)
misc/infrastructure/powerbot/bot.go

index 9557685fc5bf9cc31b1b18423513134743973d4a..b373c8262fa0b1d465eb994d9c5437c29ec7490e 100644 (file)
@@ -19,8 +19,8 @@ const (
 )
 
 type Room struct {
-       ID   id.RoomID
-       Name string
+       ID   id.RoomID `json:"id"`
+       Name string    `json:"name",omitempty`
 }
 
 type Config struct {
@@ -207,12 +207,16 @@ func Run() (err error) {
                        return
                }
                for _, group := range config.Rooms {
-                       for _, room := range group {
+                       for i := range group {
+                               room := &group[i]
                                if room.ID == evt.RoomID {
                                        configMu.Lock()
                                        defer configMu.Unlock()
                                        room.ID = tomb.ReplacementRoom
-                                       config.Save()
+                                       err := config.Save()
+                                       if err != nil {
+                                               log.Printf("failed to save config: %v", err)
+                                       }
                                        log.Fatalf("room upgrade for %v handled from %v to %v - need restart", room.Name, evt.RoomID, tomb.ReplacementRoom)
                                }
                        }