From 94dfececf6b4cf5d996ff2a12e7801bd640b1a57 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 15 Oct 2011 15:02:28 +0300 Subject: [PATCH] strict_protocol_version_checking setting; PROTOCOL_VERSION in clientserver.h; clean up defaultsettings.cpp and minetest.conf.example --- CMakeLists.txt | 1 + minetest.conf.example | 19 ++++++++++++++----- src/clientserver.h | 2 ++ src/defaultsettings.cpp | 11 ++++++----- src/server.cpp | 15 +++++++++------ 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efab516dc..da569191b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ endif(${CMAKE_VERSION} STREQUAL "2.8.2") # This can be read from ${PROJECT_NAME} after project() is called project(minetest) +# Also remember to set PROTOCOL_VERSION in clientserver.h when releasing set(VERSION_MAJOR 0) set(VERSION_MINOR 3) set(VERSION_PATCH dev-201110xx) diff --git a/minetest.conf.example b/minetest.conf.example index c47ac77ce..130158254 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -109,27 +109,33 @@ screenH# = 600 # # Map directory (everything in the world is stored here) -#map-#dir = /custom/map +#map-dir = /custom/map # Message of the Day #motd = Welcome to this awesome Minetest server! +# Maximum number of players connected simultaneously +#max_users = 20 +# Set to false to allow old clients to connect +#strict_protocol_version_checking = true # Set to true to enable creative mode (unlimited inventory) #creative_mode = false +# Enable players getting damage and dying #enable_damage = false +# A chosen map seed for a new map, leave empty for random +#fixed_map_seed = # Gives some stuff to players at the beginning #give_initial_stuff = false +# New users need to input this password #default_password = # Available privileges: build, teleport, settime, privs, shout #default_privs = build, shout -# Set to true to enable experimental features or stuff that is tested -# (varies from version to version, usually not useful at all) -#enable_experimental = false # Profiler data print interval. #0 = disable. #profiler_print_interval = 0 #enable_mapgen_debug_info = false # Player and object positions are sent at intervals specified by this #objectdata_interval = 0.2 -#active_object_range = 2 +#active_object_send_range_blocks = 3 +#active_block_range = 5 #max_simultaneous_block_sends_per_client = 2 #max_simultaneous_block_sends_server_total = 8 #max_block_send_distance = 8 @@ -140,4 +146,7 @@ screenH# = 600 #server_unload_unused_data_timeout = 60 #server_map_save_interval = 60 #full_block_send_enable_min_time_from_building = 2.0 +# Set to true to enable experimental features or stuff that is tested +# (varies from version to version, usually not useful at all) +#enable_experimental = false diff --git a/src/clientserver.h b/src/clientserver.h index b96cc61aa..0f6925696 100644 --- a/src/clientserver.h +++ b/src/clientserver.h @@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "utility.h" +#define PROTOCOL_VERSION 3 + #define PROTOCOL_ID 0x4f457403 #define PASSWORD_SIZE 28 // Maximum password length. Allows for diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 05b0611e9..2f4147a99 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -76,18 +76,19 @@ void set_default_settings(Settings *settings) settings->setDefault("screenshot_path", "."); // Server stuff + // "map-dir" doesn't exist by default. settings->setDefault("motd", ""); settings->setDefault("max_users", "20"); - settings->setDefault("enable_experimental", "false"); + settings->setDefault("strict_protocol_version_checking", "true"); settings->setDefault("creative_mode", "false"); settings->setDefault("enable_damage", "true"); + settings->setDefault("fixed_map_seed", ""); settings->setDefault("give_initial_stuff", "false"); settings->setDefault("default_password", ""); settings->setDefault("default_privs", "build, shout"); + settings->setDefault("profiler_print_interval", "0"); settings->setDefault("enable_mapgen_debug_info", "false"); - settings->setDefault("fixed_map_seed", ""); - settings->setDefault("objectdata_interval", "0.2"); settings->setDefault("active_object_send_range_blocks", "3"); settings->setDefault("active_block_range", "5"); @@ -100,8 +101,8 @@ void set_default_settings(Settings *settings) settings->setDefault("time_send_interval", "20"); settings->setDefault("time_speed", "96"); settings->setDefault("server_unload_unused_data_timeout", "60"); - settings->setDefault("server_map_save_interval", "60"); + settings->setDefault("server_map_save_interval", "10"); settings->setDefault("full_block_send_enable_min_time_from_building", "2.0"); - //settings->setDefault("dungeon_rarity", "0.025"); + settings->setDefault("enable_experimental", "false"); } diff --git a/src/server.cpp b/src/server.cpp index 59f7477a9..828eadbf3 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1927,11 +1927,14 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) } /* Uhh... this should actually be a warning but let's do it like this */ - if(net_proto_version < 2) + if(g_settings->getBool("strict_protocol_version_checking")) { - SendAccessDenied(m_con, peer_id, - L"Your client is too old. Please upgrade."); - return; + if(net_proto_version < PROTOCOL_VERSION) + { + SendAccessDenied(m_con, peer_id, + L"Your client is too old. Please upgrade."); + return; + } } /* @@ -2110,9 +2113,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) } // Warnings about protocol version can be issued here - if(getClient(peer->id)->net_proto_version < 3) + if(getClient(peer->id)->net_proto_version < PROTOCOL_VERSION) { - SendChatMessage(peer_id, L"# Server: WARNING: YOUR CLIENT IS OLD AND DOES NOT WORK PROPERLY WITH THIS SERVER"); + SendChatMessage(peer_id, L"# Server: WARNING: YOUR CLIENT IS OLD AND MAY WORK PROPERLY WITH THIS SERVER"); } /* -- 2.25.1