Initial work on server_config.xml
This commit is contained in:
parent
4262418532
commit
0d93fe427e
@ -1,5 +1,5 @@
|
||||
# Modify this file to change the last-modified date when you add/remove a file.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
||||
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
||||
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
||||
|
@ -18,13 +18,13 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include <vector>
|
||||
|
||||
// The order here is important. If all_params is declared later (e.g. after
|
||||
// the #includes), all elements will be added to all_params, and then
|
||||
// all_params will be initialised, i.e. cleared!
|
||||
class UserConfigParam;
|
||||
static PtrVector<UserConfigParam, REF> all_params;
|
||||
static std::vector<UserConfigParam*> all_params;
|
||||
|
||||
// X-macros
|
||||
#define PARAM_PREFIX
|
||||
@ -53,7 +53,9 @@ const int UserConfig::m_current_config_version = 8;
|
||||
// ----------------------------------------------------------------------------
|
||||
UserConfigParam::~UserConfigParam()
|
||||
{
|
||||
all_params.remove(this);
|
||||
// Now we have server config param so we cannot do this anymore,
|
||||
// esp all params are kept until the closing of stk anyway
|
||||
//all_params.remove(this);
|
||||
} // ~UserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -181,16 +183,6 @@ void GroupUserConfigParam::addChild(UserConfigParam* child)
|
||||
m_attributes.push_back(child);
|
||||
} // addChild
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template<typename T, typename U>
|
||||
MapUserConfigParam<T, U>::MapUserConfigParam(const char* param_name,
|
||||
const char* comment)
|
||||
{
|
||||
m_param_name = param_name;
|
||||
all_params.push_back(this);
|
||||
if (comment != NULL) m_comment = comment;
|
||||
} // MapUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template<typename T, typename U>
|
||||
MapUserConfigParam<T, U>::MapUserConfigParam(const char* param_name,
|
||||
@ -672,7 +664,7 @@ bool UserConfig::loadConfig()
|
||||
const int paramAmount = all_params.size();
|
||||
for(int i=0; i<paramAmount; i++)
|
||||
{
|
||||
all_params[i].findYourDataInAChildOf(root);
|
||||
all_params[i]->findYourDataInAChildOf(root);
|
||||
}
|
||||
|
||||
|
||||
@ -709,7 +701,7 @@ void UserConfig::saveConfig()
|
||||
for(int i=0; i<paramAmount; i++)
|
||||
{
|
||||
//Log::info("UserConfig", "Saving parameter %d to file", i);
|
||||
all_params[i].write(configfile);
|
||||
all_params[i]->write(configfile);
|
||||
}
|
||||
|
||||
configfile << "</stkconfig>\n";
|
||||
|
@ -102,11 +102,17 @@ public:
|
||||
template<typename T, typename U>
|
||||
class MapUserConfigParam : public UserConfigParam
|
||||
{
|
||||
protected:
|
||||
std::map<T, U> m_elements;
|
||||
MapUserConfigParam(const char* param_name,
|
||||
const char* comment)
|
||||
{
|
||||
m_param_name = param_name;
|
||||
if (comment != NULL)
|
||||
m_comment = comment;
|
||||
}
|
||||
|
||||
public:
|
||||
MapUserConfigParam(const char* param_name,
|
||||
const char* comment = NULL);
|
||||
MapUserConfigParam(const char* param_name,
|
||||
const char* comment,
|
||||
std::map<T, U> default_value);
|
||||
@ -162,8 +168,15 @@ typedef MapUserConfigParam<std::string, uint32_t> StringToUIntUserConfigParam;
|
||||
// ============================================================================
|
||||
class IntUserConfigParam : public UserConfigParam
|
||||
{
|
||||
protected:
|
||||
int m_value;
|
||||
int m_default_value;
|
||||
IntUserConfigParam(const char* param_name, const char* comment)
|
||||
{
|
||||
m_param_name = param_name;
|
||||
if (comment != NULL)
|
||||
m_comment = comment;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@ -216,8 +229,15 @@ public:
|
||||
// ============================================================================
|
||||
class StringUserConfigParam : public UserConfigParam
|
||||
{
|
||||
protected:
|
||||
std::string m_value;
|
||||
std::string m_default_value;
|
||||
StringUserConfigParam(const char* param_name, const char* comment)
|
||||
{
|
||||
m_param_name = param_name;
|
||||
if (comment != NULL)
|
||||
m_comment = comment;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@ -249,8 +269,15 @@ public:
|
||||
// ============================================================================
|
||||
class BoolUserConfigParam : public UserConfigParam
|
||||
{
|
||||
protected:
|
||||
bool m_value;
|
||||
bool m_default_value;
|
||||
BoolUserConfigParam(const char* param_name, const char* comment)
|
||||
{
|
||||
m_param_name = param_name;
|
||||
if (comment != NULL)
|
||||
m_comment = comment;
|
||||
}
|
||||
|
||||
public:
|
||||
BoolUserConfigParam(bool default_value, const char* param_name,
|
||||
@ -274,8 +301,15 @@ public:
|
||||
// ============================================================================
|
||||
class FloatUserConfigParam : public UserConfigParam
|
||||
{
|
||||
protected:
|
||||
float m_value;
|
||||
float m_default_value;
|
||||
FloatUserConfigParam(const char* param_name, const char* comment)
|
||||
{
|
||||
m_param_name = param_name;
|
||||
if (comment != NULL)
|
||||
m_comment = comment;
|
||||
}
|
||||
|
||||
public:
|
||||
FloatUserConfigParam(float default_value, const char* param_name,
|
||||
@ -725,80 +759,17 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT(BoolUserConfigParam(false, "lobby-chat",
|
||||
&m_network_group, "Enable chatting in networking lobby, if off than "
|
||||
"no chat message will be displayed from any players."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_voting_timeout
|
||||
PARAM_DEFAULT(FloatUserConfigParam(20.0f, "voting-timeout",
|
||||
&m_network_group, "Timeout in seconds for voting tracks in server."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_validation_timeout
|
||||
PARAM_DEFAULT(FloatUserConfigParam(20.0f, "validation-timeout",
|
||||
&m_network_group, "Timeout in seconds for validation of clients."));
|
||||
PARAM_PREFIX IntUserConfigParam m_server_max_players
|
||||
PARAM_DEFAULT(IntUserConfigParam(8, "server-max-players",
|
||||
&m_network_group, "Maximum number of players on the server."));
|
||||
PARAM_PREFIX BoolUserConfigParam m_firewalled_server
|
||||
PARAM_DEFAULT(BoolUserConfigParam(true, "firewalled-server",
|
||||
&m_network_group, "Disable it to turn off all stun related code "
|
||||
"in server, for official server hosting use only."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_start_game_counter
|
||||
PARAM_DEFAULT(FloatUserConfigParam(30.0f, "start-game-counter",
|
||||
&m_network_group, "Time to wait before entering kart selection screen "
|
||||
"if satisfied start-game-threshold below for owner less or ranked "
|
||||
"server."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_start_game_threshold
|
||||
PARAM_DEFAULT(FloatUserConfigParam(0.7f, "start-game-threshold",
|
||||
&m_network_group, "Only auto start kart selection when number of "
|
||||
"connected player is larger than max player * this value, for "
|
||||
"owner less or ranked server, after start-game-counter."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_flag_return_timemout
|
||||
PARAM_DEFAULT(FloatUserConfigParam(20.0f, "flag-return-timemout",
|
||||
&m_network_group, "Time in seconds when a flag is dropped a by player in CTF "
|
||||
"returning to its own base."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_hit_limit_threshold
|
||||
PARAM_DEFAULT(FloatUserConfigParam(5.0f, "hit-limit-threshold",
|
||||
&m_network_group, "Value used to calculate hit limit in free for all, which "
|
||||
"is min(number of players * hit-limit-threshold, 40), negative value to disable hit limit."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_time_limit_threshold_ffa
|
||||
PARAM_DEFAULT(FloatUserConfigParam(0.7f, "time-limit-threshold-ffa",
|
||||
&m_network_group, "Value used to calculate time limit in free for all, which "
|
||||
"is max(number of players * time-limit-threshold-ffa, 3.0) * 60, negative value to disable time limit."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_capture_limit_threshold
|
||||
PARAM_DEFAULT(FloatUserConfigParam(0.7f, "capture-limit-threshold",
|
||||
&m_network_group, "Value used to calculate capture limit in CTF, which "
|
||||
"is max(3.0, number of players * capture-limit-threshold), negative value to disable capture limit."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_time_limit_threshold_ctf
|
||||
PARAM_DEFAULT(FloatUserConfigParam(0.9f, "time-limit-threshold-ctf",
|
||||
&m_network_group, "Value used to calculate time limit in CTF, which "
|
||||
"is max(3.0, number of players * (time-limit-threshold-ctf + flag-return-timemout / 60.0)) * 60.0,"
|
||||
" negative value to disable time limit."));
|
||||
PARAM_PREFIX StringToUIntUserConfigParam m_server_ip_ban_list
|
||||
PARAM_DEFAULT(StringToUIntUserConfigParam("server_ip_ban_list",
|
||||
"LHS: IP in X.X.X.X/Y (CIDR) format, use Y of 32 for a specific ip, "
|
||||
"RHS: time epoch to expire, if -1 (uint32_t max) than a permanent ban.",
|
||||
{ { "0.0.0.0/0", 0u } }));
|
||||
PARAM_PREFIX UIntToUIntUserConfigParam m_server_online_id_ban_list
|
||||
PARAM_DEFAULT(UIntToUIntUserConfigParam("server_online_id_ban_list",
|
||||
"LHS: online id, RHS: time epoch to expire, if -1 (uint32_t max) than a permanent ban.",
|
||||
{ { 0u, 0u } }));
|
||||
PARAM_PREFIX IntUserConfigParam m_max_ping
|
||||
PARAM_DEFAULT(IntUserConfigParam(300, "max-ping",
|
||||
&m_network_group, "Maximum ping allowed for a player (in ms)."));
|
||||
PARAM_PREFIX IntUserConfigParam m_jitter_tolerance
|
||||
PARAM_DEFAULT(IntUserConfigParam(100, "jitter-tolerance",
|
||||
&m_network_group, "Tolerance of jitter in network allowed (in ms)."));
|
||||
PARAM_PREFIX IntUserConfigParam m_max_players
|
||||
PARAM_DEFAULT(IntUserConfigParam(8, "max-players",
|
||||
&m_network_group, "Maximum number of players on the server "
|
||||
"(for gui server creation."));
|
||||
PARAM_PREFIX IntUserConfigParam m_timer_sync_difference_tolerance
|
||||
PARAM_DEFAULT(IntUserConfigParam(5, "timer-sync-difference-tolerance",
|
||||
&m_network_group, "Max time difference tolerance (in ms) to synchronize timer with server."));
|
||||
PARAM_PREFIX BoolUserConfigParam m_kick_high_ping_players
|
||||
PARAM_DEFAULT(BoolUserConfigParam(false, "kick-high-ping-players",
|
||||
&m_network_group, "Kick players whose ping is above max-ping."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_auto_lap_ratio
|
||||
PARAM_DEFAULT(FloatUserConfigParam(-1.0f, "auto-lap-ratio",
|
||||
&m_network_group, "Value used by server to automatically calculate lap of each race in network game, "
|
||||
"if more than 0.0f, the number of lap of each track vote in linear race will be determined "
|
||||
"by max(1.0f, auto-lap-ratio * default lap of that track)."));
|
||||
|
||||
// ---- Gamemode setup
|
||||
PARAM_PREFIX UIntToUIntUserConfigParam m_num_karts_per_gamemode
|
||||
PARAM_DEFAULT(UIntToUIntUserConfigParam("num_karts_per_gamemode",
|
||||
PARAM_DEFAULT(UIntToUIntUserConfigParam("num-karts-per-gamemode",
|
||||
"The Number of karts per gamemode.",
|
||||
{
|
||||
{ 0u, 4u },
|
||||
|
35
src/main.cpp
35
src/main.cpp
@ -222,6 +222,7 @@
|
||||
#include "network/rewind_manager.hpp"
|
||||
#include "network/rewind_queue.hpp"
|
||||
#include "network/server.hpp"
|
||||
#include "network/server_config.hpp"
|
||||
#include "network/servers_manager.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "online/profile_manager.hpp"
|
||||
@ -1157,21 +1158,21 @@ int handleCmdLine()
|
||||
}
|
||||
if (CommandLine::has("--max-players", &n))
|
||||
{
|
||||
UserConfigParams::m_server_max_players = n;
|
||||
ServerConfig::m_server_max_players = n;
|
||||
}
|
||||
|
||||
if (UserConfigParams::m_server_max_players < 1)
|
||||
if (ServerConfig::m_server_max_players < 1)
|
||||
{
|
||||
UserConfigParams::m_server_max_players = 1;
|
||||
ServerConfig::m_server_max_players = 1;
|
||||
}
|
||||
NetworkConfig::get()->setMaxPlayers(UserConfigParams::m_server_max_players);
|
||||
NetworkConfig::get()->setMaxPlayers(ServerConfig::m_server_max_players);
|
||||
|
||||
if (CommandLine::has("--min-players", &n))
|
||||
{
|
||||
float threshold = ((float)(n) - 0.5f) /
|
||||
UserConfigParams::m_server_max_players;
|
||||
ServerConfig::m_server_max_players;
|
||||
threshold = std::max(std::min(threshold, 1.0f), 0.0f);
|
||||
UserConfigParams::m_start_game_threshold = threshold;
|
||||
ServerConfig::m_start_game_threshold = threshold;
|
||||
}
|
||||
if (CommandLine::has("--port", &n))
|
||||
{
|
||||
@ -1337,19 +1338,19 @@ int handleCmdLine()
|
||||
|
||||
if (is_battle)
|
||||
{
|
||||
if (UserConfigParams::m_hit_limit_threshold < 0.0f &&
|
||||
UserConfigParams::m_time_limit_threshold_ffa < 0.0f)
|
||||
if (ServerConfig::m_hit_limit_threshold < 0.0f &&
|
||||
ServerConfig::m_time_limit_threshold_ffa < 0.0f)
|
||||
{
|
||||
Log::warn("main", "Reset invalid hit and time limit settings");
|
||||
UserConfigParams::m_hit_limit_threshold.revertToDefaults();
|
||||
UserConfigParams::m_time_limit_threshold_ffa.revertToDefaults();
|
||||
ServerConfig::m_hit_limit_threshold.revertToDefaults();
|
||||
ServerConfig::m_time_limit_threshold_ffa.revertToDefaults();
|
||||
}
|
||||
if (UserConfigParams::m_capture_limit_threshold < 0.0f &&
|
||||
UserConfigParams::m_time_limit_threshold_ctf < 0.0f)
|
||||
if (ServerConfig::m_capture_limit_threshold < 0.0f &&
|
||||
ServerConfig::m_time_limit_threshold_ctf < 0.0f)
|
||||
{
|
||||
Log::warn("main", "Reset invalid Capture and time limit settings");
|
||||
UserConfigParams::m_capture_limit_threshold.revertToDefaults();
|
||||
UserConfigParams::m_time_limit_threshold_ctf.revertToDefaults();
|
||||
ServerConfig::m_capture_limit_threshold.revertToDefaults();
|
||||
ServerConfig::m_time_limit_threshold_ctf.revertToDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2377,7 +2378,7 @@ void runUnitTests()
|
||||
NetworkConfig::get()->unsetNetworking();
|
||||
ServerLobby sl;
|
||||
|
||||
UserConfigParams::m_server_ip_ban_list =
|
||||
ServerConfig::m_server_ip_ban_list =
|
||||
{
|
||||
{ "1.2.3.4/32", std::numeric_limits<uint32_t>::max() }
|
||||
};
|
||||
@ -2386,7 +2387,7 @@ void runUnitTests()
|
||||
assert(!sl.isBannedForIP(TransportAddress("1.2.3.5")));
|
||||
assert(!sl.isBannedForIP(TransportAddress("1.2.3.3")));
|
||||
|
||||
UserConfigParams::m_server_ip_ban_list =
|
||||
ServerConfig::m_server_ip_ban_list =
|
||||
{
|
||||
{ "1.2.3.4/23", std::numeric_limits<uint32_t>::max() }
|
||||
};
|
||||
@ -2402,7 +2403,7 @@ void runUnitTests()
|
||||
assert(sl.isBannedForIP(TransportAddress("1.2.3.255")));
|
||||
assert(!sl.isBannedForIP(TransportAddress("1.2.4.0")));
|
||||
|
||||
UserConfigParams::m_server_ip_ban_list =
|
||||
ServerConfig::m_server_ip_ban_list =
|
||||
{
|
||||
{ "11.12.13.14/22", std::numeric_limits<uint32_t>::max() },
|
||||
{ "12.13.14.15/24", std::numeric_limits<uint32_t>::max() },
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include "modes/capture_the_flag.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
@ -26,6 +25,7 @@
|
||||
#include "network/network_config.hpp"
|
||||
#include "network/network_string.hpp"
|
||||
#include "network/protocols/game_events_protocol.hpp"
|
||||
#include "network/server_config.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "physics/triangle_mesh.hpp"
|
||||
#include "states_screens/race_gui.hpp"
|
||||
@ -190,7 +190,7 @@ void CaptureTheFlag::update(int ticks)
|
||||
m_blue_return_ticks++;
|
||||
|
||||
const int max_flag_return_timeout = stk_config->time2Ticks(
|
||||
UserConfigParams::m_flag_return_timemout);
|
||||
ServerConfig::m_flag_return_timemout);
|
||||
if (m_red_holder == -1 && m_red_return_ticks > max_flag_return_timeout)
|
||||
{
|
||||
resetRedFlagToOrigin();
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "network/network_config.hpp"
|
||||
#include "network/network_player_profile.hpp"
|
||||
#include "network/protocols/game_events_protocol.hpp"
|
||||
#include "network/server_config.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
@ -183,8 +184,8 @@ void GameSetup::addServerInfo(NetworkString* ns)
|
||||
}
|
||||
if (NetworkConfig::get()->isOwnerLess())
|
||||
{
|
||||
ns->addFloat(UserConfigParams::m_start_game_threshold)
|
||||
.addFloat(UserConfigParams::m_start_game_counter);
|
||||
ns->addFloat(ServerConfig::m_start_game_threshold)
|
||||
.addFloat(ServerConfig::m_start_game_counter);
|
||||
}
|
||||
else
|
||||
ns->addFloat(0.0f).addFloat(0.0f);
|
||||
|
@ -16,9 +16,9 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "network/network_config.hpp"
|
||||
#include "network/network_player_profile.hpp"
|
||||
#include "network/server_config.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "network/protocols/server_lobby.hpp"
|
||||
@ -91,7 +91,7 @@ void mainLoop(STKHost* host)
|
||||
// ATM use permanently ban
|
||||
auto sl = LobbyProtocol::get<ServerLobby>();
|
||||
auto lock = sl->acquireConnectionMutex();
|
||||
UserConfigParams::m_server_ip_ban_list
|
||||
ServerConfig::m_server_ip_ban_list
|
||||
[peer->getAddress().toString(false/*show_port*/) + "/32"]
|
||||
= std::numeric_limits<uint32_t>::max();
|
||||
sl->updateBanList();
|
||||
@ -112,14 +112,14 @@ void mainLoop(STKHost* host)
|
||||
}
|
||||
else if (str == "listban")
|
||||
{
|
||||
for (auto& ban : UserConfigParams::m_server_ip_ban_list)
|
||||
for (auto& ban : ServerConfig::m_server_ip_ban_list)
|
||||
{
|
||||
if (ban.first == "0.0.0.0/0")
|
||||
continue;
|
||||
std::cout << "IP: " << ban.first << ", expire at: " <<
|
||||
ban.second << std::endl;
|
||||
}
|
||||
for (auto& ban : UserConfigParams::m_server_online_id_ban_list)
|
||||
for (auto& ban : ServerConfig::m_server_online_id_ban_list)
|
||||
{
|
||||
if (ban.first == 0)
|
||||
continue;
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "network/protocols/game_events_protocol.hpp"
|
||||
#include "network/race_event_manager.hpp"
|
||||
#include "network/server.hpp"
|
||||
#include "network/server_config.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "states_screens/networking_lobby.hpp"
|
||||
@ -233,7 +234,7 @@ void ClientLobby::addAllPlayers(Event* event)
|
||||
// time
|
||||
if (!STKHost::get()->getNetworkTimerSynchronizer()->isSynchronised())
|
||||
{
|
||||
if (UserConfigParams::m_voting_timeout >= 10.0f)
|
||||
if (ServerConfig::m_voting_timeout >= 10.0f)
|
||||
{
|
||||
core::stringw msg = _("Bad network connection is detected.");
|
||||
MessageQueue::add(MessageQueue::MT_ERROR, msg);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "network/protocols/game_protocol.hpp"
|
||||
#include "network/protocols/game_events_protocol.hpp"
|
||||
#include "network/race_event_manager.hpp"
|
||||
#include "network/server_config.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
@ -426,17 +427,17 @@ void ServerLobby::asynchronousUpdate()
|
||||
float player_size = (float)m_game_setup->getPlayerCount();
|
||||
if ((player_size >=
|
||||
(float)NetworkConfig::get()->getMaxPlayers() *
|
||||
UserConfigParams::m_start_game_threshold ||
|
||||
ServerConfig::m_start_game_threshold ||
|
||||
m_game_setup->isGrandPrixStarted()) &&
|
||||
m_timeout.load() == std::numeric_limits<int64_t>::max())
|
||||
{
|
||||
m_timeout.store((int64_t)StkTime::getRealTimeMs() +
|
||||
(int64_t)
|
||||
(UserConfigParams::m_start_game_counter * 1000.0f));
|
||||
(ServerConfig::m_start_game_counter * 1000.0f));
|
||||
}
|
||||
else if (player_size <
|
||||
(float)NetworkConfig::get()->getMaxPlayers() *
|
||||
UserConfigParams::m_start_game_threshold &&
|
||||
ServerConfig::m_start_game_threshold &&
|
||||
!m_game_setup->isGrandPrixStarted())
|
||||
{
|
||||
m_timeout.store(std::numeric_limits<int64_t>::max());
|
||||
@ -474,7 +475,7 @@ void ServerLobby::asynchronousUpdate()
|
||||
if (m_timeout.load() < (int64_t)StkTime::getRealTimeMs() ||
|
||||
(std::get<3>(result) &&
|
||||
m_timeout.load() -
|
||||
(int64_t)(UserConfigParams::m_voting_timeout / 2.0f * 1000.0f) <
|
||||
(int64_t)(ServerConfig::m_voting_timeout / 2.0f * 1000.0f) <
|
||||
(int64_t)StkTime::getRealTimeMs()))
|
||||
{
|
||||
m_game_setup->setRace(std::get<0>(result), std::get<1>(result),
|
||||
@ -536,7 +537,7 @@ void ServerLobby::asynchronousUpdate()
|
||||
//-----------------------------------------------------------------------------
|
||||
void ServerLobby::sendBadConnectionMessageToPeer(std::shared_ptr<STKPeer> p)
|
||||
{
|
||||
const unsigned max_ping = UserConfigParams::m_max_ping;
|
||||
const unsigned max_ping = ServerConfig::m_max_ping;
|
||||
Log::warn("ServerLobby", "Peer %s cannot catch up with max ping %d.",
|
||||
p->getAddress().toString().c_str(), max_ping);
|
||||
NetworkString* msg = getNetworkString();
|
||||
@ -808,7 +809,7 @@ void ServerLobby::startSelection(const Event *event)
|
||||
ns->setSynchronous(true);
|
||||
ns->addUInt8(LE_START_SELECTION).addUInt8(
|
||||
m_game_setup->isGrandPrixStarted() ? 1 : 0)
|
||||
.addUInt8(UserConfigParams::m_auto_lap_ratio > 0.0f ? 1 : 0);
|
||||
.addUInt8(ServerConfig::m_auto_lap_ratio > 0.0f ? 1 : 0);
|
||||
|
||||
// Remove karts / tracks from server that are not supported on all clients
|
||||
std::set<std::string> karts_erase, tracks_erase;
|
||||
@ -893,7 +894,7 @@ void ServerLobby::checkIncomingConnectionRequests()
|
||||
|
||||
// Keep the port open, it can be sent to anywhere as we will send to the
|
||||
// correct peer later in ConnectToPeer.
|
||||
if (UserConfigParams::m_firewalled_server)
|
||||
if (ServerConfig::m_firewalled_server)
|
||||
{
|
||||
BareNetworkString data;
|
||||
data.addUInt8(0);
|
||||
@ -946,7 +947,7 @@ void ServerLobby::checkIncomingConnectionRequests()
|
||||
users_xml->getNode(i)->get("aes-iv", &keys[id].m_aes_iv);
|
||||
users_xml->getNode(i)->get("username", &keys[id].m_name);
|
||||
keys[id].m_tried = false;
|
||||
if (UserConfigParams::m_firewalled_server)
|
||||
if (ServerConfig::m_firewalled_server)
|
||||
{
|
||||
TransportAddress peer_addr(addr, port);
|
||||
std::string peer_addr_str = peer_addr.toString();
|
||||
@ -1764,7 +1765,7 @@ void ServerLobby::playerVote(Event* event)
|
||||
if (m_timeout.load() == std::numeric_limits<int64_t>::max())
|
||||
{
|
||||
m_timeout.store((int64_t)StkTime::getRealTimeMs() +
|
||||
(int64_t)(UserConfigParams::m_voting_timeout * 1000.0f));
|
||||
(int64_t)(ServerConfig::m_voting_timeout * 1000.0f));
|
||||
}
|
||||
int64_t remaining_time =
|
||||
m_timeout.load() - (int64_t)StkTime::getRealTimeMs();
|
||||
@ -1781,14 +1782,14 @@ void ServerLobby::playerVote(Event* event)
|
||||
|
||||
if (race_manager->modeHasLaps())
|
||||
{
|
||||
if (UserConfigParams::m_auto_lap_ratio > 0.0f)
|
||||
if (ServerConfig::m_auto_lap_ratio > 0.0f)
|
||||
{
|
||||
Track* t = track_manager->getTrack(track_name);
|
||||
if (t)
|
||||
{
|
||||
lap = (uint8_t)(fmaxf(1.0f,
|
||||
(float)t->getDefaultNumberOfLaps() *
|
||||
UserConfigParams::m_auto_lap_ratio));
|
||||
ServerConfig::m_auto_lap_ratio));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1805,7 +1806,7 @@ void ServerLobby::playerVote(Event* event)
|
||||
std::string name = StringUtils::wideToUtf8(event->getPeer()
|
||||
->getPlayerProfiles()[0]->getName());
|
||||
other.setSynchronous(true);
|
||||
other.addUInt8(LE_VOTE).addFloat(UserConfigParams::m_voting_timeout)
|
||||
other.addUInt8(LE_VOTE).addFloat(ServerConfig::m_voting_timeout)
|
||||
.encodeString(name).addUInt32(event->getPeer()->getHostId())
|
||||
.encodeString(track_name).addUInt8(lap).addUInt8(reverse);
|
||||
|
||||
@ -1926,33 +1927,33 @@ std::pair<int, float> ServerLobby::getHitCaptureLimit(float num_karts)
|
||||
if (race_manager->getMajorMode() ==
|
||||
RaceManager::MAJOR_MODE_CAPTURE_THE_FLAG)
|
||||
{
|
||||
if (UserConfigParams::m_capture_limit_threshold > 0.0f)
|
||||
if (ServerConfig::m_capture_limit_threshold > 0.0f)
|
||||
{
|
||||
float val = fmaxf(3.0f, num_karts *
|
||||
UserConfigParams::m_capture_limit_threshold);
|
||||
ServerConfig::m_capture_limit_threshold);
|
||||
hit_capture_limit = (int)val;
|
||||
}
|
||||
if (UserConfigParams::m_time_limit_threshold_ctf > 0.0f)
|
||||
if (ServerConfig::m_time_limit_threshold_ctf > 0.0f)
|
||||
{
|
||||
time_limit = fmaxf(2.0f, num_karts *
|
||||
(UserConfigParams::m_time_limit_threshold_ctf +
|
||||
UserConfigParams::m_flag_return_timemout / 60.f) * 60.0f);
|
||||
(ServerConfig::m_time_limit_threshold_ctf +
|
||||
ServerConfig::m_flag_return_timemout / 60.f) * 60.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UserConfigParams::m_hit_limit_threshold > 0.0f)
|
||||
if (ServerConfig::m_hit_limit_threshold > 0.0f)
|
||||
{
|
||||
float val = fminf(num_karts *
|
||||
UserConfigParams::m_hit_limit_threshold, 40.0f);
|
||||
ServerConfig::m_hit_limit_threshold, 40.0f);
|
||||
hit_capture_limit = (int)val;
|
||||
if (hit_capture_limit == 0)
|
||||
hit_capture_limit = 1;
|
||||
}
|
||||
if (UserConfigParams::m_time_limit_threshold_ffa > 0.0f)
|
||||
if (ServerConfig::m_time_limit_threshold_ffa > 0.0f)
|
||||
{
|
||||
time_limit = fmaxf(num_karts *
|
||||
UserConfigParams::m_time_limit_threshold_ffa, 3.0f) * 60.0f;
|
||||
ServerConfig::m_time_limit_threshold_ffa, 3.0f) * 60.0f;
|
||||
}
|
||||
}
|
||||
return std::make_pair(hit_capture_limit, time_limit);
|
||||
@ -1997,7 +1998,7 @@ void ServerLobby::updateBanList()
|
||||
m_ip_ban_list.clear();
|
||||
m_online_id_ban_list.clear();
|
||||
|
||||
for (auto& ban : UserConfigParams::m_server_ip_ban_list)
|
||||
for (auto& ban : ServerConfig::m_server_ip_ban_list)
|
||||
{
|
||||
if (ban.first == "0.0.0.0/0" ||
|
||||
(uint32_t)StkTime::getTimeSinceEpoch() > ban.second)
|
||||
@ -2040,22 +2041,22 @@ void ServerLobby::updateBanList()
|
||||
continue;
|
||||
}
|
||||
final_ip_ban_list[std::get<1>(it->second)] =
|
||||
UserConfigParams::m_server_ip_ban_list.at(std::get<1>(it->second));
|
||||
ServerConfig::m_server_ip_ban_list.at(std::get<1>(it->second));
|
||||
it++;
|
||||
}
|
||||
UserConfigParams::m_server_ip_ban_list = final_ip_ban_list;
|
||||
ServerConfig::m_server_ip_ban_list = final_ip_ban_list;
|
||||
|
||||
std::map<uint32_t, uint32_t> final_online_id_ban_list;
|
||||
for (auto& ban : UserConfigParams::m_server_online_id_ban_list)
|
||||
for (auto& ban : ServerConfig::m_server_online_id_ban_list)
|
||||
{
|
||||
if (ban.first == 0 ||
|
||||
(uint32_t)StkTime::getTimeSinceEpoch() > ban.second)
|
||||
continue;
|
||||
m_online_id_ban_list[ban.first] = ban.second;
|
||||
final_online_id_ban_list[ban.first] =
|
||||
UserConfigParams::m_server_online_id_ban_list.at(ban.first);
|
||||
ServerConfig::m_server_online_id_ban_list.at(ban.first);
|
||||
}
|
||||
UserConfigParams::m_server_online_id_ban_list = final_online_id_ban_list;
|
||||
ServerConfig::m_server_online_id_ban_list = final_online_id_ban_list;
|
||||
} // updateBanList
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -2229,7 +2230,7 @@ void ServerLobby::submitRankingsToAddons()
|
||||
void ServerLobby::configPeersStartTime()
|
||||
{
|
||||
uint32_t max_ping = 0;
|
||||
const unsigned max_ping_from_peers = UserConfigParams::m_max_ping;
|
||||
const unsigned max_ping_from_peers = ServerConfig::m_max_ping;
|
||||
for (auto p : m_peers_ready)
|
||||
{
|
||||
auto peer = p.first.lock();
|
||||
@ -2249,7 +2250,7 @@ void ServerLobby::configPeersStartTime()
|
||||
ns->addUInt8(LE_START_RACE).addUInt64(start_time);
|
||||
sendMessageToPeers(ns, /*reliable*/true);
|
||||
|
||||
const unsigned jitter_tolerance = UserConfigParams::m_jitter_tolerance;
|
||||
const unsigned jitter_tolerance = ServerConfig::m_jitter_tolerance;
|
||||
Log::info("ServerLobby", "Max ping from peers: %d, jitter tolerance: %d",
|
||||
max_ping, jitter_tolerance);
|
||||
// Delay server for max ping / 2 from peers and jitter tolerance.
|
||||
|
105
src/network/server_config.cpp
Normal file
105
src/network/server_config.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2018 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include <vector>
|
||||
|
||||
// The order here is important. If all_params is declared later (e.g. after
|
||||
// the #includes), all elements will be added to all_params, and then
|
||||
// g_server_params will be initialised, i.e. cleared!
|
||||
// ============================================================================
|
||||
class UserConfigParam;
|
||||
static std::vector<UserConfigParam*> g_server_params;
|
||||
// ============================================================================
|
||||
|
||||
// X-macros
|
||||
#define SERVER_CFG_PREFIX
|
||||
#define SERVER_CFG_DEFAULT(X) = X
|
||||
|
||||
#include "network/server_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
|
||||
namespace ServerConfig
|
||||
{
|
||||
// ============================================================================
|
||||
std::string g_server_config_path;
|
||||
// ============================================================================
|
||||
FloatServerConfigParam::FloatServerConfigParam(float default_value,
|
||||
const char* param_name,
|
||||
const char* comment)
|
||||
: FloatUserConfigParam(param_name, comment)
|
||||
{
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
g_server_params.push_back(this);
|
||||
} // FloatServerConfigParam
|
||||
|
||||
// ============================================================================
|
||||
IntServerConfigParam::IntServerConfigParam(int default_value,
|
||||
const char* param_name,
|
||||
const char* comment)
|
||||
: IntUserConfigParam(param_name, comment)
|
||||
{
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
g_server_params.push_back(this);
|
||||
} // IntServerConfigParam
|
||||
|
||||
// ============================================================================
|
||||
BoolServerConfigParam::BoolServerConfigParam(bool default_value,
|
||||
const char* param_name,
|
||||
const char* comment)
|
||||
: BoolUserConfigParam(param_name, comment)
|
||||
{
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
g_server_params.push_back(this);
|
||||
} // BoolServerConfigParam
|
||||
|
||||
// ============================================================================
|
||||
template<typename T, typename U>
|
||||
MapServerConfigParam<T, U>::MapServerConfigParam(const char* param_name,
|
||||
const char* comment,
|
||||
std::map<T, U> default_value)
|
||||
: MapUserConfigParam<T, U>(param_name, comment)
|
||||
{
|
||||
m_elements = default_value;
|
||||
g_server_params.push_back(this);
|
||||
} // MapServerConfigParam
|
||||
|
||||
// ============================================================================
|
||||
void loadServerConfig(const std::string& path)
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
g_server_config_path =
|
||||
file_manager->getUserConfigFile("server_config.xml");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_server_config_path = path;
|
||||
}
|
||||
|
||||
} // loadServerConfig
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void writeServerConfig()
|
||||
{
|
||||
} // writeServerConfig
|
||||
|
||||
}
|
||||
|
180
src/network/server_config.hpp
Normal file
180
src/network/server_config.hpp
Normal file
@ -0,0 +1,180 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2018 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_SERVER_CONFIG
|
||||
#define HEADER_SERVER_CONFIG
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
|
||||
#ifndef SERVER_CFG_PREFIX
|
||||
#define SERVER_CFG_PREFIX extern
|
||||
#endif
|
||||
|
||||
#ifndef SERVER_CFG_DEFAULT
|
||||
#define SERVER_CFG_DEFAULT(X)
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ServerConfig
|
||||
{
|
||||
// ========================================================================
|
||||
class FloatServerConfigParam : public FloatUserConfigParam
|
||||
{
|
||||
public:
|
||||
FloatServerConfigParam(float default_value, const char* param_name,
|
||||
const char* comment);
|
||||
using FloatUserConfigParam::operator=;
|
||||
};
|
||||
// ========================================================================
|
||||
class IntServerConfigParam : public IntUserConfigParam
|
||||
{
|
||||
public:
|
||||
IntServerConfigParam(int default_value, const char* param_name,
|
||||
const char* comment);
|
||||
using IntUserConfigParam::operator=;
|
||||
};
|
||||
// ========================================================================
|
||||
class BoolServerConfigParam : public BoolUserConfigParam
|
||||
{
|
||||
public:
|
||||
BoolServerConfigParam(bool default_value, const char* param_name,
|
||||
const char* comment);
|
||||
using BoolUserConfigParam::operator=;
|
||||
};
|
||||
// ========================================================================
|
||||
template<typename T, typename U>
|
||||
class MapServerConfigParam : public MapUserConfigParam<T, U>
|
||||
{
|
||||
private:
|
||||
using MapUserConfigParam<T, U>::m_elements;
|
||||
public:
|
||||
MapServerConfigParam(const char* param_name, const char* comment,
|
||||
std::map<T, U> default_value);
|
||||
using MapUserConfigParam<T, U>::operator=;
|
||||
};
|
||||
// ========================================================================
|
||||
typedef MapServerConfigParam<uint32_t, uint32_t> UIntToUIntServerConfigParam;
|
||||
typedef MapServerConfigParam<std::string, uint32_t>
|
||||
StringToUIntServerConfigParam;
|
||||
// ========================================================================
|
||||
void loadServerConfig(const std::string& path = "");
|
||||
void writeServerConfig();
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_voting_timeout
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(20.0f, "voting-timeout",
|
||||
"Timeout in seconds for voting tracks in server."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_validation_timeout
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(20.0f, "validation-timeout",
|
||||
"Timeout in seconds for validation of clients."));
|
||||
|
||||
SERVER_CFG_PREFIX IntServerConfigParam m_server_max_players
|
||||
SERVER_CFG_DEFAULT(IntServerConfigParam(8, "server-max-players",
|
||||
"Maximum number of players on the server, setting it more than "
|
||||
"8 will have performance degradation."));
|
||||
|
||||
SERVER_CFG_PREFIX BoolServerConfigParam m_firewalled_server
|
||||
SERVER_CFG_DEFAULT(BoolServerConfigParam(true, "firewalled-server",
|
||||
"Disable it to turn off all stun related code in server, "
|
||||
"it allows saving server resource if your server is not "
|
||||
"behind a firewall."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_start_game_counter
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(30.0f, "start-game-counter",
|
||||
"Time to wait before entering kart selection screen "
|
||||
"if satisfied start-game-threshold below for owner less or ranked "
|
||||
"server."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_start_game_threshold
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(0.5f, "start-game-threshold",
|
||||
"Only auto start kart selection when number of "
|
||||
"connected player is larger than max player * this value, for "
|
||||
"owner less or ranked server, after start-game-counter."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_flag_return_timemout
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(20.0f, "flag-return-timemout",
|
||||
"Time in seconds when a flag is dropped a by player in CTF "
|
||||
"returning to its own base."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_hit_limit_threshold
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(5.0f, "hit-limit-threshold",
|
||||
"Value used to calculate hit limit in free for all, which "
|
||||
"is min(number of players * hit-limit-threshold, 40), "
|
||||
"negative value to disable hit limit."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_time_limit_threshold_ffa
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(0.7f,
|
||||
"time-limit-threshold-ffa",
|
||||
"Value used to calculate time limit in free for all, which "
|
||||
"is max(number of players * time-limit-threshold-ffa, 3.0) * 60, "
|
||||
"negative value to disable time limit."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_capture_limit_threshold
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(0.7f,
|
||||
"capture-limit-threshold",
|
||||
"Value used to calculate capture limit in CTF, which "
|
||||
"is max(3.0, number of players * capture-limit-threshold), "
|
||||
"negative value to disable capture limit."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_time_limit_threshold_ctf
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(0.9f,
|
||||
"time-limit-threshold-ctf",
|
||||
"Value used to calculate time limit in CTF, which "
|
||||
"is max(3.0, number of players * "
|
||||
"(time-limit-threshold-ctf + flag-return-timemout / 60.0)) * 60.0,"
|
||||
" negative value to disable time limit."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_auto_lap_ratio
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(-1.0f, "auto-lap-ratio",
|
||||
"Value used by server to automatically calculate "
|
||||
"lap of each race in network game, if more than 0.0f, the number of "
|
||||
"lap of each track vote in linear race will be determined by "
|
||||
"max(1.0f, auto-lap-ratio * default lap of that track)."));
|
||||
|
||||
SERVER_CFG_PREFIX IntServerConfigParam m_max_ping
|
||||
SERVER_CFG_DEFAULT(IntServerConfigParam(300, "max-ping",
|
||||
"Maximum ping allowed for a player (in ms)."));
|
||||
|
||||
SERVER_CFG_PREFIX IntServerConfigParam m_jitter_tolerance
|
||||
SERVER_CFG_DEFAULT(IntServerConfigParam(100, "jitter-tolerance",
|
||||
"Tolerance of jitter in network allowed (in ms)."));
|
||||
|
||||
SERVER_CFG_PREFIX BoolServerConfigParam m_kick_high_ping_players
|
||||
SERVER_CFG_DEFAULT(BoolServerConfigParam(false,
|
||||
"kick-high-ping-players",
|
||||
"Kick players whose ping is above max-ping."));
|
||||
|
||||
SERVER_CFG_PREFIX StringToUIntServerConfigParam m_server_ip_ban_list
|
||||
SERVER_CFG_DEFAULT(StringToUIntServerConfigParam("server-ip-ban-list",
|
||||
"LHS: IP in X.X.X.X/Y (CIDR) format, use Y of 32 for a specific ip, "
|
||||
"RHS: time epoch to expire, "
|
||||
"if -1 (uint32_t max) than a permanent ban.",
|
||||
{ { "0.0.0.0/0", 0u } }));
|
||||
|
||||
SERVER_CFG_PREFIX UIntToUIntServerConfigParam m_server_online_id_ban_list
|
||||
SERVER_CFG_DEFAULT(UIntToUIntServerConfigParam(
|
||||
"server-online-id-ban-list",
|
||||
"LHS: online id, RHS: time epoch to expire, "
|
||||
"if -1 (uint32_t max) than a permanent ban.",
|
||||
{ { 0u, 0u } }));
|
||||
|
||||
}; // namespace ServerConfig
|
||||
|
||||
#endif // HEADER_SERVER_CONFIG
|
@ -30,6 +30,7 @@
|
||||
#include "network/protocols/connect_to_peer.hpp"
|
||||
#include "network/protocols/server_lobby.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/server_config.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/separate_process.hpp"
|
||||
@ -736,7 +737,7 @@ void STKHost::mainLoop()
|
||||
if (is_server)
|
||||
{
|
||||
std::unique_lock<std::mutex> peer_lock(m_peers_mutex);
|
||||
const float timeout = UserConfigParams::m_validation_timeout;
|
||||
const float timeout = ServerConfig::m_validation_timeout;
|
||||
bool need_ping = false;
|
||||
if (sl && (!sl->isRacing() || sl->allowJoinedPlayersWaiting()) &&
|
||||
last_ping_time < StkTime::getRealTimeMs())
|
||||
@ -759,8 +760,8 @@ void STKHost::mainLoop()
|
||||
m_peer_pings.getData()[p.second->getHostId()] =
|
||||
p.second->getPing();
|
||||
const unsigned ap = p.second->getAveragePing();
|
||||
const unsigned max_ping = UserConfigParams::m_max_ping;
|
||||
if (UserConfigParams::m_kick_high_ping_players &&
|
||||
const unsigned max_ping = ServerConfig::m_max_ping;
|
||||
if (ServerConfig::m_kick_high_ping_players &&
|
||||
p.second->isValidated() &&
|
||||
p.second->getConnectedTime() > 5.0f && ap > max_ping)
|
||||
{
|
||||
|
@ -53,13 +53,13 @@ void CreateServerScreen::loadedFromFile()
|
||||
|
||||
m_max_players_widget = getWidget<SpinnerWidget>("max_players");
|
||||
assert(m_max_players_widget != NULL);
|
||||
int max = UserConfigParams::m_server_max_players.getDefaultValue();
|
||||
int max = UserConfigParams::m_max_players.getDefaultValue();
|
||||
m_max_players_widget->setMax(max);
|
||||
|
||||
if (UserConfigParams::m_server_max_players > max)
|
||||
UserConfigParams::m_server_max_players = max;
|
||||
if (UserConfigParams::m_max_players > max)
|
||||
UserConfigParams::m_max_players = max;
|
||||
|
||||
m_max_players_widget->setValue(UserConfigParams::m_server_max_players);
|
||||
m_max_players_widget->setValue(UserConfigParams::m_max_players);
|
||||
|
||||
m_info_widget = getWidget<LabelWidget>("info");
|
||||
assert(m_info_widget != NULL);
|
||||
@ -240,9 +240,9 @@ void CreateServerScreen::createServer()
|
||||
return;
|
||||
}
|
||||
assert(max_players > 1 && max_players <=
|
||||
UserConfigParams::m_server_max_players.getDefaultValue());
|
||||
UserConfigParams::m_max_players.getDefaultValue());
|
||||
|
||||
UserConfigParams::m_server_max_players = max_players;
|
||||
UserConfigParams::m_max_players = max_players;
|
||||
std::string password = StringUtils::wideToUtf8(getWidget<TextBoxWidget>
|
||||
("password")->getText());
|
||||
if ((!password.empty() != 0 &&
|
||||
|
Loading…
Reference in New Issue
Block a user