Skip to content

Commit

Permalink
Number remote installs to differentiate them
Browse files Browse the repository at this point in the history
  • Loading branch information
mircearoata committed Dec 29, 2023
1 parent 5a3c28c commit 0c1fed7
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion backend/bindings/ficsitcli/remote_servers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package ficsitcli

import (
"strconv"
"strings"

"github.com/pkg/errors"

"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders/common"
Expand Down Expand Up @@ -63,7 +66,7 @@ func (f *FicsitCLI) AddRemoteServer(path string) error {
Location: common.LocationTypeRemote,
Branch: branch,
Version: gameVersion,
Launcher: "Remote",
Launcher: f.getNextRemoteLauncherName(),
},
})

Expand All @@ -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 {
Expand Down

0 comments on commit 0c1fed7

Please sign in to comment.