From 830ed6be6114b2b1ed6680c3acc422cd8a849874 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Sun, 10 Feb 2019 18:04:48 +0100 Subject: Fix: Do not mangle tagged revision strings for network revision strings --- src/network/network.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/network/network.cpp b/src/network/network.cpp index d70d800f9..4727e3344 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -1121,8 +1121,11 @@ const char * GetNetworkRevisionString() /* Ensure it's not longer than the packet buffer length. */ if (strlen(network_revision) >= NETWORK_REVISION_LENGTH) network_revision[NETWORK_REVISION_LENGTH - 1] = '\0'; - /* Release version names are not mangled further. */ - if (IsReleasedVersion()) return network_revision; + /* Tag names are not mangled further. */ + if (_openttd_revision_tagged) { + DEBUG(net, 1, "Network revision name is '%s'", network_revision); + return network_revision; + } /* Prepare a prefix of the git hash. * Size is length + 1 for terminator, +2 for -g prefix. */ @@ -1140,6 +1143,7 @@ const char * GetNetworkRevisionString() /* Replace the git hash in revision string. */ strecpy(network_revision + hashofs, githash_suffix, network_revision + NETWORK_REVISION_LENGTH); assert(strlen(network_revision) < NETWORK_REVISION_LENGTH); // strlen does not include terminator, constant does, hence strictly less than + DEBUG(net, 1, "Network revision name is '%s'", network_revision); } return network_revision; @@ -1159,6 +1163,11 @@ bool IsNetworkCompatibleVersion(const char *other) { if (strncmp(GetNetworkRevisionString(), other, NETWORK_REVISION_LENGTH - 1) == 0) return true; + /* If this version is tagged, then the revision string must be a complete match, + * since there is no git hash suffix in it. + * This is needed to avoid situations like "1.9.0-beta1" comparing equal to "2.0.0-beta1". */ + if (_openttd_revision_tagged) return false; + const char *hash1 = ExtractNetworkRevisionHash(GetNetworkRevisionString()); const char *hash2 = ExtractNetworkRevisionHash(other); return hash1 && hash2 && (strncmp(hash1, hash2, GITHASH_SUFFIX_LEN) == 0); -- cgit v1.2.3-70-g09d2