mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(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
This commit is contained in:
parent
2c99805117
commit
4f62472fd9
@ -37,7 +37,6 @@ STAGE = !!STAGE!!
|
|||||||
MAKEDEPEND = !!MAKEDEPEND!!
|
MAKEDEPEND = !!MAKEDEPEND!!
|
||||||
CFLAGS_MAKEDEP = !!CFLAGS_MAKEDEP!!
|
CFLAGS_MAKEDEP = !!CFLAGS_MAKEDEP!!
|
||||||
SORT = !!SORT!!
|
SORT = !!SORT!!
|
||||||
REVISION = !!REVISION!!
|
|
||||||
AWK = !!AWK!!
|
AWK = !!AWK!!
|
||||||
CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!!
|
CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!!
|
||||||
CONFIG_CACHE_LINKER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!!
|
CONFIG_CACHE_LINKER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!!
|
||||||
@ -94,15 +93,9 @@ $(LANG_OBJS_DIR)/table/strings.h: $(LANG_DIR)/english.txt $(LANG_OBJS_DIR)/$(STR
|
|||||||
VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
|
VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
|
||||||
MODIFIED := $(shell echo "$(VERSIONS)" | cut -f 3 -d' ')
|
MODIFIED := $(shell echo "$(VERSIONS)" | cut -f 3 -d' ')
|
||||||
|
|
||||||
ifdef REVISION
|
|
||||||
# Use specified revision (which should be of the form "r000").
|
|
||||||
REV := $(REVISION)
|
|
||||||
REV_NR := $(shell echo $(REVISION) | sed "s@[^0-9]@@g")
|
|
||||||
else
|
|
||||||
# Use autodetected revisions
|
# Use autodetected revisions
|
||||||
REV := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
|
REV := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
|
||||||
REV_NR := $(shell echo "$(VERSIONS)" | cut -f 2 -d' ')
|
REV_NR := $(shell echo "$(VERSIONS)" | cut -f 2 -d' ')
|
||||||
endif
|
|
||||||
|
|
||||||
# Make sure we have something in REV and REV_NR
|
# Make sure we have something in REV and REV_NR
|
||||||
ifeq ($(REV),)
|
ifeq ($(REV),)
|
||||||
|
25
config.lib
25
config.lib
@ -32,7 +32,6 @@ set_default() {
|
|||||||
os="DETECT"
|
os="DETECT"
|
||||||
endian="AUTO"
|
endian="AUTO"
|
||||||
cpu_type="DETECT"
|
cpu_type="DETECT"
|
||||||
revision=""
|
|
||||||
config_log="config.log"
|
config_log="config.log"
|
||||||
prefix_dir="/usr/local"
|
prefix_dir="/usr/local"
|
||||||
binary_dir="games"
|
binary_dir="games"
|
||||||
@ -107,7 +106,6 @@ set_default() {
|
|||||||
os
|
os
|
||||||
endian
|
endian
|
||||||
cpu_type
|
cpu_type
|
||||||
revision
|
|
||||||
config_log
|
config_log
|
||||||
prefix_dir
|
prefix_dir
|
||||||
binary_dir
|
binary_dir
|
||||||
@ -199,8 +197,6 @@ detect_params() {
|
|||||||
--cpu-type) prev_p="cpu_type";;
|
--cpu-type) prev_p="cpu_type";;
|
||||||
--cpu-type=*) cpu_type="$optarg";;
|
--cpu-type=*) cpu_type="$optarg";;
|
||||||
|
|
||||||
--revision=*) revision="$optarg";;
|
|
||||||
|
|
||||||
--cc-build) prevp_p="cc_build";;
|
--cc-build) prevp_p="cc_build";;
|
||||||
--cc-build=*) cc_build="$optarg";;
|
--cc-build=*) cc_build="$optarg";;
|
||||||
--cc-host) prevp_p="cc_host";;
|
--cc-host) prevp_p="cc_host";;
|
||||||
@ -1010,31 +1006,15 @@ check_params() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$revision" ]; then
|
if [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then
|
||||||
log 1 "checking revision... $revision"
|
|
||||||
log 1 "WARNING: we do not advise you to use this setting"
|
|
||||||
log 1 "WARNING: in most cases it is not safe for network use"
|
|
||||||
log 1 "WARNING: USE WITH CAUTION!"
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
elif [ -f "$ROOT_DIR/version" ]; then
|
|
||||||
revision="`cat $ROOT_DIR/version`"
|
|
||||||
|
|
||||||
log 1 "checking revision... $revision"
|
|
||||||
elif [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then
|
|
||||||
revision=""
|
|
||||||
log 1 "checking revision... svn detection"
|
log 1 "checking revision... svn detection"
|
||||||
elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then
|
elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then
|
||||||
revision=""
|
|
||||||
log 1 "checking revision... git detection"
|
log 1 "checking revision... git detection"
|
||||||
elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`hg help 2>/dev/null`" ]; then
|
elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`hg help 2>/dev/null`" ]; then
|
||||||
revision=""
|
|
||||||
log 1 "checking revision... hg detection"
|
log 1 "checking revision... hg detection"
|
||||||
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
|
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
|
||||||
revision=""
|
|
||||||
log 1 "checking revision... source tarball"
|
log 1 "checking revision... source tarball"
|
||||||
else
|
else
|
||||||
revision=""
|
|
||||||
log 1 "checking revision... no detection"
|
log 1 "checking revision... no detection"
|
||||||
log 1 "WARNING: there is no means to determine the version."
|
log 1 "WARNING: there is no means to determine the version."
|
||||||
log 1 "WARNING: please use a subversion, mercurial, or git checkout of OpenTTD."
|
log 1 "WARNING: please use a subversion, mercurial, or git checkout of OpenTTD."
|
||||||
@ -3245,7 +3225,6 @@ make_sed() {
|
|||||||
s@!!SRCS!!@$SRCS@g;
|
s@!!SRCS!!@$SRCS@g;
|
||||||
s@!!OS!!@$os@g;
|
s@!!OS!!@$os@g;
|
||||||
s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
|
s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
|
||||||
s@!!REVISION!!@$revision@g;
|
|
||||||
s@!!AWK!!@$awk@g;
|
s@!!AWK!!@$awk@g;
|
||||||
s@!!DISTCC!!@$distcc@g;
|
s@!!DISTCC!!@$distcc@g;
|
||||||
s@!!NFORENUM!!@$nforenum@g;
|
s@!!NFORENUM!!@$nforenum@g;
|
||||||
@ -3468,8 +3447,6 @@ showhelp() {
|
|||||||
echo " MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/MINGW/OS2/"
|
echo " MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/MINGW/OS2/"
|
||||||
echo " DOS/WINCE/PSP/HAIKU"
|
echo " DOS/WINCE/PSP/HAIKU"
|
||||||
echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE)"
|
echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE)"
|
||||||
echo " --revision=rXXXX overwrite the revision detection."
|
|
||||||
echo " Use with care!"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Paths:"
|
echo "Paths:"
|
||||||
echo " --prefix-dir=dir specifies the prefix for all installed"
|
echo " --prefix-dir=dir specifies the prefix for all installed"
|
||||||
|
@ -329,6 +329,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendJoin()
|
|||||||
|
|
||||||
Packet *p = new Packet(PACKET_CLIENT_JOIN);
|
Packet *p = new Packet(PACKET_CLIENT_JOIN);
|
||||||
p->Send_string(_openttd_revision);
|
p->Send_string(_openttd_revision);
|
||||||
|
p->Send_uint32(_openttd_newgrf_version);
|
||||||
p->Send_string(_settings_client.network.client_name); // Client name
|
p->Send_string(_settings_client.network.client_name); // Client name
|
||||||
p->Send_uint8 (_network_join_as); // PlayAs
|
p->Send_uint8 (_network_join_as); // PlayAs
|
||||||
p->Send_uint8 (NETLANG_ANY); // Language
|
p->Send_uint8 (NETLANG_ANY); // Language
|
||||||
@ -374,13 +375,6 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendGetMap()
|
|||||||
my_client->status = STATUS_MAP_WAIT;
|
my_client->status = STATUS_MAP_WAIT;
|
||||||
|
|
||||||
Packet *p = new Packet(PACKET_CLIENT_GETMAP);
|
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);
|
my_client->SendPacket(p);
|
||||||
return NETWORK_RECV_STATUS_OKAY;
|
return NETWORK_RECV_STATUS_OKAY;
|
||||||
}
|
}
|
||||||
|
@ -856,9 +856,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
|
|||||||
char client_revision[NETWORK_REVISION_LENGTH];
|
char client_revision[NETWORK_REVISION_LENGTH];
|
||||||
|
|
||||||
p->Recv_string(client_revision, sizeof(client_revision));
|
p->Recv_string(client_revision, sizeof(client_revision));
|
||||||
|
uint32 newgrf_version = p->Recv_uint32();
|
||||||
|
|
||||||
/* Check if the client has revision control enabled */
|
/* Check if the client has revision control enabled */
|
||||||
if (!IsNetworkCompatibleVersion(client_revision)) {
|
if (!IsNetworkCompatibleVersion(client_revision) || _openttd_newgrf_version != newgrf_version) {
|
||||||
/* Different revisions!! */
|
/* Different revisions!! */
|
||||||
return this->SendError(NETWORK_ERROR_WRONG_REVISION);
|
return this->SendError(NETWORK_ERROR_WRONG_REVISION);
|
||||||
}
|
}
|
||||||
@ -968,26 +969,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMPANY_PASSWOR
|
|||||||
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GETMAP(Packet *p)
|
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GETMAP(Packet *p)
|
||||||
{
|
{
|
||||||
NetworkClientSocket *new_cs;
|
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?
|
/* The client was never joined.. so this is impossible, right?
|
||||||
* Ignore the packet, give the client a warning, and close his connection */
|
* Ignore the packet, give the client a warning, and close his connection */
|
||||||
if (this->status < STATUS_AUTHORIZED || this->HasClientQuit()) {
|
if (this->status < STATUS_AUTHORIZED || this->HasClientQuit()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user