Allow real addon kart hitbox if live-spectate disabled

This commit is contained in:
Benau 2020-07-21 00:58:14 +08:00
parent 4270533f07
commit 4c9617139f
10 changed files with 45 additions and 21 deletions

View File

@ -104,7 +104,7 @@ The current server configuration xml looks like this:
<!-- Automatically end linear race game after 1st player finished for some time (currently his finished time * 0.25 + 15.0). -->
<auto-end value="false" />
<!-- Enable team choosing in lobby in team game (soccer and CTF). If owner-less is enabled and live-players is not enabled, than this option is always disabled. -->
<!-- Enable team choosing in lobby in team game (soccer and CTF). If owner-less is enabled and live-spectate is not enabled, than this option is always disabled. -->
<team-choosing value="true" />
<!-- If strict-players is on, no duplicated online id or split screen players are allowed, which can prevent someone using more than 1 network AI with this server. -->
@ -116,7 +116,7 @@ The current server configuration xml looks like this:
<!-- If true, the server owner can config the difficulty and game mode in the GUI of lobby. This option cannot be used with owner-less or grand prix server, and will be automatically turned on if the server was created using the in-game GUI. The changed difficulty and game mode will not be saved in this config file. -->
<server-configurable value="false" />
<!-- If true, players can live join or spectate the in-progress game. Currently live joining is only available if the current game mode used in server is FFA, CTF or soccer, also official-karts-threshold will be made 1.0. -->
<!-- If true, players can live join or spectate the in-progress game. Currently live joining is only available if the current game mode used in server is FFA, CTF or soccer, also official-karts-threshold will be made 1.0. If false addon karts will use their original hitbox other than tux, all players having it restriction applies. -->
<live-spectate value="true" />
<!-- Time in seconds when a flag is dropped a by player in CTF returning to its own base. -->
@ -140,10 +140,10 @@ The current server configuration xml looks like this:
<!-- Value used by server to automatically estimate each game time. For races, it decides the 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-game-time-ratio * default lap of that track). For soccer if more than 0.0f, for time limit game it will be auto-game-time-ratio * soccer-time-limit in UserConfig, for goal limit game it will be auto-game-time-ratio * numgoals in UserConfig, -1 to disable for all. -->
<auto-game-time-ratio value="-1" />
<!-- Maximum ping allowed for a player (in ms), it's recommended to use default value if live-players is on. -->
<!-- Maximum ping allowed for a player (in ms), it's recommended to use default value if live-spectate is on. -->
<max-ping value="300" />
<!-- Tolerance of jitter in network allowed (in ms), it's recommended to use default value if live-players is on. -->
<!-- Tolerance of jitter in network allowed (in ms), it's recommended to use default value if live-spectate is on. -->
<jitter-tolerance value="100" />
<!-- Kick players whose ping is above max-ping. -->

View File

@ -80,7 +80,8 @@ void AbstractKart::loadKartProperties(const std::string& new_ident,
m_kart_properties.reset(new KartProperties());
const KartProperties* kp = kart_properties_manager->getKart(new_ident);
const KartProperties* kp_addon = NULL;
if (NetworkConfig::get()->isNetworking() && kp && kp->isAddon())
if (NetworkConfig::get()->isNetworking() &&
NetworkConfig::get()->useTuxHitboxAddon() && kp && kp->isAddon())
{
// For addon kart in network we use the same hitbox (tux) so anyone
// can use any addon karts with different graphical kart model
@ -89,7 +90,8 @@ void AbstractKart::loadKartProperties(const std::string& new_ident,
}
if (kp == NULL)
{
if (!NetworkConfig::get()->isNetworking())
if (!NetworkConfig::get()->isNetworking() ||
!NetworkConfig::get()->useTuxHitboxAddon())
{
Log::warn("Abstract_Kart", "Unknown kart %s, fallback to tux",
new_ident.c_str());

View File

@ -153,6 +153,7 @@ NetworkConfig::NetworkConfig()
m_state_frequency = 10;
m_nat64_prefix_data.fill(-1);
m_num_fixed_ai = 0;
m_tux_hitbox_addon = false;
} // NetworkConfig
// ----------------------------------------------------------------------------

View File

@ -92,6 +92,9 @@ private:
* AI. (usually used together with ai-handling in server config) */
bool m_network_ai_instance;
/** When live join is disabled addon kart will use their real hitbox */
bool m_tux_hitbox_addon;
/** No. of fixed AI in all-in-one graphical client server, the player
* connecting with 127.* or ::1/128 will be in charged of controlling the
* AI. */
@ -308,6 +311,10 @@ public:
// ------------------------------------------------------------------------
static const std::vector<std::pair<std::string, int> >&
getStunList(bool ipv4);
// ------------------------------------------------------------------------
void setTuxHitboxAddon(bool val) { m_tux_hitbox_addon = val; }
// ------------------------------------------------------------------------
bool useTuxHitboxAddon() const { return m_tux_hitbox_addon; }
}; // class NetworkConfig
#endif // HEADER_NETWORK_CONFIG

View File

@ -764,6 +764,7 @@ void ClientLobby::handleServerInfo(Event* event)
if (!GUIEngine::isNoGraphics())
NetworkingLobby::getInstance()->toggleServerConfigButton(server_config);
m_server_live_joinable = data.getUInt8() == 1;
NetworkConfig::get()->setTuxHitboxAddon(m_server_live_joinable);
} // handleServerInfo
//-----------------------------------------------------------------------------

View File

@ -582,7 +582,10 @@ void ServerLobby::updateAddons()
auto all_k = kart_properties_manager->getAllAvailableKarts();
if (all_k.size() >= 65536)
all_k.resize(65535);
m_available_kts.first = m_official_kts.first;
if (ServerConfig::m_live_players)
m_available_kts.first = m_official_kts.first;
else
m_available_kts.first = { all_k.begin(), all_k.end() };
} // updateAddons
//-----------------------------------------------------------------------------
@ -700,7 +703,11 @@ void ServerLobby::setup()
auto all_k = kart_properties_manager->getAllAvailableKarts();
if (all_k.size() >= 65536)
all_k.resize(65535);
m_available_kts.first = m_official_kts.first;
if (ServerConfig::m_live_players)
m_available_kts.first = m_official_kts.first;
else
m_available_kts.first = { all_k.begin(), all_k.end() };
NetworkConfig::get()->setTuxHitboxAddon(ServerConfig::m_live_players);
updateTracksForMode();
m_server_has_loaded_world.store(false);

View File

@ -234,7 +234,7 @@ namespace ServerConfig
SERVER_CFG_PREFIX BoolServerConfigParam m_team_choosing
SERVER_CFG_DEFAULT(BoolServerConfigParam(true, "team-choosing",
"Enable team choosing in lobby in team game (soccer and CTF). "
"If owner-less is enabled and live-players is not enabled, than this "
"If owner-less is enabled and live-spectate is not enabled, than this "
"option is always disabled."));
SERVER_CFG_PREFIX BoolServerConfigParam m_strict_players
@ -263,7 +263,8 @@ namespace ServerConfig
"If true, players can live join or spectate the in-progress game. "
"Currently live joining is only available if the current game mode "
"used in server is FFA, CTF or soccer, also official-karts-threshold "
"will be made 1.0."));
"will be made 1.0. If false addon karts will use their original "
"hitbox other than tux, all players having it restriction applies."));
SERVER_CFG_PREFIX FloatServerConfigParam m_flag_return_timeout
SERVER_CFG_DEFAULT(FloatServerConfigParam(20.0f, "flag-return-timeout",
@ -307,12 +308,12 @@ namespace ServerConfig
SERVER_CFG_PREFIX IntServerConfigParam m_max_ping
SERVER_CFG_DEFAULT(IntServerConfigParam(300, "max-ping",
"Maximum ping allowed for a player (in ms), it's recommended to use "
"default value if live-players is on."));
"default value if live-spectate is on."));
SERVER_CFG_PREFIX IntServerConfigParam m_jitter_tolerance
SERVER_CFG_DEFAULT(IntServerConfigParam(100, "jitter-tolerance",
"Tolerance of jitter in network allowed (in ms), it's recommended to "
"use default value if live-players is on."));
"use default value if live-spectate is on."));
SERVER_CFG_PREFIX BoolServerConfigParam m_kick_high_ping_players
SERVER_CFG_DEFAULT(BoolServerConfigParam(false,

View File

@ -869,7 +869,8 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id,
const KartProperties *kp =
kart_properties_manager->getKart(selection);
// Adjust for online addon karts
if (kp && kp->isAddon() && NetworkConfig::get()->isNetworking())
if (kp && kp->isAddon() && NetworkConfig::get()->isNetworking() &&
NetworkConfig::get()->useTuxHitboxAddon())
kp = kart_properties_manager->getKart("tux");
if (kp != NULL)
{

View File

@ -196,3 +196,14 @@ void NetworkKartSelectionScreen::updateProgressBarText()
m_timer->setText(message);
}
} // updateProgressBarText
// ----------------------------------------------------------------------------
bool NetworkKartSelectionScreen::isIgnored(const std::string& ident) const
{
// Online addon kart use tux for hitbox in server so we can allow any
// addon kart graphically, if live join is disabled
if (NetworkConfig::get()->useTuxHitboxAddon() &&
ident.find("addon_") != std::string::npos)
return false;
return m_available_karts.find(ident) == m_available_karts.end();
} // isIgnored

View File

@ -60,14 +60,7 @@ private:
std::set<std::string> m_available_karts;
// ------------------------------------------------------------------------
virtual bool isIgnored(const std::string& ident) const OVERRIDE
{
// Online addon kart use tux for hitbox in server so we can allow any
// addon kart graphically
if (ident.find("addon_") != std::string::npos)
return false;
return m_available_karts.find(ident) == m_available_karts.end();
}
virtual bool isIgnored(const std::string& ident) const OVERRIDE;
// ------------------------------------------------------------------------
void updateProgressBarText();
// ------------------------------------------------------------------------