Use a more server owner friendly value instead of threshold
This commit is contained in:
parent
4c6d535f00
commit
e5f5a1c04d
@ -1228,10 +1228,9 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
|
||||
|
||||
if (CommandLine::has("--min-players", &n))
|
||||
{
|
||||
float threshold = ((float)(n) - 0.5f) /
|
||||
ServerConfig::m_server_max_players;
|
||||
threshold = std::max(std::min(threshold, 1.0f), 0.0f);
|
||||
ServerConfig::m_start_game_threshold = threshold;
|
||||
if (n > ServerConfig::m_server_max_players)
|
||||
n = 1;
|
||||
ServerConfig::m_min_start_game_players = n;
|
||||
}
|
||||
if (CommandLine::has("--port", &n))
|
||||
{
|
||||
|
@ -216,12 +216,11 @@ void GameSetup::addServerInfo(NetworkString* ns)
|
||||
}
|
||||
if (ServerConfig::m_owner_less)
|
||||
{
|
||||
ns->addFloat(ServerConfig::m_start_game_threshold)
|
||||
ns->addUInt8(ServerConfig::m_min_start_game_players)
|
||||
.addFloat(ServerConfig::m_start_game_counter);
|
||||
}
|
||||
else
|
||||
ns->addFloat(0.0f).addFloat(0.0f);
|
||||
ns->addUInt8(ServerConfig::m_server_max_players);
|
||||
ns->addUInt8(0).addFloat(0.0f);
|
||||
|
||||
ns->encodeString16(m_message_of_today);
|
||||
} // addServerInfo
|
||||
|
@ -574,9 +574,9 @@ void ClientLobby::handleServerInfo(Event* event)
|
||||
each_line = _("Difficulty: %s", difficulty_name);
|
||||
NetworkingLobby::getInstance()->addMoreServerInfo(each_line);
|
||||
|
||||
u_data = data.getUInt8();
|
||||
unsigned max_player = data.getUInt8();
|
||||
//I18N: In the networking lobby
|
||||
each_line = _("Max players: %d", (int)u_data);
|
||||
each_line = _("Max players: %d", (int)max_player);
|
||||
NetworkingLobby::getInstance()->addMoreServerInfo(each_line);
|
||||
|
||||
u_data = data.getUInt8();
|
||||
@ -627,11 +627,10 @@ void ClientLobby::handleServerInfo(Event* event)
|
||||
}
|
||||
}
|
||||
// Auto start info
|
||||
float start_threshold = data.getFloat();
|
||||
unsigned min_players = data.getUInt8();
|
||||
float start_timeout = data.getFloat();
|
||||
unsigned max_player = data.getUInt8();
|
||||
NetworkingLobby::getInstance()->initAutoStartTimer(grand_prix_started,
|
||||
start_threshold, start_timeout, max_player);
|
||||
min_players, start_timeout, max_player);
|
||||
|
||||
// MOTD
|
||||
core::stringw motd;
|
||||
|
@ -437,10 +437,8 @@ void ServerLobby::asynchronousUpdate()
|
||||
{
|
||||
if (ServerConfig::m_owner_less)
|
||||
{
|
||||
float player_size = (float)m_game_setup->getPlayerCount();
|
||||
if ((player_size >=
|
||||
(float)ServerConfig::m_server_max_players *
|
||||
ServerConfig::m_start_game_threshold ||
|
||||
int player_size = m_game_setup->getPlayerCount();
|
||||
if ((player_size >= ServerConfig::m_min_start_game_players ||
|
||||
m_game_setup->isGrandPrixStarted()) &&
|
||||
m_timeout.load() == std::numeric_limits<int64_t>::max())
|
||||
{
|
||||
@ -448,9 +446,7 @@ void ServerLobby::asynchronousUpdate()
|
||||
(int64_t)
|
||||
(ServerConfig::m_start_game_counter * 1000.0f));
|
||||
}
|
||||
else if (player_size <
|
||||
(float)ServerConfig::m_server_max_players*
|
||||
ServerConfig::m_start_game_threshold &&
|
||||
else if (player_size < ServerConfig::m_min_start_game_players &&
|
||||
!m_game_setup->isGrandPrixStarted())
|
||||
{
|
||||
m_timeout.store(std::numeric_limits<int64_t>::max());
|
||||
|
@ -275,7 +275,11 @@ void loadServerLobbyFromConfig()
|
||||
m_owner_less = true;
|
||||
}
|
||||
if (m_owner_less)
|
||||
{
|
||||
if (m_min_start_game_players > m_server_max_players)
|
||||
m_min_start_game_players = 1;
|
||||
m_team_choosing = false;
|
||||
}
|
||||
|
||||
const bool is_soccer =
|
||||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
|
||||
|
@ -176,10 +176,10 @@ namespace ServerConfig
|
||||
"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",
|
||||
SERVER_CFG_PREFIX IntServerConfigParam m_min_start_game_players
|
||||
SERVER_CFG_DEFAULT(IntServerConfigParam(2, "min-start-game-players",
|
||||
"Only auto start kart selection when number of "
|
||||
"connected player is larger than max player * this value, for "
|
||||
"connected player is larger than or equals this value, for "
|
||||
"owner less or ranked server, after start-game-counter."));
|
||||
|
||||
SERVER_CFG_PREFIX BoolServerConfigParam m_auto_end
|
||||
|
@ -143,8 +143,9 @@ void NetworkingLobby::init()
|
||||
m_allow_change_team = false;
|
||||
m_has_auto_start_in_server = false;
|
||||
m_ping_update_timer = 0.0f;
|
||||
m_cur_starting_timer = m_start_threshold = m_start_timeout =
|
||||
m_cur_starting_timer = m_start_timeout =
|
||||
m_server_max_player = std::numeric_limits<float>::max();
|
||||
m_min_start_game_players = 0;
|
||||
m_timeout_message->setVisible(false);
|
||||
|
||||
//I18N: In the networking lobby
|
||||
@ -252,13 +253,13 @@ void NetworkingLobby::onUpdate(float delta)
|
||||
if (m_has_auto_start_in_server && m_player_list)
|
||||
{
|
||||
m_timeout_message->setVisible(true);
|
||||
float cur_player = (float)(m_player_list->getItemCount());
|
||||
if (cur_player >= m_server_max_player * m_start_threshold &&
|
||||
unsigned cur_player = m_player_list->getItemCount();
|
||||
if (cur_player >= m_min_start_game_players &&
|
||||
m_cur_starting_timer == std::numeric_limits<float>::max())
|
||||
{
|
||||
m_cur_starting_timer = m_start_timeout;
|
||||
}
|
||||
else if (cur_player < m_server_max_player * m_start_threshold)
|
||||
else if (cur_player < m_min_start_game_players)
|
||||
{
|
||||
m_cur_starting_timer = std::numeric_limits<float>::max();
|
||||
//I18N: In the networking lobby, display the number of players
|
||||
@ -266,7 +267,7 @@ void NetworkingLobby::onUpdate(float delta)
|
||||
core::stringw msg =
|
||||
_P("Game will start if there is more than %d player.",
|
||||
"Game will start if there are more than %d players.",
|
||||
(int)ceil(m_server_max_player * m_start_threshold) - 1);
|
||||
(int)(m_min_start_game_players - 1));
|
||||
m_timeout_message->setText(msg, true);
|
||||
}
|
||||
|
||||
@ -534,15 +535,15 @@ void NetworkingLobby::cleanAddedPlayers()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void NetworkingLobby::initAutoStartTimer(bool grand_prix_started,
|
||||
float start_threshold,
|
||||
unsigned min_players,
|
||||
float start_timeout,
|
||||
unsigned server_max_player)
|
||||
{
|
||||
if (start_threshold == 0.0f || start_timeout == 0.0f)
|
||||
if (min_players == 0 || start_timeout == 0.0f)
|
||||
return;
|
||||
|
||||
m_has_auto_start_in_server = true;
|
||||
m_start_threshold = grand_prix_started ? 0.0f : start_threshold;
|
||||
m_min_start_game_players = grand_prix_started ? 0 : min_players;
|
||||
m_start_timeout = start_timeout;
|
||||
m_server_max_player = (float)server_max_player;
|
||||
} // initAutoStartTimer
|
||||
|
@ -71,8 +71,9 @@ private:
|
||||
std::vector<core::stringw> m_server_info;
|
||||
int m_server_info_height;
|
||||
|
||||
float m_cur_starting_timer, m_start_threshold, m_start_timeout,
|
||||
float m_cur_starting_timer, m_start_timeout,
|
||||
m_server_max_player;
|
||||
unsigned m_min_start_game_players;
|
||||
|
||||
bool m_allow_change_team, m_has_auto_start_in_server;
|
||||
|
||||
@ -137,7 +138,7 @@ public:
|
||||
KartTeam> >& p);
|
||||
void addSplitscreenPlayer(irr::core::stringw name);
|
||||
void cleanAddedPlayers();
|
||||
void initAutoStartTimer(bool grand_prix_started, float start_threshold,
|
||||
void initAutoStartTimer(bool grand_prix_started, unsigned min_players,
|
||||
float start_timeout, unsigned server_max_player);
|
||||
void setStartingTimerTo(float t) { m_cur_starting_timer = t; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user