summaryrefslogtreecommitdiff
path: root/src/network/network_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/network_server.cpp')
-rw-r--r--src/network/network_server.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index c35e437e5..89d97ae50 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -29,6 +29,7 @@
#include "../company_gui.h"
#include "../window_func.h"
#include "../roadveh.h"
+#include "../rev.h"
#include "table/strings.h"
@@ -776,6 +777,27 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_GETMAP)
{
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 (HasBit(_openttd_newgrf_version, 19)) {
+ 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. */
+ SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
+ return NETWORK_RECV_STATUS_OKAY;
+ }
+ } 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. */
+ SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
+ return NETWORK_RECV_STATUS_OKAY;
+ }
+
/* The client was never joined.. so this is impossible, right?
* Ignore the packet, give the client a warning, and close his connection */
if (cs->status < STATUS_AUTH || cs->HasClientQuit()) {