Change int to int map to uint32_t for server ban list

This commit is contained in:
Benau 2018-03-12 12:39:16 +08:00
parent 93c910f18b
commit bb3bcdca3e
4 changed files with 23 additions and 13 deletions

View File

@ -184,7 +184,7 @@ public:
return m_elements[key];
}
}; // ListUserConfigParam
typedef MapUserConfigParam<int, int> IntToIntUserConfigParam;
typedef MapUserConfigParam<uint32_t, uint32_t> UIntToUIntUserConfigParam;
// ============================================================================
class IntUserConfigParam : public UserConfigParam
{
@ -732,11 +732,11 @@ namespace UserConfigParams
"stun.ivao.aero") );
// ---- Gamemode setup
PARAM_PREFIX IntToIntUserConfigParam m_num_karts_per_gamemode
PARAM_DEFAULT(IntToIntUserConfigParam("num_karts_per_gamemode",
PARAM_PREFIX UIntToUIntUserConfigParam m_num_karts_per_gamemode
PARAM_DEFAULT(UIntToUIntUserConfigParam("num_karts_per_gamemode",
"The Number of karts per gamemode.",
1,
std::make_pair(1100, 4)
std::make_pair(1100u, 4u)
));
// ---- Network
@ -749,6 +749,15 @@ namespace UserConfigParams
PARAM_DEFAULT(BoolUserConfigParam(true, "randrom-ports",
&m_network_group, "Use random ports for client and server connection"));
// ---- Gamemode setup
PARAM_PREFIX UIntToUIntUserConfigParam m_server_ban_list
PARAM_DEFAULT(UIntToUIntUserConfigParam("server_ban_list",
"LHS: IP in 32bit format, RHS: online id, if 0 than all players "
"from this IP will be banned.",
1,
std::make_pair(0u, 0u)
));
// ---- Graphic Quality
PARAM_PREFIX GroupUserConfigParam m_graphics_quality
PARAM_DEFAULT( GroupUserConfigParam("GFX",

View File

@ -16,8 +16,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_USER_INFO_DIALOG_HPP
#define HEADER_USER_INFO_DIALOG_HPP
#ifndef HEADER_NETWORK_USER_DIALOG_HPP
#define HEADER_NETWORK_USER_DIALOG_HPP
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"

View File

@ -234,9 +234,9 @@ void GPInfoScreen::init()
{
const int local_players = race_manager->getNumLocalPlayers();
int min_ai = 0;
int num_ai = UserConfigParams::m_num_karts_per_gamemode[RaceManager::MAJOR_MODE_GRAND_PRIX]
- local_players;
int num_ai = int(UserConfigParams::m_num_karts_per_gamemode
[RaceManager::MAJOR_MODE_GRAND_PRIX]) - local_players;
// A ftl reace needs at least three karts to make any sense
if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
{

View File

@ -167,12 +167,13 @@ void TrackInfoScreen::init()
if (has_AI)
{
m_ai_kart_spinner->setActive(true);
int num_ai = UserConfigParams::m_num_karts_per_gamemode[race_manager->getMinorMode()] - local_players;
int num_ai = int(UserConfigParams::m_num_karts_per_gamemode
[race_manager->getMinorMode()]) - local_players;
// Avoid negative numbers (which can happen if e.g. the number of karts
// in a previous race was lower than the number of players now.
if (num_ai < 0) num_ai = 0;
m_ai_kart_spinner->setValue(num_ai);