diff --git a/CHANGELOG.md b/CHANGELOG.md index 9be6431..2f9faea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## Nächste Version +## 2.8.1 + +**Kleine Updates** +- Mod-Version (2.8.1 für MSCLoader/MSC Launcher) und Netzwerk-Version (2.8) sind getrennt: Updates an der dritten Stelle + passen zu allen 2.8-Servern und -Mitspielern. Anleitung im README („Updates veröffentlichen“) **Server-Browser** - **Hervorgehobene Server**: vom Keymaster-Admin markierte Server (Tag `featured`) stehen ganz oben, mit goldener diff --git a/LobbyUI.cs b/LobbyUI.cs index e855cf6..478ccf3 100644 --- a/LobbyUI.cs +++ b/LobbyUI.cs @@ -328,7 +328,7 @@ namespace MSCO // Server auf diesem PC (localhost) nameX += Pill(nameX, row, "LOCAL", pillStyle); } - if (!string.IsNullOrEmpty(s.Version) && s.Version != MSCO.ModVersion) + if (!string.IsNullOrEmpty(s.Version) && !MSCO.Compatible(s.Version)) { nameX += Pill(nameX, row, "v" + s.Version, pillStyle); // abweichende Version } @@ -583,7 +583,7 @@ namespace MSCO if (official) bx += Pill(bx, badgeRow, "OFFICIAL", pillStyle); bx += Pill(bx, badgeRow, s.RequireSteam ? "STEAM" : "NON-STEAM", s.RequireSteam ? pillStyle : pillMutedStyle); if (s.IsLocal) bx += Pill(bx, badgeRow, "LOCAL", pillStyle); - if (s.Version != MSCO.ModVersion) bx += Pill(bx, badgeRow, "v" + s.Version, pillStyle); + if (!MSCO.Compatible(s.Version)) bx += Pill(bx, badgeRow, "v" + s.Version, pillStyle); if (s.Tags != null) foreach (string tag in s.Tags) if (!string.IsNullOrEmpty(tag) && tag != "featured" && tag != "official") bx += Pill(bx, badgeRow, tag.ToUpper(), pillMutedStyle); @@ -629,7 +629,7 @@ namespace MSCO } // Infos links, Spielerliste rechts - bool versionOk = s.Version == MSCO.ModVersion; + bool versionOk = MSCO.Compatible(s.Version); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(S(250))); InfoLine("HOSTED BY", string.IsNullOrEmpty(s.Owner) ? "unknown" : s.Owner, rowNameStyle); diff --git a/MSCO.cs b/MSCO.cs index 34307d4..36daaf2 100644 --- a/MSCO.cs +++ b/MSCO.cs @@ -5,7 +5,30 @@ namespace MSCO { public class MSCO : Mod { - public const string ModVersion = "2.8"; + /// + /// Version der Mod (MSCLoader / MSC Launcher). Kleine Updates: nur die dritte Stelle erhöhen (2.8.1, 2.8.2 ...) - + /// sie bleiben mit 2.8-Servern und -Mitspielern kompatibel. + /// + public const string ModVersion = "2.8.1"; + /// + /// Netzwerk-Version (die ersten beiden Stellen). Nur erhöhen, wenn sich das Protokoll inkompatibel ändert - dann + /// auch GameServer.ModVersion im Server und eine neue Mod-Version 2.9.0 o.ä. + /// + public const string ProtocolVersion = "2.8"; + + /// Passt eine andere Version (Server, Host, Mitspieler) zu uns? Verglichen werden nur die ersten zwei Stellen. + public static bool Compatible(string other) + { + return Protocol(other) == ProtocolVersion; + } + + /// "2.8.3" -> "2.8" + public static string Protocol(string version) + { + if (string.IsNullOrEmpty(version)) return ""; + string[] parts = version.Trim().Split('.'); + return parts.Length >= 2 ? parts[0] + "." + parts[1] : version.Trim(); + } public override string ID => "MSCO"; // Your (unique) mod ID public override string Name => "MSCO"; // Your mod name diff --git a/MultiplayerManager.cs b/MultiplayerManager.cs index 8cb47c5..bc8256d 100644 --- a/MultiplayerManager.cs +++ b/MultiplayerManager.cs @@ -675,7 +675,7 @@ namespace MSCO string name = string.IsNullOrEmpty(displayName) ? info.Name : displayName; int max = info.MaxPlayers > 0 ? info.MaxPlayers : maxPlayers; - if (info.Version != MSCO.ModVersion) + if (!MSCO.Compatible(info.Version)) { PendingVersionWarning = new VersionWarning { Host = host, Port = port, Name = name, MaxPlayers = max, ServerVersion = info.Version }; SetStatus("Version mismatch: server v" + info.Version + ", you v" + MSCO.ModVersion); @@ -1064,7 +1064,7 @@ namespace MSCO byte[] ticket = SteamLobby.CreateAuthTicket(); session.SendTo(NetSession.HostId, MsgType.Hello, NetSession.Build(w => { - w.Write(MSCO.ModVersion); + w.Write(MSCO.ProtocolVersion); // nur die Netzwerk-Version: ältere Hosts vergleichen genau w.Write(name); // Steam-Identität: dedizierte Server lassen nur Spieler mit Steam rein w.Write(SteamLobby.OwnSteamId); @@ -1392,7 +1392,7 @@ namespace MSCO string version = r.ReadString(); string name = r.ReadString(); - if (version != MSCO.ModVersion) + if (!MSCO.Compatible(version)) { Reject(peerId, "Version mismatch (host " + MSCO.ModVersion + ", you " + version + ")"); return; diff --git a/README.md b/README.md index e7441f0..4b05574 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,15 @@ In der F7-Konsole direkt, in der MSCLoader-Konsole mit `mp` davor (z.B. `mp conn msbuild MSCO.csproj -p:Configuration=Release ``` +### Updates veröffentlichen (MSC Launcher / MSCLoader) + +- **Kleines Update** (Fehlerbehebungen, neue Funktionen, Netzwerk unverändert): in `MSCO.cs` nur die dritte Stelle von + `ModVersion` erhöhen (`2.8.1` → `2.8.2`), Release bauen und `bin/Release/MSCO.dll` hochladen. Spieler mit 2.8.x + spielen weiter zusammen, Server 2.8 müssen nicht aktualisiert werden. +- **Großes Update** (Protokoll inkompatibel geändert): `ProtocolVersion` in `MSCO.cs` **und** `GameServer.ModVersion` im + Server erhöhen (z.B. `2.9`), `ModVersion` auf `2.9.0`. Dann brauchen alle die neue Mod und den neuen Server. +- Verglichen werden immer nur die ersten zwei Stellen; übers Netz geht nur die Netzwerk-Version. + ## Aufbau | Datei | Aufgabe | diff --git a/SteamLobby.cs b/SteamLobby.cs index 7e1fe46..28b47e1 100644 --- a/SteamLobby.cs +++ b/SteamLobby.cs @@ -164,7 +164,7 @@ namespace MSCO return; } LobbyId = new CSteamID(result.m_ulSteamIDLobby); - SteamMatchmaking.SetLobbyData(LobbyId, VersionKey, MSCO.ModVersion); + SteamMatchmaking.SetLobbyData(LobbyId, VersionKey, MSCO.ProtocolVersion); // ältere Mods vergleichen genau if (Created != null) Created(LobbyId); } @@ -178,7 +178,7 @@ namespace MSCO LobbyId = new CSteamID(result.m_ulSteamIDLobby); string hostVersion = SteamMatchmaking.GetLobbyData(LobbyId, VersionKey); - if (!string.IsNullOrEmpty(hostVersion) && hostVersion != MSCO.ModVersion) + if (!string.IsNullOrEmpty(hostVersion) && !MSCO.Compatible(hostVersion)) { Leave(); Fail("Version mismatch (host " + hostVersion + ", you " + MSCO.ModVersion + ")");