* 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 */
| 102 | * @param other the version string to compare to |
| 103 | */ |
| 104 | bool 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. |
no test coverage detected