diff --git a/CODEOWNERS b/CODEOWNERS index 0519999..0f27853 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,2 +1,2 @@ # see https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners for more information -* @Unity-Technologies/multiplayer-services \ No newline at end of file +* @Unity-Technologies/multiplay diff --git a/simple-game-server-go/internal/game/allocated.go b/simple-game-server-go/internal/game/allocated.go index 3256c57..5650152 100644 --- a/simple-game-server-go/internal/game/allocated.go +++ b/simple-game-server-go/internal/game/allocated.go @@ -28,6 +28,7 @@ func (g *Game) allocated(allocationID string) { c := g.Config() port, _ := c.Port.Int64() maxPlayers, _ := strconv.ParseInt(c.Extra["maxPlayers"], 10, 32) + if maxPlayers == 0 { maxPlayers = defaultMaxPlayers } @@ -114,8 +115,10 @@ func (g *Game) handleClient(client *net.TCPConn) { "current_players": currentPlayers, }).Info("client disconnected") }() + for { buf := make([]byte, 16) + if _, err := client.Read(buf); err != nil { return } diff --git a/simple-game-server-go/main.go b/simple-game-server-go/main.go index a9ab26c..2650beb 100644 --- a/simple-game-server-go/main.go +++ b/simple-game-server-go/main.go @@ -34,6 +34,7 @@ func parseFlags(args []string) (string, string, string, error) { // If no valid targets are provided, it defaults to writing to stdout. func logWritersFromTargets(logTargets string, logFile string, logger *logrus.Logger) io.Writer { targets := make([]io.Writer, 0) + for _, t := range splitAndTrim(logTargets) { switch t { case "stdout": @@ -54,6 +55,7 @@ func logWritersFromTargets(logTargets string, logFile string, logger *logrus.Log targets = append(targets, f) } } + // logFile takes precedence if logFile != "" { f, err := os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o666) @@ -63,6 +65,7 @@ func logWritersFromTargets(logTargets string, logFile string, logger *logrus.Log logger.WithError(err).Warning("could not open log file for writing") } } + if len(targets) == 0 { return os.Stdout } @@ -72,6 +75,7 @@ func logWritersFromTargets(logTargets string, logFile string, logger *logrus.Log // splitAndTrim splits a string by the OS-specific path list separator and trims each part. func splitAndTrim(s string) []string { parts := make([]string, 0) + for _, p := range filepath.SplitList(s) { for _, t := range splitComma(p) { trimmed := filepath.Clean(t) @@ -86,6 +90,7 @@ func splitAndTrim(s string) []string { // splitComma splits a string by commas and trims each part, returning a slice of non-empty strings. func splitComma(s string) []string { res := make([]string, 0) + for _, t := range strings.Split(s, ",") { trimmed := strings.TrimSpace(t) if trimmed != "" && trimmed != "." {