Mod 2.8.1: separate mod version from network protocol version

ModVersion (2.8.1, shown in MSCLoader/MSC Launcher) and ProtocolVersion
(2.8) are separate; only the first two digits are compared (P2P host, Steam
lobby, server info, server browser) and only the protocol version is sent,
so minor updates stay compatible with 2.8 servers, hosts and players.
README: how to publish minor and major updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 17:48:07 +02:00
co-authored by Claude Opus 5.5
parent f707e67e5c
commit ea1b0f74d9
6 changed files with 46 additions and 10 deletions
+5 -1
View File
@@ -1,6 +1,10 @@
# Changelog # 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** **Server-Browser**
- **Hervorgehobene Server**: vom Keymaster-Admin markierte Server (Tag `featured`) stehen ganz oben, mit goldener - **Hervorgehobene Server**: vom Keymaster-Admin markierte Server (Tag `featured`) stehen ganz oben, mit goldener
+3 -3
View File
@@ -328,7 +328,7 @@ namespace MSCO
// Server auf diesem PC (localhost) // Server auf diesem PC (localhost)
nameX += Pill(nameX, row, "LOCAL", pillStyle); 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 nameX += Pill(nameX, row, "v" + s.Version, pillStyle); // abweichende Version
} }
@@ -583,7 +583,7 @@ namespace MSCO
if (official) bx += Pill(bx, badgeRow, "OFFICIAL", pillStyle); if (official) bx += Pill(bx, badgeRow, "OFFICIAL", pillStyle);
bx += Pill(bx, badgeRow, s.RequireSteam ? "STEAM" : "NON-STEAM", s.RequireSteam ? pillStyle : pillMutedStyle); bx += Pill(bx, badgeRow, s.RequireSteam ? "STEAM" : "NON-STEAM", s.RequireSteam ? pillStyle : pillMutedStyle);
if (s.IsLocal) bx += Pill(bx, badgeRow, "LOCAL", pillStyle); 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) if (s.Tags != null)
foreach (string tag in s.Tags) foreach (string tag in s.Tags)
if (!string.IsNullOrEmpty(tag) && tag != "featured" && tag != "official") bx += Pill(bx, badgeRow, tag.ToUpper(), pillMutedStyle); 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 // Infos links, Spielerliste rechts
bool versionOk = s.Version == MSCO.ModVersion; bool versionOk = MSCO.Compatible(s.Version);
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.BeginVertical(GUILayout.Width(S(250))); GUILayout.BeginVertical(GUILayout.Width(S(250)));
InfoLine("HOSTED BY", string.IsNullOrEmpty(s.Owner) ? "unknown" : s.Owner, rowNameStyle); InfoLine("HOSTED BY", string.IsNullOrEmpty(s.Owner) ? "unknown" : s.Owner, rowNameStyle);
+24 -1
View File
@@ -5,7 +5,30 @@ namespace MSCO
{ {
public class MSCO : Mod public class MSCO : Mod
{ {
public const string ModVersion = "2.8"; /// <summary>
/// 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.
/// </summary>
public const string ModVersion = "2.8.1";
/// <summary>
/// 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.ä.
/// </summary>
public const string ProtocolVersion = "2.8";
/// <summary>Passt eine andere Version (Server, Host, Mitspieler) zu uns? Verglichen werden nur die ersten zwei Stellen.</summary>
public static bool Compatible(string other)
{
return Protocol(other) == ProtocolVersion;
}
/// <summary>"2.8.3" -> "2.8"</summary>
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 ID => "MSCO"; // Your (unique) mod ID
public override string Name => "MSCO"; // Your mod name public override string Name => "MSCO"; // Your mod name
+3 -3
View File
@@ -675,7 +675,7 @@ namespace MSCO
string name = string.IsNullOrEmpty(displayName) ? info.Name : displayName; string name = string.IsNullOrEmpty(displayName) ? info.Name : displayName;
int max = info.MaxPlayers > 0 ? info.MaxPlayers : maxPlayers; 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 }; 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); SetStatus("Version mismatch: server v" + info.Version + ", you v" + MSCO.ModVersion);
@@ -1064,7 +1064,7 @@ namespace MSCO
byte[] ticket = SteamLobby.CreateAuthTicket(); byte[] ticket = SteamLobby.CreateAuthTicket();
session.SendTo(NetSession.HostId, MsgType.Hello, NetSession.Build(w => 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); w.Write(name);
// Steam-Identität: dedizierte Server lassen nur Spieler mit Steam rein // Steam-Identität: dedizierte Server lassen nur Spieler mit Steam rein
w.Write(SteamLobby.OwnSteamId); w.Write(SteamLobby.OwnSteamId);
@@ -1392,7 +1392,7 @@ namespace MSCO
string version = r.ReadString(); string version = r.ReadString();
string name = r.ReadString(); string name = r.ReadString();
if (version != MSCO.ModVersion) if (!MSCO.Compatible(version))
{ {
Reject(peerId, "Version mismatch (host " + MSCO.ModVersion + ", you " + version + ")"); Reject(peerId, "Version mismatch (host " + MSCO.ModVersion + ", you " + version + ")");
return; return;
+9
View File
@@ -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 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 ## Aufbau
| Datei | Aufgabe | | Datei | Aufgabe |
+2 -2
View File
@@ -164,7 +164,7 @@ namespace MSCO
return; return;
} }
LobbyId = new CSteamID(result.m_ulSteamIDLobby); 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); if (Created != null) Created(LobbyId);
} }
@@ -178,7 +178,7 @@ namespace MSCO
LobbyId = new CSteamID(result.m_ulSteamIDLobby); LobbyId = new CSteamID(result.m_ulSteamIDLobby);
string hostVersion = SteamMatchmaking.GetLobbyData(LobbyId, VersionKey); string hostVersion = SteamMatchmaking.GetLobbyData(LobbyId, VersionKey);
if (!string.IsNullOrEmpty(hostVersion) && hostVersion != MSCO.ModVersion) if (!string.IsNullOrEmpty(hostVersion) && !MSCO.Compatible(hostVersion))
{ {
Leave(); Leave();
Fail("Version mismatch (host " + hostVersion + ", you " + MSCO.ModVersion + ")"); Fail("Version mismatch (host " + hostVersion + ", you " + MSCO.ModVersion + ")");