Codechange: refactor CheckGameCompatibility() from existing function

Later commits use this function in other places too.
This commit is contained in:
Patric Stout
2021-04-26 20:02:58 +02:00
committed by Patric Stout
parent b3003dd163
commit b57d845e55
3 changed files with 22 additions and 8 deletions

View File

@@ -106,6 +106,21 @@ bool IsNetworkCompatibleVersion(const char *other)
return hash1 != nullptr && hash2 != nullptr && strncmp(hash1, hash2, GITHASH_SUFFIX_LEN) == 0;
}
/**
* Check if an game entry is compatible with our client.
*/
void CheckGameCompatibility(NetworkGameInfo &ngi)
{
/* Check if we are allowed on this server based on the revision-check. */
ngi.version_compatible = IsNetworkCompatibleVersion(ngi.server_revision);
ngi.compatible = ngi.version_compatible;
/* Check if we have all the GRFs on the client-system too. */
for (const GRFConfig *c = ngi.grfconfig; c != nullptr; c = c->next) {
if (c->status == GCS_NOT_FOUND) ngi.compatible = false;
}
}
/**
* Fill a NetworkGameInfo structure with the latest information of the server.
* @param ngi the NetworkGameInfo struct to fill with data.