diff options
author | Patric Stout <truebrain@openttd.org> | 2021-04-26 20:02:58 +0200 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-04-27 20:18:53 +0200 |
commit | b57d845e55f733514d235e24f64b09a8744f3abc (patch) | |
tree | f50ec91958930485070826c308b9cd028e62def9 /src/network/core | |
parent | b3003dd163ab6b7902da33fa6cfaa29e45556db1 (diff) | |
download | openttd-b57d845e55f733514d235e24f64b09a8744f3abc.tar.xz |
Codechange: refactor CheckGameCompatibility() from existing function
Later commits use this function in other places too.
Diffstat (limited to 'src/network/core')
-rw-r--r-- | src/network/core/game_info.cpp | 15 | ||||
-rw-r--r-- | src/network/core/game_info.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/network/core/game_info.cpp b/src/network/core/game_info.cpp index b664bb580..55b5d1749 100644 --- a/src/network/core/game_info.cpp +++ b/src/network/core/game_info.cpp @@ -107,6 +107,21 @@ bool IsNetworkCompatibleVersion(const char *other) } /** + * 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. */ diff --git a/src/network/core/game_info.h b/src/network/core/game_info.h index 776700511..28aea7507 100644 --- a/src/network/core/game_info.h +++ b/src/network/core/game_info.h @@ -93,6 +93,7 @@ extern NetworkServerGameInfo _network_game_info; const char *GetNetworkRevisionString(); bool IsNetworkCompatibleVersion(const char *other); +void CheckGameCompatibility(NetworkGameInfo &ngi); void FillNetworkGameInfo(NetworkGameInfo &ngi); |