Add the possibility to disable track voting in server
This commit is contained in:
parent
e0de1318d2
commit
091e9e0f1e
@ -98,6 +98,7 @@ ClientLobby::ClientLobby(const TransportAddress& a, std::shared_ptr<Server> s)
|
||||
m_server_live_joinable = false;
|
||||
m_server_send_live_load_world = false;
|
||||
m_server_enabled_chat = true;
|
||||
m_server_enabled_track_voting = true;
|
||||
} // ClientLobby
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -938,6 +939,7 @@ void ClientLobby::startSelection(Event* event)
|
||||
startVotingPeriod(data.getFloat());
|
||||
bool skip_kart_screen = data.getUInt8() == 1;
|
||||
m_server_auto_game_time = data.getUInt8() == 1;
|
||||
m_server_enabled_track_voting = data.getUInt8() == 1;
|
||||
const unsigned kart_num = data.getUInt16();
|
||||
const unsigned track_num = data.getUInt16();
|
||||
m_available_karts.clear();
|
||||
@ -964,7 +966,8 @@ void ClientLobby::startSelection(Event* event)
|
||||
screen->setLiveJoin(false);
|
||||
// In case of auto-connect or continue a grand prix, use random karts
|
||||
// (or previous kart) from server and go to track selection
|
||||
if (NetworkConfig::get()->isAutoConnect() || skip_kart_screen)
|
||||
if ((NetworkConfig::get()->isAutoConnect() || skip_kart_screen) &&
|
||||
m_server_enabled_track_voting)
|
||||
{
|
||||
input_manager->setMasterPlayerOnly(true);
|
||||
for (auto& p : NetworkConfig::get()->getNetworkPlayers())
|
||||
|
@ -105,6 +105,8 @@ private:
|
||||
|
||||
bool m_server_enabled_chat;
|
||||
|
||||
bool m_server_enabled_track_voting;
|
||||
|
||||
uint64_t m_auto_back_to_lobby_time;
|
||||
|
||||
uint64_t m_start_live_game_time;
|
||||
@ -165,6 +167,8 @@ public:
|
||||
Input::InputType type) const;
|
||||
void addSpectateHelperMessage() const;
|
||||
bool serverEnabledChat() const { return m_server_enabled_chat; }
|
||||
bool serverEnabledTrackVoting() const
|
||||
{ return m_server_enabled_track_voting; }
|
||||
};
|
||||
|
||||
#endif // CLIENT_LOBBY_HPP
|
||||
|
@ -572,7 +572,14 @@ void ServerLobby::asynchronousUpdate()
|
||||
{
|
||||
PeerVote winner_vote;
|
||||
m_winner_peer_id = std::numeric_limits<uint32_t>::max();
|
||||
bool go_on_race = handleAllVotes(&winner_vote, &m_winner_peer_id);
|
||||
bool go_on_race = false;
|
||||
if (ServerConfig::m_track_voting)
|
||||
go_on_race = handleAllVotes(&winner_vote, &m_winner_peer_id);
|
||||
else if (m_game_setup->isGrandPrixStarted() || isVotingOver())
|
||||
{
|
||||
winner_vote = *m_default_vote;
|
||||
go_on_race = true;
|
||||
}
|
||||
if (go_on_race)
|
||||
{
|
||||
*m_default_vote = winner_vote;
|
||||
@ -1407,11 +1414,15 @@ void ServerLobby::startSelection(const Event *event)
|
||||
Track* t = track_manager->getTrack(*it);
|
||||
assert(t);
|
||||
m_default_vote->m_num_laps = t->getDefaultNumberOfLaps();
|
||||
m_default_vote->m_reverse =
|
||||
m_default_vote->m_track_name.size() % 2 == 0;
|
||||
m_default_vote->m_reverse = rg.get(2) == 0;
|
||||
break;
|
||||
}
|
||||
case RaceManager::MINOR_MODE_FREE_FOR_ALL:
|
||||
{
|
||||
m_default_vote->m_num_laps = 0;
|
||||
m_default_vote->m_reverse = rg.get(2) == 0;
|
||||
break;
|
||||
}
|
||||
case RaceManager::MINOR_MODE_CAPTURE_THE_FLAG:
|
||||
{
|
||||
m_default_vote->m_num_laps = 0;
|
||||
@ -1420,8 +1431,21 @@ void ServerLobby::startSelection(const Event *event)
|
||||
}
|
||||
case RaceManager::MINOR_MODE_SOCCER:
|
||||
{
|
||||
m_default_vote->m_num_laps = 3;
|
||||
m_default_vote->m_reverse = 0;
|
||||
if (m_game_setup->isSoccerGoalTarget())
|
||||
{
|
||||
m_default_vote->m_num_laps =
|
||||
(uint8_t)(UserConfigParams::m_num_goals);
|
||||
if (m_default_vote->m_num_laps > 10)
|
||||
m_default_vote->m_num_laps = (uint8_t)5;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_default_vote->m_num_laps =
|
||||
(uint8_t)(UserConfigParams::m_soccer_time_limit);
|
||||
if (m_default_vote->m_num_laps > 15)
|
||||
m_default_vote->m_num_laps = (uint8_t)7;
|
||||
}
|
||||
m_default_vote->m_reverse = rg.get(2) == 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1446,7 +1470,8 @@ void ServerLobby::startSelection(const Event *event)
|
||||
ns->addUInt8(LE_START_SELECTION)
|
||||
.addFloat(ServerConfig::m_voting_timeout)
|
||||
.addUInt8(m_game_setup->isGrandPrixStarted() ? 1 : 0)
|
||||
.addUInt8(ServerConfig::m_auto_game_time_ratio > 0.0f ? 1 : 0);
|
||||
.addUInt8(ServerConfig::m_auto_game_time_ratio > 0.0f ? 1 : 0)
|
||||
.addUInt8(ServerConfig::m_track_voting ? 1 : 0);
|
||||
|
||||
const auto& all_k = m_available_kts.first;
|
||||
const auto& all_t = m_available_kts.second;
|
||||
@ -2465,7 +2490,7 @@ void ServerLobby::kartSelectionRequested(Event* event)
|
||||
*/
|
||||
void ServerLobby::handlePlayerVote(Event* event)
|
||||
{
|
||||
if (m_state != SELECTING)
|
||||
if (m_state != SELECTING || !ServerConfig::m_track_voting)
|
||||
{
|
||||
Log::warn("ServerLobby", "Received track vote while in state %d.",
|
||||
m_state.load());
|
||||
|
@ -148,9 +148,16 @@ namespace ServerConfig
|
||||
SERVER_CFG_DEFAULT(BoolServerConfigParam(true, "chat",
|
||||
"If off this server will ignore chat message from all players."));
|
||||
|
||||
SERVER_CFG_PREFIX BoolServerConfigParam m_track_voting
|
||||
SERVER_CFG_DEFAULT(BoolServerConfigParam(true, "track-voting",
|
||||
"Allow players to vote track to play, if off server will pick next "
|
||||
"track to play randomly."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_voting_timeout
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(30.0f, "voting-timeout",
|
||||
"Timeout in seconds for voting tracks in server."));
|
||||
"Timeout in seconds for selecting karts and (or) voting tracks in "
|
||||
"server, you may want to use a lower value if you have track-voting "
|
||||
"off."));
|
||||
|
||||
SERVER_CFG_PREFIX FloatServerConfigParam m_validation_timeout
|
||||
SERVER_CFG_DEFAULT(FloatServerConfigParam(20.0f, "validation-timeout",
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "guiengine/widgets/progress_bar_widget.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "network/network_config.hpp"
|
||||
#include "network/protocols/lobby_protocol.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/online/tracks_screen.hpp"
|
||||
@ -32,6 +32,7 @@ using namespace GUIEngine;
|
||||
void NetworkKartSelectionScreen::init()
|
||||
{
|
||||
assert(!NetworkConfig::get()->isAddingNetworkPlayers());
|
||||
m_all_players_done = false;
|
||||
m_multiplayer = NetworkConfig::get()->getNetworkPlayers().size() != 1;
|
||||
KartSelectionScreen::init();
|
||||
|
||||
@ -88,6 +89,7 @@ void NetworkKartSelectionScreen::onUpdate(float dt)
|
||||
// ----------------------------------------------------------------------------
|
||||
void NetworkKartSelectionScreen::allPlayersDone()
|
||||
{
|
||||
m_all_players_done = true;
|
||||
input_manager->setMasterPlayerOnly(true);
|
||||
|
||||
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
|
||||
@ -128,7 +130,8 @@ void NetworkKartSelectionScreen::allPlayersDone()
|
||||
|
||||
// ---- Switch to assign mode
|
||||
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
|
||||
if (!m_live_join)
|
||||
auto cl = LobbyProtocol::get<ClientLobby>();
|
||||
if (!m_live_join && cl && cl->serverEnabledTrackVoting())
|
||||
{
|
||||
TracksScreen::getInstance()->setNetworkTracks();
|
||||
TracksScreen::getInstance()->push();
|
||||
@ -140,6 +143,13 @@ bool NetworkKartSelectionScreen::onEscapePressed()
|
||||
{
|
||||
if (!m_live_join)
|
||||
{
|
||||
/*auto cl = LobbyProtocol::get<ClientLobby>();
|
||||
if (m_all_players_done && cl && !cl->serverEnabledTrackVoting())
|
||||
{
|
||||
// TODO: Allow players to re-choose kart(s) if no track voting
|
||||
init();
|
||||
return false;
|
||||
}*/
|
||||
if (m_exit_timeout == std::numeric_limits<uint64_t>::max())
|
||||
{
|
||||
// Send go back lobby event to server with an exit timeout, so if
|
||||
|
@ -40,6 +40,8 @@ private:
|
||||
|
||||
bool m_live_join;
|
||||
|
||||
bool m_all_players_done;
|
||||
|
||||
uint64_t m_exit_timeout;
|
||||
protected:
|
||||
// ------------------------------------------------------------------------
|
||||
@ -47,6 +49,7 @@ protected:
|
||||
: KartSelectionScreen("online/network_karts.stkgui")
|
||||
{
|
||||
m_live_join = false;
|
||||
m_all_players_done = false;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
~NetworkKartSelectionScreen() {}
|
||||
|
Loading…
Reference in New Issue
Block a user