summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2019-02-10 18:04:48 +0100
committerCharles Pigott <charlespigott@googlemail.com>2019-02-12 21:32:43 +0000
commit830ed6be6114b2b1ed6680c3acc422cd8a849874 (patch)
treeade04c0f369d288ad0380af244af32e837cb4f2e /src
parent46d97239c4aaead07e61f676fa88268b5b5208fa (diff)
downloadopenttd-830ed6be6114b2b1ed6680c3acc422cd8a849874.tar.xz
Fix: Do not mangle tagged revision strings for network revision strings
Diffstat (limited to 'src')
-rw-r--r--src/network/network.cpp13
1 files 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);