diff options
author | rubidium <rubidium@openttd.org> | 2012-01-17 17:27:38 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2012-01-17 17:27:38 +0000 |
commit | 4f62472fd98145ca9d4e479dfbd1f2fb0b4ed524 (patch) | |
tree | a5e1f9426fec0d4518ad112f0511edcf5caeb38e /src | |
parent | 2c998051173484aeac026de21a50177313908d37 (diff) | |
download | openttd-4f62472fd98145ca9d4e479dfbd1f2fb0b4ed524.tar.xz |
(svn r23817) -Fix [FS#4962]: desync due to different NewGRF version. So reduce the chance that it happens significantly with betas/RCs/nightlies by doing the same as is done for stable releases: check the NewGRF version of server vs client.
Previously this check was not done for nightlies/betas/RCs due to missing versioning information in the source tarballs, but they have that for a while now. So just force the NewGRF version check for all versions, and remove the broken --revision configure option
Diffstat (limited to 'src')
-rw-r--r-- | src/network/network_client.cpp | 8 | ||||
-rw-r--r-- | src/network/network_server.cpp | 23 |
2 files changed, 3 insertions, 28 deletions
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 9f348b6fa..8eaa2eb41 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -329,6 +329,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendJoin() Packet *p = new Packet(PACKET_CLIENT_JOIN); p->Send_string(_openttd_revision); + p->Send_uint32(_openttd_newgrf_version); p->Send_string(_settings_client.network.client_name); // Client name p->Send_uint8 (_network_join_as); // PlayAs p->Send_uint8 (NETLANG_ANY); // Language @@ -374,13 +375,6 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendGetMap() my_client->status = STATUS_MAP_WAIT; Packet *p = new Packet(PACKET_CLIENT_GETMAP); - /* Send the OpenTTD version to the server, let it validate it too. - * But only do it for stable releases because of those we are sure - * that everybody has the same NewGRF version. For trunk and the - * branches we make tarballs of the OpenTTDs compiled from tarball - * will have the lower bits set to 0. As such they would become - * incompatible, which we would like to prevent by this. */ - if (IsReleasedVersion()) p->Send_uint32(_openttd_newgrf_version); my_client->SendPacket(p); return NETWORK_RECV_STATUS_OKAY; } diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index dbbe8fe28..42d5ed9d5 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -856,9 +856,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p) char client_revision[NETWORK_REVISION_LENGTH]; p->Recv_string(client_revision, sizeof(client_revision)); + uint32 newgrf_version = p->Recv_uint32(); /* Check if the client has revision control enabled */ - if (!IsNetworkCompatibleVersion(client_revision)) { + if (!IsNetworkCompatibleVersion(client_revision) || _openttd_newgrf_version != newgrf_version) { /* Different revisions!! */ return this->SendError(NETWORK_ERROR_WRONG_REVISION); } @@ -968,26 +969,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMPANY_PASSWOR NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GETMAP(Packet *p) { NetworkClientSocket *new_cs; - - /* Do an extra version match. We told the client our version already, - * lets confirm that the client isn't lieing to us. - * But only do it for stable releases because of those we are sure - * that everybody has the same NewGRF version. For trunk and the - * branches we make tarballs of the OpenTTDs compiled from tarball - * will have the lower bits set to 0. As such they would become - * incompatible, which we would like to prevent by this. */ - if (IsReleasedVersion()) { - if (_openttd_newgrf_version != p->Recv_uint32()) { - /* The version we get from the client differs, it must have the - * wrong version. The client must be wrong. */ - return this->SendError(NETWORK_ERROR_NOT_EXPECTED); - } - } else if (p->size != 3) { - /* We received a packet from a version that claims to be stable. - * That shouldn't happen. The client must be wrong. */ - return this->SendError(NETWORK_ERROR_NOT_EXPECTED); - } - /* The client was never joined.. so this is impossible, right? * Ignore the packet, give the client a warning, and close his connection */ if (this->status < STATUS_AUTHORIZED || this->HasClientQuit()) { |