feat: add Wine Z: path prefix for Windows platform on Linux host
CI / build (push) Successful in 1m44s

- Add winePath helper that prepends Z: when platform is windows on Linux
- Thread platform through buildModPath, buildAutoArgs, and Start()
- Apply Z: prefix to -config=, -mod=, -profiles=, and %command% binary paths
- Add tests for winePath, buildAutoArgs, and buildModPath with platform param
- Fix formatting across services package with gofmt
- Include all prior bug fixes from this branch
This commit is contained in:
MrFastwind
2026-07-24 03:57:51 +02:00
parent 41c1390972
commit 6f3175ac9a
18 changed files with 219 additions and 75 deletions
+14 -6
View File
@@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"sync"
"sync/atomic"
@@ -14,6 +15,13 @@ import (
"arma3-web-server/internal/models"
)
func winePath(path, platform string) string {
if platform == "windows" && runtime.GOOS != "windows" {
return "Z:" + path
}
return path
}
type procState int32
const (
@@ -101,7 +109,7 @@ func (pm *ProcessManager) Start() error {
ctx, cancel := context.WithCancel(context.Background())
var cmd *exec.Cmd
if strings.Contains(s.ServerParameters, "%command%") {
full := strings.ReplaceAll(s.ServerParameters, "%command%", binPath)
full := strings.ReplaceAll(s.ServerParameters, "%command%", winePath(binPath, s.Platform))
parts := splitArgs(full)
if len(parts) == 0 {
cancel()
@@ -205,18 +213,18 @@ func (pm *ProcessManager) buildAutoArgs(s *models.ServerSettings) []string {
if s.ActiveConfig != "" {
cfgPath := filepath.Join(pm.cfgDir, s.ActiveConfig+".cfg")
args = append(args, "-config="+cfgPath)
args = append(args, "-config="+winePath(cfgPath, s.Platform))
}
if s.ActiveModlist != "" {
modPath := pm.buildModPath(s.ActiveModlist)
modPath := pm.buildModPath(s.ActiveModlist, s.Platform)
if modPath != "" {
args = append(args, modPath)
}
}
if pm.profilesDir != "" && !hasArgPrefix(args, "-profiles=") {
args = append(args, "-profiles="+pm.profilesDir)
args = append(args, "-profiles="+winePath(pm.profilesDir, s.Platform))
}
if s.IPPort != "" && !hasArgPrefix(args, "-port=") {
@@ -245,7 +253,7 @@ func hasArgPrefix(args []string, prefix string) bool {
const workshopAppID = "107410"
func (pm *ProcessManager) buildModPath(modlistID string) string {
func (pm *ProcessManager) buildModPath(modlistID string, platform string) string {
ml, err := pm.modlists.Get(modlistID)
if err != nil {
return ""
@@ -256,7 +264,7 @@ func (pm *ProcessManager) buildModPath(modlistID string) string {
if !mod.Enabled {
continue
}
parts = append(parts, pm.resolveModPath(mod))
parts = append(parts, winePath(pm.resolveModPath(mod), platform))
}
if len(parts) == 0 {