MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsNetworkCompatibleVersion

Function IsNetworkCompatibleVersion

src/network/core/network_game_info.cpp:104–121  ·  view source on GitHub ↗

* Checks whether the given version string is compatible with our version. * First tries to match the full string, if that fails, attempts to compare just git hashes. * @param other the version string to compare to */

Source from the content-addressed store, hash-verified

102 * @param other the version string to compare to
103 */
104bool IsNetworkCompatibleVersion(std::string_view other)
105{
106 std::string_view our_revision = GetNetworkRevisionString();
107 if (our_revision == other) return true;
108
109 /* If this version is tagged, then the revision string must be a complete match,
110 * since there is no git hash suffix in it.
111 * This is needed to avoid situations like "1.9.0-beta1" comparing equal to "2.0.0-beta1". */
112 if (_openttd_revision_tagged) return false;
113
114 /* One of the versions is for some sort of debugging, but not both. */
115 if (other.starts_with("dbg_seed") != our_revision.starts_with("dbg_seed")) return false;
116 if (other.starts_with("dbg_sync") != our_revision.starts_with("dbg_sync")) return false;
117
118 std::string_view hash1 = ExtractNetworkRevisionHash(our_revision);
119 std::string_view hash2 = ExtractNetworkRevisionHash(other);
120 return hash1 == hash2;
121}
122
123/**
124 * Check if an game entry is compatible with our client.

Callers 2

Receive_CLIENT_JOINMethod · 0.85
CheckGameCompatibilityFunction · 0.85

Calls 2

GetNetworkRevisionStringFunction · 0.85

Tested by

no test coverage detected