diff --git a/backend/bindings/ficsitcli/remote_servers.go b/backend/bindings/ficsitcli/remote_servers.go index 56ec8a6e..1401e5e4 100644 --- a/backend/bindings/ficsitcli/remote_servers.go +++ b/backend/bindings/ficsitcli/remote_servers.go @@ -1,6 +1,9 @@ package ficsitcli import ( + "strconv" + "strings" + "github.com/pkg/errors" "github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/common" @@ -63,7 +66,7 @@ func (f *FicsitCLI) AddRemoteServer(path string) error { Location: common.LocationTypeRemote, Branch: branch, Version: gameVersion, - Launcher: "Remote", + Launcher: f.getNextRemoteLauncherName(), }, }) @@ -72,6 +75,23 @@ func (f *FicsitCLI) AddRemoteServer(path string) error { return nil } +func (f *FicsitCLI) getNextRemoteLauncherName() string { + existingNumbers := make(map[int]bool) + for _, install := range f.GetRemoteInstallations() { + if strings.HasPrefix(install.Launcher, "Remote ") { + num, err := strconv.Atoi(strings.TrimPrefix(install.Launcher, "Remote ")) + if err == nil { + existingNumbers[num] = true + } + } + } + for i := 1; ; i++ { + if !existingNumbers[i] { + return "Remote " + strconv.Itoa(i) + } + } +} + func (f *FicsitCLI) RemoveRemoteServer(path string) error { for _, install := range f.installations { if install.Info.Path == path && install.Info.Location != common.LocationTypeRemote {